Mercurial > audlegacy
annotate Plugins/Input/aac/libmp4v2/mp4file.h @ 199:0a2ad94e8607 trunk
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
author | chainsaw |
---|---|
date | Wed, 16 Nov 2005 16:21:11 -0800 |
parents | fa848bd484d8 |
children | f2dc045d2327 |
rev | line source |
---|---|
61 | 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 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
16 * Copyright (C) Cisco Systems Inc. 2001 - 2004. All Rights Reserved. |
61 | 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 AddMP4VideoTrack( | |
238 u_int32_t timeScale, | |
239 MP4Duration sampleDuration, | |
240 u_int16_t width, | |
241 u_int16_t height, | |
242 u_int8_t videoType); | |
243 | |
244 MP4TrackId AddEncVideoTrack( // ismacryp | |
245 u_int32_t timeScale, | |
246 MP4Duration sampleDuration, | |
247 u_int16_t width, | |
248 u_int16_t height, | |
249 u_int8_t videoType, | |
250 u_int32_t scheme_type, | |
251 u_int16_t scheme_version, | |
252 u_int8_t key_ind_len, | |
253 u_int8_t iv_len, | |
254 bool selective_enc, | |
255 char *kms_uri); | |
256 | |
257 void SetH263Vendor( | |
258 MP4TrackId trackId, | |
259 u_int32_t vendor); | |
260 | |
261 void SetH263DecoderVersion( | |
262 MP4TrackId trackId, | |
263 u_int8_t decoderVersion); | |
264 | |
265 void SetH263Bitrates( | |
266 MP4TrackId, | |
267 u_int32_t avgBitrate, | |
268 u_int32_t maxBitrate); | |
269 | |
270 MP4TrackId AddH263VideoTrack( | |
271 u_int32_t timeScale, | |
272 MP4Duration sampleDuration, | |
273 u_int16_t width, | |
274 u_int16_t height, | |
275 u_int8_t h263Level, | |
276 u_int8_t h263Profile, | |
277 u_int32_t avgBitrate, | |
278 u_int32_t maxBitrate); | |
279 MP4TrackId AddH264VideoTrack( | |
280 u_int32_t timeScale, | |
281 MP4Duration sampleDuration, | |
282 u_int16_t width, | |
283 u_int16_t height, | |
284 uint8_t AVCProfileIndication, | |
285 uint8_t profile_compat, | |
286 uint8_t AVCLevelIndication, | |
287 uint8_t sampleLenFieldSizeMinusOne); | |
288 bool AddH264SequenceParameterSet(MP4TrackId trackId, | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
289 uint8_t *pSequence, |
61 | 290 uint16_t sequenceLen); |
291 bool AddH264PictureParameterSet(MP4TrackId trackId, | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
292 uint8_t *pPicture, |
61 | 293 uint16_t pictureLen); |
294 MP4TrackId AddHintTrack(MP4TrackId refTrackId); | |
295 | |
296 MP4SampleId GetTrackNumberOfSamples(MP4TrackId trackId); | |
297 | |
298 const char* GetTrackType(MP4TrackId trackId); | |
299 | |
300 const char *GetTrackMediaDataName(MP4TrackId trackId); | |
301 MP4Duration GetTrackDuration(MP4TrackId trackId); | |
302 | |
303 u_int32_t GetTrackTimeScale(MP4TrackId trackId); | |
304 void SetTrackTimeScale(MP4TrackId trackId, u_int32_t value); | |
305 | |
306 // replacement to GetTrackAudioType and GetTrackVideoType | |
307 u_int8_t GetTrackEsdsObjectTypeId(MP4TrackId trackId); | |
308 | |
309 u_int8_t GetTrackAudioMpeg4Type(MP4TrackId trackId); | |
310 | |
311 MP4Duration GetTrackFixedSampleDuration(MP4TrackId trackId); | |
312 | |
199
0a2ad94e8607
[svn] Synced with bmp-mp4. Build system is fragile, but should work now.
chainsaw
parents:
61
diff
changeset
|
313 float GetTrackVideoFrameRate(MP4TrackId trackId); |
61 | 314 |
315 int GetTrackAudioChannels(MP4TrackId trackId); | |
316 void GetTrackESConfiguration(MP4TrackId trackId, | |
317 u_int8_t** ppConfig, u_int32_t* pConfigSize); | |
318 void SetTrackESConfiguration(MP4TrackId trackId, | |
319 const u_int8_t* pConfig, u_int32_t configSize); | |
320 | |
321 void GetTrackVideoMetadata(MP4TrackId trackId, | |
322 u_int8_t** ppConfig, u_int32_t* pConfigSize); | |
323 void GetTrackH264ProfileLevel(MP4TrackId trackId, | |
324 uint8_t *pProfile, | |
325 uint8_t *pLevel); | |
326 bool GetTrackH264SeqPictHeaders(MP4TrackId trackId, | |
327 uint8_t ***pSeqHeader, | |
328 uint32_t **pSeqHeaderSize, | |
329 uint8_t ***pPictHeader, | |
330 uint32_t **pPictHeaderSize); | |
331 void GetTrackH264LengthSize(MP4TrackId, | |
332 uint32_t *pLength); | |
333 const char* GetHintTrackSdp(MP4TrackId hintTrackId); | |
334 void SetHintTrackSdp(MP4TrackId hintTrackId, const char* sdpString); | |
335 void AppendHintTrackSdp(MP4TrackId hintTrackId, const char* sdpString); | |
336 | |
337 // 3GPP specific functions | |
338 void MakeFtypAtom(char* majorBrand, | |
339 u_int32_t minorVersion, | |
340 char** supportedBrands, | |
341 u_int32_t supportedBrandsCount); | |
342 void Make3GPCompliant(const char* fileName, | |
343 char* majorBrand, | |
344 u_int32_t minorVersion, | |
345 char** supportedBrands, | |
346 u_int32_t supportedBrandsCount, | |
347 bool deleteIodsAtom); | |
348 | |
349 // ISMA specific functions | |
350 | |
351 // true if media track encrypted according to ismacryp | |
352 bool IsIsmaCrypMediaTrack(MP4TrackId trackId); | |
353 | |
354 void MakeIsmaCompliant(bool addIsmaComplianceSdp = true); | |
355 | |
356 void CreateIsmaIodFromParams( | |
357 u_int8_t videoProfile, | |
358 u_int32_t videoBitrate, | |
359 u_int8_t* videoConfig, | |
360 u_int32_t videoConfigLength, | |
361 u_int8_t audioProfile, | |
362 u_int32_t audioBitrate, | |
363 u_int8_t* audioConfig, | |
364 u_int32_t audioConfigLength, | |
365 u_int8_t** ppBytes, | |
366 u_int64_t* pNumBytes); | |
367 | |
368 // time convenience functions | |
369 | |
370 u_int64_t ConvertFromMovieDuration( | |
371 MP4Duration duration, | |
372 u_int32_t timeScale); | |
373 | |
374 u_int64_t ConvertFromTrackTimestamp( | |
375 MP4TrackId trackId, | |
376 MP4Timestamp timeStamp, | |
377 u_int32_t timeScale); | |
378 | |
379 MP4Timestamp ConvertToTrackTimestamp( | |
380 MP4TrackId trackId, | |
381 u_int64_t timeStamp, | |
382 u_int32_t timeScale); | |
383 | |
384 u_int64_t ConvertFromTrackDuration( | |
385 MP4TrackId trackId, | |
386 MP4Duration duration, | |
387 u_int32_t timeScale); | |
388 | |
389 MP4Duration ConvertToTrackDuration( | |
390 MP4TrackId trackId, | |
391 u_int64_t duration, | |
392 u_int32_t timeScale); | |
393 | |
394 // specialized operations | |
395 | |
396 void GetHintTrackRtpPayload( | |
397 MP4TrackId hintTrackId, | |
398 char** ppPayloadName = NULL, | |
399 u_int8_t* pPayloadNumber = NULL, | |
400 u_int16_t* pMaxPayloadSize = NULL, | |
401 char **ppEncodingParams = NULL); | |
402 | |
403 void SetHintTrackRtpPayload( | |
404 MP4TrackId hintTrackId, | |
405 const char* payloadName, | |
406 u_int8_t* pPayloadNumber, | |
407 u_int16_t maxPayloadSize, | |
408 const char *encoding_params, | |
409 bool include_rtp_map, | |
410 bool include_mpeg4_esid); | |
411 | |
412 MP4TrackId GetHintTrackReferenceTrackId( | |
413 MP4TrackId hintTrackId); | |
414 | |
415 void ReadRtpHint( | |
416 MP4TrackId hintTrackId, | |
417 MP4SampleId hintSampleId, | |
418 u_int16_t* pNumPackets = NULL); | |
419 | |
420 u_int16_t GetRtpHintNumberOfPackets( | |
421 MP4TrackId hintTrackId); | |
422 | |
423 int8_t GetRtpPacketBFrame( | |
424 MP4TrackId hintTrackId, | |
425 u_int16_t packetIndex); | |
426 | |
427 int32_t GetRtpPacketTransmitOffset( | |
428 MP4TrackId hintTrackId, | |
429 u_int16_t packetIndex); | |
430 | |
431 void ReadRtpPacket( | |
432 MP4TrackId hintTrackId, | |
433 u_int16_t packetIndex, | |
434 u_int8_t** ppBytes, | |
435 u_int32_t* pNumBytes, | |
436 u_int32_t ssrc = 0, | |
437 bool includeHeader = true, | |
438 bool includePayload = true); | |
439 | |
440 MP4Timestamp GetRtpTimestampStart( | |
441 MP4TrackId hintTrackId); | |
442 | |
443 void SetRtpTimestampStart( | |
444 MP4TrackId hintTrackId, | |
445 MP4Timestamp rtpStart); | |
446 | |
447 void AddRtpHint( | |
448 MP4TrackId hintTrackId, | |
449 bool isBframe, | |
450 u_int32_t timestampOffset); | |
451 | |
452 void AddRtpPacket( | |
453 MP4TrackId hintTrackId, | |
454 bool setMbit, | |
455 int32_t transmitOffset); | |
456 | |
457 void AddRtpImmediateData( | |
458 MP4TrackId hintTrackId, | |
459 const u_int8_t* pBytes, | |
460 u_int32_t numBytes); | |
461 | |
462 void AddRtpSampleData( | |
463 MP4TrackId hintTrackId, | |
464 MP4SampleId sampleId, | |
465 u_int32_t dataOffset, | |
466 u_int32_t dataLength); | |
467 | |
468 void AddRtpESConfigurationPacket( | |
469 MP4TrackId hintTrackId); | |
470 | |
471 void WriteRtpHint( | |
472 MP4TrackId hintTrackId, | |
473 MP4Duration duration, | |
474 bool isSyncSample); | |
475 | |
476 u_int8_t AllocRtpPayloadNumber(); | |
477 | |
478 // edit list related | |
479 | |
480 char* MakeTrackEditName( | |
481 MP4TrackId trackId, | |
482 MP4EditId editId, | |
483 const char* name); | |
484 | |
485 MP4EditId AddTrackEdit( | |
486 MP4TrackId trackId, | |
487 MP4EditId editId = MP4_INVALID_EDIT_ID); | |
488 | |
489 void DeleteTrackEdit( | |
490 MP4TrackId trackId, | |
491 MP4EditId editId); | |
492 | |
493 u_int32_t GetTrackNumberOfEdits( | |
494 MP4TrackId trackId); | |
495 | |
496 MP4Timestamp GetTrackEditStart( | |
497 MP4TrackId trackId, | |
498 MP4EditId editId); | |
499 | |
500 MP4Duration GetTrackEditTotalDuration( | |
501 MP4TrackId trackId, | |
502 MP4EditId editId); | |
503 | |
504 MP4Timestamp GetTrackEditMediaStart( | |
505 MP4TrackId trackId, | |
506 MP4EditId editId); | |
507 | |
508 void SetTrackEditMediaStart( | |
509 MP4TrackId trackId, | |
510 MP4EditId editId, | |
511 MP4Timestamp startTime); | |
512 | |
513 MP4Duration GetTrackEditDuration( | |
514 MP4TrackId trackId, | |
515 MP4EditId editId); | |
516 | |
517 void SetTrackEditDuration( | |
518 MP4TrackId trackId, | |
519 MP4EditId editId, | |
520 MP4Duration duration); | |
521 | |
522 bool GetTrackEditDwell( | |
523 MP4TrackId trackId, | |
524 MP4EditId editId); | |
525 | |
526 void SetTrackEditDwell( | |
527 MP4TrackId trackId, | |
528 MP4EditId editId, | |
529 bool dwell); | |
530 | |
531 MP4SampleId GetSampleIdFromEditTime( | |
532 MP4TrackId trackId, | |
533 MP4Timestamp when, | |
534 MP4Timestamp* pStartTime = NULL, | |
535 MP4Duration* pDuration = NULL); | |
536 | |
537 /* iTunes metadata handling */ | |
538 bool CreateMetadataAtom(const char* name); | |
539 bool MetadataDelete(void); | |
540 | |
541 /* set metadata */ | |
542 bool SetMetadataName(const char* value); | |
543 bool SetMetadataWriter(const char* value); | |
544 bool SetMetadataAlbum(const char* value); | |
545 bool SetMetadataArtist(const char* value); | |
546 bool SetMetadataTool(const char* value); | |
547 bool SetMetadataComment(const char* value); | |
548 bool SetMetadataYear(const char* value); | |
549 bool SetMetadataTrack(u_int16_t track, u_int16_t totalTracks); | |
550 bool SetMetadataDisk(u_int16_t disk, u_int16_t totalDisks); | |
551 bool SetMetadataGenre(const char *value); | |
552 bool SetMetadataTempo(u_int16_t tempo); | |
553 bool SetMetadataCompilation(u_int8_t compilation); | |
554 bool SetMetadataCoverArt(u_int8_t *coverArt, u_int32_t size); | |
555 bool SetMetadataFreeForm(char *name, | |
556 u_int8_t* pValue, | |
557 u_int32_t valueSize); | |
558 | |
559 /* get metadata */ | |
560 bool GetMetadataByIndex(u_int32_t index, | |
561 const char** ppName, | |
562 u_int8_t** ppValue, | |
563 u_int32_t* pValueSize); | |
564 bool GetMetadataName(char** value); | |
565 bool GetMetadataWriter(char** value); | |
566 bool GetMetadataAlbum(char** value); | |
567 bool GetMetadataArtist(char** value); | |
568 bool GetMetadataTool(char** value); | |
569 bool GetMetadataComment(char** value); | |
570 bool GetMetadataYear(char** value); | |
571 bool GetMetadataTrack(u_int16_t* track, u_int16_t* totalTracks); | |
572 bool GetMetadataDisk(u_int16_t* disk, u_int16_t* totalDisks); | |
573 bool GetMetadataGenre(char **value); | |
574 bool GetMetadataTempo(u_int16_t* tempo); | |
575 bool GetMetadataCompilation(u_int8_t* compilation); | |
576 bool GetMetadataCoverArt(u_int8_t **coverArt, u_int32_t* size); | |
577 bool GetMetadataFreeForm(char *name, | |
578 u_int8_t** pValue, | |
579 u_int32_t* valueSize); | |
580 /* end of MP4 API */ | |
581 | |
582 /* "protected" interface to be used only by friends in library */ | |
583 | |
584 u_int64_t GetPosition(FILE* pFile = NULL); | |
585 void SetPosition(u_int64_t pos, FILE* pFile = NULL); | |
586 | |
587 u_int64_t GetSize(); | |
588 | |
589 u_int32_t ReadBytes( | |
590 u_int8_t* pBytes, u_int32_t numBytes, FILE* pFile = NULL); | |
591 u_int64_t ReadUInt(u_int8_t size); | |
592 u_int8_t ReadUInt8(); | |
593 u_int16_t ReadUInt16(); | |
594 u_int32_t ReadUInt24(); | |
595 u_int32_t ReadUInt32(); | |
596 u_int64_t ReadUInt64(); | |
597 float ReadFixed16(); | |
598 float ReadFixed32(); | |
599 float ReadFloat(); | |
600 char* ReadString(); | |
601 char* ReadCountedString( | |
602 u_int8_t charSize = 1, bool allowExpandedCount = false); | |
603 u_int64_t ReadBits(u_int8_t numBits); | |
604 void FlushReadBits(); | |
605 u_int32_t ReadMpegLength(); | |
606 | |
607 u_int32_t PeekBytes( | |
608 u_int8_t* pBytes, u_int32_t numBytes, FILE* pFile = NULL); | |
609 | |
610 void WriteBytes(u_int8_t* pBytes, u_int32_t numBytes, FILE* pFile = NULL); | |
611 void WriteUInt(u_int64_t value, u_int8_t size); | |
612 void WriteUInt8(u_int8_t value); | |
613 void WriteUInt16(u_int16_t value); | |
614 void WriteUInt24(u_int32_t value); | |
615 void WriteUInt32(u_int32_t value); | |
616 void WriteUInt64(u_int64_t value); | |
617 void WriteFixed16(float value); | |
618 void WriteFixed32(float value); | |
619 void WriteFloat(float value); | |
620 void WriteString(char* string); | |
621 void WriteCountedString(char* string, | |
622 u_int8_t charSize = 1, bool allowExpandedCount = false); | |
623 void WriteBits(u_int64_t bits, u_int8_t numBits); | |
624 void PadWriteBits(u_int8_t pad = 0); | |
625 void FlushWriteBits(); | |
626 void WriteMpegLength(u_int32_t value, bool compact = false); | |
627 | |
628 void EnableMemoryBuffer( | |
629 u_int8_t* pBytes = NULL, u_int64_t numBytes = 0); | |
630 void DisableMemoryBuffer( | |
631 u_int8_t** ppBytes = NULL, u_int64_t* pNumBytes = NULL); | |
632 | |
633 char GetMode() { | |
634 return m_mode; | |
635 } | |
636 | |
637 MP4Track* GetTrack(MP4TrackId trackId); | |
638 | |
639 MP4Duration UpdateDuration(MP4Duration duration); | |
640 | |
641 MP4Atom* FindAtom(const char* name); | |
642 | |
643 MP4Atom* AddChildAtom( | |
644 const char* parentName, | |
645 const char* childName); | |
646 | |
647 MP4Atom* AddChildAtom( | |
648 MP4Atom* pParentAtom, | |
649 const char* childName); | |
650 | |
651 MP4Atom* InsertChildAtom( | |
652 const char* parentName, | |
653 const char* childName, | |
654 u_int32_t index); | |
655 | |
656 MP4Atom* InsertChildAtom( | |
657 MP4Atom* pParentAtom, | |
658 const char* childName, | |
659 u_int32_t index); | |
660 | |
661 MP4Atom* AddDescendantAtoms( | |
662 const char* ancestorName, | |
663 const char* childName); | |
664 | |
665 MP4Atom* AddDescendantAtoms( | |
666 MP4Atom* pAncestorAtom, | |
667 const char* childName); | |
668 | |
669 protected: | |
670 void Open(const char* fmode); | |
671 void ReadFromFile(); | |
672 void GenerateTracks(); | |
673 void BeginWrite(); | |
674 void FinishWrite(); | |
675 void CacheProperties(); | |
676 void RewriteMdat(FILE* pReadFile, FILE* pWriteFile); | |
677 bool ShallHaveIods(); | |
678 | |
679 const char* TempFileName(); | |
680 void Rename(const char* existingFileName, const char* newFileName); | |
681 | |
682 void ProtectWriteOperation(char* where); | |
683 | |
684 void FindIntegerProperty(const char* name, | |
685 MP4Property** ppProperty, u_int32_t* pIndex = NULL); | |
686 void FindFloatProperty(const char* name, | |
687 MP4Property** ppProperty, u_int32_t* pIndex = NULL); | |
688 void FindStringProperty(const char* name, | |
689 MP4Property** ppProperty, u_int32_t* pIndex = NULL); | |
690 void FindBytesProperty(const char* name, | |
691 MP4Property** ppProperty, u_int32_t* pIndex = NULL); | |
692 | |
693 bool FindProperty(const char* name, | |
694 MP4Property** ppProperty, u_int32_t* pIndex = NULL); | |
695 | |
696 MP4TrackId AddVideoTrackDefault( | |
697 u_int32_t timeScale, | |
698 MP4Duration sampleDuration, | |
699 u_int16_t width, | |
700 u_int16_t height, | |
701 const char *videoType); | |
702 void AddTrackToIod(MP4TrackId trackId); | |
703 | |
704 void RemoveTrackFromIod(MP4TrackId trackId, bool shallHaveIods = true); | |
705 | |
706 void AddTrackToOd(MP4TrackId trackId); | |
707 | |
708 void RemoveTrackFromOd(MP4TrackId trackId); | |
709 | |
710 void GetTrackReferenceProperties(const char* trefName, | |
711 MP4Property** ppCountProperty, MP4Property** ppTrackIdProperty); | |
712 | |
713 void AddTrackReference(const char* trefName, MP4TrackId refTrackId); | |
714 | |
715 u_int32_t FindTrackReference(const char* trefName, MP4TrackId refTrackId); | |
716 | |
717 void RemoveTrackReference(const char* trefName, MP4TrackId refTrackId); | |
718 | |
719 void AddDataReference(MP4TrackId trackId, const char* url); | |
720 | |
721 char* MakeTrackName(MP4TrackId trackId, const char* name); | |
722 | |
723 u_int8_t ConvertTrackTypeToStreamType(const char* trackType); | |
724 | |
725 void CreateIsmaIodFromFile( | |
726 MP4TrackId odTrackId, | |
727 MP4TrackId sceneTrackId, | |
728 MP4TrackId audioTrackId, | |
729 MP4TrackId videoTrackId, | |
730 u_int8_t** ppBytes, | |
731 u_int64_t* pNumBytes); | |
732 | |
733 MP4Descriptor* CreateESD( | |
734 MP4DescriptorProperty* pEsProperty, | |
735 u_int32_t esid, | |
736 u_int8_t objectType, | |
737 u_int8_t streamType, | |
738 u_int32_t bufferSize, | |
739 u_int32_t bitrate, | |
740 const u_int8_t* pConfig, | |
741 u_int32_t configLength, | |
742 char* url); | |
743 | |
744 void CreateIsmaODUpdateCommandFromFileForFile( | |
745 MP4TrackId odTrackId, | |
746 MP4TrackId audioTrackId, | |
747 MP4TrackId videoTrackId, | |
748 u_int8_t** ppBytes, | |
749 u_int64_t* pNumBytes); | |
750 | |
751 void CreateIsmaODUpdateCommandFromFileForStream( | |
752 MP4TrackId audioTrackId, | |
753 MP4TrackId videoTrackId, | |
754 u_int8_t** ppBytes, | |
755 u_int64_t* pNumBytes); | |
756 | |
757 void CreateIsmaODUpdateCommandForStream( | |
758 MP4DescriptorProperty* pAudioEsdProperty, | |
759 MP4DescriptorProperty* pVideoEsdProperty, | |
760 u_int8_t** ppBytes, | |
761 u_int64_t* pNumBytes); | |
762 | |
763 void CreateIsmaSceneCommand( | |
764 bool hasAudio, | |
765 bool hasVideo, | |
766 u_int8_t** ppBytes, | |
767 u_int64_t* pNumBytes); | |
768 | |
769 protected: | |
770 char* m_fileName; | |
771 FILE* m_pFile; | |
772 u_int64_t m_orgFileSize; | |
773 u_int64_t m_fileSize; | |
774 MP4Atom* m_pRootAtom; | |
775 MP4Integer32Array m_trakIds; | |
776 MP4TrackArray m_pTracks; | |
777 MP4TrackId m_odTrackId; | |
778 u_int32_t m_verbosity; | |
779 char m_mode; | |
780 u_int32_t m_createFlags; | |
781 bool m_useIsma; | |
782 | |
783 // cached properties | |
784 MP4IntegerProperty* m_pModificationProperty; | |
785 MP4Integer32Property* m_pTimeScaleProperty; | |
786 MP4IntegerProperty* m_pDurationProperty; | |
787 | |
788 // read/write in memory | |
789 u_int8_t* m_memoryBuffer; | |
790 u_int64_t m_memoryBufferPosition; | |
791 u_int64_t m_memoryBufferSize; | |
792 | |
793 // bit read/write buffering | |
794 u_int8_t m_numReadBits; | |
795 u_int8_t m_bufReadBits; | |
796 u_int8_t m_numWriteBits; | |
797 u_int8_t m_bufWriteBits; | |
798 | |
799 #ifndef _WIN32 | |
800 char m_tempFileName[64]; | |
801 #else | |
802 char m_tempFileName[MAX_PATH + 3]; | |
803 #endif | |
804 char m_trakName[1024]; | |
805 char *m_editName; | |
806 }; | |
807 | |
808 #endif /* __MP4_FILE_INCLUDED__ */ |