changeset 5721:82b0dc4f052a libavformat

RTSP muxer: Use a local copy of the AVPacket for sending to the chained muxer This way, we avoid overwriting stream_index in the user's AVPacket with a nonsense value.
author mstorsjo
date Fri, 26 Feb 2010 16:21:56 +0000
parents d833557e7287
children 8e0b6203dfb5
files rtspenc.c
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rtspenc.c	Thu Feb 25 16:59:55 2010 +0000
+++ b/rtspenc.c	Fri Feb 26 16:21:56 2010 +0000
@@ -71,6 +71,7 @@
     int n, tcp_fd;
     struct timeval tv;
     AVFormatContext *rtpctx;
+    AVPacket local_pkt;
 
     FD_ZERO(&rfds);
     tcp_fd = url_get_file_handle(rt->rtsp_hd);
@@ -96,8 +97,11 @@
     rtsp_st = rt->rtsp_streams[pkt->stream_index];
     rtpctx = rtsp_st->transport_priv;
 
-    pkt->stream_index = 0;
-    return av_write_frame(rtpctx, pkt);
+    /* Use a local packet for writing to the chained muxer, otherwise
+     * the internal stream_index = 0 becomes visible to the muxer user. */
+    local_pkt = *pkt;
+    local_pkt.stream_index = 0;
+    return av_write_frame(rtpctx, &local_pkt);
 }
 
 static int rtsp_write_close(AVFormatContext *s)