Update contrib.
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.
27 #define MP4Handle mp4_i32*
31 #include <3gplibrary/mp4config.h>
34 Provides async parse read observer.
36 class M3GPMP4LibAsyncObserver
41 Informs the client about asyncronous parse audio frames operation completion.
43 @param aError Error code.
44 @param aAudioSize Size of the returned audio frames (in bytes).
45 @param aTimeStamp Audio frame presentation time in milliseconds from the
46 beginning of the audio sequence.
47 @param aReturnedFrames Number of frames returned, or 0 if not known.
48 @param aTimestamp2 Audio frame presentation time in timescale from the
49 beginning of the audio sequence
52 virtual void M3GPMP4LibAudioFramesAvailable(MP4Err aError,
55 mp4_u32 aReturnedFrames,
56 mp4_u32 aTimestamp2) = 0;
59 Informs the client about asyncronous parse video frame operation completion.
61 @param aError Error code.
62 @param aFrameSize Size of the returned frame (in bytes).
63 @param aTimeStamp Video frame presentation time in milliseconds from the
64 beginning of the video sequence
65 @param aKeyFrame Returns MP4TRUE if the current frame is a key frame (intra),
66 otherwise the value is MP4FALSE
67 @param aTimestamp2 Video frame presentation time in timescale from the beginning
71 virtual void M3GPMP4LibVideoFrameAvailable(MP4Err aError,
75 mp4_u32 aTimestamp2) = 0;
79 This class provides async temporary file deleting observer.
81 class M3GPMP4LibAsyncTempFileRemoverObserver
86 Informs the client about unused temporary file that can be deleted.
87 @param tempFileName Name of the temporary file that can be deleted.
88 Ownership of the file name memory buffer is transferred.
90 virtual void M3GPMP4LibDeleteTempFileName( MP4FileName tempFileName ) = 0;
99 Error codes returned by the library
107 /** Library can't allocate memory */
109 /** MP4 library needs more data before the
110 requested information can be returned */
112 /** The library has been opened with the input in a file */
114 /** The input is not streamable */
116 /** Frame of requested type is not available */
117 MP4_NO_REQUESTED_FRAME,
118 /** Requested frame doesn't fit into the given buffer */
119 MP4_BUFFER_TOO_SMALL,
120 /** No more video frames left */
122 /** Can't seek to requested position */
124 /** Error in file handling */
126 /** Input stream is invalid */
127 MP4_INVALID_INPUT_STREAM,
128 /** Frame doesn't exist (previous frame was last) */
132 /** Timescale has not been set */
133 MP4_TIMESCALE_NOT_SET,
134 /** Error writing metadata */
136 /** No video in input stream */
138 /** No audio in input stream */
140 /** Output buffer has not been initialized for buffer writing */
141 MP4_NO_OUTPUT_BUFFER,
142 /** Not enough space in output buffer to write to */
143 MP4_OUTPUT_BUFFER_TOO_SMALL,
144 /** No UDTA data found */
150 Possible data source types
154 /** Data is read from an RFile64 handle */
156 /** Data is read via the CAF */
161 Possible input/output values for audio/video type
164 /** No audio or video */
165 #define MP4_TYPE_NONE 0x0000
166 /** Video Type. MPEG-4 video (MPEG-4 Part 2) - Simple and Advance Simple Profiles */
167 #define MP4_TYPE_MPEG4_VIDEO 0x0001
168 /** Audio Type. MPEG-4 audio (MPEG-4 Part 3) */
169 #define MP4_TYPE_MPEG4_AUDIO 0x0002
170 /** Video Type. H263 Profile 0 */
171 #define MP4_TYPE_H263_PROFILE_0 0x0004
172 /** Video Type. H263 Profile 3 */
173 #define MP4_TYPE_H263_PROFILE_3 0x0008
174 /** Audio Type. AMR NB */
175 #define MP4_TYPE_AMR_NB 0x0010
176 /** Audio Type. AMR WB */
177 #define MP4_TYPE_AMR_WB 0x0020
178 /** Type not supported */
179 #define MP4_TYPE_UNSUPPORTED 0x0040
180 /** AVC baseline (MPEG-4 Part 10) */
181 #define MP4_TYPE_AVC_PROFILE_BASELINE 0x0080
182 /** AVC main (MPEG-4 Part 10) */
183 #define MP4_TYPE_AVC_PROFILE_MAIN 0x0100
184 /** AVC extended (MPEG-4 Part 10) */
185 #define MP4_TYPE_AVC_PROFILE_EXTENDED 0x0200
186 /** QCELP 13K additions */
187 #define MP4_TYPE_QCELP_13K 0x0400
188 /** AVC high (MPEG-4 Part 10) */
189 #define MP4_TYPE_AVC_PROFILE_HIGH 0x0800
192 Flags used by composer
194 /** No special setup */
195 #define MP4_FLAG_NONE 0x0000
196 /** Meta data is placed at end of file */
197 #define MP4_FLAG_METADATALAST 0x0001
198 /** Collect metadata in files instead of storing it in memory */
199 #define MP4_FLAG_LONGCLIP 0x0002
200 /** Generate a 3G2 File instead of a 3GP File */
201 #define MP4_FLAG_GENERATE_3G2 0x0004
202 /** Generate a MP4 File instead of a 3GP File */
203 #define MP4_FLAG_GENERATE_MP4 0x0008
204 /** Use large output buffers for writing */
205 #define MP4_FLAG_LARGEFILEBUFFER 0x0010
208 /** Size of buf in MP4HandleStruct must be at least 128 bytes */
209 #define TMPBUFSIZE 128
210 /** Duration of one AMR frame is 20 ms */
211 #define AUDIO_FRAME_DURATION 20
213 #define MP4FALSE (mp4_bool)0
214 #define MP4TRUE (mp4_bool)1
217 Possible locations for user data atom (UDTA)
220 #define MP4_UDTA_NONE 0x0000
221 /** User data resides within the Movie Box */
222 #define MP4_UDTA_MOOV 0x0001
223 /** User data resides within the Track Box for video */
224 #define MP4_UDTA_VIDEOTRAK 0x0002
225 /** User data resides within the Track Box for audio */
226 #define MP4_UDTA_AUDIOTRAK 0x0004
229 Initializes the MP4 composing operation. The instance handle of the library is
232 The possible values of type parameter are
234 MP4_TYPE_H263_PROFILE_0
235 MP4_TYPE_H263_PROFILE_3
241 MP4_TYPE_AVC_PROFILE_BASELINE
242 MP4_TYPE_AVC_PROFILE_MAIN
243 MP4_TYPE_AVC_PROFILE_EXTENDED
244 MP4_TYPE_AVC_PROFILE_HIGH
247 In addition, any combination of one video and one audio type are
248 possible. For example
250 MP4_TYPE_H263_PROFILE_0 | MP4_TYPE_AMR_NB
252 The output file is placed in the current working directory if no path is
253 specified. The type of filename is dependent on the architecture. When
254 compiling in Symbian OS, this is a unicode string.
257 @param handle MP4 library handle
258 @param filename Name of the output MP4 file
259 @param type Type of the output file
261 @return MP4_OK Success
262 MP4_ERROR Generic error
263 MP4_FILE_ERROR Error opening file
264 MP4_OUT_OF_MEMORY Out of memory
266 extern IMPORT_C MP4Err MP4ComposeOpen(MP4Handle *handle, MP4FileName filename, mp4_u32 type);
269 This function initializes the MP4 composing operation. The instance
270 handle of the library is set by the function.
272 The possible values of type parameter are
274 MP4_TYPE_H263_PROFILE_0
275 MP4_TYPE_H263_PROFILE_3
281 MP4_TYPE_AVC_PROFILE_BASELINE
282 MP4_TYPE_AVC_PROFILE_MAIN
283 MP4_TYPE_AVC_PROFILE_EXTENDED
284 MP4_TYPE_AVC_PROFILE_HIGH
287 In addition, any combination of one video and one audio type are possible. For example
289 MP4_TYPE_H263_PROFILE_0 | MP4_TYPE_AMR_NB
291 The output is placed in the buffer given as argument.
292 Size of composed data is in composedSize variable.
294 @param handle MP4 library handle
295 @param type Type of the output file
296 @param composeBuffer Buffer to write to.
297 @param composedSize Size of composed data.
301 MP4_ERROR Generic error
302 MP4_FILE_ERROR Error opening file
303 MP4_OUT_OF_MEMORY Out of memory
304 MP4_NO_OUTPUT_BUFFER No composed buffer
306 extern IMPORT_C MP4Err MP4ComposeOpenToBuffer(MP4Handle *handle, mp4_u32 type, mp4_u8* composeBuffer, mp4_u32 *composedSize);
309 This function initializes the MP4 composing operation to existing file handle. The instance
310 handle of the library is set by the function.
312 NOTE: MP4_FLAG_METADATALAST must be defined in MP4ComposeSetFlags if MP4ComposeOpenFileHandle is used!
314 The possible values of type parameter are
316 MP4_TYPE_H263_PROFILE_0
317 MP4_TYPE_H263_PROFILE_3
323 MP4_TYPE_AVC_PROFILE_BASELINE
324 MP4_TYPE_AVC_PROFILE_MAIN
325 MP4_TYPE_AVC_PROFILE_EXTENDED
326 MP4_TYPE_AVC_PROFILE_HIGH
329 In addition, any combination of one video and one audio type are possible. For example
331 MP4_TYPE_H263_PROFILE_0 | MP4_TYPE_AMR_NB
333 The output file is placed in the current working directory if no path is
334 specified. The type of filename is dependent on the architecture. When
335 compiling in Symbian OS, this is a unicode string.
337 @param handle MP4 library handle
338 @param composedfile File handle to output file
339 @param metadataTempDrive If MP4ComposeSetFlags() is configured to use temporary files for metadata
340 (MP4_FLAG_LONGCLIP) this is way to tell library which drive to use for
342 @param type Type of the output file
344 @return MP4_OK Success
345 MP4_ERROR Generic error
346 MP4_FILE_ERROR Error opening file
347 MP4_OUT_OF_MEMORY Out of memory
349 extern IMPORT_C MP4Err MP4ComposeOpenFileHandle(MP4Handle *handle, RFile *composedfile, TDriveNumber metadataTempDrive, mp4_u32 type);
352 This function initializes the MP4 composing operation to existing file handle. The instance
353 handle of the library is set by the function.
355 NOTE: MP4_FLAG_METADATALAST must be defined in MP4ComposeSetFlags if MP4ComposeOpenFileHandle is used!
357 The possible values of type parameter are
359 MP4_TYPE_H263_PROFILE_0
360 MP4_TYPE_H263_PROFILE_3
366 MP4_TYPE_AVC_PROFILE_BASELINE
367 MP4_TYPE_AVC_PROFILE_MAIN
368 MP4_TYPE_AVC_PROFILE_EXTENDED
369 MP4_TYPE_AVC_PROFILE_HIGH
372 In addition, any combination of one video and one audio type are possible. For example
374 MP4_TYPE_H263_PROFILE_0 | MP4_TYPE_AMR_NB
376 The output file is placed in the current working directory if no path is
377 specified. The type of filename is dependent on the architecture. When
378 compiling in Symbian OS, this is a unicode string.
380 @param handle MP4 library handle
381 @param composedfile File handle to output file
382 @param metadataTempDrive If MP4ComposeSetFlags() is configured to use temporary files for metadata
383 (MP4_FLAG_LONGCLIP) this is way to tell library which drive to use for
385 @param type Type of the output file
387 @return MP4_OK Success
388 MP4_ERROR Generic error
389 MP4_FILE_ERROR Error opening file
390 MP4_OUT_OF_MEMORY Out of memory
392 extern IMPORT_C MP4Err MP4ComposeOpenFileHandle64(MP4Handle *handle, RFile64 *composedfile, TDriveNumber metadataTempDrive, mp4_u32 type);
395 This function closes the MP4 composing operation. It frees the memory
396 allocated by the library instance and closes the output MP4 file.
398 It is necessary to call this function before the output file is
399 guaranteed to be a valid MP4 file even though the file may exist prior to
402 The library handle is not valid after this call.
404 @param handle MP4 library handle
406 @return MP4_OK Success
407 MP4_ERROR Generic error
408 MP4_METADATA_ERROR Metadata could not be written
410 extern IMPORT_C MP4Err MP4ComposeClose(MP4Handle handle);
413 This function is used to inform the MP4 library about the video data. The
414 data given to the library is inserted into the MP4 file headers.
416 The parameter timescale indicates the timescale of the video data
417 to be inserted. Timescale tells how many units of time pass in one second.
419 Note: Timescale should be chosen so that the duration of each sample is
420 an integer. Timescale should also be chosen so that the duration
421 of the presentation fits into 32 bits.
423 @param handle MP4 library handle
424 @param timescale Timescale of video
425 @param width Video width
426 @param height Video height
427 @param maxbitrate Maximum bitrate of video
428 @param avgbitrate Average bitrate of video
430 @return MP4_OK Success
431 MP4_ERROR Generic error
433 extern IMPORT_C MP4Err MP4ComposeAddVideoDescription(MP4Handle handle, mp4_u32 timescale, mp4_u16 width, mp4_u16 height, mp4_u32 maxbitrate, mp4_u32 avgbitrate);
436 This function is used to inform the MP4 library about the audio data. The
437 data given to the library is inserted into the MP4 file headers.
439 The parameter timescale indicates the timescale of the audio data
440 to be inserted. Timescale tells how many units of time pass in one second.
442 Note: timescale must be smaller than 65536.
444 Note: audioFramesPerSample and modeSet are needed only for AMR audio.
446 @param handle MP4 library handle
447 @param timescale Timescale of audio
448 @param audioFramesPerSample AMR frames per sample
449 @param modeSet AMR mode set
451 @return MP4_OK Success
452 MP4_ERROR Generic error
454 extern IMPORT_C MP4Err MP4ComposeAddAudioDescription(MP4Handle handle, mp4_u32 timescale, mp4_u8 audioFramesPerSample, mp4_u16 modeSet);
457 This function writes one video frame to the MP4 composer library.
459 The frames must be inserted in causal order. Because the library doesn't
460 analyze the video bitstream, the frames can't be retrieved from the
461 resulting MP4 file correctly if they are not in proper order.
463 The data is available in the MP4 output file only after calling
464 MP4ComposeClose. MP4ComposeClose is called exactly once when all audio
465 and video data has been inserted into the library.
467 @param handle MP4 library handle
468 @param buffer Video frame data
469 @param framesize Size of the video frame in bytes
470 @param duration Duration of video frame (in timescale,
471 see MP4ComposeAddVideoDescription)
472 @param keyframe Flag to indicate whether this frame is a keyframe
474 @return MP4_OK Success
475 MP4_ERROR Generic error
476 MP4_TIMESCALE_NOT_SET Timescale has not been set
478 extern IMPORT_C MP4Err MP4ComposeWriteVideoFrame(MP4Handle handle, mp4_u8 *buffer, mp4_u32 framesize, mp4_u32 duration, mp4_bool keyframe);
481 This function writes audio frames to the MP4 composer library. The data is
482 available in the MP4 output file only after calling
483 MP4ComposeClose. MP4ComposeClose is called exactly once when all audio
484 and video data has been insrted into the library.
488 This function writes one MPEG audio frame to the MP4 composer library.
490 Note: numberofframes is meaningless with MPEG audio since only one frame
491 can be added with one call.
493 For other audio types:
495 This function writes a number of audio frames to the MP4 composer library.
496 All audio frames inserted with one function call will be placed inside
497 one audio sample in the resulting file.
499 Note: Once this function is called with a certain numberofframes
500 parameter, it can't be changed. This is a limitation of the MP4 file
501 format. Only the last call can have a different number of frames if
502 their number is less than numberofframes.
504 @param handle MP4 library handle
505 @param buffer Audio data
506 @param bytestowrite Number of bytes of audio data in buffer
507 @param numberofframes Number of frames to write
508 @param duration Duration of audio frames (in timescale,
509 see MP4ComposeAddAudioDescription)
511 @return MP4_OK Success
512 MP4_ERROR Generic error
513 MP4_TIMESCALE_NOT_SET Timescale has not been set
515 extern IMPORT_C MP4Err MP4ComposeWriteAudioFrames(MP4Handle handle, mp4_u8 *buffer, mp4_u32 bytestowrite, mp4_u32 numberofframes, mp4_u32 duration);
518 This function writes MPEG-4 or AVC video DecoderSpecificInfo data into the appropriate atom.
520 If the video type is MPEG-4 the DecoderSpecificInfo will be written into the esds atom. If the
521 video type is AVC (any profile) the DecoderSpecificInfo will be written into the avcC atom.
523 Note: This function needs to be called only when MPEG-4 or AVC video is used.
525 @param handle MP4 library handle
526 @param info Buffer containing DecoderSpecificInfo
527 @param infosize Size of info in bytes
529 @return MP4_OK Success
530 MP4_ERROR Generic error
532 extern IMPORT_C MP4Err MP4ComposeWriteVideoDecoderSpecificInfo(MP4Handle handle, mp4_u8 *info, mp4_u32 infosize);
535 This function writes MPEG audio DecoderSpecificInfo data into esds atom.
537 Note: This function needs to be called only when MPEG audio is used.
539 @param handle MP4 library handle
540 @param info Buffer containing DecoderSpecificInfo
541 @param infosize Size of info in bytes
543 @return MP4_OK Success
544 MP4_ERROR Generic error
546 extern IMPORT_C MP4Err MP4ComposeWriteAudioDecoderSpecificInfo(MP4Handle handle, mp4_u8 *info, mp4_u32 infosize);
549 This function allows settings flags that modify the behaviour
550 of the library. Use binary OR to specify several flags.
552 The following flags can be used:
554 MP4_FLAG_NONE No special setup.
556 MP4_FLAG_METADATALAST Write metadata last in the file without tmpfile.
557 Default is to write the metadata in the
558 beginning of the file.
560 MP4_FLAG_LONGCLIP Collect metadata in files instead of collecting
561 it in memory if the amount is large. Only usable
564 MP4_FLAG_GENERATE_3G2 Generate a 3G2 File instead of a 3GP File.
565 If not set, then 3GP file is generated.
566 Generation of 3G2 file may be automatically set
567 during composition, based on the selection
568 of 3GPP2 specific codecs.
570 MP4_FLAG_GENERATE_MP4 Generate a MP4 File instead of a 3GP File.
571 If not set, then 3GP file is generated.
572 Generation may be automatically set to 3GP
573 if codecs selected do not support MP4.
575 MP4_FLAG_LARGEFILEBUFFER Use larger output buffers in file writing.
576 Non MP4_ARCH_WIN32 compilations only.
578 Note: This function should be called after MP4ComposeOpen before
579 any other MP4Compose functions.
581 Note: If MP4ComposeOpenFileHandle is used instead of MP4ComposeOpen the MP4_FLAG_METADATALAST must be defined.
583 @param handle MP4 library handle
584 @param flags Flags to enable
586 @return MP4_OK Success
587 MP4_ERROR Generic error
588 MP4_OUT_OF_MEMORY Out of Memory
590 extern IMPORT_C MP4Err MP4ComposeSetFlags(MP4Handle handle, mp4_u32 flags);
593 This function initializes the MP4 parsing operation. The instance handle
594 of the library is set by the function.
596 The filename parameter is used to specify the type of the input. If the
597 parameter is non-NULL, it is assumed to be the filename of the input MP4
598 file. If the parameter is NULL, the library expects the input MP4 data to
599 be inserted by subsequent calls of MP4ParseWriteData.
601 @param handle MP4 library handle
602 @param filename Name of the input MP4 file or NULL if the data is coming from
605 @return MP4_OK Success
606 MP4_ERROR Generic error
607 MP4_OUT_OF_MEMORY Out of memory
608 MP4_FILE_ERROR Error opening file
610 extern IMPORT_C MP4Err MP4ParseOpen(MP4Handle *handle, MP4FileName filename);
613 This function initializes the MP4 parsing operation. The instance handle
614 of the library is set by the function.
616 The RFile *inputfile parameter is pointer to valid file handle.
617 Library expects that file has been opened and will be closed outside of library.
619 @param handle MP4 library handle
620 @param inputfile File handle to be parsed.
622 @return MP4_OK Success
623 MP4_ERROR Generic error
624 MP4_OUT_OF_MEMORY Out of memory
625 MP4_FILE_ERROR; Error accessing file
627 extern IMPORT_C MP4Err MP4ParseOpenFileHandle(MP4Handle *handle, RFile *inputfile );
630 This function initializes the MP4 parsing operation. The instance handle
631 of the library is set by the function.
633 The RFile64 *inputfile parameter is pointer to valid file handle.
634 Library expects that file has been opened and will be closed outside of library.
636 @param handle MP4 library handle
637 @param inputfile File handle to be parsed.
639 @return MP4_OK Success
640 MP4_ERROR Generic error
641 MP4_OUT_OF_MEMORY Out of memory
642 MP4_FILE_ERROR; Error accessing file
644 extern IMPORT_C MP4Err MP4ParseOpenFileHandle64(MP4Handle *handle, RFile64 *inputfile );
647 This function initializes the MP4 parsing operation. The instance handle
648 of the library is set by the function.
650 The ContentAccess::CData *inputfile parameter is pointer to valid CAF object.
651 Library expects that file has been opened and will be closed outside of library.
653 @param handle MP4 library handle
654 @param inputfile CAF data source handle to be parsed.
656 @return MP4_OK Success
657 MP4_ERROR Generic error
658 MP4_OUT_OF_MEMORY Out of memory
659 MP4_FILE_ERROR; Error accessing file
661 extern IMPORT_C MP4Err MP4ParseOpenCAF(MP4Handle *handle, ContentAccess::CData *inputfile );
664 This function closes the MP4 parsing operation. It frees the resources
665 allocated by the library instance.
667 The library handle is not valid after this call.
669 @param handle MP4 library handle
671 @return MP4_OK Success
672 MP4_ERROR Generic error
674 extern IMPORT_C MP4Err MP4ParseClose(MP4Handle handle);
677 This function returns parameters describing the video stream. It can be
678 called after enough data has been inserted into the library so that MP4
679 headers containing the information can be read. If there is not enough
680 data, those functions return MP4_NOT_AVAILABLE and more data needs to be
681 inserted into the library by MP4ParseWriteData.
683 The framerate parameter refers to the frame rate of the original video
686 The videotype parameter can be one of the following:
688 MP4_TYPE_H263_PROFILE_0
689 MP4_TYPE_H263_PROFILE_3
690 MP4_TYPE_AVC_PROFILE_BASELINE
691 MP4_TYPE_AVC_PROFILE_MAIN
692 MP4_TYPE_AVC_PROFILE_EXTENDED
693 MP4_TYPE_AVC_PROFILE_HIGH
695 Note: For timescale parameter, NULL can be specified if the caller
696 doesn't need the value.
698 @param handle MP4 library handle
699 @param videolength Duration of video in milliseconds
700 @param framerate Frame rate of video (in Hz)
701 @param videotype Type of video stream
702 @param videowidth Width of video image measured in pixels
703 @param videoheight Height of video image measured in pixels
704 @param timescale Timescale of video track
706 @return MP4_OK Success
707 MP4_ERROR Generic error
708 MP4_NOT_AVAILABLE MP4 library needs more data before the
709 requested information can be returned
710 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
711 MP4_NO_VIDEO Input doesn't contain video track
713 extern IMPORT_C MP4Err MP4ParseRequestVideoDescription(MP4Handle handle, mp4_u32 *videolength, mp4_double *framerate, mp4_u32 *videotype, mp4_u32 *videowidth, mp4_u32 *videoheight, mp4_u32 *timescale);
716 This function returns parameters describing the audio stream. It can be
717 called after enough data has been inserted into the library so that MP4
718 headers containing the information can be read.
720 Note: framespersample parameter is set only when AMR type audio is used.
722 Note: For timescale parameter, NULL can be specified if the caller
723 doesn't need the value.
725 @param handle MP4 library handle
726 @param audiolength Duration of audio in milliseconds
727 @param audiotype Type of audio
728 @param framespersample Number of audio frames in each sample
729 @param timescale Timescale of audio track
730 @param averagebitrate Average bitrate of audio
732 @return MP4_OK Success
733 MP4_ERROR Generic error
734 MP4_NOT_AVAILABLE MP4 library needs more data before the
735 requested information can be returned
736 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
737 MP4_NO_AUDIO Input doesn't contain audio track
739 extern IMPORT_C MP4Err MP4ParseRequestAudioDescription(MP4Handle handle, mp4_u32 *audiolength, mp4_u32 *audiotype, mp4_u8 *framespersample, mp4_u32 *timescale, mp4_u32 *averagebitrate);
742 This function returns parameters describing the contents of the MP4
743 file. It can be called after enough data has been inserted into the
744 library so that MP4 headers containing the information can be read.
746 @param handle MP4 library handle
747 @param streamsize Length of the stream in bytes
748 @param streamaveragebitrate Average bitrate of the stream in bps
750 @return MP4_OK Success
751 MP4_ERROR Generic error
752 MP4_NOT_AVAILABLE MP4 library needs more data before the
753 requested information can be returned
754 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
756 extern IMPORT_C MP4Err MP4ParseRequestStreamDescription(MP4Handle handle, mp4_u32 *streamsize, mp4_u32 *streamaveragebitrate);
759 This function inserts MP4 data to the MP4 library.
761 It is necessary to call this function only if the input filename has not
762 been given with MP4ParseOpen. Several functions can return
763 MP4_NOT_AVAILABLE if the library doesn't have enough data to return the
764 information that the caller requests. In that case, more data needs to be
765 inserted to the library before calling those functions again.
767 This function makes a copy of the data inserted into the library so the
768 caller can use buffer for other purposes. If the function returns
769 MP4_OUT_OF_MEMORY, the buffer contents have not been copied into the
770 library and the caller needs to reduce the buffer size before calling
773 If bytestowrite argument is zero, it indicates that there would be no more
774 data to feed via this function. Such a function call MUST be done if a
775 complete 3GP/MP4 file is to be written to the library's internal memory. The
776 buffer argument may be inputted as NULL in such a case.
778 @param handle MP4 library handle
779 @param buffer Data to be written
780 @param bytestowrite Size of buffer in bytes
782 @return MP4_OK Success
783 MP4_ERROR Generic error
784 MP4_OUT_OF_MEMORY Library can't allocate enough memory for the data
786 extern IMPORT_C MP4Err MP4ParseWriteData(MP4Handle handle, mp4_u8 *buffer, mp4_u32 bytestowrite);
789 This function returns the number of bytes that the library instance has
790 in its allocated buffers.
792 The function is only valid when the filename is not provided when opening
793 the library. Zero is returned in bytes when in file mode.
795 @see MP4ParseWriteData.
797 @param handle MP4 library handle
798 @param bytes Number of allocated bytes in the library
800 @return MP4_OK Success
801 MP4_ERROR Generic error
802 MP4_FILE_MODE The library has been opened with the input in a file
804 extern IMPORT_C MP4Err MP4ParseGetBufferedBytes(MP4Handle handle, mp4_u32 *bytes);
807 This function returns the type of the next audio/video frame in the
808 stream. The type can be one of the following:
812 MP4_TYPE_H263_PROFILE_0
813 MP4_TYPE_H263_PROFILE_3
816 MP4_TYPE_AVC_PROFILE_BASELINE
817 MP4_TYPE_AVC_PROFILE_MAIN
818 MP4_TYPE_AVC_PROFILE_EXTENDED
819 MP4_TYPE_AVC_PROFILE_HIGH
822 The function is only valid when the input is streamable.
824 When reading audio/video from an MP4 container in streaming mode, the
825 samples must be read from the container in the same order as they were
826 inserted in it. This function determines the type of the next sample and
827 based on this information the user can call either MP4ParseReadVideoFrame
828 or MP4ParseReadAudioFrames to fetch more data.
830 @param handle MP4 library handle
831 @param type Type of the next frame
833 @return MP4_OK Success
834 MP4_ERROR Generic error
835 MP4_NOT_STREAMABLE The input is not streamable
836 MP4_NOT_AVAILABLE MP4 library needs more data before the
837 requested information can be returned
838 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
839 MP4_NO_FRAME Frame doesn't exist (previous frame was last)
841 extern IMPORT_C MP4Err MP4ParseNextFrameType(MP4Handle handle, mp4_u32 *type);
844 This function returns the size of the next frame of type type in bytes.
845 The frame type can be one of the following:
849 MP4_TYPE_H263_PROFILE_0
850 MP4_TYPE_H263_PROFILE_3
853 MP4_TYPE_AVC_PROFILE_BASELINE
854 MP4_TYPE_AVC_PROFILE_MAIN
855 MP4_TYPE_AVC_PROFILE_EXTENDED
856 MP4_TYPE_AVC_PROFILE_HIGH
859 @param handle MP4 library handle
860 @param type Type of the frame
861 @param framesize Size of the requested frame in bytes
863 @return MP4_OK Success
864 MP4_ERROR Generic error
865 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
866 frames can be returned
867 MP4_NO_REQUESTED_FRAME Frame of requested type is not available
868 MP4_INVALID_TYPE Illegal type
869 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
872 extern IMPORT_C MP4Err MP4ParseNextFrameSize(MP4Handle handle, mp4_u32 type, mp4_u32 *framesize);
875 This function reads the next video frame from the MP4 file/stream and
876 returns it to the caller.
878 Note: Next frame depends on the position in the input MP4 file.
879 MP4ParseSeek can be used to change the current position in the MP4 file.
881 If the function returns MP4_NOT_AVAILABLE, the caller needs to call
882 MP4ParseWriteData to insert more data before calling again.
884 framesize is returned even if buffer was too small to contain the data.
886 Note: Specify NULL as timestamp2 if not interested in this parameter.
888 @param handle MP4 library handle
889 @param buffer Video frame is returned here
890 @param buffersize Size of the user allocated buffer (in bytes)
891 @param framesize Size of the frame that was returned (in bytes)
892 @param timestamp Video frame presentation time in milliseconds from the
893 beginning of the video sequence
894 @param keyframe Has a value of MP4TRUE if current frame is a keyframe
895 (intra) or MP4FALSE otherwise
896 @param timestamp2 Video frame presentation time in timescale from the
897 beginning of the video sequence
899 @return MP4_OK Success
900 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
901 frame can be returned
902 MP4_BUFFER_TOO_SMALL Requested frame doesn't fit into the given buffer
903 MP4_NO_FRAME Frame doesn't exist (previous frame was last)
904 MP4_ERROR Generic error
905 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
907 extern IMPORT_C MP4Err MP4ParseReadVideoFrame(MP4Handle handle, mp4_u8 *buffer, mp4_u32 buffersize, mp4_u32 *framesize, mp4_u32 *timestamp, mp4_bool *keyframe, mp4_u32 *timestamp2);
910 This function reads DecoderSpecificInfo data from MPEG-4 or AVC metadata and
911 returns it to the caller.
913 If the video type is MPEG-4 the DecoderSpecificInfo from the esds atom will be
914 returned. If the video type is AVC (any profile) the DecoderSpecificInfo from the
915 avcC atom will be returned.
917 decspecinfosize is set even if buffer is too small to contain the data.
918 The function can be called with buffersize 0 to query the size of
921 Note: DecoderSpecificInfo is specific to MPEG-4 and AVC video. Therefore,
922 only MPEG-4 or AVC video streams contain this information.
924 @param handle MP4 library handle
925 @param buffer DecoderSpecificInfo is returned here
926 @param buffersize Size of the user allocated buffer (in bytes)
927 @param decspecinfosize Size of DecoderSpecificInfo is returned here
929 @return MP4_OK Success
930 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
931 frames can be returned
932 MP4_BUFFER_TOO_SMALL Requested data doesn't fit into the given buffer
933 MP4_ERROR Generic error
934 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
936 extern IMPORT_C MP4Err MP4ParseReadVideoDecoderSpecificInfo(MP4Handle handle, mp4_u8 *buffer, mp4_u32 buffersize, mp4_u32 *decspecinfosize);
939 This function reads the audio frames that are stored in the current
940 audio sample from the MP4 file/stream and returns them to the caller.
942 Note: Next frame depends on the position in the input MP4 file.
943 MP4ParseSeek can be used to change the current position in the
946 If the function returns MP4_NOT_AVAILABLE, the caller needs to call
947 MP4ParseWriteData to insert more data before calling again.
949 audiosize is returned even if buffer was too small to contain the data.
951 Note: returnedframes may differ from the correct value when accessing
952 the last audio sample.
954 Note: Specify NULL as timestamp2 if not interested in this parameter.
956 @param handle MP4 library handle
957 @param buffer Audio frames are returned here
958 @param buffersize Size of the user allocated buffer (in bytes)
959 @param audiosize Size of the returned audio frames (in bytes)
960 @param timestamp Audio frame presentation time in milliseconds from the
961 beginning of the audio sequence
962 @param returnedframes Number of frames returned, or 0 if not known
963 @param timestamp2 Audio frame presentation time in timescale from the
964 beginning of the audio sequence
966 @return MP4_OK Success
967 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
968 frames can be returned
969 MP4_BUFFER_TOO_SMALL Requested frames don't fit into the given buffer
970 MP4_ERROR Generic error
971 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
972 MP4_NO_FRAME No more frames available
974 extern IMPORT_C MP4Err MP4ParseReadAudioFrames(MP4Handle handle, mp4_u8 *buffer, mp4_u32 buffersize, mp4_u32 *audiosize, mp4_u32 *timestamp, mp4_u32 *returnedframes, mp4_u32 *timestamp2);
977 This function reads DecoderSpecificInfo data from MP4 metadata and
978 returns it to the caller.
980 decspecinfosize is set even if buffer is too small to contain the data.
981 The function can be called with buffersize 0 to query the size of
984 Note: This function can be used for both MPEG-4 audio and AMR.
986 @param handle MP4 library handle
987 @param buffer DecoderSpecificInfo is returned here
988 @param buffersize Size of the user allocated buffer (in bytes)
989 @param decspecinfosize Size of DecoderSpecificInfo is returned here
991 @return MP4_OK Success
992 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
993 frames can be returned
994 MP4_BUFFER_TOO_SMALL Requested data doesn't fit into the given buffer
995 MP4_ERROR Generic error
996 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
998 extern IMPORT_C MP4Err MP4ParseReadAudioDecoderSpecificInfo(MP4Handle handle, mp4_u8 *buffer, mp4_u32 buffersize, mp4_u32 *decspecinfosize);
1001 Return the timestamp of the next video frame. This only works if the
1002 input MP4 data is in a file.
1004 The function can be used to find out which frames have been coded to
1005 optimize the input frame selection if video frame rate needs to be
1008 When this function call returns MP4_END_OF_VIDEO, there are no more video
1009 frames left in the MP4 file and the timestamp returned with the previous
1010 call was the timestamp of the last video frame.
1012 Note: User must call MP4ParseSeek() to seek to the correct position
1013 after calls of this function. Otherwise the current position is
1016 Note: Specify NULL as timestamp2 if this value is not needed.
1018 @param handle MP4 library handle
1019 @param timestamp Timestamp in milliseconds is returned here
1020 @param timestamp2 Timestamp in timescale is returned here
1022 @return MP4_OK Success
1023 MP4_END_OF_VIDEO No more video frames left
1024 MP4_ERROR Generic error
1025 MP4_NOT_AVAILABLE MP4 library needs more data before the
1026 requested information can be returned
1027 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
1029 extern IMPORT_C MP4Err MP4ParseGetNextVideoTimestamp(MP4Handle handle, mp4_u32 *timestamp, mp4_u32 *timestamp2);
1032 This function determines whether the input MP4 stream is streamable,
1033 i.e. the media data is arranged in such a manner that playback can be
1034 started without downloading the entire stream.
1036 @param handle MP4 library handle
1038 @return MP4_OK The file is streamable
1039 MP4_NOT_STREAMABLE The file is not streamable
1040 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
1041 information can be returned
1042 MP4_ERROR Generic error
1043 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
1045 extern IMPORT_C MP4Err MP4ParseIsStreamable(MP4Handle handle);
1048 This function seeks to the position specified by position parameter in
1049 the input MP4 file. The function can be called only if the input MP4 data
1050 is in a file and the file name has been specified with MP4ParseOpen
1053 The position is considered to be from the start of the presentation time
1054 line in the MP4 file. Thus audio and video positions can't be given
1057 The function will set current audio and video positions in the following
1060 If there is only audio in the file, the current position will be set to
1061 the audio frame at or just before the given position.
1063 If there is only video in the file and keyframe is MP4FALSE, the current
1064 position will be set to the video frame at or just before the given
1065 position. If keyframe is set to MP4TRUE, the current position will be set
1066 to the first keyframe at or before current position.
1068 If there are both audio and video in the file, video is first positioned
1069 as explained above and then audio is seeked to the closest position in
1072 @param handle MP4 library handle
1073 @param position Position to seek to in milliseconds in the MP4
1074 presentation time line
1075 @param audioPosition Position of audio after seek (in milliseconds)
1076 @param videoPosition Position of video after seek (in milliseconds)
1077 @param keyframe If set to MP4TRUE, the 1st video keyframe before given
1078 point will be seeked to. If set to MP4FALSE, the first
1079 video frame before given point will be seeked to.
1081 @return MP4_OK Success
1082 MP4_ERROR Generic error
1083 MP4_CANT_SEEK Can't seek to requested position
1086 extern IMPORT_C MP4Err MP4ParseSeek(MP4Handle handle, mp4_u32 position, mp4_u32 *audioPosition, mp4_u32 *videoPosition, mp4_bool keyframe);
1089 This function determines whether the next frame of type type is
1092 The frame type can be one of the following:
1094 MP4_TYPE_MPEG4_VIDEO
1095 MP4_TYPE_MPEG4_AUDIO
1096 MP4_TYPE_H263_PROFILE_0
1097 MP4_TYPE_H263_PROFILE_3
1100 MP4_TYPE_AVC_PROFILE_BASELINE
1101 MP4_TYPE_AVC_PROFILE_MAIN
1102 MP4_TYPE_AVC_PROFILE_EXTENDED
1103 MP4_TYPE_AVC_PROFILE_HIGH
1106 @param handle MP4 library handle
1107 @param type Type of the frame
1109 @return MP4_OK Frame is available
1110 MP4_ERROR Generic error
1111 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
1112 frames can be returned
1113 MP4_NO_REQUESTED_FRAME Frame of requested type is not available
1114 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
1116 extern IMPORT_C MP4Err MP4ParseIsFrameAvailable(MP4Handle handle, mp4_u32 type);
1119 Return the largest position in a file that has been accessed or the latest accessed
1120 absolute byte location of the stream.
1122 Note: The function returns a valid position after one audio or video
1123 sample has been read.
1125 @param handle MP4 library handle
1126 @param position Result is returned here
1128 @return MP4_OK Success
1130 extern IMPORT_C MP4Err MP4ParseGetLastPosition(MP4Handle handle, mp4_u32 *position);
1133 Return the largest position in a file that has been accessed or the latest accessed
1134 absolute byte location of the stream.
1136 Note: The function returns a valid position after one audio or video
1137 sample has been read.
1139 @param handle MP4 library handle
1140 @param position Result is returned here
1142 @return MP4_OK Success
1144 extern IMPORT_C MP4Err MP4ParseGetLastPosition64(MP4Handle handle, mp4_u64 *position);
1147 Return the number of video frames.
1149 @param handle MP4 library handle
1150 @param numberOfFrames Result is returned here
1152 @return MP4_OK Success
1153 MP4_ERROR Generic error
1155 extern IMPORT_C MP4Err MP4ParseGetNumberOfVideoFrames(MP4Handle handle, mp4_u32 *numberOfFrames);
1158 Return video frame size.
1160 @param handle MP4 library handle
1161 @param index Index of video frame
1162 @param frameSize Result is returned here
1164 @return MP4_OK Success
1165 MP4_ERROR Generic error
1167 extern IMPORT_C MP4Err MP4ParseGetVideoFrameSize(MP4Handle handle, mp4_u32 index, mp4_u32 *frameSize);
1170 Return video frame start time.
1172 @param handle MP4 library handle
1173 @param index Index of video frame
1174 @param timestamp Result is returned here
1175 @param timestampms Result in milliseconds
1177 @return MP4_OK Success
1178 MP4_ERROR Generic error
1180 extern IMPORT_C MP4Err MP4ParseGetVideoFrameStartTime(MP4Handle handle, mp4_u32 index, mp4_u32 *timestamp, mp4_u32 *timestampms);
1183 Return video frame type.
1185 @param handle MP4 library handle
1186 @param index Index of video frame
1187 @param frametype Result is returned here
1189 @return MP4_OK Success
1190 MP4_ERROR Generic error
1192 extern IMPORT_C MP4Err MP4ParseGetVideoFrameType(MP4Handle handle, mp4_u32 index, mp4_bool *frametype);
1195 Return the video sample entry index of the next video frame to be read.
1197 The smallest index value is 1.
1199 @param handle MP4 library handle
1200 @param videosampleentryindex Visual SampleEntry index of the next video frame to be read.
1202 @return MP4_OK Success
1203 MP4_ERROR Generic error
1205 extern IMPORT_C MP4Err MP4ParseGetVideoSampleEntryIndex(MP4Handle handle, mp4_u32 *videosampleentryindex);
1208 Return the audio sample entry index of the next audio frame to be read.
1210 The smallest index value is 1.
1212 @param handle MP4 library handle
1213 @param audiosampleentryindex Visual SampleEntry index of the next audio frame to be read.
1215 @return MP4_OK Success
1216 MP4_ERROR Generic error
1218 extern IMPORT_C MP4Err MP4ParseGetAudioSampleEntryIndex(MP4Handle handle, mp4_u32 *audiosampleentryindex);
1221 This function sets the storage mode of QCELP 13K
1222 qcelpStorageMode = 0 ...QCELP will be registered using QCELPSampleEntry Box (Default)
1223 qcelpStorageMode = 1 ...QCELP will be registered using MP4AudioDescription Box
1225 Note: This function needs to be called only when QCLEP 13K is used and when it is going to
1226 be stored registered using the MP4AudioDescription Box.
1228 @param handle MP4 library handle
1229 @param qcelpStorageMode Decoder configuration registration mode of QCELP 13K Codec
1231 @return MP4_OK Success
1232 MP4_ERROR Generic error
1234 extern IMPORT_C MP4Err MP4ComposeSetQCELPStorageMode(MP4Handle handle, mp4_u8 qcelpStorageMode);
1237 Return the decoder configuration registration mode of QCELP 13K Codec.
1239 qcelpStorageMode = 0 QCELP is registered using QCELPSampleEntry Box (Default)
1240 qcelpStorageMode = 1 QCELP is registered using MP4AudioDescription Box
1242 @param handle MP4 library handle
1243 @param qcelpStorageMode Decoder configuration registration mode of QCELP 13K Codec
1245 @return MP4_OK Success
1246 MP4_ERROR Generic error
1248 extern IMPORT_C MP4Err MP4ParseGetQCELPStorageMode(MP4Handle handle, mp4_u8 *qcelpStorageMode);
1251 This function gets the frame infoparameters from star index to number of elements in array from that index,
1252 properties obtained are startTime, frameType and frameSize.
1254 Important Note:--- The number of elements allocated in the array should be equal to the sizeofarray
1257 @param apihandle MP4 library handle
1258 @param startindex Index from where to start getting information for the array
1259 @param sizeofarray number of elements that exist in the allocated frame array
1260 @param aFrameInfoArray Array of Structures of frame parameters
1263 @return MP4_OK Success
1264 MP4_ERROR Generic error
1265 MP4_NO_OUTPUT_BUFFER Output buffer pointer uninitialized
1267 extern IMPORT_C MP4Err MP4GetVideoFrameProperties(MP4Handle apihandle,mp4_u32 startindex,mp4_u32 sizeofarray,TFrameInfoParameters* aFrameInfoArray);
1270 This function sets properties of composed video clip.
1272 Setup details in TVideoClipProperties struct:
1274 mp4_u32 iH263Level level of H.263
1276 @param apihandle MP4 library handle
1277 @param aVideoClipProperties Setup info struct.
1279 @return MP4_OK Success
1280 MP4_ERROR Generic error
1282 extern IMPORT_C MP4Err MP4ComposeSetVideoClipProperties(MP4Handle apihandle, const TVideoClipProperties& aVideoClipProperties);
1285 This function gets properties of parsed video clip.
1287 Returned details in TVideoClipProperties struct:
1289 mp4_u32 iH263Level level of H.263
1291 @param apihandle MP4 library handle
1292 @param aVideoClipProperties Filled info struct.
1294 @return MP4_OK Success
1295 MP4_ERROR Generic error
1297 extern IMPORT_C MP4Err MP4ParseGetVideoClipProperties(MP4Handle apihandle, TVideoClipProperties& aVideoClipProperties);
1300 Retrieve an atom of given type from user data atom (UDTA) to the given buffer.
1302 Note: on return parameters contain following information:
1303 udtaLocation Hash of all locations in file that contain UDTA atom.
1304 MP4_UDTA_NONE | MP4_UDTA_MOOV | MP4_UDTA_VIDEOTRAK | MP4_UDTA_AUDIOTRAK
1305 buffer Buffer containing asked atom.
1306 bufferSize Size of atom written in buffer. If buffer is too small for atom variable contains needed size.
1307 atomIndex Count of same subatom type in this UDTA. Starts from 0 (zero) index.
1309 @param handle MP4 library handle
1310 @param udtaLocation Location of UDTA atom inside file.
1311 @param udtaAtomType Type of atom to be read from UDTA.
1312 Hex value of 4 chars representing atom type defined in standard.
1313 For example: 0x7469746c //'titl' - title for the media atom
1314 0x61757468 //'auth' - author of the media atom
1315 0x676e7265 //'gnre' - genre (category and style) of the media atom
1316 @param buffer Buffer to write atom to.
1317 @param bufferSize Size of given buffer.
1318 @param atomIndex Index of atom if UDTA contains multiple subatoms of same asked udtaAtomType.
1320 @return MP4_OK Success
1321 MP4_ERROR Generic error
1322 MP4_OUTPUT_BUFFER_TOO_SMALL Buffer to write atom to is too small, required size in buffersize argument.
1323 MP4_INVALID_TYPE Asked udtaLocation is invalid.
1324 MP4_NOT_AVAILABLE UDTA or wanted subatom is not available in asked location.
1325 MP4_CANT_SEEK Can't seek to UDTA atom location.
1327 extern IMPORT_C MP4Err MP4ParseGetUserDataAtom(MP4Handle handle,
1328 mp4_u8& udtaLocation,
1329 mp4_u32 udtaAtomType,
1331 mp4_u32& bufferSize,
1332 mp4_u32& atomIndex );
1335 Writes a buffer containing whole atom to inside of user data atom (UDTA) defined in udtaLocation.
1337 @param apihandle MP4 library handle
1338 @param udtaLocation Location of UDTA atom inside file.
1339 MP4_UDTA_MOOV | MP4_UDTA_VIDEOTRAK | MP4_UDTA_AUDIOTRAK
1340 @param buffer Buffer to write atom from.
1341 @param bufferSize Size of buffer.
1343 @return MP4_OK Success
1344 MP4_ERROR Generic error
1345 MP4_OUT_OF_MEMORY Out of memory
1346 MP4_INVALID_TYPE Asked udtaLocation is invalid.
1348 extern IMPORT_C MP4Err MP4ComposeSetUserDataAtom(MP4Handle apihandle,
1349 mp4_u8& udtaLocation,
1351 mp4_u32& bufferSize );
1354 Sets internal buffer sizes to 3GPMP4Lib. Usage optional.
1355 Must be used after MP4ComposeSetFlags when composing.
1357 Defaults for composing (with MP4_FLAG_LARGEFILEBUFFER):
1359 mediaWriteBufferSize: 2048, (2*65536)
1360 writeBufferMaxCount: 15
1362 Default for parsing:
1365 @param apihandle MP4 library handle
1366 @param mediaWriteBufferSize Size of media data file output buffers (bytes).
1367 0 to use default internal value.
1368 @param writeBufferMaxCount Max amount of buffers (both media and meta) before file output changes
1369 to synchronous (by default file writing is asynchronous operation).
1370 0 to use default internal value.
1372 @param readBufferSize Size of file read buffer. 0 to use default internal value.
1374 @return MP4_OK Success
1375 MP4_ERROR Generic error
1376 MP4_OUT_OF_MEMORY Out of Memory error
1378 extern IMPORT_C MP4Err MP4SetCustomFileBufferSizes( MP4Handle apihandle,
1379 mp4_u32 mediaWriteBufferSize,
1380 mp4_u32 writeBufferMaxCount,
1381 mp4_u32 readBufferSize );
1384 This function gets the next frame's dependency information from SDTP box.
1386 Return values of each parameter can be the following:
1388 0: the dependency of this sample is unknown;
1389 1: this sample does depend on others (not an I picture);
1390 2: this sample does not depend on others (I picture);
1393 0: the dependency of other samples on this sample is unknown;
1394 1: other samples depend on this one (not disposable);
1395 2: no other sample depends on this one (disposable);
1398 0: it is unknown whether there is redundant coding in this sample;
1399 1: there is redundant coding in this sample;
1400 2: there is no redundant coding in this sample;
1402 @param apihandle MP4 library handle
1403 @param aDependsOn Defines whether current frame is I-frame (2), isn't I-frame (1) or if it only
1404 can be found out by using MP4ParseReadVideoFrame()-method (0).
1405 @param aIsDependentOn Defined the dependency of other frames on this one
1406 @param aHasRedundancy Defined the existence of redundant coding in this frame
1408 @return MP4_OK Success
1409 MP4_ERROR Generic error
1410 MP4_NOT_AVAILABLE Metadata not available
1411 MP4_INVALID_INPUT_STREAM Error in reading metadata
1412 MP4_NO_OUTPUT_BUFFER Output buffer uninitialized
1414 extern IMPORT_C MP4Err MP4ParseNextVideoFrameDependencies(MP4Handle apihandle, mp4_u8* aDependsOn, mp4_u8* aIsDependentOn, mp4_u8* aHasRedundancy);
1417 This function sets the next frame's dependency information to SDTP box.
1419 NOTE: This function should be called before MP4ComposeWriteVideoFrame for each frame. Otherwise
1420 default values are inserted for the missing frames (0 = unknown).
1422 Possible values for each parameter are the following:
1424 0: the dependency of this sample is unknown;
1425 1: this sample does depend on others (not an I picture);
1426 2: this sample does not depend on others (I picture);
1427 3: reserved, DO NOT USE
1430 0: the dependency of other samples on this sample is unknown;
1431 1: other samples depend on this one (not disposable);
1432 2: no other sample depends on this one (disposable);
1433 3: reserved, DO NOT USE
1436 0: it is unknown whether there is redundant coding in this sample;
1437 1: there is redundant coding in this sample;
1438 2: there is no redundant coding in this sample;
1439 3: reserved, DO NOT USE
1441 @param apihandle MP4 library handle
1442 @param aDependsOn Defines whether current frame is I-frame (2), isn't I-frame (1) or if it only
1443 can be found out by using MP4ParseReadVideoFrame()-method (0).
1444 @param aIsDependentOn Defines the dependency of other frames on this one
1445 @param aHasRedundancy Defines the existence of redundant coding in this frame
1447 @return MP4_OK Success
1448 MP4_ERROR Generic error
1450 extern IMPORT_C MP4Err MP4ComposeWriteNextVideoFrameDependencies(MP4Handle apihandle, mp4_u8 aDependsOn, mp4_u8 aIsDependentOn, mp4_u8 aHasRedundancy);
1453 This function reads the audio frames asynchronously that are stored in the current
1454 audio sample from the MP4 file and returns them to the caller.
1456 Note: Only one async parse audio or video frame(s) operation can be ongoing at any given time.
1458 Note: Observer notification only comes if called function returns MP4_OK.
1459 If given buffer is too small MP4_BUFFER_TOO_SMALL is returned and buffersize contains needed
1460 size for audio frame.
1462 When feeding in parsed clip as memory buffers if the function returns MP4_NOT_AVAILABLE,
1463 the client needs to call MP4ParseWriteData to insert more data before calling this method again.
1465 @param handle MP4 library handle
1466 @param aObserver Observer designed to receive notification of Asynchronous event completion
1467 @param buffer Buffer that audio frames are written to.
1468 @param buffersize Size of the user allocated buffer (in bytes). In MP4_BUFFER_TOO_SMALL error case contains
1469 needed size for memory buffer.
1471 @return MP4_OK Success
1472 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
1473 frames can be returned
1474 MP4_BUFFER_TOO_SMALL Requested frames don't fit into the given buffer
1475 MP4_ERROR Generic error
1476 MP4_FILE_ERROR Async operation is not for buffer mode
1477 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
1478 MP4_NO_FRAME No more frames available
1479 MP4_OUT_OF_MEMORY Out of Memory.
1481 extern IMPORT_C MP4Err MP4ParseReadAudioFramesAsync(MP4Handle handle, M3GPMP4LibAsyncObserver* aObserver, mp4_u8 *buffer, mp4_u32* buffersize );
1484 This function reads the next video frame from the MP4 file and returns it to the caller.
1486 Note: Only one async parse audio or video frame(s) operation can be ongoing at any given time.
1488 Note: Observer notification only comes if called function returns MP4_OK.
1489 If given buffer is too small MP4_BUFFER_TOO_SMALL is returned and buffersize contains needed
1490 size for video frame.
1492 When feeding in parsed clip as memory buffers if the function returns MP4_NOT_AVAILABLE,
1493 the client needs to call MP4ParseWriteData to insert more data before calling this method again.
1495 @param handle MP4 library handle
1496 @param aObserver Observer designed to receive notification of Asynchronous event completion
1497 @param buffer Video frame is returned here
1498 @param buffersize Size of the user allocated buffer (in bytes). In MP4_BUFFER_TOO_SMALL error case contains
1499 needed size for memory buffer.
1501 @return MP4_OK Success
1502 MP4_NOT_AVAILABLE MP4 library needs more data before the requested
1503 frame can be returned
1504 MP4_BUFFER_TOO_SMALL Requested frame doesn't fit into the given buffer
1505 MP4_NO_FRAME Frame doesn't exist (previous frame was last)
1506 MP4_ERROR Generic error
1507 MP4_OUT_OF_MEMORY Out of Memory
1508 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
1509 MP4_FILE_ERROR Async operation is not for buffer mode
1511 extern IMPORT_C MP4Err MP4ParseReadVideoFrameAsync(MP4Handle handle, M3GPMP4LibAsyncObserver* aObserver, mp4_u8* buffer, mp4_u32* buffersize );
1514 This function sets async temporary file deleting observer. Meta data temporary file removing can be done
1515 on background to improve video recording stopping.
1517 @param handle MP4 library handle
1518 @param aObserver Temorary file deleting observer
1520 @return MP4_OK Success
1521 MP4_ERROR Generic error
1524 extern IMPORT_C MP4Err MP4ComposeSetTempFileRemoverObserver(MP4Handle *handle, M3GPMP4LibAsyncTempFileRemoverObserver *aObserver);
1527 This function cancels the outstanding asynchronous read audio/video frame request.
1529 No callback function will be called.
1531 Note: As only one asynchronous parse audio or video frame(s) operation can be ongoing at any given time,
1532 this function can be used to cancel audio or video read request. If this is called without any outstanding
1533 request, nothing happens.
1535 @param handle MP4 library handle
1537 @see MP4ParseReadVideoFrameAsync
1538 @see MP4ParseReadAudioFramesAsync
1540 extern IMPORT_C void MP4CancelReadFrame(MP4Handle handle);
1543 Fetches ID32 data location.
1547 @param handle MP4 library handle
1548 @param location Returns ID32 data location
1550 @return MP4_OK Success
1551 MP4_ERROR Generic error
1552 MP4_INVALID_INPUT_STREAM MP4 stream is invalid
1553 MP4_NOT_AVAILABLE Metadata, META atom or ID32 atom is not available
1555 extern IMPORT_C MP4Err MP4ParseGetID32Location(MP4Handle apihandle, mp4_u32& location);