Skip to content

Commit

Permalink
fix: concurrent transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
hongcha98 committed Dec 22, 2023
1 parent 3b172dc commit 4143531
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions src/forward/forward_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::hash::{Hash, Hasher};
use std::sync::{Arc, Weak};

use anyhow::Result;
use log::{debug, info};
use log::{debug, info, warn};
use tokio::sync::mpsc::{channel, unbounded_channel, Receiver, Sender, UnboundedSender};
use tokio::sync::RwLock;
use webrtc::api::interceptor_registry::register_default_interceptors;
Expand Down Expand Up @@ -255,24 +255,34 @@ impl PeerForwardInternal {
drop(subscription_group);
let mut subscription_group =
track_forward_original.subscription_group.write().await;
let sender = subscription_group.remove(&peer).unwrap();
drop(subscription_group);
track_forward
.subscription_group
.write()
.await
.insert(peer.clone(), sender);
let _ = track_forward
.rtcp_send
.try_send(RtcpMessage::PictureLossIndication);
info!(
"[{}] [subscribe] [{}] select layer {} to {} ",
self.id,
peer.get_key(),
track_remote_original.0.rid(),
rid
);
return Ok(());
if let Some(sender) = subscription_group.remove(&peer) {
drop(subscription_group);
track_forward
.subscription_group
.write()
.await
.insert(peer.clone(), sender);
let _ = track_forward
.rtcp_send
.try_send(RtcpMessage::PictureLossIndication);
info!(
"[{}] [subscribe] [{}] select layer {} to {} success",
self.id,
peer.get_key(),
track_remote_original.0.rid(),
rid
);
return Ok(());
} else {
warn!(
"[{}] [subscribe] [{}] select layer {} to {} fail,concurrent transfer",
self.id,
peer.get_key(),
track_remote_original.0.rid(),
rid
);
return Err(anyhow::anyhow!("concurrent transfer"));
}
}
}
}
Expand Down

0 comments on commit 4143531

Please sign in to comment.