Commit graph

174 commits

Author SHA1 Message Date
Thibault Saunier
019971a3c7 Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir 2021-09-24 16:14:36 -03:00
Johan Sternerup
1a919a1e41 webrtcbin: Return typed "sctp-transport"
With GstWebRTCSCTPTransport type exposed we can now define
"sctp-transport" property as being of this type.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2214>
2021-08-25 13:20:22 +00:00
Johan Sternerup
607ef6db60 webrtc: Split sctptransport into lib and implementation parts
GstWebRTCSCTPTransport is now made into into an abstract base class
that only contains property specifications matching the
RTCSctpTransport interface of the W3C WebRTC specification, see
https://w3c.github.io/webrtc-pc/#rtcsctptransport-interface. This
class is put into the WebRTC library to expose it for applications and
to allow for generation of bindings for non-dynamic languages using
GObject introspection.

The actual implementation is moved to the subclass WebRTCSCTPTransport
located in the WebRTC plugin.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2214>
2021-08-25 13:20:22 +00:00
Johan Sternerup
7f9bb15055 webrtcbin: Expose SCTP Transport
Being able to access the SCTP Transport object from the application
means the application can access the associated DTLS Transport object
and its ICE Transport object. This means we can observe the ICE state
also for a data-channel-only session. The collated
ice-connection-state on webrtcbin only includes the ICE Transport
objects that resides on the RTP transceivers (which is exactly how it
is specified in
https://w3c.github.io/webrtc-pc/#rtciceconnectionstate-enum).

For the consent freshness functionality (RFC 7675) to work the ICE
state must be accessible and consequently the SCTP transport must be
accessible for enabling consent freshness checking for a
data-channel-only session.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2214>
2021-08-25 13:20:22 +00:00
Matthew Waters
18314764fc webrtc: improve matching on the correct jitterbuffer
The mapping between an RTP session and the SDP m= line is not always the
same, especially when BUNDLEing is used.

This causes a failure in a specific case where if when bundling,
if mline 0 is a data channel, and mline 1 an audio/video section,
then retrieving the transceiver at mline 0 (rtp session used) will fail
and cause an assertion.

This fix is actually potentially a regression for cases where the remote
part does not provide the a=ssrc: media level SDP attributes as is now
becoming common, especially when simulcast is involved.

The correct fix actually requires reading out header extensions as used
with bundle for signalling in the actual data, what media and therefore
transceiver is being used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2467>
2021-08-16 16:15:44 +00:00
Sebastian Dröge
01c430fa45 webrtcbin: Don't assume that non-audio medias are video medias when creating transceivers
And print the unknown media kind in the logs.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2464>
2021-08-12 12:31:15 +00:00
Sebastian Dröge
7a03acc546 webrtcbin: Use the correct media for deciding the media kind when creating the transceiver from the SDP
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2464>
2021-08-12 12:31:15 +00:00
Sebastian Dröge
0e559fc2f3 webrtcbin: Sync to the clock per stream and not per bundle
By using the clocksync inside the dtlssrtpenc, all streams inside a
bundled are synchronized together. This will cause problems if their
buffers are not already arriving synchronized: clocksync would wait for
a buffer on one stream and then buffers from the other stream(s) with
lower timestamps would all be sent out too late.

Placing the clocksync before the rtpbin and rtpfunnel synchronizes each
stream individually and they will be send out more smoothly as a result.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2355>
2021-06-28 16:38:33 +00:00
Sebastian Dröge
096a7f1ac0 webrtcbin: Set transceiver kind and codec preferences immediately when creating it
Otherwise the on-new-transceiver signal will always be emitted with kind
set to UNKNOWN and no codec preferences although both are often known at
this point already.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2360>
2021-06-25 14:35:43 +03:00
Sebastian Dröge
7ee8f4539e webrtcbin: Store newly created transceivers when creating an answer also in the seen transceivers list
Otherwise it might be used a second time for another media afterwards.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2310>
2021-06-25 09:45:24 +00:00
Sebastian Dröge
4efdb40f43 webrtcbin: When creating a new transceiver as part of creating the answer also take its codec preferences into account
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2310>
2021-06-25 09:45:24 +00:00
Sebastian Dröge
b7951fb897 webrtcbin: Fix a couple of caps leaks of the offer caps
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2310>
2021-06-25 09:45:24 +00:00
Philippe Normand
0f492a39c9 webrtcbin: Stop transceivers update after first SDP error on data channel
When invalid SDP is supplied, _update_data_channel_from_sdp_media() sets the
GError, so it is invalid to continue any further SDP processing, we have to exit
early when the first error is raised.

This change is similar to the one applied in
064428cb34.
See also #1595

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2356>
2021-06-25 05:12:37 +00:00
Olivier Crête
a6593753a5 webrtc lib: Make the rtpsender struct private
This will prevent any unsafe access.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2241>
2021-06-21 20:53:09 +00:00
Philippe Normand
064428cb34 webrtcbin: Stop transceivers update after first SDP error
When invalid SDP is supplied, _update_transceiver_from_sdp_media() sets the
GError, so it is invalid to continue any further SDP processing, we have to exit
early when the first error is raised.

Fixes #1595

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2254>
2021-05-30 00:16:10 +00:00
Matthew Waters
a836bd4766 webrtcbin: advertise harder the rtcp-mux-only requirement
And ignore rtcp ICE candidates

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2239>
2021-05-19 04:42:56 +00:00
Sid Sethupathi
abe7e724ed webrtcbin: update default jb latency docs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2242>
2021-05-19 03:53:55 +00:00
Olivier Crête
f34be8a3bd webrtcbin: Intersect answer with codec prefs & capabilities
In case the local capabilities changed since the last negotiaton,
we need to re-intersect and see if the result would be different.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2183>
2021-05-13 15:05:00 -04:00
Olivier Crête
3065ac49fb webrtcbin: Ignore current caps for codec negotiation
On the sink pad, we want the caps of the current stream, those
are the "received_caps" field. If we haven't received caps yet, then
we only care about the caps that the next element can accept, that is
the caps from the peer pad (and the preferences). Otherwise, we prevent
re-negotiation to a better codec when possible.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2183>
2021-05-13 15:05:00 -04:00
Olivier Crête
4bb94c6970 webrtcbin: Remove dead code
The function is only called to create an offer, so no
need to pass the offer parameter and then check it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2183>
2021-05-13 15:05:00 -04:00
Olivier Crête
f6345b4b03 webrtcbin: Refactor codec preference retrieval
Now intersect against pads on both sides if they are available.
If the intersection fails, we now just reject the creation of the offer
or answer as it means that the codec_preferences are too restrictive or
that the caps on both sides the webrtcbin are not compatible.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2183>
2021-05-13 15:05:00 -04:00
Olivier Crête
48f4498801 webrtcbin: Intersect codec preferences with caps from pads
When creating an offer or an answer, also take into account
the caps on the pads as well as the codec preferences when both are set.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2183>
2021-05-13 15:05:00 -04:00
Olivier Crête
70befc0b21 webrtcbin: Implement caps queries on sinkpad based on codec preferences
Also includes a unit test.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2183>
2021-05-13 15:05:00 -04:00
Olivier Crête
dc6655542d webrtcbin: Hold transceiver lock when accessing codec_preferences
This is required to allow the applications to modify the preferences.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2183>
2021-05-13 15:05:00 -04:00
Johan Sternerup
4d514abfd6 webrtcbin: Fix deadlock when receiving new sctp stream
When receiving an sctp message for a stream that not yet has an
sctpdec pad associated with it means we end up in
_on_sctpdec_pad_added. At this point we're holding the sctpassocation
lock. Then it's not possible to take the pc_lock because then code
executing under the pc_lock (which means anything in the webrtc
thread) may not take the sctpassociation lock. For example, running
the data channel close procedure from the webrtc thread means we
eventually end up sending a SCTP_RESET_STREAMS packet which needs to
grab the sctpassociation lock.

This means _on_sctpdec_pad_added simply cannot take the pc_lock and
also it is not possible to postpone the channel creation as we need to
link the pads right there. The solution is to introduce a more
granular dc_lock that protects only the things that needs to be done
to create the datachannel.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2186>
2021-05-12 03:02:27 +00:00
Johan Sternerup
8dbdfad914 webrtcbin: Support closing of data channels
Support for closing WebRTC data channels as described in RFC
8831 (section 6.7) now fully supported. This means that we can now
reuse data channels that have been closed properly. Previously, an
application that created a lot of short-lived on-demand data channels
would quickly exhaust resources held by lingering non-closed data
channels.

We now use a one-to-one style socket interface to SCTP just like the
Google implementation (i.e. SOCK_STREAM instead of SOCK_SEQPACKET, see
RFC 6458). For some reason the socket interface to use was made
optional through a property "use-sock-stream" even though code wasn't
written to handle the SOCK_SEQPACKET style. Specifically the
SCTP_RESET_STREAMS command wouldn't work without passing the correct
assocation id. Changing the default interface to use from
SOCK_SEQPACKET to SOCK_STREAM now means we don't have to bother about
the association id as there is only one association per socket. For
the SCTP_RESET_STREAMS command we set it to SCTP_ALL_ASSOC just to
match the Google implementation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2186>
2021-05-12 03:02:27 +00:00
Matthew Waters
a78c907597 webrtc: only add nack pli by default if kind is video
Sending/receiving PLI's (Picture Loss Indication) for non-video doesn't
really make sense.  This also matches what the browsers do.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2220>
2021-05-06 12:19:51 +00:00
Matthew Waters
1470660976 webrtc: move webrtc_kind_from_caps() to utils
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2220>
2021-05-06 12:19:51 +00:00
François Laignel
ad3d7d34cc Use gst_element_request_pad_simple...
Instead of the deprecated gst_element_get_request_pad.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2180>
2021-05-05 06:17:14 +00:00
Matthew Waters
5835f2aa8d webrtc: advertise support for transport-cc rtcp-fb by default
Still requires explicit enabling by the application through the header
extension on all the relevant payloaders.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2207>
2021-04-29 22:01:54 +10:00
Nazar Mokrynskyi
fe190fb5eb webrtcbin: downgrade "dropping ICE candidates from SDP" from warning to debug level
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2187>
2021-04-23 00:15:26 +00:00
Olivier Crête
c690be3e03 webrtcbin: Attach rtpbin even for data channels
This is required because the same transport may later be used for RTP.
In which case the RTCP needs to flow bi-directionnally already.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2172>
2021-04-22 22:15:31 +00:00
Olivier Crête
813a320c06 webrtcbin: Filter caps isn't fixed
Fix an assertion because the filter paramter passed to
gst_caps_is_equal_fixed() wasn't fixed. So use the regular
gst_caps_is_equal() instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2175>
2021-04-19 19:06:50 -04:00
Olivier Crête
d67dcb2227 webrtcbin: Simplify answer_caps intersection code a little
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
12ab469ad3 webrtcbin: Move GstPromise reply to operation framework
This makes it possible to reply to all promises in a consistent way
without having to do a unlock/relock that is always risky.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
38ef12063d webrtcbin: Make sure PC_LOCK is release when replying to promise
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
913383166b webrtcbin: Take PC lock around all entry points
All of those action signals change the internal state, so
protect it by using the PC_LOCK

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
572c2b6783 webrtcbin: Take PC_LOCK when requesting new pad
This is needed to avoid having the state change under us.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
c7107fd940 webrtcbin: Ensure that query caps method returns valid caps
This means rejecting any caps that aren't fixed. Also, use a filter
that will create unfixed caps if the other side just returns ANY.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
09c65fe534 webrtcbin: Associate the stream with a new transceiver
Otherwise, this newly created transceiver has no stream and it
aborts later when it tries to connect the input pad.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
83e546f935 webrtcbin: Match unassociated transceiver by kind too
When a new m-line comes in that doesn't have a transceiver, only match
existing transceivers of the same kind.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
7db5848376 webrtcbin: Fix typoe in name of error GstStructure
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 18:37:27 -04:00
Olivier Crête
7f29486ba4 webrtcbin: Enforce direction on request sink pad with a specific name
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
5971a96109 webrtcbin: Try to match an existing transceiver on pad request
This should avoid creating extra transceivers that are duplicated.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
2ca4cea538 webrtcbin: Validate locked m-lines in set*Description
Verify that the remote description match the locked m-lines, otherwise
just reject the SDP.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
be84cc2c54 webrtcbin: Remove unused session_mid_map
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
08dd305a20 webrtcbin: Enforce m-line restrictions when creating offer
First fail the offer creation if the mid of an existing offer doesn't
match a forced m-mline.

Then, for all newly added mlines, first look for a transceiver that
forces this m-line, then add a "floating" one, then the data channel.
And repeat this until we're out of transceivers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
ed1f0f33a2 webrtcbin: Remember if a transceiver had a forced m-line
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
92d356d4b0 webrtcbin: Enforce same-kind on request sink pad with a specific name
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
249b2d54d7 webrtcbin: Enforce compatible caps on pad request
If a pad is requested with certain caps and there is already a
transceiver, reject the pad request if the caps don't match.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00