Skip to content

Commit

Permalink
make transceivers in Endpoint private
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Jan 25, 2024
1 parent 0304a1e commit e78e805
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/server/endpoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ pub(crate) struct Endpoint {
session: Weak<Session>,
endpoint_id: EndpointId,
transports: RefCell<HashMap<FourTuple, Transport>>,

pub(crate) transceivers: RefCell<HashMap<Mid, RTCRtpTransceiver>>,
transceivers: RefCell<HashMap<Mid, RTCRtpTransceiver>>,
}

impl Endpoint {
Expand All @@ -41,6 +40,11 @@ impl Endpoint {
transports.insert(*transport.four_tuple(), transport);
}

pub(crate) fn remove_transport(&self, four_tuple: &FourTuple) {
let mut transports = self.transports.borrow_mut();
transports.remove(four_tuple);
}

pub(crate) fn has_transport(&self, four_tuple: &FourTuple) -> bool {
let transports = self.transports.borrow();
transports.contains_key(four_tuple)
Expand All @@ -49,4 +53,8 @@ impl Endpoint {
pub(crate) fn transports(&self) -> &RefCell<HashMap<FourTuple, Transport>> {
&self.transports
}

pub(crate) fn transceivers(&self) -> &RefCell<HashMap<Mid, RTCRtpTransceiver>> {
&self.transceivers
}
}
6 changes: 3 additions & 3 deletions src/server/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Session {
.as_ref()
.ok_or(Error::Other("Unparsed remote description".to_string()))?;

let mut local_transceivers = endpoint.transceivers.borrow_mut();
let mut local_transceivers = endpoint.transceivers().borrow_mut();
let we_offer = remote_description.sdp_type == RTCSdpType::Answer;

if !we_offer {
Expand Down Expand Up @@ -250,7 +250,7 @@ impl Session {

let media_sections = {
let mut local_transceivers = if let Some(endpoint) = endpoint.as_ref() {
endpoint.transceivers.borrow_mut()
endpoint.transceivers().borrow_mut()
} else {
empty_transceivers.borrow_mut()
};
Expand Down Expand Up @@ -334,7 +334,7 @@ impl Session {
};

let local_transceiver = if let Some(endpoint) = endpoint.as_ref() {
endpoint.transceivers.borrow()
endpoint.transceivers().borrow()
} else {
empty_transceivers.borrow()
};
Expand Down

0 comments on commit e78e805

Please sign in to comment.