First public contribution.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <3gplibrary/mp4config.h>
20 #include <3gplibrary/mp4lib.h>
22 #include "filewriter.h" /* Async buffering filewriter */
23 #include "metadatafilewriter.h" /* Async buffering filewriter */
24 #include "asyncfileparser.h" /*Async file reader for parsing */
26 #define ATOMTYPE_FTYP 0x66747970 /* 'ftyp' */
27 #define ATOMTYPE_MOOV 0x6d6f6f76 /* 'moov' */
28 #define ATOMTYPE_MDAT 0x6d646174 /* 'mdat' */
29 #define ATOMTYPE_FREE 0x66726565 /* 'free' */
30 #define ATOMTYPE_SKIP 0x736b6970 /* 'skip' */
31 #define ATOMTYPE_UDTA 0x75647461 /* 'udta' */
32 #define ATOMTYPE_MVHD 0x6d766864 /* 'mvhd' */
33 #define ATOMTYPE_IODS 0x696f6473 /* 'iods' */
34 #define ATOMTYPE_TRAK 0x7472616b /* 'trak' */
35 #define ATOMTYPE_TKHD 0x746b6864 /* 'tkhd' */
36 #define ATOMTYPE_MDIA 0x6d646961 /* 'mdia' */
37 #define ATOMTYPE_MDHD 0x6d646864 /* 'mdhd' */
38 #define ATOMTYPE_HDLR 0x68646c72 /* 'hdlr' */
39 #define ATOMTYPE_MINF 0x6d696e66 /* 'minf' */
40 #define ATOMTYPE_VMHD 0x766d6864 /* 'vmhd' */
41 #define ATOMTYPE_SMHD 0x736d6864 /* 'smhd' */
42 #define ATOMTYPE_DINF 0x64696e66 /* 'dinf' */
43 #define ATOMTYPE_DREF 0x64726566 /* 'dref' */
44 #define ATOMTYPE_TREF 0x74726566 /* 'tref' */
45 #define ATOMTYPE_STBL 0x7374626c /* 'stbl' */
46 #define ATOMTYPE_STTS 0x73747473 /* 'stts' */
47 #define ATOMTYPE_CTTS 0x63747473 /* 'ctts' */
48 #define ATOMTYPE_STSS 0x73747373 /* 'stss' */
49 #define ATOMTYPE_STSD 0x73747364 /* 'stsd' */
50 #define ATOMTYPE_STSZ 0x7374737a /* 'stsz' */
51 #define ATOMTYPE_STZ2 0x73747a32 /* 'stz2' */
52 #define ATOMTYPE_STSC 0x73747363 /* 'stsc' */
53 #define ATOMTYPE_STCO 0x7374636f /* 'stco' */
54 #define ATOMTYPE_CO64 0x636f3634 /* 'co64' */
55 #define ATOMTYPE_MP4V 0x6d703476 /* 'mp4v' */
56 #define ATOMTYPE_MP4A 0x6d703461 /* 'mp4a' */
57 #define ATOMTYPE_MP4S 0x6d703473 /* 'mp4s' */
58 #define ATOMTYPE_S263 0x73323633 /* 's263' */
59 #define ATOMTYPE_D263 0x64323633 /* 'd263' */
60 #define ATOMTYPE_BITR 0x62697472 /* 'bitr' */
61 #define ATOMTYPE_SAMR 0x73616d72 /* 'samr' */
62 #define ATOMTYPE_SAWB 0x73617762 /* 'sawb' */
63 #define ATOMTYPE_DAMR 0x64616d72 /* 'damr' */
64 #define ATOMTYPE_ESD 0x65736473 /* 'esds' */
65 #define ATOMTYPE_URL 0x75726c20 /* 'url ' */
66 #define ATOMTYPE_URN 0x75726e20 /* 'urn ' */
67 #define ATOMTYPE_UUID 0x75756964 /* 'uuid' */
68 #define ATOMTYPE_EDTS 0x65647473 /* 'edts' */
69 #define ATOMTYPE_META 0x6d657461 /* 'meta' */
71 #define ATOMTYPE_AVCC 0x61766343 /* 'avcC' */
72 #define ATOMTYPE_BTRT 0x62747274 /* 'btrt' */
73 #define ATOMTYPE_AVC1 0x61766331 /* 'avc1' */
74 #define ATOMTYPE_M4DS 0x6d346473 /* 'm4ds' */
75 #define ATOMTYPE_SDTP 0x73647470 /* 'sdtp' */
76 #define ATOMTYPE_AVCP 0x61766370 /* 'avcp' */
77 /* QCELP 13K Additions */
78 #define ATOMTYPE_SQCP 0x73716370 /* 'sqcp' */
79 #define ATOMTYPE_DQCP 0x64716370 /* 'dqcp' */
81 #define ATOMTYPE_ID32 0x49443332 /* 'ID32' */
83 #define HANDLERTYPE_ODSM 0x6f64736d /* 'odsm' */
84 #define HANDLERTYPE_VIDE 0x76696465 /* 'vide' */
85 #define HANDLERTYPE_SOUN 0x736f756e /* 'soun' */
89 #define FTYP_SIZE 24 /* Size of FTYP box in bytes */
91 #define READBUFSIZE 8192 /* Size of file reading buffer */
92 #define WRITEBUFSIZE 2048 /* Size of file writing buffer */
94 #define BLOCK_LIMIT 200 /* Max number of metadata blocks to keep in memory */
96 #define MAXSAMPLESPERSECOND 150 /* magic number used to try validate input data to parser from possibly corrupted file */
99 #define METADATAFILE_VIDEO_STTS_SAMPLE_COUNT 0
100 #define METADATAFILE_VIDEO_STTS_SAMPLE_DELTA 1
101 #define METADATAFILE_VIDEO_STSZ_ENTRY_SIZE 2
102 #define METADATAFILE_VIDEO_STCO_CHUNK_OFFSET 3
103 #define METADATAFILE_VIDEO_STSS_SAMPLE_NUMBER 4
104 #define METADATAFILE_AUDIO_STTS_SAMPLE_COUNT 5
105 #define METADATAFILE_AUDIO_STTS_SAMPLE_DELTA 6
106 #define METADATAFILE_AUDIO_STSZ_ENTRY_SIZE 7
107 #define METADATAFILE_AUDIO_STCO_CHUNK_OFFSET 8
108 #define METADATAFILE_VIDEO_SDTP_SAMPLE_DEPENDENCY 9
110 /* Multiple Sample Entry Inclusion */
111 #define STSDMAXSAMPLEENTRYCOUNT 10 /* defined the maximum number of sample entried allowed in a Sample Description Box */
114 typedef struct atomHeader
119 mp4_u8 extendedType[16];
125 typedef struct fileTypeAtom
129 mp4_u32 minorVersion;
130 mp4_u32 *compatibleBrands;
134 typedef struct movieHeaderAtom
137 mp4_u32 creationTime;
138 mp4_u32 modificationTime;
142 mp4_u64 creationTime64;
143 mp4_u64 modificationTime64;
148 typedef struct objectDescriptorAtom
152 mp4_u32 sizeOfInstance;
154 mp4_u8 ODProfileLevelIndication;
155 mp4_u8 SceneProfileLevelIndication;
156 mp4_u8 AudioProfileLevelIndication;
157 mp4_u8 VisualProfileLevelIndication;
158 mp4_u8 GraphicsProfileLevelIndication;
159 } objectDescriptorAtom;
162 typedef struct trackHeaderAtom
165 mp4_u32 creationTime;
166 mp4_u32 modificationTime;
170 mp4_u64 creationTime64;
171 mp4_u64 modificationTime64;
180 typedef struct mediaHeaderAtom
183 mp4_u32 creationTime;
184 mp4_u32 modificationTime;
187 mp4_u64 creationTime64;
188 mp4_u64 modificationTime64;
193 typedef struct handlerAtom
201 typedef struct dataEntryURLAtom
207 typedef struct dataEntryURNAtom
213 typedef struct dataReferenceAtom
217 dataEntryURLAtom *url;
218 dataEntryURNAtom *urn;
222 typedef struct dataInformationAtom
225 dataReferenceAtom *dref;
226 } dataInformationAtom;
229 typedef struct timeToSampleAtom
233 mp4_u32 *sampleCount;
234 mp4_i32 *sampleDelta;
238 typedef struct compositionTimeToSampleAtom
242 mp4_u32 *sampleCount;
243 mp4_u32 *sampleOffset;
244 } compositionTimeToSampleAtom;
247 typedef struct ESDAtom
254 mp4_u16 dependsOnESID;
258 mp4_u8 decConfDescrTag;
259 mp4_u32 decConfDescrSize;
260 mp4_u8 objectTypeIndication;
262 mp4_u32 bufferSizeDB;
265 mp4_u8 decSpecificInfoTag;
266 mp4_u32 decSpecificInfoSize;
267 mp4_u8 *decSpecificInfo;
271 typedef struct visualSampleEntry
274 mp4_u16 dataReferenceIndex;
281 typedef struct audioSampleEntry
284 mp4_u16 dataReferenceIndex;
290 typedef struct mpegSampleEntry
293 mp4_u16 dataReferenceIndex;
298 typedef struct bitrateAtom
306 typedef struct h263SpecificAtom
310 mp4_u8 decoderVersion;
317 typedef struct h263SampleEntry
320 mp4_u16 dataReferenceIndex;
323 h263SpecificAtom *d263;
327 typedef struct amrDecSpecStruc
331 mp4_u8 decoderVersion;
333 mp4_u8 modeChangePeriod;
334 mp4_u8 framesPerSample;
338 typedef struct amrSampleEntry
341 mp4_u16 dataReferenceIndex;
343 amrDecSpecStruc *damr;
346 typedef struct avcConfigurationAtom
350 mp4_u32 avcConfigSize;
351 } avcConfigurationAtom;
353 typedef struct mpeg4BitrateAtom
356 mp4_u32 bufferSizeDB;
361 typedef struct mpeg4ExtensionDescriptorsAtom
366 } mpeg4ExtensionDescriptorsAtom;
368 typedef struct avcSampleEntry
371 mp4_u16 dataReferenceIndex;
374 avcConfigurationAtom *avcc;
375 mpeg4BitrateAtom *btrt;
376 mpeg4ExtensionDescriptorsAtom *m4ds;
379 typedef struct qcelpDecSpecStruc
383 mp4_u8 decoderVersion;
384 mp4_u8 framesPerSample;
387 typedef struct qcelpSampleEntry
390 mp4_u16 dataReferenceIndex;
392 qcelpDecSpecStruc *dqcp;
395 typedef struct avcParameterSampleEntry
398 } avcParameterSampleEntry;
400 typedef struct sampleDescriptionAtom
404 visualSampleEntry *mp4v[STSDMAXSAMPLEENTRYCOUNT];
405 audioSampleEntry *mp4a[STSDMAXSAMPLEENTRYCOUNT];
406 mpegSampleEntry *mp4s[STSDMAXSAMPLEENTRYCOUNT];
407 h263SampleEntry *s263[STSDMAXSAMPLEENTRYCOUNT];
408 amrSampleEntry *samr[STSDMAXSAMPLEENTRYCOUNT];
409 amrSampleEntry *sawb[STSDMAXSAMPLEENTRYCOUNT];
411 avcSampleEntry *avc1[STSDMAXSAMPLEENTRYCOUNT];
412 /* QCELP 13K addition */
413 qcelpSampleEntry *sqcp[STSDMAXSAMPLEENTRYCOUNT];
414 avcParameterSampleEntry *avcp[STSDMAXSAMPLEENTRYCOUNT];
415 } sampleDescriptionAtom;
418 typedef struct sampleSizeAtom
427 typedef struct sampleToChunkAtom
432 mp4_u32 *samplesPerChunk;
433 mp4_u32 *sampleDescriptionIndex;
437 typedef struct chunkOffsetAtom
441 mp4_u32 *chunkOffset;
444 typedef struct chunkOffset64Atom
448 mp4_u64 *chunkOffset;
452 typedef struct syncSampleAtom
456 mp4_u32 *sampleNumber;
460 typedef struct shadowSyncSampleAtom
463 } shadowSyncSampleAtom;
465 typedef struct sampleDependency
468 mp4_u8 sIsDependentOn;
469 mp4_u8 sHasRedundancy;
472 typedef struct sampleDependencyAtom
476 sampleDependency *dep;
477 } sampleDependencyAtom;
479 typedef struct sampleTableAtom
482 timeToSampleAtom *stts;
483 compositionTimeToSampleAtom *ctts;
484 sampleDescriptionAtom *stsd;
485 sampleSizeAtom *stsz;
486 sampleToChunkAtom *stsc;
487 mp4_bool is32BitOffsets;
490 chunkOffsetAtom *stco;
491 chunkOffset64Atom *stco64;
493 syncSampleAtom *stss;
494 shadowSyncSampleAtom *stsh;
495 sampleDependencyAtom *sdtp;
499 typedef struct videoMediaHeaderAtom
502 } videoMediaHeaderAtom;
505 typedef struct soundMediaHeaderAtom
508 } soundMediaHeaderAtom;
511 typedef struct mediaInformationAtom
514 videoMediaHeaderAtom *vmhd;
515 soundMediaHeaderAtom *smhd;
516 dataInformationAtom *dinf;
517 sampleTableAtom *stbl;
518 } mediaInformationAtom;
521 typedef struct mediaAtom
524 mediaHeaderAtom *mdhd;
526 mediaInformationAtom *minf;
530 typedef struct trackReferenceAtom
533 } trackReferenceAtom;
536 typedef struct editListContainerAtom
539 } editListContainerAtom;
542 typedef struct copyrightAtom
547 typedef struct userDataAtom
550 mp4_u64 atomcontentloc; //used for parsing
551 mp4_u32 atomcontentsize; //used for parsing and composing
552 mp4_u8 *contentdata; //used for composing
555 typedef struct trackAtom
558 trackHeaderAtom *tkhd;
559 trackReferenceAtom *tref;
560 editListContainerAtom *edts;
565 typedef struct ID32Atom
568 mp4_u64 atomcontentloc;
569 mp4_u16 language; // top bit is padding, remaining 15 bits is Packed ISO-639-2/T language code
572 typedef struct metaAtom
579 typedef struct movieAtom
582 movieHeaderAtom *mvhd;
583 trackAtom *trakAudio; // audio
584 trackAtom *trakVideo; // video
585 objectDescriptorAtom *iods;
591 typedef struct mediaDataAtom
598 typedef struct sampleTable
600 mp4_u32 currentChunk;
602 /* Decoding time to sample */
603 mp4_u32 sttsEntryCount;
604 mp4_u32 *sttsSampleCount;
605 mp4_u32 *sttsSampleDelta;
606 mp4_u32 sttsMaxEntryCount;
607 mp4_u32 sttsCurrentEntryCount;
610 mp4_u32 stszSampleSize;
611 mp4_u32 stszSampleCount;
612 mp4_u32 *stszEntrySize;
613 mp4_u32 stszMaxSampleCount;
614 mp4_u32 stszCurrentSampleCount;
616 /* Sample to chunk */
617 mp4_u32 stscEntryCount;
618 mp4_u32 *stscFirstChunk;
619 mp4_u32 *stscSamplesPerChunk;
620 mp4_u32 *stscSampleDescriptionIndex;
621 mp4_u32 stscMaxEntryCount;
622 mp4_u32 stscCurrentEntryCount;
625 mp4_u32 stcoEntryCount;
626 mp4_u64 *stcoChunkOffset;
627 mp4_u32 stcoMaxEntryCount;
628 mp4_u32 stcoCurrentEntryCount;
629 mp4_bool stcoNeed64Bits;
632 mp4_u32 stssEntryCount;
633 mp4_u32 *stssSampleNumber;
634 mp4_u32 stssMaxEntryCount;
635 mp4_u32 stssCurrentEntryCount;
636 /* Sample Dependency */
637 mp4_u32 sdtpEntryCount;
638 mp4_u8 *sdtpSampleDependency;
639 mp4_u32 sdtpMaxEntryCount;
640 mp4_u32 sdtpCurrentEntryCount;
644 typedef struct MP4HandleStruct
646 mp4_u8 sourceType; /* Determines the type of the source file (CAF or RFile64) */
647 void *file; /* FILE * of possible file */
648 void *fs; /* File server */
649 void *rfile; /* File handle */
650 ContentAccess::CData *cfile; /* used when reading via the CAF and not the file based interfaces */
651 mp4_i32 cafError; /* variable to store possible CAF error to be reported to client */
652 void *tmpfile; /* FILE * of temporary output file */
653 void *metaDataFile[NUM_MDF]; /* File handles for metadata files */
654 MP4FileName metaDataFileName[NUM_MDF]; /* Names of the temporary meta data files */
655 MP4FileName fileName; /* Name of the file */
656 MP4FileName tmpFileName; /* Name of the temporary file */
657 mp4_u64 bytesInTmpFile; /* Number of bytes in temporary file */
658 mp4_u64 mediaDataBytes; /* Number of media data bytes */
659 mp4_bool ftypWritten; /* Has FTYP been written */
660 mp4_u32 flags; /* Composing flags */
661 mp4_u32 type; /* Type of audio/video */
662 list_s *mem; /* Memory list */
663 mp4_u32 position; /* Current position in memory */
664 mp4_u32 absPosition; /* Current absolute position in memory */
665 mp4_u64 lastAccessedPosInFile; /* Last accessed position in a file */
666 mp4_u8 *buf; /* Temporary buffer space */
667 mp4_u8 *diskReadBuf; /* Memory for file buffering */
668 mp4_u32 diskReadPos; /* Reading position in the file */
669 mp4_u64 diskReadBufStart; /* Position of the start of the buffer */
670 mp4_u32 diskReadBufPos; /* Reading position inside buffer */
671 mp4_u32 diskReadSize; /* Number of bytes in buffer */
672 mp4_u8 *diskWriteBuf; /* Memory for file buffering */
673 mp4_bool ftypRead; /* FTYP atom has been read */
674 fileTypeAtom *ftyp; /* Pointer to file type atom structure */
675 mp4_bool metaDataComplete; /* Metadata has been completeley read */
676 movieAtom *moov; /* Pointer to movie atom structure */
677 mp4_u32 videoSampleNum; /* Current video sample number */
678 mp4_u64 videoFrameOffset; /* Absolute position of current video frame */
679 mp4_u32 videoFrameSize; /* Size of current video frame in bytes */
680 mp4_bool videoLast; /* Has last video sample been read */
681 mp4_u32 videoTimeScale; /* Video timescale */
682 mp4_u64 videoDuration; /* Duration of video when composing */
683 mp4_u16 videoWidth; /* Video image width */
684 mp4_u16 videoHeight; /* Video image height */
685 mp4_u32 videoMaxBitrate; /* MPEG-4 video maximum bitrate */
686 mp4_u32 videoAvgBitrate; /* MPEG-4 video average bitrate */
687 mp4_u8 *videoDecSpecificInfo; /* MPEG-4 video DecoderSpecificInfo */
688 mp4_u32 videoDecSpecificInfoSize; /* MPEG-4 video DecoderSpecificInfo size in bytes */
689 sampleTable *videoSampleTable; /* Video sample table */
690 mp4_u8 videoLevel; /* Video codec level, default is H.263 level 10 */
691 mp4_u32 audioSampleNum; /* Current audio sample number */
692 mp4_u32 audioSampleSize; /* Size of current audio sample in bytes */
693 mp4_u64 audioSampleOffset; /* Absolute position of current audio frame (in MP4 file) */
694 mp4_u32 audioFrameCount; /* Number of audio frames when composing */
695 mp4_u32 audioTimeScale; /* Audio timescale */
696 mp4_u64 audioDuration; /* Duration of audio when composing */
697 mp4_bool audioLast; /* Has last audio sample been read */
698 mp4_u8 *audioDecSpecificInfo; /* MPEG audio DecoderSpecificInfo */
699 mp4_u32 audioDecSpecificInfoSize; /* MPEG audio DecoderSpecificInfo size in bytes */
700 sampleTable *audioSampleTable; /* Audio sample table */
701 mp4_u8 audioFramesPerSample; /* AMR frames per sample value */
702 mp4_u16 audioModeSet; /* AMR mode set */
703 mp4_u32 metaDataBlocks; /* Number of metadata blocks in memory */
704 mp4_bool metaDataOnDisk; /* Is (a part of) metadata on the disk */
705 mp4_u32 metaDataSize; /* Size of metadata */
706 mp4_u32 videoSampleEntryIndex; /* SampleEntry index of the video frame being read */
707 mp4_u32 audioSampleEntryIndex; /* SampleEntry index of the audio frame being read */
708 mp4_u8 avcNalUnitLengthSize; /* byte size of the length field */
709 mp4_bool generate3G2; /* 3GPP2 File Format Generation is Selected: default:FALSE (Generate 3GP)*/
710 mp4_bool generateMP4; /* MPEG-4 File Format Generation is Selected: defailt:FALSE (Generate 3GP)*/
711 mp4_bool qcelpStoredAsMPEGAudio; /* QCELP 13K is registered as MPEG4 Audio: default: FALSE (in QCELPSampleEntry)*/
712 mp4_u64 audioMediaDataSize; /* Total byte size of the written audio data. This is used to calculate the max and avg bitrates */
713 mp4_u32 ES_DescriptorSize; /* size of the ES_Descriptor inside the ESDS box */
716 mp4_u8 *composeBuffer;
717 mp4_bool bufferWrite;
718 mp4_u32 bytesProgressed;
720 mp4_u32 *composedSize;
722 CFileWriter* filewriter; /* Async buffering filewriter */
723 CMetaDataFileWriter* metadatafilewriter; /* Async buffering metadata temp file writer */
725 mp4_bool LastWriteDataCalled; /* When TRUE, it indicates that ParseWriteData() function is called for the last time */
726 mp4_bool FileHandleFromOutside; /* When TRUE file handle is passed to library instead of file name, don't close file in end */
728 mp4_bool metaDataFileEmpty[NUM_MDF]; /* when TRUE it indicates that metadata file has been read and rest of data is in readbuffer of metadatafilewriter */
730 userDataAtom* moovUDTA; // used to compose MOOV UDTA (User Data)
731 userDataAtom* audioUDTA; // used to compose AudioTrack UDTA (User Data)
732 userDataAtom* videoUDTA; // used to compose VideoTrack UDTA (User Data)
734 TDriveNumber fileHandleDrive; /* Used when we get file handle to library from outside. Used to indicate which drive are metadata temp files written.*/
736 // Custom buffer size additions:
737 mp4_u32 mediaWriteBufferSize;
738 mp4_u32 metaWriteBufferSize;
739 mp4_u32 writeBufferMaxCount;
740 mp4_u32 readBufferSize;
742 // Async parsing observer
743 M3GPMP4LibAsyncObserver* asyncObserver;
744 CFileAsyncParser* asyncReader;
745 M3GPMP4LibAsyncTempFileRemoverObserver* tempFileRemoverObserver;
747 void *file32Duplicate; //this is a RFile64 duplicate of the RFile used in Open
751 typedef MP4HandleStruct *MP4HandleImp;
754 mp4_i32 metaDataAvailable(MP4HandleImp handle);
755 mp4_i32 readFTYP(MP4HandleImp handle, fileTypeAtom *ftyp);
756 mp4_i32 readMetaData(MP4HandleImp handle);
757 mp4_i32 readMoov(MP4HandleImp handle, movieAtom *moov);
758 mp4_i32 readAtomHeader(MP4HandleImp handle, atomHeader *ah);
759 mp4_i32 readFullAtomHeader(MP4HandleImp handle, atomHeader *ah);
760 mp4_i32 readMVHD(MP4HandleImp handle, movieHeaderAtom *mvhd);
761 mp4_i32 readIODS(MP4HandleImp handle, objectDescriptorAtom *iods);
762 mp4_i32 readTRAK(MP4HandleImp handle, trackAtom *trak);
763 mp4_i32 readUnknown(MP4HandleImp handle);
764 mp4_i32 readTKHD(MP4HandleImp handle, trackHeaderAtom *tkhd);
765 mp4_i32 readTREF(MP4HandleImp handle, trackReferenceAtom *tref);
766 mp4_i32 readEDTS(MP4HandleImp handle, editListContainerAtom *edts);
767 mp4_i32 readMDIA(MP4HandleImp handle, mediaAtom *mdia);
768 mp4_i32 readMDHD(MP4HandleImp handle, mediaHeaderAtom *mdhd);
769 mp4_i32 readHDLR(MP4HandleImp handle, handlerAtom *hdlr);
770 mp4_i32 readMINF(MP4HandleImp handle, mediaInformationAtom *minf);
771 mp4_i32 readVMHD(MP4HandleImp handle, videoMediaHeaderAtom *vmhd);
772 mp4_i32 readSMHD(MP4HandleImp handle, soundMediaHeaderAtom *smhd);
773 mp4_i32 readDINF(MP4HandleImp handle, dataInformationAtom *dinf);
774 mp4_i32 readDREF(MP4HandleImp handle, dataReferenceAtom *dref);
775 mp4_i32 readURL(MP4HandleImp handle, dataEntryURLAtom *url);
776 mp4_i32 readURN(MP4HandleImp handle, dataEntryURNAtom *urn);
777 mp4_i32 readSTBL(MP4HandleImp handle, sampleTableAtom *stbl);
778 mp4_i32 readSTTS(MP4HandleImp handle, timeToSampleAtom *stts);
779 mp4_i32 readCTTS(MP4HandleImp handle, compositionTimeToSampleAtom *ctts);
780 mp4_i32 readSTSS(MP4HandleImp handle, syncSampleAtom *stss);
781 mp4_i32 readSTSD(MP4HandleImp handle, sampleDescriptionAtom *stsd);
782 mp4_i32 readSTSZ(MP4HandleImp handle, sampleSizeAtom *stsz);
783 mp4_i32 readSTZ2(MP4HandleImp handle, sampleSizeAtom *stsz);
784 mp4_i32 readSTSC(MP4HandleImp handle, sampleToChunkAtom *stsc);
785 mp4_i32 readSTCO(MP4HandleImp handle, chunkOffsetAtom *stco);
786 mp4_i32 readCO64(MP4HandleImp handle, chunkOffset64Atom *stco64);
787 mp4_i32 readMP4V(MP4HandleImp handle, visualSampleEntry *mp4v);
788 mp4_i32 readMP4A(MP4HandleImp handle, audioSampleEntry *mp4a);
789 mp4_i32 readMP4S(MP4HandleImp handle, mpegSampleEntry *mp4s);
790 mp4_i32 readS263(MP4HandleImp handle, h263SampleEntry *s263);
791 mp4_i32 readSAMR(MP4HandleImp handle, amrSampleEntry *samr);
792 mp4_i32 readSAWB(MP4HandleImp handle, amrSampleEntry *sawb);
793 mp4_i32 readESD(MP4HandleImp handle, ESDAtom *esd);
794 mp4_i32 readD263(MP4HandleImp handle, h263SpecificAtom *d263);
795 mp4_i32 readBITR(MP4HandleImp handle, bitrateAtom *bitr);
796 mp4_i32 readDAMR(MP4HandleImp handle, amrDecSpecStruc *damr);
797 mp4_i32 readMeta(MP4HandleImp handle, metaAtom *meta);
799 mp4_i32 readAVC1(MP4HandleImp handle, avcSampleEntry *avc1);
800 mp4_i32 readSDTP(MP4HandleImp handle, sampleDependencyAtom *sdtp, mp4_i32 sample_count);
801 /* QCELP 13k inclusions */
802 mp4_i32 readSQCP(MP4HandleImp handle, qcelpSampleEntry *sqcp);
803 mp4_i32 readDQCP(MP4HandleImp handle, qcelpDecSpecStruc *dqcp);
805 mp4_i32 readID32(MP4HandleImp handle, ID32Atom *ID32);
807 mp4_i32 freeFTYP(fileTypeAtom *ftyp);
808 mp4_i32 freeMOOV(movieAtom *moov);
809 mp4_i32 freeAtomHeader(atomHeader *atomhdr);
810 mp4_i32 freeMVHD(movieHeaderAtom *mvhd);
811 mp4_i32 freeTRAK(trackAtom *trak);
812 mp4_i32 freeTKHD(trackHeaderAtom *tkhd);
813 mp4_i32 freeTREF(trackReferenceAtom *tref);
814 mp4_i32 freeEDTS(editListContainerAtom *edts);
815 mp4_i32 freeMDIA(mediaAtom *mdia);
816 mp4_i32 freeMDHD(mediaHeaderAtom *mdhd);
817 mp4_i32 freeHDLR(handlerAtom *hdlr);
818 mp4_i32 freeMINF(mediaInformationAtom *minf);
819 mp4_i32 freeVMHD(videoMediaHeaderAtom *vmhd);
820 mp4_i32 freeSMHD(soundMediaHeaderAtom *smhd);
821 mp4_i32 freeDINF(dataInformationAtom *dinf);
822 mp4_i32 freeDREF(dataReferenceAtom *dref);
823 mp4_i32 freeURL(dataEntryURLAtom *url);
824 mp4_i32 freeURN(dataEntryURNAtom *urn);
825 mp4_i32 freeSTBL(sampleTableAtom *stbl);
826 mp4_i32 freeSTTS(timeToSampleAtom *stts);
827 mp4_i32 freeCTTS(compositionTimeToSampleAtom *ctts);
828 mp4_i32 freeSTSD(sampleDescriptionAtom *stsd);
829 mp4_i32 freeMP4V(visualSampleEntry *mp4v);
830 mp4_i32 freeESD(ESDAtom *esd);
831 mp4_i32 freeMP4A(audioSampleEntry *mp4a);
832 mp4_i32 freeMP4S(mpegSampleEntry *mp4s);
833 mp4_i32 freeS263(h263SampleEntry *s263);
834 mp4_i32 freeD263(h263SpecificAtom *d263);
835 mp4_i32 freeBITR(bitrateAtom *bitr);
836 mp4_i32 freeSAMR(amrSampleEntry *samr);
837 mp4_i32 freeSAWB(amrSampleEntry *sawb);
838 mp4_i32 freeDAMR(amrDecSpecStruc *damr);
839 mp4_i32 freeSTSZ(sampleSizeAtom *stsz);
840 mp4_i32 freeSTSC(sampleToChunkAtom *stsc);
841 mp4_i32 freeSTCO(chunkOffsetAtom *stco);
842 mp4_i32 freeSTCO64(chunkOffset64Atom *stco64);
843 mp4_i32 freeSTSS(syncSampleAtom *stss);
844 mp4_i32 freeSTSH(shadowSyncSampleAtom *stsh);
845 mp4_i32 freeIODS(objectDescriptorAtom *iods);
846 mp4_i32 readUDTA(MP4HandleImp handle, userDataAtom *udta);
847 mp4_i32 freeUDTA(userDataAtom *udta);
848 mp4_i32 freeSDTP(sampleDependencyAtom* sdtp);
849 mp4_i32 freeMETA(metaAtom *meta);
850 /* The following and AVC related */
851 mp4_i32 freeAVC1(avcSampleEntry *avc1);
852 mp4_i32 freeM4DS(mpeg4ExtensionDescriptorsAtom *m4ds);
853 mp4_i32 freeBTRT(mpeg4BitrateAtom *btrt);
854 mp4_i32 freeAVCC(avcConfigurationAtom *avcc);
855 /* QCELP 13K related */
856 mp4_i32 freeSQCP(qcelpSampleEntry *sqcp);
857 mp4_i32 freeDQCP(qcelpDecSpecStruc *dqcp);
859 mp4_i32 freeID32(ID32Atom *ID32);
861 mp4_i32 determineVideoLength(MP4HandleImp handle, mp4_u32 *videolength);
862 mp4_i32 determineFrameRate(MP4HandleImp handle, mp4_double *framerate);
863 mp4_i32 determineVideoType(MP4HandleImp handle, mp4_u32 *videotype);
864 mp4_i32 determineVideoResolution(MP4HandleImp handle, mp4_u32 *videowidth, mp4_u32 *videoheight);
865 mp4_i32 determineVideoTimeScale(MP4HandleImp handle, mp4_u32 *timescale);
866 mp4_i32 determineAudioLength(MP4HandleImp handle, mp4_u32 *audiolength);
867 mp4_i32 determineAudioType(MP4HandleImp handle, mp4_u32 *audiotype);
868 mp4_i32 determineAudioFramesPerSample(MP4HandleImp handle, mp4_u8 *framespersample);
869 mp4_i32 determineAudioTimeScale(MP4HandleImp handle, mp4_u32 *timescale);
870 mp4_i32 determineAudioAverageBitRate(MP4HandleImp handle, mp4_u32 *averagebitrate);
871 mp4_i32 determineStreamSize(MP4HandleImp handle, mp4_u32 *streamsize);
872 mp4_i32 determineStreamAverageBitRate(MP4HandleImp handle, mp4_u32 *streamaveragebitrate, mp4_u32 streamsize);
873 mp4_i32 advanceVideoFrame(MP4HandleImp handle, trackAtom *trak);
874 mp4_i32 resolveVideoSampleOffset(MP4HandleImp handle, sampleTableAtom *stbl);
875 mp4_i32 resolveVideoSampleSize(MP4HandleImp handle, sampleSizeAtom *stsz);
876 mp4_i32 fetchVideoFrame(MP4HandleImp handle, trackAtom *trak, mp4_u8 *buffer, mp4_u32 buffersize, mp4_u32 *framesize, mp4_u32 *framenumber, mp4_bool *keyframe, mp4_u32 *timestamp2);
877 mp4_i32 isVideoFrameKeyFrame(MP4HandleImp handle, trackAtom *trak, mp4_bool *keyframe);
878 mp4_i32 convertVideoSampleToTime(MP4HandleImp handle, mediaAtom *mdia, mp4_u32 *framenumber, mp4_u32 *timestamp2);
879 mp4_i32 advanceAudioSample(MP4HandleImp handle, trackAtom *trak);
880 mp4_i32 resolveAudioSampleOffset(MP4HandleImp handle, sampleTableAtom *stbl);
881 mp4_i32 resolveAudioSampleSize(MP4HandleImp handle, sampleSizeAtom *stsz);
882 mp4_i32 fetchAudioSample(MP4HandleImp handle, trackAtom *trak, mp4_u8 *buffer, mp4_u32 buffersize, mp4_u32 *framesize, mp4_u32 *timestamp, mp4_u32 *returnedframes, mp4_u32 *timestamp2);
883 mp4_i32 convertAudioSampleToTime(MP4HandleImp handle, mediaAtom *mdia, mp4_u32 *timestamp, mp4_u32 *timestamp2);
884 mp4_i32 convertTimeToSample(MP4HandleImp handle, trackAtom *trak, mp4_u32 position, mp4_u32 *sample);
885 mp4_i32 goToVideoSample(MP4HandleImp handle, trackAtom *trak, mp4_u32 sample);
886 mp4_i32 goToAudioSample(MP4HandleImp handle, trackAtom *trak, mp4_u32 sample);
887 mp4_i32 findVideoKeyFrame(MP4HandleImp handle, trackAtom *trak, mp4_u32 sample, mp4_u32 *newsample);
888 mp4_i32 fetchAudioSampleAsync(MP4HandleImp handle, trackAtom *trak, mp4_u8 *buffer, mp4_u32* buffersize);
889 mp4_i32 fetchVideoFrameAsync(MP4HandleImp handle, trackAtom *trak, mp4_u8 *buffer, mp4_u32* buffersize);
890 mp4_i64 getChunkOffset(sampleTableAtom *stbl, mp4_u32 index);