gstreamer-rs/gstreamer-webrtc/src/auto/web_rtc_data_channel.rs

504 lines
16 KiB
Rust
Raw Normal View History

2020-06-03 12:26:16 +00:00
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
2020-06-03 12:26:16 +00:00
// DO NOT EDIT
use crate::{WebRTCDataChannelState, WebRTCPriorityType};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
2022-10-12 12:05:07 +00:00
#[cfg(any(feature = "v1_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
use std::ptr;
use std::{boxed::Box as Box_, mem::transmute};
2020-06-03 12:26:16 +00:00
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[doc(alias = "GstWebRTCDataChannel")]
2020-11-22 10:46:23 +00:00
pub struct WebRTCDataChannel(Object<ffi::GstWebRTCDataChannel, ffi::GstWebRTCDataChannelClass>);
2020-06-03 12:26:16 +00:00
match fn {
type_ => || ffi::gst_webrtc_data_channel_get_type(),
2020-06-03 12:26:16 +00:00
}
}
impl WebRTCDataChannel {
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_webrtc_data_channel_close")]
2020-06-03 12:26:16 +00:00
pub fn close(&self) {
unsafe {
2020-11-22 10:46:23 +00:00
ffi::gst_webrtc_data_channel_close(self.to_glib_none().0);
2020-06-03 12:26:16 +00:00
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_webrtc_data_channel_send_data")]
2020-06-03 12:26:16 +00:00
pub fn send_data(&self, data: Option<&glib::Bytes>) {
unsafe {
2020-11-22 10:46:23 +00:00
ffi::gst_webrtc_data_channel_send_data(self.to_glib_none().0, data.to_glib_none().0);
2020-06-03 12:26:16 +00:00
}
}
2022-10-12 12:05:07 +00:00
#[cfg(any(feature = "v1_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
#[doc(alias = "gst_webrtc_data_channel_send_data_full")]
pub fn send_data_full(&self, data: Option<&glib::Bytes>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::gst_webrtc_data_channel_send_data_full(
self.to_glib_none().0,
data.to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2022-10-12 12:05:07 +00:00
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_webrtc_data_channel_send_string")]
2020-06-03 12:26:16 +00:00
pub fn send_string(&self, str: Option<&str>) {
unsafe {
2020-11-22 10:46:23 +00:00
ffi::gst_webrtc_data_channel_send_string(self.to_glib_none().0, str.to_glib_none().0);
2020-06-03 12:26:16 +00:00
}
}
2022-10-12 12:05:07 +00:00
#[cfg(any(feature = "v1_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
#[doc(alias = "gst_webrtc_data_channel_send_string_full")]
pub fn send_string_full(&self, str: Option<&str>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::gst_webrtc_data_channel_send_string_full(
self.to_glib_none().0,
str.to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2022-10-12 12:05:07 +00:00
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "buffered-amount")]
2021-04-11 19:38:18 +00:00
pub fn buffered_amount(&self) -> u64 {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "buffered-amount")
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "buffered-amount-low-threshold")]
2021-04-11 19:38:18 +00:00
pub fn buffered_amount_low_threshold(&self) -> u64 {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "buffered-amount-low-threshold")
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "buffered-amount-low-threshold")]
2021-04-11 19:38:18 +00:00
pub fn set_buffered_amount_low_threshold(&self, buffered_amount_low_threshold: u64) {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::set_property(
self,
"buffered-amount-low-threshold",
&buffered_amount_low_threshold,
)
2020-06-03 12:26:16 +00:00
}
2021-04-11 19:38:18 +00:00
pub fn id(&self) -> i32 {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "id")
2020-06-03 12:26:16 +00:00
}
2021-04-11 19:38:18 +00:00
pub fn label(&self) -> Option<glib::GString> {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "label")
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "max-packet-lifetime")]
2021-04-11 19:38:18 +00:00
pub fn max_packet_lifetime(&self) -> i32 {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "max-packet-lifetime")
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "max-retransmits")]
2021-04-11 19:38:18 +00:00
pub fn max_retransmits(&self) -> i32 {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "max-retransmits")
2020-06-03 12:26:16 +00:00
}
2021-04-11 19:38:18 +00:00
pub fn is_negotiated(&self) -> bool {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "negotiated")
2020-06-03 12:26:16 +00:00
}
2021-04-11 19:38:18 +00:00
pub fn is_ordered(&self) -> bool {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "ordered")
2020-06-03 12:26:16 +00:00
}
2021-04-11 19:38:18 +00:00
pub fn priority(&self) -> WebRTCPriorityType {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "priority")
2020-06-03 12:26:16 +00:00
}
2021-04-11 19:38:18 +00:00
pub fn protocol(&self) -> Option<glib::GString> {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "protocol")
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "ready-state")]
2021-04-11 19:38:18 +00:00
pub fn ready_state(&self) -> WebRTCDataChannelState {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "ready-state")
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "close")]
pub fn connect_close<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
2020-06-03 12:26:16 +00:00
unsafe extern "C" fn close_trampoline<F: Fn(&WebRTCDataChannel) + Send + Sync + 'static>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"close\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
close_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
pub fn emit_close(&self) {
2021-11-21 08:35:36 +00:00
self.emit_by_name::<()>("close", &[]);
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "on-buffered-amount-low")]
pub fn connect_on_buffered_amount_low<F: Fn(&Self) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn on_buffered_amount_low_trampoline<
F: Fn(&WebRTCDataChannel) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"on-buffered-amount-low\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
on_buffered_amount_low_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "on-close")]
pub fn connect_on_close<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
2020-06-03 12:26:16 +00:00
unsafe extern "C" fn on_close_trampoline<
F: Fn(&WebRTCDataChannel) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"on-close\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
on_close_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "on-error")]
pub fn connect_on_error<F: Fn(&Self, &glib::Error) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn on_error_trampoline<
F: Fn(&WebRTCDataChannel, &glib::Error) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
error: *mut glib::ffi::GError,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(error))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"on-error\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
on_error_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "on-message-data")]
pub fn connect_on_message_data<F: Fn(&Self, Option<&glib::Bytes>) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn on_message_data_trampoline<
F: Fn(&WebRTCDataChannel, Option<&glib::Bytes>) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
data: *mut glib::ffi::GBytes,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(
&from_glib_borrow(this),
Option::<glib::Bytes>::from_glib_borrow(data)
.as_ref()
.as_ref(),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"on-message-data\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
on_message_data_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "on-message-string")]
pub fn connect_on_message_string<F: Fn(&Self, Option<&str>) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn on_message_string_trampoline<
F: Fn(&WebRTCDataChannel, Option<&str>) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
2020-06-03 12:26:16 +00:00
data: *mut libc::c_char,
2020-11-22 10:46:23 +00:00
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(
&from_glib_borrow(this),
2020-11-22 10:46:23 +00:00
Option::<glib::GString>::from_glib_borrow(data)
2020-06-03 12:26:16 +00:00
.as_ref()
2022-03-30 15:45:54 +00:00
.as_ref()
.map(|s| s.as_str()),
2020-06-03 12:26:16 +00:00
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"on-message-string\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
on_message_string_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "on-open")]
pub fn connect_on_open<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
2020-06-03 12:26:16 +00:00
unsafe extern "C" fn on_open_trampoline<
F: Fn(&WebRTCDataChannel) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"on-open\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
on_open_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "send-data")]
pub fn connect_send_data<F: Fn(&Self, Option<&glib::Bytes>) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn send_data_trampoline<
F: Fn(&WebRTCDataChannel, Option<&glib::Bytes>) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
data: *mut glib::ffi::GBytes,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(
&from_glib_borrow(this),
Option::<glib::Bytes>::from_glib_borrow(data)
.as_ref()
.as_ref(),
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"send-data\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
send_data_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
pub fn emit_send_data(&self, data: Option<&glib::Bytes>) {
2021-11-21 08:35:36 +00:00
self.emit_by_name::<()>("send-data", &[&data]);
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "send-string")]
pub fn connect_send_string<F: Fn(&Self, Option<&str>) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn send_string_trampoline<
F: Fn(&WebRTCDataChannel, Option<&str>) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
2020-06-03 12:26:16 +00:00
data: *mut libc::c_char,
2020-11-22 10:46:23 +00:00
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(
&from_glib_borrow(this),
2020-11-22 10:46:23 +00:00
Option::<glib::GString>::from_glib_borrow(data)
2020-06-03 12:26:16 +00:00
.as_ref()
2022-03-30 15:45:54 +00:00
.as_ref()
.map(|s| s.as_str()),
2020-06-03 12:26:16 +00:00
)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"send-string\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
send_string_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
pub fn emit_send_string(&self, data: Option<&str>) {
2021-11-21 08:35:36 +00:00
self.emit_by_name::<()>("send-string", &[&data]);
2020-06-03 12:26:16 +00:00
}
#[doc(alias = "buffered-amount")]
pub fn connect_buffered_amount_notify<F: Fn(&Self) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_buffered_amount_trampoline<
F: Fn(&WebRTCDataChannel) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::buffered-amount\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_buffered_amount_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "buffered-amount-low-threshold")]
pub fn connect_buffered_amount_low_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_buffered_amount_low_threshold_trampoline<
F: Fn(&WebRTCDataChannel) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::buffered-amount-low-threshold\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_buffered_amount_low_threshold_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "ready-state")]
pub fn connect_ready_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
2020-06-03 12:26:16 +00:00
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_ready_state_trampoline<
F: Fn(&WebRTCDataChannel) + Send + Sync + 'static,
>(
2020-11-22 10:46:23 +00:00
this: *mut ffi::GstWebRTCDataChannel,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
2020-06-03 12:26:16 +00:00
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::ready-state\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_ready_state_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
unsafe impl Send for WebRTCDataChannel {}
unsafe impl Sync for WebRTCDataChannel {}