diff rtsp.c @ 5843:777a89fdb1c0 libavformat

RTSP: Synchronize the start time of the chained RTP muxers This makes sure that the streams get correctly synchronized when viewed, previously the streams were out of sync by as much time as it took between the initialization of the individual muxers.
author mstorsjo
date Mon, 15 Mar 2010 14:20:07 +0000
parents d605f589f0be
children ca238015a806
line wrap: on
line diff
--- a/rtsp.c	Mon Mar 15 10:37:12 2010 +0000
+++ b/rtsp.c	Mon Mar 15 14:20:07 2010 +0000
@@ -612,6 +612,7 @@
 static void *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st,
                                URLContext *handle)
 {
+    RTSPState *rt = s->priv_data;
     AVFormatContext *rtpctx;
     int ret;
     AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
@@ -634,6 +635,9 @@
     /* Copy other stream parameters. */
     rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio;
 
+    /* Set the synchronized start time. */
+    rtpctx->start_time_realtime = rt->start_time;
+
     /* Remove the local codec, link to the original codec
      * context instead, to give the rtp muxer access to
      * codec parameters. */
@@ -1340,6 +1344,8 @@
     char *sdp;
     AVFormatContext sdp_ctx, *ctx_array[1];
 
+    rt->start_time = av_gettime();
+
     /* Announce the stream */
     snprintf(cmd, sizeof(cmd),
              "ANNOUNCE %s RTSP/1.0\r\n"