From 992f8d9a5d3f5cb9336bfb63748c1d0ee4aa2a10 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 7 Mar 2024 10:25:11 +0100 Subject: [PATCH] webrtc: janus: handle 'destroyed' messages from Janus Fix this error when the room is destroyed: ERROR webrtc-janusvr-signaller imp.rs:413:gstrswebrtc::janusvr_signaller::imp::Signaller::handle_msg: Unknown message from server: { "janus": "event", "session_id": 6667171862739941, "sender": 1964690595468240, "plugindata": { "plugin": "janus.plugin.videoroom", "data": { "videoroom": "destroyed", "room": 8320333573294267 } } } Part-of: --- net/webrtc/src/janusvr_signaller/imp.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/net/webrtc/src/janusvr_signaller/imp.rs b/net/webrtc/src/janusvr_signaller/imp.rs index 5bf33b86..174a1798 100644 --- a/net/webrtc/src/janusvr_signaller/imp.rs +++ b/net/webrtc/src/janusvr_signaller/imp.rs @@ -64,6 +64,15 @@ impl JanusId { } } +impl std::fmt::Display for JanusId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + JanusId::Str(s) => write!(f, "{s}"), + JanusId::Num(n) => write!(f, "{n}"), + } + } +} + #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] struct KeepAliveMsg { janus: String, @@ -179,6 +188,11 @@ struct RoomEvent { error: Option, } +#[derive(Serialize, Deserialize, Debug)] +struct RoomDestroyed { + room: JanusId, +} + #[derive(Serialize, Deserialize, Debug)] struct RoomTalking { room: JanusId, @@ -192,6 +206,7 @@ struct RoomTalking { enum VideoRoomData { Joined(RoomJoined), Event(RoomEvent), + Destroyed(RoomDestroyed), Talking(RoomTalking), StoppedTalking(RoomTalking), } @@ -484,6 +499,14 @@ impl Signaller { } } } + VideoRoomData::Destroyed(room_destroyed) => { + gst::trace!(CAT, imp: self, "Room {} has been destroyed", room_destroyed.room); + + self.raise_error(format!( + "room {} has been destroyed", + room_destroyed.room + )); + } VideoRoomData::Talking(talking) => { self.emit_talking(true, talking.id, talking.audio_level); }