webrtc: janus: inline JsonReply members

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2244>
This commit is contained in:
Guillaume Desmottes 2025-05-15 09:18:32 +02:00 committed by GStreamer Marge Bot
parent 8147ed59ad
commit bd7cc01377

View file

@ -158,30 +158,6 @@ enum Join {
}, },
} }
#[derive(Serialize, Deserialize, Debug)]
struct InnerError {
code: i32,
reason: String,
}
#[derive(Serialize, Deserialize, Debug)]
struct InnerHangup {
session_id: JanusId,
sender: JanusId,
reason: String,
}
#[derive(Serialize, Deserialize, Debug)]
struct InnerSlowLink {
session_id: u64,
sender: u64,
opaque_id: Option<String>,
mid: String,
media: String,
uplink: bool,
lost: u64,
}
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "videoroom", rename_all = "kebab-case")] #[serde(tag = "videoroom", rename_all = "kebab-case")]
enum VideoRoomData { enum VideoRoomData {
@ -228,33 +204,42 @@ struct DataHolder {
id: u64, id: u64,
} }
#[derive(Serialize, Deserialize, Debug)]
struct SuccessMsg {
transaction: Option<String>,
session_id: Option<u64>,
data: Option<DataHolder>,
}
#[derive(Serialize, Deserialize, Debug)]
struct EventMsg {
transaction: Option<String>,
session_id: Option<u64>,
plugindata: Option<PluginData>,
jsep: Option<Jsep>,
}
// IncomingMessage // IncomingMessage
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "janus", rename_all = "lowercase")] #[serde(tag = "janus", rename_all = "lowercase")]
enum JsonReply { enum JsonReply {
Ack, Ack,
Success(SuccessMsg), Success {
Event(EventMsg), transaction: Option<String>,
session_id: Option<u64>,
data: Option<DataHolder>,
},
Event {
transaction: Option<String>,
session_id: Option<u64>,
plugindata: Option<PluginData>,
jsep: Option<Jsep>,
},
WebRTCUp, WebRTCUp,
Media, Media,
Error(InnerError), Error {
HangUp(InnerHangup), code: i32,
SlowLink(InnerSlowLink), reason: String,
},
HangUp {
session_id: JanusId,
sender: JanusId,
reason: String,
},
SlowLink {
session_id: u64,
sender: u64,
opaque_id: Option<String>,
mid: String,
media: String,
uplink: bool,
lost: u64,
},
} }
#[derive(Default)] #[derive(Default)]
@ -444,9 +429,11 @@ impl Signaller {
self.obj() self.obj()
.emit_by_name::<()>("state-updated", &[&JanusVRSignallerState::WebrtcUp]); .emit_by_name::<()>("state-updated", &[&JanusVRSignallerState::WebrtcUp]);
} }
JsonReply::Success(success) => { JsonReply::Success {
if let Some(data) = success.data { data, session_id, ..
if success.session_id.is_none() { } => {
if let Some(data) = data {
if session_id.is_none() {
gst::trace!( gst::trace!(
CAT, CAT,
imp = self, imp = self,
@ -467,8 +454,10 @@ impl Signaller {
} }
} }
} }
JsonReply::Event(event) => { JsonReply::Event {
if let Some(PluginData::VideoRoom { data: plugindata }) = event.plugindata { plugindata, jsep, ..
} => {
if let Some(PluginData::VideoRoom { data: plugindata }) = plugindata {
match plugindata { match plugindata {
VideoRoomData::Joined { room, id } => { VideoRoomData::Joined { room, id } => {
let feed_id_changed = { let feed_id_changed = {
@ -512,7 +501,7 @@ impl Signaller {
return; return;
} }
if let Some(Jsep::Answer { sdp, .. }) = event.jsep { if let Some(Jsep::Answer { sdp, .. }) = jsep {
gst::trace!(CAT, imp = self, "Session requested successfully"); gst::trace!(CAT, imp = self, "Session requested successfully");
self.handle_answer(sdp); self.handle_answer(sdp);
} }
@ -538,12 +527,12 @@ impl Signaller {
} }
} }
} }
JsonReply::Error(error) => { JsonReply::Error { code, reason } => {
self.raise_error(format!("code: {}, reason: {}", error.code, error.reason)) self.raise_error(format!("code: {code}, reason: {reason}"))
} }
JsonReply::HangUp(hangup) => self.raise_error(format!("hangup: {}", hangup.reason)), JsonReply::HangUp { reason, .. } => self.raise_error(format!("hangup: {reason}")),
// ignore for now // ignore for now
JsonReply::Ack | JsonReply::Media | JsonReply::SlowLink(_) => {} JsonReply::Ack | JsonReply::Media | JsonReply::SlowLink { .. } => {}
} }
} }