pub async fn receive(&self, parameters: &RTCRtpReceiveParameters) -> Result<()> {
        let receiver = Arc::downgrade(&self.internal);

        let _d = {
            let mut received_tx = self.received_tx.lock().await;
            if received_tx.is_none() {
                return Err(Error::ErrRTPReceiverReceiveAlreadyCalled);
            }
            received_tx.take()
        };

        let (global_params, interceptor, media_engine) = {
            (
                self.internal.get_parameters().await,
                Arc::clone(&self.internal.interceptor),
                Arc::clone(&self.internal.media_engine),
            )
        };

        let codec = if let Some(codec) = global_params.codecs.first() {
            codec.capability.clone()
        } else {
            RTCRtpCodecCapability::default()
        };

        for encoding in &parameters.encodings {
            let (stream_info, rtp_read_stream, rtp_interceptor, rtcp_read_stream, rtcp_interceptor) =
                if encoding.ssrc != 0 {
                    let stream_info = create_stream_info(
                        "".to_owned(),
                        encoding.ssrc,
                        0,
                        codec.clone(),
                        &global_params.header_extensions,
                    );
                    let (rtp_read_stream, rtp_interceptor, rtcp_read_stream, rtcp_interceptor) =
                        self.transport
                            .streams_for_ssrc(encoding.ssrc, &stream_info, &interceptor)
                            .await?;

                    (
                        Some(stream_info),
                        rtp_read_stream,
                        rtp_interceptor,
                        rtcp_read_stream,
                        rtcp_interceptor,
                    )
                } else {
                    (None, None, None, None, None)
                };

            let t = TrackStreams {
                track: Arc::new(TrackRemote::new(
                    self.receive_mtu,
                    self.kind,
                    encoding.ssrc,
                    encoding.rid.clone(),
                    receiver.clone(),
                    Arc::clone(&media_engine),
                    Arc::clone(&interceptor),
                )),
                stream: TrackStream {
                    stream_info,
                    rtp_read_stream,
                    rtp_interceptor,
                    rtcp_read_stream,
                    rtcp_interceptor,
                },

                repair_stream: TrackStream {
                    stream_info: None,
                    rtp_read_stream: None,
                    rtp_interceptor: None,
                    rtcp_read_stream: None,
                    rtcp_interceptor: None,
                },
            };

            {
                let mut tracks = self.internal.tracks.lock().await;
                tracks.push(t);
            };

            let rtx_ssrc = encoding.rtx.ssrc;
            if rtx_ssrc != 0 {
                let stream_info = create_stream_info(
                    "".to_owned(),
                    rtx_ssrc,
                    0,
                    codec.clone(),
                    &global_params.header_extensions,
                );
                let (rtp_read_stream, rtp_interceptor, rtcp_read_stream, rtcp_interceptor) = self
                    .transport
                    .streams_for_ssrc(rtx_ssrc, &stream_info, &interceptor)
                    .await?;

                self.receive_for_rtx(
                    rtx_ssrc,
                    "".to_owned(),
                    TrackStream {
                        stream_info: Some(stream_info),
                        rtp_read_stream,
                        rtp_interceptor,
                        rtcp_read_stream,
                        rtcp_interceptor,
                    },
                )
                .await?;
            }
        }

        Ok(())
    }
/// receive initialize the track and starts all the transports
receive initialize the track and starts all the transports
receive initialize the track and starts all the transports
pub async fn receive(&self, parameters: &RTCRtpReceiveParameters) -> Result<()> {
        let receiver = Arc::downgrade(&self.internal);
        let _d = {
            let mut received_tx = self.received_tx.lock().await;
            if received_tx.is_none() {
                return Err(Error::ErrRTPReceiverReceiveAlreadyCalled);
            }
            received_tx.take()
        };
        let (global_params, interceptor, media_engine) = {
            (
                self.internal.get_parameters().await,
                Arc::clone(&self.internal.interceptor),
                Arc::clone(&self.internal.media_engine),
            )
        };
        let codec = if let Some(codec) = global_params.codecs.first() {
            codec.capability.clone()
        } else {
            RTCRtpCodecCapability::default()
        };
        for encoding in &parameters.encodings {
            let (stream_info, rtp_read_stream, rtp_interceptor, rtcp_read_stream, rtcp_interceptor) =
                if encoding.ssrc != 0 {
                    let stream_info = create_stream_info(
                        "".to_owned(),
                        encoding.ssrc,
                        0,
                        codec.clone(),
                        &global_params.header_extensions,
                    );
                    let (rtp_read_stream, rtp_interceptor, rtcp_read_stream, rtcp_interceptor) =
                        self.transport
                            .streams_for_ssrc(encoding.ssrc, &stream_info, &interceptor)
                            .await?;
                    (
                        Some(stream_info),
                        rtp_read_stream,
                        rtp_interceptor,
                        rtcp_read_stream,
                        rtcp_interceptor,
                    )
                } else {
                    (None, None, None, None, None)
                };
            let t = TrackStreams {
                track: Arc::new(TrackRemote::new(
                    self.receive_mtu,
                    self.kind,
                    encoding.ssrc,
                    encoding.rid.clone(),
                    receiver.clone(),
                    Arc::clone(&media_engine),
                    Arc::clone(&interceptor),
                )),
                stream: TrackStream {
                    stream_info,
                    rtp_read_stream,
                    rtp_interceptor,
                    rtcp_read_stream,
                    rtcp_interceptor,
                },
                repair_stream: TrackStream {
                    stream_info: None,
                    rtp_read_stream: None,
                    rtp_interceptor: None,
                    rtcp_read_stream: None,
                    rtcp_interceptor: None,
                },
            };
            {
                let mut tracks = self.internal.tracks.lock().await;
                tracks.push(t);
            };
            let rtx_ssrc = encoding.rtx.ssrc;
            if rtx_ssrc != 0 {
                let stream_info = create_stream_info(
                    "".to_owned(),
                    rtx_ssrc,
                    0,
                    codec.clone(),
                    &global_params.header_extensions,
                );
                let (rtp_read_stream, rtp_interceptor, rtcp_read_stream, rtcp_interceptor) = self
                    .transport
                    .streams_for_ssrc(rtx_ssrc, &stream_info, &interceptor)
                    .await?;
                self.receive_for_rtx(
                    rtx_ssrc,
                    "".to_owned(),
                    TrackStream {
                        stream_info: Some(stream_info),
                        rtp_read_stream,
                        rtp_interceptor,
                        rtcp_read_stream,
                        rtcp_interceptor,
                    },
                )
                .await?;
            }
        }
        Ok(())
    }
pub async fn receive ( & self , parameters : & RTCRtpReceiveParameters ) -> Result < ( ) > { let receiver = Arc :: downgrade ( & self . internal ) ; let _d = { let mut received_tx = self . received_tx . lock ( ) . await ; if received_tx . is_none ( ) { return Err ( Error :: ErrRTPReceiverReceiveAlreadyCalled ) ; } received_tx . take ( ) } ; let ( global_params , interceptor , media_engine ) = { ( self . internal . get_parameters ( ) . await , Arc :: clone ( & self . internal . interceptor ) , Arc :: clone ( & self . internal . media_engine ) , ) } ; let codec = if let Some ( codec ) = global_params . codecs . first ( ) { codec . capability . clone ( ) } else { RTCRtpCodecCapability :: default ( ) } ; for encoding in & parameters . encodings { let ( stream_info , rtp_read_stream , rtp_interceptor , rtcp_read_stream , rtcp_interceptor ) = if encoding . ssrc != 0 { let stream_info = create_stream_info ( " " . to_owned ( ) , encoding . ssrc , 0 , codec . clone ( ) , & global_params . header_extensions , ) ; let ( rtp_read_stream , rtp_interceptor , rtcp_read_stream , rtcp_interceptor ) = self . transport . streams_for_ssrc ( encoding . ssrc , & stream_info , & interceptor ) . await ? ; ( Some ( stream_info ) , rtp_read_stream , rtp_interceptor , rtcp_read_stream , rtcp_interceptor , ) } else { ( None , None , None , None , None ) } ; let t = TrackStreams { track : Arc :: new ( TrackRemote :: new ( self . receive_mtu , self . kind , encoding . ssrc , encoding . rid . clone ( ) , receiver . clone ( ) , Arc :: clone ( & media_engine ) , Arc :: clone ( & interceptor ) , ) ) , stream : TrackStream { stream_info , rtp_read_stream , rtp_interceptor , rtcp_read_stream , rtcp_interceptor , } , repair_stream : TrackStream { stream_info : None , rtp_read_stream : None , rtp_interceptor : None , rtcp_read_stream : None , rtcp_interceptor : None , } , } ; { let mut tracks = self . internal . tracks . lock ( ) . await ; tracks . push ( t ) ; } ; let rtx_ssrc = encoding . rtx . ssrc ; if rtx_ssrc != 0 { let stream_info = create_stream_info ( " " . to_owned ( ) , rtx_ssrc , 0 , codec . clone ( ) , & global_params . header_extensions , ) ; let ( rtp_read_stream , rtp_interceptor , rtcp_read_stream , rtcp_interceptor ) = self . transport . streams_for_ssrc ( rtx_ssrc , & stream_info , & interceptor ) . await ? ; self . receive_for_rtx ( rtx_ssrc , " " . to_owned ( ) , TrackStream { stream_info : Some ( stream_info ) , rtp_read_stream , rtp_interceptor , rtcp_read_stream , rtcp_interceptor , } , ) . await ? ; } } Ok ( ( ) ) }
receive initialize the track and starts all the transports
receive initialize the track and starts all the transports
&self
parameters
&RTCRtpReceiveParameters