Skip to content

Commit

Permalink
fix: anchor is ok
Browse files Browse the repository at this point in the history
  • Loading branch information
hongcha98 committed Oct 10, 2023
1 parent 612d36e commit cb8ff9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/forward/forward_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use webrtc::track::track_local::{TrackLocal, TrackLocalWriter};
use webrtc::track::track_remote::TrackRemote;

use crate::forward::track_match::{track_match_codec, track_sort};
use crate::media;

use super::track_match;

Expand Down Expand Up @@ -130,7 +131,18 @@ impl PeerForwardInternal {
let anchor = self.anchor.read().await;
let anchor_track_forward_map = self.anchor_track_forward_map.read().await;
anchor.is_some()
&& !anchor_track_forward_map.is_empty()
&& anchor_track_forward_map.len()
== media::count_sends(
&anchor
.as_ref()
.unwrap()
.remote_description()
.await
.unwrap()
.unmarshal()
.unwrap()
.media_descriptions,
)
&& anchor.as_ref().unwrap().connection_state() == RTCPeerConnectionState::Connected
}

Expand Down
8 changes: 8 additions & 0 deletions src/media/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ pub fn codecs_from_media_description(
Ok(out)
}

pub fn count_sends(mds: &Vec<MediaDescription>) -> usize {
let mut count = 0;
for md in mds {
count += count_send(md);
}
count
}

pub fn count_send(md: &MediaDescription) -> usize {
let mut count = 0;
let mut minus = 0;
Expand Down

0 comments on commit cb8ff9b

Please sign in to comment.