[Live-devel] Timestamp conversion in RTPSink.cpp

Ross Finlayson finlayson at live555.com
Mon Nov 5 07:59:17 PST 2012


> we want to use live555 in one of our products on the WinCE platform and we have some issues with timestamp calculation.
> From file liveMedia/RTPSink.cpp:
> u_int32_t RTPSink::convertToRTPTimestamp(struct timeval tv) {
> 
> // Begin by converting from "struct timeval" units to RTP timestamp units:
> 
> u_int32_t timestampIncrement = (fTimestampFrequency*tv.tv_sec);
> 
> timestampIncrement += (u_int32_t)((2.0*fTimestampFrequency*tv.tv_usec + 1000000.0)/2000000);
> 
> // note: rounding
> 
> ...
> 
> Could you tell me why you are calculation the timstampIncrement like this?

It's done this way so that the result is rounded to the nearest integer.  Suppose, for example, that "fTimestampFrequency*tv.tv_usec" is 1990000.  Computing "tv.tv_usec*fTimestampFrequency/1000000.0" will give you 1 (when converted back to an "int").  However, computing "(2.0*fTimestampFrequency*tv.tv_usec + 1000000.0)/2000000" will give you 2, which is more accurate.

What specific 'issues' do you think you are having with timestamp calculation?  Are you having a problem specifically with this line of code??  If not, then your 'issues' are probably not with timestamp calculation.  Note that developers usually don't need to concern themselves with RTP timestamps; our software automatically converts presentation times to RTP timestamps (on transmission), and then back to presentation times (on reception).  As a developer, the important thing that you need to concern yourself with is ***presentation times***.  Your data sources' frames *must* have accurate presentation times, and they must be aligned to 'wall clock' time (i.e., the time that you would get by calling "gettimeofday()".)


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20121105/abecf289/attachment.html>


More information about the live-devel mailing list