webrtc: janus: handle 'hangup' messages from Janus

Fix error about this message not being handled:

{
   "janus": "hangup",
   "session_id": 4758817463851315,
   "sender": 4126342934227009,
   "reason": "Close PC"
}

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1481>
This commit is contained in:
Guillaume Desmottes 2024-03-08 15:54:29 +01:00 committed by Guillaume Desmottes
parent 992f8d9a5d
commit 8f997ea4e3

View file

@ -175,6 +175,13 @@ struct InnerError {
reason: String,
}
#[derive(Serialize, Deserialize, Debug)]
struct InnerHangup {
session_id: JanusId,
sender: JanusId,
reason: String,
}
#[derive(Serialize, Deserialize, Debug)]
struct RoomJoined {
room: JanusId,
@ -240,20 +247,15 @@ struct EventMsg {
// IncomingMessage
#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "janus")]
#[serde(tag = "janus", rename_all = "lowercase")]
enum JsonReply {
#[serde(rename = "ack")]
Ack,
#[serde(rename = "success")]
Success(SuccessMsg),
#[serde(rename = "event")]
Event(EventMsg),
#[serde(rename = "webrtcup")]
WebRTCUp,
#[serde(rename = "media")]
Media,
#[serde(rename = "error")]
Error(InnerError),
HangUp(InnerHangup),
}
#[derive(Default)]
@ -519,6 +521,7 @@ impl Signaller {
JsonReply::Error(error) => {
self.raise_error(format!("code: {}, reason: {}", error.code, error.reason))
}
JsonReply::HangUp(hangup) => self.raise_error(format!("hangup: {}", hangup.reason)),
// ignore for now
JsonReply::Ack | JsonReply::Media => {}
}