1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use std::ffi::CStr;
use std::fmt;
#[repr(transparent)]
#[doc(alias = "GstSDPOrigin")]
pub struct SDPOrigin(pub(crate) ffi::GstSDPOrigin);
unsafe impl Send for SDPOrigin {}
unsafe impl Sync for SDPOrigin {}
impl SDPOrigin {
pub fn username(&self) -> Option<&str> {
unsafe {
if self.0.username.is_null() {
None
} else {
Some(CStr::from_ptr(self.0.username).to_str().unwrap())
}
}
}
pub fn sess_id(&self) -> Option<&str> {
unsafe {
if self.0.sess_id.is_null() {
None
} else {
Some(CStr::from_ptr(self.0.sess_id).to_str().unwrap())
}
}
}
pub fn sess_version(&self) -> Option<&str> {
unsafe {
if self.0.sess_version.is_null() {
None
} else {
Some(CStr::from_ptr(self.0.sess_version).to_str().unwrap())
}
}
}
pub fn nettype(&self) -> Option<&str> {
unsafe {
if self.0.nettype.is_null() {
None
} else {
Some(CStr::from_ptr(self.0.nettype).to_str().unwrap())
}
}
}
pub fn addrtype(&self) -> Option<&str> {
unsafe {
if self.0.addrtype.is_null() {
None
} else {
Some(CStr::from_ptr(self.0.addrtype).to_str().unwrap())
}
}
}
pub fn addr(&self) -> Option<&str> {
unsafe {
if self.0.addr.is_null() {
None
} else {
Some(CStr::from_ptr(self.0.addr).to_str().unwrap())
}
}
}
}
impl fmt::Debug for SDPOrigin {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("SDPOrigin")
.field("username", &self.username())
.field("sess_id", &self.sess_id())
.field("sess_version", &self.sess_version())
.field("nettype", &self.nettype())
.field("addrtype", &self.addrtype())
.field("addr", &self.addr())
.finish()
}
}