* Copyright (c) 2009 Colin McQuillian
* Copyright (c) 2010 Josh Allmann
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
struct PayloadContext {
unsigned ident; ///< 24-bit stream configuration identifier
uint32_t timestamp;
- ByteIOContext* fragment; ///< buffer for split payloads
+ AVIOContext* fragment; ///< buffer for split payloads
uint8_t *split_buf;
int split_pos, split_buf_len, split_buf_size;
int split_pkts;
{
if (data->fragment) {
uint8_t* p;
- url_close_dyn_buf(data->fragment, &p);
+ avio_close_dyn_buf(data->fragment, &p);
av_free(p);
data->fragment = NULL;
}
av_free(data);
}
-static int xiph_handle_packet(AVFormatContext * ctx,
- PayloadContext * data,
- AVStream * st,
- AVPacket * pkt,
- uint32_t * timestamp,
- const uint8_t * buf, int len, int flags)
+static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
+ AVStream *st, AVPacket *pkt, uint32_t *timestamp,
+ const uint8_t *buf, int len, uint16_t seq,
+ int flags)
{
int ident, fragmented, tdt, num_pkts, pkt_len;
// end packet has been lost somewhere, so drop buffered data
free_fragment_if_needed(data);
- if((res = url_open_dyn_buf(&data->fragment)) < 0)
+ if((res = avio_open_dyn_buf(&data->fragment)) < 0)
return res;
- put_buffer(data->fragment, buf, pkt_len);
+ avio_write(data->fragment, buf, pkt_len);
data->timestamp = *timestamp;
} else {
}
// copy data to fragment buffer
- put_buffer(data->fragment, buf, pkt_len);
+ avio_write(data->fragment, buf, pkt_len);
if (fragmented == 3) {
// end of xiph data packet
- av_init_packet(pkt);
- pkt->size = url_close_dyn_buf(data->fragment, &pkt->data);
-
- if (pkt->size < 0) {
+ int ret = ff_rtp_finalize_packet(pkt, &data->fragment, st->index);
+ if (ret < 0) {
av_log(ctx, AV_LOG_ERROR,
"Error occurred when getting fragment buffer.");
- return pkt->size;
+ return ret;
}
- pkt->stream_index = st->index;
- pkt->destruct = av_destruct_packet;
-
- data->fragment = NULL;
-
return 0;
}
}
/**
* Based off parse_packed_headers in Vorbis RTP
*/
-static unsigned int
+static int
parse_packed_headers(const uint8_t * packed_headers,
const uint8_t * packed_headers_end,
AVCodecContext * codec, PayloadContext * xiph_data)
if (!strcmp(attr, "sampling")) {
if (!strcmp(value, "YCbCr-4:2:0")) {
- codec->pix_fmt = PIX_FMT_YUV420P;
+ codec->pix_fmt = AV_PIX_FMT_YUV420P;
} else if (!strcmp(value, "YCbCr-4:4:2")) {
- codec->pix_fmt = PIX_FMT_YUV422P;
+ codec->pix_fmt = AV_PIX_FMT_YUV422P;
} else if (!strcmp(value, "YCbCr-4:4:4")) {
- codec->pix_fmt = PIX_FMT_YUV444P;
+ codec->pix_fmt = AV_PIX_FMT_YUV444P;
} else {
av_log(codec, AV_LOG_ERROR,
"Unsupported pixel format %s\n", attr);
}
static int xiph_parse_sdp_line(AVFormatContext *s, int st_index,
- PayloadContext *data, const char *line)
+ PayloadContext *data, const char *line)
{
const char *p;
+ if (st_index < 0)
+ return 0;
+
if (av_strstart(line, "fmtp:", &p)) {
return ff_parse_fmtp(s->streams[st_index], data, p,
xiph_parse_fmtp_pair);
RTPDynamicProtocolHandler ff_theora_dynamic_handler = {
.enc_name = "theora",
.codec_type = AVMEDIA_TYPE_VIDEO,
- .codec_id = CODEC_ID_THEORA,
+ .codec_id = AV_CODEC_ID_THEORA,
.parse_sdp_a_line = xiph_parse_sdp_line,
- .open = xiph_new_context,
- .close = xiph_free_context,
+ .alloc = xiph_new_context,
+ .free = xiph_free_context,
.parse_packet = xiph_handle_packet
};
RTPDynamicProtocolHandler ff_vorbis_dynamic_handler = {
.enc_name = "vorbis",
.codec_type = AVMEDIA_TYPE_AUDIO,
- .codec_id = CODEC_ID_VORBIS,
+ .codec_id = AV_CODEC_ID_VORBIS,
.parse_sdp_a_line = xiph_parse_sdp_line,
- .open = xiph_new_context,
- .close = xiph_free_context,
+ .alloc = xiph_new_context,
+ .free = xiph_free_context,
.parse_packet = xiph_handle_packet
};