Re: DirectShow timestamps vs RTP



On Thu, 18 Sep 2008 06:50:37 -0700 (PDT), tim.slechten@xxxxxxxxx
wrote:

On the receiving side I would calculate TimeStart of the MediaSample
like this:
1. take the 64-bit NTP time (1sec units) from the last SR and convert
to 100ns units
2. calculate the difference between the last SR's timestamp and the
timestamp of the first RTP packet I received for this MediaSample, and
also convert it to 100ns units
3. add 1 and 2

You need to use the SR to keep the two streams in sync and relate this
to a baseline stream time.

When you get the first SR after going active, record the NTP and RTP
times and associate this with a directshow stream time. If you are
doing this in pause mode while cueing, the stream time can be 0, but
most likely you have flagged VFW_S_CANT_CUE so you are doing this when
running. In this case you need to get the current stream time and add
a latency for how long the decoder will take. So now you know that
this RTP time corresponds to this NTP time and to this dshow stream
time.

The NTP/RTP pairings you get are per stream, but the ntp to directshow
stream time is established once for the whole filter.

Then each time you get an RTP timestamp on a packet, you use the
RTP/NTP relationship to convert to NTP and then the NTP/Stream Time
relationship to convert to a directshow time. Use the first NTP time
as the start time of the IMediaSample even if there are several
packets in the sample. You don't need to worry about the end time of
the sample unless you are dealing with uncompressed data -- just set
this to the packet start time + 1 and the decoder will do the right
thing.

G
.


Loading