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:👿:Signaller::handle_msg:<GstJanusVRWebRTCSignallerU64@0x55b166a3fe40> Unknown message from server: {
   "janus": "event",
   "session_id": 6667171862739941,
   "sender": 1964690595468240,
   "plugindata": {
      "plugin": "janus.plugin.videoroom",
      "data": {
         "videoroom": "destroyed",
         "room": 8320333573294267
      }
   }
}

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1508>
This commit is contained in:
Guillaume Desmottes 2024-03-07 10:25:11 +01:00 committed by Sebastian Dröge
parent c982db73a7
commit be055f6dfa

View file

@ -51,6 +51,15 @@ enum JanusId {
Num(u64),
}
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,
@ -166,11 +175,18 @@ struct RoomEvent {
#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "videoroom")]
struct RoomDestroyed {
room: JanusId,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "videoroom", rename_all = "kebab-case")]
enum VideoRoomData {
#[serde(rename = "joined")]
Joined(RoomJoined),
#[serde(rename = "event")]
Event(RoomEvent),
Destroyed(RoomDestroyed),
}
#[derive(Serialize, Deserialize, Debug)]
@ -447,6 +463,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
));
}
}
}
}