Commit c07c6f81 authored by Martin Storsjö's avatar Martin Storsjö
Browse files

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.

Originally committed as revision 22545 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 4a287145
...@@ -612,6 +612,7 @@ void ff_rtsp_close_streams(AVFormatContext *s) ...@@ -612,6 +612,7 @@ void ff_rtsp_close_streams(AVFormatContext *s)
static void *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st, static void *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st,
URLContext *handle) URLContext *handle)
{ {
RTSPState *rt = s->priv_data;
AVFormatContext *rtpctx; AVFormatContext *rtpctx;
int ret; int ret;
AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL);
...@@ -634,6 +635,9 @@ static void *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st, ...@@ -634,6 +635,9 @@ static void *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st,
/* Copy other stream parameters. */ /* Copy other stream parameters. */
rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio; 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 /* Remove the local codec, link to the original codec
* context instead, to give the rtp muxer access to * context instead, to give the rtp muxer access to
* codec parameters. */ * codec parameters. */
...@@ -1340,6 +1344,8 @@ static int rtsp_setup_output_streams(AVFormatContext *s, const char *addr) ...@@ -1340,6 +1344,8 @@ static int rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
char *sdp; char *sdp;
AVFormatContext sdp_ctx, *ctx_array[1]; AVFormatContext sdp_ctx, *ctx_array[1];
rt->start_time = av_gettime();
/* Announce the stream */ /* Announce the stream */
snprintf(cmd, sizeof(cmd), snprintf(cmd, sizeof(cmd),
"ANNOUNCE %s RTSP/1.0\r\n" "ANNOUNCE %s RTSP/1.0\r\n"
......
...@@ -271,6 +271,9 @@ typedef struct RTSPState { ...@@ -271,6 +271,9 @@ typedef struct RTSPState {
* for all subsequent RTSP requests, rather than the input URI; in * for all subsequent RTSP requests, rather than the input URI; in
* other cases, this is a copy of AVFormatContext->filename. */ * other cases, this is a copy of AVFormatContext->filename. */
char control_uri[1024]; char control_uri[1024];
/** The synchronized start time of the output streams. */
int64_t start_time;
} RTSPState; } RTSPState;
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment