Commit graph

151 commits

Author SHA1 Message Date
Matthew Waters
e2d88f0569 webrtc: propagate more errors through the promise
Return errors on promises when things fail where available.

Things like parsing errors, invalid states, missing fields, unsupported
transitions, etc.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1565>
2020-09-14 04:04:29 +00:00
Nirbheek Chauhan
16d84a2816 webrtc: Clean up the userinfo unescaping code
Continuation from 04fd705906. This is
easier to understand and also avoids two copies.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1547>
2020-08-30 09:53:42 +00:00
trilene
04fd705906 webrtc: Unescape turnserver user and password
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1530>
2020-08-26 23:37:17 +01:00
Matthew Waters
e15a8fcbdd webrtc/datachannel: clear the error after use
Fixes a memory leak

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1535>
2020-08-24 17:02:35 +10:00
Matthew Waters
7489addc0a webrtc/datachannel: free previous protocol/label fields
Fixes a memory leak

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1535>
2020-08-24 17:02:35 +10:00
Matthew Waters
9011539940 webrtc/ice: resolve .local candidates internally
Requires the system's DNS resolver to support mdns resolution.

Fixes interoperablity with recent versions of chrome/firefox that
produce .local address in for local candidates.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1139
2020-08-20 13:01:17 +10:00
Nirbheek Chauhan
d4ca8820e7 webrtc, rtmp2: Warn if the user or password aren't escaped
If the user/pass aren't escaped, the userinfo will be ambiguous and we
won't know where to split. We will accidentally get it right if the :
belongs in the password.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1481>
2020-08-03 18:12:50 +00:00
Nirbheek Chauhan
827afa206d webrtc, rtmp2: Fix parsing of userinfo in URI strings
While parsing the string, `gst_uri_from_string()` also unescapes the
userinfo. This is bad if your username contains a `:` character, since
we will then split the userinfo at the wrong location when parsing it.

To fix this, we can use the new `gst_uri_from_string_escaped()` API
that was added in
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/583

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/831

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1481>
2020-08-03 18:12:50 +00:00
Matthew Waters
597c1b4ec6 webrtc: remove private properties/signals from the now public ice object
We don't want to expose all of the webrtcbin internals to the world.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1444>
2020-07-20 15:56:20 +10:00
Olivier Crête
cceca1ffe8 webrtcbin: Expose "latency" property
This property sets the latency both on the rtpbin/rtpjittbuffer, but
also on the RTPStorage elements currently used by the FEC decoder.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1367>
2020-06-29 22:45:31 -04:00
Sebastian Dröge
aa01e6ba22 webrtcbin: Don't call gst_ghost_pad_construct() anymore
It's deprecated, unneeded and doesn't do anything anymore.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1360>
2020-06-22 17:01:34 +00:00
Matthew Waters
0f41c0f000 webrtc: fix ice control mode when we offer initially
An initial offer means we have a local description not a remote
description.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1332

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1358>
2020-06-22 12:17:09 +00:00
Mathieu Duponchelle
a048ce81d4 plugins: uddate gst_type_mark_as_plugin_api() calls 2020-06-06 00:40:42 +02:00
Thibault Saunier
d9ffa3b3b2 doc: Fix spelling of GstWebRTCICE 2020-06-04 13:33:16 -04:00
Sebastian Dröge
74f2f733be plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-04 13:33:16 -04:00
Sebastian Dröge
b25d153c34 webrtc: Add GstWebRTCDataChannel to the library API
This makes it more discoverable for bindings and allows bindings to
generate static API for the signals and functions.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1168

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1313>
2020-06-02 21:04:37 +00:00
Matthew Waters
67ae885d4c webrtc: handle an ice-lite remote offer
When the remote peer offers an ice-lite SDP, we need to configure our
ICE negotiation to be in controlling mode as the peer will not be.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1304>
2020-05-28 19:57:45 +10:00
Chris Ayoup
9937101e51 webrtc: move filtering properties to webrtcice
We want webrtcbin to only expose properties that are defined in JSEP, so
these additional properties should be moved out.  In order to access
them, the webrtcice instance is exposed from webrtcbin.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1223>
2020-05-11 05:30:59 +00:00
Chris Ayoup
ca754245e9 webrtc: allow setting local IP addresses
If a local IP address is specified, ICE gathering can be much faster
in environments where there are multiple IP addreses but only some are
usable (for example, if you are running docker on the machine).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1223>
2020-05-11 05:30:59 +00:00
Chris Ayoup
3fc8818824 webrtc: Allow toggling TCP and UDP candidates
Add some properties to allow TCP and UDP candidates to be toggled.  This
is useful in cases where someone is using this element in an environment
where it is known in advance whether a given transport will work or not
and will prevent wasting time generating and checking candidate pairs
that will not succeed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1223>
2020-05-11 05:30:59 +00:00
Matthew Waters
02c8e66ff1 webrtc: fix an off-by-one calculating low-threshold
We were not signalling low-threshold when the previous amount was at
exactly the low-threshold mark.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1247>
2020-05-06 15:49:58 +10:00
Matthew Waters
18de5f8f04 webrtc: remove debugging leftover
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1247>
2020-05-06 15:49:58 +10:00
Matthew Waters
50644f5718 webrtc: always reply to a promise
Otherwise, we defeat the purpose of a promise.

We were not replying when the state was closed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1240>
2020-05-06 02:53:27 +00:00
Matthew Waters
1f395e3ddb webrtc: name threads based on the element name
Makes debugging a busy loop possibly easier

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1240>
2020-05-06 02:53:27 +00:00
Matthew Waters
d552c6556c webrtc: correctly use the pad template
GstHarness uses this for releasing request pads correctly. Fixes
numerous leaks in the webrtc unit tests.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1240>
2020-05-06 02:53:27 +00:00
Matthew Waters
46176fbcc7 webrtc: Fix a couple of renegotiation races
When negotiating the SDP we should only connect the streams that are
actually mentioned in the SDP.  All other streams are not relevant at
this time and would likely be part of a future SDP update.  Fixes a
couple of the renegotiation webrtc unit tests.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1240>
2020-05-06 02:53:27 +00:00
Matthew Waters
b266652043 webrtcbin: also mark data channel transports as active
Fixes negotiation of a bundled sdp with only a data channel.

Without marking the transport as active, we would never unblock the
transportreceivebin and thus no data would ever reach us.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1231>
2020-05-01 03:13:46 +00:00
Matthew Waters
ce9b41f5d4 webrtcbin: fix bundle none case with remote offer bundling
If the remote is bundling, but we are not and remote is offering.
we cannot put the remote media sections into a bundled transport as that
is not how we are going to respond.

This specific failure case was that the remote ICE credentials were
never set on the ice stream and so ice connectivity would fail.

Technically, this whole bunde-policy=none handling should be removed
eventually when we implement bundle-policy=balanced.  Until such time,
we have this workaround.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1231>
2020-05-01 03:13:46 +00:00
Matthew Waters
80ede09193 webrtcbin: only start gathering on local descriptions
If we are in a state where we are answering, we would start gathering
when the offer is set which is incorrect for at least two reasons.

1. Sending ICE candidates before sending an answer is a hard error in
   all of the major browsers and will fail the negotiation.
2. If libnice ever adds the username fragment to the candidate for
   ice-restart hardening, the ice username and fragment would be
   incorrect.

JSEP also hints that the right call flow is to only start gathering when
a local description is set in 4.1.9 setLocalDescription

"This API indirectly controls the candidate gathering process."

as well as hints throughout other sections.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1226>
2020-04-30 14:47:55 +00:00
Seungha Yang
0b102d22ec webrtc: Correct symbol visibility to fix build warning on Windows
GstWebRTCDataChannel is fully internal of plugin

webrtcdatachannel.c(50): warning C4273: 'gst_webrtc_data_channel_get_type': inconsistent dll linkage

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1225>
2020-04-30 10:27:47 +00:00
Matthew Waters
319a5e5779 webrtc: mark streams as active on renegotiation as well.
Otherwise when bundling, only the changed streams would be considered as
to whether the bundled transport needs to be blocked as all streams are
inactive.

Scenario is one transceiver changes direction to inactive and as that is
the only change in transciever direction, the entire bundled transport would
be blocked even if there are other active transceivers inside the same bundled
transport that are still active.

Fix by always checking the activeness of a stream regardless of if the
transceiverr has changed direction.
2020-03-25 14:46:15 +11:00
Sebastian Dröge
5a2053e0af webrtcbin: Use GPtrArrays or store items inline instead of using GArrays of pointers 2020-03-09 21:38:42 +02:00
Jan Schmidt
8274fcd311 webrtcbin: Prevent ICE gathering state reaching complete early
The ICE gathering state can transition to complete prematurely if the
underlying ICE components complete their gathering while the initial
ICE gathering state task is queued and still pending.

In that situation, the ice gathering state task will report complete
while there are still ICE candidates queued for emission.

Prevent that by storing ICE candidates in an array and checking if
there are any pending before reporting a completed ICE gathering
state.
2020-03-10 05:47:40 +11:00
Jan Schmidt
9410ef56b8 webrtc: Protect the pending ICE candidates array
ICE candidates can be added to the array directly from the application
or from the webrtc main loop. Rename it to make it clear that it's
holding remote ICE candidates from the peer, and protect it with a
new mutex
2020-03-10 05:25:40 +11:00
Jan Schmidt
ad53de1da1 webrtc: Don't crash in ICE gathering
Fix a crash collating ICE gathering states if there are
unassociated transceivers in the list with no TransportStream
2020-03-04 23:06:52 +00:00
Jan Schmidt
905988c63f webrtc: Unblock transportreceivebin for send-only bundled streams
If there is any active mline in a bundle, we need to unblock
the transportreceivebin for DTLS setup and RTCP reception,
otherwise no data can ever start flowing.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1206
2020-03-04 10:15:19 +00:00
Jan Schmidt
cb48733ff3 webrtc: Remove RECEIVE_STATE_DROP from transportreceivebin
As per discussion in the bug, remove the drop state from transportreceivebin.
Dropping data is necessary, but for bundled config, needs to happen
further downstream after mixed flows have been separated.

Also support switching back to BLOCK from PASS state.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1206
2020-03-04 10:15:19 +00:00
Jan Schmidt
8e3472faee webrtc: Use the dtlssrtenc rtp-sync property
Instead of synchronising at the ICE transport, do clock sync for the
RTP stream at the DTLS transport via the dtlssrtpenc rtp-sync
property. This avoids delaying RTCP while waiting until it is time
to output an RTP packet when rtcp-mux is enabled.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1212
2020-02-27 12:30:32 +00:00
Jan Schmidt
499be261cd webrtc: Configure transportsendbin latency internally
Add latency configuration logic to transportsendbin to
isolate it from the overall pipeline latency. That means that
it configures minimum latency internally based on the
latency query, and sends a latency event upstream that
matches.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1209
2020-02-21 13:42:05 +11:00
Jan Schmidt
96a407334d webrtc: Merge ICE candidates to local descriptions
When emitting ICE candidates, also merge them to the local and
pending description so they show up in the SDP if those are
retrieved from the current-local-description and
pending-local-description properties.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/676
2020-02-17 14:23:56 +00:00
Sebastian Dröge
f156ee1da4 webrtcbin: Block the source pads before dtlssrtpdec inside transportreceivebin
Otherwise dropped sticky events are not actually re-sent on the next
opportunity and we can end up with data-flow before stream-start/segment
events.
2020-02-12 16:54:42 +00:00
Sebastian Dröge
4ffa6350e8 webrtc: In all blocking pad probes except for sink pads also handle serialized events
Otherwise it can happen that e.g. the stream-start event is tried to be
sent as part of pushing the first buffer. Downstream might not be in
PAUSED/PLAYING yet, so the event is rejected with GST_FLOW_FLUSHING and
because it's an event would not cause the blocking pad probe to trigger
first. This would then return GST_FLOW_FLUSHING for the buffer and shut
down all of upstream.

To solve this we return GST_PAD_PROBE_DROP for all events. In case of
sticky events they would be resent again later once we unblocked after
blocking on the buffer and everything works fine.

Don't handle events specifically in sink pad blocking pad probes as here
downstream is not linked yet and we are actually waiting for the
following CAPS event before unblocking can happen.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1172
2020-02-11 00:49:51 +00:00
Sebastian Dröge
c16d4d2c33 webrtcbin: Add a blocking pad probe for the receivebin -> sctpdec connection
Without this it might happen that received data from the DTLS transport
is already passed to sctpdec before its state was set to PLAYING. This
would cause the data to be dropped, GST_FLOW_FLUSHING to be returned and
the whole DTLS transport to shut down.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1172
among other things.
2020-02-11 00:49:51 +00:00
Sebastian Dröge
f8fa71da27 webrtcbin/transportreceivebin: Use actual pad blocks instead of an additional GCond for blocking pads
Using a GCond can easily lead to deadlocks and only duplicates the
waiting code from gstpad.c in the best case.

In this case it actually could lead to a deadlock if both RTP and RTCP
were waiting. Only one of them would be woken up because g_cond_signal()
was used instead of g_cond_broadcast().
2020-02-11 00:49:51 +00:00
Sebastian Dröge
1ecb27f221 webrtc/transportsendbin: Clean up pad probe removal
We already have a helper function for this so just use it instead of
duplicating it.
2020-02-11 00:49:51 +00:00
Mathieu Duponchelle
f8eef0aba0 webrtcbin: fix blocking of receive bin
The receive bin should block buffers from reaching dtlsdec before
the dtls connection has started.

While there was code to block its sinkpads until receive_state
was different from BLOCK, nothing was ever setting it to BLOCK
in the first place. This commit corrects this by setting the
initial state to BLOCK, directly in the constructor.

In addition, now that blocking is effective, we want to only
block buffers and buffer lists, as that's what might trigger
errors, we want to still let events and queries go through,
not doing so causes immediate deadlocks when linking the
bin.
2020-02-01 01:46:57 +01:00
Mathieu Duponchelle
7cc185bd86 webrtcbin: connect rtp funnel after updating ptmaps
We need the streams' pt maps updated before requesting pads
on rtpbin, because this is what will trigger the requesting
of FEC encoders, and our handler for this request looks for
the payload types in the relevant stream's pt map.

Fixes #1187
2020-01-21 11:17:38 +00:00
Sebastian Dröge
0c39068c89 webrtcbin: Start datachannel SCTP elements only after the DTLS connection is established
Otherwise we would start sending data to the DTLS connection before, and
the DTLS elements consider this an error.

Also RFC 8261 mentions:
  o A DTLS connection MUST be established before an SCTP association can
    be set up.
2020-01-19 11:16:34 +00:00
Sebastian Dröge
2798a80ebe webrtcbin: Add handling of unspecified peer-connection-state situation
For us it can happen that the DTLS transports are still in the process
of connecting while the ICE transport is already completed. This
situation is not specified in the spec but conceptually that means it is
still in the process of connecting.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/758
2020-01-19 11:16:34 +00:00
Sebastian Dröge
4b73322333 webrtcbin: Return the old state if we ended up being in an unspecified situation
Previously we would've returned NEW, which is usually more wrong.
2020-01-19 11:16:34 +00:00