Skip to content

Track reader functions

Dimitri Podborski edited this page Sep 17, 2020 · 1 revision

Track readers are objects that allow you to easily read sequential samples or access units from a movie track.

ISOCreateTrackReader

ISOErr ISOCreateTrackReader( ISOTrack theTrack, ISOTrackReader *outReader )

Create a track reader for a movie track.

ISODisposeTrackReader

ISOErr ISODisposeTrackReader( ISOTrackReader theReader );

Frees up resources associated with a track reader.

MP4TrackReaderGetCurrentDecoderConfig

ISOErr MP4TrackReaderGetCurrentDecoderConfig( 
            ISOTrackReader theReader,
            ISOHandle decoderConfigH );

Places the appropriate decoder config descriptor into the handle provided.

MP4TrackReaderGetNextAccessUnit, MJ2TrackReaderGetNextSample

ISOErr MP4TrackReaderGetNextAccessUnit( 
            ISOTrackReader theReader,
            ISOHandle outAccessUnit, 
            u32 *outSize, u32 *outSampleFlags,
            s32 *outCTS, s32 *outDTS );

This function can also be called as MJ2TrackReaderGetNextSample. Use this to get the next access unit (MPEG-4), or sample, from the track. Parameters include:

outAccessUnit A handler that the sample/AU will be placed into

outSize The size of the returned sample/AU in bytes

outSampleFlags Contains information about the media sample that specifies this sample/AU. Flag values are combinations of MP4MediaSampleNotSync if the sample is not a sync sample and MP4MediaSampleHasCompositionOffset if the sample’s DTS differs from its CTS.

outCTS The composition time stamp for this sample/AU. This is measured in the movie time, but in media time-units. If the DTS is negative (see below) and the CTS offset not that large (or not present, and hence zero), this may also be negative. NB in previous releases this parameter was unsigned.

outDTS The decoding time stamp for this sample/AU. This is measured in the movie time, but in media time-units. It may be negative, or overlap the end of the previously decoded access unit, indicating that not all the normal duration of this AU should be presented, and some material trimmed from the beginning (the amount the time-stamp is negative or overlaps the previous timestamp plus previous duration). NB in previous releases this parameter was unsigned.

Note that this function returns ISOEOF if no more samples are available.

MP4TrackReaderGetNextAccessUnitWithDuration

ISOErr MP4TrackReaderGetNextAccessUnitWithDuration( 
            ISOTrackReader theReader,
            ISOHandle outAccessUnit, 
            u32 *outSize, u32 *outSampleFlags,
            u32 *outCTS, u32 *outDTS,
            u32 *outDuration );

Like MP4TrackReaderGetNextAccessUnit, but also returns the duration of the sample. The duration may be shorter than the natural duration of the AU, in the case where the end of an edit falls within the AU. Some material may need to be trimmed from the end of the AU.

MP4TrackReaderGetNextAccessUnitWithPad

ISOErr MP4TrackReaderGetNextAccessUnitWithPad( 
            ISOTrackReader theReader,
            ISOHandle outAccessUnit, 
            u32 *outSize, u32 *outSampleFlags,
            u32 *outCTS, u32 *outDTS,
            u8 *outPad );

Like MP4TrackReaderGetNextAccessUnit, but also returns the padding bits for the sample. If the track has no recorded padding table (no padding information) then the padding value returned will be 0xF8. This is not a legal value for actual padding and should not be supplied to calls which add samples.

MP4TrackReaderGetNextPacket

ISOErr MP4TrackReaderGetNextPacket( ISOTrackReader theReader,
            ISOHandle outPacket, u32 *outSize );

Use this to read the next SL-packet from the track. The packet is placed into the outPacket handle, and its size is indicated in outSize.

Note that this function returns ISOEOF if no more samples are available.

MP4TrackReaderGetCurrentSampleNumber

ISOErr MP4TrackReaderGetCurrentSampleNumber( 
            MP4TrackReader theReader, 
            u32 *sampleNumber );

After a track reader has returned an access unit (one of the above functions), this function can be called to find the sample number of that access unit. This may be useful when (for example), sample group association information is wanted for that sample.

MP4TrackReaderGetCurrentSampleDescription

ISOErr MP4TrackReaderGetCurrentSampleDescription( MP4TrackReader theReader, MP4Handle sampleEntryH );

Get the sample description associated with the current read-point.

MP4TrackReaderGetCurrentSampleDescriptionIndex

ISOErr MP4TrackReaderGetCurrentSampleDescriptionIndex( MP4TrackReader theReader, u32 *index );

Get the index of the current sample description.

MP4TrackReaderSetSLConfig

ISOErr MP4TrackReaderSetSLConfig( MP4TrackReader theReader, MP4SLConfig slConfig );

Sets the ...

Clone this wiki locally