Commit graph

80 commits

Author SHA1 Message Date
Edward Hervey a100f36b69 webrtcbin: Don't duplicate enum string values
Some were leaked when debugging was enabled. Instead just directly use the
static strings as-is.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3347>
2022-11-07 11:21:00 +00:00
Matthew Waters 0077d13304 webrtcbin: configure rtpulpfecdec passthrough property
This allows downstream (payloaders mostly) to be able to correctly
detect actual packet loss from rtp sequence numbers.

See
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/581
for background.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1407

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3212>
2022-10-23 23:44:07 +00:00
Matthew Waters a633f5d287 webrtcbin: also add rtcp-fb ccm fir for video mlines by default
In addition to the 'nack pli' already added.  Both are supported by
rtpbin/rtpsession by default already.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3235>
2022-10-21 01:02:34 +00:00
Sangchul Lee 0f05be382b webrtcbin: Improve documentation of 'turn-server' property
Description about how to set time-limited credentials is added.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3229>
2022-10-20 15:30:07 +00:00
Sangchul Lee 93b896eb4e webrtcbin: Fix pointer dereference before null check
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3129>
2022-10-06 16:46:33 +00:00
Johan Sternerup 212c09a70e webrtc: return error when sending on non-open datachannel
According to W3C
specification (https://w3c.github.io/webrtc-pc/#datachannel-send) we
should return InvalidStateError exception when trying to send when the
channel is not open. In the world of C/glib/gstreamer we don't have
exceptions but have to rely on gboolean/GError instead. Introducing
these calls for a change in function signature of the action signals
used to send data on the datachannel. Changing the signature of the
existing "send-string" and "send-data" signals would mean an immediate
breaking change so instead we deprecate them. Furthermore, there is no
way to express GError** as an argument to an action signal in a way
that fits language bindings (pointer-to-pointer simply does not work)
and we have to use regular functions instead.

Therefore we introduce gst_webrtc_data_channel_send_data_full() and
gst_webrtc_data_channel_send_string_full() while deprecating the old
functions and corresponding signals.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1958>
2022-10-05 11:08:30 +00:00
Mathieu Duponchelle b454ec972f webrtcbin: fix picking available payload types
When picking an available payload type, we need to pick one that is
available across all media.

The previous code, when multiple media were present, looked at the first one,
noticed it had pt 96 as the media pt, then simply looked at the next media,
noticed it didn't, and decided 96 was available.

Instead, check if the pt is used by any of the media, if it is, decide
it is not available and go to the next pt. I'm fairly sure that was the
original intent.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2984>
2022-09-07 03:22:34 +00:00
Olivier Crête 4b3b234f72 webrtcbin: Allow locked mlines with no caps, as the last ones
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2439>
2022-09-02 11:52:58 +02:00
Olivier Crête 0930c467d4 webrtcbin: Reject creating an offer if a locked mline has no caps
This avoids getting in a bunch of corner cases. We'd have to insert
a "rejected" line from the start as a place-holder to get around this,
but the rest of the code just becomes more complicated, so just
disallow it for now.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2439>
2022-09-02 11:52:58 +02:00
Olivier Crête 3503599e0a webrtcbin: Store pending mid to make create-offer idempotent
If the mid is not stored in the transceiver, but it is stored in
last_offer, then a further create-offer call will just ignore that
transceiver.

Also include unit test for ensure it doesn't regress.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2439>
2022-09-02 11:52:58 +02:00
Thibault Saunier 6a4425e46a meson: Call pkgconfig.generate in the loop where we declare plugins dependencies
Removing some copy pasted code

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2970>
2022-09-01 21:17:35 +00:00
U. Artie Eoff e3e98da727 meson: webrtc: ensure definition of libgstwebrtcnice_dep
... and skip if it's disabled.

Fixes #1344

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2797>
2022-07-26 17:39:52 -04:00
yatinmaan 2c1e61ea16 webrtc: Split WebRTCICE into base classes and implementation.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2398>
2022-07-26 13:51:11 +00:00
Thibault Saunier 073df3d820 webrtcbin: Add a signal to plug bandwidth estimator elements
We need GStreamer elements to do the bandwidth estimation as this way
they can also control the pacing of the transmission flow as specified
 in the [GCC] algorithm for example.

Bandwidth estimator element are placed right before the "RTPSession" as
an "rtp-aux-sender" element. This way they can use the "Transport-wide
Congestion Control" RTCP feedback messages through the "RTPTwcc" custom
events that are sent by the rtpsession.

Applications are responsible to react to the bandwidth estimator element
and set the encoder target bitrate etc... which means that we can not
pass an estimator as an element factory, so a signal as been chosen
instead.

[GCC]: https://datatracker.ietf.org/doc/html/draft-ietf-rmcat-gcc-02

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2562>
2022-07-12 20:40:55 +00:00
Matthew Waters 6066e913ee webrtc: implement support for asynchronous host resolution
Doesn't block anymore if a mdns host resolution takes multiple seconds
to complete in e.g. stun/turn/ice candidate usage.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1961>
2022-07-05 03:20:57 +00:00
Sebastian Dröge a54eddad3a webrtcbin: Reject caps that are not valid for creating an SDP media.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2689>
2022-06-30 09:28:27 +00:00
Olivier Crête c4971a456e webrtcbin: Limit sink query to sink pads
This allows the reception of streams that don't exactly match
the codec preferences. In particular, the ssrc in the codec preferences
is local sender SSRC, the other side is expected to send a different SSRC.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2615>
2022-06-17 08:08:43 +00:00
Philippe Normand c287711418 webrtcbin: Add a prepare-data-channel GObject signal
This new signal allows data-channel consumers to configure signal handlers on a
newly created data-channel, before any data or state change has been notified.

The webrtcin unit-tests were refactored to make use of this new signal.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2427>
2022-06-07 11:29:33 +00:00
Philippe Normand 779ca38229 webrtcdatachannel: Chain to parent class constructed
And add a debug log statement.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2427>
2022-06-07 11:29:32 +00:00
Olivier Crête 9fe2e1c5eb webrtcbin: Reject answers that don't contain the same number of m-line as offer
Otherwise, it segfaults later. Also add test to validate this.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2526>
2022-06-03 20:28:19 +00:00
Tim-Philipp Müller 962dc37d4f webrtc: fix build with older libnice versions
1) check for right macro name when checking for NICE_VERSION_CHECK

2) if libnice version is 0.1.18.1 this should not satisfy
   a NICE_VERSION_CHECK(0,1,19).

Fixes build with libnice 0.1.18.1 subproject checkout.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2499>
2022-05-26 18:17:49 +00:00
Philippe Normand eefd793011 webrtc: Use new libnice API to get the candidate relay address
Corresponding libnice API added in:
https://gitlab.freedesktop.org/libnice/libnice/-/merge_requests/229 (0.1.19)
https://gitlab.freedesktop.org/libnice/libnice/-/merge_requests/232 (0.1.20)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998>
2022-05-26 10:54:59 +00:00
Philippe Normand 08021caa73 webrtc: Ensure the NICE_CHECK_VERSION macro is available
This macro was introduced in libnice 0.1.19.1, so until we bump our libnice
dependency to 0.1.20 we have to vendor the macro.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998>
2022-05-26 10:54:59 +00:00
Philippe Normand c19319c777 webrtc: Refactor ICECandidateStats freeing logic to a dedicated function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998>
2022-05-26 10:54:59 +00:00
Philippe Normand dce8a7750d webrtcbin: Document IceCandidateStats and RTCIceCandidatePairStats
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998>
2022-05-26 10:54:59 +00:00
Sherrill Lin 3e7fb83393 webrtcstats: Improve selected candidate pair stats by adding ICE candidate info
The implementation follows w3.org specs:
* https://www.w3.org/TR/webrtc-stats/#icecandidate-dict*
* https://www.w3.org/TR/webrtc-stats/#candidatepair-dict*

Corresponding unit tests are also added.

Rebased and updated from
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1462

Fixes #1207

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998>
2022-05-26 10:54:59 +00:00
Matthew Waters be2dfd0c36 webrtcbin: reuese the same fec/rtx/red payload types for the same media payload
WHen bundling, if multiple medias are used with the same media payload, then
each of the fec/rtx/red additions would add a distinct payload.  This could
very easily overflow the available payload space.

Instead, track the relationship between the media payload value and
the relevant fec/rtx/red payload values and reuse them whenever
necessary, even when bundling.

e.g.

...
a=group:BUNDLE video0 video1
m=video 9 UDP/SAVPF 96 97
a=mid:video0
a=rtpmap:96 VP8/90000
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
...
m=video 9 UDP/SAVPF 96 97
a=mid:video1
a=rtpmap:96 VP8/90000
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
...

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2474>
2022-05-24 10:21:11 +00:00
Philippe Normand 556ee45bfa datachannel: Notify low buffered amount according to spec
Quoting
https://www.w3.org/TR/webrtc/#dom-rtcdatachannel-bufferedamountlowthreshold

The bufferedAmountLowThreshold attribute sets the threshold at which the
bufferedAmount is considered to be low. When the bufferedAmount decreases from
above this threshold to **equal** or below it, the bufferedamountlow event fires.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2448>
2022-05-19 05:52:51 +00:00
Ludvig Rappe 26263c194e webrtc: Fix memory leak in icestream
Since both g_value_set_object() and g_weak_ref_get() takes a reference
there will be two new references to the GstWebRTCICE object when there
should be only one. g_value_take_object() has the same functionality as
g_value_set_object() but does not take a reference.

Without this change, the GstWebRTCICE object will be leaked.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2333>
2022-04-29 21:52:43 +00:00
Sangchul Lee c5b1eecb69 webrtcbin: Avoid access of freed memory
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2256>
2022-04-22 14:45:05 +00:00
Johan Sternerup 1842ffc906 webrtc: Improve robustness of nice agent signal handlers
NiceAgent and it's associated thread is alive for as long as
GstWebRTCICE is alive so make sure any signal handlers connected to
NiceAgent do not access data that is deleted earlier.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2073>
2022-04-04 02:10:35 +00:00
Xavier Claessens b004464ac6 Remove glib and gobject dependencies everywhere
They are part of gst_dep already and we have to make sure to always have
gst_dep. The order in dependencies matters, because it is also the order
in which Meson will set -I args. We want gstreamer's config.h to take
precedence over glib's private config.h when it's a subproject.

While at it, remove useless fallback args for gmodule/gio dependencies,
only gstreamer core needs it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2031>
2022-04-01 16:32:17 +00:00
Sangchul Lee a801d6dd63 webrtcstats: Unify 'packets-lost' data type to int64
Previously, 'packets-lost' member of RTCReceivedRtpStreamStats had
a value of G_TYPE_INT from rtpsource or a value of G_TYPE_UINT64
from rtpjitterbuffer.
Because of the negative value of estimated amount of packets lost
in rtpsource as well as the description in
https://www.w3.org/TR/webrtc-stats/#dom-rtcreceivedrtpstreamstats
it is fixed to set this value with G_TYPE_INT64.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2049>
2022-03-31 05:37:39 +00:00
Matthew Waters 041eee6c2e webrtc: produce stats for all relevant streams
Instead of only using the last ssrc that was pushed into a sink pad.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:41 +00:00
Matthew Waters 04de1a161f webrtc: avoid different versions of gnu-indent always wanting to change !!
Add some sneaky parenthesis to avoid always having to use git commit -n
or revert out hunk of the change.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:41 +00:00
Matthew Waters 5bfe36746a webrtc: implement initial simulcast fec/rtx usage
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:41 +00:00
Matthew Waters 5741ee38e0 webrtc/datachannel: fix use-after-free in sctp state notification
g_signal_disconnect*() doesn't stop any existing callbacks from running
which means that if the notify::state callback is in progress in one
thread and the data channel object is finalize()ed in another thread,
then there could be a use-after-free trying lock the data channel
object.

We can't reasonably use a GWeakRef as we don't have a 'parent' object to
free the GWeakRef after the data channel is finalized.  This is also
complicated by the fact that the application can hold a reference to the
data channel object that would live beyond the lifetime of webrtcbin
itself.

We solve this by implementing a ghetto weak-ref solution internally with
a list of outstanding data channels.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters 2377f8b3f2 webrtcbin: initial support for sending and receiving simulcast streams
Input (sink pads) is the already-ssrc-muxed stream with the relevant rtp
sdes header extensions already applied:
  - mid
  - stream-id
  - repaired-stream-id

Output (src pads) have the pads separated into individual ssrc's as
that's what rtpbin gives us.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters 699739c130 webrtcbin: support multiple received streams for a single mline
Each rtpbin exposed recv_src pad is now exposed as webrtcbin src_%u pad
now with no meaining applied to the value of %u.  Previously this used
to mean the mline in the SDP.  If this is is still required, then the
transceiver can be retrieved from the pad and the "mlineindex" property
from the transciever.  The "mid" is also retrievable from the
transceiver.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters e28c45fd05 webrtc: explicitly error out in a couple of renegotiation cases
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters 318a639e43 webrtc/transportstream: add debug category
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters 2aeca9ed84 webrtcbin: don't name src pads based on the mline specifically anymore
Naming based on the mline doesn't really work with e.g. simulcast
scenarios.

It is entirely possible to retrieve the transceiver and then the mline
from that if that is so required.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters cda81bdb1e webrtcbin: improve some debugging output
- Put human readable names into debug strings.
- Demote some frequent rtpbin signal logging
- Don't use GST_PTR_FORMAT in g_set_error()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters 533d4937fe webrtcbin: add a specific find_transceiver_by_mid function
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters 79d58200c9 webrtcbin: explicitly use a variable for the rtp session idx
Slightly clearer in meaning.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Matthew Waters 9a758d78a9 webrtcbin: support using an a=mid value from the sink/transceiver caps
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
2022-03-29 23:55:40 +00:00
Sangchul Lee 952c1194f3 webrtcbin: Update documentation of 'get-stats' action signal
Some stats fields are updated according to the current implementation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2005>
2022-03-25 07:01:40 +00:00
Mathieu Duponchelle 29de0e8e1d Revert "webrtcbin: fix msid line and allow customization"
This reverts commit 3cad3455377d5a22faa138d9df840257059776c8.

That commit was breaking the association between an audio and
a video track in the standard case.

In practice, to support carrying separate MediaStream, we are
going a way to map what MediaStreamTrack belong to what MediaStream,
but that will require some thinking about the API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2023>
2022-03-25 00:31:58 +01:00
Mathieu Duponchelle 06fec40f45 webrtcbin: fix msid line and allow customization
From https://datatracker.ietf.org/doc/html/draft-ietf-mmusic-msid-16:

> Multiple media descriptions with the same value for msid-id and
> msid-appdata are not permitted.

Our previous implementation of simply using the CNAME as the msid
identifier and the name of the transceiver as the msid appdata was
misguided and incorrect, and created issues when bundling multiple
video streams together: the ontrack event was emitted with the same
streams for the two bundled medias, at least in Firefox.

Instead, use the transceiver name as the identifier, and expose
a msid-appdata property on transceivers to allow for further
customization by the application. When the property is not set,
msid-appdata can be left empty as it is specified as optional.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2003>
2022-03-24 16:43:29 +00:00
Nirbheek Chauhan 253ee75a72 webrtcbin: Warn when offer didn't intersect with transceiver caps
We were silently falling back to creating a recvonly offer if the caps
didn't intersect.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1864>
2022-03-18 08:16:46 +00:00