Commit graph

1175 commits

Author SHA1 Message Date
Thomas Bluemel
567afdd4d3 rtpjitterbuffer: Fix calculating next_seqnum when dropping old buffers from a full queue.
Fixes calculating the next sequence number when a ITEM_TYPE_LOST with more than one
definitely lost packets is encountered.

https://bugzilla.gnome.org/show_bug.cgi?id=769757
2016-09-14 19:47:28 -04:00
Havard Graff
f440b074b1 rtpjitterbuffer: improved rtx-rtt averaging
The basic idea is this:
1. For *larger* rtx-rtt, weigh a new measurement as before
2. For *smaller* rtx-rtt, be a bit more conservative and weigh a bit less
3. For very large measurements, consider them "outliers"
   and count them a lot less

The idea being that reducing the rtx-rtt is much more harmful then
increasing it, since we don't want to be underestimating the rtt of the
network, and when using this number to estimate the latency you need for
you jitterbuffer, you would rather want it to be a bit larger then a bit
smaller, potentially losing rtx-packets. The "outlier-detector" is there
to prevent a single skewed measurement to affect the outcome too much.
On wireless networks, these are surprisingly common.

https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Stian Selnes
f8238f0a9f rtpjitterbuffer: Detect whether to assume equidistant spacing when loss
Assuming equidistant packet spacing when that's not true leads to more
loss than necessary in the case of reordering and jitter. Typically this
is true for video where one frame often consists of multiple packets
with the same rtp timestamp. In this case it's better to assume that the
missing packets have the same timestamp as the last received packet, so
that the scheduled lost timer does not time out too early causing the
packets to be considered lost even though they may arrive in time.

https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Stian Selnes
2eb7383816 rtpjitterbuffer: Don't request rtx if 'now' is past retry period
There is no need to schedule another EXPECTED timer if we're already
past the retry period. Under normal operation this won't happen, but if
there are more timers than the jitterbuffer is able to process in
real-time, scheduling more timers will just make the situation worse.
Instead, consider this packet as lost and move on. This scenario can
occur with high loss rate, low rtt and high configured latency.

https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Stian Selnes
ab49dfd0b2 rtpjitterbuffer: Fix lost duration when gap after lost timer
This patch fixes an issue with the estimated gap duration when there is
a gap immediately after a lost timer has been processed. Previously
there was a discrepancy beteen the gap in seqnum and gap in dts which
would cause wrong calculated duration. The issue would only be seen with
retranmission enabled since when it's disabled lost timers are only
created when a packet is received and the actual gap length and last dts
is known.

https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Havard Graff
dd020f5cc8 rtpjitterbuffer: Expose rtx-deadline as a property
The default -1 gives the old behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Havard Graff
8087a8a31c rtpjitterbuffer: Improved expected-timer handling when gap > 0
https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Stian Selnes
38a7545003 rtpjitterbuffer: Major improvements for RTX stats
Stats should also be collected for unsuccessful packets.

rtx-rtt is very important for determining the necessary configured
latency on the jitterbuffer. It's especially important to be able to
increase the latency when retransmitted packets arrive too late and are
considered lost. This patch includes these late packets in the
calculation of the various rtx stats, making them more correct and
useful.

Also in the case where the original packet arrives after a NACK is sent,
the received RTX packet should update the stats since it provides useful
information about RTT.

The RTT is only updated if and only if all requested retranmissions are
received. That way the RTT is guaranteed to make sense. If not we don't
know which request the packet is a response to and the RTT may be bogus.
A consequence of this patch is that RTT is not updated for a request
when one of the RTX packets for that seqnum is lost, but that since
measured RTT will be more accurate.

The implementation store the RTX information from the timed out timers
and use this when the retransmitted packet arrives. For performance
these timers are stored separately from the "normal" timers in order to
not impact performance (see attached performance test).

https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Havard Graff
1b868cc9b1 rtpjitterbuffer: Add and expose more stats and increase testing of it
Add num-pushed and num-lost.
Expose num-late, num-duplicates and avg-jitter.

https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Stian Selnes
531199d5c4 rtxreceive: Set buffer flag for retransmitted packets
https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Havard Graff
1436fc01e9 rtpjitterbuffer: Option to disable rtx-delay-reorder
When disabled we can save some iterations over timers.

There is probably an argument for rtx-delay-reorder to exist, but
for normal operations, handling jitter (reordering) is something a
jitterbuffer should do, and this variable feels like functionality that
is not "in-sync" with what the jitterbuffer is trying to achieve.

Example: You have 50ms jitter on your network, and are receiving
audio packets with 10ms durations. An audio packet should not be
considered late until its rtx-timeout has expired (and hence a rtx-event
is sent), but with rtx-delay-reorder, events will be sent pretty much
all the time due to the jitter on the network.

Point being: The jitterbuffer should adapt its size to the measured network
jitter, and then rtx-delay-reorder needs to adapt as well, or simply
get out of the way and let the other (better) rtx-mechanisms do their job.

Also change find_timer to only use seqnum as an argument, since there
will only ever be one timer per seqnum at any given time. In the
one case where the type matters, the caller simply checks the type.

https://bugzilla.gnome.org/show_bug.cgi?id=769768
2016-09-14 19:37:50 -04:00
Olivier Crête
4fceb5050f Revert "rtpmux: fix PROP_TIMESTAMP_OFFSET range problems"
This broke API, so we need a better solution!

This reverts commit c7579d31a6.
2016-08-26 12:06:51 -04:00
Havard Graff
c7579d31a6 rtpmux: fix PROP_TIMESTAMP_OFFSET range problems
It could not set the offset for the full guint32 range.
2016-08-26 11:57:14 -04:00
Havard Graff
7ad7266163 rtpbin: introduce max-streams property
To be able to cap the number of allowed streams for one session.

This is useful for preventing DoS attacks, where a sender can change
SSRC for every buffer, effectively bringing rtpbin to a halt.

https://bugzilla.gnome.org/show_bug.cgi?id=770292
2016-08-26 11:57:06 -04:00
Havard Graff
b33470f80c rtpsource: reordered packets are very normal, and should not be a warning 2016-08-26 11:53:22 -04:00
Havard Graff
babc591707 rtpsession: degrade g_warning to GST_ERROR
So we don't blow up while investigating
2016-08-26 11:53:22 -04:00
Stian Selnes
61bc228a71 rtpsession: sanity check RTT before ignoring PLI/FIR 2016-08-25 18:28:44 -04:00
Stian Selnes
85a56f8ee3 rtpsession: handle sdes messages with non-utf8 more gracefully 2016-08-25 18:28:44 -04:00
Havard Graff
1ef896b29d gstrtpsession: refactor duplicate code into a function
Less code, easier to read, more consistent.

https://bugzilla.gnome.org/show_bug.cgi?id=770293
2016-08-23 15:09:03 -04:00
Vincent Penquerc'h
0fb0c0c8e6 rtpbin: fix typo in max-misorder-time property name 2016-08-23 17:19:17 +01:00
Nirbheek Chauhan
b09f478e80 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Jussi Pakkanen <jpakkane@gmail.com> (original port)

Highlights of the features provided are:
* Faster builds on Linux (~40-50% faster)
* The ability to build with MSVC on Windows
* Generate Visual Studio project files
* Generate XCode project files
* Much faster builds on Windows (on-par with Linux)
* Seriously fast configure and building on embedded

... and many more. For more details see:

http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html
http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html

Building with Meson should work on both Linux and Windows, but may
need a few more tweaks on other operating systems.
2016-08-20 11:21:12 +01:00
Thomas Bluemel
4dff74358e rtpjitterbuffer: Actually calculate the packet rate for max-dropout and max-misorder calculations.
https://bugzilla.gnome.org/show_bug.cgi?id=751311
2016-08-10 19:49:27 +02:00
Thomas Bluemel
e7d4ad7ac7 rtpjitterbuffer: Don't warn for duplicate packets
This is a normal scenario and should not be a warning.  This can
happen frequently when re-transmits of lost packets are enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=762208
2016-08-10 19:39:42 +02:00
Thiago Santos
7f0381fdd9 rtpjitterbuffer: avoid unref of null buffer
The current 'l' pointer will be NULL when the loop
is interrupted with a 'break' statement. Need to have
it advance to the next list item before interrupting.
2016-08-04 00:36:28 -03:00
Aurélien Zanelli
f8f8935c77 rtpjitterbuffer: fix RTPJitterBufferMode documentation
Documentation lacks '@' before each enum values and there was an extra
line after symbol section which confuses GTK-Doc parser.

https://bugzilla.gnome.org/show_bug.cgi?id=767788
2016-06-17 15:16:45 +03:00
Miguel París Díaz
83f4c08747 rtpsession: take the lock when changing stats
https://bugzilla.gnome.org/show_bug.cgi?id=766025
2016-06-17 12:52:29 +03:00
Olivier Crête
5328378132 rtpjitterbuffer: Work with non-TIME segments
With non-time segments, it now assumes that the arrival time of packets
is not relevant and that only the RTP timestamp matter and it produces
an output segment start at running time 0.

https://bugzilla.gnome.org/show_bug.cgi?id=766438
2016-06-08 14:49:49 -04:00
Miguel París Díaz
389e0abeb0 rtpsource: complete warn log with SSRC
https://bugzilla.gnome.org/show_bug.cgi?id=767195
2016-06-06 10:47:17 +03:00
Mikhail Fludkov
ee7e80d615 rtpsession: don't act on suspicious BYE RTCP
Some endpoints (like Tandberg E20) can send BYE packet containing our
internal SSRC. I this case we would detect SSRC collision and get rid
of the source at some point. But because we are still sending packets
with that SSRC the source will be recreated immediately.
This brand new internal source will not have some variables incorrectly
set in its state. For example 'seqnum-base` and `clock-rate` values will be
-1.
The fix is not to act on BYE RTCP if it contains internal or unknown
SSRC.

https://bugzilla.gnome.org/show_bug.cgi?id=762219
2016-05-20 09:28:39 +03:00
Sebastian Dröge
fe34f46f32 rtpsession: Take the lock already when reading the other stats, not just for the hash table
https://bugzilla.gnome.org/show_bug.cgi?id=766025
2016-05-15 12:31:33 +03:00
Olivier Crête
0ebdb97797 jitterbuffer: Upgrade debug message to error
It causes the entire pipeline to fail, it should be easier to find.
2016-05-14 12:36:08 +02:00
Sebastian Dröge
204a86af97 rtpsession: Don't notify about stats property changes while taking the session lock
The signal handlers might want to actually get the value of the stats
property, which would take the session lock again and deadlock.

This was introduced by 2e960e7075.

https://bugzilla.gnome.org/show_bug.cgi?id=766025
2016-05-11 09:28:13 +03:00
Havard Graff
8f7962e1c3 rtpjitterbuffer: Fix stall when receiving already lost packet
When a packet arrives that has already been considered lost as part of a
large gap the "lost timer" for this will be cancelled. If the remaining
packets of this large gap never arrives, there will be missing entries
in the queue and the loop function will keep waiting for these packets
to arrive and never push another packet, effectively stalling the
pipeline.

The proposed fix conciders parts of a large gap definitely lost (since
they are calculated from latency) and ignores the late arrivals.

In practice the issue is rare since large gaps are scheduled immediately,
and for the stall to happen the late arrival needs to be processed
before this times out.

https://bugzilla.gnome.org/show_bug.cgi?id=765933
2016-05-06 14:32:42 +03:00
Miguel París Díaz
2e960e7075 rtpsession: Take session lock when creating stats
The access to the session hash table must happen while the session lock is
taken, otherwise another thread might modify the hash table while we're
creating the stats.

https://bugzilla.gnome.org/show_bug.cgi?id=766025
2016-05-06 09:24:22 +03:00
Sebastian Dröge
608b4ee53c rtpjitterbuffer: Ensure to not take caps with the wrong pt for getting the clock-rate
Especially the caps on the pad might be out of date, and the new caps would be
provided for the current pt via the request-pt-map signal.

https://bugzilla.gnome.org/show_bug.cgi?id=765689
2016-04-27 20:52:27 +03:00
Jan Schmidt
a660ac7e88 rtpjitterbuffer: Fix debug output when resyncing
Don't output the pointer value of the time() function as a timestamp
by using the correct variable.

Fixes build on Raspberry Pi 3.
2016-04-15 14:35:07 +00:00
Paolo Pettinato
40fbffc208 rtpmux: Forward sticky events on buffer lists too, not only on buffers
https://bugzilla.gnome.org/show_bug.cgi?id=764933
2016-04-12 15:22:14 +03:00
Sebastian Dröge
4a0de53cc1 rtpjitterbuffer: Fix rtp_jitter_buffer_get_ts_diff() fill level calculation
The head of the queue is the oldest packet (as in lowest seqnum), the tail is
the newest packet. To calculate the fill level, we should calculate tail-head
while considering wraparounds. Not the other way around.

Other code is already doing this in the correct order.

https://bugzilla.gnome.org/show_bug.cgi?id=764889
2016-04-12 10:17:57 +03:00
Sebastian Dröge
95dc198563 rtpmanager: It's GST_LIBS, not GST_LIBS_LIBS 2016-04-11 10:44:56 +03:00
Edward Hervey
5fa1c2ba59 jiterbuffer: Move assertion to the right location
We shouldn't have "late" lost timers at that point
2016-04-07 13:01:52 +02:00
Edward Hervey
b82da62922 jitterbuffer: Speed up lost timeout handling
When downstream blocks, "lost" timers are created to notify the
outgoing thread that packets are lost.

The problem is that for high packet-rate streams, we might end up with
a big list of lost timeouts (had a use-case with ~1000...).

The problem isn't so much the amount of lost timeouts to handle, but
rather the way they were handled. All timers would first be iterated,
then the one selected would be handled ... to re-iterate the list again.

All of this is being done while the jbuf lock is taken, which in some use-cases
would return in holding that lock for 10s... blocking any buffers from
being accepted in input... which would then arrive late ... which would
create plenty of lost timers ... which would cause the same issue.

In order to avoid that situation, handle the lost timers immediately when
iterating the list of pending timers. This modifies the complexity from
a quadratic to a linear complexity.

https://bugzilla.gnome.org/show_bug.cgi?id=762988
2016-04-07 10:14:24 +02:00
Edward Hervey
d656fe8d54 jitterbuffer: Don't create lost events if we don't need them
When "do-lost" is set to FALSE we don't use/send the lost events.
In that case, don't create them to start with :)

https://bugzilla.gnome.org/show_bug.cgi?id=762988
2016-04-07 10:13:56 +02:00
Edward Hervey
cf866a8469 jitterbuffer: Add tracing of lock usage
Helps with debugging lock usage

https://bugzilla.gnome.org/show_bug.cgi?id=762988
2016-04-07 10:06:18 +02:00
Sebastian Dröge
df247f091c rtpjitterbuffer: Add RFC7273 media clock handling
https://bugzilla.gnome.org/show_bug.cgi?id=762259
2016-04-03 11:24:34 +03:00
Stian Selnes
4c0e509328 rtpsession: Add new signal 'on-app-rtcp'
Similar to the 'on-feedback-rtcp' signal, but emitted for RTCP APP
packets.

https://bugzilla.gnome.org/show_bug.cgi?id=762217
2016-03-30 15:42:01 +03:00
Minjae Kim
eb13a1d607 rtpmanager: Set to initial value for 'ntpns' in get_current_times()
Initialize "ntpns" variable to -1 as the OE compiler for some reason doesn't
realize that the variable is set in all code paths.

https://bugzilla.gnome.org/show_bug.cgi?id=764119
2016-03-29 10:21:07 +03:00
Vineeth TM
1071309870 good: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763076
2016-03-24 14:32:20 +02:00
Nirbheek Chauhan
78847d03cf rtpmanager: Some comment and documentation clarifications/fixes 2016-03-15 09:32:47 +00:00
Sebastian Dröge
b6e10be278 Revert "rtpjitterbuffer: don't forget to unlock mutex in error code path in two cases"
This reverts commit a7fb7b5359.

The mutex is taken by the caller, we should keep it locked when returning so
the caller can unlock it again.
2016-03-02 13:13:24 +02:00
Tim-Philipp Müller
a7fb7b5359 rtpjitterbuffer: don't forget to unlock mutex in error code path in two cases 2016-03-01 14:14:36 +00:00