gstreamer_webrtc/auto/
web_rtcrtp_sender.rs1use crate::ffi;
7#[cfg(feature = "v1_20")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
9use crate::{WebRTCDTLSTransport, WebRTCPriorityType};
10#[cfg(feature = "v1_20")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
12use glib::{
13    prelude::*,
14    signal::{connect_raw, SignalHandlerId},
15    translate::*,
16};
17#[cfg(feature = "v1_20")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
19use std::boxed::Box as Box_;
20
21glib::wrapper! {
22    #[doc(alias = "GstWebRTCRTPSender")]
60    pub struct WebRTCRTPSender(Object<ffi::GstWebRTCRTPSender, ffi::GstWebRTCRTPSenderClass>) @extends gst::Object;
61
62    match fn {
63        type_ => || ffi::gst_webrtc_rtp_sender_get_type(),
64    }
65}
66
67impl WebRTCRTPSender {
68    #[cfg(feature = "v1_20")]
74    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
75    #[doc(alias = "gst_webrtc_rtp_sender_set_priority")]
76    #[doc(alias = "priority")]
77    pub fn set_priority(&self, priority: WebRTCPriorityType) {
78        unsafe {
79            ffi::gst_webrtc_rtp_sender_set_priority(self.to_glib_none().0, priority.into_glib());
80        }
81    }
82
83    #[cfg(feature = "v1_20")]
85    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
86    pub fn priority(&self) -> WebRTCPriorityType {
87        ObjectExt::property(self, "priority")
88    }
89
90    #[cfg(feature = "v1_20")]
92    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
93    pub fn transport(&self) -> Option<WebRTCDTLSTransport> {
94        ObjectExt::property(self, "transport")
95    }
96
97    #[cfg(feature = "v1_20")]
98    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
99    #[doc(alias = "priority")]
100    pub fn connect_priority_notify<F: Fn(&Self) + Send + Sync + 'static>(
101        &self,
102        f: F,
103    ) -> SignalHandlerId {
104        unsafe extern "C" fn notify_priority_trampoline<
105            F: Fn(&WebRTCRTPSender) + Send + Sync + 'static,
106        >(
107            this: *mut ffi::GstWebRTCRTPSender,
108            _param_spec: glib::ffi::gpointer,
109            f: glib::ffi::gpointer,
110        ) {
111            let f: &F = &*(f as *const F);
112            f(&from_glib_borrow(this))
113        }
114        unsafe {
115            let f: Box_<F> = Box_::new(f);
116            connect_raw(
117                self.as_ptr() as *mut _,
118                c"notify::priority".as_ptr() as *const _,
119                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
120                    notify_priority_trampoline::<F> as *const (),
121                )),
122                Box_::into_raw(f),
123            )
124        }
125    }
126
127    #[cfg(feature = "v1_20")]
128    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
129    #[doc(alias = "transport")]
130    pub fn connect_transport_notify<F: Fn(&Self) + Send + Sync + 'static>(
131        &self,
132        f: F,
133    ) -> SignalHandlerId {
134        unsafe extern "C" fn notify_transport_trampoline<
135            F: Fn(&WebRTCRTPSender) + Send + Sync + 'static,
136        >(
137            this: *mut ffi::GstWebRTCRTPSender,
138            _param_spec: glib::ffi::gpointer,
139            f: glib::ffi::gpointer,
140        ) {
141            let f: &F = &*(f as *const F);
142            f(&from_glib_borrow(this))
143        }
144        unsafe {
145            let f: Box_<F> = Box_::new(f);
146            connect_raw(
147                self.as_ptr() as *mut _,
148                c"notify::transport".as_ptr() as *const _,
149                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
150                    notify_transport_trampoline::<F> as *const (),
151                )),
152                Box_::into_raw(f),
153            )
154        }
155    }
156}
157
158unsafe impl Send for WebRTCRTPSender {}
159unsafe impl Sync for WebRTCRTPSender {}