First import.

This commit is contained in:
Damiano Galassi committed 2013-11-01 10:20:09 +01:00
1 parent 4e61250dc6
commit 796e9691ce
114 files changed
+37004 -44

No files matched your search

BIN
View File
Binary file not shown.
+83
View File
@@ -0,0 +1,83 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is MPEG4IP.
*
* The Initial Developer of the Original Code is Cisco Systems Inc.
* Portions created by Cisco Systems Inc. are
* Copyright (C) Cisco Systems Inc. 2001 - 2005. All Rights Reserved.
*
* 3GPP features implementation is based on 3GPP's TS26.234-v5.60,
* and was contributed by Ximpo Group Ltd.
*
* Portions created by Ximpo Group Ltd. are
* Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved.
*
* Contributor(s):
* Dave Mackie dmackie@cisco.com
* Alix Marchandise-Franquet alix@cisco.com
* Ximpo Group Ltd. mp4v2@ximpo.com
* Bill May wmay@cisco.com
*/
#ifndef MP4V2_MP4V2_H
#define MP4V2_MP4V2_H
/*****************************************************************************/
#include <mp4v2/platform.h>
#include <mp4v2/project.h>
/*****************************************************************************/
/* exploit C++ ability of default values for function parameters */
#if defined( DEFAULT )
# define __MP4V2_SAVE_DEFAULT DEFAULT
#endif
#undef DEFAULT
#if defined( __cplusplus )
# define DEFAULT(x) =x
#else
# define DEFAULT(x)
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
#include <mp4v2/general.h>
#include <mp4v2/file.h>
#include <mp4v2/file_prop.h>
#include <mp4v2/track.h>
#include <mp4v2/track_prop.h>
#include <mp4v2/sample.h>
#include <mp4v2/chapter.h>
#include <mp4v2/itmf_generic.h>
#include <mp4v2/itmf_tags.h>
#include <mp4v2/streaming.h>
#include <mp4v2/isma.h>
/*****************************************************************************/
/* restore macro DEFAULT to state prior to mp4v2 headers */
#undef DEFAULT
#if defined( __MP4V2_SAVE_DEFAULT )
# define DEFAULT __MP4V2_SAVE_DEFAULT
#endif
#ifdef __cplusplus
} // extern "C"
#endif
/*****************************************************************************/
#endif /* MP4V2_MP4V2_H */
+177
View File
@@ -0,0 +1,177 @@
#ifndef MP4V2_CHAPTER_H
#define MP4V2_CHAPTER_H
/**************************************************************************//**
*
* @defgroup mp4_chapter MP4v2 Chapter
* @{
*
*****************************************************************************/
/** The maximum length of a QuickTime chapter title (in 8-bit chars)
*/
#define MP4V2_CHAPTER_TITLE_MAX 1023
/** Chapter item.
* This item defines various attributes for a chapter.
* @ingroup mp4_chapter
*/
typedef struct MP4Chapter_s {
MP4Duration duration; /**< duration of chapter in milliseconds */
char title[MP4V2_CHAPTER_TITLE_MAX+1]; /**< title of chapter */
uint32_t titleLength;
} MP4Chapter_t;
/** Known chapter types.
* @ingroup mp4_chapter
*/
typedef enum {
MP4ChapterTypeNone = 0, /**< no chapters found return value */
MP4ChapterTypeAny = 1, /**< any or all known chapter types */
MP4ChapterTypeQt = 2, /**< QuickTime chapter type */
MP4ChapterTypeNero = 4 /**< Nero chapter type */
} MP4ChapterType;
/** Add a QuickTime chapter.
*
* This function adds a QuickTime chapter to file <b>hFile</b>.
*
* @param hFile handle of file to add chapter.
* @param chapterTrackId ID of chapter track or #MP4_INVALID_TRACK_ID
* if unknown.
* @param chapterDuration duration (in the timescale of the chapter track).
* @param chapterTitle title text for the chapter or NULL to use default
* title format ("Chapter %03d", n) where n is the chapter number.
*/
MP4V2_EXPORT
void MP4AddChapter(
MP4FileHandle hFile,
MP4TrackId chapterTrackId,
MP4Duration chapterDuration,
const char* chapterTitle DEFAULT(0));
/** Add a QuickTime chapter track.
*
* This function adds a chapter (text) track to file <b>hFile</b>.
* The optional parameter <b>timescale</b> may be supplied to give the new
* chapter a specific timescale. Otherwise the chapter track will have
* the same timescale as the reference track defined in parameter refTrackId.
*
* @param hFile handle of file to add chapter track.
* @param refTrackId ID of the track that will reference the chapter track.
* @param timescale the timescale of the chapter track or 0 to use the
* timescale of track specified by <b>refTrackId</b>.
*
* @return ID of the created chapter track.
*/
MP4V2_EXPORT
MP4TrackId MP4AddChapterTextTrack(
MP4FileHandle hFile,
MP4TrackId refTrackId,
uint32_t timescale DEFAULT(0) );
/** Add a Nero chapter.
*
* This function adds a Nero chapter to file <b>hFile</b>.
*
* @param hFile handle of file to add chapter.
* @param chapterStart the start time of the chapter in 100 nanosecond units
* @param chapterTitle title text for the chapter or NULL to use default
* title format ("Chapter %03d", n) where n is the chapter number.
*/
MP4V2_EXPORT
void MP4AddNeroChapter(
MP4FileHandle hFile,
MP4Timestamp chapterStart,
const char* chapterTitle DEFAULT(0));
/** Convert chapters to another type.
*
* This function converts existing chapters in file <b>hFile</b>
* from one type to another type.
* Conversion from Nero to QuickTime or QuickTime to Nero is supported.
*
* @param hFile handle of file to convert.
* @param toChapterType the chapter type to convert to:
* @li #MP4ChapterTypeQt (convert from Nero to Qt)
* @li #MP4ChapterTypeNero (convert from Qt to Nero)
*
* @return the chapter type before conversion or #MP4ChapterTypeNone
* if the source chapters do not exist
* or invalid <b>toChapterType</b> was specified.
*/
MP4V2_EXPORT
MP4ChapterType MP4ConvertChapters(
MP4FileHandle hFile,
MP4ChapterType toChapterType DEFAULT(MP4ChapterTypeQt));
/** Delete chapters.
*
* This function deletes existing chapters in file <b>hFile</b>.
*
* @param hFile handle of file to delete chapters.
* @param chapterType the type of chapters to delete:
* @li #MP4ChapterTypeAny (delete all known chapter types)
* @li #MP4ChapterTypeQt
* @li #MP4ChapterTypeNero
* @param chapterTrackId ID of the chapter track if known,
* or #MP4_INVALID_TRACK_ID.
* Only applies when <b>chapterType</b>=#MP4ChapterTypeQt.
*
* @return the type of deleted chapters
*/
MP4V2_EXPORT
MP4ChapterType MP4DeleteChapters(
MP4FileHandle hFile,
MP4ChapterType chapterType DEFAULT(MP4ChapterTypeQt),
MP4TrackId chapterTrackId DEFAULT(MP4_INVALID_TRACK_ID) );
/** Get list of chapters.
*
* This function gets a chpter list from file <b>hFile</b>.
*
* @param hFile handle of file to read.
* @param chapterList address receiving array of chapter items.
* If a non-NULL is received the caller is responsible for freeing the
* memory with MP4Free().
* @param chapterCount address receiving count of items in array.
* @param chapterType the type of chapters to read:
* @li #MP4ChapterTypeAny (any chapters, searched in order of Qt, Nero)
* @li #MP4ChapterTypeQt
* @li #MP4ChapterTypeNero
*
* @result the first type of chapters found.
*/
MP4V2_EXPORT
MP4ChapterType MP4GetChapters(
MP4FileHandle hFile,
MP4Chapter_t** chapterList,
uint32_t* chapterCount,
MP4ChapterType chapterType DEFAULT(MP4ChapterTypeQt));
/** Set list of chapters OKOK.
*
* This functions sets the complete chapter list in file <b>hFile</b>.
* If any chapters of the same type already exist they will first
* be deleted.
*
* @param hFile handle of file to modify.
* @param chapterList array of chapters items.
* @param chapterCount count of items in array.
* @param chapterType type of chapters to write:
* @li #MP4ChapterTypeAny (chapters of all types are written)
* @li #MP4ChapterTypeQt
* @li #MP4ChapterTypeNero
*
* @return the type of chapters written.
*/
MP4V2_EXPORT
MP4ChapterType MP4SetChapters(
MP4FileHandle hFile,
MP4Chapter_t* chapterList,
uint32_t chapterCount,
MP4ChapterType chapterType DEFAULT(MP4ChapterTypeQt));
/** @} ***********************************************************************/
#endif /* MP4V2_CHAPTER_H */
+362
View File
@@ -0,0 +1,362 @@
#ifndef MP4V2_FILE_H
#define MP4V2_FILE_H
/**************************************************************************//**
*
* @defgroup mp4_file MP4v2 File I/O
* @{
*
*****************************************************************************/
/** Bit: enable 64-bit data-atoms. */
#define MP4_CREATE_64BIT_DATA 0x01
/** Bit: enable 64-bit time-atoms. @note Incompatible with QuickTime. */
#define MP4_CREATE_64BIT_TIME 0x02
/** Bit: do not recompute avg/max bitrates on file close. @note See http://code.google.com/p/mp4v2/issues/detail?id=66 */
#define MP4_CLOSE_DO_NOT_COMPUTE_BITRATE 0x01
/** Enumeration of file modes for custom file provider. */
typedef enum MP4FileMode_e
{
FILEMODE_UNDEFINED, /**< undefined */
FILEMODE_READ, /**< file may be read */
FILEMODE_MODIFY, /**< file may be read/written */
FILEMODE_CREATE /**< file will be created/truncated for read/write */
} MP4FileMode;
/** Structure of functions implementing custom file provider.
*
* Except for <b>open</b>, all the functions must return a true value
* to indicate failure or false on success. The open function must return
* a pointer or handle which represents the open file, otherwise NULL.
*
* maxChunkSize is a hint suggesting what the max size of data should be read
* as in underlying read/write operations. A value of 0 indicates there is no hint.
*/
typedef struct MP4FileProvider_s
{
void* ( *open )( const char* name, MP4FileMode mode );
int ( *seek )( void* handle, int64_t pos );
int ( *read )( void* handle, void* buffer, int64_t size, int64_t* nin, int64_t maxChunkSize );
int ( *write )( void* handle, const void* buffer, int64_t size, int64_t* nout, int64_t maxChunkSize );
int ( *close )( void* handle );
} MP4FileProvider;
/** Close an mp4 file.
* MP4Close closes a previously opened mp4 file. If the file was opened
* writable with MP4Create() or MP4Modify(), then MP4Close() will write
* out all pending information to disk.
*
* @param hFile handle of file to close.
* @param flags bitmask that allows the user to set extra options for the
* close commands. Valid options include:
* @li #MP4_CLOSE_DO_NOT_COMPUTE_BITRATE
*/
MP4V2_EXPORT
bool MP4Close(
MP4FileHandle hFile,
uint32_t flags DEFAULT(0) );
/** Create a new mp4 file.
*
* MP4Create is the first call that should be used when you want to create
* a new, empty mp4 file. It is equivalent to opening a file for writing,
* but also involved with creation of necessary mp4 framework structures.
* ie. invoking MP4Create() followed by MP4Close() will result in a file
* with a non-zero size.
*
* @param fileName pathname of the file to be created.
* On Windows, this should be a UTF-8 encoded string.
* On other platforms, it should be an 8-bit encoding that is
* appropriate for the platform, locale, file system, etc.
* (prefer to use UTF-8 when possible).
* @param flags bitmask that allows the user to set 64-bit values for
* data or time atoms. Valid bits may be any combination of:
* @li #MP4_CREATE_64BIT_DATA
* @li #MP4_CREATE_64BIT_TIME
*
* @return On success a handle of the newly created file for use in
* subsequent calls to the library.
* On error, #MP4_INVALID_FILE_HANDLE.
*/
MP4V2_EXPORT
MP4FileHandle MP4Create(
const char* fileName,
uint32_t flags DEFAULT(0) );
/** Create a new mp4 file with extended options.
*
* MP4CreateEx is an extended version of MP4Create().
*
* @param fileName pathname of the file to be created.
* On Windows, this should be a UTF-8 encoded string.
* On other platforms, it should be an 8-bit encoding that is
* appropriate for the platform, locale, file system, etc.
* (prefer to use UTF-8 when possible).
* @param flags bitmask that allows the user to set 64-bit values for
* data or time atoms. Valid bits may be any combination of:
* @li #MP4_CREATE_64BIT_DATA
* @li #MP4_CREATE_64BIT_TIME
* @param add_ftyp if true an <b>ftyp</b> atom is automatically created.
* @param add_iods if true an <b>iods</b> atom is automatically created.
* @param majorBrand <b>ftyp</b> brand identifier.
* @param minorVersion <b>ftyp</b> informative integer for the minor version
* of the major brand.
* @param compatibleBrands <b>ftyp</b> list of compatible brands.
* @param compatibleBrandsCount is the count of items specified in
* compatibleBrands.
*
* @return On success a handle of the newly created file for use in
* subsequent calls to the library.
* On error, #MP4_INVALID_FILE_HANDLE.
*/
MP4V2_EXPORT
MP4FileHandle MP4CreateEx(
const char* fileName,
uint32_t flags DEFAULT(0),
int add_ftyp DEFAULT(1),
int add_iods DEFAULT(1),
char* majorBrand DEFAULT(0),
uint32_t minorVersion DEFAULT(0),
char** compatibleBrands DEFAULT(0),
uint32_t compatibleBrandsCount DEFAULT(0) );
/** Dump mp4 file contents as ASCII either to stdout or the
* log callback (@p see MP4SetLogCallback)
*
* Dump is an invaluable debugging tool in that in can reveal all the details
* of the mp4 control structures. However, the output will not make much sense
* until you familiarize yourself with the mp4 specification (or the Quicktime
* File Format specification).
*
* Note that MP4Dump() will not print the individual values of control tables,
* such as the size of each sample, unless the current log level is at least
* #MP4_LOG_VERBOSE2. @p see MP4LogSetLevel() for how to set this.
*
* @param hFile handle of file to dump.
* @param dumpImplicits prints properties which would not actually be
* written to the mp4 file, but still exist in mp4 control structures.
* ie. they are implicit given the current values of other controlling
* properties.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4Dump(
MP4FileHandle hFile,
bool dumpImplicits DEFAULT(0) );
/** Return a textual summary of an mp4 file.
*
* MP4FileInfo provides a string that contains a textual summary of the
* contents of an mp4 file. This includes the track id's, the track type,
* and track specific information. For example, for a video track, media
* encoding, image size, frame rate, and bitrate are summarized.
*
* Note that the returned string is malloc'ed, so it is the caller's
* responsibility to free() the string. Also note that the returned string
* contains newlines and tabs which may or may not be desirable.
*
* The following is an example of the output of MP4Info():
@verbatim
Track Type Info
1 video MPEG-4 Simple @ L3, 119.625 secs, 1008 kbps, 352x288 @ 24.00 fps
2 audio MPEG-4, 119.327 secs, 128 kbps, 44100 Hz
3 hint Payload MP4V-ES for track 1
4 hint Payload mpeg4-generic for track 2
5 od Object Descriptors
6 scene BIFS
@endverbatim
*
* @param fileName pathname to mp4 file to summarize.
* On Windows, this should be a UTF-8 encoded string.
* On other platforms, it should be an 8-bit encoding that is
* appropriate for the platform, locale, file system, etc.
* (prefer to use UTF-8 when possible).
* @param trackId specifies track to summarize. If the value is
* #MP4_INVALID_TRACK_ID, the summary info is created for all
* tracks in the file.
*
* @return On success a malloc'd string containing summary information.
* On failure, <b>NULL</b>.
*
* @see MP4Info().
*/
MP4V2_EXPORT
char* MP4FileInfo(
const char* fileName,
MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID) );
/** Accessor for the filename associated with a file handle
*
* @param hFile a file handle
*
* @return the NUL-terminated, UTF-8 encoded filename
* associated with @p hFile
*/
MP4V2_EXPORT
const char* MP4GetFilename(
MP4FileHandle hFile );
/** Return a textual summary of an mp4 file.
*
* MP4FileInfo provides a string that contains a textual summary of the
* contents of an mp4 file. This includes the track id's, the track type,
* and track specific information. For example, for a video track, media
* encoding, image size, frame rate, and bitrate are summarized.
*
* Note that the returned string is malloc'ed, so it is the caller's
* responsibility to free() the string. Also note that the returned string
* contains newlines and tabs which may or may not be desirable.
*
* The following is an example of the output of MP4Info():
@verbatim
Track Type Info
1 video MPEG-4 Simple @ L3, 119.625 secs, 1008 kbps, 352x288 @ 24.00 fps
2 audio MPEG-4, 119.327 secs, 128 kbps, 44100 Hz
3 hint Payload MP4V-ES for track 1
4 hint Payload mpeg4-generic for track 2
5 od Object Descriptors
6 scene BIFS
@endverbatim
*
* @param hFile handle of file to summarize.
* @param trackId specifies track to summarize. If the value is
* #MP4_INVALID_TRACK_ID, the summary info is created for all
* tracks in the file.
*
* @return On success a malloc'd string containing summary information.
* On failure, <b>NULL</b>.
*
* @see MP4FileInfo().
*/
MP4V2_EXPORT
char* MP4Info(
MP4FileHandle hFile,
MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID) );
/** Modify an existing mp4 file.
*
* MP4Modify is the first call that should be used when you want to modify
* an existing mp4 file. It is roughly equivalent to opening a file in
* read/write mode.
*
* Since modifications to an existing mp4 file can result in a sub-optimal
* file layout, you may want to use MP4Optimize() after you have modified
* and closed the mp4 file.
*
* @param fileName pathname of the file to be modified.
* On Windows, this should be a UTF-8 encoded string.
* On other platforms, it should be an 8-bit encoding that is
* appropriate for the platform, locale, file system, etc.
* (prefer to use UTF-8 when possible).
* @param flags currently ignored.
*
* @return On success a handle of the target file for use in subsequent calls
* to the library.
* On error, #MP4_INVALID_FILE_HANDLE.
*/
MP4V2_EXPORT
MP4FileHandle MP4Modify(
const char* fileName,
uint32_t flags DEFAULT(0) );
/** Optimize the layout of an mp4 file.
*
* MP4Optimize reads an existing mp4 file and writes a new version of the
* file with the two important changes:
*
* First, the mp4 control information is moved to the beginning of the file.
* (Frequenty it is at the end of the file due to it being constantly
* modified as track samples are added to an mp4 file). This optimization
* is useful in that in allows the mp4 file to be HTTP streamed.
*
* Second, the track samples are interleaved so that the samples for a
* particular instant in time are colocated within the file. This
* eliminates disk seeks during playback of the file which results in
* better performance.
*
* There are also two important side effects of MP4Optimize():
*
* First, any free blocks within the mp4 file are eliminated.
*
* Second, as a side effect of the sample interleaving process any media
* data chunks that are not actually referenced by the mp4 control
* structures are deleted. This is useful if you have called MP4DeleteTrack()
* which only deletes the control information for a track, and not the
* actual media data.
*
* @param fileName pathname of (existing) file to be optimized.
* On Windows, this should be a UTF-8 encoded string.
* On other platforms, it should be an 8-bit encoding that is
* appropriate for the platform, locale, file system, etc.
* (prefer to use UTF-8 when possible).
* @param newFileName pathname of the new optimized file.
* On Windows, this should be a UTF-8 encoded string.
* On other platforms, it should be an 8-bit encoding that is
* appropriate for the platform, locale, file system, etc.
* (prefer to use UTF-8 when possible).
* If NULL a temporary file in the same directory as the
* <b>fileName</b> will be used and <b>fileName</b>
* will be over-written upon successful completion.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4Optimize(
const char* fileName,
const char* newFileName DEFAULT(NULL) );
/** Read an existing mp4 file.
*
* MP4Read is the first call that should be used when you want to just
* read an existing mp4 file. It is equivalent to opening a file for
* reading, but in addition the mp4 file is parsed and the control
* information is loaded into memory. Note that actual track samples are not
* read into memory until MP4ReadSample() is called.
*
* @param fileName pathname of the file to be read.
* On Windows, this should be a UTF-8 encoded string.
* On other platforms, it should be an 8-bit encoding that is
* appropriate for the platform, locale, file system, etc.
* (prefer to use UTF-8 when possible).
(
* @return On success a handle of the file for use in subsequent calls to
* the library.
* On error, #MP4_INVALID_FILE_HANDLE.
*/
MP4V2_EXPORT
MP4FileHandle MP4Read(
const char* fileName );
/** Read an existing mp4 file.
*
* MP4ReadProvider is the first call that should be used when you want to just
* read an existing mp4 file. It is equivalent to opening a file for
* reading, but in addition the mp4 file is parsed and the control
* information is loaded into memory. Note that actual track samples are not
* read into memory until MP4ReadSample() is called.
*
* @param fileName pathname of the file to be read.
* On Windows, this should be a UTF-8 encoded string.
* On other platforms, it should be an 8-bit encoding that is
* appropriate for the platform, locale, file system, etc.
* (prefer to use UTF-8 when possible).
* @param fileProvider custom implementation of file I/O operations.
* All functions in structure must be implemented.
* The structure is immediately copied internally.
*
* @return On success a handle of the file for use in subsequent calls to
* the library.
* On error, #MP4_INVALID_FILE_HANDLE.
*/
MP4V2_EXPORT
MP4FileHandle MP4ReadProvider(
const char* fileName,
const MP4FileProvider* fileProvider DEFAULT(NULL) );
/** @} ***********************************************************************/
#endif /* MP4V2_FILE_H */
+148
View File
@@ -0,0 +1,148 @@
#ifndef MP4V2_FILE_PROP_H
#define MP4V2_FILE_PROP_H
/**************************************************************************//**
*
* @defgroup mp4_file_prop MP4v2 File Property
* @{
*
*****************************************************************************/
/* generic props */
MP4V2_EXPORT
bool MP4HaveAtom(
MP4FileHandle hFile,
const char* atomName );
MP4V2_EXPORT
bool MP4GetIntegerProperty(
MP4FileHandle hFile,
const char* propName,
uint64_t* retval );
MP4V2_EXPORT
bool MP4GetFloatProperty(
MP4FileHandle hFile,
const char* propName,
float* retvalue );
MP4V2_EXPORT
bool MP4GetStringProperty(
MP4FileHandle hFile,
const char* propName,
const char** retvalue );
MP4V2_EXPORT
bool MP4GetBytesProperty(
MP4FileHandle hFile,
const char* propName,
uint8_t** ppValue,
uint32_t* pValueSize );
MP4V2_EXPORT
bool MP4SetIntegerProperty(
MP4FileHandle hFile,
const char* propName,
int64_t value );
MP4V2_EXPORT
bool MP4SetFloatProperty(
MP4FileHandle hFile,
const char* propName,
float value );
MP4V2_EXPORT
bool MP4SetStringProperty(
MP4FileHandle hFile,
const char* propName,
const char* value );
MP4V2_EXPORT
bool MP4SetBytesProperty(
MP4FileHandle hFile,
const char* propName,
const uint8_t* pValue,
uint32_t valueSize );
/* specific props */
MP4V2_EXPORT
MP4Duration MP4GetDuration( MP4FileHandle hFile );
/** Get the time scale of the movie (file).
*
* MP4GetTimeScale returns the time scale in units of ticks per second for
* the mp4 file. Caveat: tracks may use the same time scale as the movie
* or may use their own time scale.
*
* @param hFile handle of file for operation.
*
* @return timescale (ticks per second) of the mp4 file.
*/
MP4V2_EXPORT
uint32_t MP4GetTimeScale( MP4FileHandle hFile );
/** Set the time scale of the movie (file).
*
* MP4SetTimeScale sets the time scale of the mp4 file. The time scale is
* in the number of clock ticks per second. Caveat: tracks may use the
* same time scale as the movie or may use their own time scale.
*
* @param hFile handle of file for operation.
* @param value desired timescale for the movie.
*
* @return On success, true. On failure, false.
*/
MP4V2_EXPORT
bool MP4SetTimeScale( MP4FileHandle hFile, uint32_t value );
/** Change the general timescale of file hFile.
*
* This function changes the general timescale of the file <b>hFile</b>
* to the new timescale <b>value</b> by recalculating all values that depend
* on the timescale in "moov.mvhd".
*
* If the timescale is already equal to value nothing is done.
*
* @param hFile handle of file to change.
* @param value the new timescale.
*/
MP4V2_EXPORT
void MP4ChangeMovieTimeScale( MP4FileHandle hFile, uint32_t value );
MP4V2_EXPORT
uint8_t MP4GetODProfileLevel( MP4FileHandle hFile );
MP4V2_EXPORT
bool MP4SetODProfileLevel( MP4FileHandle hFile, uint8_t value );
MP4V2_EXPORT
uint8_t MP4GetSceneProfileLevel( MP4FileHandle hFile );
MP4V2_EXPORT
bool MP4SetSceneProfileLevel( MP4FileHandle hFile, uint8_t value );
MP4V2_EXPORT
uint8_t MP4GetVideoProfileLevel(
MP4FileHandle hFile,
MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID) );
MP4V2_EXPORT
void MP4SetVideoProfileLevel( MP4FileHandle hFile, uint8_t value );
MP4V2_EXPORT
uint8_t MP4GetAudioProfileLevel( MP4FileHandle hFile );
MP4V2_EXPORT
void MP4SetAudioProfileLevel( MP4FileHandle hFile, uint8_t value );
MP4V2_EXPORT
uint8_t MP4GetGraphicsProfileLevel( MP4FileHandle hFile );
MP4V2_EXPORT
bool MP4SetGraphicsProfileLevel( MP4FileHandle hFile, uint8_t value );
/** @} ***********************************************************************/
#endif /* MP4V2_FILE_PROP_H */
+496
View File
@@ -0,0 +1,496 @@
#ifndef MP4V2_GENERAL_H
#define MP4V2_GENERAL_H
/**************************************************************************//**
*
* @defgroup mp4_general MP4v2 General
* @{
*
*****************************************************************************/
/* MP4 API types */
typedef void* MP4FileHandle;
typedef uint32_t MP4TrackId;
typedef uint32_t MP4SampleId;
typedef uint64_t MP4Timestamp;
typedef uint64_t MP4Duration;
typedef uint32_t MP4EditId;
typedef enum {
MP4_LOG_NONE = 0,
MP4_LOG_ERROR = 1,
MP4_LOG_WARNING = 2,
MP4_LOG_INFO = 3,
MP4_LOG_VERBOSE1 = 4,
MP4_LOG_VERBOSE2 = 5,
MP4_LOG_VERBOSE3 = 6,
MP4_LOG_VERBOSE4 = 7
} MP4LogLevel;
/*****************************************************************************/
typedef void (*MP4LogCallback)(
MP4LogLevel loglevel,
const char* fmt,
va_list ap );
/*****************************************************************************/
/** Encryption function pointer.
*
* @see MP4EncAndCopySample().
* @see MP4EncAndCopyTrack().
*/
typedef uint32_t (*encryptFunc_t)( uint32_t, uint32_t, uint8_t*, uint32_t*, uint8_t** );
/*****************************************************************************/
#define MP4_INVALID_FILE_HANDLE ((MP4FileHandle)NULL) /**< Constant: invalid MP4FileHandle. */
#define MP4_INVALID_TRACK_ID ((MP4TrackId)0) /**< Constant: invalid MP4TrackId. */
#define MP4_INVALID_SAMPLE_ID ((MP4SampleId)0) /**< Constant: invalid MP4SampleId. */
#define MP4_INVALID_TIMESTAMP ((MP4Timestamp)-1) /**< Constant: invalid MP4Timestamp. */
#define MP4_INVALID_DURATION ((MP4Duration)-1) /**< Constant: invalid MP4Duration. */
#define MP4_INVALID_EDIT_ID ((MP4EditId)0) /**< Constant: invalid MP4EditId. */
/* Macros to test for API type validity */
#define MP4_IS_VALID_FILE_HANDLE(x) ((x) != MP4_INVALID_FILE_HANDLE)
#define MP4_IS_VALID_TRACK_ID(x) ((x) != MP4_INVALID_TRACK_ID)
#define MP4_IS_VALID_SAMPLE_ID(x) ((x) != MP4_INVALID_SAMPLE_ID)
#define MP4_IS_VALID_TIMESTAMP(x) ((x) != MP4_INVALID_TIMESTAMP)
#define MP4_IS_VALID_DURATION(x) ((x) != MP4_INVALID_DURATION)
#define MP4_IS_VALID_EDIT_ID(x) ((x) != MP4_INVALID_EDIT_ID)
/*
* MP4 Known track type names - e.g. MP4GetNumberOfTracks(type)
*
* Note this first group of track types should be created
* via the MP4Add<Type>Track() functions, and not MP4AddTrack(type)
*/
#define MP4_OD_TRACK_TYPE "odsm" /**< Constant: OD track. */
#define MP4_SCENE_TRACK_TYPE "sdsm" /**< Constant: scene track. */
#define MP4_AUDIO_TRACK_TYPE "soun" /**< Constant: audio track. */
#define MP4_VIDEO_TRACK_TYPE "vide" /**< Constant: video track. */
#define MP4_HINT_TRACK_TYPE "hint" /**< Constant: hint track. */
#define MP4_CNTL_TRACK_TYPE "cntl" /**< Constant: control track. */
#define MP4_TEXT_TRACK_TYPE "text" /**< Constant: text track. */
#define MP4_SUBTITLE_TRACK_TYPE "sbtl" /**< Constant: subtitle track. */
#define MP4_CC_TRACK_TYPE "clcp" /**< Constant: closed captions track. */
#define MP4_SUBPIC_TRACK_TYPE "subp" /**< Constant: subpic track. */
/*
* This second set of track types should be created
* via MP4AddSystemsTrack(type)
*/
#define MP4_CLOCK_TRACK_TYPE "crsm" /**< Constant: clock track. */
#define MP4_MPEG7_TRACK_TYPE "m7sm" /**< Constant: mpeg7 track. */
#define MP4_OCI_TRACK_TYPE "ocsm" /**< Constant: OCI track. */
#define MP4_IPMP_TRACK_TYPE "ipsm" /**< Constant: IPMP track. */
#define MP4_MPEGJ_TRACK_TYPE "mjsm" /**< Constant: MPEGJ track. */
#define MP4_IS_VIDEO_TRACK_TYPE(type) \
(!strcasecmp(type, MP4_VIDEO_TRACK_TYPE))
#define MP4_IS_AUDIO_TRACK_TYPE(type) \
(!strcasecmp(type, MP4_AUDIO_TRACK_TYPE))
#define MP4_IS_CNTL_TRACK_TYPE(type) \
(!strcasecmp(type, MP4_CNTL_TRACK_TYPE))
#define MP4_IS_OD_TRACK_TYPE(type) \
(!strcasecmp(type, MP4_OD_TRACK_TYPE))
#define MP4_IS_SCENE_TRACK_TYPE(type) \
(!strcasecmp(type, MP4_SCENE_TRACK_TYPE))
#define MP4_IS_HINT_TRACK_TYPE(type) \
(!strcasecmp(type, MP4_HINT_TRACK_TYPE))
#define MP4_IS_SYSTEMS_TRACK_TYPE(type) \
(!strcasecmp(type, MP4_CLOCK_TRACK_TYPE) \
|| !strcasecmp(type, MP4_MPEG7_TRACK_TYPE) \
|| !strcasecmp(type, MP4_OCI_TRACK_TYPE) \
|| !strcasecmp(type, MP4_IPMP_TRACK_TYPE) \
|| !strcasecmp(type, MP4_MPEGJ_TRACK_TYPE))
/* MP4 Audio track types - see MP4AddAudioTrack()*/
#define MP4_INVALID_AUDIO_TYPE 0x00
#define MP4_MPEG1_AUDIO_TYPE 0x6B
#define MP4_MPEG2_AUDIO_TYPE 0x69
#define MP4_MP3_AUDIO_TYPE MP4_MPEG2_AUDIO_TYPE
#define MP4_MPEG2_AAC_MAIN_AUDIO_TYPE 0x66
#define MP4_MPEG2_AAC_LC_AUDIO_TYPE 0x67
#define MP4_MPEG2_AAC_SSR_AUDIO_TYPE 0x68
#define MP4_MPEG2_AAC_AUDIO_TYPE MP4_MPEG2_AAC_MAIN_AUDIO_TYPE
#define MP4_MPEG4_AUDIO_TYPE 0x40
#define MP4_PRIVATE_AUDIO_TYPE 0xC0
#define MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE 0xE0 /* a private definition */
#define MP4_VORBIS_AUDIO_TYPE 0xE1 /* a private definition */
#define MP4_AC3_AUDIO_TYPE 0xE2 /* a private definition */
#define MP4_ALAW_AUDIO_TYPE 0xE3 /* a private definition */
#define MP4_ULAW_AUDIO_TYPE 0xE4 /* a private definition */
#define MP4_G723_AUDIO_TYPE 0xE5 /* a private definition */
#define MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE 0xE6 /* a private definition */
/* MP4 MPEG-4 Audio types from 14496-3 Table 1.5.1 */
#define MP4_MPEG4_INVALID_AUDIO_TYPE 0
#define MP4_MPEG4_AAC_MAIN_AUDIO_TYPE 1
#define MP4_MPEG4_AAC_LC_AUDIO_TYPE 2
#define MP4_MPEG4_AAC_SSR_AUDIO_TYPE 3
#define MP4_MPEG4_AAC_LTP_AUDIO_TYPE 4
#define MP4_MPEG4_AAC_HE_AUDIO_TYPE 5
#define MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE 6
#define MP4_MPEG4_CELP_AUDIO_TYPE 8
#define MP4_MPEG4_HVXC_AUDIO_TYPE 9
#define MP4_MPEG4_TTSI_AUDIO_TYPE 12
#define MP4_MPEG4_MAIN_SYNTHETIC_AUDIO_TYPE 13
#define MP4_MPEG4_WAVETABLE_AUDIO_TYPE 14
#define MP4_MPEG4_MIDI_AUDIO_TYPE 15
#define MP4_MPEG4_ALGORITHMIC_FX_AUDIO_TYPE 16
#define MP4_MPEG4_ALS_AUDIO_TYPE 31
#define MP4_MPEG4_LAYER1_AUDIO_TYPE 32
#define MP4_MPEG4_LAYER2_AUDIO_TYPE 33
#define MP4_MPEG4_LAYER3_AUDIO_TYPE 34
#define MP4_MPEG4_SLS_AUDIO_TYPE 35
/* MP4 Audio type utilities following common usage */
#define MP4_IS_MP3_AUDIO_TYPE(type) \
((type) == MP4_MPEG1_AUDIO_TYPE || (type) == MP4_MPEG2_AUDIO_TYPE)
#define MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
(((type) >= MP4_MPEG2_AAC_MAIN_AUDIO_TYPE \
&& (type) <= MP4_MPEG2_AAC_SSR_AUDIO_TYPE))
#define MP4_IS_MPEG4_AAC_AUDIO_TYPE(mpeg4Type) \
(((mpeg4Type) >= MP4_MPEG4_AAC_MAIN_AUDIO_TYPE \
&& (mpeg4Type) <= MP4_MPEG4_AAC_HE_AUDIO_TYPE) \
|| (mpeg4Type) == MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE \
|| (mpeg4Type) == 17)
#define MP4_IS_AAC_AUDIO_TYPE(type) \
(MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
|| (type) == MP4_MPEG4_AUDIO_TYPE)
/* MP4 Video track types - see MP4AddVideoTrack() */
#define MP4_INVALID_VIDEO_TYPE 0x00
#define MP4_MPEG1_VIDEO_TYPE 0x6A
#define MP4_MPEG2_SIMPLE_VIDEO_TYPE 0x60
#define MP4_MPEG2_MAIN_VIDEO_TYPE 0x61
#define MP4_MPEG2_SNR_VIDEO_TYPE 0x62
#define MP4_MPEG2_SPATIAL_VIDEO_TYPE 0x63
#define MP4_MPEG2_HIGH_VIDEO_TYPE 0x64
#define MP4_MPEG2_442_VIDEO_TYPE 0x65
#define MP4_MPEG2_VIDEO_TYPE MP4_MPEG2_MAIN_VIDEO_TYPE
#define MP4_MPEG4_VIDEO_TYPE 0x20
#define MP4_JPEG_VIDEO_TYPE 0x6C
#define MP4_PRIVATE_VIDEO_TYPE 0xD0
#define MP4_YUV12_VIDEO_TYPE 0xF0 /* a private definition */
#define MP4_H263_VIDEO_TYPE 0xF2 /* a private definition */
#define MP4_H261_VIDEO_TYPE 0xF3 /* a private definition */
/* MP4 Video type utilities */
#define MP4_IS_MPEG1_VIDEO_TYPE(type) \
((type) == MP4_MPEG1_VIDEO_TYPE)
#define MP4_IS_MPEG2_VIDEO_TYPE(type) \
(((type) >= MP4_MPEG2_SIMPLE_VIDEO_TYPE \
&& (type) <= MP4_MPEG2_442_VIDEO_TYPE) \
|| MP4_IS_MPEG1_VIDEO_TYPE(type))
#define MP4_IS_MPEG4_VIDEO_TYPE(type) \
((type) == MP4_MPEG4_VIDEO_TYPE)
/* Mpeg4 Visual Profile Defines - ISO/IEC 14496-2:2001/Amd.2:2002(E) */
#define MPEG4_SP_L1 (0x1)
#define MPEG4_SP_L2 (0x2)
#define MPEG4_SP_L3 (0x3)
#define MPEG4_SP_L0 (0x8)
#define MPEG4_SSP_L1 (0x11)
#define MPEG4_SSP_L2 (0x12)
#define MPEG4_CP_L1 (0x21)
#define MPEG4_CP_L2 (0x22)
#define MPEG4_MP_L2 (0x32)
#define MPEG4_MP_L3 (0x33)
#define MPEG4_MP_L4 (0x34)
#define MPEG4_NBP_L2 (0x42)
#define MPEG4_STP_L1 (0x51)
#define MPEG4_SFAP_L1 (0x61)
#define MPEG4_SFAP_L2 (0x62)
#define MPEG4_SFBAP_L1 (0x63)
#define MPEG4_SFBAP_L2 (0x64)
#define MPEG4_BATP_L1 (0x71)
#define MPEG4_BATP_L2 (0x72)
#define MPEG4_HP_L1 (0x81)
#define MPEG4_HP_L2 (0x82)
#define MPEG4_ARTSP_L1 (0x91)
#define MPEG4_ARTSP_L2 (0x92)
#define MPEG4_ARTSP_L3 (0x93)
#define MPEG4_ARTSP_L4 (0x94)
#define MPEG4_CSP_L1 (0xa1)
#define MPEG4_CSP_L2 (0xa2)
#define MPEG4_CSP_L3 (0xa3)
#define MPEG4_ACEP_L1 (0xb1)
#define MPEG4_ACEP_L2 (0xb2)
#define MPEG4_ACEP_L3 (0xb3)
#define MPEG4_ACEP_L4 (0xb4)
#define MPEG4_ACP_L1 (0xc1)
#define MPEG4_ACP_L2 (0xc2)
#define MPEG4_AST_L1 (0xd1)
#define MPEG4_AST_L2 (0xd2)
#define MPEG4_AST_L3 (0xd3)
#define MPEG4_S_STUDIO_P_L1 (0xe1)
#define MPEG4_S_STUDIO_P_L2 (0xe2)
#define MPEG4_S_STUDIO_P_L3 (0xe3)
#define MPEG4_S_STUDIO_P_L4 (0xe4)
#define MPEG4_C_STUDIO_P_L1 (0xe5)
#define MPEG4_C_STUDIO_P_L2 (0xe6)
#define MPEG4_C_STUDIO_P_L3 (0xe7)
#define MPEG4_C_STUDIO_P_L4 (0xe8)
#define MPEG4_ASP_L0 (0xF0)
#define MPEG4_ASP_L1 (0xF1)
#define MPEG4_ASP_L2 (0xF2)
#define MPEG4_ASP_L3 (0xF3)
#define MPEG4_ASP_L4 (0xF4)
#define MPEG4_ASP_L5 (0xF5)
#define MPEG4_ASP_L3B (0xF7)
#define MPEG4_FGSP_L0 (0xf8)
#define MPEG4_FGSP_L1 (0xf9)
#define MPEG4_FGSP_L2 (0xfa)
#define MPEG4_FGSP_L3 (0xfb)
#define MPEG4_FGSP_L4 (0xfc)
#define MPEG4_FGSP_L5 (0xfd)
/*****************************************************************************/
/* 3GP specific utilities */
MP4V2_EXPORT
bool MP4Make3GPCompliant(
const char* fileName,
char* majorBrand DEFAULT(0),
uint32_t minorVersion DEFAULT(0),
char** supportedBrands DEFAULT(NULL),
uint32_t supportedBrandsCount DEFAULT(0),
bool deleteIodsAtom DEFAULT(true) );
/* NOTE this section of functionality has not yet been fully tested */
MP4V2_EXPORT
MP4EditId MP4AddTrackEdit(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID),
MP4Timestamp startTime DEFAULT(0),
MP4Duration duration DEFAULT(0),
bool dwell DEFAULT(false) );
MP4V2_EXPORT
bool MP4DeleteTrackEdit(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId );
MP4V2_EXPORT
uint32_t MP4GetTrackNumberOfEdits(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
MP4Timestamp MP4GetTrackEditStart(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId );
MP4V2_EXPORT
MP4Duration MP4GetTrackEditTotalDuration(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID) );
MP4V2_EXPORT
MP4Timestamp MP4GetTrackEditMediaStart(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId );
MP4V2_EXPORT
bool MP4SetTrackEditMediaStart(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId,
MP4Timestamp startTime );
MP4V2_EXPORT
MP4Duration MP4GetTrackEditDuration(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId );
MP4V2_EXPORT
bool MP4SetTrackEditDuration(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId,
MP4Duration duration );
MP4V2_EXPORT
int8_t MP4GetTrackEditDwell(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId );
MP4V2_EXPORT
bool MP4SetTrackEditDwell(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4EditId editId,
bool dwell );
MP4V2_EXPORT
bool MP4ReadSampleFromEditTime(
/* input parameters */
MP4FileHandle hFile,
MP4TrackId trackId,
MP4Timestamp when,
/* input/output parameters */
uint8_t** ppBytes,
uint32_t* pNumBytes,
/* output parameters */
MP4Timestamp* pStartTime DEFAULT(NULL),
MP4Duration* pDuration DEFAULT(NULL),
MP4Duration* pRenderingOffset DEFAULT(NULL),
bool* pIsSyncSample DEFAULT(NULL) );
MP4V2_EXPORT
MP4SampleId MP4GetSampleIdFromEditTime(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4Timestamp when,
MP4Timestamp* pStartTime DEFAULT(NULL),
MP4Duration* pDuration DEFAULT(NULL) );
/* time conversion utilties */
/* predefined values for timeScale parameter below */
#define MP4_SECONDS_TIME_SCALE 1
#define MP4_MILLISECONDS_TIME_SCALE 1000
#define MP4_MICROSECONDS_TIME_SCALE 1000000
#define MP4_NANOSECONDS_TIME_SCALE 1000000000
#define MP4_SECS_TIME_SCALE MP4_SECONDS_TIME_SCALE
#define MP4_MSECS_TIME_SCALE MP4_MILLISECONDS_TIME_SCALE
#define MP4_USECS_TIME_SCALE MP4_MICROSECONDS_TIME_SCALE
#define MP4_NSECS_TIME_SCALE MP4_NANOSECONDS_TIME_SCALE
MP4V2_EXPORT
uint64_t MP4ConvertFromMovieDuration(
MP4FileHandle hFile,
MP4Duration duration,
uint32_t timeScale );
MP4V2_EXPORT
uint64_t MP4ConvertFromTrackTimestamp(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4Timestamp timeStamp,
uint32_t timeScale );
MP4V2_EXPORT
MP4Timestamp MP4ConvertToTrackTimestamp(
MP4FileHandle hFile,
MP4TrackId trackId,
uint64_t timeStamp,
uint32_t timeScale );
/** Convert duration from track time scale to an arbitrary time scale.
*
* MP4ConvertFromTrackDuration converts a duration such as a sample duration
* from the track time scale to another time scale. This can be used by a
* player application to map all track samples to a common time scale.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param duration value to be converted.
* @param timeScale time scale in ticks per second.
*
* @return On success, the duration in arbitrary time scale units.
* On error, <b>0</b>.
*
* @see MP4GetSampleDuration().
* @see MP4ConvertToTrackDuration().
*/
MP4V2_EXPORT
uint64_t MP4ConvertFromTrackDuration(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4Duration duration,
uint32_t timeScale );
/** Convert duration from arbitrary time scale to track time scale.
*
* MP4ConvertToTrackDuration converts a duration such as a sample duration
* from the specified time scale to the track time scale.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param duration value to be converted.
* @param timeScale time scale in ticks per second.
*
* @return On success, the duration in track time scale units.
* On error, #MP4_INVALID_DURATION.
*
* @see MP4ConvertFromTrackDuration().
*/
MP4V2_EXPORT
MP4Duration MP4ConvertToTrackDuration(
MP4FileHandle hFile,
MP4TrackId trackId,
uint64_t duration,
uint32_t timeScale );
MP4V2_EXPORT
char* MP4BinaryToBase16(
const uint8_t* pData,
uint32_t dataSize );
MP4V2_EXPORT
char* MP4BinaryToBase64(
const uint8_t* pData,
uint32_t dataSize );
MP4V2_EXPORT
uint8_t* Base64ToBinary(
const char* pData,
uint32_t decodeSize,
uint32_t* pDataSize );
MP4V2_EXPORT
void MP4Free(
void* p );
/** Set the function to call in place of default logging behavior
*
* @param cb_func the function to call
*/
MP4V2_EXPORT
void MP4SetLogCallback(
MP4LogCallback cb_func );
/** @} ***********************************************************************/
/**
* Accessor for the maximum level for diagnostic information
*
* @return the maximum level for diagnostic information
*
* @see MP4LogSetLevel() for further details.
*/
MP4V2_EXPORT
MP4LogLevel MP4LogGetLevel( void );
/**
* Set the maximum level for diagnostic information
*
* @param verbosity the level to set
*/
MP4V2_EXPORT
void MP4LogSetLevel( MP4LogLevel verbosity );
#endif /* MP4V2_GENERAL_H */
+96
View File
@@ -0,0 +1,96 @@
#ifndef MP4V2_ISMA_H
#define MP4V2_ISMA_H
/**************************************************************************//**
*
* @defgroup mp4_isma MP4v2 ISMA (Internet Streaming Media Alliance)
* @{
*
*****************************************************************************/
/** something */
typedef struct mp4v2_ismacryp_session_params {
uint32_t scheme_type;
uint16_t scheme_version;
uint8_t key_ind_len;
uint8_t iv_len;
uint8_t selective_enc;
const char* kms_uri;
} mp4v2_ismacrypParams;
/*
* API to initialize ismacryp properties to sensible defaults
* if input param is null then mallocs a params struct
*/
MP4V2_EXPORT
mp4v2_ismacrypParams* MP4DefaultISMACrypParams( mp4v2_ismacrypParams* ptr );
MP4V2_EXPORT
MP4TrackId MP4AddEncAudioTrack(
MP4FileHandle hFile,
uint32_t timeScale,
MP4Duration sampleDuration,
mp4v2_ismacrypParams* icPp,
uint8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE) );
MP4V2_EXPORT
MP4TrackId MP4AddEncVideoTrack(
MP4FileHandle hFile,
uint32_t timeScale,
MP4Duration sampleDuration,
uint16_t width,
uint16_t height,
mp4v2_ismacrypParams* icPp,
uint8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE),
const char* oFormat DEFAULT(NULL) );
MP4V2_EXPORT
MP4TrackId MP4AddEncH264VideoTrack(
MP4FileHandle dstFile,
uint32_t timeScale,
MP4Duration sampleDuration,
uint16_t width,
uint16_t height,
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
mp4v2_ismacrypParams* icPp );
MP4V2_EXPORT
MP4TrackId MP4EncAndCloneTrack(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
mp4v2_ismacrypParams* icPp,
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID) );
MP4V2_EXPORT
MP4TrackId MP4EncAndCopyTrack(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
mp4v2_ismacrypParams* icPp,
encryptFunc_t encfcnp,
uint32_t encfcnparam1,
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
bool applyEdits DEFAULT(false),
MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID) );
MP4V2_EXPORT
bool MP4MakeIsmaCompliant(
const char* fileName,
bool addIsmaComplianceSdp DEFAULT(true) );
MP4V2_EXPORT
char* MP4MakeIsmaSdpIod(
uint8_t videoProfile,
uint32_t videoBitrate,
uint8_t* videoConfig,
uint32_t videoConfigLength,
uint8_t audioProfile,
uint32_t audioBitrate,
uint8_t* audioConfig,
uint32_t audioConfigLength );
/** @} ***********************************************************************/
#endif /* MP4V2_ISMA_H */
+207
View File
@@ -0,0 +1,207 @@
#ifndef MP4V2_ITMF_GENERIC_H
#define MP4V2_ITMF_GENERIC_H
/**************************************************************************//**
*
* @defgroup mp4_itmf_generic MP4v2 iTMF (iTunes Metadata Format) Generic
* @{
*
* This is a low-level API used to manage iTMF metadata.
*
* It provides support for virtually any kind of iTMF metadata item,
* including meaning atoms, sometimes referred to as reverse-DNS meanings.
* Structures are directly modified; ie: there are no fuctions which
* modify values for you. There is little type-safety, logic checks, or
* specifications compliance checks. For these reasons it is recommended
* to use iTMF Tags API when possible.
*
* At the heart of this API is an #MP4ItmfItem which corresponds to an
* iTMF metadata item atom. The item, and any recursive data structures
* contained within require <b>manual</b> memory management. The general
* rule to follow is that you must always check/free a ptr if you intend
* to resize data. In cases where you know the existing data size is
* exactly what is needed, you may overwrite the buffer contents.
*
* Each item always has at least 1 data elements which corresponds to
* a data atom. Additionally, each item has optional <b>mean</b> and
* <b>name</b> values which correspond to mean and name atoms.
*
* Each #MP4ItmfItem has a list of #MP4ItmfData. Similarily, care must
* be taken to manage memory with one key difference; these structures
* also have a valueSize field. If value is NULL then set valueSize=0.
* Otherwise, set valueSize to the size (in bytes) of value buffer.
*
* In rare cases where the number of data elements in a single item
* is > 1, the user must manually free/alloc/copy the <b>elements</b>
* buffer and update <b>size</b> accordingly.
*
* The mp4 file structure is modified only when MP4AddItem(),
* MP4SetItem() and MP4RemoveItem() are used. Simply free'ing
* the item list does not modify the mp4 file.
*
* <b>iTMF Generic read workflow:</b>
*
* @li MP4ItmfGetItems()
* @li inspect each item...
* @li MP4ItmfItemListFree()
*
* <b>iTMF Generic read/modify/remove workflow:</b>
*
* @li MP4ItmfGetItems()
* @li inspect/modify item...
* @li MP4ItmfSetItem() each modified item...
* @li MP4ItmfRemoveItem()...
* @li MP4ItmfItemListFree()
*
* <b>iTMF Generic add workflow:</b>
*
* @li MP4ItmfItemAlloc()
* @li MP4ItmfAddItem()
* @li MP4ItmfItemFree()
*
* @par Warning:
* Care must be taken when using multiple mechanisms to modify an open mp4
* file as it is not thread-safe, nor does it permit overlapping different
* API workflows which have a begin/end to their workflow. That is to say
* do not interleave an iTMF Generic workflow with an iTMF Tags workflow.
*
*****************************************************************************/
/** Basic types of value data as enumerated in spec. */
typedef enum MP4ItmfBasicType_e
{
MP4_ITMF_BT_IMPLICIT = 0, /**< for use with tags for which no type needs to be indicated */
MP4_ITMF_BT_UTF8 = 1, /**< without any count or null terminator */
MP4_ITMF_BT_UTF16 = 2, /**< also known as UTF-16BE */
MP4_ITMF_BT_SJIS = 3, /**< deprecated unless it is needed for special Japanese characters */
MP4_ITMF_BT_HTML = 6, /**< the HTML file header specifies which HTML version */
MP4_ITMF_BT_XML = 7, /**< the XML header must identify the DTD or schemas */
MP4_ITMF_BT_UUID = 8, /**< also known as GUID; stored as 16 bytes in binary (valid as an ID) */
MP4_ITMF_BT_ISRC = 9, /**< stored as UTF-8 text (valid as an ID) */
MP4_ITMF_BT_MI3P = 10, /**< stored as UTF-8 text (valid as an ID) */
MP4_ITMF_BT_GIF = 12, /**< (deprecated) a GIF image */
MP4_ITMF_BT_JPEG = 13, /**< a JPEG image */
MP4_ITMF_BT_PNG = 14, /**< a PNG image */
MP4_ITMF_BT_URL = 15, /**< absolute, in UTF-8 characters */
MP4_ITMF_BT_DURATION = 16, /**< in milliseconds, 32-bit integer */
MP4_ITMF_BT_DATETIME = 17, /**< in UTC, counting seconds since midnight, January 1, 1904; 32 or 64-bits */
MP4_ITMF_BT_GENRES = 18, /**< a list of enumerated values */
MP4_ITMF_BT_INTEGER = 21, /**< a signed big-endian integer with length one of { 1,2,3,4,8 } bytes */
MP4_ITMF_BT_RIAA_PA = 24, /**< RIAA parental advisory; { -1=no, 1=yes, 0=unspecified }, 8-bit ingteger */
MP4_ITMF_BT_UPC = 25, /**< Universal Product Code, in text UTF-8 format (valid as an ID) */
MP4_ITMF_BT_BMP = 27, /**< Windows bitmap image */
MP4_ITMF_BT_UNDEFINED = 255 /**< undefined */
} MP4ItmfBasicType;
/** Data structure.
* Models an iTMF data atom contained in an iTMF metadata item atom.
*/
typedef struct MP4ItmfData_s
{
uint8_t typeSetIdentifier; /**< always zero. */
MP4ItmfBasicType typeCode; /**< iTMF basic type. */
uint32_t locale; /**< always zero. */
uint8_t* value; /**< may be NULL. */
uint32_t valueSize; /**< value size in bytes. */
} MP4ItmfData;
/** List of data. */
typedef struct MP4ItmfDataList_s
{
MP4ItmfData* elements; /**< flat array. NULL when size is zero. */
uint32_t size; /**< number of elements. */
} MP4ItmfDataList;
/** Item structure.
* Models an iTMF metadata item atom contained in an ilst atom.
*/
typedef struct MP4ItmfItem_s
{
void* __handle; /**< internal use only. */
char* code; /**< four-char code identifing atom type. NULL-terminated. */
char* mean; /**< may be NULL. UTF-8 meaning. NULL-terminated. */
char* name; /**< may be NULL. UTF-8 name. NULL-terminated. */
MP4ItmfDataList dataList; /**< list of data. can be zero length. */
} MP4ItmfItem;
/** List of items. */
typedef struct MP4ItmfItemList_s
{
MP4ItmfItem* elements; /**< flat array. NULL when size is zero. */
uint32_t size; /**< number of elements. */
} MP4ItmfItemList;
/** Allocate an item on the heap.
* @param code four-char code identifying atom type. NULL-terminated.
* @param numData number of data elements to allocate. Must be >= 1.
* @return newly allocated item.
*/
MP4V2_EXPORT MP4ItmfItem*
MP4ItmfItemAlloc( const char* code, uint32_t numData );
/** Free an item (deep free).
* @param item to be free'd.
*/
MP4V2_EXPORT void
MP4ItmfItemFree( MP4ItmfItem* item );
/** Free an item list (deep free).
* @param itemList to be free'd.
*/
MP4V2_EXPORT void
MP4ItmfItemListFree( MP4ItmfItemList* itemList );
/** Get list of all items from file.
* @param hFile handle of file to operate on.
* @return On succes, list of items, which must be free'd. On failure, NULL.
*/
MP4V2_EXPORT MP4ItmfItemList*
MP4ItmfGetItems( MP4FileHandle hFile );
/** Get list of items by code from file.
* @param hFile handle of file to operate on.
* @param code four-char code identifying atom type. NULL-terminated.
* @return On succes, list of items, which must be free'd. On failure, NULL.
*/
MP4V2_EXPORT MP4ItmfItemList*
MP4ItmfGetItemsByCode( MP4FileHandle hFile, const char* code );
/** Get list of items by meaning from file.
* Implicitly only returns atoms of code @b{----}.
* @param hFile handle of file to operate on.
* @param meaning UTF-8 meaning. NULL-terminated.
* @param name may be NULL. UTF-8 name. NULL-terminated.
* @return On succes, list of items, which must be free'd. On failure, NULL.
*/
MP4V2_EXPORT MP4ItmfItemList*
MP4ItmfGetItemsByMeaning( MP4FileHandle hFile, const char* meaning, const char* name );
/** Add an item to file.
* @param hFile handle of file to operate on.
* @param item object to add.
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT bool
MP4ItmfAddItem( MP4FileHandle hFile, const MP4ItmfItem* item );
/** Overwrite an existing item in file.
* @param hFile handle of file to operate on.
* @param item object to overwrite. Must have a valid index obtained from prior get.
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT bool
MP4ItmfSetItem( MP4FileHandle hFile, const MP4ItmfItem* item );
/** Remove an existing item from file.
* @param hFile handle of file to operate on.
* @param item object to remove. Must have a valid index obtained from prior get.
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT bool
MP4ItmfRemoveItem( MP4FileHandle hFile, const MP4ItmfItem* item );
/** @} ***********************************************************************/
#endif /* MP4V2_ITMF_GENERIC_H */
+337
View File
@@ -0,0 +1,337 @@
#ifndef MP4V2_ITMF_TAGS_H
#define MP4V2_ITMF_TAGS_H
/**************************************************************************//**
*
* @defgroup mp4_itmf_tags MP4v2 iTMF (iTunes Metadata Format) Tags
* @{
*
* This is a high-level API used to manage iTMF metadata.
*
* It provides more type-safety and simplified memory management as compared
* to iTMF Generic API.
*
* At the heart of this API is a read-only structure that holds all known
* items and their current values. The value is always a pointer which if
* NULL indicates its corresponding atom does not exist. Thus, one must
* always check if the pointer is non-NULL before attempting to extract
* its value.
*
* The structure may not be directly modified. Instead, <b>set</b> functions
* corresponding to each item are used to modify the backing-store of
* the read-only structure. Setting the value ptr to NULL will effectively
* remove it. Setting the value ptr to real data will immediately make a
* copy of the value in the backing-store and the read-only structure
* will correctly reflect the change.
*
* The hidden data cache memory is automatically managed. Thus the user need
* only guarantee the data is available during the lifetime of the set-function
* call.
*
* <b>iTMF Tags read workflow:</b>
*
* @li MP4TagsAlloc()
* @li MP4TagsFetch()
* @li inspect each tag of interest...
* @li MP4TagsStore() (if modified)
* @li MP4TagsFree()
*
* <b>iTMF Tags read/modify/add/remove workflow:</b>
*
* @li MP4TagsAlloc()
* @li MP4TagsFetch()
* @li inspect each tag of interest...
* @li MP4TagsSetName(), MP4TagsSetArtist()...
* @li MP4TagsStore()
* @li MP4TagsFree()
*
* @par Warning:
* Care must be taken when using multiple mechanisms to modify an open mp4
* file as it is not thread-safe, nor does it permit overlapping different
* API workflows which have a begin/end to their workflow. That is to say
* do not interleave an iTMF Generic workflow with an iTMF Tags workflow.
*
*****************************************************************************/
/** Enumeration of possible MP4TagArtwork::type values. */
typedef enum MP4TagArtworkType_e
{
MP4_ART_UNDEFINED = 0,
MP4_ART_BMP = 1,
MP4_ART_GIF = 2,
MP4_ART_JPEG = 3,
MP4_ART_PNG = 4
} MP4TagArtworkType;
/** Data object representing a single piece of artwork. */
typedef struct MP4TagArtwork_s
{
void* data; /**< raw picture data */
uint32_t size; /**< data size in bytes */
MP4TagArtworkType type; /**< data type */
} MP4TagArtwork;
typedef struct MP4TagTrack_s
{
uint16_t index;
uint16_t total;
} MP4TagTrack;
typedef struct MP4TagDisk_s
{
uint16_t index;
uint16_t total;
} MP4TagDisk;
/** Tags <b>convenience</b> structure.
*
* This structure is used in the tags convenience API which allows for
* simplified retrieval and modification of the majority of known tags.
*
* This is a read-only structure and each tag is present if and only if the
* pointer is a <b>non-NULL</b> value. The actual data is backed by a hidden
* data cache which is only updated when the appropriate metadata <b>set</b>
* function is used, or if MP4TagsFetch() is invoked. Thus, if other API
* is used to manipulate relevent atom structure of the MP4 file, the user
* is responsible for re-fetching the data in this structure.
*/
typedef struct MP4Tags_s
{
void* __handle; /* internal use only */
const char* name;
const char* artist;
const char* albumArtist;
const char* album;
const char* grouping;
const char* composer;
const char* comments;
const char* genre;
const uint16_t* genreType;
const char* releaseDate;
const MP4TagTrack* track;
const MP4TagDisk* disk;
const uint16_t* tempo;
const uint8_t* compilation;
const char* trackSubTitle;
const char* songDescription;
const char* artDirector;
const char* arranger;
const char* lyricist;
const char* acknowledgement;
const char* conductor;
const char* linearNotes;
const char* recordCompany;
const char* originalArtist;
const char* phonogramRights;
const char* producer;
const char* performer;
const char* publisher;
const char* soundEngineer;
const char* soloist;
const char* credits;
const char* thanks;
const char* onlineExtras;
const char* executiveProducer;
const char* tvShow;
const char* tvNetwork;
const char* tvEpisodeID;
const uint32_t* tvSeason;
const uint32_t* tvEpisode;
const char* description;
const char* longDescription;
const char* seriesDescription;
const char* lyrics;
const char* sortName;
const char* sortArtist;
const char* sortAlbumArtist;
const char* sortAlbum;
const char* sortComposer;
const char* sortTVShow;
const MP4TagArtwork* artwork;
uint32_t artworkCount;
const char* copyright;
const char* encodingTool;
const char* encodedBy;
const char* purchaseDate;
const uint8_t* itunesu;
const uint8_t* podcast;
const char* keywords; /* TODO: Needs testing */
const char* category;
const uint8_t* hdVideo;
const uint8_t* mediaType;
const uint8_t* contentRating;
const uint8_t* gapless;
const char* iTunesAccount;
const uint8_t* iTunesAccountType;
const uint32_t* iTunesCountry;
const uint32_t* contentID;
const uint32_t* artistID;
const uint64_t* playlistID;
const uint32_t* genreID;
const uint32_t* composerID;
const char* xid;
} MP4Tags;
/** Allocate tags convenience structure for reading and settings tags.
*
* This function allocates a new structure which represents a snapshot
* of all the tags therein, tracking if the tag is missing,
* or present and with value. It is the caller's responsibility to free
* the structure with MP4TagsFree().
*
* @return structure with all tags missing.
*/
MP4V2_EXPORT
const MP4Tags* MP4TagsAlloc( void );
/** Fetch data from mp4 file and populate structure.
*
* The tags structure and its hidden data-cache is updated to
* reflect the actual tags values found in the <b>hFile</b>.
*
* @param tags structure to fetch (write) into.
* @param hFile handle of file to fetch data from.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4TagsFetch( const MP4Tags* tags, MP4FileHandle hFile );
/** Store data to mp4 file from structure.
*
* The tags structure is pushed out to the mp4 file,
* adding tags if needed, removing tags if needed, and updating
* the values to modified tags.
*
* @param tags structure to store (read) from.
* @param hFile handle of file to store data to.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4TagsStore( const MP4Tags* tags, MP4FileHandle hFile );
/** Free tags convenience structure.
*
* This function frees memory associated with the structure.
*
* @param tags structure to destroy.
*/
MP4V2_EXPORT
void MP4TagsFree( const MP4Tags* tags );
/** Accessor that indicates whether a tags structure
* contains any metadata
*
* @param tags the structure to inspect
*
* @param hasMetadata populated with false if @p tags
* contains no metadata, true if @p tags contains metadata
*
* @retval false error determining if @p tags contains
* metadata
*
* @retval true successfully determined if @p tags contains
* metadata
*/
MP4V2_EXPORT
bool MP4TagsHasMetadata ( const MP4Tags* tags, bool *hasMetadata );
MP4V2_EXPORT bool MP4TagsSetName ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetArtist ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetAlbumArtist ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetAlbum ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetGrouping ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetComposer ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetComments ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetGenre ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetGenreType ( const MP4Tags*, const uint16_t* );
MP4V2_EXPORT bool MP4TagsSetReleaseDate ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetTrack ( const MP4Tags*, const MP4TagTrack* );
MP4V2_EXPORT bool MP4TagsSetDisk ( const MP4Tags*, const MP4TagDisk* );
MP4V2_EXPORT bool MP4TagsSetTempo ( const MP4Tags*, const uint16_t* );
MP4V2_EXPORT bool MP4TagsSetCompilation ( const MP4Tags*, const uint8_t* );
MP4V2_EXPORT bool MP4TagsSetTrackSubTitle ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSongDescription ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetArtDirector ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetArranger ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetLyricist ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetAcknowledgement ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetConductor ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetLinearNotes ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetRecordCompany ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetOriginalArtist ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetPhonogramRights ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetProducer ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetPerformer ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetPublisher ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSoundEngineer ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSoloist ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetCredits ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetThanks ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetOnlineExtras ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetExecutiveProducer ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetTVShow ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetTVNetwork ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetTVEpisodeID ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetTVSeason ( const MP4Tags*, const uint32_t* );
MP4V2_EXPORT bool MP4TagsSetTVEpisode ( const MP4Tags*, const uint32_t* );
MP4V2_EXPORT bool MP4TagsSetDescription ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetLongDescription ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSeriesDescription ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetLyrics ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSortName ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSortArtist ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSortAlbumArtist ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSortAlbum ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSortComposer ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetSortTVShow ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsAddArtwork ( const MP4Tags*, MP4TagArtwork* );
MP4V2_EXPORT bool MP4TagsSetArtwork ( const MP4Tags*, uint32_t, MP4TagArtwork* );
MP4V2_EXPORT bool MP4TagsRemoveArtwork ( const MP4Tags*, uint32_t );
MP4V2_EXPORT bool MP4TagsSetCopyright ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetEncodingTool ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetEncodedBy ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetPurchaseDate ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetITunesU ( const MP4Tags*, const uint8_t* );
MP4V2_EXPORT bool MP4TagsSetPodcast ( const MP4Tags*, const uint8_t* );
MP4V2_EXPORT bool MP4TagsSetKeywords ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetCategory ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetHDVideo ( const MP4Tags*, const uint8_t* );
MP4V2_EXPORT bool MP4TagsSetMediaType ( const MP4Tags*, const uint8_t* );
MP4V2_EXPORT bool MP4TagsSetContentRating ( const MP4Tags*, const uint8_t* );
MP4V2_EXPORT bool MP4TagsSetGapless ( const MP4Tags*, const uint8_t* );
MP4V2_EXPORT bool MP4TagsSetITunesAccount ( const MP4Tags*, const char* );
MP4V2_EXPORT bool MP4TagsSetITunesAccountType ( const MP4Tags*, const uint8_t* );
MP4V2_EXPORT bool MP4TagsSetITunesCountry ( const MP4Tags*, const uint32_t* );
MP4V2_EXPORT bool MP4TagsSetContentID ( const MP4Tags*, const uint32_t* );
MP4V2_EXPORT bool MP4TagsSetArtistID ( const MP4Tags*, const uint32_t* );
MP4V2_EXPORT bool MP4TagsSetPlaylistID ( const MP4Tags*, const uint64_t* );
MP4V2_EXPORT bool MP4TagsSetGenreID ( const MP4Tags*, const uint32_t* );
MP4V2_EXPORT bool MP4TagsSetComposerID ( const MP4Tags*, const uint32_t* );
MP4V2_EXPORT bool MP4TagsSetXID ( const MP4Tags*, const char* );
/** @} ***********************************************************************/
#endif /* MP4V2_ITMF_TAGS_H */
+95
View File
@@ -0,0 +1,95 @@
#ifndef MP4V2_PLATFORM_H
#define MP4V2_PLATFORM_H
/*****************************************************************************/
#include <stddef.h>
#include <stdio.h>
#include <stdarg.h>
// Thanks, MSFT, for making C99 a total PITA. Declare this not to define any stdint stuff; this is useful
// if you're going to be using mp4v2 on windows with some other library that defines its own stdint.
// TODO msft has finally re-included stdint in vs2010, so maybe at some point in the future this won't be needed.
#ifndef MP4V2_NO_STDINT_DEFS
#if defined( _WIN32 ) && !defined( __MINGW32__ )
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
#else
#include <stdint.h>
#endif
#endif
#if defined( _WIN32 ) || defined( __MINGW32__ )
# if defined( MP4V2_EXPORTS )
# define MP4V2_EXPORT __declspec(dllexport)
# elif defined( MP4V2_USE_DLL_IMPORT ) || !defined( MP4V2_USE_STATIC_LIB )
# define MP4V2_EXPORT __declspec(dllimport)
# else
# define MP4V2_EXPORT
# endif
#else
# define MP4V2_EXPORT __attribute__((visibility("default")))
#endif
#if defined( __GNUC__ )
# define MP4V2_DEPRECATED __attribute__((deprecated))
#else
# define MP4V2_DEPRECATED
#endif
/******************************************************************************
*
* TODO-KB: cleanup -- absolutely no need for a C-API to fuss with reserved
* C++ keywords. This will involve changing the public interface and current
* plan of action:
*
* typdef enum {
* mp4_false,
* mp4_true,
* } mp4_bool_t;
*
* followed by updating all public signatures and implementation.
*/
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#if !defined( __cplusplus )
#ifndef bool
#if SIZEOF_BOOL == 8
typedef uint64_t bool;
#else
#if SIZEOF_BOOL == 4
typedef uint32_t bool;
#else
#if SIZEOF_BOOL == 2
typedef uint16_t bool;
#else
typedef unsigned char bool;
#endif
#endif
#endif
#ifndef false
#define false FALSE
#endif
#ifndef true
#define true TRUE
#endif
#endif
#endif
/*****************************************************************************/
#endif /* MP4V2_PLATFORM_H */
+31
View File
@@ -0,0 +1,31 @@
#ifndef MP4V2_PROJECT_H
#define MP4V2_PROJECT_H
/*****************************************************************************/
#define MP4V2_PROJECT_name "MP4v2"
#define MP4V2_PROJECT_name_lower "mp4v2"
#define MP4V2_PROJECT_name_upper "MP4V2"
#define MP4V2_PROJECT_name_formal "MP4v2 trunk-r487"
#define MP4V2_PROJECT_url_website "http://code.google.com/p/mp4v2"
#define MP4V2_PROJECT_url_downloads "http://code.google.com/p/mp4v2/downloads/list"
#define MP4V2_PROJECT_url_discussion "http://groups.google.com/group/mp4v2"
#define MP4V2_PROJECT_irc "irc://irc.freenode.net/handbrake"
#define MP4V2_PROJECT_bugreport "<eddyg@myreflection.org>"
#define MP4V2_PROJECT_version "trunk-r487"
#define MP4V2_PROJECT_version_hex 0x00020000
#define MP4V2_PROJECT_version_major 2
#define MP4V2_PROJECT_version_minor 0
#define MP4V2_PROJECT_version_point 0
#define MP4V2_PROJECT_repo_url "http://mp4v2.googlecode.com/svn/trunk"
#define MP4V2_PROJECT_repo_branch "trunk"
#define MP4V2_PROJECT_repo_root "http://mp4v2.googlecode.com/svn"
#define MP4V2_PROJECT_repo_uuid "6e6572fa-98a6-11dd-ad9f-f77439c74b79"
#define MP4V2_PROJECT_repo_rev 487
#define MP4V2_PROJECT_repo_date "2011-10-19 20:03:14 +0200 (Wed, 19 Oct 2011)"
#define MP4V2_PROJECT_repo_type "developer"
#define MP4V2_PROJECT_build "Sat Aug 4 12:47:15 CEST 2012"
/*****************************************************************************/
#endif /* MP4V2_PROJECT_H */
+557
View File
@@ -0,0 +1,557 @@
#ifndef MP4V2_SAMPLE_H
#define MP4V2_SAMPLE_H
/**************************************************************************//**
*
* @defgroup mp4_sample MP4v2 Sample
* @{
*
*****************************************************************************/
/** Sample dependency types.
*
* Bit combinations 0x03, 0x30, 0xc0 are reserved.
*/
typedef enum MP4SampleDependencyType_e {
MP4_SDT_UNKNOWN = 0x00, /**< unknown */
MP4_SDT_HAS_REDUNDANT_CODING = 0x01, /**< contains redundant coding */
MP4_SDT_HAS_NO_REDUNDANT_CODING = 0x02, /**< does not contain redundant coding */
MP4_SDT_HAS_DEPENDENTS = 0x04, /**< referenced by other samples */
MP4_SDT_HAS_NO_DEPENDENTS = 0x08, /**< not referenced by other samples */
MP4_SDT_IS_DEPENDENT = 0x10, /**< references other samples */
MP4_SDT_IS_INDEPENDENT = 0x20, /**< does not reference other samples */
MP4_SDT_EARLIER_DISPLAY_TIMES_ALLOWED = 0x40, /**< subequent samples in GOP may display earlier */
_MP4_SDT_RESERVED = 0x80 /**< reserved */
} MP4SampleDependencyType;
/** Read a track sample.
*
* MP4ReadSample reads the specified sample from the specified track.
* Typically this sample is then decoded in a codec dependent fashion and
* rendered in an appropriate fashion.
*
* The argument <b>ppBytes</b> allows for two possible approaches for
* buffering:
*
* If the calling application wishes to handle its own buffering it can set
* *ppBytes to the buffer it wishes to use. The calling application is
* responsible for ensuring that the buffer is large enough to hold the
* sample. This can be done by using either MP4GetSampleSize() or
* MP4GetTrackMaxSampleSize() to determine before-hand how large the
* receiving buffer must be.
*
* If the value of *ppBytes is NULL, then an appropriately sized buffer is
* automatically malloc'ed for the sample data and *ppBytes set to this
* pointer. The calling application is responsible for free'ing this
* memory.
*
* The last four arguments are pointers to variables that can receive
* optional sample information.
*
* Typically for audio none of these are needed. MPEG audio such as MP3 or
* AAC has a fixed sample duration and every sample can be accessed at
* random.
*
* For video, all of these optional values could be needed. MPEG video can
* be encoded at a variable frame rate, with only occasional random access
* points, and with "B frames" which cause the rendering (display) order
* of the video frames to differ from the storage/decoding order.
*
* Other media types fall between these two extremes.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param sampleId specifies which sample is to be read.
* Caveat: the first sample has id <b>1</b> not <b>0</b>.
* @param ppBytes pointer to the pointer to the sample data.
* @param pNumBytes pointer to variable that will be hold the size in bytes
* of the sample.
* @param pStartTime if non-NULL, pointer to variable that will receive the
* starting timestamp for this sample. Caveat: The timestamp is in
* <b>trackId</b>'s timescale.
* @param pDuration if non-NULL, pointer to variable that will receive the
* duration for this sample. Caveat: The duration is in
* <b>trackId</b>'s timescale.
* @param pRenderingOffset if non-NULL, pointer to variable that will
* receive the rendering offset for this sample. Currently the only
* media type that needs this feature is MPEG video. Caveat: The offset
* is in <b>trackId</b>'s timescale.
* @param pIsSyncSample if non-NULL, pointer to variable that will receive
* the state of the sync/random access flag for this sample.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*
* @see MP4GetSampleSize().
* @see MP4GetTrackMaxSampleSize().
*/
MP4V2_EXPORT
bool MP4ReadSample(
/* input parameters */
MP4FileHandle hFile,
MP4TrackId trackId,
MP4SampleId sampleId,
/* input/output parameters */
uint8_t** ppBytes,
uint32_t* pNumBytes,
/* output parameters */
MP4Timestamp* pStartTime DEFAULT(NULL),
MP4Duration* pDuration DEFAULT(NULL),
MP4Duration* pRenderingOffset DEFAULT(NULL),
bool* pIsSyncSample DEFAULT(NULL) );
/** Read a track sample based on a specified time.
*
* MP4ReadSampleFromTime is similar to MP4ReadSample() except the sample
* is specified by using a timestamp instead of sampleId.
* Typically this sample is then decoded in a codec dependent fashion and
* rendered in an appropriate fashion.
*
* The argument <b>ppBytes</b> allows for two possible approaches for
* buffering:
*
* If the calling application wishes to handle its own buffering it can set
* *ppBytes to the buffer it wishes to use. The calling application is
* responsible for ensuring that the buffer is large enough to hold the
* sample. This can be done by using either MP4GetSampleSize() or
* MP4GetTrackMaxSampleSize() to determine before-hand how large the
* receiving buffer must be.
*
* If the value of *ppBytes is NULL, then an appropriately sized buffer is
* automatically malloc'ed for the sample data and *ppBytes set to this
* pointer. The calling application is responsible for free'ing this
* memory.
*
* The last four arguments are pointers to variables that can receive
* optional sample information.
*
* Typically for audio none of these are needed. MPEG audio such as MP3 or
* AAC has a fixed sample duration and every sample can be accessed at
* random.
*
* For video, all of these optional values could be needed. MPEG video can
* be encoded at a variable frame rate, with only occasional random access
* points, and with "B frames" which cause the rendering (display) order
* of the video frames to differ from the storage/decoding order.
*
* Other media types fall between these two extremes.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param when specifies which sample is to be read based on a time in the
* track timeline. See MP4GetSampleIdFromTime() for details.
* @param ppBytes pointer to the pointer to the sample data.
* @param pNumBytes pointer to variable that will be hold the size in bytes
* of the sample.
* @param pStartTime if non-NULL, pointer to variable that will receive the
* starting timestamp for this sample. Caveat: The timestamp is in
* <b>trackId</b>'s timescale.
* @param pDuration if non-NULL, pointer to variable that will receive the
* duration for this sample. Caveat: The duration is in
* <b>trackId</b>'s timescale.
* @param pRenderingOffset if non-NULL, pointer to variable that will
* receive the rendering offset for this sample. Currently the only
* media type that needs this feature is MPEG video. Caveat: The offset
* is in <b>trackId</b>'s timescale.
* @param pIsSyncSample if non-NULL, pointer to variable that will receive
* the state of the sync/random access flag for this sample.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*
* @see MP4ReadSample().
* @see MP4GetSampleIdFromTime().
* @see MP4GetSampleSize().
* @see MP4GetTrackMaxSampleSize().
*/
MP4V2_EXPORT
bool MP4ReadSampleFromTime(
/* input parameters */
MP4FileHandle hFile,
MP4TrackId trackId,
MP4Timestamp when,
/* input/output parameters */
uint8_t** ppBytes,
uint32_t* pNumBytes,
/* output parameters */
MP4Timestamp* pStartTime DEFAULT(NULL),
MP4Duration* pDuration DEFAULT(NULL),
MP4Duration* pRenderingOffset DEFAULT(NULL),
bool* pIsSyncSample DEFAULT(NULL) );
/** Write a track sample.
*
* MP4WriteSample writes the given sample at the end of the specified track.
* Currently the library does not support random insertion of samples into
* the track timeline. Note that with mp4 there cannot be any holes or
* overlapping samples in the track timeline. The last three arguments give
* optional sample information.
*
* The value of duration can be given as #MP4_INVALID_DURATION if all samples
* in the track have the same duration. This can be specified with
* MP4AddTrack() and related functions.
*
* Typically for audio none of the optional arguments are needed. MPEG audio
* such as MP3 or AAC has a fixed sample duration and every sample can be
* accessed at random.
*
* For video, all of the optional arguments could be needed. MPEG video
* can be encoded at a variable frame rate, with only occasional random
* access points, and with "B frames" which cause the rendering (display)
* order of the video frames to differ from the storage/decoding order.
*
* Other media types fall between these two extremes.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param pBytes pointer to sample data.
* @param numBytes length of sample data in bytes.
* @param duration sample duration. Caveat: should be in track timescale.
* @param renderingOffset the rendering offset for this sample.
* Currently the only media type that needs this feature is MPEG
* video. Caveat: The offset should be in the track timescale.
* @param isSyncSample the sync/random access flag for this sample.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*
* @see MP4AddTrack().
*/
MP4V2_EXPORT
bool MP4WriteSample(
MP4FileHandle hFile,
MP4TrackId trackId,
const uint8_t* pBytes,
uint32_t numBytes,
MP4Duration duration DEFAULT(MP4_INVALID_DURATION),
MP4Duration renderingOffset DEFAULT(0),
bool isSyncSample DEFAULT(true) );
/** Write a track sample and supply dependency information.
*
* MP4WriteSampleDependency writes the given sample at the end of the specified track.
* Currently the library does not support random insertion of samples into
* the track timeline. Note that with mp4 there cannot be any holes or
* overlapping samples in the track timeline. The last three arguments give
* optional sample information.
*
* The value of duration can be given as #MP4_INVALID_DURATION if all samples
* in the track have the same duration. This can be specified with
* MP4AddTrack() and related functions.
*
* When this method is used instead of MP4WriteSample() it enables <b>sdtp</b>
* atom to be written out. This atom may be used by advanced players to
* optimize trick-operations such as fast-fwd, reverse or scrubbing.
*
* An <b>sdtp</b> atom will always be written out if this method is used.
* To avoid writing the atom, use MP4WriteSample() instead.
*
* Intermixing use of MP4WriteSampleDependency() and MP4WriteSample() on the
* same track is not permitted.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param pBytes pointer to sample data.
* @param numBytes length of sample data in bytes.
* @param duration sample duration. Caveat: should be in track timescale.
* @param renderingOffset the rendering offset for this sample.
* Currently the only media type that needs this feature is MPEG
* video. Caveat: The offset should be in the track timescale.
* @param isSyncSample the sync/random access flag for this sample.
* @param dependencyFlags bitmask specifying sample dependency characteristics.
* See #MP4SampleDependencyType for bit constants.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*
* @see MP4AddTrack().
*/
MP4V2_EXPORT
bool MP4WriteSampleDependency(
MP4FileHandle hFile,
MP4TrackId trackId,
const uint8_t* pBytes,
uint32_t numBytes,
MP4Duration duration,
MP4Duration renderingOffset,
bool isSyncSample,
uint32_t dependencyFlags );
/** Make a copy of a sample.
*
* MP4CopySample creates a new sample based on an existing sample. Note that
* another copy of the media sample data is created in the file using this
* function. ie. this call is equivalent to MP4ReadSample() followed by
* MP4WriteSample().
*
* Note that is the responsibility of the caller to ensure that the copied
* media sample makes sense in the destination track. eg. copying a video
* sample to an audio track is unlikely to result in anything good happening,
* even copying a sample from video track to another requires that the tracks
* use the same encoding and that issues such as image size are addressed.
*
* @param srcFile source sample file handle.
* @param srcTrackId source sample track id.
* @param srcSampleId source sample id.
* @param dstFile destination file handle for new (copied) sample.
* If the value is #MP4_INVALID_FILE_HANDLE, the copy is created in
* the same file as <b>srcFile</b>.
* @param dstTrackId destination track id for new sample.
* If the value is #MP4_INVALID_TRACK_ID, the the copy is created in
* the same track as the <b>srcTrackId</b>.
* @param dstSampleDuration duration in track timescale for new sample.
* If the value is #MP4_INVALID_DURATION, then the duration of
* the source sample is used.
*
* @return On success, thew id of the new sample.
* On error, #MP4_INVALID_SAMPLE_ID.
*
* @see MP4ReadSample().
* @see MP4WriteSample().
*/
MP4V2_EXPORT
bool MP4CopySample(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
MP4SampleId srcSampleId,
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID),
MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION) );
/** Make a copy of a sample.
*
* MP4EncAndCopySample is similar to MP4CopySample() except that it
* offers an encryption hook to the caller.
*
* @param srcFile source sample file handle.
* @param srcTrackId source sample track id.
* @param srcSampleId source sample id.
* @param encfcnp undocumented.
* @param encfcnparam1 undocumented.
* @param dstFile destination file handle for new (copied) sample.
* If the value is #MP4_INVALID_FILE_HANDLE, the copy is created in
* the same file as <b>srcFile</b>.
* @param dstTrackId destination track id for new sample.
* If the value is #MP4_INVALID_TRACK_ID, the the copy is created in
* the same track as the <b>srcTrackId</b>.
* @param dstSampleDuration duration in track timescale for new sample.
* If the value is #MP4_INVALID_DURATION, then the duration of
* the source sample is used.
*
* @return On success, thew id of the new sample.
* On error, #MP4_INVALID_SAMPLE_ID.
*
* @see MP4CopySample().
*/
MP4V2_EXPORT
bool MP4EncAndCopySample(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
MP4SampleId srcSampleId,
encryptFunc_t encfcnp,
uint32_t encfcnparam1,
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID),
MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION) );
/** Not implemented.
*/
MP4V2_EXPORT
bool MP4ReferenceSample(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
MP4SampleId srcSampleId,
MP4FileHandle dstFile,
MP4TrackId dstTrackId,
MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION) );
/** Get size of a track sample.
*
* MP4GetSampleSize returns the size in bytes of the specified sample from the
* the specified track.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param sampleId id of sample for operation. Caveat: the first sample has
* id <b>1</b>, not <b>0</b>.
*
* @return On success the sample size in bytes. On error, <b>0</b>.
*/
MP4V2_EXPORT
uint32_t MP4GetSampleSize(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4SampleId sampleId);
/** Get the maximum sample size of a track.
*
* MP4GetTrackMaxSampleSize returns the maximum size in bytes of all the
* samples in the specified track.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
*
* @return On success, the maximum sample size in bytes. On error, <b>0</b>.
*
* @see MP4GetSampleSize().
*/
MP4V2_EXPORT
uint32_t MP4GetTrackMaxSampleSize(
MP4FileHandle hFile,
MP4TrackId trackId );
/** Get sample id of a specified time.
*
* MP4GetSampleIdFromTime returns the sample id of the track sample in which
* the specified time occurs.
*
* The specified time should be in the track timescale.
*
* It is wise to use MP4GetSampleTime() with the returned sample id so one
* can adjust for any difference between the specified time and the actual
* start time of the sample.
*
* If the calling application needs a sample that can be accessed randomly
* then the <b>wantSyncSample</b> argument should be set to true. This could
* be the case for a player that is implementing a positioning function and
* needs to be able to start decoding a track from the returned sample id.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param when time in track timescale.
* @param wantSyncSample specifies if the result sample id must correspond
* to a sample whose sync/random access flag is true.
*
* @return On success, the sample id that occurs at the specified time.
* On error, #MP4_INVALID_SAMPLE_ID.
*
* @see MP4ConvertToTrackTimestamp() for how to map a time value to this
* timescale.
*/
MP4V2_EXPORT
MP4SampleId MP4GetSampleIdFromTime(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4Timestamp when,
bool wantSyncSample DEFAULT(false) );
/** Get start time of track sample.
*
* MP4GetSampleTime returns the start time of the specified sample from
* the specified track in the track timescale units.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param sampleId id of sample for operation. Caveat: the first sample has
* id <b>1</b>, not <b>0</b>.
*
* @return On success, sample start time in track timescale units.
* On error, #MP4_INVALID_TIMESTAMP.
*
* @see MP4ConvertFromTrackTimestamp() for how to map this value to another
* timescale.
*/
MP4V2_EXPORT
MP4Timestamp MP4GetSampleTime(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4SampleId sampleId );
/** Get the duration of a track sample.
*
* MP4GetSampleDuration returns the duration of the specified sample from
* the specified track in the track timescale units.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param sampleId id of sample for operation. Caveat: the first sample has
* id <b>1</b>, not <b>0</b>.
*
* @return On success, the sample duration in track timescale units.
* On error, #MP4_INVALID_DURATION.
*
* @see MP4ConvertFromTrackDuration() for how to map this value to another
* timescale.
*/
MP4V2_EXPORT
MP4Duration MP4GetSampleDuration(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4SampleId sampleId );
/** Get the rendering offset of a track sample.
*
* MP4GetSampleRenderingOffset returns the rendering offset of the specified
* sample from the specified track in the track timescale units.
*
* The sample rendering offset is typically zero for all media types other
* than video. For video, encodings such as those defined by MPEG have
* three types of frames: I, P, and B. To increase coding efficiency B
* frames can depend on I or P frames that should be rendered after the B
* frame. However to decode the B frame the I or P frame must already have
* been decoded. This situation is addressed by placing the frames in
* decoding order in the video track, and then setting the rendering offset
* property to indicate when the video frame should actually be rendered to
* the screen. Hence the start time of a sample indicates when it should be
* decoded, the start time plus the rendering offset indicates when it
* should be rendered.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param sampleId id of sample for operation. Caveat: the first sample has
* id <b>1</b>, not <b>0</b>.
*
* @return On success, the rendering offset in track timescale units.
* On error, #MP4_INVALID_DURATION.
*
* @see MP4ConvertFromTrackDuration() for how to map this value to another
* timescale.
*/
MP4V2_EXPORT
MP4Duration MP4GetSampleRenderingOffset(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4SampleId sampleId );
/** Set the rendering offset of a track sample.
*
* MP4SetSampleRenderingOffset sets the rendering offset of the specified
* sample from the specified track in the track timescale units.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param sampleId id of sample for operation. Caveat: the first sample has
* id <b>1</b>, not <b>0</b>.
* @param renderingOffset new offset value in timescale units.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*
* @see MP4ConvertToTrackDuration() for how to map this value from another
* timescale.
* @see MP4GetSampleRenderingOffset() for a description of this sample
* property.
*/
MP4V2_EXPORT
bool MP4SetSampleRenderingOffset(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4SampleId sampleId,
MP4Duration renderingOffset );
/** Get sync/random access state of sample.
*
* MP4GetSampleSync returns the state of the sync/random access flag of
* the specified sample from the specified track.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param sampleId id of sample for operation. Caveat: the first sample has
* id <b>1</b>, not <b>0</b>.
*
* @return <b>1</b> when true, <b>0</b> when false. On error, <b>-1</b>.
*/
MP4V2_EXPORT
int8_t MP4GetSampleSync(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4SampleId sampleId );
/* @} ***********************************************************************/
#endif /* MP4V2_SAMPLE_H */
+163
View File
@@ -0,0 +1,163 @@
#ifndef MP4V2_STREAMING_H
#define MP4V2_STREAMING_H
/**************************************************************************//**
*
* @defgroup mp4_hint MP4v2 Streaming
* @{
*
*****************************************************************************/
MP4V2_EXPORT
bool MP4GetHintTrackRtpPayload(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
char** ppPayloadName DEFAULT(NULL),
uint8_t* pPayloadNumber DEFAULT(NULL),
uint16_t* pMaxPayloadSize DEFAULT(NULL),
char** ppEncodingParams DEFAULT(NULL) );
#define MP4_SET_DYNAMIC_PAYLOAD 0xff
MP4V2_EXPORT
bool MP4SetHintTrackRtpPayload(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
const char* pPayloadName,
uint8_t* pPayloadNumber,
uint16_t maxPayloadSize DEFAULT(0),
const char * encode_params DEFAULT(NULL),
bool include_rtp_map DEFAULT(true),
bool include_mpeg4_esid DEFAULT(true) );
MP4V2_EXPORT
const char* MP4GetSessionSdp(
MP4FileHandle hFile );
MP4V2_EXPORT
bool MP4SetSessionSdp(
MP4FileHandle hFile,
const char* sdpString );
MP4V2_EXPORT
bool MP4AppendSessionSdp(
MP4FileHandle hFile,
const char* sdpString );
MP4V2_EXPORT
const char* MP4GetHintTrackSdp(
MP4FileHandle hFile,
MP4TrackId hintTrackId );
MP4V2_EXPORT
bool MP4SetHintTrackSdp(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
const char* sdpString );
MP4V2_EXPORT
bool MP4AppendHintTrackSdp(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
const char* sdpString );
MP4V2_EXPORT
MP4TrackId MP4GetHintTrackReferenceTrackId(
MP4FileHandle hFile,
MP4TrackId hintTrackId );
MP4V2_EXPORT
bool MP4ReadRtpHint(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
MP4SampleId hintSampleId,
uint16_t* pNumPackets DEFAULT(NULL) );
MP4V2_EXPORT
uint16_t MP4GetRtpHintNumberOfPackets(
MP4FileHandle hFile,
MP4TrackId hintTrackId );
MP4V2_EXPORT
int8_t MP4GetRtpPacketBFrame(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
uint16_t packetIndex );
MP4V2_EXPORT
int32_t MP4GetRtpPacketTransmitOffset(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
uint16_t packetIndex );
MP4V2_EXPORT
bool MP4ReadRtpPacket(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
uint16_t packetIndex,
uint8_t** ppBytes,
uint32_t* pNumBytes,
uint32_t ssrc DEFAULT(0),
bool includeHeader DEFAULT(true),
bool includePayload DEFAULT(true) );
MP4V2_EXPORT
MP4Timestamp MP4GetRtpTimestampStart(
MP4FileHandle hFile,
MP4TrackId hintTrackId );
MP4V2_EXPORT
bool MP4SetRtpTimestampStart(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
MP4Timestamp rtpStart );
MP4V2_EXPORT
bool MP4AddRtpHint(
MP4FileHandle hFile,
MP4TrackId hintTrackId );
MP4V2_EXPORT
bool MP4AddRtpVideoHint(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
bool isBframe DEFAULT(false),
uint32_t timestampOffset DEFAULT(0) );
MP4V2_EXPORT
bool MP4AddRtpPacket(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
bool setMbit DEFAULT(false),
int32_t transmitOffset DEFAULT(0) );
MP4V2_EXPORT
bool MP4AddRtpImmediateData(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
const uint8_t* pBytes,
uint32_t numBytes );
MP4V2_EXPORT
bool MP4AddRtpSampleData(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
MP4SampleId sampleId,
uint32_t dataOffset,
uint32_t dataLength );
MP4V2_EXPORT
bool MP4AddRtpESConfigurationPacket(
MP4FileHandle hFile,
MP4TrackId hintTrackId );
MP4V2_EXPORT
bool MP4WriteRtpHint(
MP4FileHandle hFile,
MP4TrackId hintTrackId,
MP4Duration duration,
bool isSyncSample DEFAULT(true) );
/** @} ***********************************************************************/
#endif /* MP4V2_STREAMING_H */
+506
View File
@@ -0,0 +1,506 @@
#ifndef MP4V2_TRACK_H
#define MP4V2_TRACK_H
/**************************************************************************//**
*
* @defgroup mp4_track MP4v2 Track
* @{
*
*****************************************************************************/
/** Add a user defined track.
*
* MP4AddTrack adds a user defined track to the mp4 file. Care should be
* taken to avoid any of the standardized track type names. A useful
* convention is use only uppercase characters for user defined track types.
* The string should be exactly four characters in length, e.g. "MINE".
*
* Note this should not be used to add any of the known track types defined
* in the MP4 standard (ISO/IEC 14496-1:2001).
*
* @param hFile handle of file for operation.
* @param type specifies the type of track to be added.
* @param timeScale the time scale in ticks per second of the track. Default is 1000.
*
* @return On success, the track-id of new track.
* On failure, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddTrack(
MP4FileHandle hFile,
const char* type,
uint32_t timeScale DEFAULT(MP4_MSECS_TIME_SCALE) );
/** Add an MPEG-4 systems track.
*
* MP4AddSystemsTrack adds an MPEG-4 Systems track to the mp4 file. Note
* this should not be used to add OD or scene tracks, MP4AddODTrack() and
* MP4AddSceneTrack() should be used for those purposes. Other known
* MPEG-4 System track types are:
* @li #MP4_CLOCK_TRACK_TYPE
* @li #MP4_MPEG7_TRACK_TYPE
* @li #MP4_OCI_TRACK_TYPE
* @li #MP4_IPMP_TRACK_TYPE
* @li #MP4_MPEGJ_TRACK_TYPE
*
* @param hFile handle of file for operation.
* @param type specifies the type of track to be added.
*
* @return On success, the track-id of new track.
* On failure, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddSystemsTrack(
MP4FileHandle hFile,
const char* type );
/** Add a object descriptor (OD) track.
*
* MP4AddODTrack adds an object descriptor (aka OD) track to the mp4 file.
* MP4WriteSample() can then be used to add the desired OD commands to the
* track. The burden is currently on the calling application to understand
* OD.
*
* Those wishing to have a simple audio/video scene without understanding
* OD may wish to use MP4MakeIsmaCompliant() to create the minimal OD and
* BIFS information.
*
* @param hFile handle of file for operation.
*
* @return On success, the track-id of new track.
* On failure, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddODTrack(
MP4FileHandle hFile );
/** Add a scene (BIFS) track.
*
* MP4AddSceneTrack adds a scene (aka BIFS) track to the mp4 file.
* MP4WriteSample() can then be used to add the desired BIFS commands to
* the track. The burden is currently on the calling application to
* understand BIFS.
*
* Those wishing to have a simple audio/video scene without understanding
* BIFS may wish to use MP4MakeIsmaCompliant() to create the minimal OD
* and BIFS information.
*
* @param hFile handle of file for operation.
*
* @return On success, the track-id of new track.
* On failure, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddSceneTrack(
MP4FileHandle hFile );
/** Add audio track to mp4 file.
*
* MP4AddAudioTrack adds an audio track to the mp4 file. MP4WriteSample()
* can then be used to add the desired audio samples.
*
* It is recommended that the time scale be set to the sampling frequency
* (eg. 44100 Hz) of the audio so as to preserve the timing information
* accurately.
*
* If the audio encoding uses a fixed duration for each sample that should
* be specified here. If not then the value #MP4_INVALID_DURATION
* should be given for the sampleDuration argument.
*
* @param hFile handle of file for operation.
* @param timeScale the time scale in ticks per second of the track.
* @param sampleDuration the fixed duration for all track samples.
* Caveat: the value should be in track-timescale units.
* @param audioType the audio encoding type.
* See MP4GetTrackEsdsObjectTypeId() for known values.
*
* @return On success, the track-id of the new track.
* On error, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddAudioTrack(
MP4FileHandle hFile,
uint32_t timeScale,
MP4Duration sampleDuration,
uint8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE) );
/** Add ulaw track to mp4 file.
*
* MP4AddULawAudioTrack adds a ulaw track to the mp4 file. MP4WriteSample()
* can then be used to add the desired audio samples.
*
* @param hFile handle of file for operation.
* @param timeScale the time scale in ticks per second of the track.
*
* @return On success, the track-id of the new track.
* On error, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddULawAudioTrack(
MP4FileHandle hFile,
uint32_t timeScale);
/** Add alaw track to mp4 file.
*
* MP4AddALawAudioTrack adds a alaw track to the mp4 file. MP4WriteSample()
* can then be used to add the desired audio samples.
*
* @param hFile handle of file for operation.
* @param timeScale the time scale in ticks per second of the track.
*
* @return On success, the track-id of the new track.
* On error, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddALawAudioTrack(
MP4FileHandle hFile,
uint32_t timeScale);
MP4V2_EXPORT
MP4TrackId MP4AddAC3AudioTrack(
MP4FileHandle hFile,
uint32_t samplingRate,
uint8_t fscod,
uint8_t bsid,
uint8_t bsmod,
uint8_t acmod,
uint8_t lfeon,
uint8_t bit_rate_code );
MP4V2_EXPORT
MP4TrackId MP4AddALACAudioTrack(
MP4FileHandle hFile,
uint32_t samplingRate );
MP4V2_EXPORT
MP4TrackId MP4AddAmrAudioTrack(
MP4FileHandle hFile,
uint32_t timeScale,
uint16_t modeSet,
uint8_t modeChangePeriod,
uint8_t framesPerSample,
bool isAmrWB );
MP4V2_EXPORT
void MP4SetAmrVendor(
MP4FileHandle hFile,
MP4TrackId trackId,
uint32_t vendor );
MP4V2_EXPORT
void MP4SetAmrDecoderVersion(
MP4FileHandle hFile,
MP4TrackId trackId,
uint8_t decoderVersion );
MP4V2_EXPORT
void MP4SetAmrModeSet(
MP4FileHandle hFile,
MP4TrackId trakId,
uint16_t modeSet );
MP4V2_EXPORT
uint16_t MP4GetAmrModeSet(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
MP4TrackId MP4AddHrefTrack(
MP4FileHandle hFile,
uint32_t timeScale,
MP4Duration sampleDuration,
const char* base_url DEFAULT(NULL) );
MP4V2_EXPORT
const char* MP4GetHrefTrackBaseUrl(
MP4FileHandle hFile,
MP4TrackId trackId );
/** Add a video track.
*
* MP4AddVideoTrack adds a video track to the mp4 file. MP4WriteSample()
* can then be used to add the desired video samples.
*
* It is recommended that the time scale be set to 90000 so as to preserve
* the timing information accurately for the range of video frame rates
* commonly in use.
*
* If the video frame rate is to be fixed then the sampleDuration argument
* should be give the appropriate fixed value. If the video frame rate is
* to be variable then the value #MP4_INVALID_DURATION should be
* given for the sampleDuration argument.
*
* @param hFile handle of file for operation.
* @param timeScale the timescale in ticks per second of the track.
* @param sampleDuration specifies fixed sample duration for all track
* samples. Caveat: the value should be in track timescale units.
* @param width specifies the video frame width in pixels.
* @param height specifies the video frame height in pixels.
* @param videoType specifies the video encoding type.
* See MP4GetTrackVideoType() for known values.
*
* @return On success, the track-id of the new track.
* On error, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddVideoTrack(
MP4FileHandle hFile,
uint32_t timeScale,
MP4Duration sampleDuration,
uint16_t width,
uint16_t height,
uint8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE) );
MP4V2_EXPORT
MP4TrackId MP4AddJpegVideoTrack(
MP4FileHandle hFile,
uint32_t timeScale,
MP4Duration sampleDuration,
uint16_t width,
uint16_t height);
MP4V2_EXPORT
MP4TrackId MP4AddH264VideoTrack(
MP4FileHandle hFile,
uint32_t timeScale,
MP4Duration sampleDuration,
uint16_t width,
uint16_t height,
uint8_t AVCProfileIndication,
uint8_t profile_compat,
uint8_t AVCLevelIndication,
uint8_t sampleLenFieldSizeMinusOne );
MP4V2_EXPORT
void MP4AddH264SequenceParameterSet(
MP4FileHandle hFile,
MP4TrackId trackId,
const uint8_t* pSequence,
uint16_t sequenceLen );
MP4V2_EXPORT
void MP4AddH264PictureParameterSet(
MP4FileHandle hFile,
MP4TrackId trackId,
const uint8_t* pPict,
uint16_t pictLen );
MP4V2_EXPORT
void MP4SetH263Vendor(
MP4FileHandle hFile,
MP4TrackId trackId,
uint32_t vendor );
MP4V2_EXPORT
void MP4SetH263DecoderVersion(
MP4FileHandle hFile,
MP4TrackId trackId,
uint8_t decoderVersion );
MP4V2_EXPORT
void MP4SetH263Bitrates(
MP4FileHandle hFile,
MP4TrackId trackId,
uint32_t avgBitrate,
uint32_t maxBitrate );
MP4V2_EXPORT
MP4TrackId MP4AddH263VideoTrack(
MP4FileHandle hFile,
uint32_t timeScale,
MP4Duration sampleDuration,
uint16_t width,
uint16_t height,
uint8_t h263Level,
uint8_t h263Profile,
uint32_t avgBitrate,
uint32_t maxBitrate );
/** Add a hint track.
*
* MP4AddHintTrack adds a hint track to the mp4 file. A hint track is used
* to describe how to send the reference media track over a particular
* network transport. In the case of the IETF RTP protocol, the hint track
* describes how the media data should be placed into packets and any
* media specific protocol headers that should be added.
*
* Typically there is a one to one correspondence between reference media
* track samples and hint track samples. The start time, duration, and
* sync flags are typically the same, however provisions are made for
* deviations from this rule.
*
* The MP4 library provides extensive support for RTP hint tracks. This
* includes a easy to use API to create RTP hint tracks, and read out
* fully constructed RTP packets based on the hint track.
*
* @param hFile handle of file for operation.
* @param refTrackId specifies the reference media track for this hint track.
*
* @return On success, the track-id of the new track.
* On error, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddHintTrack(
MP4FileHandle hFile,
MP4TrackId refTrackId );
MP4V2_EXPORT
MP4TrackId MP4AddTextTrack(
MP4FileHandle hFile,
MP4TrackId refTrackId );
MP4V2_EXPORT
MP4TrackId MP4AddSubtitleTrack(
MP4FileHandle hFile,
uint32_t timescale,
uint16_t width,
uint16_t height );
/** Add a closed caption track.
*
* MP4AddCCTrack adds a closed caption track track to the mp4 file. MP4WriteSample()
* can then be used to add the desired video samples.
*
* @param hFile handle of file for operation.
* @param timeScale the timescale in ticks per second of the track.
* @param width specifies the video frame width in pixels.
* @param height specifies the video frame height in pixels.
*
* @return On success, the track-id of the new track.
* On error, #MP4_INVALID_TRACK_ID.
*/
MP4V2_EXPORT
MP4TrackId MP4AddCCTrack(
MP4FileHandle hFile,
uint32_t timeScale,
uint16_t width,
uint16_t height );
MP4V2_EXPORT
MP4TrackId MP4AddSubpicTrack(
MP4FileHandle hFile,
uint32_t timescale,
uint16_t width,
uint16_t height );
MP4V2_EXPORT
MP4TrackId MP4AddPixelAspectRatio(
MP4FileHandle hFile,
MP4TrackId refTrackId,
uint32_t hSpacing,
uint32_t vSpacing );
MP4V2_EXPORT
MP4TrackId MP4AddCleanAperture(
MP4FileHandle hFile,
MP4TrackId trackId,
uint32_t cleanApertureWidthN, uint32_t cleanApertureWidthD,
uint32_t cleanApertureHeightN, uint32_t cleanApertureHeightD,
uint32_t horizOffN, uint32_t horizOffD,
uint32_t vertOffN, uint32_t vertOffD );
MP4V2_EXPORT
MP4TrackId MP4AddColr(
MP4FileHandle hFile,
MP4TrackId refTrackId,
uint16_t primary,
uint16_t transfer,
uint16_t matrix );
MP4V2_EXPORT
MP4TrackId MP4CloneTrack(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID) );
MP4V2_EXPORT
MP4TrackId MP4CopyTrack(
MP4FileHandle srcFile,
MP4TrackId srcTrackId,
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
bool applyEdits DEFAULT(false),
MP4TrackId dstHintTrackReferenceTrack DEFAULT(MP4_INVALID_TRACK_ID) );
MP4V2_EXPORT
bool MP4DeleteTrack(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
uint32_t MP4GetNumberOfTracks(
MP4FileHandle hFile,
const char* type DEFAULT(NULL),
uint8_t subType DEFAULT(0) );
MP4V2_EXPORT
MP4TrackId MP4FindTrackId(
MP4FileHandle hFile,
uint16_t index,
const char* type DEFAULT(NULL),
uint8_t subType DEFAULT(0) );
MP4V2_EXPORT
uint16_t MP4FindTrackIndex(
MP4FileHandle hFile,
MP4TrackId trackId );
/** Get maximum duration of chunk.
*
* MP4GetTrackDurationPerChunk gets the maximum duration for each chunk.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param duration out value of duration in track timescale units.
*
* return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4GetTrackDurationPerChunk(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4Duration* duration );
/** Set maximum duration of chunk.
*
* MP4SetTrackDurationPerChunk sets the maximum duration for each chunk.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param duration in timescale units.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4SetTrackDurationPerChunk(
MP4FileHandle hFile,
MP4TrackId trackId,
MP4Duration duration );
/**
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4AddTrackReference(
MP4FileHandle hFile,
const char* trefName,
MP4TrackId trackId,
MP4TrackId refTrackId );
MP4V2_EXPORT
bool MP4RemoveAllTrackReferences(
MP4FileHandle hFile,
const char* trefName,
MP4TrackId trackId );
MP4V2_EXPORT
bool MP4AddIPodUUID(
MP4FileHandle hFile,
MP4TrackId trackId );
/** @} ***********************************************************************/
#endif /* MP4V2_TRACK_H */
+337
View File
@@ -0,0 +1,337 @@
#ifndef MP4V2_TRACK_PROP_H
#define MP4V2_TRACK_PROP_H
/**************************************************************************//**
*
* @defgroup mp4_track_prop MP4v2 Track Property
* @{
*
*****************************************************************************/
/* specific track properties */
MP4V2_EXPORT
bool MP4HaveTrackAtom(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* atomname );
/** Get the track type.
*
* MP4GetTrackType gets the type of the track with the specified track id.
*
* Note: the library does not provide a MP4SetTrackType function, the
* track type needs to be specified when the track is created, e.g.
* MP4AddSystemsTrack(MP4_OCI_TRACK_TYPE).
*
* Known track types are:
* @li #MP4_OD_TRACK_TYPE
* @li #MP4_SCENE_TRACK_TYPE
* @li #MP4_AUDIO_TRACK_TYPE
* @li #MP4_VIDEO_TRACK_TYPE
* @li #MP4_HINT_TRACK_TYPE
* @li #MP4_CNTL_TRACK_TYPE
* @li #MP4_TEXT_TRACK_TYPE
* @li #MP4_CLOCK_TRACK_TYPE
* @li #MP4_MPEG7_TRACK_TYPE
* @li #MP4_OCI_TRACK_TYPE
* @li #MP4_IPMP_TRACK_TYPE
* @li #MP4_MPEGJ_TRACK_TYPE
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
*
* @return On success, a string indicating track type. On failure, NULL.
*/
MP4V2_EXPORT
const char* MP4GetTrackType(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
const char* MP4GetTrackMediaDataName(
MP4FileHandle hFile,
MP4TrackId trackId );
/*
* MP4GetTrackMediaDataOriginalFormat is to be used to get the original
* MediaDataName if a track has been encrypted.
*/
MP4V2_EXPORT
bool MP4GetTrackMediaDataOriginalFormat(
MP4FileHandle hFile,
MP4TrackId trackId,
char* originalFormat,
uint32_t buflen );
MP4V2_EXPORT
MP4Duration MP4GetTrackDuration(
MP4FileHandle hFile,
MP4TrackId trackId );
/** Get the time scale of a track.
*
* MP4GetTrackTimeScale returns the time scale of the specified track in
* the mp4 file. The time scale determines the number of clock ticks per
* second for this track.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
*
* @return timescale (ticks per second) of the track in the mp4 file.
*/
MP4V2_EXPORT
uint32_t MP4GetTrackTimeScale(
MP4FileHandle hFile,
MP4TrackId trackId );
/** Set the time scale of a track.
*
* MP4SetTrackTimeScale sets the time scale of the specified track in the
* mp4 file. The time scale determines the number of clock ticks per
* second for this track.
*
* Typically this value is set once when the track is created. However
* this call can be used to modify the value if that is desired. Since
* track sample durations are expressed in units of the track time scale,
* any change to the time scale value will effect the real time duration
* of the samples.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param timeScale desired time scale for the track.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4SetTrackTimeScale(
MP4FileHandle hFile,
MP4TrackId trackId,
uint32_t value );
/** Get ISO-639-2/T language code of a track.
* The language code is a 3-char alpha code consisting of lower-case letters.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param code buffer to hold 3-char+null (4-bytes total).
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4GetTrackLanguage(
MP4FileHandle hFile,
MP4TrackId trackId,
char* code );
/** Set ISO-639-2/T language code of a track.
* The language code is a 3-char alpha code consisting of lower-case letters.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
* @param code 3-char language code.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4SetTrackLanguage(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* code );
/** Get track name.
*
* MP4GetTrackName gets the name of the track via udta.name property.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4GetTrackName(
MP4FileHandle hFile,
MP4TrackId trackId,
char** name );
/** Set track name.
*
* MP4SetTrackName sets the name of the track via udta.name property.
* The udta atom is created if needed.
*
* @param hFile handle of file for operation.
* @param trackId id of track for operation.
*
* @return <b>true</b> on success, <b>false</b> on failure.
*/
MP4V2_EXPORT
bool MP4SetTrackName(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* name );
MP4V2_EXPORT
uint8_t MP4GetTrackAudioMpeg4Type(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
uint8_t MP4GetTrackEsdsObjectTypeId(
MP4FileHandle hFile,
MP4TrackId trackId );
/* returns MP4_INVALID_DURATION if track samples do not have a fixed duration */
MP4V2_EXPORT
MP4Duration MP4GetTrackFixedSampleDuration(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
uint32_t MP4GetTrackBitRate(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
bool MP4GetTrackVideoMetadata(
MP4FileHandle hFile,
MP4TrackId trackId,
uint8_t** ppConfig,
uint32_t* pConfigSize );
MP4V2_EXPORT
bool MP4GetTrackESConfiguration(
MP4FileHandle hFile,
MP4TrackId trackId,
uint8_t** ppConfig,
uint32_t* pConfigSize );
MP4V2_EXPORT
bool MP4SetTrackESConfiguration(
MP4FileHandle hFile,
MP4TrackId trackId,
const uint8_t* pConfig,
uint32_t configSize );
/* h264 information routines */
MP4V2_EXPORT
bool MP4GetTrackH264ProfileLevel(
MP4FileHandle hFile,
MP4TrackId trackId,
uint8_t* pProfile,
uint8_t* pLevel );
MP4V2_EXPORT
bool MP4GetTrackH264SeqPictHeaders(
MP4FileHandle hFile,
MP4TrackId trackId,
uint8_t*** pSeqHeaders,
uint32_t** pSeqHeaderSize,
uint8_t*** pPictHeader,
uint32_t** pPictHeaderSize );
MP4V2_EXPORT
bool MP4GetTrackH264LengthSize(
MP4FileHandle hFile,
MP4TrackId trackId,
uint32_t* pLength );
MP4V2_EXPORT
MP4SampleId MP4GetTrackNumberOfSamples(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
uint16_t MP4GetTrackVideoWidth(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
uint16_t MP4GetTrackVideoHeight(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
double MP4GetTrackVideoFrameRate(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
int MP4GetTrackAudioChannels(
MP4FileHandle hFile,
MP4TrackId trackId );
MP4V2_EXPORT
bool MP4IsIsmaCrypMediaTrack(
MP4FileHandle hFile,
MP4TrackId trackId );
/* generic track properties */
MP4V2_EXPORT
bool MP4HaveTrackAtom(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* atomName );
MP4V2_EXPORT
bool MP4GetTrackIntegerProperty(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* propName,
uint64_t* retvalue );
MP4V2_EXPORT
bool MP4GetTrackFloatProperty(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* propName,
float* ret_value );
MP4V2_EXPORT
bool MP4GetTrackStringProperty(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* propName,
const char** retvalue );
MP4V2_EXPORT
bool MP4GetTrackBytesProperty(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* propName,
uint8_t** ppValue,
uint32_t* pValueSize );
MP4V2_EXPORT
bool MP4SetTrackIntegerProperty(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* propName,
int64_t value );
MP4V2_EXPORT
bool MP4SetTrackFloatProperty(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* propName,
float value );
MP4V2_EXPORT
bool MP4SetTrackStringProperty(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* propName,
const char* value );
MP4V2_EXPORT
bool MP4SetTrackBytesProperty(
MP4FileHandle hFile,
MP4TrackId trackId,
const char* propName,
const uint8_t* pValue,
uint32_t valueSize);
/** @} ***********************************************************************/
#endif /* MP4V2_TRACK_PROP_H */