Commit graph

236 commits

Author SHA1 Message Date
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
Sebastian Dröge
22869356db webrtcbin: Fix transitions for the peer connection state
They're now mapping exactly to what
  https://www.w3.org/TR/webrtc/#rtcpeerconnectionstate-enum
actually specifies.

Related to https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/758
2020-01-19 11:16:34 +00:00
Sebastian Dröge
41175f4ebe webrtcbin: Fix transitions for the connection state
They're now mapping exactly to what
  https://www.w3.org/TR/webrtc/#dom-rtciceconnectionstate
actually specifies.

Related to https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/758
2020-01-19 11:16:34 +00:00
Sebastian Dröge
47ce34d32c webrtcbin: Don't consider transceivers without mid as inactive during ICE gathering state updates
We don't have any mid before parsing the SDP, which happens after we
handled the SDP answer and that usually happens long after ICE candidate
gathering is finished.

Without this all transceivers are considered inactive and as such ICE
gathering is for active transceiver was considered complete from the
very beginning.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1126
2020-01-19 10:47:59 +00:00
Sebastian Dröge
de0f803d56 webrtcbin: Don't consider RTP receivers stopped
We don't support stopping RTP receivers currently so let's not consider
them all stopped all the time. This fixes some of the ICE/DTLS state
change handling and specifically fixes the ICE gathering state.

Previously the ICE gathering state was immediately going from NEW to
COMPLETE because it considered all transceivers stopped and as such all
activate transceivers were finished gathering ICE candidates.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1126
2020-01-19 10:47:59 +00:00
Sebastian Dröge
57c982a1dd webrtcbin: Improve logging related to ICE/DTLS state changes 2020-01-19 10:47:59 +00:00
Jan Schmidt
8e87fe42ad WebRTC: Support non-trickle ICE candidates in the SDP
Add any ICE candidates from the SDP before adding pending
trickle ICE candidates to support non-trickle peers

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/678
2020-01-13 02:30:44 +11:00
Sebastian Dröge
04c5a550ad webrtc: Unmap all non-binary buffers received via the datachannel
Previously they were only unmapped in case of binary data, causing all
of them to be leaked.
2020-01-07 21:15:20 +00:00
Edward Hervey
706ec236ac webrtcdatachannels: Don't leak strings
They would leak in error cases

CID: 1455480
2019-11-21 16:38:53 +01:00
Edward Hervey
c026522084 webrtcbin: Fix memory leak
The structure is not used after this block

CID: 1455481
2019-11-21 16:25:21 +01:00
Niels De Graef
d8f61515d8 Don't pass default GLib marshallers for signals
By passing NULL to `g_signal_new` instead of a marshaller, GLib will
actually internally optimize the signal (if the marshaller is available
in GLib itself) by also setting the valist marshaller. This makes the
signal emission a bit more performant than the regular marshalling,
which still needs to box into `GValue` and call libffi in case of a
generic marshaller.

Note that for custom marshallers, one would use
`g_signal_set_va_marshaller()` with the valist marshaller instead.
2019-11-06 14:27:46 +00:00
Aaron Boxer
6d3429af34 documentation: fixed a heap o' typos 2019-11-05 09:11:25 -05:00
Tim-Philipp Müller
f218ec2794 Remove autotools build system 2019-10-14 13:54:27 +01:00
Matthew Waters
523f4e4b50 webrtc/stats: redo considering internal sources
Internal sources seem to be rtp streams we are sending whereas
non-internal sources are the rtp streams we are receiving. Redo the
statistics with that in mind.
2019-09-12 01:06:41 +00:00
Sam Gigliotti
90d939ea36 webrtcbin: Fixed memory leak in gstwebrtcstats
The function _get_stats_from_ice_transport returns a string which must be
freed by the caller. However, _get_stats_from_dtls_transport was ignoring
the return value from this function, resulting in a leak.

Ran this with valgrind. Before this fix there was a leak of 40 bytes each
time this was called. After there was no leak.
2019-08-30 15:55:35 +00:00
Mathieu Duponchelle
42adb02a10 docstrings: port ulinks to markdown links 2019-08-23 20:14:12 +02:00
David Gunzinger
e2e86658f2 webrtc: fix type of max-retransmits, make it work 2019-08-13 12:17:13 +02:00
Sebastian Dröge
28b0be4036 rtptransceiver: Remove direction setter and vfunc and replace it by a property
It was changed from a function to a property in the latest WebRTC spec.
2019-08-06 12:22:21 +00:00
Jakub Adam
831b124976 webrtcbin: Support data channel SDP offers from Chrome
When negotiating a data channel, Chrome as recent as 75 still uses SDP
based on version 05 of the SCTP SDP draft, for example:

 m=application 9 DTLS/SCTP 5000
 a=sctpmap:5000 webrtc-datachannel 1024

Implement support for parsing SCTP port out of SDP message with sctpmap
attribute. Fixes data channel negotiation with Chrome browser.
2019-07-29 22:04:08 +00:00
Ilya Smelykh
e898f1565d webrtcbin: fix GInetAddress leak 2019-07-29 15:55:36 +07:00
Mathieu Duponchelle
b42d98ca19 webrtcdatachannel: inherit directly from GObject
There's no reason for it to inherit from GstObject apart from
locking, which is easily replaced, and inheriting from
GInitiallyUnowned made introspection awkward and needlessly
complicated.
2019-07-16 21:35:47 +00:00
Sebastian Dröge
329b2d3a6a webrtcbin: Don't assert if an SDP media can't be converted to caps
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1008
2019-07-08 07:18:41 +00:00
Matthew Waters
cef839533e webrtcbin: use the latest self-generated SDP as the basis for renegotiations
Fixes multiple errors when a webrtcbin renegotiation can switch between the
offerer and the answerer.
2019-07-03 23:44:15 +00:00
Philippe Normand
36de11520e webrtc: Fix data-channel send-string doc 2019-06-23 17:03:32 +01:00
Mathieu Duponchelle
9023ac1c95 webrtcbin: fix DTLS when receivebin is set to DROP
Regression introduced by b4bdcf15b7

This commit prevents the handshake from reaching dtlsdec when
the receive state of the receive bin is set to DROP (for example
when transceivers are sendonly).

This preserves the intent of the commit, by blocking the bin
at its sinks until the receive state is no longer BLOCK, but
makes sure the handshake still goes through, by only dropping
data at the src pads, as was the case before.
2019-06-19 18:04:14 +00:00
Ali Yousuf
69e06ced7d webrtc: Fix log when adding stun server 2019-06-04 07:54:25 +00:00
Matthew Waters
95488812b2 webrtc: fix the location of signalling-state change notification
1. The spec indicates that the notification should occur near the end of
   'setting the description' processing
2. The current location with the drop of the lock could cause the 'check
   if negotiation is needed' logic to execute and become confused about
   the state of the webrtcbin's current local descriptions.
   In the bad case, the following assertions could be hit:
   g_assert (trans->mline < gst_sdp_message_medias_len (webrtc->current_local_description->sdp));
   g_assert (trans->mline < gst_sdp_message_medias_len (webrtc->current_remote_description->sdp));

Moving the signalling state change later in the set description task
means that checking for a renegotiation will early abort as the
signalling state is not STABLE before the session description and
transceivers have been updated.
2019-06-04 05:43:43 +00:00
Matthew Waters
f8911deccf webrtc: only set sctp ports if they are different
SCTPassociation will complain if we do that while running and resetting
is not something we support at the moment
2019-05-30 21:33:09 +10:00
Matthew Waters
979daea7f2 tests/webrtc: fix racy test with a prenegotiated data channel
If both data channels become ready simultaneously, then the two integer
read-add-update cycles can execute concurrently and only ever increment
once instead of the required twice.  Use an atomic add instead.
2019-05-30 21:33:09 +10:00
Matthew Waters
be011d2086 webrtc/dc: move some code from webrtcbin into the datachannel 2019-05-30 21:33:09 +10:00
Matthew Waters
a51db86ac4 webrtc: hold onto any unknown ICE candidates until the next SDP set
It is very possible for badly behaving signalling or peers to send
us ICE candidates before we receive an SDP.  While we had consideration
for that on the first set SDP, subsequent SDP's could result in
misconfigured ICE transports.  Expand the previous code to also take
into account reconfigurations.
2019-05-30 21:33:09 +10:00
Matthew Waters
177aa22bcd webrtc: Initial support for stream addition/removal
Limitations:
- No transport changes at all (ICE, DTLS)
- Codec changes are untested and probably don't work
- Stream removal doesn't remove transports (i.e. non-bundled transports
  will stay around until webrtcbin is shutdown)
- Unified Plan SDP only. No Plan-B support.
2019-05-30 21:33:09 +10:00
Matthew Waters
033e55695f webrtcbin: expose the transceiver as a pad property 2019-05-30 21:33:09 +10:00
Matthew Waters
c3c4b07ad3 webrtc/transceiver: add a set_direction function
Matches the setDirection() from the W3C spec and allows changing the
transceiver direction at the next negotiation cycle.
2019-05-30 21:33:09 +10:00
Matthew Waters
6ad0edbe92 webrtc: track and log more rtpbin state
like bye's timeouts, validation, activation, etc
2019-05-30 21:33:09 +10:00
Matthew Waters
2df7da85fe webrtc: add support for intersecting inactive transceiver directions 2019-05-30 21:33:09 +10:00
Matthew Waters
5ea7031bd0 webrtc: mark remote/local-description as readonly 2019-05-30 21:32:06 +10:00
Matthew Waters
19b3d744d8 webrtc: don't reuse stopped transceivers at all 2019-05-30 21:26:46 +10:00
Matthew Waters
4d34fe7617 webrtc: also check for a null mid to signify an unassociated transceiver
We always give our transceivers an mline on creation so that check is
not useful by itself
2019-05-30 21:26:46 +10:00
Matthew Waters
00977f263a webrtc: only check sink pads for a 'sink pads have caps' check 2019-05-30 21:26:46 +10:00
Matthew Waters
bd92b2f7c4 webrtc: fix answer creation with multiple streams and similar caps 2019-05-30 21:26:46 +10:00
Philippe Normand
9595a7a721 webrtcbin: Expose current and pending local/remote description properties
They are already handled in the property getter and setter functions but were
not formally declared in the GObject class.
2019-05-30 10:35:58 +01:00
Niels De Graef
7cd4064425 webrtc: Fix some signals' GIR annotations
This will lead to wrong bindings otherwise (and creates more correct
expectations for developers).
2019-05-17 15:28:54 +02:00
Thibault Saunier
47a49f3381 docs: Build documentation with hotdoc 2019-05-13 17:00:00 -04:00
Thibault Saunier
7fe3f36ac8 Minor documentation fixes 2019-05-13 11:36:27 -04:00
Niels De Graef
ce92cb81a0 webrtc: Fix signals documentation
Some GIR annotations were incorrect or even missing. The former isn't
good for bindings, while the latter is especially annoying for signal
handlers, as that means your arguments will get the wrong names in the
rendered documentation.
2019-05-09 14:19:01 +02:00
Mathieu Duponchelle
a2779ef366 webrtcbin: fix pt selection for FEC and RTX when BUNDLE
When we offer bundled media, payload types must be unique
across all bundled media, as they will be multiplexed in the
same session.
2019-03-15 18:37:51 +01:00
Mathieu Duponchelle
08858d753c webrtcbin: add get-transceiver signal
get-transceivers is not introspectable, and a method to get a
transceiver by index is convenient.
2019-03-12 21:04:48 +00:00
Jan Alexander Steffens (heftig)
dc0e95acab webrtcbin: Filter transport stream stats by ssrc
Since the addition of BUNDLE support, the pads and the transceivers
share a single transport stream. When getting stats from the stream,
filter by the ssrc of the current pad to avoid merging the stats for
different pads.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/889
2019-03-12 01:40:59 +00:00
Jan Alexander Steffens (heftig)
926ff109b9 webrtcbin: Syntax cleanup 2019-03-12 01:40:59 +00:00
Matthew Waters
2a1176973a webrtc: fix rtx + bundle
If bundle was used in combination with rtx, only the bundled transport
stream would have correctly configured rtx parameters.

Iterate over the payloads upfront in the bundled case to ensure the
correct payload mapping is set for the RTX elements.
2019-02-15 08:19:51 +00:00
Mathieu Duponchelle
85c75bb23b webrtc: expose ice-transport-policy property
This is the equivalent of iceTransportPolicy in the RTCConfiguration
dictionary.

Only two values are implemented:

* all: default behaviour
* relay: only gather relay candidates

The third member of the iceTransportPolicy enum, "public", is
obsolete.
2019-01-23 22:47:51 +00:00
Tim-Philipp Müller
9eb7f7cbc7 webrtc: include stdlib.h for atoi()
Fixes #857
2018-12-31 12:09:42 +00:00
Matthew Waters
b4bdcf15b7 webrtc/receive-bin: block pads before dtlssrtpdec:
Fixes SSL errors in fast-start scenarios and whenever media stream may
be received before an answer is set.
2018-12-19 00:44:06 +00:00
Matthew Waters
26a5cbddbb webrtcbin: only change the receive state after setting the dtls-client
Doing so before will cause SSL errors with fast-start implementations
like Chrome or if media data arrives before an answer.
2018-12-19 00:44:06 +00:00
Matthew Waters
0a3f662ed6 webrtc: A couple of documentation fixes
set-*-description only takes the combined GstWebRTCSessionDescription
object
2018-12-19 00:44:06 +00:00
Nirbheek Chauhan
9504fc7174 meson: Add missing gio dep to webrtcbin plugin
It's usually pulled in implicitly through gstsdp_dep, but it's
actually a private dependency there. Fixes a build failure on Windows
with newer Meson.
2018-12-05 19:58:44 +05:30
Jordan Petridis
1f562870ee Run gst-indent through the files
This is required before we enabled an indent test in the CI.

https://gitlab.freedesktop.org/gstreamer/gstreamer-project/issues/33
2018-11-28 14:18:26 +00:00
Matthew Waters
57a006d8a5 tests/webrtc: use the existing functions in the plugin
Instead of redefining our own, use the function implementations in
webrtcsdp.c and utils.c
2018-11-26 17:13:08 +11:00
Matthew Waters
14ee6f9d35 webrtc: fix typo in RTCRemoteOutboundRTPStreamStats 2018-11-26 16:21:58 +11:00
Matthew Waters
a42fdbb012 webrtc: add a few comments on bundle and src pad exposure 2018-11-26 16:21:19 +11:00
Matthew Waters
6f91a191de webrtcbin: factor out dtls fingerprint setting 2018-11-26 16:20:02 +11:00
Matthew Waters
3a2566c61f webrtc: remove extra 'pad' from log line 2018-11-26 16:12:03 +11:00
Matthew Waters
5ecca0bb22 webrtc: move some functions to the appropriate files 2018-11-26 16:07:57 +11:00
Harshad Khedkar
9ad618e487 Webrtcbin : Need to use 'host' from gst_uri_get_host s libnice agent expects it
Currently master code of gst1-plugins-bad use plain-string host name while passing it to
libnice agent: nice_agent_set_relay_info() in gstwebrtcice.c while adding turn_server(_add_turn_server).

It is observered that if we don't convert the host parameter by using gst_uri_get_host, it fails in libnice agent(0.1.14-1).

Code does, actually, set the host correctly but while passing params to nice_agent_set_relay_info, it uses incorrect one.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/823
2018-11-22 18:47:13 +05:30
Tim-Philipp Müller
247cd2113e webrtc: update default libnice options
Uses feature options now.
2018-11-02 20:16:56 +00:00
Luis de Bethencourt
16c1eee36f webrtcbin: options is a placeholder argument
Make it clear this unused argument is there for planned future use.
2018-10-26 15:15:57 +01:00
Luis de Bethencourt
83b29b813e webrtcbin: ws-semantic is not supported
Don't offer something that isn't supported.
2018-10-26 14:36:47 +01:00
Mathieu Duponchelle
9f684a2f81 webrtcbin: implement support for group: BUNDLE 2018-10-15 14:17:35 +02:00
Matthew Waters
21bf3a35ac webrtc/datachannel: fix support for prenegotiated channels
With prenegotiated channels, the data-channel protocol is not used and
instead the channel's negotiation is intended to be performed out of band in
some application-specific manner.

Comes with test!
2018-10-09 02:38:14 +11:00
Matthew Waters
7bf18ad258 webrtc: start in the closed state
This means that we will reject all operations before we've transitioned
into READY.

This also fixes the tests using the default GMainContext in the NULL
state instead of the webrtcbin internal GMainContext and thread.  Also
removes a potential ordering race where on the element transitioning to
READY, an operations could have been queued on two different threads and
removing a guarentee on operation ordering.
2018-10-08 21:56:31 +11:00
Aleix Conchillo Flaqué
c4fe52395b webrtcbin: start and stop thread when changing state
It might be possible that if we set webrtcbin to the NULL state some
tasks (idle sources) are still executed and they might even freeze. The freeze
is caused because the webrtcbin tasks don't hold a reference to webrtcbin and
if it's last unref inside the idle source itself this will not allow the main
loop to finish because the main loop is waiting on the idle source to finish.

We now start and stop webrtcbin thread when changing states. This will allow
the idle sources to finish properly.

https://bugzilla.gnome.org/show_bug.cgi?id=797251
2018-10-08 13:46:55 +11:00
Matthew Waters
8e8eb41ddf webrtcdatachannel: take ref of data so it doesn't disappear 2018-09-26 16:01:57 +10:00
Matthew Waters
07e9374eff webrtcbin: add support for data channels based on SCTP
Mostly follows the W3C specification
https://www.w3.org/TR/webrtc/#peer-to-peer-data-api

With contributions from:
Mathieu Duponchelle <mathieu@centricular.com>

https://bugzilla.gnome.org/show_bug.cgi?id=794351
2018-09-21 19:45:12 +10:00
Matthew Waters
cf46d49b1e webrtcbin: functionify dependent element checks 2018-09-21 19:36:52 +10:00
Matthew Waters
f0a4713932 webrtc/stats: rename debug category not to be ice related 2018-09-21 19:36:52 +10:00
Mathieu Duponchelle
45fe050286 webrtcice: do not run host resolution from applictation thread
g_resolver_lookup_by_name is a blocking call, and should not
be run when the user sets or adds a turn-server.

https://bugzilla.gnome.org/show_bug.cgi?id=797012
2018-09-19 16:17:24 +02:00
Mathieu Duponchelle
1d6160d59c webrtcbin: New add-turn-server API
It is possible and often desirable to pass multiple ICE relays
to libnice agents, the "turn-server" property, while convenient
to use from the command line, does not allow that.

This adds a new action signal, "add-turn-server" to address that.

https://bugzilla.gnome.org/show_bug.cgi?id=797012
2018-09-19 16:17:24 +02:00
Matthew Waters
515e2d765a meson: add pkg-config file for the webrtc plugin 2018-08-31 18:08:55 +10:00
Nirbheek Chauhan
b55dfb5313 Add feature options for almost all plugins
The only plugins remaining are those that haven't been ported to Meson
yet, and msdk. Also, the tests are still automagic.

https://bugzilla.gnome.org/show_bug.cgi?id=795107
2018-07-27 19:04:38 +05:30
Sam Gigliotti
1b095e9609 webrtc: fix memory leak
When it parses SDP, it doesn't free the error object.

https://bugzilla.gnome.org/show_bug.cgi?id=796830
2018-07-19 14:30:55 +01:00
Jan Schmidt
e6a564216d webrtc: Add a warning in sdp_media_from_transceiver()
When generating caps with no ssrc, at least throw a
warning instead of using an uninitialised stack variable

https://bugzilla.gnome.org/show_bug.cgi?id=796810
2018-07-15 23:07:21 +10:00
Jan Schmidt
76a93da2a7 webrtc: Fix memory leak
Fix a leaked string when building RTX info.
2018-07-14 23:20:13 +10:00
Jan Schmidt
15d3bc9870 webrtc: Clean up and fix transportsendbin
Refactor transportsendbin, and change the way
pads are blocked on dtlssrtpenc so that they
don't interfere with state changes.

As well as being easier to read, this fixes
spurious failures shutting down webrtcbin
if DTLS negotiation hasn't completed yet.
2018-07-14 23:20:13 +10:00
Jan Schmidt
cb750efd6c webrtc: Move dtlssrtpenc state management
Move the errant piece of dtlssrtpenc state change
management from dtlstransport in the Webrtc libs,
into the transportsendbin that does the rest of
the element management so it's all in one place.
2018-07-14 23:18:50 +10:00
Mathieu Duponchelle
6fd3e2a400 find_codec_preferences: use received caps
When negotiation is triggered by receiving caps on our sink pad
probes, we could encounter a race condition where need-negotiation
is emitted and the application requires the creation of an offer
before the current caps were actually updated.

This led to retrieving incomplete caps when creating the offer,
using find_codec_preferences -> pad_get_current_caps.

Instead, as we save the caps in the probe callback anyway, it is better
and thread safe to use these if they were set.

https://bugzilla.gnome.org/show_bug.cgi?id=796801
2018-07-12 21:39:41 +02:00
Jan Schmidt
27b28f3aec webrtc: Explicitly initialise mutex and condition
Fixes random crashes when an allocated webrtcbin isn't
given fresh 0-filled memory in its allocation. It works
mostly because GMutex and GCond are automatically initialised
in that case.
2018-07-01 10:44:45 +10:00
Jan Schmidt
0fca02bb5e webrtc: Move the transportsendbin pad block removal
Move freeing of the pad blocks back to before we call the
GstBin state change function, as there's something racy
going on on the build server otherwise, where the pads don't
unblock during downward state changes.

This is a bit of a stab in the dark, since I can't recreate
the build server failure locally.
2018-06-30 01:07:32 +10:00
Jan Schmidt
bc128d6100 webrtc: Clean up pad block allocs on dispose.
Release references in pad blocks and release the memory in the
dispose function too, in case the state change doesn't get
run (because calling the parent state change fails).
2018-06-27 22:44:26 +10:00
Jan Schmidt
ed90d3b2ec webrtc: Don't deadlock on block pads on shutdown
When changing state downward, we can't set pads
to inactive if they are blocked, it will deadlock
trying to acquire the streaming lock.

Just calling the parent state change function
will do the correct things to unblock probes and
set the pad inactive, so let it do that and
remove the probes after the parent state change
function has run

https://bugzilla.gnome.org/show_bug.cgi?id=796682
2018-06-27 22:44:26 +10:00
Tim-Philipp Müller
6f46792f0f webrtc: Update for g_type_class_add_private() deprecation in recent GLib 2018-06-24 00:17:26 +02:00
Mathieu Duponchelle
33c7af8845 webrtcbin: copy sticky events on our ghostpads
This lets users call gst_pad_get_current_caps on newly-added
pads to easily determine what to plug them into.

We cannot copy sticky events unconditionally in core,
see #719437

https://bugzilla.gnome.org/show_bug.cgi?id=796387
2018-05-29 13:07:30 +02:00
Tim-Philipp Müller
ed7a98d45b webrtcbin: rtpstorage takes a 64-bit integer for "size-time" property
https://bugzilla.gnome.org/show_bug.cgi?id=796429
2018-05-28 10:43:37 +01:00
Tim-Philipp Müller
2227ef1304 meson: fix libnice fallback options 2018-05-21 14:42:56 +01:00
Tim-Philipp Müller
69fcd6391a webrtc: add some default options for libnice fallback
The tests are not very reliable, so disable for now.
2018-05-19 12:25:02 +01:00
Mathieu Duponchelle
5c450c5992 webrtcbin: implement support for FEC and RTX
https://bugzilla.gnome.org/show_bug.cgi?id=795044
2018-05-09 14:46:14 +02:00
Nirbheek Chauhan
7f7324b3e6 meson: Add a subproject fallback for libnice in webrtc 2018-05-05 18:48:13 +05:30
Sebastian Dröge
8375e33965 webrtcbin: Remove parameter from gst_webrtc_rtp_sender_new() 2018-03-16 11:07:01 +02:00
Matthew Waters
6f50d35246 webrtc: Fix ffeb09e4 conditional
Fixes ffeb09e4ab

if (sscanf(...)) {  // != 0
  error;
}

Is not correct where != 0 indicates some kind of success.

Check instead that the correct number of elements were slurped.
2018-02-08 15:51:35 +11:00
Matthew Waters
7e6b4dcb49 webrtc: change dead code to an assert
CID #1429140
2018-02-08 15:47:33 +11:00
Matthew Waters
ffeb09e4ab webrtc: bail on invalid rtpbin names
If we fail parsing rtpbin pad names, someone has screwed up so critical
and return.

CID #1429142
2018-02-08 15:29:56 +11:00
Matthew Waters
1894293d63 webrtcbin: an element that handles the transport aspects of webrtc connections
SDP's are generated and consumed according to the W3C PeerConnection API
available from https://www.w3.org/TR/webrtc/

The SDP is either created initially from the connected
sink pads/attached transceivers as in the case of generating an offer or
intersected with the connected sink pads/attached transceivers as in
the case for creating an answer.  In both cases, the rtp payloaded streams
sent by the peer are exposed as separate src pads.

The implementation supports trickle ICE, RTCP muxing, reduced size RTCP.

With contributions from:
Nirbheek Chauhan <nirbheek@centricular.com>
Mathieu Duponchelle <mathieu@centricular.com>
Edward Hervey <edward@centricular.com>

https://bugzilla.gnome.org/show_bug.cgi?id=792523
2018-02-02 15:02:21 +11:00