2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of
5
* the License at http://www.mozilla.org/MPL/
7
* Software distributed under the License is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the License for the specific language governing
10
* rights and limitations under the License.
12
* The Original Code is MPEG4IP.
14
* The Initial Developer of the Original Code is Cisco Systems Inc.
15
* Portions created by Cisco Systems Inc. are
16
* Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
19
* Dave Mackie dmackie@cisco.com
20
* Alix Marchandise-Franquet alix@cisco.com
23
#ifndef __MP4_INCLUDED__
24
#define __MP4_INCLUDED__
26
/* include system and project specific headers */
29
#include <math.h> /* to define float HUGE_VAL and/or NAN */
35
/* exploit C++ ability of default values for function parameters */
42
typedef void* MP4FileHandle;
43
typedef u_int32_t MP4TrackId;
44
typedef u_int32_t MP4SampleId;
45
typedef u_int64_t MP4Timestamp;
46
typedef u_int64_t MP4Duration;
47
typedef u_int32_t MP4EditId;
49
/* Invalid values for API types */
50
#define MP4_INVALID_FILE_HANDLE ((MP4FileHandle)NULL)
51
#define MP4_INVALID_TRACK_ID ((MP4TrackId)0)
52
#define MP4_INVALID_SAMPLE_ID ((MP4SampleId)0)
53
#define MP4_INVALID_TIMESTAMP ((MP4Timestamp)-1)
54
#define MP4_INVALID_DURATION ((MP4Duration)-1)
55
#define MP4_INVALID_EDIT_ID ((MP4EditId)0)
57
/* Macros to test for API type validity */
58
#define MP4_IS_VALID_FILE_HANDLE(x) ((x) != MP4_INVALID_FILE_HANDLE)
59
#define MP4_IS_VALID_TRACK_ID(x) ((x) != MP4_INVALID_TRACK_ID)
60
#define MP4_IS_VALID_SAMPLE_ID(x) ((x) != MP4_INVALID_SAMPLE_ID)
61
#define MP4_IS_VALID_TIMESTAMP(x) ((x) != MP4_INVALID_TIMESTAMP)
62
#define MP4_IS_VALID_DURATION(x) ((x) != MP4_INVALID_DURATION)
63
#define MP4_IS_VALID_EDIT_ID(x) ((x) != MP4_INVALID_EDIT_ID)
65
/* MP4 verbosity levels - e.g. MP4SetVerbosity() */
66
#define MP4_DETAILS_ALL 0xFFFFFFFF
67
#define MP4_DETAILS_ERROR 0x00000001
68
#define MP4_DETAILS_WARNING 0x00000002
69
#define MP4_DETAILS_READ 0x00000004
70
#define MP4_DETAILS_WRITE 0x00000008
71
#define MP4_DETAILS_FIND 0x00000010
72
#define MP4_DETAILS_TABLE 0x00000020
73
#define MP4_DETAILS_SAMPLE 0x00000040
74
#define MP4_DETAILS_HINT 0x00000080
75
#define MP4_DETAILS_ISMA 0x00000100
76
#define MP4_DETAILS_EDIT 0x00000200
78
#define MP4_DETAILS_READ_ALL \
79
(MP4_DETAILS_READ | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE)
80
#define MP4_DETAILS_WRITE_ALL \
81
(MP4_DETAILS_WRITE | MP4_DETAILS_TABLE | MP4_DETAILS_SAMPLE)
84
* MP4 Known track type names - e.g. MP4GetNumberOfTracks(type)
86
* Note this first group of track types should be created
87
* via the MP4Add<Type>Track() functions, and not MP4AddTrack(type)
89
#define MP4_OD_TRACK_TYPE "odsm"
90
#define MP4_SCENE_TRACK_TYPE "sdsm"
91
#define MP4_AUDIO_TRACK_TYPE "soun"
92
#define MP4_VIDEO_TRACK_TYPE "vide"
93
#define MP4_HINT_TRACK_TYPE "hint"
95
* This second set of track types should be created
96
* via MP4AddSystemsTrack(type)
98
#define MP4_CLOCK_TRACK_TYPE "crsm"
99
#define MP4_MPEG7_TRACK_TYPE "m7sm"
100
#define MP4_OCI_TRACK_TYPE "ocsm"
101
#define MP4_IPMP_TRACK_TYPE "ipsm"
102
#define MP4_MPEGJ_TRACK_TYPE "mjsm"
104
#define MP4_IS_VIDEO_TRACK_TYPE(type) \
105
(!strcasecmp(type, MP4_VIDEO_TRACK_TYPE))
107
#define MP4_IS_AUDIO_TRACK_TYPE(type) \
108
(!strcasecmp(type, MP4_AUDIO_TRACK_TYPE))
110
#define MP4_IS_OD_TRACK_TYPE(type) \
111
(!strcasecmp(type, MP4_OD_TRACK_TYPE))
113
#define MP4_IS_SCENE_TRACK_TYPE(type) \
114
(!strcasecmp(type, MP4_SCENE_TRACK_TYPE))
116
#define MP4_IS_HINT_TRACK_TYPE(type) \
117
(!strcasecmp(type, MP4_HINT_TRACK_TYPE))
119
#define MP4_IS_SYSTEMS_TRACK_TYPE(type) \
120
(!strcasecmp(type, MP4_CLOCK_TRACK_TYPE) \
121
|| !strcasecmp(type, MP4_MPEG7_TRACK_TYPE) \
122
|| !strcasecmp(type, MP4_OCI_TRACK_TYPE) \
123
|| !strcasecmp(type, MP4_IPMP_TRACK_TYPE) \
124
|| !strcasecmp(type, MP4_MPEGJ_TRACK_TYPE))
126
/* MP4 Audio track types - see MP4AddAudioTrack()*/
127
#define MP4_INVALID_AUDIO_TYPE 0x00
128
#define MP4_MPEG1_AUDIO_TYPE 0x6B
129
#define MP4_MPEG2_AUDIO_TYPE 0x69
130
#define MP4_MP3_AUDIO_TYPE MP4_MPEG2_AUDIO_TYPE
131
#define MP4_MPEG2_AAC_MAIN_AUDIO_TYPE 0x66
132
#define MP4_MPEG2_AAC_LC_AUDIO_TYPE 0x67
133
#define MP4_MPEG2_AAC_SSR_AUDIO_TYPE 0x68
134
#define MP4_MPEG2_AAC_AUDIO_TYPE MP4_MPEG2_AAC_MAIN_AUDIO_TYPE
135
#define MP4_MPEG4_AUDIO_TYPE 0x40
136
#define MP4_PRIVATE_AUDIO_TYPE 0xC0
137
#define MP4_PCM16_LITTLE_ENDIAN_AUDIO_TYPE 0xE0 /* a private definition */
138
#define MP4_VORBIS_AUDIO_TYPE 0xE1 /* a private definition */
139
#define MP4_AC3_AUDIO_TYPE 0xE2 /* a private definition */
140
#define MP4_ALAW_AUDIO_TYPE 0xE3 /* a private definition */
141
#define MP4_ULAW_AUDIO_TYPE 0xE4 /* a private definition */
142
#define MP4_G723_AUDIO_TYPE 0xE5 /* a private definition */
143
#define MP4_PCM16_BIG_ENDIAN_AUDIO_TYPE 0xE6 /* a private definition */
145
/* MP4 MPEG-4 Audio types from 14496-3 Table 1.5.1 */
146
#define MP4_MPEG4_INVALID_AUDIO_TYPE 0
147
#define MP4_MPEG4_AAC_MAIN_AUDIO_TYPE 1
148
#define MP4_MPEG4_AAC_LC_AUDIO_TYPE 2
149
#define MP4_MPEG4_AAC_SSR_AUDIO_TYPE 3
150
#define MP4_MPEG4_AAC_LTP_AUDIO_TYPE 4
151
#define MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE 6
152
#define MP4_MPEG4_CELP_AUDIO_TYPE 8
153
#define MP4_MPEG4_HVXC_AUDIO_TYPE 9
154
#define MP4_MPEG4_TTSI_AUDIO_TYPE 12
155
#define MP4_MPEG4_MAIN_SYNTHETIC_AUDIO_TYPE 13
156
#define MP4_MPEG4_WAVETABLE_AUDIO_TYPE 14
157
#define MP4_MPEG4_MIDI_AUDIO_TYPE 15
158
#define MP4_MPEG4_ALGORITHMIC_FX_AUDIO_TYPE 16
160
/* MP4 Audio type utilities following common usage */
161
#define MP4_IS_MP3_AUDIO_TYPE(type) \
162
((type) == MP4_MPEG1_AUDIO_TYPE || (type) == MP4_MPEG2_AUDIO_TYPE)
164
#define MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
165
(((type) >= MP4_MPEG2_AAC_MAIN_AUDIO_TYPE \
166
&& (type) <= MP4_MPEG2_AAC_SSR_AUDIO_TYPE))
168
#define MP4_IS_MPEG4_AAC_AUDIO_TYPE(mpeg4Type) \
169
(((mpeg4Type) >= MP4_MPEG4_AAC_MAIN_AUDIO_TYPE \
170
&& (mpeg4Type) <= MP4_MPEG4_AAC_LTP_AUDIO_TYPE) \
171
|| (mpeg4Type) == MP4_MPEG4_AAC_SCALABLE_AUDIO_TYPE \
172
|| (mpeg4Type) == 17)
174
#define MP4_IS_AAC_AUDIO_TYPE(type) \
175
(MP4_IS_MPEG2_AAC_AUDIO_TYPE(type) \
176
|| (type) == MP4_MPEG4_AUDIO_TYPE)
178
/* MP4 Video track types - see MP4AddVideoTrack() */
179
#define MP4_INVALID_VIDEO_TYPE 0x00
180
#define MP4_MPEG1_VIDEO_TYPE 0x6A
181
#define MP4_MPEG2_SIMPLE_VIDEO_TYPE 0x60
182
#define MP4_MPEG2_MAIN_VIDEO_TYPE 0x61
183
#define MP4_MPEG2_SNR_VIDEO_TYPE 0x62
184
#define MP4_MPEG2_SPATIAL_VIDEO_TYPE 0x63
185
#define MP4_MPEG2_HIGH_VIDEO_TYPE 0x64
186
#define MP4_MPEG2_442_VIDEO_TYPE 0x65
187
#define MP4_MPEG2_VIDEO_TYPE MP4_MPEG2_MAIN_VIDEO_TYPE
188
#define MP4_MPEG4_VIDEO_TYPE 0x20
189
#define MP4_JPEG_VIDEO_TYPE 0x6C
190
#define MP4_PRIVATE_VIDEO_TYPE 0xD0
191
#define MP4_YUV12_VIDEO_TYPE 0xF0 /* a private definition */
192
#define MP4_H264_VIDEO_TYPE 0xF1 /* a private definition */
193
#define MP4_H263_VIDEO_TYPE 0xF2 /* a private definition */
194
#define MP4_H261_VIDEO_TYPE 0xF3 /* a private definition */
196
/* MP4 Video type utilities */
197
#define MP4_IS_MPEG1_VIDEO_TYPE(type) \
198
((type) == MP4_MPEG1_VIDEO_TYPE)
200
#define MP4_IS_MPEG2_VIDEO_TYPE(type) \
201
(((type) >= MP4_MPEG2_SIMPLE_VIDEO_TYPE \
202
&& (type) <= MP4_MPEG2_442_VIDEO_TYPE) \
203
|| MP4_IS_MPEG1_VIDEO_TYPE(type))
205
#define MP4_IS_MPEG4_VIDEO_TYPE(type) \
206
((type) == MP4_MPEG4_VIDEO_TYPE)
209
/* MP4 API declarations */
215
/* file operations */
217
MP4FileHandle MP4Create(
218
const char* fileName,
219
u_int32_t verbosity DEFAULT(0),
220
bool use64bits DEFAULT(0),
221
bool useExtensibleFormat DEFAULT(0));
223
MP4FileHandle MP4Modify(
224
const char* fileName,
225
u_int32_t verbosity DEFAULT(0),
226
bool useExtensibleFormat DEFAULT(0));
228
MP4FileHandle MP4Read(
229
const char* fileName,
230
u_int32_t verbosity DEFAULT(0));
233
MP4FileHandle hFile);
236
const char* existingFileName,
237
const char* newFileName DEFAULT(NULL),
238
u_int32_t verbosity DEFAULT(0));
242
FILE* pDumpFile DEFAULT(NULL),
243
bool dumpImplicits DEFAULT(0));
247
MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
250
const char* fileName,
251
MP4TrackId trackId DEFAULT(MP4_INVALID_TRACK_ID));
253
/* file properties */
255
/* specific file properties */
257
u_int32_t MP4GetVerbosity(MP4FileHandle hFile);
259
bool MP4SetVerbosity(MP4FileHandle hFile, u_int32_t verbosity);
261
MP4Duration MP4GetDuration(MP4FileHandle hFile);
263
u_int32_t MP4GetTimeScale(MP4FileHandle hFile);
265
bool MP4SetTimeScale(MP4FileHandle hFile, u_int32_t value);
267
u_int8_t MP4GetODProfileLevel(MP4FileHandle hFile);
269
bool MP4SetODProfileLevel(MP4FileHandle hFile, u_int8_t value);
271
u_int8_t MP4GetSceneProfileLevel(MP4FileHandle hFile);
273
bool MP4SetSceneProfileLevel(MP4FileHandle hFile, u_int8_t value);
275
u_int8_t MP4GetVideoProfileLevel(MP4FileHandle hFile);
277
bool MP4SetVideoProfileLevel(MP4FileHandle hFile, u_int8_t value);
279
u_int8_t MP4GetAudioProfileLevel(MP4FileHandle hFile);
281
bool MP4SetAudioProfileLevel(MP4FileHandle hFile, u_int8_t value);
283
u_int8_t MP4GetGraphicsProfileLevel(MP4FileHandle hFile);
285
bool MP4SetGraphicsProfileLevel(MP4FileHandle hFile, u_int8_t value);
287
/* generic file properties */
289
u_int64_t MP4GetIntegerProperty(
291
const char* propName);
293
float MP4GetFloatProperty(
295
const char* propName);
297
const char* MP4GetStringProperty(
299
const char* propName);
301
void MP4GetBytesProperty(
303
const char* propName,
305
u_int32_t* pValueSize);
307
bool MP4SetIntegerProperty(
309
const char* propName,
312
bool MP4SetFloatProperty(
314
const char* propName,
317
bool MP4SetStringProperty(
318
MP4FileHandle hFile, const char* propName, const char* value);
320
bool MP4SetBytesProperty(
321
MP4FileHandle hFile, const char* propName,
322
const u_int8_t* pValue, u_int32_t valueSize);
324
/* track operations */
326
MP4TrackId MP4AddTrack(
330
MP4TrackId MP4AddSystemsTrack(
334
MP4TrackId MP4AddODTrack(
335
MP4FileHandle hFile);
337
MP4TrackId MP4AddSceneTrack(
338
MP4FileHandle hFile);
340
MP4TrackId MP4AddAudioTrack(
343
MP4Duration sampleDuration,
344
u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
346
MP4TrackId MP4AddEncAudioTrack(
349
MP4Duration sampleDuration,
350
u_int8_t audioType DEFAULT(MP4_MPEG4_AUDIO_TYPE));
352
MP4TrackId MP4AddVideoTrack(
355
MP4Duration sampleDuration,
358
u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE));
360
MP4TrackId MP4AddEncVideoTrack(
363
MP4Duration sampleDuration,
366
u_int8_t videoType DEFAULT(MP4_MPEG4_VIDEO_TYPE));
368
MP4TrackId MP4AddHintTrack(
370
MP4TrackId refTrackId);
372
MP4TrackId MP4CloneTrack(
373
MP4FileHandle srcFile,
374
MP4TrackId srcTrackId,
375
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE));
377
MP4TrackId MP4EncAndCloneTrack(
378
MP4FileHandle srcFile,
379
MP4TrackId srcTrackId,
380
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE));
382
MP4TrackId MP4CopyTrack(
383
MP4FileHandle srcFile,
384
MP4TrackId srcTrackId,
385
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
386
bool applyEdits DEFAULT(false));
388
MP4TrackId MP4EncAndCopyTrack(
389
MP4FileHandle srcFile,
390
MP4TrackId srcTrackId,
391
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
392
bool applyEdits DEFAULT(false));
398
u_int32_t MP4GetNumberOfTracks(
400
const char* type DEFAULT(NULL),
401
u_int8_t subType DEFAULT(0));
403
MP4TrackId MP4FindTrackId(
406
const char* type DEFAULT(NULL),
407
u_int8_t subType DEFAULT(0));
409
u_int16_t MP4FindTrackIndex(
413
/* track properties */
415
/* specific track properties */
417
const char* MP4GetTrackType(
421
MP4Duration MP4GetTrackDuration(
425
u_int32_t MP4GetTrackTimeScale(
429
bool MP4SetTrackTimeScale(
434
// Should not be used, replace with MP4GetTrackEsdsObjectTypeId
435
u_int8_t MP4GetTrackAudioType(
439
u_int8_t MP4GetTrackAudioMpeg4Type(
443
// Should not be used, replace with MP4GetTrackEsdsObjectTypeId
444
u_int8_t MP4GetTrackVideoType(
448
u_int8_t MP4GetTrackEsdsObjectTypeId(
452
/* returns MP4_INVALID_DURATION if track samples do not have a fixed duration */
453
MP4Duration MP4GetTrackFixedSampleDuration(
457
u_int32_t MP4GetTrackBitRate(
461
bool MP4GetTrackESConfiguration(
465
u_int32_t* pConfigSize);
467
bool MP4SetTrackESConfiguration(
470
const u_int8_t* pConfig,
471
u_int32_t configSize);
473
MP4SampleId MP4GetTrackNumberOfSamples(
477
u_int16_t MP4GetTrackVideoWidth(
481
u_int16_t MP4GetTrackVideoHeight(
485
float MP4GetTrackVideoFrameRate(
489
/* generic track properties */
491
u_int64_t MP4GetTrackIntegerProperty(
494
const char* propName);
496
float MP4GetTrackFloatProperty(
499
const char* propName);
501
const char* MP4GetTrackStringProperty(
504
const char* propName);
506
void MP4GetTrackBytesProperty(
509
const char* propName,
511
u_int32_t* pValueSize);
513
bool MP4SetTrackIntegerProperty(
516
const char* propName,
519
bool MP4SetTrackFloatProperty(
522
const char* propName,
525
bool MP4SetTrackStringProperty(
528
const char* propName,
531
bool MP4SetTrackBytesProperty(
534
const char* propName,
535
const u_int8_t* pValue,
536
u_int32_t valueSize);
538
/* sample operations */
541
/* input parameters */
544
MP4SampleId sampleId,
545
/* input/output parameters */
547
u_int32_t* pNumBytes,
548
/* output parameters */
549
MP4Timestamp* pStartTime DEFAULT(NULL),
550
MP4Duration* pDuration DEFAULT(NULL),
551
MP4Duration* pRenderingOffset DEFAULT(NULL),
552
bool* pIsSyncSample DEFAULT(NULL));
554
/* uses (unedited) time to specify sample instead of sample id */
555
bool MP4ReadSampleFromTime(
556
/* input parameters */
560
/* input/output parameters */
562
u_int32_t* pNumBytes,
563
/* output parameters */
564
MP4Timestamp* pStartTime DEFAULT(NULL),
565
MP4Duration* pDuration DEFAULT(NULL),
566
MP4Duration* pRenderingOffset DEFAULT(NULL),
567
bool* pIsSyncSample DEFAULT(NULL));
572
const u_int8_t* pBytes,
574
MP4Duration duration DEFAULT(MP4_INVALID_DURATION),
575
MP4Duration renderingOffset DEFAULT(0),
576
bool isSyncSample DEFAULT(true));
579
MP4FileHandle srcFile,
580
MP4TrackId srcTrackId,
581
MP4SampleId srcSampleId,
582
MP4FileHandle dstFile DEFAULT(MP4_INVALID_FILE_HANDLE),
583
MP4TrackId dstTrackId DEFAULT(MP4_INVALID_TRACK_ID),
584
MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
586
/* Note this function is not yet implemented */
587
bool MP4ReferenceSample(
588
MP4FileHandle srcFile,
589
MP4TrackId srcTrackId,
590
MP4SampleId srcSampleId,
591
MP4FileHandle dstFile,
592
MP4TrackId dstTrackId,
593
MP4Duration dstSampleDuration DEFAULT(MP4_INVALID_DURATION));
595
u_int32_t MP4GetSampleSize(
598
MP4SampleId sampleId);
600
u_int32_t MP4GetTrackMaxSampleSize(
604
MP4SampleId MP4GetSampleIdFromTime(
608
bool wantSyncSample DEFAULT(false));
610
MP4Timestamp MP4GetSampleTime(
613
MP4SampleId sampleId);
615
MP4Duration MP4GetSampleDuration(
618
MP4SampleId sampleId);
620
MP4Duration MP4GetSampleRenderingOffset(
623
MP4SampleId sampleId);
625
bool MP4SetSampleRenderingOffset(
628
MP4SampleId sampleId,
629
MP4Duration renderingOffset);
631
int8_t MP4GetSampleSync(
634
MP4SampleId sampleId);
636
/* rtp hint track operations */
638
bool MP4GetHintTrackRtpPayload(
640
MP4TrackId hintTrackId,
641
char** ppPayloadName DEFAULT(NULL),
642
u_int8_t* pPayloadNumber DEFAULT(NULL),
643
u_int16_t* pMaxPayloadSize DEFAULT(NULL),
644
char **ppEncodingParams DEFAULT(NULL));
646
#define MP4_SET_DYNAMIC_PAYLOAD 0xff
648
bool MP4SetHintTrackRtpPayload(
650
MP4TrackId hintTrackId,
651
const char* pPayloadName,
652
u_int8_t* pPayloadNumber,
653
u_int16_t maxPayloadSize DEFAULT(0),
654
const char *encode_params DEFAULT(NULL),
655
bool include_rtp_map DEFAULT(true),
656
bool include_mpeg4_esid DEFAULT(true));
658
const char* MP4GetSessionSdp(
659
MP4FileHandle hFile);
661
bool MP4SetSessionSdp(
663
const char* sdpString);
665
bool MP4AppendSessionSdp(
667
const char* sdpString);
669
const char* MP4GetHintTrackSdp(
671
MP4TrackId hintTrackId);
673
bool MP4SetHintTrackSdp(
675
MP4TrackId hintTrackId,
676
const char* sdpString);
678
bool MP4AppendHintTrackSdp(
680
MP4TrackId hintTrackId,
681
const char* sdpString);
683
MP4TrackId MP4GetHintTrackReferenceTrackId(
685
MP4TrackId hintTrackId);
689
MP4TrackId hintTrackId,
690
MP4SampleId hintSampleId,
691
u_int16_t* pNumPackets DEFAULT(NULL));
693
u_int16_t MP4GetRtpHintNumberOfPackets(
695
MP4TrackId hintTrackId);
697
int8_t MP4GetRtpPacketBFrame(
699
MP4TrackId hintTrackId,
700
u_int16_t packetIndex);
702
int32_t MP4GetRtpPacketTransmitOffset(
704
MP4TrackId hintTrackId,
705
u_int16_t packetIndex);
707
bool MP4ReadRtpPacket(
709
MP4TrackId hintTrackId,
710
u_int16_t packetIndex,
712
u_int32_t* pNumBytes,
713
u_int32_t ssrc DEFAULT(0),
714
bool includeHeader DEFAULT(true),
715
bool includePayload DEFAULT(true));
717
MP4Timestamp MP4GetRtpTimestampStart(
719
MP4TrackId hintTrackId);
721
bool MP4SetRtpTimestampStart(
723
MP4TrackId hintTrackId,
724
MP4Timestamp rtpStart);
728
MP4TrackId hintTrackId);
730
bool MP4AddRtpVideoHint(
732
MP4TrackId hintTrackId,
733
bool isBframe DEFAULT(false),
734
u_int32_t timestampOffset DEFAULT(0));
736
bool MP4AddRtpPacket(
738
MP4TrackId hintTrackId,
739
bool setMbit DEFAULT(false),
740
int32_t transmitOffset DEFAULT(0));
742
bool MP4AddRtpImmediateData(
744
MP4TrackId hintTrackId,
745
const u_int8_t* pBytes,
748
bool MP4AddRtpSampleData(
750
MP4TrackId hintTrackId,
751
MP4SampleId sampleId,
752
u_int32_t dataOffset,
753
u_int32_t dataLength);
755
bool MP4AddRtpESConfigurationPacket(
757
MP4TrackId hintTrackId);
759
bool MP4WriteRtpHint(
761
MP4TrackId hintTrackId,
762
MP4Duration duration,
763
bool isSyncSample DEFAULT(true));
765
/* ISMA specific utilities */
767
bool MP4MakeIsmaCompliant(const char* fileName,
768
u_int32_t verbosity DEFAULT(0),
769
bool addIsmaComplianceSdp DEFAULT(true));
771
char* MP4MakeIsmaSdpIod(
772
u_int8_t videoProfile,
773
u_int32_t videoBitrate,
774
u_int8_t* videoConfig,
775
u_int32_t videoConfigLength,
776
u_int8_t audioProfile,
777
u_int32_t audioBitrate,
778
u_int8_t* audioConfig,
779
u_int32_t audioConfigLength,
780
u_int32_t verbosity DEFAULT(0));
784
/* NOTE this section of functionality
785
* has not yet been fully tested
788
MP4EditId MP4AddTrackEdit(
791
MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID),
792
MP4Timestamp startTime DEFAULT(0),
793
MP4Duration duration DEFAULT(0),
794
bool dwell DEFAULT(false));
796
bool MP4DeleteTrackEdit(
801
u_int32_t MP4GetTrackNumberOfEdits(
805
MP4Timestamp MP4GetTrackEditStart(
810
MP4Duration MP4GetTrackEditTotalDuration(
813
MP4EditId editId DEFAULT(MP4_INVALID_EDIT_ID));
815
MP4Timestamp MP4GetTrackEditMediaStart(
820
bool MP4SetTrackEditMediaStart(
824
MP4Timestamp startTime);
826
MP4Duration MP4GetTrackEditDuration(
831
bool MP4SetTrackEditDuration(
835
MP4Duration duration);
837
int8_t MP4GetTrackEditDwell(
842
bool MP4SetTrackEditDwell(
848
bool MP4ReadSampleFromEditTime(
849
/* input parameters */
853
/* input/output parameters */
855
u_int32_t* pNumBytes,
856
/* output parameters */
857
MP4Timestamp* pStartTime DEFAULT(NULL),
858
MP4Duration* pDuration DEFAULT(NULL),
859
MP4Duration* pRenderingOffset DEFAULT(NULL),
860
bool* pIsSyncSample DEFAULT(NULL));
862
MP4SampleId MP4GetSampleIdFromEditTime(
866
MP4Timestamp* pStartTime DEFAULT(NULL),
867
MP4Duration* pDuration DEFAULT(NULL));
869
/* time conversion utilties */
871
/* predefined values for timeScale parameter below */
872
#define MP4_SECONDS_TIME_SCALE 1
873
#define MP4_MILLISECONDS_TIME_SCALE 1000
874
#define MP4_MICROSECONDS_TIME_SCALE 1000000
875
#define MP4_NANOSECONDS_TIME_SCALE 1000000000
877
#define MP4_SECS_TIME_SCALE MP4_SECONDS_TIME_SCALE
878
#define MP4_MSECS_TIME_SCALE MP4_MILLISECONDS_TIME_SCALE
879
#define MP4_USECS_TIME_SCALE MP4_MICROSECONDS_TIME_SCALE
880
#define MP4_NSECS_TIME_SCALE MP4_NANOSECONDS_TIME_SCALE
882
u_int64_t MP4ConvertFromMovieDuration(
884
MP4Duration duration,
885
u_int32_t timeScale);
887
u_int64_t MP4ConvertFromTrackTimestamp(
890
MP4Timestamp timeStamp,
891
u_int32_t timeScale);
893
MP4Timestamp MP4ConvertToTrackTimestamp(
897
u_int32_t timeScale);
899
u_int64_t MP4ConvertFromTrackDuration(
902
MP4Duration duration,
903
u_int32_t timeScale);
905
MP4Duration MP4ConvertToTrackDuration(
909
u_int32_t timeScale);
911
char* MP4BinaryToBase16(
912
const u_int8_t* pData,
915
char* MP4BinaryToBase64(
916
const u_int8_t* pData,
919
/* iTunes metadata handling */
920
bool MP4MetadataDelete(MP4FileHandle hFile);
921
bool MP4GetMetadataByIndex(MP4FileHandle hFile, u_int32_t index,
923
u_int8_t** ppValue, u_int32_t* pValueSize);
924
bool MP4SetMetadataName(MP4FileHandle hFile, const char* value);
925
bool MP4GetMetadataName(MP4FileHandle hFile, char** value);
926
bool MP4SetMetadataArtist(MP4FileHandle hFile, const char* value);
927
bool MP4GetMetadataArtist(MP4FileHandle hFile, char** value);
928
bool MP4SetMetadataWriter(MP4FileHandle hFile, const char* value);
929
bool MP4GetMetadataWriter(MP4FileHandle hFile, char** value);
930
bool MP4SetMetadataComment(MP4FileHandle hFile, const char* value);
931
bool MP4GetMetadataComment(MP4FileHandle hFile, char** value);
932
bool MP4SetMetadataTool(MP4FileHandle hFile, const char* value);
933
bool MP4GetMetadataTool(MP4FileHandle hFile, char** value);
934
bool MP4SetMetadataYear(MP4FileHandle hFile, const char* value);
935
bool MP4GetMetadataYear(MP4FileHandle hFile, char** value);
936
bool MP4SetMetadataAlbum(MP4FileHandle hFile, const char* value);
937
bool MP4GetMetadataAlbum(MP4FileHandle hFile, char** value);
938
bool MP4SetMetadataTrack(MP4FileHandle hFile,
939
u_int16_t track, u_int16_t totalTracks);
940
bool MP4GetMetadataTrack(MP4FileHandle hFile,
941
u_int16_t* track, u_int16_t* totalTracks);
942
bool MP4SetMetadataDisk(MP4FileHandle hFile,
943
u_int16_t disk, u_int16_t totalDisks);
944
bool MP4GetMetadataDisk(MP4FileHandle hFile,
945
u_int16_t* disk, u_int16_t* totalDisks);
946
bool MP4SetMetadataGenre(MP4FileHandle hFile, const char* genre);
947
bool MP4GetMetadataGenre(MP4FileHandle hFile, char** genre);
948
bool MP4SetMetadataTempo(MP4FileHandle hFile, u_int16_t tempo);
949
bool MP4GetMetadataTempo(MP4FileHandle hFile, u_int16_t* tempo);
950
bool MP4SetMetadataCompilation(MP4FileHandle hFile, u_int8_t cpl);
951
bool MP4GetMetadataCompilation(MP4FileHandle hFile, u_int8_t* cpl);
952
bool MP4SetMetadataCoverArt(MP4FileHandle hFile,
953
u_int8_t *coverArt, u_int32_t size);
954
bool MP4GetMetadataCoverArt(MP4FileHandle hFile,
955
u_int8_t **coverArt, u_int32_t* size);
956
bool MP4SetMetadataFreeForm(MP4FileHandle hFile, char *name,
957
u_int8_t* pValue, u_int32_t valueSize);
958
bool MP4GetMetadataFreeForm(MP4FileHandle hFile, char *name,
959
u_int8_t** pValue, u_int32_t* valueSize);
961
//#ifdef USE_FILE_CALLBACKS
962
typedef u_int32_t (*MP4OpenCallback)(const char *pName, const char *mode, void *userData);
963
typedef void (*MP4CloseCallback)(void *userData);
964
typedef u_int32_t (*MP4ReadCallback)(void *pBuffer, unsigned int nBytesToRead, void *userData);
965
typedef u_int32_t (*MP4WriteCallback)(void *pBuffer, unsigned int nBytesToWrite, void *userData);
966
typedef int32_t (*MP4SetposCallback)(u_int32_t pos, void *userData);
967
typedef int64_t (*MP4GetposCallback)(void *userData);
968
typedef int64_t (*MP4FilesizeCallback)(void *userData);
970
MP4FileHandle MP4CreateCb(u_int32_t verbosity,
972
bool useExtensibleFormat,
973
MP4OpenCallback MP4fopen,
974
MP4CloseCallback MP4fclose,
975
MP4ReadCallback MP4fread,
976
MP4WriteCallback MP4fwrite,
977
MP4SetposCallback MP4fsetpos,
978
MP4GetposCallback MP4fgetpos,
979
MP4FilesizeCallback MP4filesize,
982
MP4FileHandle MP4ReadCb(u_int32_t verbosity,
983
MP4OpenCallback MP4fopen,
984
MP4CloseCallback MP4fclose,
985
MP4ReadCallback MP4fread,
986
MP4WriteCallback MP4fwrite,
987
MP4SetposCallback MP4fsetpos,
988
MP4GetposCallback MP4fgetpos,
989
MP4FilesizeCallback MP4filesize,
991
MP4FileHandle MP4ModifyCb(int32_t verbosity,
992
bool useExtensibleFormat,
993
MP4OpenCallback MP4fopen, MP4CloseCallback MP4fclose,
994
MP4ReadCallback MP4fread, MP4WriteCallback MP4fwrite,
995
MP4SetposCallback MP4fsetpos, MP4GetposCallback MP4fgetpos,
996
MP4FilesizeCallback MP4filesize, void *userData);
1003
/* undefined our utlity macro to avoid conflicts */
1006
#endif /* __MP4_INCLUDED__ */