*/
#include "avformat.h"
+#include "avio_internal.h"
#include "rtpdec_formats.h"
+#include "libavutil/attributes.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/get_bits.h"
int newformat;
};
-static PayloadContext *h263_new_context(void)
+static void h263_close_context(PayloadContext *data)
{
- return av_mallocz(sizeof(PayloadContext));
-}
-
-static void h263_free_context(PayloadContext *data)
-{
- if (!data)
- return;
- if (data->buf) {
- uint8_t *p;
- avio_close_dyn_buf(data->buf, &p);
- av_free(p);
- }
- av_free(data);
+ ffio_free_dyn_buf(&data->buf);
}
static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
- const uint8_t *buf, int len, int flags)
+ const uint8_t *buf, int len, uint16_t seq,
+ int flags)
{
/* Corresponding to header fields in the RFC */
int f, p, i, sbit, ebit, src, r;
if (data->newformat)
return ff_h263_handle_packet(ctx, data, st, pkt, timestamp, buf, len,
- flags);
+ seq, flags);
if (data->buf && data->timestamp != *timestamp) {
/* Dropping old buffered, unfinished data */
- uint8_t *p;
- avio_close_dyn_buf(data->buf, &p);
- av_free(p);
- data->buf = NULL;
+ ffio_free_dyn_buf(&data->buf);
+ data->endbyte_bits = 0;
}
if (len < 4) {
/* Invalid src for this format, and bits that should be zero
* according to RFC 2190 aren't zero. */
av_log(ctx, AV_LOG_WARNING,
- "Interpreting H263 RTP data as RFC 2429/4629 even though "
+ "Interpreting H.263 RTP data as RFC 2429/4629 even though "
"signalled with a static payload type.\n");
data->newformat = 1;
return ff_h263_handle_packet(ctx, data, st, pkt, timestamp, buf,
- len, flags);
+ len, seq, flags);
}
}
RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler = {
.codec_type = AVMEDIA_TYPE_VIDEO,
.codec_id = AV_CODEC_ID_H263,
+ .need_parsing = AVSTREAM_PARSE_FULL,
.parse_packet = h263_handle_packet,
- .alloc = h263_new_context,
- .free = h263_free_context,
+ .priv_data_size = sizeof(PayloadContext),
+ .close = h263_close_context,
.static_payload_id = 34,
};