pub async fn send(&self, parameters: &RTCRtpSendParameters) -> Result<()> {
        if self.has_sent().await {
            return Err(Error::ErrRTPSenderSendAlreadyCalled);
        }

        let write_stream = Arc::new(InterceptorToTrackLocalWriter::new());
        let (context, stream_info) = {
            let track = self.track.lock().await;
            let mut context = TrackLocalContext {
                id: self.id.clone(),
                params: self
                    .media_engine
                    .get_rtp_parameters_by_kind(
                        if let Some(t) = &*track {
                            t.kind()
                        } else {
                            RTPCodecType::default()
                        },
                        &[RTCRtpTransceiverDirection::Sendonly],
                    )
                    .await,
                ssrc: parameters.encodings[0].ssrc,
                write_stream: Some(
                    Arc::clone(&write_stream) as Arc<dyn TrackLocalWriter + Send + Sync>
                ),
            };

            let codec = if let Some(t) = &*track {
                t.bind(&context).await?
            } else {
                RTCRtpCodecParameters::default()
            };
            let payload_type = codec.payload_type;
            let capability = codec.capability.clone();
            context.params.codecs = vec![codec];
            let stream_info = create_stream_info(
                self.id.clone(),
                parameters.encodings[0].ssrc,
                payload_type,
                capability,
                &parameters.rtp_parameters.header_extensions,
            );

            (context, stream_info)
        };

        let srtp_rtp_writer = Arc::clone(&self.srtp_stream) as Arc<dyn RTPWriter + Send + Sync>;
        let rtp_interceptor = self
            .interceptor
            .bind_local_stream(&stream_info, srtp_rtp_writer)
            .await;
        {
            let mut interceptor_rtp_writer = write_stream.interceptor_rtp_writer.lock().await;
            *interceptor_rtp_writer = Some(rtp_interceptor);
        }

        {
            let mut ctx = self.context.lock().await;
            *ctx = context;
        }
        {
            let mut si = self.stream_info.lock().await;
            *si = stream_info;
        }

        {
            let mut send_called_tx = self.send_called_tx.lock().await;
            send_called_tx.take();
        }

        Ok(())
    }
/// send Attempts to set the parameters controlling the sending of media.
send Attempts to set the parameters controlling the sending of media.
send Attempts to set the parameters controlling the sending of media .
pub async fn send(&self, parameters: &RTCRtpSendParameters) -> Result<()> {
        if self.has_sent().await {
            return Err(Error::ErrRTPSenderSendAlreadyCalled);
        }
        let write_stream = Arc::new(InterceptorToTrackLocalWriter::new());
        let (context, stream_info) = {
            let track = self.track.lock().await;
            let mut context = TrackLocalContext {
                id: self.id.clone(),
                params: self
                    .media_engine
                    .get_rtp_parameters_by_kind(
                        if let Some(t) = &*track {
                            t.kind()
                        } else {
                            RTPCodecType::default()
                        },
                        &[RTCRtpTransceiverDirection::Sendonly],
                    )
                    .await,
                ssrc: parameters.encodings[0].ssrc,
                write_stream: Some(
                    Arc::clone(&write_stream) as Arc<dyn TrackLocalWriter + Send + Sync>
                ),
            };
            let codec = if let Some(t) = &*track {
                t.bind(&context).await?
            } else {
                RTCRtpCodecParameters::default()
            };
            let payload_type = codec.payload_type;
            let capability = codec.capability.clone();
            context.params.codecs = vec![codec];
            let stream_info = create_stream_info(
                self.id.clone(),
                parameters.encodings[0].ssrc,
                payload_type,
                capability,
                &parameters.rtp_parameters.header_extensions,
            );
            (context, stream_info)
        };
        let srtp_rtp_writer = Arc::clone(&self.srtp_stream) as Arc<dyn RTPWriter + Send + Sync>;
        let rtp_interceptor = self
            .interceptor
            .bind_local_stream(&stream_info, srtp_rtp_writer)
            .await;
        {
            let mut interceptor_rtp_writer = write_stream.interceptor_rtp_writer.lock().await;
            *interceptor_rtp_writer = Some(rtp_interceptor);
        }
        {
            let mut ctx = self.context.lock().await;
            *ctx = context;
        }
        {
            let mut si = self.stream_info.lock().await;
            *si = stream_info;
        }
        {
            let mut send_called_tx = self.send_called_tx.lock().await;
            send_called_tx.take();
        }
        Ok(())
    }
pub async fn send ( & self , parameters : & RTCRtpSendParameters ) -> Result < ( ) > { if self . has_sent ( ) . await { return Err ( Error :: ErrRTPSenderSendAlreadyCalled ) ; } let write_stream = Arc :: new ( InterceptorToTrackLocalWriter :: new ( ) ) ; let ( context , stream_info ) = { let track = self . track . lock ( ) . await ; let mut context = TrackLocalContext { id : self . id . clone ( ) , params : self . media_engine . get_rtp_parameters_by_kind ( if let Some ( t ) = & * track { t . kind ( ) } else { RTPCodecType :: default ( ) } , & [ RTCRtpTransceiverDirection :: Sendonly ] , ) . await , ssrc : parameters . encodings [ 0 ] . ssrc , write_stream : Some ( Arc :: clone ( & write_stream ) as Arc < dyn TrackLocalWriter + Send + Sync > ) , } ; let codec = if let Some ( t ) = & * track { t . bind ( & context ) . await ? } else { RTCRtpCodecParameters :: default ( ) } ; let payload_type = codec . payload_type ; let capability = codec . capability . clone ( ) ; context . params . codecs = vec ! [ codec ] ; let stream_info = create_stream_info ( self . id . clone ( ) , parameters . encodings [ 0 ] . ssrc , payload_type , capability , & parameters . rtp_parameters . header_extensions , ) ; ( context , stream_info ) } ; let srtp_rtp_writer = Arc :: clone ( & self . srtp_stream ) as Arc < dyn RTPWriter + Send + Sync > ; let rtp_interceptor = self . interceptor . bind_local_stream ( & stream_info , srtp_rtp_writer ) . await ; { let mut interceptor_rtp_writer = write_stream . interceptor_rtp_writer . lock ( ) . await ; * interceptor_rtp_writer = Some ( rtp_interceptor ) ; } { let mut ctx = self . context . lock ( ) . await ; * ctx = context ; } { let mut si = self . stream_info . lock ( ) . await ; * si = stream_info ; } { let mut send_called_tx = self . send_called_tx . lock ( ) . await ; send_called_tx . take ( ) ; } Ok ( ( ) ) }
send Attempts to set the parameters controlling the sending of media.
send Attempts to set the parameters controlling the sending of media .
&self
parameters
&RTCRtpSendParameters