rtmpproto: Readjust the end of the flv buffer if handle_metadata exited early
authorMartin Storsjö <martin@martin.st>
Thu, 3 Oct 2013 11:44:38 +0000 (13:44 +0200)
committerMartin Storsjö <martin@martin.st>
Fri, 4 Oct 2013 06:25:08 +0000 (09:25 +0300)
If the embedded flv packets were incomplete and we aborted the
copying loop early, make sure the flv buffer is trimmed to
only contain full packets.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtmpproto.c

index bc6cd3f..e7e37a3 100644 (file)
@@ -2229,6 +2229,11 @@ static int handle_metadata(RTMPContext *rt, RTMPPacket *pkt)
         next += size + 3 + 4;
         p    += size + 3 + 4;
     }
+    if (p != rt->flv_data + rt->flv_size) {
+        av_log(NULL, AV_LOG_WARNING, "Incomplete flv packets in "
+                                     "RTMP_PT_METADATA packet\n");
+        rt->flv_size = p - rt->flv_data;
+    }
 
     return 0;
 }