Commit graph

236 commits

Author SHA1 Message Date
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
Doug Nazar
4fcfd5b7f9 webrtcbin: Fix race bringing up sctp data channel
Notifying before pads are linked can cause the stream to fail to start.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2256>
2021-05-19 05:49:48 +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
3bdf1e691e webrtc: Remove reundundant context object in transportsendbin
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2260>
2021-05-18 20:26:38 -04:00
Olivier Crête
51821644ba webrtc: Wait until ICE is connected to start DTLS handshake process
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2260>
2021-05-18 20:18:28 -04:00
Olivier Crête
b6965e9906 webrtcbin: Remove pad probe on nicesink
This pad probe is no longer necessary, libnice now drops
all buffers before the stream is connected. This pad problem
also caused deadlocks in some situations.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2260>
2021-05-18 19:08:48 -04: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
Matthew Waters
1ab58736df webrtc/stats: provide the twcc stats when available
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
Frederich Munch
6f2c010360 Fix missing unref of nice-agent causing sockets to never close.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1960>
2021-04-22 21:14:49 +00:00
Doug Nazar
4e29ba9fce webrtc: Fix sctp task's return type.
GstWebRTCBinFunc expects a GstStructure* return type.

Fixes segfault on PowerPC.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2188>
2021-04-22 16:14:41 -04: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
Olivier Crête
902e40cae2 webrtcbin: Reject pad request for a specific m-line if it already exists
This way, the app developer is in control.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
0e2d128bec webrtcbin: Make request-pad validation an early return
This reduces the indendation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
0f758a1730 webrtcbin: Add document for webrtcbin itself to generated doc
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
3be72a6c86 webrtc: Reset received_caps when releasing pad
This is to work around a race where the pad is accessed in the
webrtc main thread while being released.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:07 -04:00
Olivier Crête
b6114a7fed webrtcbin: Split pad name from mline
The simple case where this breaks is if you add a
datachannel and want to add a new pad (a new media) after). Another
case where this is broken is if the order of the media is forced to
something different by the peer.

It's more simple to just split both things completely. In practice, the
pads will be named in the order in which they are allocated, so it
shouldn't change the current behaviour, just enable new ones.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
2021-04-12 17:55:06 -04:00
Matthew Waters
2bed220771 webrtc: don't generate duplicate rtx payloads when bundle-policy is set
It was possible to generate a SDP that had an RTX payload type
that matched one of the media payload types when providing caps via
codec_preferences without any sink pads.

Fixes

m=video 9 UDP/TLS/RTP/SAVPF 96
...
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 nack pli
a=fmtp:96 apt=96

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2046>
2021-03-09 02:22:35 +00:00
Ilya Kreymer
92626535c7 webrtc ice: Add 'min/max-rtp-port' props for setting RTP port range
default min port == 0, max port == 65535 -- if min port == 0, uses existing random port selection (range ignored)
add 'gathering_started' flag to avoid changing ports after gathering has started
validity checks: min port <= max port enforced, error thrown otherwise
include tests to ensure port range is being utilized (by @hhardy)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/119>
2021-03-01 14:42:17 +00:00