diff rtp_mpv.c @ 2411:9134c5f663bd libavformat

Backport fix for mpegvideo rtp, fixes Issue119, original fix from Dario Gallucci <dariodotgallucciatpolito.it> in feng
author lu_zero
date Tue, 28 Aug 2007 13:43:39 +0000
parents 18e94e5989d8
children a19cdec5d552
line wrap: on
line diff
--- a/rtp_mpv.c	Mon Aug 27 21:58:39 2007 +0000
+++ b/rtp_mpv.c	Tue Aug 28 13:43:39 2007 +0000
@@ -28,32 +28,39 @@
     RTPDemuxContext *s = s1->priv_data;
     AVStream *st = s1->streams[0];
     int len, h, max_packet_size;
+    int b=1, e=0;
     uint8_t *q;
 
     max_packet_size = s->max_payload_size;
 
     while (size > 0) {
-        /* XXX: more correct headers */
+        len = max_packet_size - 4;
+
+        if (len >= size) {
+            len = size;
+            e = 1;
+        }
+
         h = 0;
-        if (st->codec->sub_id == 2)
-            h |= 1 << 26; /* mpeg 2 indicator */
+        h |= b << 12;
+        h |= e << 11;
+
+//        if (st->codec->sub_id == 2)
+//            h |= 1 << 26; /* mpeg 2 indicator */
+
         q = s->buf;
         *q++ = h >> 24;
         *q++ = h >> 16;
         *q++ = h >> 8;
         *q++ = h;
 
-        if (st->codec->sub_id == 2) {
+/*        if (st->codec->sub_id == 2) {
             h = 0;
             *q++ = h >> 24;
             *q++ = h >> 16;
             *q++ = h >> 8;
             *q++ = h;
-        }
-
-        len = max_packet_size - (q - s->buf);
-        if (len > size)
-            len = size;
+        } */
 
         memcpy(q, buf1, len);
         q += len;