From 7c28fbcc4e15b5424a65089eb36b40e7bee98f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Wed, 25 Oct 2023 18:34:45 +0200 Subject: [PATCH] enhance scalability_mode parsing --- rust/src/ortc.rs | 5 +++-- rust/src/worker/channel.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rust/src/ortc.rs b/rust/src/ortc.rs index 9e232afc6f..f176e477f6 100644 --- a/rust/src/ortc.rs +++ b/rust/src/ortc.rs @@ -101,8 +101,9 @@ impl RtpMapping { ssrc: mapping?.ssrc()?, scalability_mode: mapping? .scalability_mode()? - .unwrap_or(String::from("S1T1").as_str()) - .parse()?, + .map(|maybe_scalability_mode| maybe_scalability_mode.parse()) + .transpose()? + .unwrap_or_default(), mapped_ssrc: mapping?.mapped_ssrc()?, }) }) diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index 1a9a192ba7..ea24ebe8c3 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -92,13 +92,13 @@ enum ChannelReceiveMessage<'a> { } // Remove the first 4 bytes which represent the buffer size. -// NOTE: This is only needed for NodeJS. +// NOTE: The prefix is only needed for NodeJS. fn unprefix_message(bytes: &[u8]) -> &[u8] { &bytes[4..] } fn deserialize_message(bytes: &[u8]) -> ChannelReceiveMessage<'_> { - let message_ref = message::MessageRef::read_as_root(&bytes).unwrap(); + let message_ref = message::MessageRef::read_as_root(bytes).unwrap(); match message_ref.data().unwrap() { message::BodyRef::Log(data) => match data.data().unwrap().chars().next() {