webrtcbin: Support closing of data channels
authorJohan Sternerup <johast@axis.com>
Tue, 20 Apr 2021 08:45:46 +0000 (10:45 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 12 May 2021 03:02:27 +0000 (03:02 +0000)
commit8dbdfad914340c2f7e0a91317e85ecb438e0ca39
tree339ad281ef17627e7cc8dd107583951db9cfd060
parentb884bcb93e291ebb80451457a21ba764e9a45d0d
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>
ext/sctp/sctpassociation.c
ext/webrtc/gstwebrtcbin.c
ext/webrtc/sctptransport.c
ext/webrtc/webrtcdatachannel.c
ext/webrtc/webrtcdatachannel.h