]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpdec_h263_rfc2190.c
Merge commit 'f61272f0efd80da437570aad2c40e00f9d3f4fe6'
[ffmpeg] / libavformat / rtpdec_h263_rfc2190.c
index a3a48257190e493ea6c258497a0227da9052c74a..4792a9fdc5f50ef33b565881471c4d9ceaafb02f 100644 (file)
@@ -57,15 +57,16 @@ static void h263_free_context(PayloadContext *data)
 
 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;
-    int header_size;
+    int header_size, ret;
 
     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 */
@@ -122,7 +123,7 @@ static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
                    "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);
         }
     }
 
@@ -132,8 +133,8 @@ static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
     if (!data->buf) {
         /* Check the picture start code, only start buffering a new frame
          * if this is correct */
-        if (!f && len > 4 && AV_RB32(buf) >> 10 == 0x20) {
-            int ret = avio_open_dyn_buf(&data->buf);
+        if (len > 4 && AV_RB32(buf) >> 10 == 0x20) {
+            ret = avio_open_dyn_buf(&data->buf);
             if (ret < 0)
                 return ret;
             data->timestamp = *timestamp;
@@ -185,20 +186,18 @@ static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data,
         avio_w8(data->buf, data->endbyte);
     data->endbyte_bits = 0;
 
-    av_init_packet(pkt);
-    pkt->size         = avio_close_dyn_buf(data->buf, &pkt->data);
-    pkt->destruct     = av_destruct_packet;
-    pkt->stream_index = st->index;
+    ret = ff_rtp_finalize_packet(pkt, &data->buf, st->index);
+    if (ret < 0)
+        return ret;
     if (!i)
         pkt->flags   |= AV_PKT_FLAG_KEY;
-    data->buf = NULL;
 
     return 0;
 }
 
 RTPDynamicProtocolHandler ff_h263_rfc2190_dynamic_handler = {
     .codec_type        = AVMEDIA_TYPE_VIDEO,
-    .codec_id          = CODEC_ID_H263,
+    .codec_id          = AV_CODEC_ID_H263,
     .parse_packet      = h263_handle_packet,
     .alloc             = h263_new_context,
     .free              = h263_free_context,