MP4DMXFindHeader

Syntax

#include <cafe/mp4dmx.h>

s32
MP4DMXFindHeader(
    void     *data,
    s32      size,
    u64      *next_offset,
    s32      *next_size,
    void     *handle
);

Parameters

data The address of the MP4 data that was read from an MP4 data file into application memory (the memory region for input MP4 data). Read FileTypeBox from the first 8 bytes of the MP4 data file, MovieBox, MovieFragmentBox, and MovieFragmentRandomAccessBox 8 bytes from the offset returned when parsing the header, and MovieFragmentRandomAccessOffsetBox 16 bytes from the end of the MP4 data file (Input).
NOTE:
For all of these, no more than 16 bytes needs to be read.
size The amount of MP4 data that was read from an MP4 data file into the memory region for input MP4 data (Input).
NOTE:
Specify either 8 or 16 bytes.
next_offset Input:
An offset from the beginning of the MP4 data file. (This indicates the position in the MP4 data file corresponding to the content of data).

Output:
The next offset from the beginning of the MP4 data file to pass to the library.
next_size The next data size to pass to the library (the MP4 data file size that should be read by the user application) (Output).
handle A pointer referencing an object handle (Input).

Return Values

MP4DMX_RET_FOUND_MOOV_BOX Success. A moov header (MovieBox) was found. The offset from the beginning of the MP4 data file to the moov header is set in next_offset and the size of the moov header is set in next_size. Read the specified amount of data from the specified offset in the MP4 file and then parse the header (call MP4DMXReadHeader).
MP4DMX_RET_FOUND_MOOF_BOX Success. A moof header (MovieFragmentBox) was found. The offset from the beginning of the MP4 data file to the moof header is set in next_offset and the size of the moof header is set in next_size. Read the specified amount of data from the specified offset in the MP4 file and then parse the header (call MP4DMXReadHeader).
MP4DMX_RET_FOUND_MFRA_BOX Success. A mfra header (MoveFragmentRandomAccessBox) was found. The offset from the beginning of the MP4 data file to the mfra header is set in next_offset and the size of the mfra header is set in next_size. Read the specified amount of data from the specified offset in the MP4 file and then parse the header (call MP4DMXReadHeader).
MP4DMX_RET_FOUND_MFRO_BOX Success. A MovieFragmentRandomAccessOffsetBox (mfroBox) was found in the mfro header. The offset from the beginning of the MP4 data file to the mfroBox is set in next_offset and the size of the mfroBox is set in next_size. Read the specified amount of data from the specified offset in the MP4 file and then parse the header (call MP4DMXReadHeader).
MP4DMX_RET_FOUND_FTYP_BOX Success. A ftyp header (FileTypeBox) was found. The offset from the beginning of the MP4 data file to the ftyp header is set in next_offset and the size of the ftyp header is set in next_size. Read the specified amount of data from the specified offset in the MP4 file and then parse the header (call MP4DMXReadHeader).
MP4DMX_RET_NOT_FOUND_BOX An ftype, moov, moof, or mfra header or a mfroBox could not be found. The offset and size from the beginning of the MP4 data file, used to find the next header, are set as the next_offset and next_size parameters. Read the specified amount of data from the MP4 file at the specified offset and then call this function again.
MP4DMX_RET_ERROR_NOT_ENOUGH_MEMORY Failure. This error value is returned when the necessary memory could not be allocated.
MP4DMX_RET_ERROR_INVALID_POINTER Failure. This error is returned when an argument is NULL.
MP4DMX_RET_ERROR_FATAL Failure. This error is returned when functions are not called in the correct order.

Description

Gets the position and size of a MovieBox and MovieFragmentBox in an MP4 data file.

By setting 8 bytes of data from the MP4 data file and then calling this function, user applications can get the position and size of the header information below the root directory in the file. After getting the header information's offset and size using this function, pass it to the header-parsing function MP4DMXReadHeader.

Consider the following with regard to the values returned in the next_size parameter.

In both cases, the value obtained from the MP4 data file is output as is. The library cannot know the size of the MP4 data memory reserved by the user application, so if parsing the header MP4DMXFindHeader returns a size that exceeds the range of MP4 data memory, reading the MP4 data file or calling this function with this value can result in an access violation and trigger an exception. If it is necessary to partition the Box for reading and limit the buffer size for input parameters, and there is a possibility that the MP4 data memory size exceeds the header data size, the user application must control access to avoid an access violation.

Do Not Call From

Background Do not call this function from the background.
Multiple threads This function is not thread-safe.

See Also

MP4DMXOpen
MP4DMXBegin
MP4DMXReadHeader
MP4DMXExecute
MP4DMXEnd
MP4DMXClose

Revision History

2014/07/29 Initial version.


CONFIDENTIAL