pub(crate) async fn check_and_update_track(&self, b: &[u8]) -> Result<()> {
        if b.len() < 2 {
            return Err(Error::ErrRTPTooShort);
        }

        let payload_type = b[1] & RTP_PAYLOAD_TYPE_BITMASK;
        if payload_type != self.payload_type() {
            let p = self
                .media_engine
                .get_rtp_parameters_by_payload_type(payload_type)
                .await?;

            if let Some(receiver) = &self.receiver {
                if let Some(receiver) = receiver.upgrade() {
                    self.kind.store(receiver.kind as u8, Ordering::SeqCst);
                }
            }
            self.payload_type.store(payload_type, Ordering::SeqCst);
            {
                let mut codec = self.codec.lock().await;
                *codec = if let Some(codec) = p.codecs.first() {
                    codec.clone()
                } else {
                    return Err(Error::ErrCodecNotFound);
                };
            }
            {
                let mut params = self.params.lock().await;
                *params = p;
            }
        }

        Ok(())
    }
/// check_and_update_track checks payloadType for every incoming packet
/// once a different payloadType is detected the track will be updated
check_and_update_track checks payloadType for every incoming packet
once a different payloadType is detected the track will be updated
check_and_update_track checks payloadType for every incoming packet once a different payloadType is detected the track will be updated
pub(crate) async fn check_and_update_track(&self, b: &[u8]) -> Result<()> {
        if b.len() < 2 {
            return Err(Error::ErrRTPTooShort);
        }
        let payload_type = b[1] & RTP_PAYLOAD_TYPE_BITMASK;
        if payload_type != self.payload_type() {
            let p = self
                .media_engine
                .get_rtp_parameters_by_payload_type(payload_type)
                .await?;
            if let Some(receiver) = &self.receiver {
                if let Some(receiver) = receiver.upgrade() {
                    self.kind.store(receiver.kind as u8, Ordering::SeqCst);
                }
            }
            self.payload_type.store(payload_type, Ordering::SeqCst);
            {
                let mut codec = self.codec.lock().await;
                *codec = if let Some(codec) = p.codecs.first() {
                    codec.clone()
                } else {
                    return Err(Error::ErrCodecNotFound);
                };
            }
            {
                let mut params = self.params.lock().await;
                *params = p;
            }
        }
        Ok(())
    }
pub ( crate ) async fn check_and_update_track ( & self , b : & [ u8 ] ) -> Result < ( ) > { if b . len ( ) < 2 { return Err ( Error :: ErrRTPTooShort ) ; } let payload_type = b [ 1 ] & RTP_PAYLOAD_TYPE_BITMASK ; if payload_type != self . payload_type ( ) { let p = self . media_engine . get_rtp_parameters_by_payload_type ( payload_type ) . await ? ; if let Some ( receiver ) = & self . receiver { if let Some ( receiver ) = receiver . upgrade ( ) { self . kind . store ( receiver . kind as u8 , Ordering :: SeqCst ) ; } } self . payload_type . store ( payload_type , Ordering :: SeqCst ) ; { let mut codec = self . codec . lock ( ) . await ; * codec = if let Some ( codec ) = p . codecs . first ( ) { codec . clone ( ) } else { return Err ( Error :: ErrCodecNotFound ) ; } ; } { let mut params = self . params . lock ( ) . await ; * params = p ; } } Ok ( ( ) ) }
check_and_update_track checks payloadType for every incoming packet
once a different payloadType is detected the track will be updated
check_and_update_track checks payloadType for every incoming packet once a different payloadType is detected the track will be updated
&self
b
&[u8]