webrtc: Add accessors for WebRTCICECandidateStats

This commit is contained in:
Sebastian Dröge 2022-08-18 13:48:02 +03:00
parent 76f01516e3
commit ffa6d67868
2 changed files with 77 additions and 0 deletions

View file

@ -36,6 +36,9 @@ macro_rules! skip_assert_initialized {
mod auto; mod auto;
pub use crate::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; mod web_rtc_session_description;
// Re-export all the traits in a prelude module, so that applications // Re-export all the traits in a prelude module, so that applications

View file

@ -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())
}
}
}
}