Commit graph

6708 commits

Author SHA1 Message Date
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
26a6b17593 sctp: Take some socket configurations from Firefox's datachannel code
- Do not send ABORTs for unexpected packets are as response to INIT
- Enable interleaving of messages of different streams
- Configure 1MB send and receive buffer for the socket
- Enable SCTP_SEND_FAILED_EVENT and SCTP_PARTIAL_DELIVERY_EVENT events
- Set SCTP_REUSE_PORT configuration
- Set SCTP_EXPLICIT_EOR and the corresponding send flag. We probably
  want to split packets to a maximum size later and only set the flag
  on the last packet. Firefox uses 0x4000 as maximum size here.
- Enable SCTP_ENABLE_CHANGE_ASSOC_REQ
- Disable PMTUD and set an maximum initial MTU of 1200
2020-02-12 16:11:15 +00:00
Sebastian Dröge
c497370254 sctp: Start connection synchronously when starting the association
Calling bind() only sets up some data structures and calling connect()
only produces one packet before it returns. That packet is stored in a
queue that is asynchronously forwarded by the encoder's source pad loop,
so not much is happening there either. Especially no waiting is
happening here and no forwarding of data to other elements.

This fixes a race condition during connection setup: the connection
would immediately fail if we pass a packet from the peer to the socket
before bind() and connect() have returned.

This can't happen anymore as bind() and connect() have returned already
before both elements reach the PAUSED state, and in webrtcbin there is
an additional blocking pad probe before the decoder that does not let
any data pass through before that anyway.
2020-02-12 16:11:15 +00:00
Sebastian Dröge
4c5c6e68c6 sctp: Switch back to a non-recursive mutex and don't hold it while calling any usrsctp functions
The library is thread-safe by itself and potentially calls back into our
code, not only from the same thread but also from other threads. This
can easily lead to deadlocks if we try to hold our mutex on both sides.
2020-02-12 16:11:15 +00:00
Philippe Normand
9ac798ae5e wpe: Add software rendering support support
Starting from WPEBackend-FDO 1.6.x, software rendering support is available.
This features allows wpesrc to be used on machines without GPU, and/or for
testing purpose. To enable it, set the `LIBGL_ALWAYS_SOFTWARE=true` environment
variable and make sure `video/x-raw, format=BGRA` caps are negotiated by the
wpesrc element.
2020-02-11 16:47:53 +00:00
Jan Alexander Steffens (heftig)
e2cefdd6ff fluiddec: Move logging init into plugin_init
This is a nicer place to keep it. We also initialize it before touching
the drivers.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/1026
2020-02-11 12:10:50 +00:00
Jan Alexander Steffens (heftig)
9aa12399a8 fluiddec: Keep fluidsynth from probing audio drivers
It might cause problems and we don't need the drivers anyway. This also
avoids a bunch of stderr spam from the drivers.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/1026
2020-02-11 12:10:50 +00:00
Jan Alexander Steffens (heftig)
c35e80dc0e fluiddec: Avoid deprecated fluid_synth_set_sample_rate
This function is used to change the rate at runtime, which has issues:
https://github.com/FluidSynth/fluidsynth/issues/585

Use the settings key instead (which already defaults to 44100, but I did
test other rates).

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/1026
2020-02-11 12:10:50 +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
Ederson de Souza
916966606b avtp: Build with clang
Minor non-conformity on AVTP code made it not compile with clang.
2020-02-07 21:53:57 +00:00
Ederson de Souza
f1976e0de5 avtp: Plug several leaks
After finally running tests with valgrind enabled, some leaks were found
- both on code and on tests themselves. This patch plugs them all!
2020-02-07 21:53:57 +00:00
Ludvig Rappe
2d585f2b0b gstcurlhttpsink: Update HTTP header for curl 7.66
Change how content-length is set for HTTP POST headers, letting curl set
the header (given the content-length) instead of manually writing it.
This enables curl to know the content-length of the data.
In curl 7.66, if curl does not know the content-length (e.g. when
manually writing the header) curl will use Transfer-Encoding: chunked,
which might not be desired.
2020-02-07 13:24:53 +00:00
Tim-Philipp Müller
dbb0e71e70 ladspa: only multiply bounded rate properties by sample rate
We don't want to accidentally multiply G_MAXFLOAT or -GMAXFLOAT
with the sample rate.
2020-02-06 10:15:12 +00:00
Tim-Philipp Müller
ffd3e189de ladspa: fix unbounded integer properties
Use a double instead of a plain float for intermediary
property values, so we have enough bits to store INT_MAX
and it doesn't get rounded and wrapped to -1 when cast
back to a 32-bit integer.

Fixes criticals like

  g_param_spec_int: assertion 'default_value >= minimum && default_value <= maximum' failed

when loading LADSPA plugins from the Linux Studio Plugins
Project (http://lsp-plug.in) in GStreamer.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1194
2020-02-06 10:15:12 +00:00
Andre Guedes
352bf28a35 avtpsink: Implement synchronization mechanism
The avtpsink element is expected to transmit AVTPDUs at specific times,
according to GstBuffer timestamps. Currently, the transmission time is
controlled in software via the rendering synchronization mechanism
provided by GstBaseSink class. However, that mechanism may not cope with
some AVB use-cases such as Class A streams, where AVTPDUs are expected
to be transmitted at every 125 us. Thus, this patch introduces avtpsink
own mechanism which leverages the socket transmission scheduling
infrastructure introduced in Linux kernel 4.19.  When supported by the
NIC, the transmission scheduling is offloaded to the hardware, improving
transmission time accuracy considerably.

To illustrate that, a before-after experiment was carried out. The
experimental setup consisted in 2 PCs with Intel i210 card connected
back-to-back running an up-to-date Archlinux with kernel 5.3.1. In one
host gst-launch-1.0 was used to generate a 2-minute Class A stream while
the other host captured the packets. The metric under evaluation is the
transmission interval and it is measured by checking the 'time_delta'
information from ethernet frames captured at the receiving side.

The table below shows the outcome for a 48 kHz, 16-bit sample, stereo
audio stream. The unit is nanoseconds.

       |   Mean |   Stdev |     Min |     Max |   Range |
-------+--------+---------+---------+---------+---------+
Before | 125000 │    2401 │  110056 │  288432 │  178376 |
After  | 125000 │      18 │  124943 │  125055 │     112 |

Before this patch, the transmission interval mean is equal to the
optimal value (Class A stream -> 125 us interval), and it is kept the
same after the patch.  The dispersion measurements, however, had
improved considerably, meaning the system is now consistently
transmitting AVTPDUs at the correct time.

Finally, the socket transmission scheduling infrastructure requires the
system clock to be synchronized with PTP clock so this patches modifies
the AVTP plugin documentation to cover how to achieve that.
2020-02-05 22:28:12 +00:00
Andre Guedes
4f0dc8cf58 avtpsink: Prepare code to new synchronization mechanism
This patch refactors gst_avtp_sink_start() by moving all socket
initialization code to its own function. This change prepares the code
to the next patch which will introduce avtpsink's own rendering
synchronization mechanism.
2020-02-05 22:28:12 +00:00
Andre Guedes
cd03c48f88 avtpsink: Remove SOCK_NONBLOCK from avtpsink
Current avtpsink code opens the AF_PACKET socket with SOCK_NONBLOCK
option. However, we actually want sendto() to block in case there isn't
available space in socket buffer.
2020-02-05 22:28:12 +00:00
Andre Guedes
e74c807633 avtp: Refactor if_index code
This patch refactors both avtpsink and avtpsrc code so we use the
if_nametoindex() helper instead of building a request and issuing an
ioctl to get the if_index.
2020-02-05 22:28:12 +00:00
Stéphane Cerveau
4b72e8cad5 fdkaacdec: add support for mpegversion=2
Fix for #1199
2020-02-04 07:52:22 +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
Sebastian Dröge
af32ca45fa sctpassociation: Add missing return to prevent double unlock 2020-01-31 08:55:10 +02:00
Sebastian Dröge
e6c6b5ea29 sctpenc: Report errors when sending out data and the association is in error or disconnected state 2020-01-31 08:55:10 +02:00
Sebastian Dröge
6d22e80f30 sctp: Clean up association state handling and go into error/disconnected state in more circumstances 2020-01-31 08:55:10 +02:00
Sebastian Dröge
8612da865e sctpassociation: Use GStreamer logging system instead of g_warning() and g_log() 2020-01-31 08:55:10 +02:00
Sebastian Dröge
ddcfde36fa sctp: Add more logging to the encoder/decoder elements on data processing
And convert g_warning()s into normal log output instead.
2020-01-31 08:55:10 +02:00
Sebastian Dröge
db16265d86 sctpenc: Correctly log/handle errors and handle short writes 2020-01-31 08:55:10 +02:00
Sebastian Dröge
e9df80b235 sctp: Constify buffers in callbacks and functions
And free data with the correct free() function in the receive callback
by passing it to gst_buffer_new_wrapped_full() instead of
gst_buffer_new_wrapped().
2020-01-31 08:54:49 +02:00
Sebastian Dröge
fa0a233fa7 sctp: Make receive/packetout callbacks thread-safe 2020-01-30 16:07:48 +02:00
Sebastian Dröge
bff33f3b21 sctp: Add logging and missing cleanup on errors when creating pads 2020-01-30 16:00:33 +02:00
Sebastian Dröge
16ec86faf0 sctpenc: Use g_signal_emit() instead of g_signal_emit_by_name()
We have all the required information around so make use of it.
2020-01-30 15:59:12 +02:00
Sebastian Dröge
90e9f12880 sctpenc: Propagate downstream flow errors upstream
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1180
2020-01-30 15:58:30 +02:00
Sebastian Dröge
1f9c1aa489 sctpdec: Use a flow combiner for the source pad flow returns and propagate errors upstream
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1180
2020-01-30 15:56:36 +02:00
Guillermo Rodríguez
62ac77e620 waylandsink: Clear window when pipeline is stopped
When a pipeline is stopped (actually when the waylandsink element
state changes from PAUSED to READY) the video surface is cleared, but
the opaque black surface behind is not. Fix this by actually clearing
both surfaces.
2020-01-28 13:22:36 +01:00
Sebastian Dröge
0478e2dc1a ccconverter: Fill remainder of the cc_data in CDP packets with empty packets
Instead of filling it completely with zeroes. Filling with zeroes is
considered invalid by various CC implementations.
2020-01-24 09:26:28 +00: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
7fcfb6c6c5 dtls: Keep track of the connection state and signal it through all the layers
This allows the application to keep track of the underlying DTLS
connection state and act accordingly.
2020-01-19 11:16:34 +00:00
Sebastian Dröge
d66aa872ca dtls: Handle errors/close_notify at all steps and propagate through the layers properly
Previously we simply logged errors but never reported them to elements
or even to the user. Fatal errors are now properly reported.

Additionally proper connection closing is implemented based on EOS:
- dtlsenc: EOS will cause close_notify to be sent to the peer and only
           if the peer also sent back close_notify we will forward the
           EOS event.
- dtlsdec: EOS will be forwarded normally, this only means that the
           unterlying transport was closed. On receiving a DTLS packet
           containing close_notify, return EOS and send EOS downstream.
2020-01-19 11:16:34 +00:00
Sebastian Dröge
a132138f1c dtls: Propagate write errors backwards through dtlsenc/dtlsconnection 2020-01-19 11:16:34 +00:00
Sebastian Dröge
ee55dac8d4 dtls: Use a plain function pointer instead of a GClosure for the send callback
There's not point in using GClosure and going through all the
GValue/libffi infrastructure for each DTLS packet.
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