comparison 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
comparison
equal deleted inserted replaced
5842:cc35562d3747 5843:777a89fdb1c0
610 } 610 }
611 611
612 static void *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st, 612 static void *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st,
613 URLContext *handle) 613 URLContext *handle)
614 { 614 {
615 RTSPState *rt = s->priv_data;
615 AVFormatContext *rtpctx; 616 AVFormatContext *rtpctx;
616 int ret; 617 int ret;
617 AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); 618 AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
618 619
619 if (!rtp_format) 620 if (!rtp_format)
631 } 632 }
632 /* Copy the max delay setting; the rtp muxer reads this. */ 633 /* Copy the max delay setting; the rtp muxer reads this. */
633 rtpctx->max_delay = s->max_delay; 634 rtpctx->max_delay = s->max_delay;
634 /* Copy other stream parameters. */ 635 /* Copy other stream parameters. */
635 rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio; 636 rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio;
637
638 /* Set the synchronized start time. */
639 rtpctx->start_time_realtime = rt->start_time;
636 640
637 /* Remove the local codec, link to the original codec 641 /* Remove the local codec, link to the original codec
638 * context instead, to give the rtp muxer access to 642 * context instead, to give the rtp muxer access to
639 * codec parameters. */ 643 * codec parameters. */
640 av_free(rtpctx->streams[0]->codec); 644 av_free(rtpctx->streams[0]->codec);
1338 char cmd[1024]; 1342 char cmd[1024];
1339 int i; 1343 int i;
1340 char *sdp; 1344 char *sdp;
1341 AVFormatContext sdp_ctx, *ctx_array[1]; 1345 AVFormatContext sdp_ctx, *ctx_array[1];
1342 1346
1347 rt->start_time = av_gettime();
1348
1343 /* Announce the stream */ 1349 /* Announce the stream */
1344 snprintf(cmd, sizeof(cmd), 1350 snprintf(cmd, sizeof(cmd),
1345 "ANNOUNCE %s RTSP/1.0\r\n" 1351 "ANNOUNCE %s RTSP/1.0\r\n"
1346 "Content-Type: application/sdp\r\n", 1352 "Content-Type: application/sdp\r\n",
1347 rt->control_uri); 1353 rt->control_uri);