16
|
1 /*
|
|
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/
|
|
6 *
|
|
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.
|
|
11 *
|
|
12 * The Original Code is MPEG4IP.
|
|
13 *
|
|
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 - 2005. All Rights Reserved.
|
|
17 *
|
|
18 * 3GPP features implementation is based on 3GPP's TS26.234-v5.60,
|
|
19 * and was contributed by Ximpo Group Ltd.
|
|
20 *
|
|
21 * Portions created by Ximpo Group Ltd. are
|
|
22 * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved.
|
|
23 *
|
|
24 * Contributor(s):
|
|
25 * Dave Mackie dmackie@cisco.com
|
|
26 * Alix Marchandise-Franquet alix@cisco.com
|
|
27 * Ximpo Group Ltd. mp4v2@ximpo.com
|
|
28 */
|
|
29
|
|
30 #ifndef __MP4_FILE_INCLUDED__
|
|
31 #define __MP4_FILE_INCLUDED__
|
|
32
|
|
33 // forward declarations
|
|
34 class MP4Atom;
|
|
35 class MP4Property;
|
|
36 class MP4Float32Property;
|
|
37 class MP4StringProperty;
|
|
38 class MP4BytesProperty;
|
|
39 class MP4Descriptor;
|
|
40 class MP4DescriptorProperty;
|
|
41
|
|
42 class MP4File {
|
|
43 public: /* equivalent to MP4 library API */
|
|
44 MP4File(u_int32_t verbosity = 0);
|
|
45 ~MP4File();
|
|
46
|
|
47 /* file operations */
|
|
48 void Read(const char* fileName);
|
|
49 void Create(const char* fileName, u_int32_t flags,
|
|
50 int add_ftyp = 1, int add_iods = 1,
|
|
51 char* majorBrand = NULL,
|
|
52 u_int32_t minorVersion = 0, char** supportedBrands = NULL,
|
|
53 u_int32_t supportedBrandsCount = 0);
|
|
54 void Modify(const char* fileName);
|
|
55 void Optimize(const char* orgFileName,
|
|
56 const char* newFileName = NULL);
|
|
57 void Dump(FILE* pDumpFile = NULL, bool dumpImplicits = false);
|
|
58 void Close();
|
|
59
|
|
60 /* library property per file */
|
|
61
|
|
62 u_int32_t GetVerbosity() {
|
|
63 return m_verbosity;
|
|
64 }
|
|
65 void SetVerbosity(u_int32_t verbosity) {
|
|
66 m_verbosity = verbosity;
|
|
67 }
|
|
68
|
|
69 bool Use64Bits(const char *atomName);
|
|
70
|
|
71 /* file properties */
|
|
72
|
|
73 u_int64_t GetIntegerProperty(const char* name);
|
|
74 float GetFloatProperty(const char* name);
|
|
75 const char* GetStringProperty(const char* name);
|
|
76 void GetBytesProperty(const char* name,
|
|
77 u_int8_t** ppValue, u_int32_t* pValueSize);
|
|
78
|
|
79 void SetIntegerProperty(const char* name, u_int64_t value);
|
|
80 void SetFloatProperty(const char* name, float value);
|
|
81 void SetStringProperty(const char* name, const char* value);
|
|
82 void SetBytesProperty(const char* name,
|
|
83 const u_int8_t* pValue, u_int32_t valueSize);
|
|
84
|
|
85 // file level convenience functions
|
|
86
|
|
87 MP4Duration GetDuration();
|
|
88 void SetDuration(MP4Duration value);
|
|
89
|
|
90 u_int32_t GetTimeScale();
|
|
91 void SetTimeScale(u_int32_t value);
|
|
92
|
|
93 u_int8_t GetODProfileLevel();
|
|
94 void SetODProfileLevel(u_int8_t value);
|
|
95
|
|
96 u_int8_t GetSceneProfileLevel();
|
|
97 void SetSceneProfileLevel(u_int8_t value);
|
|
98
|
|
99 u_int8_t GetVideoProfileLevel();
|
|
100 void SetVideoProfileLevel(u_int8_t value);
|
|
101
|
|
102 u_int8_t GetAudioProfileLevel();
|
|
103 void SetAudioProfileLevel(u_int8_t value);
|
|
104
|
|
105 u_int8_t GetGraphicsProfileLevel();
|
|
106 void SetGraphicsProfileLevel(u_int8_t value);
|
|
107
|
|
108 const char* GetSessionSdp();
|
|
109 void SetSessionSdp(const char* sdpString);
|
|
110 void AppendSessionSdp(const char* sdpString);
|
|
111
|
|
112 /* track operations */
|
|
113
|
|
114 MP4TrackId AddTrack(const char* type, u_int32_t timeScale = 1000);
|
|
115 void DeleteTrack(MP4TrackId trackId);
|
|
116
|
|
117 u_int32_t GetNumberOfTracks(const char* type = NULL, u_int8_t subType = 0);
|
|
118
|
|
119 MP4TrackId AllocTrackId();
|
|
120 MP4TrackId FindTrackId(u_int16_t trackIndex,
|
|
121 const char* type = NULL, u_int8_t subType = 0);
|
|
122 u_int16_t FindTrackIndex(MP4TrackId trackId);
|
|
123 u_int16_t FindTrakAtomIndex(MP4TrackId trackId);
|
|
124
|
|
125 /* track properties */
|
|
126
|
|
127 u_int64_t GetTrackIntegerProperty(
|
|
128 MP4TrackId trackId, const char* name);
|
|
129 float GetTrackFloatProperty(
|
|
130 MP4TrackId trackId, const char* name);
|
|
131 const char* GetTrackStringProperty(
|
|
132 MP4TrackId trackId, const char* name);
|
|
133 void GetTrackBytesProperty(
|
|
134 MP4TrackId trackId, const char* name,
|
|
135 u_int8_t** ppValue, u_int32_t* pValueSize);
|
|
136
|
|
137 void SetTrackIntegerProperty(
|
|
138 MP4TrackId trackId, const char* name, int64_t value);
|
|
139 void SetTrackFloatProperty(
|
|
140 MP4TrackId trackId, const char* name, float value);
|
|
141 void SetTrackStringProperty(
|
|
142 MP4TrackId trackId, const char* name, const char* value);
|
|
143 void SetTrackBytesProperty(
|
|
144 MP4TrackId trackId, const char* name,
|
|
145 const u_int8_t* pValue, u_int32_t valueSize);
|
|
146
|
|
147 /* sample operations */
|
|
148
|
|
149 u_int32_t GetSampleSize(MP4TrackId trackId, MP4SampleId sampleId);
|
|
150
|
|
151 u_int32_t GetTrackMaxSampleSize(MP4TrackId trackId);
|
|
152
|
|
153 MP4SampleId GetSampleIdFromTime(MP4TrackId trackId,
|
|
154 MP4Timestamp when, bool wantSyncSample = false);
|
|
155
|
|
156 MP4Timestamp GetSampleTime(
|
|
157 MP4TrackId trackId, MP4SampleId sampleId);
|
|
158
|
|
159 MP4Duration GetSampleDuration(
|
|
160 MP4TrackId trackId, MP4SampleId sampleId);
|
|
161
|
|
162 MP4Duration GetSampleRenderingOffset(
|
|
163 MP4TrackId trackId, MP4SampleId sampleId);
|
|
164
|
|
165 bool GetSampleSync(
|
|
166 MP4TrackId trackId, MP4SampleId sampleId);
|
|
167
|
|
168 void ReadSample(
|
|
169 // input parameters
|
|
170 MP4TrackId trackId,
|
|
171 MP4SampleId sampleId,
|
|
172 // output parameters
|
|
173 u_int8_t** ppBytes,
|
|
174 u_int32_t* pNumBytes,
|
|
175 MP4Timestamp* pStartTime = NULL,
|
|
176 MP4Duration* pDuration = NULL,
|
|
177 MP4Duration* pRenderingOffset = NULL,
|
|
178 bool* pIsSyncSample = NULL);
|
|
179
|
|
180 void WriteSample(
|
|
181 MP4TrackId trackId,
|
|
182 const u_int8_t* pBytes,
|
|
183 u_int32_t numBytes,
|
|
184 MP4Duration duration = 0,
|
|
185 MP4Duration renderingOffset = 0,
|
|
186 bool isSyncSample = true);
|
|
187
|
|
188 void SetSampleRenderingOffset(
|
|
189 MP4TrackId trackId,
|
|
190 MP4SampleId sampleId,
|
|
191 MP4Duration renderingOffset);
|
|
192
|
|
193 /* track level convenience functions */
|
|
194
|
|
195 MP4TrackId AddSystemsTrack(const char* type);
|
|
196
|
|
197 MP4TrackId AddODTrack();
|
|
198
|
|
199 MP4TrackId AddSceneTrack();
|
|
200
|
|
201 MP4TrackId AddAudioTrack(
|
|
202 u_int32_t timeScale,
|
|
203 MP4Duration sampleDuration,
|
|
204 u_int8_t audioType);
|
|
205
|
|
206 MP4TrackId AddEncAudioTrack( // ismacryp
|
|
207 u_int32_t timeScale,
|
|
208 MP4Duration sampleDuration,
|
|
209 u_int8_t audioType,
|
|
210 u_int32_t scheme_type,
|
|
211 u_int16_t scheme_version,
|
|
212 u_int8_t key_ind_len,
|
|
213 u_int8_t iv_len,
|
|
214 bool selective_enc,
|
|
215 char *kms_uri);
|
|
216
|
|
217 void SetAmrVendor(
|
|
218 MP4TrackId trackId,
|
|
219 u_int32_t vendor);
|
|
220
|
|
221 void SetAmrDecoderVersion(
|
|
222 MP4TrackId trackId,
|
|
223 u_int8_t decoderVersion);
|
|
224
|
|
225 void SetAmrModeSet(
|
|
226 MP4TrackId trackId,
|
|
227 u_int16_t modeSet);
|
|
228 uint16_t GetAmrModeSet(MP4TrackId trackId);
|
|
229
|
|
230 MP4TrackId AddAmrAudioTrack(
|
|
231 u_int32_t timeScale,
|
|
232 u_int16_t modeSet,
|
|
233 u_int8_t modeChangePeriod,
|
|
234 u_int8_t framesPerSample,
|
|
235 bool isAmrWB);
|
|
236
|
|
237 MP4TrackId AddHrefTrack(uint32_t timeScale,
|
|
238 MP4Duration sampleDuration);
|
|
239
|
|
240 MP4TrackId AddMP4VideoTrack(
|
|
241 u_int32_t timeScale,
|
|
242 MP4Duration sampleDuration,
|
|
243 u_int16_t width,
|
|
244 u_int16_t height,
|
|
245 u_int8_t videoType);
|
|
246
|
|
247 MP4TrackId AddEncVideoTrack( // ismacryp
|
|
248 u_int32_t timeScale,
|
|
249 MP4Duration sampleDuration,
|
|
250 u_int16_t width,
|
|
251 u_int16_t height,
|
|
252 u_int8_t videoType,
|
|
253 u_int32_t scheme_type,
|
|
254 u_int16_t scheme_version,
|
|
255 u_int8_t key_ind_len,
|
|
256 u_int8_t iv_len,
|
|
257 bool selective_enc,
|
|
258 char *kms_uri);
|
|
259
|
|
260
|
|
261 void SetH263Vendor(
|
|
262 MP4TrackId trackId,
|
|
263 u_int32_t vendor);
|
|
264
|
|
265 void SetH263DecoderVersion(
|
|
266 MP4TrackId trackId,
|
|
267 u_int8_t decoderVersion);
|
|
268
|
|
269 void SetH263Bitrates(
|
|
270 MP4TrackId,
|
|
271 u_int32_t avgBitrate,
|
|
272 u_int32_t maxBitrate);
|
|
273
|
|
274 MP4TrackId AddH263VideoTrack(
|
|
275 u_int32_t timeScale,
|
|
276 MP4Duration sampleDuration,
|
|
277 u_int16_t width,
|
|
278 u_int16_t height,
|
|
279 u_int8_t h263Level,
|
|
280 u_int8_t h263Profile,
|
|
281 u_int32_t avgBitrate,
|
|
282 u_int32_t maxBitrate);
|
|
283 MP4TrackId AddH264VideoTrack(
|
|
284 u_int32_t timeScale,
|
|
285 MP4Duration sampleDuration,
|
|
286 u_int16_t width,
|
|
287 u_int16_t height,
|
|
288 uint8_t AVCProfileIndication,
|
|
289 uint8_t profile_compat,
|
|
290 uint8_t AVCLevelIndication,
|
|
291 uint8_t sampleLenFieldSizeMinusOne);
|
|
292 bool AddH264SequenceParameterSet(MP4TrackId trackId,
|
|
293 const uint8_t *pSequence,
|
|
294 uint16_t sequenceLen);
|
|
295 bool AddH264PictureParameterSet(MP4TrackId trackId,
|
|
296 const uint8_t *pPicture,
|
|
297 uint16_t pictureLen);
|
|
298 MP4TrackId AddHintTrack(MP4TrackId refTrackId);
|
|
299
|
|
300 MP4SampleId GetTrackNumberOfSamples(MP4TrackId trackId);
|
|
301
|
|
302 const char* GetTrackType(MP4TrackId trackId);
|
|
303
|
|
304 const char *GetTrackMediaDataName(MP4TrackId trackId);
|
|
305 MP4Duration GetTrackDuration(MP4TrackId trackId);
|
|
306
|
|
307 u_int32_t GetTrackTimeScale(MP4TrackId trackId);
|
|
308 void SetTrackTimeScale(MP4TrackId trackId, u_int32_t value);
|
|
309
|
|
310 // replacement to GetTrackAudioType and GetTrackVideoType
|
|
311 u_int8_t GetTrackEsdsObjectTypeId(MP4TrackId trackId);
|
|
312
|
|
313 u_int8_t GetTrackAudioMpeg4Type(MP4TrackId trackId);
|
|
314
|
|
315 MP4Duration GetTrackFixedSampleDuration(MP4TrackId trackId);
|
|
316
|
|
317 double GetTrackVideoFrameRate(MP4TrackId trackId);
|
|
318
|
|
319 int GetTrackAudioChannels(MP4TrackId trackId);
|
|
320 void GetTrackESConfiguration(MP4TrackId trackId,
|
|
321 u_int8_t** ppConfig, u_int32_t* pConfigSize);
|
|
322 void SetTrackESConfiguration(MP4TrackId trackId,
|
|
323 const u_int8_t* pConfig, u_int32_t configSize);
|
|
324
|
|
325 void GetTrackVideoMetadata(MP4TrackId trackId,
|
|
326 u_int8_t** ppConfig, u_int32_t* pConfigSize);
|
|
327 void GetTrackH264ProfileLevel(MP4TrackId trackId,
|
|
328 uint8_t *pProfile,
|
|
329 uint8_t *pLevel);
|
|
330 bool GetTrackH264SeqPictHeaders(MP4TrackId trackId,
|
|
331 uint8_t ***pSeqHeader,
|
|
332 uint32_t **pSeqHeaderSize,
|
|
333 uint8_t ***pPictHeader,
|
|
334 uint32_t **pPictHeaderSize);
|
|
335 void GetTrackH264LengthSize(MP4TrackId,
|
|
336 uint32_t *pLength);
|
|
337 const char* GetHintTrackSdp(MP4TrackId hintTrackId);
|
|
338 void SetHintTrackSdp(MP4TrackId hintTrackId, const char* sdpString);
|
|
339 void AppendHintTrackSdp(MP4TrackId hintTrackId, const char* sdpString);
|
|
340
|
|
341 // 3GPP specific functions
|
|
342 void MakeFtypAtom(char* majorBrand,
|
|
343 u_int32_t minorVersion,
|
|
344 char** supportedBrands,
|
|
345 u_int32_t supportedBrandsCount);
|
|
346 void Make3GPCompliant(const char* fileName,
|
|
347 char* majorBrand,
|
|
348 u_int32_t minorVersion,
|
|
349 char** supportedBrands,
|
|
350 u_int32_t supportedBrandsCount,
|
|
351 bool deleteIodsAtom);
|
|
352
|
|
353 // ISMA specific functions
|
|
354
|
|
355 // true if media track encrypted according to ismacryp
|
|
356 bool IsIsmaCrypMediaTrack(MP4TrackId trackId);
|
|
357
|
|
358 void MakeIsmaCompliant(bool addIsmaComplianceSdp = true);
|
|
359
|
|
360 void CreateIsmaIodFromParams(
|
|
361 u_int8_t videoProfile,
|
|
362 u_int32_t videoBitrate,
|
|
363 u_int8_t* videoConfig,
|
|
364 u_int32_t videoConfigLength,
|
|
365 u_int8_t audioProfile,
|
|
366 u_int32_t audioBitrate,
|
|
367 u_int8_t* audioConfig,
|
|
368 u_int32_t audioConfigLength,
|
|
369 u_int8_t** ppBytes,
|
|
370 u_int64_t* pNumBytes);
|
|
371
|
|
372 // time convenience functions
|
|
373
|
|
374 u_int64_t ConvertFromMovieDuration(
|
|
375 MP4Duration duration,
|
|
376 u_int32_t timeScale);
|
|
377
|
|
378 u_int64_t ConvertFromTrackTimestamp(
|
|
379 MP4TrackId trackId,
|
|
380 MP4Timestamp timeStamp,
|
|
381 u_int32_t timeScale);
|
|
382
|
|
383 MP4Timestamp ConvertToTrackTimestamp(
|
|
384 MP4TrackId trackId,
|
|
385 u_int64_t timeStamp,
|
|
386 u_int32_t timeScale);
|
|
387
|
|
388 u_int64_t ConvertFromTrackDuration(
|
|
389 MP4TrackId trackId,
|
|
390 MP4Duration duration,
|
|
391 u_int32_t timeScale);
|
|
392
|
|
393 MP4Duration ConvertToTrackDuration(
|
|
394 MP4TrackId trackId,
|
|
395 u_int64_t duration,
|
|
396 u_int32_t timeScale);
|
|
397
|
|
398 // specialized operations
|
|
399
|
|
400 void GetHintTrackRtpPayload(
|
|
401 MP4TrackId hintTrackId,
|
|
402 char** ppPayloadName = NULL,
|
|
403 u_int8_t* pPayloadNumber = NULL,
|
|
404 u_int16_t* pMaxPayloadSize = NULL,
|
|
405 char **ppEncodingParams = NULL);
|
|
406
|
|
407 void SetHintTrackRtpPayload(
|
|
408 MP4TrackId hintTrackId,
|
|
409 const char* payloadName,
|
|
410 u_int8_t* pPayloadNumber,
|
|
411 u_int16_t maxPayloadSize,
|
|
412 const char *encoding_params,
|
|
413 bool include_rtp_map,
|
|
414 bool include_mpeg4_esid);
|
|
415
|
|
416 MP4TrackId GetHintTrackReferenceTrackId(
|
|
417 MP4TrackId hintTrackId);
|
|
418
|
|
419 void ReadRtpHint(
|
|
420 MP4TrackId hintTrackId,
|
|
421 MP4SampleId hintSampleId,
|
|
422 u_int16_t* pNumPackets = NULL);
|
|
423
|
|
424 u_int16_t GetRtpHintNumberOfPackets(
|
|
425 MP4TrackId hintTrackId);
|
|
426
|
|
427 int8_t GetRtpPacketBFrame(
|
|
428 MP4TrackId hintTrackId,
|
|
429 u_int16_t packetIndex);
|
|
430
|
|
431 int32_t GetRtpPacketTransmitOffset(
|
|
432 MP4TrackId hintTrackId,
|
|
433 u_int16_t packetIndex);
|
|
434
|
|
435 void ReadRtpPacket(
|
|
436 MP4TrackId hintTrackId,
|
|
437 u_int16_t packetIndex,
|
|
438 u_int8_t** ppBytes,
|
|
439 u_int32_t* pNumBytes,
|
|
440 u_int32_t ssrc = 0,
|
|
441 bool includeHeader = true,
|
|
442 bool includePayload = true);
|
|
443
|
|
444 MP4Timestamp GetRtpTimestampStart(
|
|
445 MP4TrackId hintTrackId);
|
|
446
|
|
447 void SetRtpTimestampStart(
|
|
448 MP4TrackId hintTrackId,
|
|
449 MP4Timestamp rtpStart);
|
|
450
|
|
451 void AddRtpHint(
|
|
452 MP4TrackId hintTrackId,
|
|
453 bool isBframe,
|
|
454 u_int32_t timestampOffset);
|
|
455
|
|
456 void AddRtpPacket(
|
|
457 MP4TrackId hintTrackId,
|
|
458 bool setMbit,
|
|
459 int32_t transmitOffset);
|
|
460
|
|
461 void AddRtpImmediateData(
|
|
462 MP4TrackId hintTrackId,
|
|
463 const u_int8_t* pBytes,
|
|
464 u_int32_t numBytes);
|
|
465
|
|
466 void AddRtpSampleData(
|
|
467 MP4TrackId hintTrackId,
|
|
468 MP4SampleId sampleId,
|
|
469 u_int32_t dataOffset,
|
|
470 u_int32_t dataLength);
|
|
471
|
|
472 void AddRtpESConfigurationPacket(
|
|
473 MP4TrackId hintTrackId);
|
|
474
|
|
475 void WriteRtpHint(
|
|
476 MP4TrackId hintTrackId,
|
|
477 MP4Duration duration,
|
|
478 bool isSyncSample);
|
|
479
|
|
480 u_int8_t AllocRtpPayloadNumber();
|
|
481
|
|
482 // edit list related
|
|
483
|
|
484 char* MakeTrackEditName(
|
|
485 MP4TrackId trackId,
|
|
486 MP4EditId editId,
|
|
487 const char* name);
|
|
488
|
|
489 MP4EditId AddTrackEdit(
|
|
490 MP4TrackId trackId,
|
|
491 MP4EditId editId = MP4_INVALID_EDIT_ID);
|
|
492
|
|
493 void DeleteTrackEdit(
|
|
494 MP4TrackId trackId,
|
|
495 MP4EditId editId);
|
|
496
|
|
497 u_int32_t GetTrackNumberOfEdits(
|
|
498 MP4TrackId trackId);
|
|
499
|
|
500 MP4Timestamp GetTrackEditStart(
|
|
501 MP4TrackId trackId,
|
|
502 MP4EditId editId);
|
|
503
|
|
504 MP4Duration GetTrackEditTotalDuration(
|
|
505 MP4TrackId trackId,
|
|
506 MP4EditId editId);
|
|
507
|
|
508 MP4Timestamp GetTrackEditMediaStart(
|
|
509 MP4TrackId trackId,
|
|
510 MP4EditId editId);
|
|
511
|
|
512 void SetTrackEditMediaStart(
|
|
513 MP4TrackId trackId,
|
|
514 MP4EditId editId,
|
|
515 MP4Timestamp startTime);
|
|
516
|
|
517 MP4Duration GetTrackEditDuration(
|
|
518 MP4TrackId trackId,
|
|
519 MP4EditId editId);
|
|
520
|
|
521 void SetTrackEditDuration(
|
|
522 MP4TrackId trackId,
|
|
523 MP4EditId editId,
|
|
524 MP4Duration duration);
|
|
525
|
|
526 bool GetTrackEditDwell(
|
|
527 MP4TrackId trackId,
|
|
528 MP4EditId editId);
|
|
529
|
|
530 void SetTrackEditDwell(
|
|
531 MP4TrackId trackId,
|
|
532 MP4EditId editId,
|
|
533 bool dwell);
|
|
534
|
|
535 MP4SampleId GetSampleIdFromEditTime(
|
|
536 MP4TrackId trackId,
|
|
537 MP4Timestamp when,
|
|
538 MP4Timestamp* pStartTime = NULL,
|
|
539 MP4Duration* pDuration = NULL);
|
|
540
|
|
541 /* iTunes metadata handling */
|
|
542 protected:
|
|
543 bool CreateMetadataAtom(const char* name);
|
|
544 bool DeleteMetadataAtom(const char* name);
|
|
545 bool GetMetadataString(const char *atom, char **value);
|
|
546 bool SetMetadataString(const char *atom, const char *value);
|
|
547 public:
|
|
548 bool MetadataDelete(void);
|
|
549
|
|
550 /* set metadata */
|
|
551 bool SetMetadataName(const char* value);
|
|
552 bool SetMetadataWriter(const char* value);
|
|
553 bool SetMetadataAlbum(const char* value);
|
|
554 bool SetMetadataArtist(const char* value);
|
|
555 bool SetMetadataTool(const char* value);
|
|
556 bool SetMetadataComment(const char* value);
|
|
557 bool SetMetadataYear(const char* value);
|
|
558 bool SetMetadataTrack(u_int16_t track, u_int16_t totalTracks);
|
|
559 bool SetMetadataDisk(u_int16_t disk, u_int16_t totalDisks);
|
|
560 bool SetMetadataGenre(const char *value);
|
|
561 bool SetMetadataGrouping(const char *value);
|
|
562 bool SetMetadataTempo(u_int16_t tempo);
|
|
563 bool SetMetadataCompilation(u_int8_t compilation);
|
|
564 bool SetMetadataCoverArt(u_int8_t *coverArt, u_int32_t size);
|
|
565 bool SetMetadataFreeForm(char *name,
|
|
566 u_int8_t* pValue,
|
|
567 u_int32_t valueSize);
|
|
568
|
|
569 /* get metadata */
|
|
570 bool GetMetadataByIndex(u_int32_t index,
|
|
571 const char** ppName,
|
|
572 u_int8_t** ppValue,
|
|
573 u_int32_t* pValueSize);
|
|
574 bool GetMetadataName(char** value);
|
|
575 bool GetMetadataWriter(char** value);
|
|
576 bool GetMetadataAlbum(char** value);
|
|
577 bool GetMetadataArtist(char** value);
|
|
578 bool GetMetadataTool(char** value);
|
|
579 bool GetMetadataComment(char** value);
|
|
580 bool GetMetadataYear(char** value);
|
|
581 bool GetMetadataTrack(u_int16_t* track, u_int16_t* totalTracks);
|
|
582 bool GetMetadataDisk(u_int16_t* disk, u_int16_t* totalDisks);
|
|
583 bool GetMetadataGenre(char **value);
|
|
584 bool GetMetadataGrouping(char **value);
|
|
585 bool GetMetadataTempo(u_int16_t* tempo);
|
|
586 bool GetMetadataCompilation(u_int8_t* compilation);
|
|
587 bool GetMetadataCoverArt(u_int8_t **coverArt, u_int32_t* size);
|
|
588 bool GetMetadataFreeForm(char *name,
|
|
589 u_int8_t** pValue,
|
|
590 u_int32_t* valueSize);
|
|
591
|
|
592 /* delete metadata */
|
|
593 bool DeleteMetadataName();
|
|
594 bool DeleteMetadataWriter();
|
|
595 bool DeleteMetadataAlbum();
|
|
596 bool DeleteMetadataArtist();
|
|
597 bool DeleteMetadataTool();
|
|
598 bool DeleteMetadataComment();
|
|
599 bool DeleteMetadataYear();
|
|
600 bool DeleteMetadataTrack();
|
|
601 bool DeleteMetadataDisk();
|
|
602 bool DeleteMetadataGenre();
|
|
603 bool DeleteMetadataGrouping();
|
|
604 bool DeleteMetadataTempo();
|
|
605 bool DeleteMetadataCompilation();
|
|
606 bool DeleteMetadataCoverArt();
|
|
607 bool DeleteMetadataFreeForm(char *name);
|
|
608
|
|
609 /* end of MP4 API */
|
|
610
|
|
611 /* "protected" interface to be used only by friends in library */
|
|
612
|
|
613 u_int64_t GetPosition(FILE* pFile = NULL);
|
|
614 void SetPosition(u_int64_t pos, FILE* pFile = NULL);
|
|
615
|
|
616 u_int64_t GetSize();
|
|
617
|
|
618 u_int32_t ReadBytes(
|
|
619 u_int8_t* pBytes, u_int32_t numBytes, FILE* pFile = NULL);
|
|
620 u_int64_t ReadUInt(u_int8_t size);
|
|
621 u_int8_t ReadUInt8();
|
|
622 u_int16_t ReadUInt16();
|
|
623 u_int32_t ReadUInt24();
|
|
624 u_int32_t ReadUInt32();
|
|
625 u_int64_t ReadUInt64();
|
|
626 float ReadFixed16();
|
|
627 float ReadFixed32();
|
|
628 float ReadFloat();
|
|
629 char* ReadString();
|
|
630 char* ReadCountedString(
|
|
631 u_int8_t charSize = 1, bool allowExpandedCount = false);
|
|
632 u_int64_t ReadBits(u_int8_t numBits);
|
|
633 void FlushReadBits();
|
|
634 u_int32_t ReadMpegLength();
|
|
635
|
|
636 u_int32_t PeekBytes(
|
|
637 u_int8_t* pBytes, u_int32_t numBytes, FILE* pFile = NULL);
|
|
638
|
|
639 void WriteBytes(u_int8_t* pBytes, u_int32_t numBytes, FILE* pFile = NULL);
|
|
640 void WriteUInt(u_int64_t value, u_int8_t size);
|
|
641 void WriteUInt8(u_int8_t value);
|
|
642 void WriteUInt16(u_int16_t value);
|
|
643 void WriteUInt24(u_int32_t value);
|
|
644 void WriteUInt32(u_int32_t value);
|
|
645 void WriteUInt64(u_int64_t value);
|
|
646 void WriteFixed16(float value);
|
|
647 void WriteFixed32(float value);
|
|
648 void WriteFloat(float value);
|
|
649 void WriteString(char* string);
|
|
650 void WriteCountedString(char* string,
|
|
651 u_int8_t charSize = 1, bool allowExpandedCount = false);
|
|
652 void WriteBits(u_int64_t bits, u_int8_t numBits);
|
|
653 void PadWriteBits(u_int8_t pad = 0);
|
|
654 void FlushWriteBits();
|
|
655 void WriteMpegLength(u_int32_t value, bool compact = false);
|
|
656
|
|
657 void EnableMemoryBuffer(
|
|
658 u_int8_t* pBytes = NULL, u_int64_t numBytes = 0);
|
|
659 void DisableMemoryBuffer(
|
|
660 u_int8_t** ppBytes = NULL, u_int64_t* pNumBytes = NULL);
|
|
661
|
|
662 char GetMode() {
|
|
663 return m_mode;
|
|
664 }
|
|
665
|
|
666 MP4Track* GetTrack(MP4TrackId trackId);
|
|
667
|
|
668 MP4Duration UpdateDuration(MP4Duration duration);
|
|
669
|
|
670 MP4Atom* FindAtom(const char* name);
|
|
671
|
|
672 MP4Atom* AddChildAtom(
|
|
673 const char* parentName,
|
|
674 const char* childName);
|
|
675
|
|
676 MP4Atom* AddChildAtom(
|
|
677 MP4Atom* pParentAtom,
|
|
678 const char* childName);
|
|
679
|
|
680 MP4Atom* InsertChildAtom(
|
|
681 const char* parentName,
|
|
682 const char* childName,
|
|
683 u_int32_t index);
|
|
684
|
|
685 MP4Atom* InsertChildAtom(
|
|
686 MP4Atom* pParentAtom,
|
|
687 const char* childName,
|
|
688 u_int32_t index);
|
|
689
|
|
690 MP4Atom* AddDescendantAtoms(
|
|
691 const char* ancestorName,
|
|
692 const char* childName);
|
|
693
|
|
694 MP4Atom* AddDescendantAtoms(
|
|
695 MP4Atom* pAncestorAtom,
|
|
696 const char* childName);
|
|
697
|
|
698 protected:
|
|
699 void Open(const char* fmode);
|
|
700 void ReadFromFile();
|
|
701 void GenerateTracks();
|
|
702 void BeginWrite();
|
|
703 void FinishWrite();
|
|
704 void CacheProperties();
|
|
705 void RewriteMdat(FILE* pReadFile, FILE* pWriteFile);
|
|
706 bool ShallHaveIods();
|
|
707
|
|
708 const char* TempFileName();
|
|
709 void Rename(const char* existingFileName, const char* newFileName);
|
|
710
|
|
711 void ProtectWriteOperation(char* where);
|
|
712
|
|
713 void FindIntegerProperty(const char* name,
|
|
714 MP4Property** ppProperty, u_int32_t* pIndex = NULL);
|
|
715 void FindFloatProperty(const char* name,
|
|
716 MP4Property** ppProperty, u_int32_t* pIndex = NULL);
|
|
717 void FindStringProperty(const char* name,
|
|
718 MP4Property** ppProperty, u_int32_t* pIndex = NULL);
|
|
719 void FindBytesProperty(const char* name,
|
|
720 MP4Property** ppProperty, u_int32_t* pIndex = NULL);
|
|
721
|
|
722 bool FindProperty(const char* name,
|
|
723 MP4Property** ppProperty, u_int32_t* pIndex = NULL);
|
|
724
|
|
725 MP4TrackId AddVideoTrackDefault(
|
|
726 u_int32_t timeScale,
|
|
727 MP4Duration sampleDuration,
|
|
728 u_int16_t width,
|
|
729 u_int16_t height,
|
|
730 const char *videoType);
|
|
731 MP4TrackId AddCntlTrackDefault(
|
|
732 u_int32_t timeScale,
|
|
733 MP4Duration sampleDuration,
|
|
734 const char *videoType);
|
|
735 void AddTrackToIod(MP4TrackId trackId);
|
|
736
|
|
737 void RemoveTrackFromIod(MP4TrackId trackId, bool shallHaveIods = true);
|
|
738
|
|
739 void AddTrackToOd(MP4TrackId trackId);
|
|
740
|
|
741 void RemoveTrackFromOd(MP4TrackId trackId);
|
|
742
|
|
743 void GetTrackReferenceProperties(const char* trefName,
|
|
744 MP4Property** ppCountProperty, MP4Property** ppTrackIdProperty);
|
|
745
|
|
746 void AddTrackReference(const char* trefName, MP4TrackId refTrackId);
|
|
747
|
|
748 u_int32_t FindTrackReference(const char* trefName, MP4TrackId refTrackId);
|
|
749
|
|
750 void RemoveTrackReference(const char* trefName, MP4TrackId refTrackId);
|
|
751
|
|
752 void AddDataReference(MP4TrackId trackId, const char* url);
|
|
753
|
|
754 char* MakeTrackName(MP4TrackId trackId, const char* name);
|
|
755
|
|
756 u_int8_t ConvertTrackTypeToStreamType(const char* trackType);
|
|
757
|
|
758 void CreateIsmaIodFromFile(
|
|
759 MP4TrackId odTrackId,
|
|
760 MP4TrackId sceneTrackId,
|
|
761 MP4TrackId audioTrackId,
|
|
762 MP4TrackId videoTrackId,
|
|
763 u_int8_t** ppBytes,
|
|
764 u_int64_t* pNumBytes);
|
|
765
|
|
766 MP4Descriptor* CreateESD(
|
|
767 MP4DescriptorProperty* pEsProperty,
|
|
768 u_int32_t esid,
|
|
769 u_int8_t objectType,
|
|
770 u_int8_t streamType,
|
|
771 u_int32_t bufferSize,
|
|
772 u_int32_t bitrate,
|
|
773 const u_int8_t* pConfig,
|
|
774 u_int32_t configLength,
|
|
775 char* url);
|
|
776
|
|
777 void CreateIsmaODUpdateCommandFromFileForFile(
|
|
778 MP4TrackId odTrackId,
|
|
779 MP4TrackId audioTrackId,
|
|
780 MP4TrackId videoTrackId,
|
|
781 u_int8_t** ppBytes,
|
|
782 u_int64_t* pNumBytes);
|
|
783
|
|
784 void CreateIsmaODUpdateCommandFromFileForStream(
|
|
785 MP4TrackId audioTrackId,
|
|
786 MP4TrackId videoTrackId,
|
|
787 u_int8_t** ppBytes,
|
|
788 u_int64_t* pNumBytes);
|
|
789
|
|
790 void CreateIsmaODUpdateCommandForStream(
|
|
791 MP4DescriptorProperty* pAudioEsdProperty,
|
|
792 MP4DescriptorProperty* pVideoEsdProperty,
|
|
793 u_int8_t** ppBytes,
|
|
794 u_int64_t* pNumBytes);
|
|
795
|
|
796 void CreateIsmaSceneCommand(
|
|
797 bool hasAudio,
|
|
798 bool hasVideo,
|
|
799 u_int8_t** ppBytes,
|
|
800 u_int64_t* pNumBytes);
|
|
801
|
|
802 protected:
|
|
803 char* m_fileName;
|
|
804 FILE* m_pFile;
|
|
805 u_int64_t m_orgFileSize;
|
|
806 u_int64_t m_fileSize;
|
|
807 MP4Atom* m_pRootAtom;
|
|
808 MP4Integer32Array m_trakIds;
|
|
809 MP4TrackArray m_pTracks;
|
|
810 MP4TrackId m_odTrackId;
|
|
811 u_int32_t m_verbosity;
|
|
812 char m_mode;
|
|
813 u_int32_t m_createFlags;
|
|
814 bool m_useIsma;
|
|
815
|
|
816 // cached properties
|
|
817 MP4IntegerProperty* m_pModificationProperty;
|
|
818 MP4Integer32Property* m_pTimeScaleProperty;
|
|
819 MP4IntegerProperty* m_pDurationProperty;
|
|
820
|
|
821 // read/write in memory
|
|
822 u_int8_t* m_memoryBuffer;
|
|
823 u_int64_t m_memoryBufferPosition;
|
|
824 u_int64_t m_memoryBufferSize;
|
|
825
|
|
826 // bit read/write buffering
|
|
827 u_int8_t m_numReadBits;
|
|
828 u_int8_t m_bufReadBits;
|
|
829 u_int8_t m_numWriteBits;
|
|
830 u_int8_t m_bufWriteBits;
|
|
831
|
|
832 #ifndef _WIN32
|
|
833 char m_tempFileName[64];
|
|
834 #else
|
|
835 char m_tempFileName[MAX_PATH + 3];
|
|
836 #endif
|
|
837 char m_trakName[1024];
|
|
838 char *m_editName;
|
|
839 };
|
|
840
|
|
841 #endif /* __MP4_FILE_INCLUDED__ */
|