#include <mp4v2/mp4v2.h>
#include <stdio.h>
static void* my_open(
const char* name,
MP4FileMode mode )
{
const char* om;
switch( mode ) {
default:
om = "rb";
break;
}
return fopen( name, om );
}
static int my_seek( void* handle, int64_t pos )
{
return fseeko( (FILE*)handle, pos, SEEK_SET ) != 0;
}
static int my_read( void* handle, void* buffer, int64_t size, int64_t* nin, int64_t maxChunkSize )
{
if( fread( buffer, size, 1, (FILE*)handle ) != 1)
return 1;
*nin = size;
return 0;
}
static int my_write( void* handle, const void* buffer, int64_t size, int64_t* nout, int64_t maxChunkSize )
{
if( fwrite( buffer, size, 1, (FILE*)handle ) != 1)
return 1;
*nout = size;
return 0;
}
static int my_close( void* handle )
{
return fclose( (FILE*)handle ) != 0;
}
int main( int argc, char** argv )
{
if( argc != 2 ) {
printf( "usage: %s file.mp4\n", argv[0] );
return 1;
}
provider.
write = my_write;
provider.
close = my_close;
printf( "MP4Read failed\n" );
return 1;
}
printf( "MP4Dump failed\n" );
return 0;
}
bool MP4Dump(MP4FileHandle hFile, bool dumpImplicits=0)
Dump mp4 file contents as ASCII either to stdout or the log callback (see MP4SetLogCallback)
void MP4Close(MP4FileHandle hFile, uint32_t flags=0)
Close an mp4 file.
MP4FileHandle MP4ReadProvider(const char *fileName, const MP4FileProvider *fileProvider=NULL)
Read an existing mp4 file.
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_FILE_HANDLE
Constant: invalid MP4FileHandle.
Definition general.h:48
Structure of functions implementing custom file provider.
Definition file.h:37