pub fn push_frame(&mut self, frame: Vec<u8>, time: u32) -> Result<Option<Vec<u8>>, Error> {
        self.frames.push_back(frame);
        self.frame_time = self.frame_time + time;
        if self.frames.len() >= self.frames_per_packet.into() {
            let mut header = RtpHeader([0; 12]);
            header.set_version(2);
            header.set_payload_type(96); // Dynamic payload type indicated by RFC 3551, recommended by the spec
            header.set_sequence_number(self.next_sequence_number);
            header.set_timestamp(self.timestamp);
            let header_iter = header.0.iter().cloned();
            let frame_bytes_iter = self.frames.drain(..).flatten();
            let packet =
                header_iter.chain(once(self.frames_per_packet)).chain(frame_bytes_iter).collect();
            self.next_sequence_number = self.next_sequence_number.wrapping_add(1);
            self.timestamp = self.timestamp + self.frame_time;
            self.frame_time = 0;
            return Ok(Some(packet));
        }
        Ok(None)
    }
/// Add a frame that is `time` audio samples long into the builder.
/// Returns a serialized RTP packet if this frame fills the packet,
/// or an Error.
Add a frame that is `time` audio samples long into the builder.
Returns a serialized RTP packet if this frame fills the packet,
or an Error.
Add a frame that is ` time ` audio samples long into the builder . Returns a serialized RTP packet if this frame fills the packet or an Error .
pub fn push_frame(&mut self, frame: Vec<u8>, time: u32) -> Result<Option<Vec<u8>>, Error> {
        self.frames.push_back(frame);
        self.frame_time = self.frame_time + time;
        if self.frames.len() >= self.frames_per_packet.into() {
            let mut header = RtpHeader([0; 12]);
            header.set_version(2);
            header.set_payload_type(96); // Dynamic payload type indicated by RFC 3551, recommended by the spec
            header.set_sequence_number(self.next_sequence_number);
            header.set_timestamp(self.timestamp);
            let header_iter = header.0.iter().cloned();
            let frame_bytes_iter = self.frames.drain(..).flatten();
            let packet =
                header_iter.chain(once(self.frames_per_packet)).chain(frame_bytes_iter).collect();
            self.next_sequence_number = self.next_sequence_number.wrapping_add(1);
            self.timestamp = self.timestamp + self.frame_time;
            self.frame_time = 0;
            return Ok(Some(packet));
        }
        Ok(None)
    }
pub fn push_frame ( & mut self , frame : Vec < u8 > , time : u32 ) -> Result < Option < Vec < u8 > > , Error > { self . frames . push_back ( frame ) ; self . frame_time = self . frame_time + time ; if self . frames . len ( ) >= self . frames_per_packet . into ( ) { let mut header = RtpHeader ( [ 0 ; 12 ] ) ; header . set_version ( 2 ) ; header . set_payload_type ( 96 ) ; // Dynamic payload type indicated by RFC 3551, recommended by the spec header . set_sequence_number ( self . next_sequence_number ) ; header . set_timestamp ( self . timestamp ) ; let header_iter = header . 0 . iter ( ) . cloned ( ) ; let frame_bytes_iter = self . frames . drain ( .. ) . flatten ( ) ; let packet = header_iter . chain ( once ( self . frames_per_packet ) ) . chain ( frame_bytes_iter ) . collect ( ) ; self . next_sequence_number = self . next_sequence_number . wrapping_add ( 1 ) ; self . timestamp = self . timestamp + self . frame_time ; self . frame_time = 0 ; return Ok ( Some ( packet ) ) ; } Ok ( None ) }
Add a frame that is `time` audio samples long into the builder.
Add a frame that is ` time ` audio samples long into the builder .
&mut self
frame
Vec<u8>
time
u32