From d216757c23c7a66ee6f201834be1a84de2aa3e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 3 Jun 2020 16:15:47 +0300 Subject: [PATCH] webrtc: Generate DataChannel bindings --- Gir_GstWebRTC.toml | 12 ++++++++++ gstreamer-webrtc/src/lib.rs | 2 ++ gstreamer-webrtc/src/web_rtc_data_channel.rs | 25 ++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 gstreamer-webrtc/src/web_rtc_data_channel.rs diff --git a/Gir_GstWebRTC.toml b/Gir_GstWebRTC.toml index 70a8cf51b..4d1174ae8 100644 --- a/Gir_GstWebRTC.toml +++ b/Gir_GstWebRTC.toml @@ -38,6 +38,8 @@ generate = [ ] manual = [ + "GLib.Bytes", + "GLib.Error", "GObject.Object", "Gst.Structure", "GstSdp.SDPMessage", @@ -77,3 +79,13 @@ final_type = true name = "new" # takes ownership of SDP message ignore = true + +[[object]] +name = "GstWebRTC.WebRTCDataChannel" +status = "generate" +final_type = true + + [[object.function]] + name = "on_error" + # takes ownership of SDP message + ignore = true diff --git a/gstreamer-webrtc/src/lib.rs b/gstreamer-webrtc/src/lib.rs index 1775a6866..ddb3c9d70 100644 --- a/gstreamer-webrtc/src/lib.rs +++ b/gstreamer-webrtc/src/lib.rs @@ -35,6 +35,8 @@ macro_rules! skip_assert_initialized { mod auto; pub use auto::*; +#[cfg(any(feature = "v1_18", feature = "dox"))] +mod web_rtc_data_channel; mod web_rtc_session_description; // Re-export all the traits in a prelude module, so that applications diff --git a/gstreamer-webrtc/src/web_rtc_data_channel.rs b/gstreamer-webrtc/src/web_rtc_data_channel.rs new file mode 100644 index 000000000..2a4a03ea7 --- /dev/null +++ b/gstreamer-webrtc/src/web_rtc_data_channel.rs @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use glib::translate::*; +use gst_web_rtc_sys; +use WebRTCDataChannel; + +use std::mem; + +impl WebRTCDataChannel { + pub fn on_error(&self, error: glib::Error) { + let error = mem::ManuallyDrop::new(error); + unsafe { + gst_web_rtc_sys::gst_webrtc_data_channel_on_error( + self.to_glib_none().0, + mut_override(error.to_glib_none().0), + ); + } + } +}