Commit graph

18 commits

Author SHA1 Message Date
Matthew Waters
640a65bf96 gst: don't use volatile to mean atomic
volatile is not sufficient to provide atomic guarantees and real atomics
should be used instead.  GCC 11 has started warning about using volatile
with atomic operations.

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Discovered in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/868

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2098>
2021-03-22 14:34:36 +11:00
Sebastian Dröge
7ef393d5ff sctp: fix build with GST_DISABLE_GST_DEBUG
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1465>
2020-08-14 01:48:33 +01:00
Matthew Waters
3baf0d5dc4 sctp: enable usrsctp debug when supported
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1234>
2020-05-05 03:38:06 +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
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
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
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
Nirbheek Chauhan
70a90f0e5e sctp: Fix crash on free() when using the MSVC binaries
On Windows, if libusrsctp and gstreamer are built with different
C runtimes (CRT), we cannot free memory allocated inside libusrsctp
with the `free()` function from gstreamer's CRT.

`usrsctp_freedumpbuffer()` simply calls `free()`, but because of the
way DLLs work on Windows, it will always call the free function from
the correct CRT.
2019-08-20 14:33:41 +05:30
Fabio D'Urso
f53beb876c sctp: increase DEFAULT_NUMBER_OF_SCTP_STREAMS to 1024
This change makes it possible to create more than just 5 webrtc
data channels. The maximum number of data channels is exactly
DEFAULT_NUMBER_OF_SCTP_STREAMS / 2, therefore the limit is now
512.
2019-04-26 16:31:49 +02:00
Matthew Waters
57accd7570 sctpassociation: don't join a NULL thread
Can occur if no connection is actually made and thus no connection
thread is created.
2018-09-21 19:36:52 +10:00
George Kiagiadakis
e2f06326ea Add new SCTP plugins (sctpenc/sctpdec)
https://bugzilla.gnome.org/show_bug.cgi?id=744863
2018-09-21 19:36:52 +10:00