Debian Codegraph @

bento4-embedded/Source/C++/CApi/Bento4C.h

raw
1 /*****************************************************************
2 |
3 | Bento4 - C API Main Header
4 |
5 | Copyright 2002-2008 Gilles Boccon-Gibod & Julien Boeuf
6 |
7 |
8 | This file is part of Bento4/AP4 (MP4 Atom Processing Library).
9 |
10 | Unless you have obtained Bento4 under a difference license,
11 | this version of Bento4 is Bento4|GPL.
12 | Bento4|GPL is free software; you can redistribute it and/or modify
13 | it under the terms of the GNU General Public License as published by
14 | the Free Software Foundation; either version 2, or (at your option)
15 | any later version.
16 |
17 | Bento4|GPL is distributed in the hope that it will be useful,
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | GNU General Public License for more details.
21 |
22 | You should have received a copy of the GNU General Public License
23 | along with Bento4|GPL; see the file COPYING. If not, write to the
24 | Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 | 02111-1307, USA.
26 |
27 ****************************************************************/
28
29 /*----------------------------------------------------------------------
30 | includes
31 +---------------------------------------------------------------------*/
32 #include "Ap4Types.h"
33
34 /*----------------------------------------------------------------------
35 | types
36 +---------------------------------------------------------------------*/
37 #if defined(__cplusplus)
38 class AP4_ByteStream;
39 class AP4_DataBuffer;
40 class AP4_File;
41 class AP4_Movie;
42 class AP4_Track;
43 class AP4_MetaData;
44 class AP4_Sample;
45 class AP4_SampleDescription;
46 class AP4_AudioSampleDescription;
47 class AP4_VideoSampleDescription;
48 class AP4_AvcSampleDescription;
49 class AP4_MpegSampleDescription;
50 class AP4_MpegAudioSampleDescription;
51 class AP4_ProtectedSampleDescription;
52 class AP4_SyntheticSampleTable;
53 class AP4_AtomInspector;
54 #else
55 typedef struct AP4_ByteStream AP4_ByteStream;
56 typedef struct AP4_DataBuffer AP4_DataBuffer;
57 typedef struct AP4_File AP4_File;
58 typedef struct AP4_Movie AP4_Movie;
59 typedef struct AP4_Track AP4_Track;
60 typedef struct AP4_MetaData AP4_MetaData;
61 typedef struct AP4_Sample AP4_Sample;
62 typedef struct AP4_SampleDescription AP4_SampleDescription;
63 typedef struct AP4_AudioSampleDescription AP4_AudioSampleDescription;
64 typedef struct AP4_VideoSampleDescription AP4_VideoSampleDescription;
65 typedef struct AP4_AvcSampleDescription AP4_AvcSampleDescription;
66 typedef struct AP4_MpegSampleDescription AP4_MpegSampleDescription;
67 typedef struct AP4_MpegAudioSampleDescription AP4_MpegAudioSampleDescription;
68 typedef struct AP4_ProtectedSampleDescription AP4_ProtectedSampleDescription;
69 typedef struct AP4_SyntheticSampleTable AP4_SyntheticSampleTable;
70 typedef struct AP4_AtomInspector AP4_AtomInspector;
71 #endif
72
73 typedef enum {
74 AP4_FALSE = 0,
75 AP4_TRUE = 1
76 } AP4_Boolean;
77
78 /*----------------------------------------------------------------------
79 | Delegate types: allow to provide an implementation
80 +---------------------------------------------------------------------*/
81 typedef struct AP4_ByteStreamDelegate {
82 AP4_Result (*ReadPartial)(struct AP4_ByteStreamDelegate* self,
83 void* buffer,
84 AP4_Size bytes_to_read,
85 AP4_Size* bytes_read);
86
87 AP4_Result (*WritePartial)(struct AP4_ByteStreamDelegate* self,
88 const void* buffer,
89 AP4_Size bytes_to_write,
90 AP4_Size* bytes_written);
91
92 AP4_Result (*Seek)(struct AP4_ByteStreamDelegate* self,
93 AP4_Position position);
94
95 AP4_Result (*Tell)(struct AP4_ByteStreamDelegate* self,
96 AP4_Position* position);
97
98 AP4_Result (*GetSize)(struct AP4_ByteStreamDelegate* self,
99 AP4_LargeSize* size);
100
101 AP4_Result (*Flush)(struct AP4_ByteStreamDelegate* self);
102
103 /**
104 * the reference counting is done for you.
105 * The Destroy method will be called when the refcount hits 0.
106 * Can be set to NULL if no cleanup of the delegate is necessary
107 */
108 void (*Destroy)(struct AP4_ByteStreamDelegate* self);
109 } AP4_ByteStreamDelegate;
110
111 typedef struct AP4_AtomInspectorDelegate {
112 void (*StartElement)(struct AP4_AtomInspectorDelegate* self,
113 const char* name,
114 const char* extra);
115
116 void (*EndElement)(struct AP4_AtomInspectorDelegate* self);
117
118 void (*AddIntField)(struct AP4_AtomInspectorDelegate* self,
119 const char* name,
120 AP4_UI64 value,
121 int hint);
122
123 void (*AddFloatField)(struct AP4_AtomInspectorDelegate* self,
124 const char* name,
125 float value,
126 int hint);
127
128 void (*AddStringField)(struct AP4_AtomInspectorDelegate* self,
129 const char* name,
130 const char* value,
131 int hint);
132
133 void (*AddBytesField)(struct AP4_AtomInspectorDelegate* self,
134 const char* name,
135 const unsigned char* bytes,
136 AP4_Size byte_count,
137 int hint);
138
139 /**
140 * The Destroy method will be called when the AtomInspector is destroyed.
141 * Can be set to NULL if no cleanup of the delegate is necessary
142 */
143 void (*Destroy)(struct AP4_AtomInspectorDelegate* self);
144 } AP4_AtomInspectorDelegate;
145
146
147 /*----------------------------------------------------------------------
148 | constants
149 +---------------------------------------------------------------------*/
150 extern const int AP4_FILE_BYTE_STREAM_MODE_READ;
151 extern const int AP4_FILE_BYTE_STREAM_MODE_WRITE;
152 extern const int AP4_FILE_BYTE_STREAM_MODE_READ_WRITE;
153
154 extern const AP4_UI32 AP4_FILE_BRAND_QT__;
155 extern const AP4_UI32 AP4_FILE_BRAND_ISOM;
156 extern const AP4_UI32 AP4_FILE_BRAND_MP41;
157 extern const AP4_UI32 AP4_FILE_BRAND_MP42;
158 extern const AP4_UI32 AP4_FILE_BRAND_3GP1;
159 extern const AP4_UI32 AP4_FILE_BRAND_3GP2;
160 extern const AP4_UI32 AP4_FILE_BRAND_3GP3;
161 extern const AP4_UI32 AP4_FILE_BRAND_3GP4;
162 extern const AP4_UI32 AP4_FILE_BRAND_3GP5;
163 extern const AP4_UI32 AP4_FILE_BRAND_3G2A;
164 extern const AP4_UI32 AP4_FILE_BRAND_MMP4;
165 extern const AP4_UI32 AP4_FILE_BRAND_M4A_;
166 extern const AP4_UI32 AP4_FILE_BRAND_M4P_;
167 extern const AP4_UI32 AP4_FILE_BRAND_MJP2;
168
169
170 extern const int AP4_TRACK_TYPE_UNKNOWN;
171 extern const int AP4_TRACK_TYPE_AUDIO;
172 extern const int AP4_TRACK_TYPE_VIDEO;
173 extern const int AP4_TRACK_TYPE_SYSTEM;
174 extern const int AP4_TRACK_TYPE_HINT;
175 extern const int AP4_TRACK_TYPE_TEXT;
176 extern const int AP4_TRACK_TYPE_JPEG;
177 extern const int AP4_TRACK_TYPE_RTP;
178 extern const int AP4_TRACK_TYPE_SUBTITLES;
179
180 extern const AP4_UI32 AP4_HANDLER_TYPE_SOUN;
181 extern const AP4_UI32 AP4_HANDLER_TYPE_VIDE;
182 extern const AP4_UI32 AP4_HANDLER_TYPE_HINT;
183 extern const AP4_UI32 AP4_HANDLER_TYPE_MDIR;
184 extern const AP4_UI32 AP4_HANDLER_TYPE_TEXT;
185 extern const AP4_UI32 AP4_HANDLER_TYPE_TX3G;
186 extern const AP4_UI32 AP4_HANDLER_TYPE_JPEG;
187 extern const AP4_UI32 AP4_HANDLER_TYPE_ODSM;
188 extern const AP4_UI32 AP4_HANDLER_TYPE_SDSM;
189
190 extern const AP4_UI32 AP4_TRACK_DEFAULT_MOVIE_TIMESCALE;
191
192 extern const int AP4_SAMPLE_DESCRIPTION_TYPE_UNKNOWN;
193 extern const int AP4_SAMPLE_DESCRIPTION_TYPE_MPEG;
194 extern const int AP4_SAMPLE_DESCRIPTION_TYPE_PROTECTED;
195 extern const int AP4_SAMPLE_DESCRIPTION_TYPE_AVC;
196 extern const int AP4_SAMPLE_DESCRIPTION_TYPE_HEVC;
197
198 extern const AP4_UI08 AP4_STREAM_TYPE_FORBIDDEN;
199 extern const AP4_UI08 AP4_STREAM_TYPE_OD;
200 extern const AP4_UI08 AP4_STREAM_TYPE_CR;
201 extern const AP4_UI08 AP4_STREAM_TYPE_BIFS;
202 extern const AP4_UI08 AP4_STREAM_TYPE_VISUAL;
203 extern const AP4_UI08 AP4_STREAM_TYPE_AUDIO;
204 extern const AP4_UI08 AP4_STREAM_TYPE_MPEG7;
205 extern const AP4_UI08 AP4_STREAM_TYPE_IPMP;
206 extern const AP4_UI08 AP4_STREAM_TYPE_OCI;
207 extern const AP4_UI08 AP4_STREAM_TYPE_MPEGJ;
208 extern const AP4_UI08 AP4_STREAM_TYPE_TEXT;
209
210 extern const AP4_UI08 AP4_OTI_MPEG4_SYSTEM;
211 extern const AP4_UI08 AP4_OTI_MPEG4_SYSTEM_COR;
212 extern const AP4_UI08 AP4_OTI_MPEG4_TEXT;
213 extern const AP4_UI08 AP4_OTI_MPEG4_VISUAL;
214 extern const AP4_UI08 AP4_OTI_MPEG4_AUDIO;
215 extern const AP4_UI08 AP4_OTI_MPEG2_VISUAL_SIMPLE;
216 extern const AP4_UI08 AP4_OTI_MPEG2_VISUAL_MAIN;
217 extern const AP4_UI08 AP4_OTI_MPEG2_VISUAL_SNR;
218 extern const AP4_UI08 AP4_OTI_MPEG2_VISUAL_SPATIAL;
219 extern const AP4_UI08 AP4_OTI_MPEG2_VISUAL_HIGH;
220 extern const AP4_UI08 AP4_OTI_MPEG2_VISUAL_422;
221 extern const AP4_UI08 AP4_OTI_MPEG2_AAC_AUDIO_MAIN;
222 extern const AP4_UI08 AP4_OTI_MPEG2_AAC_AUDIO_LC;
223 extern const AP4_UI08 AP4_OTI_MPEG2_AAC_AUDIO_SSRP;
224 extern const AP4_UI08 AP4_OTI_MPEG2_PART3_AUDIO;
225 extern const AP4_UI08 AP4_OTI_MPEG1_VISUAL;
226 extern const AP4_UI08 AP4_OTI_MPEG1_AUDIO;
227 extern const AP4_UI08 AP4_OTI_JPEG;
228
229 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_MAIN; /**< AAC Main Profile */
230 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LC; /**< AAC Low Complexity */
231 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SSR; /**< AAC Scalable Sample Rate */
232 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_LTP; /**< AAC Long Term Predictor */
233 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_SBR; /**< Spectral Band Replication */
234 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_AAC_SCALABLE; /**< AAC Scalable */
235 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_TWINVQ; /**< Twin VQ */
236 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LC; /**< Error Resilient AAC Low Complexity */
237 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LTP; /**< Error Resilient AAC Long Term Prediction */
238 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_SCALABLE; /**< Error Resilient AAC Scalable */
239 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_TWINVQ; /**< Error Resilient Twin VQ */
240 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_BSAC; /**< Error Resilient Bit Sliced Arithmetic Coding */
241 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_ER_AAC_LD; /**< Error Resilient AAC Low Delay */
242 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_1; /**< MPEG Layer 1 */
243 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_2; /**< MPEG Layer 2 */
244 extern const AP4_UI08 AP4_MPEG4_AUDIO_OBJECT_TYPE_LAYER_3; /**< MPEG Layer 3 */
245
246 extern const AP4_Cardinal AP4_SYNTHETIC_SAMPLE_TABLE_DEFAULT_CHUNK_SIZE;
247
248 extern const int AP4_ATOM_INSPECTOR_HINT_NONE;
249 extern const int AP4_ATOM_INSPECTOR_HINT_HEX;
250 extern const int AP4_ATOM_INSPECTOR_HIN_BOOLEAN;
251
252 /*----------------------------------------------------------------------
253 | result codes
254 +---------------------------------------------------------------------*/
255 extern const int AP4_SUCCESS;
256 extern const int AP4_FAILURE;
257 extern const int AP4_ERROR_OUT_OF_MEMORY;
258 extern const int AP4_ERROR_INVALID_PARAMETERS;
259 extern const int AP4_ERROR_NO_SUCH_FILE;
260 extern const int AP4_ERROR_PERMISSION_DENIED;
261 extern const int AP4_ERROR_CANNOT_OPEN_FILE;
262 extern const int AP4_ERROR_EOS;
263 extern const int AP4_ERROR_WRITE_FAILED;
264 extern const int AP4_ERROR_READ_FAILED;
265 extern const int AP4_ERROR_INVALID_FORMAT;
266 extern const int AP4_ERROR_NO_SUCH_ITEM;
267 extern const int AP4_ERROR_OUT_OF_RANGE;
268 extern const int AP4_ERROR_INTERNAL;
269 extern const int AP4_ERROR_INVALID_STATE;
270 extern const int AP4_ERROR_LIST_EMPTY;
271 extern const int AP4_ERROR_LIST_OPERATION_ABORTED;
272 extern const int AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE;
273 extern const int AP4_ERROR_NOT_SUPPORTED;
274 extern const int AP4_ERROR_INVALID_TRACK_TYPE;
275 extern const int AP4_ERROR_INVALID_RTP_PACKET_EXTRA_DATA;
276 extern const int AP4_ERROR_BUFFER_TOO_SMALL;
277 extern const int AP4_ERROR_NOT_ENOUGH_DATA;
278
279 #ifdef __cplusplus
280 extern "C" {
281 #endif /* __cplusplus */
282
283 /*----------------------------------------------------------------------
284 | AP4_ByteStream methods
285 +---------------------------------------------------------------------*/
286 void
287 AP4_ByteStream_AddReference(AP4_ByteStream* self);
288
289 void
290 AP4_ByteStream_Release(AP4_ByteStream* self);
291
292 AP4_Result
293 AP4_ByteStream_ReadPartial(AP4_ByteStream* self,
294 void* buffer,
295 AP4_Size bytes_to_read,
296 AP4_Size* bytes_read);
297
298 AP4_Result
299 AP4_ByteStream_Read(AP4_ByteStream* self,
300 void* buffer,
301 AP4_Size bytes_to_read);
302
303 AP4_Result
304 AP4_ByteStream_ReadDouble(AP4_ByteStream* self, double* value);
305
306 AP4_Result
307 AP4_ByteStream_ReadUI64(AP4_ByteStream* self, AP4_UI64* value);
308
309 AP4_Result
310 AP4_ByteStream_ReadUI32(AP4_ByteStream* self, AP4_UI32* value);
311
312 AP4_Result
313 AP4_ByteStream_ReadUI24(AP4_ByteStream* self, AP4_UI32* value);
314
315 AP4_Result
316 AP4_ByteStream_ReadUI16(AP4_ByteStream* self, AP4_UI16* value);
317
318 AP4_Result
319 AP4_ByteStream_ReadUI08(AP4_ByteStream* self, AP4_UI08* value);
320
321 AP4_Result
322 AP4_ByteStream_ReadString(AP4_ByteStream* self,
323 char* buffer,
324 AP4_Size size);
325
326 AP4_Result
327 AP4_ByteStream_WritePartial(AP4_ByteStream* self,
328 const void* buffer,
329 AP4_Size bytes_to_write,
330 AP4_Size* bytes_written);
331
332 AP4_Result
333 AP4_ByteStream_Write(AP4_ByteStream* self,
334 const void* buffer,
335 AP4_Size bytes_to_write);
336 AP4_Result
337 AP4_ByteStream_WriteDouble(AP4_ByteStream* self, double value);
338
339 AP4_Result
340 AP4_ByteStream_WriteUI64(AP4_ByteStream* self, AP4_UI64 value);
341
342 AP4_Result
343 AP4_ByteStream_WriteUI32(AP4_ByteStream* self, AP4_UI32 value);
344
345 AP4_Result
346 AP4_ByteStream_WriteUI24(AP4_ByteStream* self, AP4_UI32 value);
347
348 AP4_Result
349 AP4_ByteStream_WriteUI16(AP4_ByteStream* self, AP4_UI16 value);
350
351 AP4_Result
352 AP4_ByteStream_WriteUI08(AP4_ByteStream* self, AP4_UI08 value);
353
354 AP4_Result
355 AP4_ByteStream_WriteString(AP4_ByteStream* self, const char* buffer);
356
357 AP4_Result
358 AP4_ByteStream_Seek(AP4_ByteStream* self, AP4_Position position);
359
360 AP4_Result
361 AP4_ByteStream_Tell(AP4_ByteStream* self, AP4_Position* position);
362
363 AP4_Result
364 AP4_ByteStream_GetSize(AP4_ByteStream* self, AP4_LargeSize* size);
365
366 AP4_Result
367 AP4_ByteStream_CopyTo(AP4_ByteStream* self,
368 AP4_ByteStream* receiver,
369 AP4_LargeSize size);
370
371 AP4_Result Ap4_ByteStream_Flush(AP4_ByteStream* self);
372
373 /*----------------------------------------------------------------------
374 | AP4_ByteStream construtors
375 +---------------------------------------------------------------------*/
376 AP4_ByteStream*
377 AP4_SubStream_Create(AP4_ByteStream* container,
378 AP4_Position position,
379 AP4_LargeSize size);
380 AP4_ByteStream*
381 AP4_MemoryByteStream_Create(AP4_Size size);
382
383 AP4_ByteStream*
384 AP4_MemoryByteStream_FromBuffer(const AP4_UI08* buffer, AP4_Size size);
385
386 AP4_ByteStream*
387 AP4_MemoryByteStream_AdaptDataBuffer(AP4_DataBuffer* buffer); /* data is read/written from the supplied data buffer */
388
389 AP4_ByteStream*
390 AP4_FileByteStream_Create(const char* name, int mode, AP4_Result* result);
391
392 AP4_ByteStream*
393 AP4_ByteStream_FromDelegate(AP4_ByteStreamDelegate* delegate);
394
395 /*----------------------------------------------------------------------
396 | AP4_DataBuffer methods
397 +---------------------------------------------------------------------*/
398 AP4_Result
399 AP4_DataBuffer_SetBuffer(AP4_DataBuffer* self, AP4_Byte* buffer, AP4_Size size);
400
401 AP4_Result
402 AP4_DataBuffer_SetBufferSize(AP4_DataBuffer* self, AP4_Size size);
403
404 AP4_Size
405 AP4_DataBuffer_GetBufferSize(const AP4_DataBuffer* self);
406
407 const AP4_Byte*
408 AP4_DataBuffer_GetData(const AP4_DataBuffer* self);
409
410 AP4_Byte*
411 AP4_DataBuffer_UseData(AP4_DataBuffer* self);
412
413 AP4_Size
414 AP4_DataBuffer_GetDataSize(const AP4_DataBuffer* self);
415
416 AP4_Result
417 AP4_DataBuffer_SetDataSize(AP4_DataBuffer* self, AP4_Size size);
418
419 AP4_Result
420 AP4_DataBuffer_SetData(AP4_DataBuffer* self,
421 const AP4_Byte* data,
422 AP4_Size data_size);
423
424 AP4_Result
425 AP4_DataBuffer_Reserve(AP4_DataBuffer* self, AP4_Size size);
426
427 void
428 AP4_DataBuffer_Destroy(AP4_DataBuffer* self);
429
430 /*----------------------------------------------------------------------
431 | AP4_DataBuffer constructors
432 +---------------------------------------------------------------------*/
433 AP4_DataBuffer*
434 AP4_DataBuffer_Create(AP4_Size size);
435
436 AP4_DataBuffer*
437 AP4_DataBuffer_FromData(const void* data, AP4_Size data_size);
438
439 AP4_DataBuffer*
440 AP4_DataBuffer_Clone(const AP4_DataBuffer* other);
441
442 /*----------------------------------------------------------------------
443 | AP4_File methods
444 +---------------------------------------------------------------------*/
445 AP4_Movie*
446 AP4_File_GetMovie(AP4_File* self);
447
448 AP4_Result
449 AP4_File_GetFileType(AP4_File* self,
450 AP4_UI32* major_brand,
451 AP4_UI32* minor_version,
452 AP4_Cardinal* compatible_brand_count);
453
454 AP4_Result
455 AP4_File_GetCompatibleBrand(AP4_File* self,
456 AP4_Ordinal index,
457 AP4_UI32* brand);
458
459 AP4_Result
460 AP4_File_SetFileType(AP4_File* self,
461 AP4_UI32 major_brand,
462 AP4_UI32 minor_version,
463 AP4_UI32* compatible_brands,
464 AP4_Cardinal compatible_brand_count);
465
466 int
467 AP4_File_IsMoovBeforeMdat(const AP4_File* self);
468
469 AP4_Result
470 AP4_File_Inspect(AP4_File* self, AP4_AtomInspector* inspector);
471
472 const AP4_MetaData*
473 AP4_File_GetMetaData(AP4_File* self);
474
475 void
476 AP4_File_Destroy(AP4_File* self);
477
478 /*----------------------------------------------------------------------
479 | AP4_File constructors
480 +---------------------------------------------------------------------*/
481 AP4_File*
482 AP4_File_Create(AP4_Movie* movie);
483
484 AP4_File*
485 AP4_File_FromStream(AP4_ByteStream* stream, int moov_only);
486
487 /*----------------------------------------------------------------------
488 | AP4_Movie methods
489 +---------------------------------------------------------------------*/
490 AP4_Cardinal
491 AP4_Movie_GetTrackCount(AP4_Movie* self);
492
493 AP4_Track*
494 AP4_Movie_GetTrackByIndex(AP4_Movie* self, AP4_Ordinal index);
495
496 AP4_Track*
497 AP4_Movie_GetTrackById(AP4_Movie* self, AP4_UI32 track_id);
498
499 AP4_Track*
500 AP4_Movie_GetTrackByType(AP4_Movie* self, int type, AP4_Ordinal index);
501
502 AP4_UI32
503 AP4_Movie_GetTimeScale(AP4_Movie* self);
504
505 AP4_UI64
506 AP4_Movie_GetDuration(AP4_Movie* self);
507
508 AP4_UI32
509 AP4_Movie_GetDurationMs(AP4_Movie* self);
510
511 AP4_Result
512 AP4_Movie_AddTrack(AP4_Movie* self, AP4_Track* track);
513
514 void
515 AP4_Movie_Destroy(AP4_Movie* self);
516
517 /*----------------------------------------------------------------------
518 | AP4_Movie constructors
519 +---------------------------------------------------------------------*/
520 AP4_Movie*
521 AP4_Movie_Create(AP4_UI32 time_scale);
522
523 /*----------------------------------------------------------------------
524 | AP4_Track methods
525 +---------------------------------------------------------------------*/
526 int
527 AP4_Track_GetType(AP4_Track* self);
528
529 AP4_UI32
530 AP4_Track_GetHandlerType(AP4_Track* self);
531
532 AP4_UI64
533 AP4_Track_GetDuration(AP4_Track* self); /* timescale of the movie */
534
535 AP4_UI32
536 AP4_Track_GetDurationMs(AP4_Track* self);
537
538 AP4_Cardinal
539 AP4_Track_GetSampleCount(AP4_Track* self);
540
541 AP4_Result
542 AP4_Track_GetSample(AP4_Track* self, AP4_Ordinal index, AP4_Sample* sample);
543
544 AP4_Result
545 AP4_Track_ReadSample(AP4_Track* self,
546 AP4_Ordinal index,
547 AP4_Sample* sample,
548 AP4_DataBuffer* data);
549
550 AP4_Result
551 AP4_Track_GetSampleIndexForTimeStampMs(AP4_Track* self,
552 AP4_UI32 ts,
553 AP4_Ordinal* index);
554
555 AP4_Ordinal
556 AP4_Track_GetNearestSyncSampleIndex(AP4_Track* self,
557 AP4_Ordinal index,
558 AP4_Boolean before);
559
560 AP4_SampleDescription*
561 AP4_Track_GetSampleDescription(AP4_Track* self, AP4_Ordinal index);
562
563 AP4_UI32
564 AP4_Track_GetId(AP4_Track* self);
565
566 AP4_Result
567 AP4_Track_SetId(AP4_Track* self, AP4_UI32 track_id);
568
569 AP4_Result
570 AP4_Track_SetMovieTimeScale(AP4_Track* self, AP4_UI32 time_scale);
571
572 AP4_UI32
573 AP4_Track_GetMediaTimeScale(AP4_Track* self);
574
575 AP4_UI64
576 AP4_Track_GetMediaDuration(AP4_Track* self); /* in the timescale of the media */
577
578 const char*
579 AP4_Track_GetName(AP4_Track* self);
580
581 const char*
582 AP4_Track_GetLanguage(AP4_Track* self);
583
584 void
585 AP4_Track_Destroy(AP4_Track* self);
586
587 /*----------------------------------------------------------------------
588 | AP4_Track constructors
589 +---------------------------------------------------------------------*/
590 AP4_Track*
591 AP4_Track_Create(int type,
592 AP4_SyntheticSampleTable* sample_table,
593 AP4_UI32 track_id,
594 AP4_UI32 movie_time_scale, /* 0 = use default */
595 AP4_UI32 track_duration, /* in the movie time scale */
596 AP4_UI32 media_time_scale,
597 AP4_UI32 media_duration, /* in the media time scale */
598 const char* language,
599 AP4_UI32 width,
600 AP4_UI32 height);
601
602 /*----------------------------------------------------------------------
603 | AP4_SampleDescription methods
604 +---------------------------------------------------------------------*/
605 int
606 AP4_SampleDescription_GetType(AP4_SampleDescription* self);
607
608 AP4_UI32
609 AP4_SampleDescription_GetFormat(AP4_SampleDescription* self);
610
611 AP4_AudioSampleDescription*
612 AP4_SampleDescription_AsAudio(AP4_SampleDescription* self);
613
614 AP4_VideoSampleDescription*
615 AP4_SampleDescription_AsVideo(AP4_SampleDescription* self);
616
617 AP4_AvcSampleDescription*
618 AP4_SampleDescription_AsAvc(AP4_SampleDescription* self);
619
620 AP4_MpegSampleDescription*
621 AP4_SampleDescription_AsMpeg(AP4_SampleDescription* self);
622
623 AP4_MpegAudioSampleDescription*
624 AP4_SampleDescription_AsMpegAudio(AP4_SampleDescription* self);
625
626 AP4_ProtectedSampleDescription*
627 AP4_SampleDescription_AsProtected(AP4_SampleDescription* self);
628
629 AP4_UI32
630 AP4_AudioSampleDescription_GetSampleRate(AP4_AudioSampleDescription* self);
631
632 AP4_UI16
633 AP4_AudioSampleDescription_GetSampleSize(AP4_AudioSampleDescription* self);
634
635 AP4_UI16
636 AP4_AudioSampleDescription_GetChannelCount(AP4_AudioSampleDescription* self);
637
638 AP4_UI32
639 AP4_VideoSampleDescription_GetWidth(AP4_VideoSampleDescription* self);
640
641 AP4_UI16
642 AP4_VideoSampleDescription_GetHeight(AP4_VideoSampleDescription* self);
643
644 AP4_UI16
645 AP4_VideoSampleDescription_GetDepth(AP4_VideoSampleDescription* self);
646
647 const char*
648 AP4_VideoSampleDescription_GetCompressorName(AP4_VideoSampleDescription* self);
649
650 AP4_UI08
651 AP4_AvcSampleDescription_GetConfigurationVersion(AP4_AvcSampleDescription* self);
652
653 AP4_UI08
654 AP4_AvcSampleDescription_GetProfile(AP4_AvcSampleDescription* self);
655
656 AP4_UI08
657 AP4_AvcSampleDescription_GetLevel(AP4_AvcSampleDescription* self);
658
659 AP4_UI08
660 AP4_AvcSampleDescription_GetProfileCompatibility(AP4_AvcSampleDescription* self);
661
662 AP4_UI08
663 AP4_AvcSampleDescription_GetNaluLengthSize(AP4_AvcSampleDescription* self);
664
665 AP4_Cardinal
666 AP4_AvcSampleDescription_GetSequenceParameterCount(AP4_AvcSampleDescription* self);
667
668 const AP4_DataBuffer*
669 AP4_AvcSampleDescription_GetSequenceParameter(AP4_AvcSampleDescription* self,
670 AP4_Ordinal index);
671
672 AP4_Cardinal
673 AP4_AvcSampleDescription_GetPictureParameterCount(AP4_AvcSampleDescription* self);
674
675 const AP4_DataBuffer*
676 AP4_AvcSampleDescription_GetPictureParameter(AP4_AvcSampleDescription* self,
677 AP4_Ordinal index);
678
679 const AP4_DataBuffer*
680 AP4_AvcSampleDescription_GetRawBytes(AP4_AvcSampleDescription* self);
681
682 const char*
683 AP4_AvcSampleDescription_GetProfileName(AP4_UI08 profile); /* class method */
684
685 AP4_UI08
686 AP4_MpegSampleDescription_GetStreamType(AP4_MpegSampleDescription* self);
687
688 AP4_UI08
689 AP4_MpegSampleDescription_GetObjectTypeId(AP4_MpegSampleDescription* self);
690
691 AP4_UI32
692 AP4_MpegSampleDescription_GetBufferSize(AP4_MpegSampleDescription* self);
693
694 AP4_UI32
695 AP4_MpegSampleDescription_GetMaxBitrate(AP4_MpegSampleDescription* self);
696
697 AP4_UI32
698 AP4_MpegSampleDescription_GetAvgBitrate(AP4_MpegSampleDescription* self);
699
700 const AP4_DataBuffer*
701 AP4_MpegSampleDescription_GetDecoderInfo(AP4_MpegSampleDescription* self);
702
703 AP4_UI08
704 AP4_MpegAudioSampleDescription_GetMpeg4AudioObjectType(AP4_MpegAudioSampleDescription* self);
705
706 const char*
707 AP4_MpegAudioSampleDescription_GetMpegAudioObjectTypeString(AP4_UI08 type); /* class method */
708
709 AP4_SampleDescription*
710 AP4_ProtectedSampleDescription_GetOriginalSampleDescription(AP4_ProtectedSampleDescription* self);
711
712 AP4_UI32
713 AP4_ProtectedSampleDescription_GetOriginalFormat(AP4_ProtectedSampleDescription* self);
714
715 AP4_UI32
716 AP4_ProtectedSampleDescription_GetSchemeType(AP4_ProtectedSampleDescription* self);
717
718 AP4_UI32
719 AP4_ProtectedSampleDescription_GetSchemeVersion(AP4_ProtectedSampleDescription* self);
720
721 const char*
722 AP4_ProtectedSampleDescription_GetSchemeUri(AP4_ProtectedSampleDescription* self);
723
724 void AP4_SampleDescription_Destroy(AP4_SampleDescription* self);
725
726 /*----------------------------------------------------------------------
727 | AP4_SampleDescription constructors
728 +---------------------------------------------------------------------*/
729 AP4_SampleDescription*
730 AP4_MpegVideoSampleDescription_Create(AP4_UI08 oti,
731 AP4_UI16 width,
732 AP4_UI16 height,
733 AP4_UI16 depth,
734 const char* compressor_name,
735 const AP4_Byte* decoder_info,
736 AP4_Size decoder_info_size,
737 AP4_UI32 buffer_size,
738 AP4_UI32 max_bitrate,
739 AP4_UI32 avg_bitrate);
740
741 AP4_SampleDescription*
742 AP4_MpegAudioSampleDescription_Create(AP4_UI08 oti,
743 AP4_UI32 sample_rate,
744 AP4_UI32 sample_size,
745 AP4_UI32 channel_count,
746 const AP4_Byte* decoder_info,
747 AP4_Size decoder_info_size,
748 AP4_UI32 buffer_size,
749 AP4_UI32 max_bitrate,
750 AP4_UI32 avg_bitrate);
751
752 AP4_SampleDescription*
753 AP4_MpegSystemSampleDescription_Create(AP4_UI08 stream_type,
754 AP4_UI08 oti,
755 const AP4_Byte* decoder_info,
756 AP4_Size decoder_info_size,
757 AP4_UI32 buffer_size,
758 AP4_UI32 max_bitrate,
759 AP4_UI32 avg_bitrate);
760
761 AP4_SampleDescription*
762 AP4_AvcSampleDescription_Create(AP4_UI16 width,
763 AP4_UI16 height,
764 AP4_UI16 depth,
765 const char* compressor_name,
766 AP4_UI08 config_version,
767 AP4_UI08 profile,
768 AP4_UI08 level,
769 AP4_UI08 profile_compatibility,
770 AP4_UI08 nalu_length_size,
771 AP4_DataBuffer** sequence_parameters,
772 AP4_Size sequence_parameter_count,
773 AP4_DataBuffer** picture_parameters,
774 AP4_Size picture_parameter_count);
775
776 /*----------------------------------------------------------------------
777 | AP4_Sample methods
778 +---------------------------------------------------------------------*/
779 AP4_Result
780 AP4_Sample_ReadData(AP4_Sample* self, AP4_DataBuffer* data);
781
782 AP4_Result
783 AP4_Sample_ReadPartialData(AP4_Sample* self,
784 AP4_DataBuffer* data,
785 AP4_Size size,
786 AP4_Size offset);
787
788 AP4_ByteStream*
789 AP4_Sample_GetDataStream(AP4_Sample* self);
790
791 void
792 AP4_Sample_SetDataStream(AP4_Sample* self, AP4_ByteStream* stream);
793
794 AP4_Position
795 AP4_Sample_GetOffset(AP4_Sample* self);
796
797 void
798 AP4_Sample_SetOffset(AP4_Sample* self, AP4_Position offset);
799
800 AP4_Size
801 AP4_Sample_GetSize(AP4_Sample* self);
802
803 void
804 AP4_Sample_SetSize(AP4_Sample* self, AP4_Size size);
805
806 AP4_Ordinal
807 AP4_Sample_GetDescriptionIndex(AP4_Sample* self);
808
809 void
810 AP4_Sample_SetDescriptionIndex(AP4_Sample* self, AP4_Ordinal index);
811
812 AP4_UI64
813 AP4_Sample_GetDts(AP4_Sample* self);
814
815 void
816 AP4_SampleSetDts(AP4_Sample* self, AP4_UI64 dts);
817
818 AP4_UI64
819 AP4_Sample_GetCts(AP4_Sample* self);
820
821 void
822 AP4_Sample_SetCts(AP4_Sample* self, AP4_UI64 cts);
823
824 AP4_UI32
825 AP4_Sample_GetDuration(AP4_Sample* self);
826
827 void
828 AP4_Sample_SetDuration(AP4_Sample* self, AP4_UI32 duration);
829
830 int
831 AP4_Sample_IsSync(AP4_Sample* self);
832
833 void
834 AP4_Sample_SetSync(AP4_Sample* self, int is_sync);
835
836 void
837 AP4_Sample_Destroy(AP4_Sample* self);
838
839 /*----------------------------------------------------------------------
840 | AP4_Sample constructors
841 +---------------------------------------------------------------------*/
842 AP4_Sample*
843 AP4_Sample_CreateEmpty(void);
844
845 AP4_Sample*
846 AP4_Sample_Create(AP4_ByteStream* data_stream,
847 AP4_Position offset,
848 AP4_Size size,
849 AP4_Ordinal description_index,
850 AP4_UI32 dts,
851 AP4_UI32 cts_offset,
852 int is_sync);
853
854 AP4_Sample*
855 AP4_Sample_Clone(const AP4_Sample* other);
856
857 /*----------------------------------------------------------------------
858 | AP4_SyntheticSampleTable methods
859 +---------------------------------------------------------------------*/
860 AP4_Result
861 AP4_SyntheticSampleTable_AddSampleDescription(AP4_SyntheticSampleTable* self,
862 AP4_SampleDescription* desc);
863
864 AP4_Result
865 AP4_SyntheticSampleTable_AddSample(AP4_SyntheticSampleTable* self,
866 AP4_ByteStream* data_stream,
867 AP4_Position offset,
868 AP4_Size size,
869 AP4_Ordinal desc_index,
870 AP4_UI32 cts,
871 AP4_UI32 dts,
872 int is_sync);
873
874 void
875 AP4_SyntheticSampleTable_Destroy(AP4_SyntheticSampleTable* self);
876
877 /*----------------------------------------------------------------------
878 | AP4_SyntheticSampleTable constructors
879 +---------------------------------------------------------------------*/
880 AP4_SyntheticSampleTable*
881 AP4_SyntheticSampleTable_Create(AP4_Cardinal chunk_size); /* see AP4_SYNTHETIC_SAMPLE_TABLE_DEFAULT_CHUNK_SIZE constant */
882
883 /*----------------------------------------------------------------------
884 | AP4_AtomInspector methods
885 +---------------------------------------------------------------------*/
886 void
887 AP4_AtomInspector_Destroy(AP4_AtomInspector* self);
888
889 /*----------------------------------------------------------------------
890 | AP4_AtomInspector constructors
891 +---------------------------------------------------------------------*/
892 AP4_AtomInspector*
893 AP4_PrintInspector_Create(AP4_ByteStream* stream);
894
895 AP4_AtomInspector*
896 AP4_AtomInspector_FromDelegate(AP4_AtomInspectorDelegate* delegate);
897
898 #ifdef __cplusplus
899 }
900 #endif /*__cplusplus */