[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] RTP Timestamp



How does the RTP timestamp work?  In the udp.cc code, the timestamp is 
caste as an unsigned integer:

#define u_int32_t unsigned int

//"rtp timestamp" needs the samplerate
#define SAMPLERATE 8000
hdr_cmn::access(p)->timestamp() = (u_int32_t)(SAMPLERATE*local_time);

but the timestamp itself is defined as a double in the common packet 
header:

	double	ts_;		// timestamp: for q-delay measurement
	inline double& timestamp() { return (ts_); }

If I access the timestamp at a packet sink:

	timestamp = hdr_cmn::access(pkt)->timestamp();

the only data type which makes sense is that the timestamp is a double, 
with no SAMPLERATE factor involved.  But where does the magic conversion 
from (u_int32_t)timestamp to (double)timestamp/(double)SAMPLERATE take 
place?

Sven.