Commit graph

288 commits

Author SHA1 Message Date
Miguel París Díaz
05bd708fc5 rtpjitterbuffer: Fix expected_dts calc in calculate_expected
Right above we consider lost_packet packets, each of them having duration,
as lost and triggered their timers immediately. Below we use expected_dts
to schedule retransmission or schedule lost timers for the packets that
come after expected_dts.

As we just triggered lost_packets packets as lost, there's no point in
scheduling new timers for them and we can just skip over all lost packets.

https://bugzilla.gnome.org/show_bug.cgi?id=739868
2015-04-13 09:06:33 +02:00
Sebastian Dröge
1a2f253c3a rtpjitterbuffer: Make the next output buffer discont after resetting the jitterbuffer
Resetting the jitterbuffer drops all packets and other things, and will cause
a discontinuity in the packets received by the depayloaders. They should now
also flush anything they had pending as the new data will start at a different
position.

https://bugzilla.gnome.org/show_bug.cgi?id=739868
2015-04-13 09:05:34 +02:00
Nicolas Dufresne
12762ad1a5 rtpjitter: Account for rtx_retry in overflow check
As rtx_retry is part of the substraction, we need to take it into
account, otherwise we may endup with a big value.
2015-03-25 15:25:56 -04:00
Sebastian Dröge
9e934d076b rtpjitterbuffer: Drop packets with sequence numbers before the seqnum-base
These are outside the expected range of sequence numbers and should be
clipped, especially for RTSP they might belong to packets from before a seek
or a previous stream in general.
2015-03-09 11:10:35 +01:00
Sebastian Dröge
38bf3d3808 rtpjitterbuffer: Don't forget to unlock the mutex when receiving GAPs in TCP streams 2015-03-09 10:05:14 +01:00
Sebastian Dröge
735c6c40f8 rtpjitterbuffer: When resetting the jitterbuffer because of packet discont, don't flush sticky events
We will otherwise flush away STREAM_START, CAPS or SEGMENT events and will
confuse downstream with buffers that come before such events.
2015-02-17 16:57:55 +02:00
Sebastian Dröge
87c8c163a8 rtpjitterbuffer: If we get a gap with a buffer without DTS, error out
We (currently?) can't really handle gaps between RTP packets if they're not
properly timestamped. The current code would go into calculations with
GST_CLOCK_TIME_NONE and then cause assertions everywhere. It's probably
better to error out cleanly instead.
2015-01-07 18:05:18 +01:00
Thibault Saunier
aa89278ade rtpjitterbuffer: Use an empty iterator in iterate_internal_link when no links
We used to setup an iterator with 1 GValue set with a NULL object
pointer which is not the normal way to do that. Instead we should make
sure that the first call to gst_iterator_next returns GST_ITERATOR_DONE.
2014-12-03 11:17:11 +01:00
Miguel París Díaz
6daa57868f rtpjitterbuffer: ensure rtx_retry_period >= 0
https://bugzilla.gnome.org/show_bug.cgi?id=739344
2014-11-22 14:48:57 +00:00
Tim-Philipp Müller
d940c21b78 rtpjitterbuffer: implement get/set for new rtx-min-retry-timeout property
Properties are so much more useful if you can actually set
and get their values.
2014-11-02 13:06:33 +00:00
Tim-Philipp Müller
b02d73a0ed rtpjitterbuffer: fix crash on some 32-bit systems
Make sure to pass right number of bits to gst_structure_new()
which is a vararg function.

Fixes elements/rtpaux unit test on ppc32.
2014-10-25 12:45:31 +01:00
Wim Taymans
bd09dc96e9 rtpjitterbuffer: limit the retry frequency
When the RTT and jitter are very low (such as on a local network), the
calculated retransmission timeout is very small. Set some sensible lower
boundary to the timeout by adding a new property. We use the packet
spacing as a lower boundary by default.
2014-10-22 15:04:24 +02:00
Miguel París Díaz
4b5243c43d gstrtpjitterbuffer: add "rtx-min-delay" property
This property is useful to set a min time to wait before sending a
retransmission event.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=735378
2014-10-22 15:00:27 +02:00
Wim Taymans
0b81b316b5 jitterbuffer: Refactor code
Refactor some code dealing with calculating various timeouts.

See https://bugzilla.gnome.org/show_bug.cgi?id=735378
2014-10-22 14:59:57 +02:00
Wim Taymans
09f179139d rtpjitterbuffer: make debug line less confusing 2014-10-21 13:10:53 +02:00
Youness Alaoui
a98341397d jitterbuffer: Allow rtp caps without clock-rate
The jitterbuffer shouldn't force clock-rate on its sink pad, this will cause a negotiation issue since rtpssrcdemux doesn't have the clock-rate and doesn't add it to the caps. The documentation states that the clock-rate can either be specified through the caps or through the request-pt-map signal, so we must remove clock-rate from the pad templates and we must accept the GST_EVENT_CAPS if the caps don't have the clock-rate.

https://bugzilla.gnome.org/show_bug.cgi?id=734322
2014-08-21 18:32:58 -04:00
Wim Taymans
ca9cfd40dd jitterbuffer: improve SR packet handling
Implement 3 different cases for handling the SR:

 1) we don't have enough timing information to handle the SR packet and
    we need to wait a little for more RTP packets. In that case we keep
    the SR packet around and retry when we get an RTP packet in the
    chain function.

 2) the SR packet has a too old timestamp and should be discarded. It is
    labeled invalid and the last_sr is cleared.

 3) the SR packet is ok and there is enough timing information, proceed
    with processing the SR packet.

Before this patch, case 2) and 1) were handled in the same way,
resulting that SR packets with too old timestamps were checked over and
over again for each RTP packet.
2014-06-25 16:14:46 +02:00
Wim Taymans
b2e1598e4a rtpjitterbuffer: increment accepted packets after loss
When we detect a lost packet, expect packets with higher
seqnum on the input.

Also update the unit test.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=729524
2014-05-09 18:10:32 +02:00
Jason Litzinger
9068e1bb8e Add new test case. 2014-05-09 18:10:32 +02:00
Mark Nauwelaerts
6c584bc833 rtpjitterbuffer: avoid stall by corrupted seqnum accounting 2014-05-04 13:38:26 +02:00
Wim Taymans
eba3bba524 rtpjitterbuffer: optimize timer update
When we are not doing retransmission, we just need to find the current
seqnum so we can stop when we found it.
2014-04-29 16:26:53 +02:00
Wim Taymans
b2c9646acb rtpjitterbuffer: small optimizations
Small optimizations where we can.
Add some more debug.
2014-04-29 16:21:44 +02:00
Wim Taymans
df04fcbb5d rtpjitterbuffer: signal when next_seqnum changed
Signal the pushing thread when the next_seqnum changed and we might be
able to push a buffer now.
2014-04-29 16:16:17 +02:00
Wim Taymans
3cd0e8ae88 rtpjitterbuffer: only signal event when head changed
After adding a buffer, only signal the pushing thread when the head
buffer changed or else we cause a useless wakeup.
2014-04-29 16:12:29 +02:00
Tim-Philipp Müller
c9597298f9 docs: remove outdated and pointless 'Last reviewed' lines from docs
They are very confusing for people, and more often than not
also just not very accurate. Seeing 'last reviewed: 2005' in
your docs is not very confidence-inspiring. Let's just remove
those comments.
2014-04-26 23:35:17 +01:00
Jan Schmidt
f2d0ddf113 rtpjitterbuffer: Clear last_pt on flush-stop.
Otherwise, we don't recheck the buffer caps for clock-rate
properly on the next chain.
2014-04-23 18:54:16 +10:00
Wim Taymans
3e11ce43b9 jitterbuffer: improve EOS handling
Make a new method to disable the jitterbuffer buffering.
Rework the update_estimated_eos() method. Calculate how much time
there is left to play. If we have less than the delay of the
jitterbuffer, we disabled buffering because we might never be able to
fill the complete jitterbuffer again.
If we receive an EOS event, disable buffering. We will drain the
buffer and eventually push the EOS event out.
When we reach the estimated NPT timeout and we didn't receive an EOS
event, make one and queue it so that it can be pushed.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=728017
2014-04-18 14:07:31 +02:00
Wim Taymans
42cfedde7f jitterbuffer: assume a full buffer when eos
Rework the logic to make buffering messages a little, make sure we
don't make the same message multiple times.
Consider the buffer full when EOS was received.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=728017
2014-04-18 04:27:39 +02:00
Sebastian Dröge
897c02cace rtpjitterbuffer: Unref clock id when waiting for the clock is interrupted 2014-04-17 17:00:37 +02:00
Wim Taymans
783b4ba2c4 rtpjitterbuffer: refuse serialied query when buffering
When we are buffering, we can't block and wait for the serialized query
to complete because the jitterbuffer will not try to forward the query
while buffering. Instead, just refuse the query.
2014-04-16 18:16:33 +02:00
Wim Taymans
233e9e64b8 rtpjitterbuffer: don't free the serialized query
We should never free a serialized query in the queue, it is the upstream
caller that will free it.
2014-04-16 18:16:32 +02:00
Wim Taymans
c3de599c4f jitterbuffer: demote warning to debug
For TCP, it is normal that we don't have timestamps so don't WARN on
it.
2014-04-03 12:09:24 +02:00
Tim-Philipp Müller
1d7f5c7a83 rtpjitterbuffer: fix compiler warning
gstrtpjitterbuffer.c: In function 'gst_rtp_jitter_buffer_loop':
gstrtpjitterbuffer.c:2978:3: error: 'result' may be used uninitialized in this function
   while (result == GST_FLOW_OK);
   ^
2014-02-27 00:11:11 +00:00
Sebastian Dröge
d4bdf5a1b1 rtpjitterbuffer: Fix uninitialized variable compiler warning 2014-02-26 21:11:23 +01:00
Jake Foytik
6dd9142592 rtpjitterbuffer: Remove raw comparisons of RTP sequence numbers
Several conditional statements perform comparison on RTP sequence
numbers without taking the sequence number rollover into account.
Instead, use the gst_rtp_buffer_compare_seqnum function to perform the
comparison.

https://bugzilla.gnome.org/show_bug.cgi?id=725159
2014-02-26 21:11:21 +01:00
Wim Taymans
353e510f94 rtpjitterbuffer: add support for serialized queries
See https://bugzilla.gnome.org/show_bug.cgi?id=723850
2014-02-14 15:59:46 +01:00
Wim Taymans
204bd715d2 rtpjitterbuffer: handle expected packet being an RTX packet
If the expected packet (do_next_seqnum is TRUE) is the one we requested
for retranmission earlier, do the logic to update the retransmission
statistics as well before setting up the timers for the next expected
packet.
Also reset the retransmission counter if the timer is reused for another
seqnum.
2014-01-21 17:52:44 +01:00
Wim Taymans
9a3d4d7cbe rtpjitterbuffer: ignore invalid timestamps in rtt calculation
When the input buffer does not have a valid timestamp, don't try to
calculate the round-trip-time.
2014-01-21 15:29:26 +01:00
Aleix Conchillo Flaqué
cdbb2ba6b8 rtpjitterbuffer: do not drop serialized events when latency is set
Serialized events are now queued in the jitter buffer, so we don't
want to drop them even latency is set.

https://bugzilla.gnome.org/show_bug.cgi?id=722372
2014-01-18 10:38:46 +01:00
Wim Taymans
f48bbabafc rtpjitterbuffer: dynamically recalculate RTX parameters
Use the round-trip-time and average jitter to dynamically calculate the
retransmission interval and expected packet arrival time.

Based on patches from Torrie Fischer <torrie.fischer@collabora.co.uk>

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=711412
2013-12-30 11:18:51 +01:00
Wim Taymans
416bd9a2c3 rtpjitterbuffer: calculate average jitter 2013-12-30 11:18:51 +01:00
Wim Taymans
7181a21ca9 rtpsession: use RTT from the Retransmission event
Place the estimated RTT in the Retransmission event and let the session
manager use that instead of the hardcoded value.
2013-12-30 11:18:50 +01:00
Wim Taymans
e996f73d0c jitterbuffer: take more accurate running-time for NACK
Don't use the current time calculated from the tmieout loop for when we
last scheduled the NACK because it might be unscheduled because of a max
packet misorder and then we don't accurately calculate the current time.
Instead, take the current element running time using the clock.
2013-12-30 11:18:50 +01:00
Wim Taymans
eee515cb2c rtpjitterbuffer: serialize events in the buffer
Serialize events into the jitterbuffer by inserting them with a -1
seqnum.
Update unit test to expect events from the streaming thread.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=652986
2013-12-10 11:57:37 +01:00
Wim Taymans
36e78bc5ca rtpjitterbuffer: detect -1 seqnum
Keep the seqnum as a full guint so that we can check for -1 entries and
deal with them correctly.
Immediately try to push -1 seqnum.
2013-12-10 11:04:06 +01:00
Wim Taymans
710d1f3a2a rtpjitterbuffer: improve clear-pt-map handling
Don't reset the expected output seqnum when clearing the pt map because this
could stall the jitterbuffer forever.
Add a unit test for this.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=709800
2013-11-25 15:52:22 +01:00
Tim-Philipp Müller
901ec63462 rtpjitterbuffer: fix wake-up when new buffers come in after running empty
Spotted by 'gratias' on IRC. Probably introduced in recent refactoring.

https://bugzilla.gnome.org/show_bug.cgi?id=715039
2013-11-25 00:37:50 +00:00
Wim Taymans
4c9474905b rtpjitterbuffer: pass downstream flowreturn to upstream
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=712722
2013-11-22 12:27:31 +01:00
Tim-Philipp Müller
d506409af5 docs: get rid of 'Since: 0.10.x' markers
And some gtk-doc markup fixes.
2013-11-18 14:47:35 +00:00
Tim-Philipp Müller
548e756e0a rtpmanager: fix Since markers
Should be next stable release series version
2013-11-16 12:15:14 +00:00