MP4v2
file.h
1#ifndef MP4V2_FILE_H
2#define MP4V2_FILE_H
3
4/**************************************************************************/
12#define MP4_CREATE_64BIT_DATA 0x01
14#define MP4_CREATE_64BIT_TIME 0x02
16#define MP4_CLOSE_DO_NOT_COMPUTE_BITRATE 0x01
17
19typedef enum MP4FileMode_e
20{
26
40typedef struct MP4FileProvider_s
41{
42 void* ( *open )( const char* name, MP4FileMode mode );
43 int ( *seek )( void* handle, int64_t pos );
44 int ( *read )( void* handle, void* buffer, int64_t size, int64_t* nin, int64_t reserved );
45 int ( *write )( void* handle, const void* buffer, int64_t size, int64_t* nout, int64_t reserved );
46 int ( *close )( void* handle );
48
59typedef struct MP4IOCallbacks_s
60{
61 int64_t ( *size )( void* handle );
62 int ( *seek )( void* handle, int64_t pos );
63 int ( *read )( void* handle, void* buffer, int64_t size, int64_t* nin );
64 int ( *write )( void* handle, const void* buffer, int64_t size, int64_t* nout );
65 int ( *truncate )( void* handle, int64_t size );
67
78MP4V2_EXPORT
80 MP4FileHandle hFile,
81 uint32_t flags DEFAULT(0) );
82
106MP4V2_EXPORT
107MP4FileHandle MP4Create(
108 const char* fileName,
109 uint32_t flags DEFAULT(0) );
110
138MP4V2_EXPORT
139MP4FileHandle MP4CreateEx(
140 const char* fileName,
141 uint32_t flags DEFAULT(0),
142 int add_ftyp DEFAULT(1),
143 int add_iods DEFAULT(1),
144 char* majorBrand DEFAULT(0),
145 uint32_t minorVersion DEFAULT(0),
146 char** compatibleBrands DEFAULT(0),
147 uint32_t compatibleBrandsCount DEFAULT(0) );
148
177MP4V2_EXPORT
178MP4FileHandle MP4CreateCallbacks(
179 const MP4IOCallbacks* callbacks,
180 void* handle DEFAULT(NULL),
181 uint32_t flags DEFAULT(0));
182
213MP4V2_EXPORT
215 const MP4IOCallbacks* callbacks,
216 void* handle DEFAULT(NULL),
217 uint32_t flags DEFAULT(0),
218 int add_ftyp DEFAULT(1),
219 int add_iods DEFAULT(1),
220 char* majorBrand DEFAULT(0),
221 uint32_t minorVersion DEFAULT(0),
222 char** compatibleBrands DEFAULT(0),
223 uint32_t compatibleBrandsCount DEFAULT(0) );
224
244MP4V2_EXPORT
246 MP4FileHandle hFile,
247 bool dumpImplicits DEFAULT(0) );
248
286MP4V2_EXPORT
288 const char* fileName,
289 MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID) );
290
298MP4V2_EXPORT
299const char* MP4GetFilename(
300 MP4FileHandle hFile );
301
335MP4V2_EXPORT
337 MP4FileHandle hFile,
338 MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID) );
339
360MP4V2_EXPORT
361MP4FileHandle MP4Modify(
362 const char* fileName,
363 uint32_t flags DEFAULT(0) );
364
392MP4V2_EXPORT
393MP4FileHandle MP4ModifyCallbacks(
394 const MP4IOCallbacks* callbacks,
395 void* handle DEFAULT(NULL),
396 uint32_t flags DEFAULT(0) );
397
439MP4V2_EXPORT
441 const char* fileName,
442 const char* newFileName DEFAULT(NULL) );
443
461MP4V2_EXPORT
462MP4FileHandle MP4Read(
463 const char* fileName );
464
490MP4V2_EXPORT
491MP4FileHandle MP4ReadProvider(
492 const char* fileName,
493 const MP4FileProvider* fileProvider DEFAULT(NULL) );
494
517MP4V2_EXPORT
518MP4FileHandle MP4ReadCallbacks(
519 const MP4IOCallbacks* callbacks,
520 void* handle DEFAULT(NULL) );
521
524#endif /* MP4V2_FILE_H */
bool MP4Dump(MP4FileHandle hFile, bool dumpImplicits=0)
Dump mp4 file contents as ASCII either to stdout or the log callback (see MP4SetLogCallback())
MP4FileHandle MP4CreateCallbacksEx(const MP4IOCallbacks *callbacks, void *handle=NULL, uint32_t flags=0, int add_ftyp=1, int add_iods=1, char *majorBrand=0, uint32_t minorVersion=0, char **compatibleBrands=0, uint32_t compatibleBrandsCount=0)
Create a new mp4 file with extended options using an I/O callbacks structure.
MP4FileHandle MP4Modify(const char *fileName, uint32_t flags=0)
Modify an existing mp4 file.
void MP4Close(MP4FileHandle hFile, uint32_t flags=0)
Close an mp4 file.
MP4FileHandle MP4Read(const char *fileName)
Read an existing mp4 file.
char * MP4FileInfo(const char *fileName, MP4TrackId trackId=MP4_INVALID_TRACK_ID)
Return a textual summary of an mp4 file.
struct MP4IOCallbacks_s MP4IOCallbacks
Structure of functions implementing custom I/O callbacks.
bool MP4Optimize(const char *fileName, const char *newFileName=NULL)
Optimize the layout of an mp4 file.
MP4FileHandle MP4ModifyCallbacks(const MP4IOCallbacks *callbacks, void *handle=NULL, uint32_t flags=0)
Modify an existing mp4 file using an I/O callbacks structure.
char * MP4Info(MP4FileHandle hFile, MP4TrackId trackId=MP4_INVALID_TRACK_ID)
Return a textual summary of an mp4 file.
MP4FileHandle MP4ReadProvider(const char *fileName, const MP4FileProvider *fileProvider=NULL)
Read an existing mp4 file.
MP4FileMode_e
Enumeration of file modes for custom file provider.
Definition: file.h:20
MP4FileHandle MP4ReadCallbacks(const MP4IOCallbacks *callbacks, void *handle=NULL)
Read an existing mp4 file using an I/O callbacks structure.
struct MP4FileProvider_s MP4FileProvider
Structure of functions implementing custom file provider.
MP4FileHandle MP4CreateCallbacks(const MP4IOCallbacks *callbacks, void *handle=NULL, uint32_t flags=0)
Create a new mp4 file using an I/O callbacks structure.
MP4FileHandle MP4Create(const char *fileName, uint32_t flags=0)
Create a new mp4 file.
MP4FileHandle MP4CreateEx(const char *fileName, uint32_t flags=0, int add_ftyp=1, int add_iods=1, char *majorBrand=0, uint32_t minorVersion=0, char **compatibleBrands=0, uint32_t compatibleBrandsCount=0)
Create a new mp4 file with extended options.
const char * MP4GetFilename(MP4FileHandle hFile)
Accessor for the filename associated with a file handle.
enum MP4FileMode_e MP4FileMode
Enumeration of file modes for custom file provider.
@ FILEMODE_UNDEFINED
undefined
Definition: file.h:21
@ FILEMODE_MODIFY
file may be read/written
Definition: file.h:23
@ FILEMODE_READ
file may be read
Definition: file.h:22
@ FILEMODE_CREATE
file will be created/truncated for read/write
Definition: file.h:24
#define MP4_INVALID_TRACK_ID
Constant: invalid MP4TrackId.
Definition: general.h:49
Structure of functions implementing custom file provider.
Definition: file.h:41
Structure of functions implementing custom I/O callbacks.
Definition: file.h:60