Commit graph

233 commits

Author SHA1 Message Date
Wim Taymans
d4892859d4 jitterbuffer: fix race in flush-start/flush-stop
When flush-stop arrives before we process the result of the _push() in the
loop function, we might pause even though we are not flushing anymore. Fix this
race by waiting for the srcpad loop function to completely pause after doing the
flush-start.
2013-10-04 12:35:18 +02:00
Wim Taymans
00056965e8 rtpjitterbuffer: fix race when updating the next_seqnum
If we were not waiting for the missing seqnum when we insert the lost packet
event in the jitterbuffer, we end up not updating the next_seqnum and wait
forever for the lost packets to arrive. Instead, keep track of the amount of
packets contained by the jitterbuffer item and update the next expected
seqnum only after pushing the buffer/event. This makes sure we correctly handle
GAPS in the sequence numbers.
2013-09-30 12:31:00 +02:00
Wim Taymans
fde438791e rtpjitterbuffer: small debug improvement 2013-09-30 12:30:23 +02:00
Wim Taymans
03d520eb69 rtpjitterbuffer: pause timer when PAUSED
Also pause the timer when we go to the PAUSED state. It is possible that we
don't have a clock or base-time in PAUSED to perform the timeouts.
2013-09-30 11:16:32 +02:00
Wim Taymans
4a31aec513 rtpjitterbuffer: improve debug 2013-09-30 11:15:25 +02:00
Wim Taymans
97f4674655 rtpjitterbuffer: calculate some stats 2013-09-25 10:50:05 +02:00
Wim Taymans
b1d29483bb rtpjitterbuffer: move send_lost_event function
Move the send_lost_event function to the do_lost_event handling, there is no
need to have a separate function.
2013-09-25 10:50:05 +02:00
Wim Taymans
adf5d96044 rtpmanager: update docs 2013-09-23 16:34:15 +02:00
Wim Taymans
e5019de80d docs: update docs with 1.0 element names 2013-09-23 15:36:47 +02:00
Wim Taymans
8ce674da87 rtpjitterbuffer: always store lost event in jitterbuffer
Always prepare a lost event in the jitterbuffer, it is to wake up and make the
pushing thread continue. We drop the event when we are not supposed to push lost
events downstream.
2013-09-23 14:45:27 +02:00
Wim Taymans
9f3345fcc2 rtpjitterbuffer: schedule lost event differently
Schedule the lost event by placing it inside the jitterbuffer with the seqnum
that was lost so that the pushing thread can interleave and push it properly.
2013-09-23 14:45:27 +02:00
Wim Taymans
28641e3145 rtpjitterbuffer: add type to the item
So that the upper layer can know what data is contained in the item.
2013-09-23 14:45:26 +02:00
Wim Taymans
479c7642fd rtpjitterbuffer: fix flush
Pass function to flush to properly free the queue items.
2013-09-23 14:45:25 +02:00
Wim Taymans
39a2ba669d rtpjitterbuffer: use structure to hold packet information
Make the jitterbuffer operate on a structure containing all the packet
information. This avoids mapping the buffer multiple times just to get the RTP
information. It will also make it possible to store other miniobjects such as
events later.
2013-09-23 14:45:25 +02:00
Wim Taymans
1760817005 rtpjitterbuffer: update expected timer when possible
When we receive a packet and we have some missing packets, we can update their
estimated arrival times based on the timestamp difference.
2013-09-23 14:45:25 +02:00
Wim Taymans
fdc1ed1680 rtpjitterbuffer: fix order of timeout events
Improve the order of the timeout events, if there are timers with the same
timeout, we want to trigger the lowest seqnum first. For this we need to loop
over the complete array of timers to find the best one before triggering the
timeout.
2013-09-23 14:45:25 +02:00
Wim Taymans
0b1a7edfea rtpjitterbuffer: send lost event before signaling next buffer
First send the lost event, then update the next_seqnum counter and then
send the signal to the pushing thread that it can retry to push a buffer. This
avoids pushing out buffers before the lost event is pushed.
2013-09-23 14:45:25 +02:00
Wim Taymans
5051f51f0a jitterbuffer: configure clock-rate on jitterbuffer
Add a get and setter to configure the clock-rate in the jitterbuffer instead of
passing it as an argument to the insert method.
2013-09-23 14:45:24 +02:00
Wim Taymans
3c421e7e48 rtpjitterbuffer: add option to reset retransmission timers 2013-09-23 14:45:24 +02:00
Wim Taymans
6f4deab298 rtpjitterbuffer: stop the timer thread
The timeout code could release the lock so we need to check if we are allowed to
wait for the clock some more.
2013-09-23 14:45:24 +02:00
Wim Taymans
cba4e6a707 rtpjitterbuffer: unlock only once 2013-09-23 14:45:24 +02:00
Wim Taymans
5dc207948c rtpjitterbuffer: improve flush and shutdown
There is no need to unschedule the timer in flush-start, flush-stop will remove
the timers and unschedule.
Unschedule the current timer before attempting to join the timer thread.
2013-09-23 14:45:23 +02:00
Wim Taymans
a512cc2d3c rtpjitterbuffer: set correct expected time
When we already have a timer for a packet, skip it but don't forget to adjust
the dts to the expected dts of the next packet.
2013-09-23 14:45:23 +02:00
Wim Taymans
517ea0f4d9 jitterbuffer: improve debug 2013-09-23 14:45:23 +02:00
Wim Taymans
fd6c57cf10 rtpjitterbuffer: keep delay as a separate variable in timer
Keep a separate delay in the timer so that we still know the original timestamp
of the packet that this timer refers to. We can then place the correct
running-time in the Retransmission event.
2013-09-19 14:32:48 +02:00
Wim Taymans
d34184dd03 rtpjitterbuffer: fix writability of properties 2013-09-19 14:32:48 +02:00
Wim Taymans
6bb2626498 rtpjitterbuffer: reevaluate the current timer after timeout
When we trigger the timeout logic of a timer, reevaluate it because it is
possible that it still has the lowest timeout.
2013-09-18 16:33:40 +02:00
Wim Taymans
8d021b6ede rtpjitterbuffer: don't update time when unscheduled
Don't try to estimate the current time when we got unscheduled.
2013-09-18 16:31:26 +02:00
Wim Taymans
65606a25bf rtpjitterbuffer: init packet spacing on first buffer
Already init the packet spacing variables on the first buffer so that we can
calculate the spacing on the second buffer already.
2013-09-18 16:29:37 +02:00
Wim Taymans
f2efdf28f5 rtpjitterbuffer: push the lost event from the timer thread
Instead of pushing the lost event from the chain function, schedule a timeout
that will push the lost event from the timer thread. This avoid blocking the
upstream thread while we push and sync the event.
2013-09-18 14:57:09 +02:00
Wim Taymans
5d5fc03e04 rtpjitterbuffer: round gap duration to multiple of duration
Make sure the gap duration in the lost event is a multiple of the packet
duration.
Enable another test.
2013-09-18 14:12:47 +02:00
Wim Taymans
6e4a051d40 rtpjitterbuffer: keep track of duration
Keep track of the estimated duration of missing packets and use it in the lost
event.
Enable another unit test
2013-09-18 12:29:38 +02:00
Wim Taymans
ac3bb3acf6 rtpjitterbuffer: handle large gaps with one lost event
When we have a large number of missing packets, generate one lost event for all
the packets that have no chance of being pushed out in time.
Fix and activate unit test for large gaps.
2013-09-18 11:59:28 +02:00
Wim Taymans
26402e1c21 rtpjitterbuffer: refactor lost event sending
Also make sure we only increment the expected seqnum and last
output timestamp.
2013-09-18 11:57:06 +02:00
Wim Taymans
f49981a597 jitterbuffer: refactor timeout triggers 2013-09-17 23:29:56 +02:00
Wim Taymans
047021c443 jitterbuffer: simplify the timeout code
Keep track of the current time in the timeout loop.
Loop over all timers and trigger all the expired ones, we can do this in the
same loop that selects the new best timer.
2013-09-17 23:29:56 +02:00
Wim Taymans
fa1ef3328b jitterbuffer: rearrange timer update code
Also update the timers when retransmission is disabled. We need to
do this because when we added LOST timers when we detected missing packets and
we need to remove those timers when the packet finally arrives.
2013-09-17 23:29:56 +02:00
Wim Taymans
232fdd8b56 jitterbuffer: release lock on shutdown 2013-09-17 15:19:42 +02:00
Wim Taymans
4de919a17a jitterbuffer: use separate thread for timeouts
Use a separate thread for scheduling the timeouts instead of using the
downstream streaming thread that might block at any time.
2013-09-16 15:55:55 +02:00
Wim Taymans
9f9ba21404 jitterbuffer: handle segments with non-0 start
We keep the DTS and PTS in running-time inside the jitterbuffer. Make sure to
transform it back to a buffer timestamp before pushing out the buffer.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=707931
2013-09-12 15:04:30 +02:00
Wim Taymans
454d75951e jitterbuffer: fix types of the retransmission event 2013-08-27 09:55:52 +02:00
Wim Taymans
dd4af0d11c jitterbuffer: only timeout EXPECTED timers on gap
Only timeout the EXPECTED timers when we detect a large seqnum gap.
2013-08-27 09:44:18 +02:00
Wim Taymans
587dc055e9 jitterbuffer: handle EOS
When the queue is empty, and we received EOS, pause and push an EOS
event downstream.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=706387
2013-08-20 14:36:59 +02:00
Wim Taymans
533f26fc99 jitterbuffer: update docs 2013-08-20 10:26:15 +02:00
Wim Taymans
c7f9ef8012 jitterbuffer: update all timers
Keep looping over all registered timers so that we can mark them lost instead of
stopping as soon as we find the timer for the current seqnum.
2013-08-20 10:25:17 +02:00
Wim Taymans
5debda9ca1 jitterbuffer: remove unused variables 2013-08-20 08:55:50 +02:00
Wim Taymans
a88db5fa2c jitterbuffer: reorganize timer handling
Restructure handling of incomming packet and the gap with the expected seqnum
and register all timers from the _chain function.
Convert a timer to a LOST packet timer when the max amount of retransmission
requests has been reached.
2013-08-19 22:04:51 +02:00
Wim Taymans
d9d6eac4bb jitterbuffer: refactor packet spacing calculation 2013-08-19 22:04:50 +02:00
Wim Taymans
c4dc159656 jitterbuffer: keep track of last seqnum and dts 2013-08-19 22:04:50 +02:00
Wim Taymans
652ce95ca6 jitterbuffer: small cleanups 2013-08-19 22:04:50 +02:00