gstreamer_webrtc/
web_rtc_ice_candidate_stats.rs1use std::ffi::CStr;
4
5use crate::WebRTCICECandidateStats;
6
7impl WebRTCICECandidateStats {
8 pub fn ipaddr(&self) -> Option<&str> {
9 unsafe {
10 let ptr = (*self.as_ptr()).ipaddr;
11 if ptr.is_null() {
12 None
13 } else {
14 Some(CStr::from_ptr(ptr).to_str().unwrap())
15 }
16 }
17 }
18
19 pub fn port(&self) -> u32 {
20 unsafe { (*self.as_ptr()).port }
21 }
22
23 pub fn stream_id(&self) -> u32 {
24 unsafe { (*self.as_ptr()).stream_id }
25 }
26
27 pub fn type_(&self) -> Option<&str> {
28 unsafe {
29 let ptr = (*self.as_ptr()).type_;
30 if ptr.is_null() {
31 None
32 } else {
33 Some(CStr::from_ptr(ptr).to_str().unwrap())
34 }
35 }
36 }
37
38 pub fn proto(&self) -> Option<&str> {
39 unsafe {
40 let ptr = (*self.as_ptr()).proto;
41 if ptr.is_null() {
42 None
43 } else {
44 Some(CStr::from_ptr(ptr).to_str().unwrap())
45 }
46 }
47 }
48
49 pub fn relay_proto(&self) -> Option<&str> {
50 unsafe {
51 let ptr = (*self.as_ptr()).relay_proto;
52 if ptr.is_null() {
53 None
54 } else {
55 Some(CStr::from_ptr(ptr).to_str().unwrap())
56 }
57 }
58 }
59
60 pub fn prio(&self) -> u32 {
61 unsafe { (*self.as_ptr()).prio }
62 }
63
64 pub fn url(&self) -> Option<&str> {
65 unsafe {
66 let ptr = (*self.as_ptr()).url;
67 if ptr.is_null() {
68 None
69 } else {
70 Some(CStr::from_ptr(ptr).to_str().unwrap())
71 }
72 }
73 }
74
75 #[cfg(feature = "v1_28")]
76 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
77 pub fn foundation(&self) -> Option<&str> {
78 unsafe {
79 let ptr = (*self.as_ptr()).ABI.abi.foundation;
80 if ptr.is_null() {
81 None
82 } else {
83 Some(CStr::from_ptr(ptr).to_str().unwrap())
84 }
85 }
86 }
87
88 #[cfg(feature = "v1_28")]
89 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
90 pub fn related_address(&self) -> Option<&str> {
91 unsafe {
92 let ptr = (*self.as_ptr()).ABI.abi.related_address;
93 if ptr.is_null() {
94 None
95 } else {
96 Some(CStr::from_ptr(ptr).to_str().unwrap())
97 }
98 }
99 }
100
101 #[cfg(feature = "v1_28")]
102 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
103 pub fn related_port(&self) -> u32 {
104 unsafe { (*self.as_ptr()).ABI.abi.related_port }
105 }
106
107 #[cfg(feature = "v1_28")]
108 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
109 pub fn username_fragment(&self) -> Option<&str> {
110 unsafe {
111 let ptr = (*self.as_ptr()).ABI.abi.username_fragment;
112 if ptr.is_null() {
113 None
114 } else {
115 Some(CStr::from_ptr(ptr).to_str().unwrap())
116 }
117 }
118 }
119
120 #[cfg(feature = "v1_28")]
121 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
122 pub fn tcp_type(&self) -> crate::WebRTCICETcpCandidateType {
123 unsafe { glib::translate::from_glib((*self.as_ptr()).ABI.abi.tcp_type) }
124 }
125}