gstreamer_webrtc/auto/
web_rtcrtp_sender.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use 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    /// An object to track the sending aspect of the stream
23    ///
24    /// Mostly matches the WebRTC RTCRtpSender interface.
25    ///
26    /// ## Properties
27    ///
28    ///
29    /// #### `priority`
30    ///  The priority from which to set the DSCP field on packets
31    ///
32    /// Readable | Writeable
33    ///
34    ///
35    /// #### `transport`
36    ///  The DTLS transport for this sender
37    ///
38    /// Readable
39    /// <details><summary><h4>Object</h4></summary>
40    ///
41    ///
42    /// #### `name`
43    ///  Readable | Writeable | Construct
44    ///
45    ///
46    /// #### `parent`
47    ///  The parent of the object. Please note, that when changing the 'parent'
48    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and `GstObject::deep-notify`
49    /// signals due to locking issues. In some cases one can use
50    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
51    /// achieve a similar effect.
52    ///
53    /// Readable | Writeable
54    /// </details>
55    ///
56    /// # Implements
57    ///
58    /// [`trait@glib::ObjectExt`]
59    #[doc(alias = "GstWebRTCRTPSender")]
60    pub struct WebRTCRTPSender(Object<ffi::GstWebRTCRTPSender, ffi::GstWebRTCRTPSenderClass>);
61
62    match fn {
63        type_ => || ffi::gst_webrtc_rtp_sender_get_type(),
64    }
65}
66
67impl WebRTCRTPSender {
68    /// Sets the content of the IPv4 Type of Service (ToS), also known as DSCP
69    /// (Differentiated Services Code Point).
70    /// This also sets the Traffic Class field of IPv6.
71    /// ## `priority`
72    /// The priority of this sender
73    #[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    /// The priority from which to set the DSCP field on packets
84    #[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    /// The DTLS transport for this sender
91    #[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 {}