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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
pub mod answer;
pub mod candidates;
pub mod hangup;
pub mod invite;
#[cfg(feature = "unstable-msc2746")]
pub mod negotiate;
#[cfg(feature = "unstable-msc2746")]
pub mod reject;
#[cfg(feature = "unstable-msc2746")]
pub mod select_answer;
use serde::{Deserialize, Serialize};
use crate::{serde::StringEnum, PrivOwnedStr};
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct SessionDescription {
#[serde(rename = "type")]
pub session_type: SessionDescriptionType,
#[cfg_attr(feature = "unstable-msc2746", serde(default))]
pub sdp: String,
}
impl SessionDescription {
pub fn new(session_type: SessionDescriptionType, sdp: String) -> Self {
Self { session_type, sdp }
}
}
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "lowercase")]
#[non_exhaustive]
pub enum SessionDescriptionType {
Answer,
Offer,
#[cfg(feature = "unstable-msc2746")]
PrAnswer,
#[cfg(feature = "unstable-msc2746")]
Rollback,
#[doc(hidden)]
_Custom(PrivOwnedStr),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[serde(tag = "type", rename = "answer")]
pub struct AnswerSessionDescription {
pub sdp: String,
}
impl AnswerSessionDescription {
pub fn new(sdp: String) -> Self {
Self { sdp }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[serde(tag = "type", rename = "offer")]
pub struct OfferSessionDescription {
pub sdp: String,
}
impl OfferSessionDescription {
pub fn new(sdp: String) -> Self {
Self { sdp }
}
}
#[cfg(feature = "unstable-msc2746")]
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct CallCapabilities {
#[serde(rename = "m.call.dtmf", default)]
pub dtmf: bool,
}
#[cfg(feature = "unstable-msc2746")]
impl CallCapabilities {
pub fn new() -> Self {
Self::default()
}
pub fn is_default(&self) -> bool {
!self.dtmf
}
}