pub async fn read(&self, b: &mut [u8]) -> Result<(usize, Attributes)> {
        let (peeked, peeked_attributes) = {
            let mut internal = self.internal.lock().await;
            (internal.peeked.take(), internal.peeked_attributes.take())
        };

        if let (Some(data), Some(attributes)) = (peeked, peeked_attributes) {
            // someone else may have stolen our packet when we
            // released the lock.  Deal with it.
            let n = std::cmp::min(b.len(), data.len());
            b[..n].copy_from_slice(&data[..n]);
            self.check_and_update_track(&b[..n]).await?;
            Ok((n, attributes))
        } else {
            let (n, attributes) = {
                if let Some(receiver) = &self.receiver {
                    if let Some(receiver) = receiver.upgrade() {
                        receiver.read_rtp(b, self.tid).await?
                    } else {
                        return Err(Error::ErrRTPReceiverNil);
                    }
                } else {
                    return Err(Error::ErrRTPReceiverNil);
                }
            };
            self.check_and_update_track(&b[..n]).await?;
            Ok((n, attributes))
        }
    }
/// Read reads data from the track.
Read reads data from the track.
Read reads data from the track .
pub async fn read(&self, b: &mut [u8]) -> Result<(usize, Attributes)> {
        let (peeked, peeked_attributes) = {
            let mut internal = self.internal.lock().await;
            (internal.peeked.take(), internal.peeked_attributes.take())
        };
        if let (Some(data), Some(attributes)) = (peeked, peeked_attributes) {
            // someone else may have stolen our packet when we
            // released the lock.  Deal with it.
            let n = std::cmp::min(b.len(), data.len());
            b[..n].copy_from_slice(&data[..n]);
            self.check_and_update_track(&b[..n]).await?;
            Ok((n, attributes))
        } else {
            let (n, attributes) = {
                if let Some(receiver) = &self.receiver {
                    if let Some(receiver) = receiver.upgrade() {
                        receiver.read_rtp(b, self.tid).await?
                    } else {
                        return Err(Error::ErrRTPReceiverNil);
                    }
                } else {
                    return Err(Error::ErrRTPReceiverNil);
                }
            };
            self.check_and_update_track(&b[..n]).await?;
            Ok((n, attributes))
        }
    }
pub async fn read ( & self , b : & mut [ u8 ] ) -> Result < ( usize , Attributes ) > { let ( peeked , peeked_attributes ) = { let mut internal = self . internal . lock ( ) . await ; ( internal . peeked . take ( ) , internal . peeked_attributes . take ( ) ) } ; if let ( Some ( data ) , Some ( attributes ) ) = ( peeked , peeked_attributes ) { // someone else may have stolen our packet when we // released the lock.  Deal with it. let n = std :: cmp :: min ( b . len ( ) , data . len ( ) ) ; b [ .. n ] . copy_from_slice ( & data [ .. n ] ) ; self . check_and_update_track ( & b [ .. n ] ) . await ? ; Ok ( ( n , attributes ) ) } else { let ( n , attributes ) = { if let Some ( receiver ) = & self . receiver { if let Some ( receiver ) = receiver . upgrade ( ) { receiver . read_rtp ( b , self . tid ) . await ? } else { return Err ( Error :: ErrRTPReceiverNil ) ; } } else { return Err ( Error :: ErrRTPReceiverNil ) ; } } ; self . check_and_update_track ( & b [ .. n ] ) . await ? ; Ok ( ( n , attributes ) ) } }
Read reads data from the track.
Read reads data from the track .
&self
b
&mut [u8]