diff --git a/gstreamer-webrtc/src/lib.rs b/gstreamer-webrtc/src/lib.rs index 7f4eb8fab..90b7b50f0 100644 --- a/gstreamer-webrtc/src/lib.rs +++ b/gstreamer-webrtc/src/lib.rs @@ -36,6 +36,9 @@ macro_rules! skip_assert_initialized { mod auto; pub use crate::auto::*; +#[cfg(any(feature = "v1_22", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] +mod web_rtc_ice_candidate_stats; 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_ice_candidate_stats.rs b/gstreamer-webrtc/src/web_rtc_ice_candidate_stats.rs new file mode 100644 index 000000000..0c0ecf01a --- /dev/null +++ b/gstreamer-webrtc/src/web_rtc_ice_candidate_stats.rs @@ -0,0 +1,74 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use crate::WebRTCICECandidateStats; +use glib::translate::*; +use std::ffi::CStr; + +impl WebRTCICECandidateStats { + pub fn ipaddr(&self) -> Option<&str> { + unsafe { + let ptr = (*self.to_glib_none().0).ipaddr; + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + pub fn port(&self) -> u32 { + unsafe { (*self.to_glib_none().0).port } + } + + pub fn stream_id(&self) -> u32 { + unsafe { (*self.to_glib_none().0).stream_id } + } + + pub fn type_(&self) -> Option<&str> { + unsafe { + let ptr = (*self.to_glib_none().0).type_; + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + pub fn proto(&self) -> Option<&str> { + unsafe { + let ptr = (*self.to_glib_none().0).proto; + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + pub fn relay_proto(&self) -> Option<&str> { + unsafe { + let ptr = (*self.to_glib_none().0).relay_proto; + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + pub fn prio(&self) -> u32 { + unsafe { (*self.to_glib_none().0).prio } + } + + pub fn url(&self) -> Option<&str> { + unsafe { + let ptr = (*self.to_glib_none().0).url; + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } +}