Skip to content

Commit

Permalink
rtp_receiver: Get rid of fields already in internal (#592)
Browse files Browse the repository at this point in the history
No need to store kind and transport, as they are already stored by
RTPReceiverInternal.
  • Loading branch information
haaspors authored Jul 7, 2024
1 parent 40642c8 commit 4bb9614
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions webrtc/src/rtp_transceiver/rtp_receiver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,14 @@ impl RTPReceiverInternal {
/// [W3C]: https://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface
pub struct RTCRtpReceiver {
receive_mtu: usize,
kind: RTPCodecType,
transport: Arc<RTCDtlsTransport>,

pub internal: Arc<RTPReceiverInternal>,
}

impl std::fmt::Debug for RTCRtpReceiver {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("RTCRtpReceiver")
.field("kind", &self.kind)
.field("kind", &self.internal.kind)
.finish()
}
}
Expand All @@ -427,8 +425,6 @@ impl RTCRtpReceiver {

RTCRtpReceiver {
receive_mtu,
kind,
transport: Arc::clone(&transport),

internal: Arc::new(RTPReceiverInternal {
kind,
Expand All @@ -447,7 +443,7 @@ impl RTCRtpReceiver {
}

pub fn kind(&self) -> RTPCodecType {
self.kind
self.internal.kind
}

pub(crate) fn set_transceiver_codecs(
Expand All @@ -460,7 +456,7 @@ impl RTCRtpReceiver {
/// transport returns the currently-configured *DTLSTransport or nil
/// if one has not yet been configured
pub fn transport(&self) -> Arc<RTCDtlsTransport> {
Arc::clone(&self.transport)
Arc::clone(&self.internal.transport)
}

/// get_parameters describes the current configuration for the encoding and
Expand Down Expand Up @@ -539,7 +535,8 @@ impl RTCRtpReceiver {
&global_params.header_extensions,
);
let (rtp_read_stream, rtp_interceptor, rtcp_read_stream, rtcp_interceptor) =
self.transport
self.internal
.transport
.streams_for_ssrc(encoding.ssrc, &stream_info, &interceptor)
.await?;

Expand All @@ -557,7 +554,7 @@ impl RTCRtpReceiver {
let t = TrackStreams {
track: Arc::new(TrackRemote::new(
self.receive_mtu,
self.kind,
self.internal.kind,
encoding.ssrc,
encoding.rid.clone(),
receiver.clone(),
Expand Down Expand Up @@ -596,6 +593,7 @@ impl RTCRtpReceiver {
&global_params.header_extensions,
);
let (rtp_read_stream, rtp_interceptor, rtcp_read_stream, rtcp_interceptor) = self
.internal
.transport
.streams_for_ssrc(rtx_ssrc, &stream_info, &interceptor)
.await?;
Expand Down Expand Up @@ -766,7 +764,7 @@ impl RTCRtpReceiver {
let mut tracks = self.internal.tracks.write().await;
for t in &mut *tracks {
if *t.track.rid() == rid {
t.track.set_kind(self.kind);
t.track.set_kind(self.internal.kind);
if let Some(codec) = params.codecs.first() {
t.track.set_codec(codec.clone());
}
Expand Down

0 comments on commit 4bb9614

Please sign in to comment.