Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Implement Control API basic Apply method (#27) #187

Merged
merged 29 commits into from
Apr 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix for WebRtcPlayEndpoint delete
evdokimovs committed Apr 2, 2021

Verified

This commit was signed with the committer’s verified signature.
commit 174db85d3bb32fb422c0272687c7cb0369b4d18d
2 changes: 1 addition & 1 deletion src/media/peer.rs
Original file line number Diff line number Diff line change
@@ -838,7 +838,7 @@ impl<T> Peer<T> {
pub fn add_endpoint(&mut self, endpoint: &Endpoint) {
match endpoint {
Endpoint::WebRtcPlayEndpoint(play) => {
play.set_peer_id(self.id());
play.set_peer_ids(self.id(), self.partner_peer_id());
}
Endpoint::WebRtcPublishEndpoint(publish) => {
publish.add_peer_id(self.id());
20 changes: 15 additions & 5 deletions src/signalling/elements/endpoints/webrtc/play_endpoint.rs
Original file line number Diff line number Diff line change
@@ -47,6 +47,10 @@ struct WebRtcPlayEndpointInner {
/// [`Peer`]: crate::media::peer::Peer
peer_id: Option<PeerId>,

/// [`PeerId`] of [`Peer`] created for source [`WebRtcPublishEndpoint`]
/// from which this [`WebRtcPlayEndpoint`] receives data.
partner_peer_id: Option<PeerId>,

/// Indicator whether only `relay` ICE candidates are allowed for this
/// [`WebRtcPlayEndpoint`].
is_force_relayed: bool,
@@ -69,8 +73,9 @@ impl WebRtcPlayEndpointInner {
self.src.upgrade()
}

fn set_peer_id(&mut self, peer_id: PeerId) {
self.peer_id = Some(peer_id)
fn set_peer_id(&mut self, peer_id: PeerId, partner_peer_id: PeerId) {
self.peer_id = Some(peer_id);
self.partner_peer_id = Some(partner_peer_id)
}

fn peer_id(&self) -> Option<PeerId> {
@@ -85,6 +90,9 @@ impl WebRtcPlayEndpointInner {
impl Drop for WebRtcPlayEndpointInner {
fn drop(&mut self) {
if let Some(receiver_publisher) = self.src.safe_upgrade() {
if let Some(partner_peer_id) = self.partner_peer_id {
receiver_publisher.remove_peer_ids(&[partner_peer_id])
}
receiver_publisher.remove_empty_weaks_from_sinks();
}
}
@@ -113,6 +121,7 @@ impl WebRtcPlayEndpoint {
src: publisher,
owner,
peer_id: None,
partner_peer_id: None,
is_force_relayed,
})))
}
@@ -150,10 +159,11 @@ impl WebRtcPlayEndpoint {
self.0.borrow().src()
}

/// Saves [`PeerId`] of this [`WebRtcPlayEndpoint`].
/// Saves [`PeerId`]s of this [`WebRtcPlayEndpoint`] and source
/// [`WebRtcPublishEndpoint`].
#[inline]
pub fn set_peer_id(&self, peer_id: PeerId) {
self.0.borrow_mut().set_peer_id(peer_id);
pub fn set_peer_ids(&self, peer_id: PeerId, partner_peer_id: PeerId) {
self.0.borrow_mut().set_peer_id(peer_id, partner_peer_id);
}

/// Returns [`PeerId`] of this [`WebRtcPlayEndpoint`]'s [`Peer`].