gstreamer_webrtc/
web_rtc_ice_candidate_stats.rs
1use 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}