Skip to content

Commit

Permalink
optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
hongcha98 committed Dec 18, 2023
1 parent b3b5344 commit 052c238
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/forward/forward_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,13 @@ impl PeerForwardInternal {
} else {
self.publish_svc_rids().await?[0].clone()
};
let peer: Option<PeerWrap> = self
let peer = self
.subscribe_group
.read()
.await
.iter()
.filter(|p| p.get_key() == key)
.map(|p| p.clone())
.next();
.find(|p| p.get_key() == key)
.cloned();
if let Some(peer) = peer {
let anchor_track_forward_map = self.anchor_track_forward_map.write().await;
for (track_remote, track_forward) in anchor_track_forward_map.iter() {
Expand Down
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async fn whep(
"Link",
format!(
"<{}/layer>; rel=\"urn:ietf:params:whep:ext:core:layer\"",
uri.to_string()
uri
),
)
}
Expand Down Expand Up @@ -290,11 +290,7 @@ async fn select_layer(
.select_layer(
id,
key,
if let Some(encoding_id) = layer.encoding_id {
Some(Layer { encoding_id })
} else {
None
},
layer.encoding_id.map(|encoding_id| Layer { encoding_id }),
)
.await?;
Ok("".to_string())
Expand Down
9 changes: 3 additions & 6 deletions src/media/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,9 @@ pub fn count_send(md: &MediaDescription) -> usize {
pub fn rids(md: &MediaDescription) -> Vec<String> {
let mut rids = vec![];
for attribute in &md.attributes {
match attribute.key.as_str() {
"rid" => {
let val = attribute.value.clone().unwrap();
rids.push(val.split(" ").next().unwrap().to_string())
}
_ => {}
if attribute.key.as_str() == "rid" {
let val = attribute.value.clone().unwrap();
rids.push(val.split(' ').next().unwrap().to_string())
}
}
rids
Expand Down

0 comments on commit 052c238

Please sign in to comment.