[FFmpeg-devel] [PATCH] Extracting NTP timestamp from RTCP

Michael Niedermayer michaelni at gmx.at
Wed Oct 30 17:19:43 CET 2013


On Wed, Oct 30, 2013 at 09:59:03AM -0600, Fred Rothganger wrote:
> Sorry to send this twice, but the first message didn't have [PATCH]
> in the subject...
> 
> 
> Attached is a patch to set AVFormatContext.start_time_realtime when
> an RTCP packet comes in. The goal is that start_time_realtime + PTS
> = the real time when a frame was captured at the source by an IP
> camera.
> 
> -- Fred
> 

>  rtsp.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> f4dc7040487a6e66b5b056b48098c0ad92cf8acc  rtsp.patch
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index 2abb36b..50c0cde 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -2049,6 +2049,14 @@ redo:
>                   * as this one. */
>                  int i;
>                  AVStream *st = NULL;
> +                if (s->start_time_realtime == 0) {
> +                    s->start_time_realtime =
> +                          (((uint64_t) rtpctx->first_rtcp_ntp_time >> 32       ) - NTP_OFFSET) * 1000000
> +                        + ((           rtpctx->first_rtcp_ntp_time & 0xFFFFFFFF)               * 1000000 >> 32)
> +                        - av_rescale (rtpctx->rtcp_ts_offset,
> +                                      (uint64_t) rtpctx->st->time_base.num * 1000000,
> +                                                 rtpctx->st->time_base.den);
> +                }

rtpctx->st can be NULL

also probably should have a note in APIChanges
micro or minor version bump
and docs in avformat.h


>                  if (rtsp_st->stream_index >= 0)
>                      st = s->streams[rtsp_st->stream_index];
>                  for (i = 0; i < rt->nb_rtsp_streams; i++) {
> 

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131030/d8ff35e3/attachment.asc>


More information about the ffmpeg-devel mailing list