From eabf31e6d041b736cbb20123740c7c8746dac4c1 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 28 Feb 2024 14:32:40 +0100 Subject: [PATCH] webrtc: janus: rename RoomId to JanusId Those weird ids are used in multiple places, not only for the room id, so best to have a more generic name. Part-of: --- net/webrtc/src/janusvr_signaller/imp.rs | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/net/webrtc/src/janusvr_signaller/imp.rs b/net/webrtc/src/janusvr_signaller/imp.rs index b46563d2..226ec2ee 100644 --- a/net/webrtc/src/janusvr_signaller/imp.rs +++ b/net/webrtc/src/janusvr_signaller/imp.rs @@ -44,7 +44,9 @@ fn feed_id() -> u32 { #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] #[serde(untagged)] -enum RoomId { +/// Ids are either u64 (default) or string in Janus, depending of the +/// `string_ids` configuration in the videoroom plugin config file. +enum JanusId { Str(String), Num(u64), } @@ -77,8 +79,8 @@ struct AttachPluginMsg { struct RoomRequestBody { request: String, ptype: String, - room: RoomId, - id: RoomId, + room: JanusId, + id: JanusId, #[serde(skip_serializing_if = "Option::is_none")] display: Option, } @@ -152,12 +154,12 @@ struct InnerError { #[derive(Serialize, Deserialize, Debug)] struct RoomJoined { - room: RoomId, + room: JanusId, } #[derive(Serialize, Deserialize, Debug)] struct RoomEvent { - room: Option, + room: Option, error_code: Option, error: Option, } @@ -224,8 +226,8 @@ struct State { session_id: Option, handle_id: Option, transaction_id: Option, - room_id: Option, - feed_id: Option, + room_id: Option, + feed_id: Option, } #[derive(Clone)] @@ -543,18 +545,18 @@ impl Signaller { * API calls. */ if settings.string_ids { - state.room_id = Some(RoomId::Str(settings.room_id.clone().unwrap())); - state.feed_id = Some(RoomId::Str(settings.feed_id.clone())); + state.room_id = Some(JanusId::Str(settings.room_id.clone().unwrap())); + state.feed_id = Some(JanusId::Str(settings.feed_id.clone())); } else { let room_id_str = settings.room_id.as_ref().unwrap(); match room_id_str.parse() { Ok(n) => { - state.room_id = Some(RoomId::Num(n)); - state.feed_id = Some(RoomId::Num(settings.feed_id.parse().unwrap())); + state.room_id = Some(JanusId::Num(n)); + state.feed_id = Some(JanusId::Num(settings.feed_id.parse().unwrap())); } Err(_) => { - state.room_id = Some(RoomId::Str(room_id_str.clone())); - state.feed_id = Some(RoomId::Str(settings.feed_id.clone())); + state.room_id = Some(JanusId::Str(room_id_str.clone())); + state.feed_id = Some(JanusId::Str(settings.feed_id.clone())); } }; }