From cc317995ff25580401f77c05c5482339276ddad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 13 May 2025 13:43:32 +0300 Subject: [PATCH] webrtc: Add accessors for new 1.28 `WebRTCICECandidateStats` fields Part-of: --- .../src/web_rtc_ice_candidate_stats.rs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/gstreamer-webrtc/src/web_rtc_ice_candidate_stats.rs b/gstreamer-webrtc/src/web_rtc_ice_candidate_stats.rs index 8040ee977..005db89ff 100644 --- a/gstreamer-webrtc/src/web_rtc_ice_candidate_stats.rs +++ b/gstreamer-webrtc/src/web_rtc_ice_candidate_stats.rs @@ -71,4 +71,55 @@ impl WebRTCICECandidateStats { } } } + + #[cfg(feature = "v1_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] + pub fn foundation(&self) -> Option<&str> { + unsafe { + let ptr = (*self.as_ptr()).ABI.abi.foundation; + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + #[cfg(feature = "v1_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] + pub fn related_address(&self) -> Option<&str> { + unsafe { + let ptr = (*self.as_ptr()).ABI.abi.related_address; + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + #[cfg(feature = "v1_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] + pub fn related_port(&self) -> u32 { + unsafe { (*self.as_ptr()).ABI.abi.related_port } + } + + #[cfg(feature = "v1_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] + pub fn username_fragment(&self) -> Option<&str> { + unsafe { + let ptr = (*self.as_ptr()).ABI.abi.username_fragment; + if ptr.is_null() { + None + } else { + Some(CStr::from_ptr(ptr).to_str().unwrap()) + } + } + } + + #[cfg(feature = "v1_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] + pub fn tcp_type(&self) -> crate::WebRTCICETcpCandidateType { + unsafe { glib::translate::from_glib((*self.as_ptr()).ABI.abi.tcp_type) } + } }