fn next_sample_info(&self) -> Result<Option<NextSampleInfo>> {
        let mut earliest = None;

        // TODO: Consider returning samples based on lowest byte position in the stream instead of
        // timestamp. This may be important if video streams are ever decoded (i.e., DTS vs. PTS).

        for (track, stream) in self.tracks.iter().zip(&self.streams) {

            // Get the timebase of the track used to calculate the presentation time.
            let tb = stream.codec_params.time_base.unwrap();

            // Get the next timestamp for the next sample of the current track. The next sample may
            // be in a future segment.
            for (seg_idx_delta, seg) in self.segs[track.cur_seg as usize..].iter().enumerate() {

                // Try to get the timestamp for the next sample of the track from the segment.
                if let Some(sample_ts) = seg.sample_ts(track.track_num, track.next_sample)? {

                    // Calculate the presentation time using the timestamp.
                    let sample_time = tb.calc_time(sample_ts);

                    // Compare the presentation time of the sample from this track to other tracks,
                    // and select the track with the earliest presentation time.
                    match earliest {
                        Some(NextSampleInfo { track_num: _, ts: _, time, seg_idx: _ })
                            if time <= sample_time =>
                        {
                            // Earliest is less than or equal to the track's next sample presentation
                            // time. No need to update earliest.
                            ()
                        }
                        _ => {
                            // Earliest was either None, or greater than the track's next sample
                            // presentation time. Update earliest.
                            earliest = Some(NextSampleInfo{
                                track_num: track.track_num,
                                ts: sample_ts,
                                time: sample_time,
                                seg_idx: seg_idx_delta + track.cur_seg,
                            });
                        }
                    }

                    // Either the next sample of the track had the earliest presentation time seen
                    // thus far, or it was greater than those from other tracks, but there is no
                    // reason to check samples in future segments.
                    break;
                }
            }
        }

        Ok(earliest)
    }
/// Idempotently gets information regarding the next sample of the media stream. This function
/// selects the next sample with the lowest timestamp of all tracks.
Idempotently gets information regarding the next sample of the media stream. This function
selects the next sample with the lowest timestamp of all tracks.
Idempotently gets information regarding the next sample of the media stream . This function selects the next sample with the lowest timestamp of all tracks .
fn next_sample_info(&self) -> Result<Option<NextSampleInfo>> {
        let mut earliest = None;
        // TODO: Consider returning samples based on lowest byte position in the stream instead of
        // timestamp. This may be important if video streams are ever decoded (i.e., DTS vs. PTS).
        for (track, stream) in self.tracks.iter().zip(&self.streams) {
            // Get the timebase of the track used to calculate the presentation time.
            let tb = stream.codec_params.time_base.unwrap();
            // Get the next timestamp for the next sample of the current track. The next sample may
            // be in a future segment.
            for (seg_idx_delta, seg) in self.segs[track.cur_seg as usize..].iter().enumerate() {
                // Try to get the timestamp for the next sample of the track from the segment.
                if let Some(sample_ts) = seg.sample_ts(track.track_num, track.next_sample)? {
                    // Calculate the presentation time using the timestamp.
                    let sample_time = tb.calc_time(sample_ts);
                    // Compare the presentation time of the sample from this track to other tracks,
                    // and select the track with the earliest presentation time.
                    match earliest {
                        Some(NextSampleInfo { track_num: _, ts: _, time, seg_idx: _ })
                            if time <= sample_time =>
                        {
                            // Earliest is less than or equal to the track's next sample presentation
                            // time. No need to update earliest.
                            ()
                        }
                        _ => {
                            // Earliest was either None, or greater than the track's next sample
                            // presentation time. Update earliest.
                            earliest = Some(NextSampleInfo{
                                track_num: track.track_num,
                                ts: sample_ts,
                                time: sample_time,
                                seg_idx: seg_idx_delta + track.cur_seg,
                            });
                        }
                    }
                    // Either the next sample of the track had the earliest presentation time seen
                    // thus far, or it was greater than those from other tracks, but there is no
                    // reason to check samples in future segments.
                    break;
                }
            }
        }
        Ok(earliest)
    }
fn next_sample_info ( & self ) -> Result < Option < NextSampleInfo > > { let mut earliest = None ; // TODO: Consider returning samples based on lowest byte position in the stream instead of // timestamp. This may be important if video streams are ever decoded (i.e., DTS vs. PTS). for ( track , stream ) in self . tracks . iter ( ) . zip ( & self . streams ) { // Get the timebase of the track used to calculate the presentation time. let tb = stream . codec_params . time_base . unwrap ( ) ; // Get the next timestamp for the next sample of the current track. The next sample may // be in a future segment. for ( seg_idx_delta , seg ) in self . segs [ track . cur_seg as usize .. ] . iter ( ) . enumerate ( ) { // Try to get the timestamp for the next sample of the track from the segment. if let Some ( sample_ts ) = seg . sample_ts ( track . track_num , track . next_sample ) ? { // Calculate the presentation time using the timestamp. let sample_time = tb . calc_time ( sample_ts ) ; // Compare the presentation time of the sample from this track to other tracks, // and select the track with the earliest presentation time. match earliest { Some ( NextSampleInfo { track_num : _ , ts : _ , time , seg_idx : _ } ) if time <= sample_time => { // Earliest is less than or equal to the track's next sample presentation // time. No need to update earliest. ( ) } _ => { // Earliest was either None, or greater than the track's next sample // presentation time. Update earliest. earliest = Some ( NextSampleInfo { track_num : track . track_num , ts : sample_ts , time : sample_time , seg_idx : seg_idx_delta + track . cur_seg , } ) ; } } // Either the next sample of the track had the earliest presentation time seen // thus far, or it was greater than those from other tracks, but there is no // reason to check samples in future segments. break ; } } } Ok ( earliest ) }
Idempotently gets information regarding the next sample of the media stream.
Idempotently gets information regarding the next sample of the media stream .
&self
&self