Commit graph

1428 commits

Author SHA1 Message Date
Havard Graff 26c94af2ea rtpssrcdemux: fix "data flow before segment event" crash
This crash could happen at any time a RTP and RTCP buffer arrived
simultaneously in ssrcdemux.

The problem was that sticky-event arriving while the rtp and rtcp pads
were being set up could arrive just too late to be included in the initial
forwarding.

The fix checks if the stickies have been sent on the srcpad about to be
pushed on, and if not sends them. It also blocks any stickes from
being forwarded *prior* to this happening, to avoid them arriving on
the srcpad multiple times.

Since the test loops 1000 times, this will make running under valgrind
take forever, so use the RUNNING_ON_VALGRIND variable to detect we
are running under valgrind, and reduce the loop-count to 2 in that case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/992>
2021-05-25 22:04:41 +00:00
Havard Graff de3a3882e9 rtpssrcdemux: refactor destruction of GstRtpSsrcDemuxPads
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/992>
2021-05-25 22:04:41 +00:00
Havard Graff c721c6fe72 rtpssrcdemux: make naming consistent
Use plural for GstRtpSsrcDemuxPads, since it contains two pads, and
use the variable-name 'dpads' everywhere.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/992>
2021-05-25 22:04:41 +00:00
François Laignel 39f0905a7e Use gst_element_request_pad_simple
Instead of the deprecated gst_element_get_request_pad.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/958>
2021-05-05 06:17:20 +00:00
Havard Graff d75c678479 rtpjitterbuffer: fix divide-by-zero
The estimated packet-duration can sometimes end up as zero, and dividing
by that is never a good idea...

The test reproduces the scenario, and the fix is easy.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/966>
2021-04-25 02:21:04 +02:00
Havard Graff 1368b4214b rtpjitterbuffer: clean up and improve missing packets handling
* Try to make variable and function names more clear.
* Add plenty of comments describing the logic step-by-step.
* Improve the logging around this, making the logs easier to read and
  understand when debugging these issues.

* Revise the logic of packets that are actually beyond saving in doing
  the following:
1. Do an optimistic estimation of which packets can still arrive.
2. Based on this, find which packets (and duration) are now hopelessly
   lost.
3. Issue an immediate lost-event for the hopelessly lost and then add
   lost/rtx timers for the ones we still hope to save, meaning that if
   they are to arrive, they will not be discarded.

* Revise the use of rtx-delay:
  Earlier the rtx-delay would vary, depending on the pts of the latest
  packet and the estimated pts of the packet it being issued a RTX for,
  but now that we aim to estimate the PTS of the missing packet accurately,
  the RTX delay should remain the same for all packets.
  Meaning: If the packet have a PTS of X, the delay in asked for a RTX
  for this packet is always a constant X + delay, not a variable one.

* Finally ensure that the chaotic "check-for-stall" tests uses timestamps
  that starts from 0 to make them easier to debug.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/952>
2021-04-24 13:53:58 +00:00
Edward Hervey 4d3b8d1129 rtpjitterbuffer: Avoid generation of invalid timestamps
When updating timestamps and timer timeouts with a new offset, make sure that
the resulting value is valid (and not a negative (signed) value which ends up in
a massive (unsigned) value).

Fixes #571

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/960>
2021-04-22 15:23:13 +02:00
Sebastian Dröge 52ead086d9 rtpjitterbuffer: Check srcresult before waiting on the condition variable too
It might've been set to FLUSHING between the last check and the waiting,
and in that case we'd be waiting here forever now.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/944>
2021-04-13 12:30:49 +00:00
Doug Nazar b5deff7b64 rtp: fix rtptwcc to support big endian.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/942>
2021-04-13 11:35:15 +00:00
Doug Nazar 7918f80a43 rtp: fix rtphdrextrfc6464 to support big endian.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/942>
2021-04-13 11:35:15 +00:00
Nirbheek Chauhan c8827acb93 rtpjitterbuffer: More logging when calculating rfc7273 timestamps
This code can be fragile, since it is very exacting in the timestamps
that it will accept. Add more logging so it's easier to debug issues
and figure out whether it's a bug in the calculation or something
wrong in the incoming buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/934>
2021-04-09 12:48:02 +05:30
Stéphane Cerveau d16e991bf4 rtpmanager: allow per feature registration
Split plugin into features including
dynamic types which can be indiviually
registered during a static build.

More details here:

https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>
2021-03-29 12:45:22 +02:00
Sebastian Dröge 516988bfad rtpbin: Don't special-case G_SIGNAL_RUN_CLEANUP stage in signal accumulators
All these signals don't run the class handler in the CLEANUP stage.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/913>
2021-03-26 09:31:11 +00:00
Sebastian Dröge 00e73e1657 rtpjitterbuffer: Fix parsing of the mediaclk:direct= field
Due to an off-by-one when parsing the string, the most significant digit
or the clock offset was skipped when parsing the offset.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/907>
2021-03-16 18:02:48 +00:00
Seungha Yang 614f4ec5b5 rtpmanager: Fix an MSVC compile warning
We don't expect this object is a part of public library.

gstrtphdrext-twcc.c(45): warning C4273: 'gst_rtp_header_extension_twcc_get_type': inconsistent dll linkage

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/889>
2021-03-03 18:30:39 +09:00
Guillaume Desmottes 7b7e49de31 rtp: add rtphdrextrfc6464
Header Extension for Client-to-Mixer Audio Level Indication as
defined in RFC 6464.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/630>
2021-02-04 11:12:51 +01:00
Mathieu Duponchelle 6d4dcb430d rtpst2022-1-fecdec: don't xor out of bounds
When reconstituting packets from a stream with variable packet
sizes, don't xor larger packets past the length of the protected
packet

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/839>
2020-12-12 09:29:15 +00:00
Mathieu Duponchelle 6d98415fd4 rtpst2022-1-fecenc: memset when reallocating xored payload
When protecting packets with a variable payload length, we
reallocate the xored payload when needed. It is a good idea
to memset the extended memory to 0 so that we don't xor
data with garbage!

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/839>
2020-12-12 09:29:15 +00:00
Mathieu Duponchelle 081509e030 rtpst2022-1-fec-*: protect additional RTP header fields
While the standard is a bit vague about whether the padding,
extension and marker bits should be protected:

> The usage, by senders and receivers, of the following bits shall
> be defined by the associated video/audio transport standards:

It is obviously necessary and useful for some formats (eg VP8)
that those indeed be protected.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/839>
2020-12-12 09:29:15 +00:00
Matthew Waters 656af79130 rtpmanager: update for rtp header extensions
Provide an implementation of the transport-wide-cc header extension and
use it in rtpfunnel.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/808>
2020-12-04 13:24:19 +11:00
Havard Graff 79748dab2b rtpsession: never send on a non-internal source
This will end up as a "received" packet, due to the code in
source_push_rtp, which will think this is a packet being received.

Instead drop the packet and hope that either:
1. Something upstream responds to the GstRTPCollision event and changes
   SSRC used for sending.
2. That the application responds to the "on-ssrc-collision" signal, and
   forces the sender (payloader) to change its SSRC.
3. That the BYE sent to the existing user of this SSRC will respond to
   the BYE, and that we timeout this source, so we can continue sending
   using the chosen SSRC.

The test reproduces a scenario where we previously would have sent
on a non-internal source.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/817>
2020-11-13 21:35:58 +01:00
Havard Graff 97ced29277 rtpsource: rewrite timeout-check to avoid underflow
If current_time is < collision_timeout, we get an uint64 underflow, and
the check will trigger prematurely.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/817>
2020-11-13 21:30:06 +01:00
Olivier Crête 99723bc1c1 rtpsource: Report for which local SSRC is a remote RB reporting on
This is useful in the Bundle case because there may be multiple local
and remote SSRCs in the same session.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/776>
2020-11-03 12:35:54 -05:00
Havard Graff 63c7a9ae43 rtpjitterbuffer: don't send multiple instant RTX for the same packet
Due to us not properly acknowleding the time when the last RTX was sent
when scheduling a new one, it can easily happen that due to the packet
you are requesting have a PTS that is slightly old (but not too old when
adding the latency of the jitterbuffer), both its calculated second and
third (etc.) timeout could already have passed. This would lead to a burst
of RTX requests, which acts completely against its purpose, potentially
spending a lot more bandwidth than needed.

This has been properly reproduced in the test:
test_rtx_not_bursting_requests

The good news is that slightly re-thinking the logic concerning
re-requesting RTX, made it a lot simpler to understand, and allows us
to remove two members of the RtpTimer which no longer serves any purpose
due to the refactoring. If desirable the whole "delay" concept can actually
be removed completely from the timers, and simply just added to the timeout
by the caller of the API. But that can be a change for a another time.

The only external change (other than the improved behavior around bursting
RTX) is that the "delay" field now stricly represents the delay between
the PTS of the RTX-requested packet and the time it is requested on,
whereas before this calculation was more about the theoretical calculated
delay. This is visible in three other RTX-tests where the delay had
to be adjusted slightly. I am confident however that this change is
correct.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/789>
2020-10-28 01:22:24 +01:00
Nicolas Dufresne b113516241 rtpbin: Add clear-ssrc action
This action signal will delegate to clear-ssrc onto the rtpssrcdemux element
associated with the session. This allow rtpbin users to clear pads and
elements for a specific ssrc that is known to no longer be in use. This
happens when a pad is reused in rtpsrc or ristsrc.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/736>
2020-10-16 16:45:56 +00:00
Stéphane Cerveau 0429c24637 meson: update glib minimum version to 2.56
In order to support the symbol g_enum_to_string in various
project using GStreamer ( gst-validate etc.), the glib minimum
version should be 2.56.0.

Remove compat code as glib requirement
is now > 2.56

Version used by Ubuntu 18.04 LTS

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/774>
2020-10-15 18:21:54 +02:00
Mathieu Duponchelle 5fb5abc8a8 rtpst2022-1-fecenc: fix input seqnum check
We need to cast the incremented last seqnum to guint16 for
consistent checks on wraparound

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/770>
2020-10-14 14:30:34 +02:00
Sebastian Dröge 6a84dc4146 rtpst2022-1-fecenc: Don't unconditionally use GLib 2.60 APIs
g_queue_clear_full() in this case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/768>
2020-10-09 09:31:27 +03:00
Mathieu Duponchelle 591af0f38a rtpmanager: implement SMPTE 2022-1 FEC encoder
+ improve integration of FEC encoders in rtpbin

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/753>
2020-10-08 22:22:18 +00:00
Mathieu Duponchelle cff42d4c26 rtpmanager: implement SMPTE 2022-1 FEC decoder
+ improve integration of FEC decoders in rtpbin

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/753>
2020-10-08 22:22:18 +00:00
Olivier Crête 7c9a5e86fe rtpfunnel: Also forward custom sticky event
This is useful to track metadata about each group of packets

Also include a unit test

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/666>
2020-10-06 20:57:49 +00:00
Nicolas Dufresne 345f74b09d rtpbin: Remove the rtpjitterbuffer with the stream
Since !348, the jitterbuffer was only removed with the session. This restores
the original behaviour and removes the jitterbuffer when the stream is
removed. This avoid accumulating jitterbuffer objects into the bin when a
session is reused.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/735>
2020-09-24 09:54:05 -04:00
Nicolas Dufresne ecc110ca8b rtpbin: Cleanup dead code
The rtpjitterbuffer is now part of the session elements, we no longer need
to do the ref_sink dance when signalling it. It is already owned by the bin
when signalled. Also, the code that handles generic session elements already
handle the ref_sink() calls since:

03dc22951b

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/735>
2020-09-23 15:48:24 -04:00
Sebastian Dröge e4ce9887cd rtpmanager: Improve readability of "stats" docs by making the fields an actual list
Otherwise they end up all in the same line one after another.

Also add docs for the "avg-jitter" stats field of the jitterbuffer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/698>
2020-08-13 07:24:17 +00:00
Tim-Philipp Müller 10f07e84a5 rtpfunnel: protect internal srccaps with lock
These are modified from sink pad event handlers, so
could be accessed from multiple threads at the same
time.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/681>
2020-07-28 07:08:04 +00:00
Havard Graff f5fc34ae83 rtpfunnel: copy caps before sending them in a caps-event
Reason being we don't want downstream to own a ref to our
internal caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/681>
2020-07-28 07:08:04 +00:00
Mathieu Duponchelle aa34c29d3b rtpmanager: fix various documentation issues
Improper naming of properties, improper links, misc

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/684>
2020-07-27 13:51:15 +00:00
Tim-Philipp Müller 913e17e19e rtpmanager: fix "redefinition of typedef RTPTWCCManager" compiler warning
G_DECLARE_FINAL_TYPE includes this typedef as well.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/675>
2020-07-20 18:20:59 +01:00
Havard Graff 57eebe8b05 rtpstats: guard against division by zero
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/646>
2020-06-26 15:29:25 +00:00
Havard Graff e45cc475bd rtptwcc: fix pruning of ack'ed twcc-packets
Fixes #750

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/645>
2020-06-26 12:53:07 +01:00
Sebastian Dröge f8196e06d5 Revert "rtpjitterbuffer: Avoid deadlock on flush"
This reverts commit 54810bf44f

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/620>
2020-06-10 16:31:06 +00:00
U. Artie Eoff bf0842aa0c rtpjitterbuffer: g_queue_clear_full introduced in glib 2.60
Define g_queue_clear_full if glib < 2.60.

Fixes #747

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/619>
2020-06-09 13:09:20 -07:00
Thibault Saunier 29a661d4a4 rtpsession: Make internal-ssrc as show default for doc 2020-06-09 11:45:13 -04:00
Nicolas Dufresne 5b2ad31583 rtptimerqueue: Fix leak on timer collision
While the caller should make sure this does not happen, make sure timer
collision are not silently ignored and leaked.

Fixes #726

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/616>
2020-06-08 17:54:53 -04:00
Nicolas Dufresne b4f421e9aa rtpjitterbuffer: Keep JBUF lock while processing timers
Until now, do_expected_timeout() was shortly dropping the JBUF_LOCK in order
to push RTX event event without causing deadlock. As a side effect, some
CPU hung would happen as the timerqueue would get filled while looping over
the due timers. To mitigate this, we were processing the lost timer first and
placing into a queue the remainign to be processed later.

In the gap caused by an unlock, we could endup receiving one of the seqnum
present in the pending timers. In that case, the timer would not be found and
a new one was created. When we then update the expected timer, the seqnum
would already exist and the updated timer would be lost.

In this patch we remove the unlock from do_expected_timeout() and place all
pending RTX event into a queue (instead of pending timer). Then, as soon as
we have selected a timer to wait (or if there is no timer to wait for) we send
all the upstream RTX events. As we no longer unlock, we no longer need to pop
more then one timer from the queue, and we do so with the lock held, which
blocks any new colliding timers from being created.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/616>
2020-06-08 17:54:53 -04:00
Edward Hervey 54810bf44f rtpjitterbuffer: Avoid deadlock on flush
When a GST_EVENT_FLUSH_START reaches the jitterbuffer, there is a chance that
our task is currently blocking waiting for a timer.

There was two problems:
* That wait wasn't checking for flushing situations
* The flushing handling wasn't waking up that conditional (to check whether it
should abort)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/608>
2020-06-08 13:34:26 +02:00
Mathieu Duponchelle f63299ff2f plugins: uddate gst_type_mark_as_plugin_api() calls 2020-06-06 00:42:25 +02:00
Sebastian Dröge e527eb3e4c rtpbin: Initialize uninitialized variable correctly
`last_out` would be used uninitialized if the element has no `set-active`
signal. Initialize it to -1 as that's what the "default" value is
further below.

CID 1455443

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/727

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/613>
2020-06-05 11:49:17 +03:00
Thibault Saunier 6f0f41fef0 doc: Fix wrong link to GString in rtpjitterbuffer 2020-06-03 22:44:09 -04:00
Mathieu Duponchelle 37c619f995 plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-03 22:44:09 -04:00