webrtc: return error when sending on non-open datachannel
authorJohan Sternerup <johan.sternerup@axis.com>
Mon, 21 Mar 2022 09:29:21 +0000 (10:29 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 5 Oct 2022 11:08:30 +0000 (11:08 +0000)
commit212c09a70e910845fce6dc51ee71c28ecee7a8fb
tree0ddb48b66c90b469498e7f33c7cc27100f22f6bd
parent8f5399b15660cb096c20f1900dee097649438c60
webrtc: return error when sending on non-open datachannel

According to W3C
specification (https://w3c.github.io/webrtc-pc/#datachannel-send) we
should return InvalidStateError exception when trying to send when the
channel is not open. In the world of C/glib/gstreamer we don't have
exceptions but have to rely on gboolean/GError instead. Introducing
these calls for a change in function signature of the action signals
used to send data on the datachannel. Changing the signature of the
existing "send-string" and "send-data" signals would mean an immediate
breaking change so instead we deprecate them. Furthermore, there is no
way to express GError** as an argument to an action signal in a way
that fits language bindings (pointer-to-pointer simply does not work)
and we have to use regular functions instead.

Therefore we introduce gst_webrtc_data_channel_send_data_full() and
gst_webrtc_data_channel_send_string_full() while deprecating the old
functions and corresponding signals.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1958>
subprojects/gst-plugins-bad/ext/webrtc/webrtcdatachannel.c
subprojects/gst-plugins-bad/gst-libs/gst/webrtc/datachannel.c
subprojects/gst-plugins-bad/gst-libs/gst/webrtc/datachannel.h
subprojects/gst-plugins-bad/gst-libs/gst/webrtc/webrtc-priv.h
subprojects/gst-plugins-bad/gst-libs/gst/webrtc/webrtc_fwd.h
subprojects/gst-plugins-bad/tests/check/elements/webrtcbin.c