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/1481>
This commit is contained in:
Guillaume Desmottes 2024-03-07 10:25:11 +01:00 committed by Guillaume Desmottes
parent 9c6a39d692
commit 992f8d9a5d

View file

@ -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<String>,
}
#[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);
}