Skip to content

API single page

Dimitri Podborski edited this page Oct 16, 2020 · 3 revisions

The reference software API

This file was automatically generated using create_single_page_api.sh. Do not modify this file, use the script instead.

This section contains documentation for the public exported API of the reference software. You are advised to use only the functions documented here. All function prototypes can be found in ISOMovies.h.


1 Data Types

u32, u64, u8, s32, etc These are typedefs that refer to unsigned (u) or signed (s) integers of size 32 bits, 64 bits, etc. Most of this API uses these instead of the underspecified int, long, short, and char types.

ISOErr This is a typedef for function error codes. The error codes are enumerated in ISOMovies.h. The general rule is that zero is used to indicate success, and negative numbers are errors.

ISOHandle This is used to pass sections of dynamically allocated memory to the API. Handles have an internal structure that remember their allocated size, and the indicated size of the data stored in the Handle. It is common to create a zero-length Handle and pass it to a function that places data into it, resizing it appropriately. You can treat handles as (char**) as long as you use the API functions to allocate their memory and change their size.

ISOMovie This is an opaque handle that contains a reference to a movie.

ISOTrack This is an opaque handle that contains a reference to a track.

ISOMedia This is an opaque handle that contains a reference to media.

ISOMeta This is an opaque handle that contains a reference to rich meta-data.

ISOMetaItem This is an opaque handle that contains a reference to a rich meta-data item.

ISOTrackReader This is an opaque handle that contains a reference to a track reader.

MP4UserData An opaque handle that references user data.

MP4_FOUR_CHAR_CODE( a, b, c, d ) Makes a four-character code when needed (e.g. for a group type, sample-entry type etc.). The arguments are the four characters.


2 Movie related functions

MP4NewMovie

ISOErr MP4NewMovie( ISOMovie *outMovie,
            u32 initialODID,
            u8 OD_profileAndLevel,
            u8 scene_profileAndLevel,
            u8 audio_profileAndLevel,
            u8 visual_profileAndLevel,
            u8 graphics_profileAndLevel )

Creates a new empty Movie in memory. You may assign an initial object descriptor ID and profile and level indications that describe the presentation you are making. The profile and level definitions are detailed in the MPEG-4 Systems specification.

If you provide zero as the initialODID, then no object descriptor is created. Such files can be used as the target of an ES URL, or standalone. Similarly if you provide zero for all the profiles, then the IOD atom will contain an object descriptor, not an initial object descriptor; these files can also be useful on occasion. Do not attempt to add tracks to the object descriptor if you have asked that one not be created.

MJ2NewMovie

ISOErr MJ2NewMovie( ISOMovie *outMovie )

Creates a new empty Motion JPEG 2000 Movie in memory.

NewMPEG21

ISOErr NewMPEG21( MP4Movie *outMovie )

Creates a new empty MPEG-21 ‘movie’ in memory (actually an MPEG-21 file with a meta-atom but no movie atom). You will probably want to get the meta-atom reference ISOGetFileMeta to add items etc. If you want a dual-function MP4/MPEG-21 file, create an MP4 file and then add a file-level meta atom to that, instead of using this call.

New3GPPMovie

ISOErr New3GPPMovie( ISOMovie *outMovie, u16 release );

Creates a new empty 3GPP Movie in memory, and sets the brand to the indicated release (4, 5 or 6).

ISONewMetaMovie

ISOErr ISONewMetaMovie( MP4Movie *outMovie,

u32 handlertype, u32 brand, u32 minorversion ); Like new MPEG21, but allows you to specify the meta handlertype, and the major brand and minor version of that brand.

ISODisposeMovie

ISOErr ISODisposeMovie( ISOMovie theMovie )

This function releases any resources owned by the Movie. You should not make any further reference to the Movie after calling this.

ISOSetMovieBrand

ISOErr ISOSetMovieBrand( ISOMovie theMovie, 
            u32 brand, u32 minorversion )

Sets the Movie’s major brand, and also inserts the major brand into the compatible brands list. This function is not normally needed; the brand is set by the appropriate movie-creation function.

ISOSetMovieCompatibleBrand

ISOErr ISOSetMovieCompatibleBrand( ISOMovie theMovie, 
u32 brand )

Adds a minor brand into the compatible brands list of the Movie. The following brands have defined constants in the headers, though of course you may use MP4_FOUR_CHAR_CODE also.

JP2JPEG2000Brand	/* brand for JPEG-2000 */
MJ2JPEG2000Brand	/* brand for Motion JPEG-2000 */
ISOQuickTimeBrand	/* brand for QuickTime */
ISOMpeg4V1Brand	/* brand for MPEG-4 version 1 */
ISOMpeg4V2Brand	/* brand for MPEG-4 version 2 */
ISOISOBrand	/* conforming brand for all files */
ISOISO2Brand	/* conforming brand for all files */
ISO3GP4Brand	/* 3GPP Release 4 */
ISO3GP5Brand	/* 3GPP Release 5 */
ISO3GP6Brand	/* 3GPP Release 6 */
ISOMPEG21Brand	/* MPEG-21 */

ISOGetMovieBrand

ISOErr ISOGetMovieBrand( ISOMovie theMovie, 
            u32* brand, u32* minorversion )

Returns the Movie’s major brand and minor version.

ISOIsMovieCompatibleBrand

u32 ISOIsMovieCompatibleBrand ( ISOMovie theMovie, u32 brand )

If the brand is a compatible brand of the movie, this returns the compatible brand, otherwise it returns 0.

ISOSetMovieTimeScale

ISOErr ISOSetMovieTimeScale( ISOMovie theMovie, u32 timeScale )

Sets the Movie’s time scale.

ISOGetMovieTimeScale

ISOErr ISOGetMovieTimeScale( ISOMovie theMovie, u32* outTimeScale )

Use this to obtain the time scale of a Movie.

ISOGetMovieTrack

ISOErr ISOGetMovieTrack( ISOMovie theMovie,
            u32 trackID,
            ISOTrack* outTrack )

Use this to obtain a track given its track ID.

ISOWriteMovieToFile

ISOErr ISOWriteMovieToFile( ISOMovie theMovie, const char *filename )

Writes the in-memory Movie to a file. The file given by filename is created, written, and closed.

ISOOpenMovieFile

ISOErr ISOOpenMovieFile( ISOMovie *theMovie,
              const char *fileName,
              int openMovieFlags )

Opens a movie file and creates a Movie in memory from this file. You may specify a pathname or a file: URL. The parameter openMovieFlags is ordinarily set to MP4OpenMovieNormal, but if you set it to MP4OpenMovieDebug a parse tree will be printed to standard output while the movie file is parsed.

MP4NewMovieFromHandle

ISOErr MP4NewMovieFromHandle( 
              MP4Movie *outMovie, 
              MP4Handle movieH, 
              u32 newMovieFlags )

Parses a movie ‘file’ in the handle and creates a Movie in memory from this file. The parameter openMovieFlags is ordinarily set to MP4OpenMovieNormal, but if you set it to MP4OpenMovieDebug a parse tree will be printed to standard output while the movie file is parsed.

ISOPutMovieIntoHandle

ISOErr ISOPutMovieIntoHandle( ISOMovie theMovie, ISOHandle aHandle )

Places the movie and its media samples into a handle.

MP4SetMovieInitialBIFSTrack

ISOErr MP4SetMovieInitialBIFSTrack( ISOMovie theMovie, ISOTrack theBIFSTrack )

Indicates that the given track is to be considered as the initial BIFS track. This information is placed into the Movie's initial object descriptor.

MP4SetMovieInitialODTrack

ISOErr MP4SetMovieInitialODTrack( ISOMovie theMovie, ISOTrack theODTrack )

Indicates that the given track is to be considered as the initial Object Descriptor stream track. This information is placed into the Movie's initial object descriptor.

MP4SetMovieIODInlineProfileFlag

ISOErr MP4SetMovieIODInlineProfileFlag( ISOMovie theMovie, u8 theFlag )

Allows you to set the value of includeInlineProfileLevelFlag in the movie's initial object descriptor.

MP4GetMovieInitialObjectDescriptor

ISOErr MP4GetMovieInitialObjectDescriptor(
              ISOMovie theMovie,
              ISOHandle h )

Retrieves the initial object descriptor from a Movie and places it into a Handle.

MP4GetMovieIODInlineProfileFlag

ISOErr MP4GetMovieIODInlineProfileFlag (
              ISOMovie theMovie,
              u8* outFlag )

Queries the setting of includeInlineProfileLevelFlag from the movie's initial object descriptor.

MP4GetMovieProfilesAndLevels

ISOErr MP4GetMovieProfilesAndLevels( ISOMovie theMovie,
              u8 *outOD, 
              u8 *outScene, 
              u8 *outAudio, 
              u8 *outVisual, 
              u8 *outGraphics )

Use this to obtain the profiles and levels from a Movie's initial object descriptor. You may pass in null for parameters that don't care to read. This call will return an error if the movie does not contain an initial object descriptor.

MJ2SetMovieMatrix

ISOErr MJ2SetMovieMatrix( ISOMovie theMovie, u32 matrix[9] );

This sets the matrix of the overall movie; the default matrix is the unity matrix, if none has been set.

MJ2GetMovieMatrix

ISOErr MJ2GetMovieMatrix( ISOMovie theMovie, u32 outMatrix[9] );

This returns the overall transformation matrix for the movie.

MJ2SetMoviePreferredRate

ISOErr MJ2SetMoviePreferredRate( ISOMovie theMovie, u32 rate );

This sets the rate of the movie (the normal and default rate is 1.0). The rate is represented as a 16.16 fixed-point number.

MJ2GetMoviePreferredRate

ISOErr MJ2GetMoviePreferredRate( ISOMovie theMovie, u32 *outRate );

This returns the currently set movie preferred rate.

MJ2SetMoviePreferredVolume

ISOErr MJ2SetMoviePreferredVolume( ISOMovie theMovie, 
s16 volume );

This sets the normal volume of the movie. The normal, default, value is 1.0. The volume is expressed as an 8.8 fixed-point number.

MJ2GetMoviePreferredVolume

ISOErr MJ2GetMoviePreferredVolume( ISOMovie theMovie, s16 *outVolume);

This returns the movie volume setting.

ISOStartMovieFragment

ISOErr ISOStartMovieFragment ( ISOMovie theMovie );

This starts a new movie fragment. Before calling this, you should create a normal movie, up to the point you would write it to the file, and you should set the track fragment defaults on the tracks to which you want to add samples. After calling this, you should only add samples, and write the file out. Each call to this function starts a new fragment. For example, in the above example, you might call this function after ISOEndMediaEdits, and then insert some more samples into the track(s).

ISOAddDelayToTrackFragmentDecodeTime

ISOErr ISOAddDelayToTrackFragmentDecodeTime (
            ISOMovie theMovie, u32 delay );

Must be called right after ISOStartMovieFragment. Setting the delay parameter to other than zero, a delay will be introduced, which will add a time offset to the track fragment decode time.

ISOSetCompositonToDecodePropertiesForFragments

ISOErr ISOSetCompositonToDecodePropertiesForFragments( 
            ISOMovie theMovie, 
            u32 trackID, 
            s32 compositionToDTSShift, 
            s32 leastDecodeToDisplayDelta,
            s32 greatestDecodeToDisplayDelta,
            s32 compositionStartTime,
            s32 compositionEndTime )

Must be called before the first ISOStartMovieFragment. Sets the compositon to decode parameters for a specific track. They have to be calculated and added before calling the first ISOStartMovieFragment and cannot be changed later.

ISOGetMovieDuration

ISOErr ISOGetMovieDuration(ISOMovie theMovie, u64* outDuration)

This calculates and returns the movie duration as recorded in the movie header, that is, the maximum track duration, expressed in units of the movie’s timescale.

ISOAddAtomToMovie

ISOErr MP4AddAtomToMovie( 
          MP4Movie theMovie, 
          MP4GenericAtom the_atom );

Adds the given atom (see ISONewForeignAtom and ISONewUUIDAtom) to the movie.


3 Track related functions

ISONewMovieTrack

ISOErr ISONewMovieTrack( ISOMovie theMovie, u32 newTrackFlags, ISOTrack *outTrack )

Creates a new track for the movie. The newTrackFlags parameter can be zero, or one of:

ISONewTrackIsVisual if the track will contain visual media

ISONewTrackIsAudio if the track will contain audio media

ISONewTrackIsPrivate if the track will not contain a media type known to MPEG-4

ISONewTrackIsMetadata if the track will be a meta-data track

ISONewMovieTrackWithID

ISOErr ISONewMovieTrackwithID( ISOMovie theMovie, 
            u32 newTrackFlags,
            u32 newTrackID,
            ISOTrack *outTrack )

Creates a new track for the movie with a specified track ID. The newTrackFlags parameter can be zero, or one of:

ISONewTrackIsVisual if the track will contain visual media

ISONewTrackIsAudio if the track will contain audio media

ISONewTrackIsPrivate if the track will not contain a media type known to MPEG-4

ISOAddTrackReference

ISOErr ISOAddTrackReference( ISOTrack theTrack, 
            ISOTrack dependsOn, 
            u32 referenceType,
            u32 *outReferenceNumber );

Indicate that there exists a dependency between two tracks. The type of dependency can be one of:

MP4HintTrackReferenceType for hint tracks, to point to the media track they depend on

MP4StreamDependencyReferenceType for elementary stream tracks, to indicate other elementary stream tracks they depend on (an enhancement layer points to a base layer, for example)

MP4ODTrackReferenceType for object descriptor tracks, to point to the elementary stream whose metadata is being updated.

The reference number is returned in outReferenceNumber. This is only useful for OD streams because the other reference types only allow one reference per track.

ISOAddTrackReferenceWithID

ISOErr ISOAddTrackReferenceWithID( ISOTrack theTrack, 
            u32 dependsOnID, u32 referenceType,
            u32 *outReferenceNumber );

Like ISOAddTrackReference, but allows you to set the reference using a track ID rather than a track.

ISOGetMovieIndTrack

ISOErr ISOGetMovieIndTrack(	ISOMovie theMovie, 
            u32 trackIndex,
            ISOTrack *outTrack );

Use this to sequence through tracks in the Movie without regard to the trackID. The index ranges between 1 and the number of tracks in the Movie.

ISOGetMovieTrackCount

ISOErr ISOGetMovieTrackCount( ISOMovie theMovie, u32* outTrackCount );

This function allows you to determine the number of Tracks in a Movie.

ISOSetTrackEnabled

ISOErr ISOSetTrackEnabled( ISOTrack theTrack, u32 enabled );

Enables or disables the track. Set enabled to a nonzero value to enable the track, or zero to disable the track.

ISOGetTrackEnabled

ISOErr ISOGetTrackEnabled( ISOTrack theTrack, u32 *outEnabled );

This returns a non-zero value in outEnabled if the track is enabled.

ISOGetTrackEditlistEntryCount

ISOErr ISOGetTrackEditlistEntryCount( ISOTrack theTrack, u32 *entryCount );

This returns the number of existent Edit list entries in entryCount if the Edit list information is present, otherwise 0.

ISOGetTrackEditlist

ISOErr ISOGetTrackEditlist( ISOTrack theTrack, 
            u32 *outSegmentDuration, 
            s64 *outMediaTime, 
            u32 entryIndex );

This returns a non-zero value in outSegmentDuration and outMediaTime if the Edit list information is present and valid. entryIndex defines the one-based index of the entry to return.

ISOGetTrackID

ISOErr ISOGetTrackID( ISOTrack theTrack, u32 *outTrackID );

Use to get the elementary stream ID for a given Track.

ISOGetTrackMedia

ISOErr ISOGetTrackMedia( ISOTrack theTrack, ISOMedia *outMedia );

Returns the Media for a given Track. An error is returned if the track contains no media.

ISOGetTrackMovie

ISOErr ISOGetTrackMovie( ISOTrack theTrack, ISOMovie *outMovie );

Get the Movie associated with a Track.

ISOGetTrackOffset

ISOErr ISOGetTrackOffset( ISOTrack theTrack, u32 *outMovieOffsetTime );

Get the track's offset (the length of its initial empty edit). The returned offset is expressed in the Movie's time scale.

ISOGetTrackReference

ISOErr ISOGetTrackReference( ISOTrack theTrack,
            u32 referenceType,
            u32 referenceIndex,
            ISOTrack *outReferencedTrack );

Use this to obtain a specific track reference of the specified type.

referenceType The type of track reference you wish to index

referenceIndex The particular reference of this type that you wish to retrieve. This is usually one, since most track references only allow one entry.

outReferencedTrack The track that is referenced.

ISOGetTrackReferenceCount

ISOErr ISOGetTrackReferenceCount( ISOTrack theTrack,
            u32 referenceType,
            u32 *outReferenceIndex );

Use this to determine the number of a particular type of track references that are contained in a track. If the track doesn’t contain any references of the specified type the return value will be zero.

ISOInsertMediaIntoTrack

ISOErr ISOInsertMediaIntoTrack( ISOTrack trak, 
            u32 trackStartTime,
            u32 mediaStartTime,
            u64 segmentDuration,
            s32 mediaRate );

Adds a reference to the specified segment of media into a Track. This may create an edit list entry for this track. Besides the Track, the parameters are:

trackstartTime time (in the movie’s time scale) at which the media is to be inserted in to the Track

mediastartTime time (in the media’s time scale) at which the desired media segment begins

segmentDuration duration (in the media’s time scale) of the segment

mediaRate The desired playback rate of the media. A value of 1 indicates normal rate. The only other permitted value is -1 which indicates a ’dwell’ should occur.

ISONewTrackMedia

ISOErr ISONewTrackMedia( ISOTrack theTrack,
            ISOMedia *outMedia,
            u32 handlerType, u32 timeScale,
            ISOHandle dataReference );

Creates the media container for a track. Parameters include:

handlerType Describes the stream type at a high level. Use one of the handler types from ISOMovies.h. Examples are ISOVisualHandlerType, ISOAudioHandlerType and ISOHintHandlerType.

timeScale The media time scale. This is the time coordinate system for the media. You express durations as a multiple of this value, so typical values are the sampling rate for audio, or frame rate for video.

dataReference A URL that indicates the location of the media samples. This must either be NULL to indicate that the samples are included in the movie’s file, or a "file://" URL encoded in UTF-8. This data reference is given index 1 in the Media. You can add others using ISOAddMediaDataReference.

ISOSetTrackOffset

ISOErr ISOSetTrackOffset( ISOTrack theTrack, u32 movieOffsetTime );

Modifies the duration of the empty space that lies at the beginning of the track, thus changing the duration of the entire track. You specify this time offset as a time value in the movie’s time scale. Call this function after you have constructed your track (e.g. after addMySamples in the example) — it relies on being able to find the duration of the media in the track.

ISOTrackTimeToMediaTime

ISOErr ISOTrackTimeToMediaTime( ISOTrack theTrack,
            u64 inTrackTime, 
            u64 *outMediaTime )

Used to convert from a time expressed in the movie time scale to a time expressed in the media time scale.

MP4AddTrackToMovieIOD

ISOErr MP4AddTrackToMovieIOD( ISOTrack theTrack );

Add track's ES_Descriptor to its movie's initial object descriptor. This should be called for any tracks that need to appear in the initial object descriptor other than the initial BIFS track or the OD track.

MJ2SetTrackMatrix

ISOErr MJ2SetTrackMatrix( ISOTrack theTrack, u32 matrix[9] );

This sets the overall transformation matrix for the movie as a whole. The matrix allows for 2D transformations; see the MJ2 specification for the details of how it is applied. The default matrix is the unitary transform.

MJ2GetTrackMatrix

ISOErr MJ2GetTrackMatrix( ISOTrack theTrack, u32 outMatrix[9] );

This returns the current matrix.

MJ2SetTrackLayer

ISOErr MJ2SetTrackLayer( ISOTrack theTrack, s16 layer );

This sets the ordering of the visual tracks. It should be set if there is more than one visual track. Smaller numbers are closer to the front.

MJ2GetTrackLayer

ISOErr MJ2GetTrackLayer( ISOTrack theTrack, s16 *outLayer );

This returns the currently set track layer.

MJ2SetTrackDimensions

ISOErr MJ2SetTrackDimensions( ISOTrack theTrack, 
            u32 width, 
            u32 height );

This sets the width and height of a track. Note that this may be different from the width and height of the media; scaling may occur. All MJ2 visual tracks should have this set explicitly.

MJ2GetTrackDimensions

ISOErr MJ2GetTrackDimensions( ISOTrack theTrack, 
            u32 *outWidth, 
            u32 *outHeight );

This returns the currently set dimensions.

MJ2SetTrackVolume

ISOErr MJ2SetTrackVolume( ISOTrack theTrack, s16 volume );

This sets the normal volume of the track. The normal, default, value is 1.0. The volume is expressed as an 8.8 fixed-point number. Different audio tracks may have different volume settings; they are mixed for playback.

MJ2GetTrackVolume

ISOErr MJ2GetTrackVolume( ISOTrack theTrack, s16 *outVolume );

Returns the currently set track volume.

ISOSetTrackFragmentDefaults

ISOErr ISOSetTrackFragmentDefaults(u32 duration, u32 size, u32 is_sync, u8 pad );

Sets the default sample duration, size, sync-flag, and padding bits for samples added into movie fragments, for this track. This function must be called for each track to which fragment samples will be added, before the first fragment is started.

ISOGetTrackDuration

ISOErr ISOGetTrackDuration(ISOMovie theMovie, u64* outDuration);

This calculates and returns the duration of the track, as expressed in the movie’s timescale. If there is an edit list, it is the sum of the durations of the edits. In the absence of an edit list, it is the track’s cumulative sample durations.

ISOAddAtomToTrack

ISOErr MP4AddAtomToTrack( MP4Track theTrack, MP4GenericAtom the_atom );

Adds the given atom (see Mp4NewForeignAtom and MP4NewUUIDAtom) to the track.


4 Media related functions

ISOAddMediaDataReference

ISOErr ISOAddMediaDataReference( ISOMedia theMedia,
            u32 *outReferenceIndex, ISOHandle urlHandle,
            ISOHandle urnHandle );

Use this to add a data reference to a media container. The data reference specifies a location for media samples. The outReferenceIndex parameter is updated to contain the index for the new reference. (You will need to use this index to create a sample description that will point to this new data reference.) The other parameters include:

urlHandle UTF-8 encoded file:// URL that indicates the file containing the samples. Set this to NULL to indicate that the samples are in the movie’s file.

urnHandle UTF-8 encoded URN. This may be used in addition to urlHandle to indicate the uniform resource name associated with this media file. If no URN is used, set urnHandle to NULL.

ISOAddMediaSampleReference

ISOErr ISOAddMediaSampleReference( ISOMedia media,
            u64 dataOffset, u32 sampleCount,
            ISOHandle durationsH, ISOHandle sizesH,
            ISOHandle sampleEntryH,
            ISOHandle compositionOffsetsH,
            ISOHandle syncSamplesH );

Use this function to add samples to a media by reference. This is usually used when the samples are already present in some file, for example when you are making reference to samples contained in an external file. There are a number of parameters:

dataOffset The byte offset into the file containing the samples. All samples added in this function are assumed to be contiguous in the file starting at this offset.

sampleCount The number of samples to be added in this call.

durationsH A handle containing u32[] durations for each sample to be added. If the durations differ you must supply a duration for each sample. If the durations are constant you should only place one entry in this handle.

sizesH A handle containing u32[] sizes (in bytes) for each sample to be added. If the sizes differ you must indicate a size for each sample. If the sizes are constant you should only place one entry in this handle.

sampleEntryH Contains a sample entry that describes the samples to be added. For MPEG-4, this entry can be created using MP4CreateSampleDescription, or for both MJ2 and MP4 you can supply your own as long as it is formatted according to the appropriate standard. If this handle is set to NULL the previous non-null sample entry will be used.

compositionOffsetsH If the media contains separate decoding and composition timestamps you must use this handle to indicate the offset between the composition time and the decoding time for each sample in a u32[]. Note that samples must be added in decoding order.

syncSamplesH If all the samples added are sync samples you can set this to NULL. Otherwise, place the one-based indexes of each sync sample into this handle as a u32[]. If none of the samples you are adding is a sync sample this handle will have a size of zero.

ISOAddMediaSamples

ISOErr ISOAddMediaSamples( ISOMedia media, 
            ISOHandle sampleH,
            u32 sampleCount,
            ISOHandle durationsH,
            ISOHandle sizesH,
            ISOHandle sampleEntryH,
            ISOHandle compositionOffsetsH,
            ISOHandle syncSamplesH );

Use this function to samples to the media. The sampleH parameter contains the data for all the samples. It is interpreted according to the other parameters, which work the same as described for ISOAddMediaSampleReference.

ISOAddMediaSamplesPad & ISOAddMediaSampleReferencePad

ISOErr ISOAddMediaSamplesPad( ISOMedia media, 
            ISOHandle sampleH,
            u32 sampleCount,
            ISOHandle durationsH,
            ISOHandle sizesH,
            ISOHandle sampleEntryH,
            ISOHandle compositionOffsetsH,
            ISOHandle syncSamplesH 
            ISOHandle padsH);

ISOErr ISOAddMediaSampleReferencePad( ISOMedia media,
            u64 dataOffset, u32 sampleCount,
            ISOHandle durationsH, ISOHandle sizesH,
            ISOHandle sampleEntryH,
            ISOHandle compositionOffsetsH,
            ISOHandle syncSamplesH 
            ISOHandle padsH);

These functions are like AddMediaSamples and ISOAddMediaSampleReference, except that it is possible to supply padding bits information for the samples (causing the insertion of a padding bits table in the output file). The parameter padsH may be NULL, indicating no pad, or may be a handle to an array of padding values (which are 8 bits each). If the array has only one value, then it is used for all the samples; otherwise, the array should be sampleCount long.

ISOBeginMediaEdits

ISOErr ISOBeginMediaEdits( ISOMedia theMedia );

Use this function to prepare the media before adding samples.

ISOCheckMediaDataReferences

ISOErr ISOCheckMediaDataReferences( ISOMedia theMedia );

Tests all data references in the media to ensure that the references exist and are readable.

ISOCheckMediaDataRef

ISOErr ISOCheckMediaDataRef ( ISOMedia theMedia, u32 dataEntryIndex );

Tests a specific data reference in the media to ensure that the reference exists and is readable.

MP4GetMediaDataRefCount

ISOErr MP4GetMediaDataRefCount( MP4Media theMedia, u32 *outCount );

Returns the number of data references.

ISOEndMediaEdits

ISOErr ISOEndMediaEdits( ISOMedia theMedia );

Call this function when you have finished adding samples to the media.

ISOGetIndMediaSample

ISOErr ISOGetIndMediaSample( ISOMedia theMedia,
            u32 sampleNumber,
            ISOHandle outSample,
            u32 *outSize,
            u64 *outDecodingTime,
            s32 *outCTSOffset,
            u64 *outDuration,
            u32 *outSampleFlags,
            u32 *outSampleDescIndex );

Returns a sample from the media, given the sample's index. Parameters include:

sampleNumber The index of the desired sample within its Media. This index runs from one to the total number of samples in the Media.

outSample The data for the desired sample. This is the raw access unit without any headers.

outSize The size of the returned sample in bytes.

outDecodingTime The decoding time for the sample using the media time scale.

outCTSOffset The composition time offset for the sample using the media time scale.

outDuration The sample's duration in units of media time scale.

outSampleFlags Flags that indicate the nature of this sample. Values are combinations of MP4MediaSampleNotSync if the sample is not a sync sample and MP4MediaSampleHasCompositionOffset if the sample’s DTS differs from its CTS.

outSampleDescIndex The index of the sample description that corresponds to this sample in the media.

MP4GetIndMediaSampleReference

ISOErr MP4GetIndMediaSampleReference( MP4Media theMedia,
            u32 sampleNumber,
            u32 *outOffset,
            u32 *outSize,
            u32 *outDuration,
            u32 *outSampleFlags,
            u32 *outSampleDescIndex,
            MP4Handle sampleDesc);

Returns a reference (offset and size) for the sample from the media, given the sample's index.

ISOGetIndMediaSampleWithPad

ISOErr ISOGetIndMediaSampleWithPad( ISOMedia theMedia,
            u32 sampleNumber,
            ISOHandle outSample,
            u32 *outSize,
            u64 *outDecodingTime,
            s32 *outCTSOffset,
            u64 *outDuration,
            u32 *outSampleFlags,
            u32 *outSampleDescIndex
            u8 *outPad );

Returns a sample from the media, given the sample's index. 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.

ISOGetMediaDataReference

ISOErr ISOGetMediaDataReference( ISOMedia theMedia,
            u32 index,
            ISOHandle referenceURL,
            ISOHandle referenceURN,
            u32 *outReferenceType,
            u32 *outReferenceAttributes );

Use this to get information about a specific data reference to a media container. The data reference specifies a location for media samples. Note that data references to samples contained in the movie's file are treated as URL reference types with no name and a special attribute bit set. The parameters are:

index The index of the desired data reference. This number ranges from one to the number of data references in the media.

referenceURL Will be set to a UTF-8 encoded file:// URL that indicates the file containing the samples. If the data reference doesn't contain a URL the handle size will be set to zero. Set referenceURL to NULL if you do not want this information.

referenceURN UTF-8 encoded URN. This may be used in addition to urlHandle to indicate the uniform resource name associated with this media file. If the data reference does not contain a URN the handle size will be set to zero. Set referenceURN to NULL if you do not want this information.

outReferenceType This will be set to MP4URLDataReferenceType or MP4URNDataReferenceType to indicate the type of data reference.

outReferenceAttributes Returns the attributes of the data reference as a bit set. The only bit currently defined is MP4DataRefSelfReferenceMask which will be set if the media's samples are contained in the same file as the movie.

ISOGetMediaDuration

ISOErr ISOGetMediaDuration( ISOMedia theMedia, u64 *outDuration );

Use this function to get the total duration of the media, expressed in the media’s time scale.

ISOGetMediaHandlerDescription

ISOErr ISOGetMediaHandlerDescription( ISOMedia theMedia,
            u32 *outType, ISOHandle *outName );

This function can be used to obtain the media type. The outType parameter is set to contain the media handler. Examples are ISOVisualHandlerType and ISOAudioHandlerType. This, and the decoder config information, can be used to obtain enough information to instantiate a decoder. If you want to retrieve the name for the handler you must supply a handle for outName, otherwise set outName to NULL.

ISOGetMediaLanguage

ISOErr ISOGetMediaLanguage( ISOMedia theMedia, char *outThreeCharCode );

Returns the ISO 639-2/T three character language code associated with the media.

ISOGetMediaExtendedLanguageTag

ISOErr ISOGetMediaExtendedLanguageTag( ISOMedia theMedia, char **extended_language );

Returns the extended language, based on RFC 4646 (Best Common Practices – BCP – 47) industry standard. Allocates memory for extended_language string. extended_language string will be set to NULL if there is no extended language tag.

ISOGetMediaSample

ISOErr ISOGetMediaSample( ISOMedia theMedia, ISOHandle outSample,
            u32 *outSize, u64 desiredDecodingTime,
            u64 *outDecodingTime, u64 *outCompositionTime,
            u64 *outDuration, ISOHandle outSampleDescription,
            u32 *outSampleDescriptionIndex,
            u32 *outSampleFlags );

Returns a closest sample from the media, given the desired decoding time. Parameters include:

outSample The data for the desired sample. This is the raw access unit without any headers.

outSize The size of the returned sample in bytes.

desiredDecodingTime The decoding time of the sample to be retrieved. You must specify this value in the media’s time scale.

outDecodingTime The decoding time for the sample using the media time scale. This time may differ from the value specified in the desiredDecodingTime parameter if that parameter's value is not at a sample time boundary.

outCompositionTime The composition time for the sample expressed in the media time scale.

outDuration The sample's duration in units of media time scale.

outSampleFlags Flags that indicate the nature of this sample. Values are combinations of MP4MediaSampleNotSync if the sample is not a sync sample and MP4MediaSampleHasCompositionOffset if the sample’s DTS differs from its CTS.

outSampleDescriptionIndex The index of the sample description that corresponds to this sample in the media.

outSampleDescription The sample description that corresponds to this sample in the media. Set this to NULL if you do not want this information to be returned.

ISOGetMediaSampleWithPad

ISOErr ISOGetMediaSampleWithPad( ISOMedia theMedia,
            ISOHandle outSample,
            u32 *outSize, u64 desiredDecodingTime,
            u64 *outDecodingTime, u64 *outCompositionTime,
            u64 *outDuration, ISOHandle outSampleDescription,
            u32 *outSampleDescriptionIndex,
            u32 outSampleFlags, u8* outPad );

Returns a closest sample from the media, given the desired decoding time. 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.

ISOGetMediaSampleCount

ISOErr ISOGetMediaSampleCount( ISOMedia theMedia, u32 *outCount );

Use this to determine the total number of samples contained in the media.

ISOGetMediaTimeScale

ISOErr ISOGetMediaTimeScale( ISOMedia theMedia, u32 *outTimeScale );

Returns the time scale associated with the media.

ISOGetMediaTrack

ISOErr ISOGetMediaTrack( ISOMedia theMedia, ISOTrack *outTrack );

Returns the track that is associated with this media.

ISOMediaTimeToSampleNum

ISOErr ISOMediaTimeToSampleNum( ISOMedia theMedia, 
            u64 desiredTime, u32 *outSampleNum,
            u64 *outSampleCompositionTime,
            u64 *outSampleDecodingTime,
            s32 *outSampleDuration );

Use this to obtain the sample number for a sample with the given decoding time. Parameters include:

desiredTime The decoding time of the desired sample. This is expressed in the media's time scale.

outSampleNum The sample number index for the desired sample.

outSampleCompositionTime, outSampleDecodingTime The composition and decoding time for the desired sample. Note that the time may differ from the desiredTime if the desired time is not on a sample boundary.

outSampleDuration The duration of the sample, expressed in the media time scale.

ISOSampleNumToMediaTime

ISOErr ISOSampleNumToMediaTime( ISOMedia theMedia, 
            u32 sampleNum, 
            u64 *outSampleCompositionTime,
            u64 *outSampleDecodingTime,
            s32 *outSampleDuration );

Use this to obtain the decoding and composition times for a particular media sample. Parameters include:

sampleNum The sample number index for the desired sample.

outSampleCompositionTime, outSampleDecodingTime The composition and decoding time for the desired sample.

outSampleDuration The duration of the sample, expressed in the media time scale.

ISOSetMediaLanguage

ISOErr ISOSetMediaLanguage( ISOMedia theMedia, char *threeCharCode );

Use this to indicate the ISO 639-2/T three character language code that is to be associated with the media.

ISOSetMediaExtendedLanguageTag

ISOErr ISOSetMediaExtendedLanguageTag( ISOMedia theMedia, char *extended_language );

The extended language tag box represents media language information, based on RFC 4646 (Best Common Practices – BCP – 47) industry standard.

ISOSetSampleSizeField

ISOErr ISOSetSampleSizeField ( ISOMedia theMedia, u32 fieldsize );

Use this to set the size of samplesize entries in the sample size table. The default value is 32, which gives the ‘old’ sample size table. Values of 4, 8, or 16 (the size in bits of the field) may be given, to request the ‘compact’ sample size table.

MP4GetMediaDecoderConfig

ISOErr MP4GetMediaDecoderConfig( ISOMedia theMedia,
u32 sampleDescIndex,
ISOHandle decoderConfigH );

Use this to obtain the decoder configuration descriptor for a given sample description.

MP4GetMediaDecoderType

ISOErr MP4GetMediaDecoderType( ISOMedia theMedia,
            u32 sampleDescIndex,
            u32 *outObjectType,
            u32 *outStreamType,
            u32 *outBufferSize,
            ISOHandle specificinfoH );

Use this to obtain the decoder configuration and specific info without having to parse the decoder config descriptor. (See MP4GetMediaDecoderConfig if you need all the configuration information.) Parameters are:

sampleDescIndex Index of the sample description you desire.

outObjectType Will contain the object type for this decoder config.

outStreamType Will contain the stream type for this decoder config.

outBufferSize Will contain the decoder buffer size.

specificInfoH Handle that will contain the specific info for this decoder config The tag and length fields are stripped from the descriptor so only the configuration data remains. Set specificInfoH to NULL if you do not want this information.

MP4GetMediaDecoderInformation

ISOErr MP4GetMediaDecoderInformation( ISOMedia theMedia,
            u32 sampleDescIndex,
            u32 *outObjectType,
            u32 *outStreamType,
            u32 *outBufferSize,
            u32 *outUpstream,
            u32 *outMaxBitrate,
            u32 *outAvgBitrate,
            ISOHandle specificinfoH );

Use this to obtain the complete decoder configuration and specific info without having to parse the decoder config descriptor. Parameters are:

sampleDescIndex Index of the sample description you desire.

outObjectType Will contain the object type for this decoder config.

outStreamType Will contain the stream type for this decoder config.

outBufferSize Will contain the decoder buffer size.

outUpstream Will contain the value of the upstream flag.

outMaxBitrate Will contain the maximum bitrate for this decoder config.

outAvgBitrate Will contain the average bitrate for this decoder config.

specificInfoH Handle that will contain the specific info for this decoder config The tag and length fields are stripped from the descriptor so only the configuration data remains. Set specificInfoH to NULL if you do not want this information.

MJ2SetMediaGraphicsMode

ISOErr MJ2SetMediaGraphicsMode( ISOMedia theMedia, 
            u32 mode, 
            const ISORGBColor *opColor );

Sets the graphics mode for this track. The mode should be chosen from the following list. The default mode is ISOGraphicsModeSrcCopy.

ISOGraphicsModeSrcCopy This video image will be copied over the top of the layers below it. This is the default value, and should be used for the backmost track.

ISOGraphicsModeTransparent The color ISORGBColor in this video image will be treated as transparent, allowing layers behind to be seen.

ISOGraphicsModeAlpha This video image includes an alpha plane to define its transparency.

ISOGraphicsModeWhiteAlpha This video image includes an alpha plane, which has been premultiplied with white, to define its transparency.

ISOGraphicsModeBlackAlpha This video image includes an alpha plane, which has been premultiplied with black, to define its transparency.

MJ2GetMediaGraphicsMode

ISOErr MJ2GetMediaGraphicsMode( ISOMedia theMedia, 
            u32 *outMode, 
            ISORGBColor *outOpColor );

Returns the currently set graphics mode.

MJ2SetMediaSoundBalance

ISOErr MJ2SetMediaSoundBalance( ISOMedia theMedia, s16 balance );

Sets the left-right balance of an audio track (normally a mono track). Balance values are represented as 16-bit, fixed-point numbers that range from -1.0 to +1.0. The high-order 8 bits contain the integer portion of the value; the low-order 8 bits contain the fractional part. Negative values weight the balance toward the left speaker; positive values emphasize the right channel. Setting the balance to 0 (the default) corresponds to a neutral setting.

MJ2GetMediaSoundBalance

ISOErr MJ2GetMediaSoundBalance( ISOMedia theMedia, s16 *outBalance );

Returns the currently set balance value.

ISOAddGroupDescription

ISOErr ISOAddGroupDescription( 
            MP4Media media, 
            u32 groupType, 
            MP4Handle description, 
            u32* index );

Adds a Sample Group Description to the indicated media. The index of the added group is returned in the index parameter. The description is the pre-serialized (big-endian format) group description.

ISOSetSamplestoGroupType

ISOErr ISOSetSamplestoGroupType ( MP4Media media, u32 enableCompact );

Sets whether this track or fragment will use a traditional sample to group map (0, default) or the newer compact sample to group map (1). Should be called only before mapping any samples in this movie or fragment.

ISOMapSamplestoGroup

ISOErr ISOMapSamplestoGroup( 
            MP4Media media, 
            u32 groupType, 
            u32 group_index, 
            s32 sample_index, 
            u32 count );

Maps a set of samples to a group of a given type, after having added the samples. The parameter groupType should be set as above, and the group_index be either 0 (to map samples to no group of this type) or an index value from the call above. The number of samples for which to set the mapping is specified by count. The first of those samples to map is indicated by sample_index; if it is zero or positive, it is the sample at that offset from the first sample in the media. If it is negative, it is at that offset from the last sample in the media. For example, a sample_index of -2 and a count of 2 sets the mapping for the last two samples. If movie fragments are in use, the sample index is relative to the current fragment (and cannot be outside it), not the whole movie.

ISOGetSampletoGroupMap

ISOErr ISOGetSampletoGroupMap( 
            MP4Media media, 
            u32 groupType, 
            u32 sample_number, 
            u32* group_index );

Returns in group_index the group index associated with the given sample number of the given group type.

ISOGetGroupDescription

ISOErr ISOGetGroupDescription( 
            MP4Media media, 
            u32 groupType, 
            u32 index, 
            MP4Handle description );

Returns in the handle ‘description’ the group description associated with the given group index of the given group type.

ISOSetSampleDependency

ISOErr ISOSetSampleDependency( MP4Media media, 
            s32 sample_index, MP4Handle dependencies );

Sets the sample dependency of a set of samples, after having added the samples. The number of samples for which to set the mapping is specified by the size of the handle. The first of those samples to map is indicated by sample_index; if it is zero or positive, it is the sample at that offset from the first sample in the media. If it is negative, it is at that offset from the last sample in the media. For example, a sample_index of -2 and a count of 2 sets the dependency for the last two samples. If movie fragments are in use, the sample index is relative to the current fragment (and cannot be outside it), not the whole movie.

The handle contains a set of one-byte values each made from OR-ing together the at most one from each pair of the following constants:

does_depend_on
does_not_depend_on

is_depended_on
is_not_depended_on

has_redundancy
has_no_redundancy

ISOGetSampleDependency

ISOErr ISOGetSampleDependency( MP4Media media, s32 sample_index, u8* dependency );

Returns in dependency the sample dependency associated with the given sample number.

ISOUseSignedCompositionTimeOffsets

ISOErr ISOUseSignedCompositionTimeOffsets ( MP4Media media );

Sets the version of the CompositionOffsetAtom to 1, which means that negative offsets for the composition time are enabled. Call this function before adding samples to the media. This function also adds the composition to decode atom to the sample table. Note that, before you start a new movie fragment you have to call ISOSetCompositonToDecodePropertiesForFragments to set the composition to decode fields manually, because they cannot be automatically computed for fragments.


5 MPEG sample auxiliary information functions

MP4SetupSampleAuxiliaryInformation

ISOErr MP4SetupSampleAuxiliaryInformation ( 
            MP4Media theMedia, 
            u8 isUsingAuxInfoPropertiesFlag,
            u32 aux_info_type, 
            u32 aux_info_type_parameter,
            u8 default_sample_info_size );

This function can be used to setup and initialize sample auxiliary information for a track. It must be called before adding sample auxiliary data. It can be called multiple times with different type, parameter combinations to setup multiple sample auxiliary information for a single track. To add sample auxiliary data for a sample use MP4AddSampleAuxiliaryInformation.

isUsingAuxInfoPropertiesFlag Indicates whether aux_info_type and aux_info_type_parameter are used for setting up auxiliary information.

aux_info_type Set this properly according to the specification.

aux_info_type_parameter Set this properly according to the specification.

default_sample_info_size If not equal to zero, all data for sample auxiliary information must be the given size.

MP4AddSampleAuxiliaryInformation

ISOErr MP4AddSampleAuxiliaryInformation ( 
            MP4Media theMedia, 
            u8 isUsingAuxInfoPropertiesFlag, 
            u32 aux_info_type, 
            u32 aux_info_type_parameter,
            MP4Handle dataH,
            u32 sampleCount,
            MP4Handle sizesH );

This function can be used to add sample auxiliary information data for a range of samples. The first three parameters are used to identify the type of sample auxiliary information. Note that before adding data, MP4SetupSampleAuxiliaryInformation has to be called with the same parameters.

MP4GetSampleAuxiliaryInformation

ISOErr MP4GetSampleAuxiliaryInformation( 
            MP4Media theMedia, 
            u32 *outCount, 
            MP4Handle isUsingAuxInfoPropertiesFlags,
            MP4Handle aux_info_types, 
            MP4Handle aux_info_type_parameters );

This function can be used to get information about all sample auxiliary information for a track. The outCount parameter will contain the number of different sample auxiliary information. The MP4Handles will contain an array of u8 and u32, which will represent the description of each instance of sample auxiliary information inside a track.

MP4GetSampleAuxiliaryInformationForSample

ISOErr MP4GetSampleAuxiliaryInformationForSample( 
            MP4Media theMedia, 
            u8 isUsingAuxInfoPropertiesFlag, 
            u32 aux_info_type, 
            u32 aux_info_type_parameter,
            u32 sampleNr, 
            MP4Handle outDataH, 
            u32 *outSize );

This function can be used to get the sample auxiliary information data for a specific sample and type.


6 MPEG sync-layer functions

MP4NewSampleDescription

ISOErr MP4NewSampleDescription( ISOTrack theTrack,
            ISOHandle sampleDescriptionH,
            u32 dataReferenceIndex,
            u32 objectTypeIndication,
            u32 streamType,
            u32 decoderBufferSize,
            u32 maxBitrate,
            u32 avgBitrate,
            ISOHandle decoderSpecificInfoH );

This function can be used to create a basic sample description that can be used for calls to AddMediaSample. This will create the proper kind of sample entry atom for the track type, and a basic elementary stream descriptor that contains the information you provide in the following parameters:

sampleDescriptionH The handle that will contain the new sample description.

dataReferenceIndex The index of the data reference that describes the media samples. If you haven’t called ISOAddMediaDataReference this parameter should be set to 1. Otherwise set it to the proper reference index for these samples.

objectTypeIndication Set this properly according to the table in the Systems specification.

streamTypeIndication Set this properly according to the table in the Systems specification.

decoderBufferSize Set this to the size (in bytes) needed for the decoder input buffer for this stream.

maxBitrate Set this to the maximum number of bits per second needed to transmit this media media, defined according to the Systems specification.

avgBitrate Set this to the average bitrate for this media, defined according to the Systems specification.

decoderSpecificInfoH A handle that must contain the decoder specific info needed for a decoder for this media type. This must be a properly formed descriptor, including tag and length fields.

MP4NewSampleDescriptionWithOCRAssociation

ISOErr MP4NewSampleDescriptionWithOCRAssociation( 
ISOTrack theTrack,
ISOHandle sampleDescriptionH,
u32 dataReferenceIndex,
u32 objectTypeIndication,
u32 streamType,
u32 decoderBufferSize,
u32 maxBitrate,
u32 avgBitrate,
ISOHandle decoderSpecificInfoH,
u32 theOCRESID );

This function is a version of MP4NewSampleDescription that permits the caller to indicate an association of the sample description with a clock reference. Parameters are the same as MP4NewSampleDescription, with the addition of:

theOCRESID Set this to the ESID of the clock reference stream. A value of zero is permitted, and indicates that the stream has no explicit OCR association.

MP4SetSampleDescriptionPriority

ISOErr MP4SetSampleDescriptionPriority(MP4Handle sampleEntryH, u32 priority);

This function sets the MPEG-4 elementary stream priority of the associated stream (in the elementary stream descriptor).


7 MPEG SLConfig functions

typedef struct MP4SLConfigSettingsRecord {
            u32 predefined;
            u32 useAccessUnitStartFlag;
            u32 useAccessUnitEndFlag;
            u32 useRandomAccessPointFlag;
            u32 useRandomAccessUnitsOnlyFlag;
            u32 usePaddingFlag;
            u32 useTimestampsFlag;
            u32 useIdleFlag;
            u32 durationFlag;
            u32 timestampResolution;
            u32 OCRResolution;
            u32 timestampLength;
            u32 OCRLength;
            u32 AULength;
            u32 instantBitrateLength;
            u32 degradationPriorityLength;
            u32 AUSeqNumLength;
            u32 packetSeqNumLength;
            u32 timeScale;
            u32 AUDuration;
            u32 CUDuration;
            u64 startDTS;
            u64 startCTS;
            u32 OCRESID;
} MP4SLConfigSettings, *MP4SLConfigSettingsPtr;

MP4GetMovieInitialObjectDescriptorUsingSLConfig

MP4GetMovieInitialObjectDescriptorUsingSLConfig( MP4Movie theMovie, MP4SLConfig slconfig, MP4Handle outDescriptorH );

This function ...

MP4NewSLConfig

MP4NewSLConfig( MP4SLConfigSettingsPtr settings, MP4SLConfig *outSLConfig );

This function ...

MP4GetSLConfigSettings

MP4GetSLConfigSettings( MP4SLConfig config, MP4SLConfigSettingsPtr outSettings );

This function ...

MP4SetSLConfigSettings

MP4SetSLConfigSettings( MP4SLConfig config, MP4SLConfigSettingsPtr settings );

This function ...


8 General Sample Description functions

These functions can be used to build general sample descriptions (i.e. non-MP4 ones).

ISONewGeneralSampleDescription

ISOErr ISONewGeneralSampleDescription( 
            MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            u32 sampleEntryType,
            MP4GenericAtom extensionAtom );

This function can be used to create a basic sample description that can be used for calls to AddMediaSample. This will create the proper kind of sample entry atom for the track type. It takes the following parameters:

sampleDescriptionH The handle that will contain the new sample description.

dataReferenceIndex The index of the data reference that describes the media samples. If you haven’t called ISOAddMediaDataReference this parameter should be set to 1. Otherwise set it to the proper reference index for these samples.

sampleEntryType The four-character-code for the type of sample entry. Use a pre-defined type or the macro MP4_FOUR_CHAR_CODE, which takes four single character arguments.

extensionAtom You can supply an extra atom to be placed into the sample entry here.

MP4GetMediaSampleDescription

ISOErr MP4GetMediaSampleDescription( 
            MP4Media theMedia, 
            u32 index, 
            MP4Handle outDescriptionH, 
            u32 *outDataReferenceIndex );

This returns the sample description at the given index, with the data reference index that is associated with it.

ISOSetSampleDescriptionDimensions

ISOErr ISOSetSampleDescriptionDimensions(
            MP4Handle sampleEntryH, 
            u16 width, 
            u16 height);

This function sets the visual width and height of a sample description.

ISOGetSampleDescriptionDimensions

ISOErr ISOGetSampleDescriptionDimensions(
            MP4Handle sampleEntryH, 
            u16 *width, 
            u16 *height);

This function gets the visual width and height of a sample description.

ISOSetSampleDescriptionType

ISOErr ISOSetSampleDescriptionType(
            MP4Handle sampleEntryH, 
            u32 type);

This function can be used to (re)set the type of a sample description. Be careful; do not set the type away from, and back to, an MPEG-4 type, or the elementary stream descriptor atom will be lost.

ISOGetSampleDescriptionType

ISOErr ISOGetSampleDescriptionType(
            MP4Handle sampleEntryH, 
            u32 *type);

This function returns the type of a sample description.

ISOAddAtomToSampleDescription

ISOErr ISOAddAtomToSampleDescription(MP4Handle sampleEntryH, MP4GenericAtom extensionAtom);

This function adds an arbitrary atom to a sample entry (description).

ISOAddBitrateToSampleDescription

ISOErr ISOAddBitrateToSampleDescription(MP4Handle sampleEntryH, u8 is_3GPP, u32 buffersizeDB, u32 maxBitrate, u32 avgBitrate);

This function adds a bitrate atom to a sample entry (description).

ISOGetAtomFromSampleDescription

ISOErr ISOGetAtomFromSampleDescription(MP4Handle sampleEntryH, u32 atomType, MP4GenericAtom* outAtom);

This function finds the atom of the given type and returns it.

ISONewXMLMetaDataSampleDescription

ISOErr ISONewXMLMetaDataSampleDescription( MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            char*	content_encoding,
            char*	xml_namespace,
            char*	schema_location );

This function makes a sample description for a timed XML meta-data track.

ISONewTextMetaDataSampleDescription

ISOErr ISONewTextMetaDataSampleDescription(  MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            char*	content_encoding,
            char*	mime_format );

This function makes a sample description for a timed text meta-data track.

ISONewH263SampleDescription

ISOErr ISONewH263SampleDescription(  MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            u32 vendor,
            u8 decoder_version,
            u8 H263_level,
            u8 H263_profile);

This function creates a new H.263 video sample description according to the 3GPP specifications.

ISONewAMRSampleDescription

ISOErr ISONewAMRSampleDescription(  MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            u8 is_WB,
            u32 vendor,
            u8 decoder_version,
            u16 mode_set,
            u8 mode_change_period,
            u8 frames_per_sample);

This function creates a new AMR audio sample description according to the 3GPP specifications.

ISONewAMRWPSampleDescription

ISOErr ISONewAMRWPSampleDescription(  MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            u32 vendor,
            u8 decoder_version);

This function creates a new AMR wideband plus audio sample description according to the 3GPP specifications.


9 AVC Sample Description functions

These convenience functions can be used to build and inspect AVC sample descriptions (i.e. non-MP4 ones).

ISONewAVCSampleDescription

ISOErr ISONewAVCSampleDescription(  MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            u32 length_size, 
            MP4Handle first_sps, 
            MP4Handle first_pps, 
            MP4Handle first_spsext );

This builds a new sample entry. The length_size is the size of the NAL Unit length field (and must be 1, 2 or 4). The remaining three parameters are parameter sets (sequence, picture, and sequence extension, respectively), or NULL. The sequence parameter set MUST be passed – it is used to get the profile, level, etc. It will only be added to the configuration if a picture parameter set is also present. The sequence extension parameter set is only used if an appropriate profile is used, of course.

You almost certainly will need to set the sample description width and height, after calling this function.

ISOAddVCSampleDescriptionPS

ISOErr ISOAddVCSampleDescriptionPS(  MP4Handle sampleEntryH, MP4Handle ps, u32 where );

This adds another parameter set (which is not, in fact, inspected), to the configuration. where can be AVCsps, AVCpps or AVCspsext.

ISOGetAVCSampleDescription

ISOErr ISOGetAVCSampleDescription( MP4Handle sampleEntryH,
            u32 *dataReferenceIndex,
            u32 *length_size,
            u32* sps_count, 
            u32* pps_count, 
            u32* spsext_count );

This gets the basic parameters of the AVC sample entry.

ISOGetVCSampleDescriptionPS

ISOErr ISOGetVCSampleDescriptionPS(  MP4Handle sampleEntryH, MP4Handle ps, u32 where, u32 index );

This gets a parameter set, placing it in the given handle. where is interpreted as for adding parameter sets; the indexes start at 1 (1 is the first parameter set in the indicated array).


10 MetaData Sample Description functions

These convenience functions can be used to build and inspect metadata sample descriptions.

ISONewXMLMetaDataSampleDescription

ISOErr ISONewXMLMetaDataSampleDescription(  
            MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            char*	content_encoding,
            char*	xml_namespace,
            char*	schema_location );

This builds a new XML metadata sample entry.

ISONewTextMetaDataSampleDescription

ISOErr ISONewTextMetaDataSampleDescription(  
            MP4Track theTrack,
            MP4Handle sampleDescriptionH,
            u32 dataReferenceIndex,
            char*	content_encoding,
            char*	mime_format );

This builds a new text metadata sample entry.


11 User data functions

These functions allow you to access and manipulate track and movie user data.

ISOAddUserData

ISOErr ISOAddUserData( MP4UserData theUserData, 
            ISOHandle dataH, u32 userDataType,
            u32 *outIndex );

Adds an entry to the user data list. Parameters are:

theUserData The user data list you are modifying

dataH An ISOHandle containing the data you are adding

userDataType The atom type that will identify this data

outIndex Returns the index (of entries of userDataType) that corresponds to this entry. You will need this to retrieve this particular entry.

ISOGetIndUserDataType

ISOErr ISOGetIndUserDataType( MP4UserData theUserData, 
            u32 typeIndex,
            u32 *outType );

Queries an indexed type of user data in the user data list. Parameters are:

theUserData The user data list you are querying

typeIndex The index for the atom type you are querying. This should be one based.

outType Returns the atom type corresponding to the given index.

ISOGetMovieUserData

ISOErr ISOGetMovieUserData( ISOMovie theMovie, MP4UserData *outUserData );

Gives you access to the Movie's user data list.

ISOGetTrackUserData

ISOErr ISOGetTrackUserData( ISOTrack theTrack, MP4UserData *outUserData );

Gives you access to the Track's user data list.

ISOGetUserDataEntryCount

ISOErr ISOGetUserDataEntryCount(MP4UserData userData,
            u32 userDataType,
            u32 *outCount );

Returns the count of user data atoms of the specified type.

ISOGetUserDataItem

ISOErr ISOGetUserDataItem(MP4UserData userData,
            ISOHandle dataH,
            u32 userDataType,
            u32 itemIndex );

Returns the contents of the requested user data item. Parameters are:

userData The user data list you are querying

dataH A handle to contain the returned data

userDataType The type of user data

itemIndex The index for the atom type you are querying. This should be one based.

ISOGetAtomFromUserData

ISOErr ISOGetAtomFromUserData(MP4UserData userData,
            MP4GenericAtom *outAtom,
            u32 userDataType,
            u32 itemIndex );

Returns the contents of the requested user data item. Parameters are:

userData The user data list you are querying

outAtom A generic atom, which will contain the requested atom

userDataType The type of user data

itemIndex The index for the atom type you are querying. This should be one based.

ISOGetUserDataTypeCount

ISOErr ISOGetUserDataTypeCount(MP4UserData userData, u32 *outCount );

Returns the count of user data types.

ISONewUserData

ISOErr ISONewUserData( MP4UserData *outUserData );

Creates a new user data list.

ISODeleteUserDataItem

ISOErr MP4DeleteUserDataItem( MP4UserData theUserData, 
            u32 userDataType, u32 itemIndex );

Deletes a user-data item, by index.

ISONewForeignAtom

ISOErr ISONewForeignAtom( 
            MP4GenericAtom *outAtom, 
            u32 atomType, 
            MP4Handle atomPayload );

Creates a new atom with the given type. The pre-serialized content of the atom is taken from the given handle.

ISONewUUIDAtom

ISOErr ISONewUUIDAtom( 
            MP4GenericAtom *outAtom, 
            u8 the_uuid[16], 
            MP4Handle atomPayload );

Creates a new extension atom with the given UUID. The pre-serialized content of the atom is taken from the given handle.

ISOGetForeignAtom

ISOErr ISOGetForeignAtom( MP4GenericAtom atom, 
            u32* atomType, 
            u8 the_uuid[16], 
            MP4Handle atomPayload );

Returns the type and contents of the given foreign atom, and, if it is a UUID atom, its UUID also.


12 Meta-data functions

These functions allow you to manage meta boxes (atoms) at file, movie, and track level, and the items they contain. The meta-type in the following functions can be a four-character code, or one of the pre-defined codes:

MP7TextHandlerType
7BinaryHandlerType
MP21HandlerType
MP4NullHandlerType

ISONewFileMeta

ISOErr ISONewFileMeta( ISOMovie theMovie, 
            u32 metaType, 
            ISOMeta* meta);

Creates a new meta box (atom), with the indicated ‘handler’ type, at the file level. If there is already a meta box present, a additional meta box atom will be created and the new meta box will be added inside.

ISONewMovieMeta

ISOErr ISONewMovieMeta( ISOMovie theMovie, 
            u32 metaType, 
            ISOMeta* meta );

Creates a new meta box (atom), with the indicated ‘handler’ type, in the movie box (atom). If there is already a meta box present, a additional meta box atom will be created and the new meta box will be added inside.

ISONewTrackMeta

ISOErr ISONewTrackMeta( ISOTrack theTrack, 
            u32 metaType, 
            ISOMeta* meta );

Creates a new meta box (atom), with the indicated ‘handler’ type, in the indicated track box (atom). If there is already a meta box present, a additional meta box atom will be created and the new meta box will be added inside.

ISOAddMetaBoxRelation

ISOErr ISOAddMetaBoxRelation (ISOMeta first_meta, 
            ISOMeta second_meta, u8 relation_type );

Adds a meta box relation box to the additional meta data box, related to first and second meta box. They must live on the same level (file, movie, track).

ISOGetMetaBoxRelation

ISOErr ISOAddMetaBoxRelation (ISOMeta first_meta, 
            ISOMeta second_meta, u8 *relation_type );

The relation_type will contain the type found in a meta box relation box or 0.

ISOAddMetaDataReference

ISOErr ISOAddMetaDataReference( ISOMeta meta, 
            u16* out_data_ref_index, 
            ISOHandle urlHandle, 
            ISOHandle urnHandle );

Adds a data reference to the given meta-data. The returned reference in can later be passed to the ISOAddMetaItem.

ISOAddMetaItem

ISOErr ISOAddMetaItem( ISOMeta meta, 
            ISOMetaItem* outItem, 
            u64 base_offset, 
            u16 data_ref_index );

Creates a new meta-data item, and returns an opaque pointer to it. The data reference can be zero (for items to be in the same file) or as returned by ISOAddMetaDataReference. The base offset should generally be zero; the software will increment this to reflect the actual base offset of the item’s first extent in the file.

ISOAddMetaItemWithID

ISOErr ISOAddMetaItemWithID( ISOMeta meta, 
            ISOMetaItem* outItem, 
            u64 base_offset, 
            u16 data_ref_index, u16 item_ID );

Like the previous function, but allows a specific ID to be requested.

ISOAddItemExtent

ISOErr ISOAddItemExtent( ISOMetaItem item, MP4Handle data );

Adds some data to the given item, as its first (perhaps only) extent. Should generally be called only when the data reference for the item was supplied as zero. The data will be added to the related mdat box. NOTE: If there are multiple extents for one item, their data must be added using the same ISOAddItemExtent* function.

ISOAddItemExtentReference

ISOErr ISOAddItemExtentReference( ISOMetaItem item, 
            u64 offset, 
            u64 length );

Adds a reference to the data. Should generally be called only when a non-zero data reference was supplied for the item. NOTE: If there are multiple extents for one item, their data must be added using the same ISOAddItemExtent* function.

ISOAddItemExtentUsingItemData

ISOErr ISOAddItemExtentUsingItemData ( ISOMetaItem item, MP4Handle data );

Adds some data to the given item, as its first (perhaps only) extent. The data will be added to an item data box, which is contained in the meta data box. NOTE: If there are multiple extents for one item, their data must be added using the same ISOAddItemExtent* function.

ISOAddItemExtentItem

ISOErr ISOAddItemExtentItem( ISOMetaItem item,
            ISOMetaItem extent_item,
            u64 offset, 
            u64 length );

Indicates that the data for this extent is located at another item’s extends. NOTE: If there are multiple extents for one item, their data must be added using the same ISOAddItemExtent* function.

ISOAddItemReference

ISOErr ISOAddItemReference (ISOMetaItem item, 
            u32 reference_type,
            u32 to_item_ID, 
            u32 *outIndex);

This function adds an item reference to the item reference box. If there is no existing item reference box, it will be created. The outIndex will contain the position of the to_item_ID in all to_item_IDs of this item / reference_type combination.

ISOAddItemReferences

ISOErr ISOAddItemReferences (ISOMetaItem item, 
            u32 reference_type, 
            u16 reference_count, 
            MP4Handle to_item_IDs);

This function adds multiple item references to the item reference box. If there is no existing item reference box, it will be created. NOTE: If there are already existing references of this item / reference_type combination, they will be overwritten.

ISOGetItemReferences

ISOErr ISOGetItemReferences (ISOMetaItem item, 
            u32 reference_type, 
            u16 *reference_count,
            MP4Handle to_item_IDs);

This function collects all item references of the item / reference_type combination.

ISOAddPrimaryData

ISOErr ISOAddPrimaryData( ISOMeta meta, 
            u32 box_type, 
            MP4Handle data, 
            u8 is_full_atom );

Places the indicated data inside a box in the meta-box, with the indicated box type (e.g. ISOXMLAtomType or ISOBinaryXMLAtomType). The flag is_full_atom can be used to insert the four bytes of version and flags required in a full atom.

ISOGetPrimaryData

ISOErr ISOGetPrimaryData( ISOMeta meta, 
            u32 box_type, 
            MP4Handle data, 
            u8 is_full_atom );

Finds the box of the given type inside the meta box, and returns its contents. The flag is_full_atom can be used to skip the four bytes of version and flags of a full atom.

ISOGetPrimaryItemData

ISOErr ISOGetPrimaryItemData( ISOMeta meta, 
            u32 box_type, 
            MP4Handle data, 
            u8 is_full_atom );

Like ISOGetPrimaryData, but probably more useful, as if a box of the given type does not exist, finds the primary item and returns its data. Gives an error indication if neither the box nor the primary item exist.

ISOSetPrimaryItem

ISOErr ISOSetPrimaryItem( ISOMeta meta, ISOMetaItem item );

Sets the item of the indicated ID as the primary item (using a primary item box).

ISOGetPrimaryItemID

ISOErr ISOGetPrimaryItemID( ISOMeta meta, u16 *ID );

Finds the ID of the primary item.

ISOGetItemID

ISOErr ISOGetItemID( ISOMetaItem item, u16* ID );

Gets the ID of the indicated item.

ISOSetItemInfo

ISOErr ISOSetItemInfo( ISOMetaItem item, 
            u16 protection_index, 
            char* name, 
            char* content_type, 
            char* content_encoding );

Sets the information for the indicated item; the protection_index is returned by ISONewMetaProtection (see below).

ISOSetItemInfoExtension

ISOErr ISOSetItemInfoExtension ( ISOMetaItem item, 
            MP4Handle extension, 
            u32 extension_type );

Adds an item info extension to an existing item info entry.

ISOGetItemInfoExtension

ISOErr ISOGetItemInfoExtension ( ISOMetaItem item, 
            MP4Handle extension, 
            u32 *extension_type );

Gets an item info extension and its extension type from an item.

ISOSetItemInfoItemType

ISOErr ISOSetItemInfoItemType ( ISOMetaItem item, 
            u32 item_type, 
            char* item_uri_type);

Adds an item info item type to an existing item info entry. NOTE: item_uri_type can be NULL, if the item_type is not ‘uri ‘.

ISOGetItemInfoItemType

ISOErr ISOGetItemInfoItemType ( ISOMetaItem item, 
            u32 *item_type, 
            char** item_uri_type);

Gets an item info item type from an existing item info entry. NOTE: item_uri_type could be NULL, if the item_type is not ‘uri ‘.

ISOGetItemInfoExtension

ISOErr ISOGetItemInfoExtension ( ISOMetaItem item, 
            MP4Handle extension, 
            u32 *extension_type );

Gets an item info extension and its extension type from an item.

ISOGetFileMeta

ISOErr ISOGetFileMeta( ISOMovie theMovie, 
            ISOMeta* meta, 
            u32 inMetaType, 
            u32* outMetaType);

Gets a reference to the file-level meta data. The input parameter meta-type, if non-zero, can be used to check that the associated meta-data is of the given type. The output always supplies the type.

ISOGetMovieMeta

ISOErr ISOGetMovieMeta( ISOMovie theMovie, 
            ISOMeta* meta, 
            u32 inMetaType, 
            u32* outMetaType );

Gets a reference to the movie-level meta data. The input parameter meta-type, if non-zero, can be used to check that the associated meta-data is of the given type. The output always supplies the type.

ISOGetTrackMeta

ISOErr ISOGetTrackMeta( ISOTrack theTrack, 
            ISOMeta* meta, 
            u32 inMetaType, 
            u32* outMetaType );

Gets a reference to the track-level meta data. The input parameter meta-type, if non-zero, can be used to check that the associated meta-data is of the given type. The output always supplies the type.

ISOGetAllItemsWithType

ISOErr ISOGetAllItemsWithType (ISOMeta meta,
            u32 type, 
            ISOMetaItem **items,
            u32 *numberOfItemsFound);

Collects all items of a given type and presents the result in form of an array.

ISOFindItemByName

ISOErr ISOFindItemByName( ISOMeta meta, 
            ISOMetaItem* item, 
            char* name, 
            u8 exact_case );

Finds an item that has the associated name in its item information.

ISOFindItemByID

ISOErr ISOFindItemByID( ISOMeta meta, 
            ISOMetaItem* item, 
            u16 ID );

Gets a reference to an item by its ID.

ISOGetItemData

ISOErr ISOGetItemData( ISOMetaItem item, 
            MP4Handle data, 
            u64* base_offset );

Reads and returns the data associated with all the extents of the given item, concatenating them. The returned base offset will be adjusted to represent the offset in the resulting handle (which will generally match the value passed in to ISOAddMetaItem, typically zero).

ISOGetItemInfo

ISOErr ISOGetItemInfo( ISOMetaItem item, 
            u16* protection_index, 
            char* name, 
            char* content_type, 
            char* content_encoding );

Returns the information for a given item. It is your responsibility to make sure the buffers are large enough for the strings.

ISOCheckMetaDataReferences

ISOErr ISOCheckMetaDataReferences( ISOMeta meta );

Checks that all the data references used by the meta-data are accessible.

ISONewMetaProtection

ISOErr ISONewMetaProtection( ISOMeta meta, 
            u32 sch_type, 
            u32 sch_version, 
            char* sch_url, 
            u16* protection_index );

Creates a new item protection information inside the given meta-data box.

ISOAddMetaProtectionInfo

ISOErr ISOAddMetaProtectionInfo( ISOMeta meta, 
            u16 protection_index, 
            MP4GenericAtom schi_atom );

Adds an arbitrary atom to the scheme information of the associated protection information.

ISOGetMetaProtection

ISOErr ISOGetMetaProtection( ISOMeta meta, 
            u16 protection_index, 
            u32* sch_type, 
            u32* sch_version, 
            char* sch_url );

Gets the scheme type, version, and URL associated with the protection information of the given index.

ISOGetMetaProtectionInfo

ISOErr ISOGetMetaProtectionInfo( ISOMeta meta, 
            u16 protection_index, 
            u32 atom_type, 
            MP4GenericAtom* schi_atom  );

Finds and returns the atom of the given type inside the scheme information of the protection scheme at the given index.

ISOAddMetaItemProperty

ISOErr ISOAddMetaItemProperty (ISOMetaItem item, MP4GenericAtom* itemProperty, u8 essential);

Adds an item property, which can be any MP4GenericAtom, to an ISOMetaItem. The essential flag can be set with 1 and unset with 0.

ISOGetProperitesOfMetaItem

ISOErr ISOGetProperitesOfMetaItem (ISOMetaItem item, MP4GenericAtom** properties, u32 *propertiesFound);

Retruns an array of MP4GenericAtom pointers, which represent the item properties found for the item given. The u32 propertiesFound indicates the amount of items found and the size of the array, that is returned.


13 Track reader functions

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 ...


14 MPEG-4 IPMPX related functions

MP4NewIPMPDescriptorPointer

ISOErr MP4NewIPMPDescriptorPointer( MP4Handle ipmpDescPtrH, 
            u8 ipmpDescPtrId,
            u16 ipmpToolDescId );

Creates a new IPMPDescriptorPointer. The parameters are:

ipmpDescPtrH Handle containing the output IPMP Descriptor Pointer

ipmpDescPtrId ID of the output IPMP Descriptor Pointer

ipmpToolDescId ID of the IPMP Tool Descriptor pointed by the output IPMP Descriptor Pointer

MP4AddDescToSampleDescription

ISOErr MP4AddDescToSampleDescription( MP4Handle sampleEntryH, MP4Handle descriptorH );

This function can be used to add an IPMP Descriptor Pointer into an existing sampleDescription.

MP4NewIPMPInitialize

ISOErr MP4NewIPMPInitialize( MP4Handle ipmpInitializeH,
            u8 controlPointCode,
            u8 sequenceCode );

Creates a new IPMPInitialize structure with the following parameters:

ipmpInitializeH Handle containing the output IPMPInitialize structure

controlPointCode The control Point Code can be one of the following:

  • MP4IPMP_NoControlPoint
  • MP4IPMP_DB_Decoder_ControlPoint
  • MP4IPMP_Decoder_CB_ControlPoint
  • MP4IPMP_CB_Compositor_ControlPoint
  • MP4IPMP_BIFSTree_ControlPoint

sequenceCode The higher the sequence code, the higher the sequencing priority of the IPMP tool instance at the given control point.

MP4AddIPMPDataToIPMPInitialize

ISOErr MP4AddIPMPDataToIPMPInitialize( 
            MP4Handle ipmpInitializeH,
            MP4Handle ipmpDataH );

Adds IPMP data to the IPMPInitialize structure with the following parameters:

ipmpInitializeH Handle containing the IPMPInitialize structure. Can be created with the MP4NewIPMPInitialize function.

ipmpDataH Handle containing the IPMP Data to insert in the IPMPInitalize structure.

MP4NewIPMPToolDescriptor

ISOErr MP4NewIPMPToolDescriptor( MP4Handle ipmpToolDescH,
            u16 ipmpToolDescrId,
            u64 ipmpToolIdLowerPart,
            u64 ipmpToolIdUpperPart,
            MP4Handle ipmpInitializeH );

Creates a new IPMP Tool Descriptor with the following parameters:

ipmpToolDescH Handle containing the ouptut IPMP Tool Descriptor

ipmpToolDescrId ID of the output IPMP Tool Descriptor

ipmpToolIdLowerPart First 64 bits of the 128bits IPMP Tool ID

ipmpToolIdUpperPart Last 64 bits of the 128bits IPMP Tool ID

ipmpInitializeH Handle Containing the IPMPInitialize structure. Can be set to NULL if no IPMPInitialize structure is present.

MP4AddIPMPDataToIPMPToolDescriptor

ISOErr MP4AddIPMPDataToIPMPToolDescriptor( 
            MP4Handle ipmpToolDescH,
            MP4Handle ipmpDataH );

Adds IPMP data to an IPMP Tool Descriptor with the following parameters:

ipmpToolDescH Handle containing the IPMP Tool Descriptor. Can be created with the MP4NewIPMPToolDescriptor function.

ipmpDataH Handle containing the IPMP Data to insert in the IPMP Tool Descriptor.

MP4NewIPMPToolDescriptorUpdate

ISOErr MP4NewIPMPToolDescriptorUpdate( MP4Handle ipmpToolDescUpdateH );

Creates a new IPMPToolDescriptorUpdate command.

MP4AddIPMPToolDescriptorToUpdate

ISOErr MP4AddIPMPToolDescriptorToUpdate( 
            MP4Handle ipmpToolDescUpdateH,
            MP4Handle ipmpToolDescH );

Adds an IPMP Tool Descriptor to IPMPToolDescriptorUpdate command with the following paramters:

ipmpToolDescUpdateH Handle containing the IPMPToolDescriptorUpdate command. Can be created with the MP4NewIPMPToolDescriptorUpdate function

ipmpToolDescH Handle containing the IPMPToolDescriptor to insert in the command. Can be created with the MP4NewIPMPToolDescriptor function.

MP4NewIPMPTool

ISOErr MP4NewIPMPTool( MP4Handle ipmpToolH,
            u64 ipmpToolIdLowerPart,
            u64 ipmpToolIdUpperPart,
            MP4Handle altGroupInfoH,
            MP4Handle parametricInfoH );

Creates a new IPMPTool structure with the following parameters:

ipmpToolH Handle containing the output IPMPTool structure

ipmpToolIdLowerPart First 64 bits of the 128bits IPMP Tool ID

ipmpToolIdUpperPart Last 64 bits of the 128bits IPMP Tool ID

altGroupInfoH Handle built as an u64[] array containing for example:

  • alternateTool1LowerPart
  • alternateTool1UpperPart
  • alternateTool2LowerPart
  • alternateTool2UpperPart
  • ...

Can be set to NULL if the IPMPTool has no alternate.

parametricInfoH Handle containing the parametric information of the IPMPTool. Can be set to NULL if the tool is not parametric.

MP4AddUrlToIPMPTool

ISOErr MP4AddUrlToIPMPTool( MP4Handle ipmpToolH, MP4Handle urlH )

Add a URL from which one or more tools specified in IPMPTool can be downloaded.

MP4NewIPMPToolListDescriptor

ISOErr MP4NewIPMPToolListDescriptor( MP4Handle ipmpToolListDescH );

Creates a new IPMPToolListDescriptor.

MP4AddIPMPToolToIPMPToolList

ISOErr MP4AddIPMPToolToIPMPToolList( 
            MP4Handle ipmpToolListDescH,
            MP4Handle ipmpToolH );

Adds and IPMPTool structure in an IPMP Tool List Descriptor with the following parameters:

ipmpToolListDescH Handle containing the IPMP Tool List Descriptor. Can be created with the MP4NewIPMPToolListDescriptor function

ipmpToolH Handle containing the IPMP Tool structure. Can be created with the MP4NewIPMPTool function.

MP4AddDescToMovieIOD (already present)

ISOErr MP4AddDescToMovieIOD( MP4Movie theMovie, MP4Handle descriptorH );

Adds a descriptor to the movie IOD. The descriptor can be an IPMP Tool List Descriptor.


15 ISMACrypt Support

ISMATransformSampleEntry

ISOErr ISMATransformSampleEntry( 
u32 newTrackFlags, 
MP4Handle insampleEntryH,
u8 selective_encryption, 
u8 key_indicator_length, 
u8 IV_length,
char* kms_URL,
MP4Handle outsampleEntryH );

ISMATransformSampleEntrySalt( 
u32 newTrackFlags, 
MP4Handle insampleEntryH,
u8 selective_encryption, 
u8 key_indicator_length, u8 IV_length,
char* kms_URL, 
u64 salt,
MP4Handle outsampleEntryH );

‘Transforms’ a sample entry into the format expected by ISMA for a sample entry for protected (encrypted) content. The flags are the same as for new tracks (audio or video track). The salt is an initial salt value which will be stored in the file if non-zero. The other parameters should be self-explanatory. (Note it is possible to build without ISMACrypt support using an ifdef).

ISMAUnTransformSampleEntry

ISOErr ISMAUnTransformSampleEntry( 
MP4Handle insampleEntryH,
u8* selective_encryption, 
u8* key_indicator_length, 
u8* IV_length,
char** kms_URL,
MP4Handle outsampleEntryH );

ISOErr ISMAUnTransformSampleEntrySalt( 
MP4Handle insampleEntryH,
u8* selective_encryption, 
u8* key_indicator_length, 
u8* IV_length,
char** kms_URL, 
u64* salt,
MP4Handle outsampleEntryH );

‘Untransforms’ a sample entry, from the encrypted form to the standard form, and returns the encryption parameter information previously supplied to the previous function, filling in salt if it was supplied in the file.


16 Utility functions

ISONewHandle

ISOErr ISONewHandle( u32 handleSize, ISOHandle *outHandle );

Creates a new handle, and allocates handleSize bytes for it. It is OK to call this with a size of zero. This is commonly done when the handle will be used as a parameter to a function that will size it appropriately.

ISOSetHandleSize

ISOErr ISOSetHandleSize( ISOHandle h, u32 handleSize );

Sets the logical size of the handle to handleSize bytes. If this is larger than the number of bytes allocated for this handle, the handle will be grown accordingly. If the new size is smaller than the allocated size the memory is not freed. The only way to free this memory is to dispose of the handle.

ISODisposeHandle

ISOErr ISODisposeHandle( ISOHandle h );

Frees the memory that was allocated for a handle.

ISOGetHandleSize

ISOErr ISOGetHandleSize( ISOHandle h, u32 *outHandleSize );

Use this to determine the present logical size (in bytes) of a handle.

MP4HandleCat

ISOErr MP4HandleCat (	MP4Handle theDstHandle, MP4Handle theSrcHandle);

Appends the data contained in theSrcHandle to data contained in theDstHandle by reallocating, if necessary, the number of bytes allocated for theDstHandle.

ISOSetHandleOffset

ISOErr MP4SetHandleOffset( MP4Handle theHandle, u32 offset );

Sets the handle so that subsequent de-references of it refer to the data starting at the given byte offset. This can be used to cause data to be read from or written to locations after the beginning, leaving room (for example) for an encryption header.

Clone this wiki locally