[dvblast-devel] PATCH: Avoid jitter in RTP timestamps
Marian Ďurkovič
md at bts.sk
Mon Aug 17 07:37:19 CEST 2009
Hi,
after sucessfully setting up dvblast in our environment, I noticed some
unexpected jitter in RTP timestamps. Closer investigation shows, that this
is caused by the fact, that kernel feeds us TS packets from DVB cards in
chunks once per approx. 12 msec. If the packet with PCR happens to be at
the end of a chunk, next TS packets will only arrive after 12 msec, which
will make the RTP timestamp inacurate.
The attached patch fixes this problem by taking reference wallclock
samples during output phase. This way RTP timestamp always matches PCR
contained in transmitted IP packet.
With kind regards,
M.
--------------------------------------------------------------------------
---- ----
---- Marian Ďurkovič network manager ----
---- ----
---- Slovak Technical University Tel: +421 2 571 041 81 ----
---- Computer Centre, Nám. Slobody 17 Fax: +421 2 524 94 351 ----
---- 812 43 Bratislava, Slovak Republic E-mail/sip: md at bts.sk ----
---- ----
--------------------------------------------------------------------------
-------------- next part --------------
Index: output.c
===================================================================
--- output.c (revision 14)
+++ output.c (working copy)
@@ -95,7 +95,7 @@
p_output->p_pmt_section = NULL;
p_output->p_sdt_section = NULL;
p_output->i_ref_timestamp = 0;
- p_output->i_ref_wallclock = mdate();
+ p_output->i_ref_wallclock = 0;
p_output->i_eit_last_table_id = 0;
p_output->i_maddr = i_maddr;
@@ -245,9 +245,19 @@
static void rtp_SetHdr( output_t *p_output, uint8_t *p_hdr )
{
- mtime_t i_timestamp = p_output->i_ref_timestamp
- + (mdate() - p_output->i_ref_wallclock) * 9 / 100;
+ mtime_t i_timestamp;
+ if (!p_output->i_ref_wallclock)
+ {
+ i_timestamp = p_output->i_ref_timestamp;
+ p_output->i_ref_wallclock = mdate();
+ }
+ else
+ {
+ i_timestamp = p_output->i_ref_timestamp
+ + (mdate() - p_output->i_ref_wallclock) * 9 / 100;
+ }
+
p_hdr[0] = 0x80;
p_hdr[1] = 33;
p_hdr[2] = p_output->i_cc >> 8;
Index: demux.c
===================================================================
--- demux.c (revision 14)
+++ demux.c (working copy)
@@ -225,7 +225,7 @@
if ( pp_outputs[j]->i_sid == i_sid )
{
pp_outputs[j]->i_ref_timestamp = i_timestamp;
- pp_outputs[j]->i_ref_wallclock = i_wallclock;
+ pp_outputs[j]->i_ref_wallclock = 0;
}
}
}
More information about the dvblast-devel
mailing list