mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-25 21:11:00 +00:00
janusvr: Add string-ids property
It forces usage of strings even if it can be parsed into an integer. This allows joining room `"133"` in a server configured with string room ids. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1466>
This commit is contained in:
parent
23955d2dbb
commit
f7ffa13543
1 changed files with 21 additions and 12 deletions
|
@ -237,6 +237,7 @@ struct Settings {
|
||||||
feed_id: String,
|
feed_id: String,
|
||||||
display_name: Option<String>,
|
display_name: Option<String>,
|
||||||
secret_key: Option<String>,
|
secret_key: Option<String>,
|
||||||
|
string_ids: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Settings {
|
impl Default for Settings {
|
||||||
|
@ -247,6 +248,7 @@ impl Default for Settings {
|
||||||
feed_id: feed_id().to_string(),
|
feed_id: feed_id().to_string(),
|
||||||
display_name: None,
|
display_name: None,
|
||||||
secret_key: None,
|
secret_key: None,
|
||||||
|
string_ids: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,6 +262,7 @@ pub struct Signaller {
|
||||||
#[property(name="feed-id", get, set, type = String, member = feed_id, blurb = "The Janus Feed ID to identify where the track is coming from")]
|
#[property(name="feed-id", get, set, type = String, member = feed_id, blurb = "The Janus Feed ID to identify where the track is coming from")]
|
||||||
#[property(name="display-name", get, set, type = String, member = display_name, blurb = "The name of the publisher in the Janus Video Room")]
|
#[property(name="display-name", get, set, type = String, member = display_name, blurb = "The name of the publisher in the Janus Video Room")]
|
||||||
#[property(name="secret-key", get, set, type = String, member = secret_key, blurb = "The secret API key to communicate with Janus server")]
|
#[property(name="secret-key", get, set, type = String, member = secret_key, blurb = "The secret API key to communicate with Janus server")]
|
||||||
|
#[property(name="string-ids", get, set, type = bool, member = string_ids, blurb = "Force passing room-id and feed-id as string even if they can be parsed into an integer")]
|
||||||
settings: Mutex<Settings>,
|
settings: Mutex<Settings>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,21 +541,27 @@ impl Signaller {
|
||||||
|
|
||||||
/* room_id and feed_id can be either a string or integer depending
|
/* room_id and feed_id can be either a string or integer depending
|
||||||
* on server configuration. The property is always a string, if we
|
* on server configuration. The property is always a string, if we
|
||||||
* can parse it to integer then assume that's what the server expects.
|
* can parse it to integer then assume that's what the server expects,
|
||||||
|
* unless string-ids=true is set to force usage of strings.
|
||||||
* Save parsed value in state to not have to parse it again for future
|
* Save parsed value in state to not have to parse it again for future
|
||||||
* API calls.
|
* API calls.
|
||||||
*/
|
*/
|
||||||
let room_id_str = settings.room_id.as_ref().unwrap();
|
if settings.string_ids {
|
||||||
match room_id_str.parse::<u32>() {
|
state.room_id = Some(RoomId::Str(settings.room_id.clone().unwrap()));
|
||||||
Ok(n) => {
|
state.feed_id = Some(RoomId::Str(settings.feed_id.clone()));
|
||||||
state.room_id = Some(RoomId::Num(n));
|
} else {
|
||||||
state.feed_id = Some(RoomId::Num(settings.feed_id.parse().unwrap()));
|
let room_id_str = settings.room_id.as_ref().unwrap();
|
||||||
}
|
match room_id_str.parse::<u32>() {
|
||||||
Err(_) => {
|
Ok(n) => {
|
||||||
state.room_id = Some(RoomId::Str(room_id_str.clone()));
|
state.room_id = Some(RoomId::Num(n));
|
||||||
state.feed_id = Some(RoomId::Str(settings.feed_id.clone()));
|
state.feed_id = Some(RoomId::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.transaction_id.clone().unwrap(),
|
state.transaction_id.clone().unwrap(),
|
||||||
|
|
Loading…
Reference in a new issue