| 1 |
/***************************************************************** |
| 2 |
| |
| 3 |
| Bento4 - C API Implementation |
| 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 "Bento4C.h" |
| 33 |
#include "Ap4.h" |
| 34 |
|
| 35 |
/*---------------------------------------------------------------------- |
| 36 |
| constants |
| 37 |
+---------------------------------------------------------------------*/ |
| 38 |
const int AP4_FILE_BYTE_STREAM_MODE_READ = AP4_FileByteStream::STREAM_MODE_READ; |
| 39 |
const int AP4_FILE_BYTE_STREAM_MODE_WRITE = AP4_FileByteStream::STREAM_MODE_WRITE; |
| 40 |
const int AP4_FILE_BYTE_STREAM_MODE_READ_WRITE = AP4_FileByteStream::STREAM_MODE_READ_WRITE; |
| 41 |
|
| 42 |
const int AP4_TRACK_TYPE_UNKNOWN = AP4_Track::TYPE_UNKNOWN; |
| 43 |
const int AP4_TRACK_TYPE_AUDIO = AP4_Track::TYPE_AUDIO; |
| 44 |
const int AP4_TRACK_TYPE_VIDEO = AP4_Track::TYPE_VIDEO; |
| 45 |
const int AP4_TRACK_TYPE_SYSTEM = AP4_Track::TYPE_SYSTEM; |
| 46 |
const int AP4_TRACK_TYPE_HINT = AP4_Track::TYPE_HINT; |
| 47 |
const int AP4_TRACK_TYPE_TEXT = AP4_Track::TYPE_TEXT; |
| 48 |
const int AP4_TRACK_TYPE_JPEG = AP4_Track::TYPE_JPEG; |
| 49 |
const int AP4_TRACK_TYPE_RTP = AP4_Track::TYPE_RTP; |
| 50 |
const int AP4_TRACK_TYPE_SUBTITLES = AP4_Track::TYPE_SUBTITLES; |
| 51 |
|
| 52 |
const int AP4_ATOM_INSPECTOR_HINT_NONE = AP4_AtomInspector::HINT_NONE; |
| 53 |
const int AP4_ATOM_INSPECTOR_HINT_HEX = AP4_AtomInspector::HINT_HEX; |
| 54 |
//const int AP4_ATOM_INSPECTOR_HINT_BOOLEAN = AP4_AtomInspector::HINT_BOOLEAN; |
| 55 |
|
| 56 |
const int AP4_SAMPLE_DESCRIPTION_TYPE_UNKNOWN = AP4_SampleDescription::TYPE_UNKNOWN; |
| 57 |
const int AP4_SAMPLE_DESCRIPTION_TYPE_MPEG = AP4_SampleDescription::TYPE_MPEG; |
| 58 |
const int AP4_SAMPLE_DESCRIPTION_TYPE_PROTECTED = AP4_SampleDescription::TYPE_PROTECTED; |
| 59 |
const int AP4_SAMPLE_DESCRIPTION_TYPE_AVC = AP4_SampleDescription::TYPE_AVC; |
| 60 |
const int AP4_SAMPLE_DESCRIPTION_TYPE_HEVC = AP4_SampleDescription::TYPE_HEVC; |
| 61 |
|
| 62 |
/*---------------------------------------------------------------------- |
| 63 |
| AP4_DelegatorByteStream |
| 64 |
+---------------------------------------------------------------------*/ |
| 65 |
class AP4_DelegatorByteStream : public AP4_ByteStream |
| 66 |
{ |
| 67 |
public: |
| 68 |
AP4_DelegatorByteStream(AP4_ByteStreamDelegate* delegate) : |
| 69 |
m_Delegate(delegate), |
| 70 |
m_RefCount(1) {} |
| 71 |
|
| 72 |
// overloaded methods |
| 73 |
void AddReference() { m_RefCount++; } |
| 74 |
void Release() { if (--m_RefCount == 0) delete this; } |
| 75 |
AP4_Result ReadPartial(void* buffer, |
| 76 |
AP4_Size bytes_to_read, |
| 77 |
AP4_Size& bytes_read); |
| 78 |
AP4_Result WritePartial(const void* buffer, |
| 79 |
AP4_Size bytes_to_write, |
| 80 |
AP4_Size& bytes_written); |
| 81 |
AP4_Result Seek(AP4_Position position); |
| 82 |
AP4_Result Tell(AP4_Position& position); |
| 83 |
AP4_Result GetSize(AP4_LargeSize& size); |
| 84 |
AP4_Result Flush(); |
| 85 |
|
| 86 |
private: |
| 87 |
~AP4_DelegatorByteStream(); |
| 88 |
AP4_ByteStreamDelegate* m_Delegate; |
| 89 |
AP4_Cardinal m_RefCount; |
| 90 |
}; |
| 91 |
|
| 92 |
AP4_DelegatorByteStream::~AP4_DelegatorByteStream() |
| 93 |
{ |
| 94 |
if (m_Delegate->Destroy) { |
| 95 |
m_Delegate->Destroy(m_Delegate); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
AP4_Result |
| 100 |
AP4_DelegatorByteStream::ReadPartial(void* buffer, |
| 101 |
AP4_Size bytes_to_read, |
| 102 |
AP4_Size& bytes_read) |
| 103 |
{ |
| 104 |
return m_Delegate->ReadPartial(m_Delegate, buffer, bytes_to_read, &bytes_read); |
| 105 |
} |
| 106 |
|
| 107 |
AP4_Result |
| 108 |
AP4_DelegatorByteStream::WritePartial(const void* buffer, |
| 109 |
AP4_Size bytes_to_write, |
| 110 |
AP4_Size& bytes_written) |
| 111 |
{ |
| 112 |
return m_Delegate->WritePartial(m_Delegate, buffer, bytes_to_write, &bytes_written); |
| 113 |
} |
| 114 |
|
| 115 |
AP4_Result |
| 116 |
AP4_DelegatorByteStream::Seek(AP4_Position position) |
| 117 |
{ |
| 118 |
return m_Delegate->Seek(m_Delegate, position); |
| 119 |
} |
| 120 |
|
| 121 |
AP4_Result |
| 122 |
AP4_DelegatorByteStream::Tell(AP4_Position& position) |
| 123 |
{ |
| 124 |
return m_Delegate->Tell(m_Delegate, &position); |
| 125 |
} |
| 126 |
|
| 127 |
AP4_Result |
| 128 |
AP4_DelegatorByteStream::GetSize(AP4_LargeSize& size) |
| 129 |
{ |
| 130 |
return m_Delegate->GetSize(m_Delegate, &size); |
| 131 |
} |
| 132 |
|
| 133 |
AP4_Result |
| 134 |
AP4_DelegatorByteStream::Flush() |
| 135 |
{ |
| 136 |
return m_Delegate->Flush(m_Delegate); |
| 137 |
} |
| 138 |
|
| 139 |
/*---------------------------------------------------------------------- |
| 140 |
| AP4_ByteStream implementation |
| 141 |
+---------------------------------------------------------------------*/ |
| 142 |
void |
| 143 |
AP4_ByteStream_AddReference(AP4_ByteStream* self) |
| 144 |
{ |
| 145 |
self->AddReference(); |
| 146 |
} |
| 147 |
|
| 148 |
void |
| 149 |
AP4_ByteStream_Release(AP4_ByteStream* self) |
| 150 |
{ |
| 151 |
self->Release(); |
| 152 |
} |
| 153 |
|
| 154 |
AP4_Result |
| 155 |
AP4_ByteStream_ReadPartial(AP4_ByteStream* self, |
| 156 |
void* buffer, |
| 157 |
AP4_Size bytes_to_read, |
| 158 |
AP4_Size* bytes_read) |
| 159 |
{ |
| 160 |
return self->ReadPartial(buffer, bytes_to_read, *bytes_read); |
| 161 |
} |
| 162 |
|
| 163 |
AP4_Result |
| 164 |
AP4_ByteStream_Read(AP4_ByteStream* self, |
| 165 |
void* buffer, |
| 166 |
AP4_Size bytes_to_read) |
| 167 |
{ |
| 168 |
return self->Read(buffer, bytes_to_read); |
| 169 |
} |
| 170 |
|
| 171 |
AP4_Result |
| 172 |
AP4_ByteStream_ReadDouble(AP4_ByteStream* self, double* value) |
| 173 |
{ |
| 174 |
return self->ReadDouble(*value); |
| 175 |
} |
| 176 |
|
| 177 |
AP4_Result |
| 178 |
AP4_ByteStream_ReadUI64(AP4_ByteStream* self, AP4_UI64* value) |
| 179 |
{ |
| 180 |
return self->ReadUI64(*value); |
| 181 |
} |
| 182 |
|
| 183 |
AP4_Result |
| 184 |
AP4_ByteStream_ReadUI32(AP4_ByteStream* self, AP4_UI32* value) |
| 185 |
{ |
| 186 |
return self->ReadUI32(*value); |
| 187 |
} |
| 188 |
|
| 189 |
AP4_Result |
| 190 |
AP4_ByteStream_ReadUI24(AP4_ByteStream* self, AP4_UI32* value) |
| 191 |
{ |
| 192 |
return self->ReadUI24(*value); |
| 193 |
} |
| 194 |
|
| 195 |
AP4_Result |
| 196 |
AP4_ByteStream_ReadUI16(AP4_ByteStream* self, AP4_UI16* value) |
| 197 |
{ |
| 198 |
return self->ReadUI16(*value); |
| 199 |
} |
| 200 |
|
| 201 |
AP4_Result |
| 202 |
AP4_ByteStream_ReadUI08(AP4_ByteStream* self, AP4_UI08* value) |
| 203 |
{ |
| 204 |
return self->ReadUI08(*value); |
| 205 |
} |
| 206 |
|
| 207 |
AP4_Result |
| 208 |
AP4_ByteStream_ReadString(AP4_ByteStream* self, |
| 209 |
char* buffer, |
| 210 |
AP4_Size size) |
| 211 |
{ |
| 212 |
return self->ReadString(buffer, size); |
| 213 |
} |
| 214 |
|
| 215 |
AP4_Result |
| 216 |
AP4_ByteStream_WritePartial(AP4_ByteStream* self, |
| 217 |
const void* buffer, |
| 218 |
AP4_Size bytes_to_write, |
| 219 |
AP4_Size* bytes_written) |
| 220 |
{ |
| 221 |
return self->WritePartial(buffer, bytes_to_write, *bytes_written); |
| 222 |
} |
| 223 |
|
| 224 |
AP4_Result |
| 225 |
AP4_ByteStream_Write(AP4_ByteStream* self, |
| 226 |
const void* buffer, |
| 227 |
AP4_Size bytes_to_write) |
| 228 |
{ |
| 229 |
return self->Write(buffer, bytes_to_write); |
| 230 |
} |
| 231 |
|
| 232 |
AP4_Result |
| 233 |
AP4_ByteStream_WriteDouble(AP4_ByteStream* self, double value) |
| 234 |
{ |
| 235 |
return self->WriteDouble(value); |
| 236 |
} |
| 237 |
|
| 238 |
AP4_Result |
| 239 |
AP4_ByteStream_WriteUI64(AP4_ByteStream* self, AP4_UI64 value) |
| 240 |
{ |
| 241 |
return self->WriteUI64(value); |
| 242 |
} |
| 243 |
|
| 244 |
AP4_Result |
| 245 |
AP4_ByteStream_WriteUI32(AP4_ByteStream* self, AP4_UI32 value) |
| 246 |
{ |
| 247 |
return self->WriteUI32(value); |
| 248 |
} |
| 249 |
|
| 250 |
AP4_Result |
| 251 |
AP4_ByteStream_WriteUI24(AP4_ByteStream* self, AP4_UI32 value) |
| 252 |
{ |
| 253 |
return self->WriteUI24(value); |
| 254 |
} |
| 255 |
|
| 256 |
AP4_Result |
| 257 |
AP4_ByteStream_WriteUI16(AP4_ByteStream* self, AP4_UI16 value) |
| 258 |
{ |
| 259 |
return self->WriteUI16(value); |
| 260 |
} |
| 261 |
|
| 262 |
AP4_Result |
| 263 |
AP4_ByteStream_WriteUI08(AP4_ByteStream* self, AP4_UI08 value) |
| 264 |
{ |
| 265 |
return self->WriteUI08(value); |
| 266 |
} |
| 267 |
|
| 268 |
AP4_Result |
| 269 |
AP4_ByteStream_WriteString(AP4_ByteStream* self, const char* buffer) |
| 270 |
{ |
| 271 |
return self->WriteString(buffer); |
| 272 |
} |
| 273 |
|
| 274 |
AP4_Result |
| 275 |
AP4_ByteStream_Seek(AP4_ByteStream* self, AP4_Position position) |
| 276 |
{ |
| 277 |
return self->Seek(position); |
| 278 |
} |
| 279 |
|
| 280 |
AP4_Result |
| 281 |
AP4_ByteStream_Tell(AP4_ByteStream* self, AP4_Position* position) |
| 282 |
{ |
| 283 |
return self->Tell(*position); |
| 284 |
} |
| 285 |
|
| 286 |
AP4_Result |
| 287 |
AP4_ByteStream_GetSize(AP4_ByteStream* self, AP4_LargeSize* size) |
| 288 |
{ |
| 289 |
return self->GetSize(*size); |
| 290 |
} |
| 291 |
|
| 292 |
AP4_Result |
| 293 |
AP4_ByteStream_CopyTo(AP4_ByteStream* self, |
| 294 |
AP4_ByteStream* receiver, |
| 295 |
AP4_LargeSize size) |
| 296 |
{ |
| 297 |
return self->CopyTo(*receiver, size); |
| 298 |
} |
| 299 |
|
| 300 |
AP4_Result |
| 301 |
Ap4_ByteStream_Flush(AP4_ByteStream* self) |
| 302 |
{ |
| 303 |
return self->Flush(); |
| 304 |
} |
| 305 |
|
| 306 |
AP4_ByteStream* |
| 307 |
AP4_SubStream_Create(AP4_ByteStream* container, |
| 308 |
AP4_Position position, |
| 309 |
AP4_LargeSize size) |
| 310 |
{ |
| 311 |
return new AP4_SubStream(*container, position, size); |
| 312 |
} |
| 313 |
|
| 314 |
AP4_ByteStream* |
| 315 |
AP4_MemoryByteStream_Create(AP4_Size size) |
| 316 |
{ |
| 317 |
return new AP4_MemoryByteStream(size); |
| 318 |
} |
| 319 |
|
| 320 |
AP4_ByteStream* |
| 321 |
AP4_MemoryByteStream_FromBuffer(const AP4_UI08* buffer, AP4_Size size) |
| 322 |
{ |
| 323 |
return new AP4_MemoryByteStream(buffer, size); |
| 324 |
} |
| 325 |
|
| 326 |
AP4_ByteStream* |
| 327 |
AP4_MemoryByteStream_AdaptDataBuffer(AP4_DataBuffer* buffer) |
| 328 |
{ |
| 329 |
return new AP4_MemoryByteStream(*buffer); |
| 330 |
} |
| 331 |
|
| 332 |
AP4_ByteStream* |
| 333 |
AP4_FileByteStream_Create(const char* name, int mode, AP4_Result* result) |
| 334 |
{ |
| 335 |
AP4_Result local_result; |
| 336 |
AP4_ByteStream* stream; |
| 337 |
|
| 338 |
local_result = AP4_FileByteStream::Create(name, |
| 339 |
(AP4_FileByteStream::Mode)mode, |
| 340 |
stream); |
| 341 |
if (result) *result = local_result; |
| 342 |
if (AP4_SUCCEEDED(local_result)) { |
| 343 |
return stream; |
| 344 |
} else { |
| 345 |
return NULL; |
| 346 |
} |
| 347 |
} |
| 348 |
|
| 349 |
AP4_ByteStream* |
| 350 |
AP4_ByteStream_FromDelegate(AP4_ByteStreamDelegate* delegate) |
| 351 |
{ |
| 352 |
return new AP4_DelegatorByteStream(delegate); |
| 353 |
} |
| 354 |
|
| 355 |
/*---------------------------------------------------------------------- |
| 356 |
| AP4_DataBuffer implementation |
| 357 |
+---------------------------------------------------------------------*/ |
| 358 |
AP4_Result |
| 359 |
AP4_DataBuffer_SetBuffer(AP4_DataBuffer* self, AP4_Byte* buffer, AP4_Size size) |
| 360 |
{ |
| 361 |
return self->SetBuffer(buffer, size); |
| 362 |
} |
| 363 |
|
| 364 |
AP4_Result |
| 365 |
AP4_DataBuffer_SetBufferSize(AP4_DataBuffer* self, AP4_Size size) |
| 366 |
{ |
| 367 |
return self->SetBufferSize(size); |
| 368 |
} |
| 369 |
|
| 370 |
AP4_Size |
| 371 |
AP4_DataBuffer_GetBufferSize(const AP4_DataBuffer* self) |
| 372 |
{ |
| 373 |
return self->GetBufferSize(); |
| 374 |
} |
| 375 |
|
| 376 |
const AP4_Byte* |
| 377 |
AP4_DataBuffer_GetData(const AP4_DataBuffer* self) |
| 378 |
{ |
| 379 |
return self->GetData(); |
| 380 |
} |
| 381 |
|
| 382 |
AP4_Byte* |
| 383 |
AP4_DataBuffer_UseData(AP4_DataBuffer* self) |
| 384 |
{ |
| 385 |
return self->UseData(); |
| 386 |
} |
| 387 |
|
| 388 |
AP4_Size |
| 389 |
AP4_DataBuffer_GetDataSize(const AP4_DataBuffer* self) |
| 390 |
{ |
| 391 |
return self->GetDataSize(); |
| 392 |
} |
| 393 |
|
| 394 |
AP4_Result |
| 395 |
AP4_DataBuffer_SetDataSize(AP4_DataBuffer* self, AP4_Size size) |
| 396 |
{ |
| 397 |
return self->SetDataSize(size); |
| 398 |
} |
| 399 |
|
| 400 |
AP4_Result |
| 401 |
AP4_DataBuffer_SetData(AP4_DataBuffer* self, |
| 402 |
const AP4_Byte* data, |
| 403 |
AP4_Size data_size) |
| 404 |
{ |
| 405 |
return self->SetData(data, data_size); |
| 406 |
} |
| 407 |
|
| 408 |
AP4_Result |
| 409 |
AP4_DataBuffer_Reserve(AP4_DataBuffer* self, AP4_Size size) |
| 410 |
{ |
| 411 |
return self->Reserve(size); |
| 412 |
} |
| 413 |
|
| 414 |
void |
| 415 |
AP4_DataBuffer_Destroy(AP4_DataBuffer* self) |
| 416 |
{ |
| 417 |
delete self; |
| 418 |
} |
| 419 |
|
| 420 |
AP4_DataBuffer* |
| 421 |
AP4_DataBuffer_Create(AP4_Size size) |
| 422 |
{ |
| 423 |
return new AP4_DataBuffer(size); |
| 424 |
} |
| 425 |
|
| 426 |
AP4_DataBuffer* |
| 427 |
AP4_DataBuffer_FromData(const void* data, AP4_Size data_size) |
| 428 |
{ |
| 429 |
return new AP4_DataBuffer(data, data_size); |
| 430 |
} |
| 431 |
|
| 432 |
AP4_DataBuffer* |
| 433 |
AP4_DataBuffer_Clone(const AP4_DataBuffer* other) |
| 434 |
{ |
| 435 |
return new AP4_DataBuffer(*other); |
| 436 |
} |
| 437 |
|
| 438 |
/*---------------------------------------------------------------------- |
| 439 |
| AP4_File implementation |
| 440 |
+---------------------------------------------------------------------*/ |
| 441 |
AP4_Movie* |
| 442 |
AP4_File_GetMovie(AP4_File* self) |
| 443 |
{ |
| 444 |
return self->GetMovie(); |
| 445 |
} |
| 446 |
|
| 447 |
AP4_Result |
| 448 |
AP4_File_GetFileType(AP4_File* self, |
| 449 |
AP4_UI32* major_brand, |
| 450 |
AP4_UI32* minor_version, |
| 451 |
AP4_Cardinal* compatible_brand_count) |
| 452 |
{ |
| 453 |
AP4_FtypAtom* ftyp = self->GetFileType(); |
| 454 |
if (!ftyp) return AP4_FAILURE; |
| 455 |
|
| 456 |
if (major_brand) *major_brand = ftyp->GetMajorBrand(); |
| 457 |
if (minor_version) *minor_version = ftyp->GetMinorVersion(); |
| 458 |
if (compatible_brand_count) { |
| 459 |
*compatible_brand_count = ftyp->GetCompatibleBrands().ItemCount(); |
| 460 |
} |
| 461 |
return AP4_SUCCESS; |
| 462 |
} |
| 463 |
|
| 464 |
AP4_Result |
| 465 |
AP4_File_GetCompatibleBrand(AP4_File* self, |
| 466 |
AP4_Ordinal index, |
| 467 |
AP4_UI32* brand) |
| 468 |
{ |
| 469 |
AP4_FtypAtom* ftyp = self->GetFileType(); |
| 470 |
if (!ftyp || !brand) return AP4_FAILURE; |
| 471 |
|
| 472 |
if (index >= ftyp->GetCompatibleBrands().ItemCount()) { |
| 473 |
return AP4_ERROR_OUT_OF_RANGE; |
| 474 |
} |
| 475 |
|
| 476 |
*brand = ftyp->GetCompatibleBrands()[index]; |
| 477 |
return AP4_SUCCESS; |
| 478 |
} |
| 479 |
|
| 480 |
AP4_Result |
| 481 |
AP4_File_SetFileType(AP4_File* self, |
| 482 |
AP4_UI32 major_brand, |
| 483 |
AP4_UI32 minor_version, |
| 484 |
AP4_UI32* compatible_brands, |
| 485 |
AP4_Cardinal compatible_brand_count) |
| 486 |
{ |
| 487 |
return self->SetFileType(major_brand, |
| 488 |
minor_version, |
| 489 |
compatible_brands, |
| 490 |
compatible_brand_count); |
| 491 |
} |
| 492 |
|
| 493 |
int |
| 494 |
AP4_File_IsMoovBeforeMdat(const AP4_File* self) |
| 495 |
{ |
| 496 |
return (int) self->IsMoovBeforeMdat(); |
| 497 |
} |
| 498 |
|
| 499 |
const AP4_MetaData* |
| 500 |
AP4_File_GetMetaData(AP4_File* self) |
| 501 |
{ |
| 502 |
return self->GetMetaData(); |
| 503 |
} |
| 504 |
|
| 505 |
AP4_Result |
| 506 |
AP4_File_Inspect(AP4_File* self, AP4_AtomInspector* inspector) |
| 507 |
{ |
| 508 |
return self->Inspect(*inspector); |
| 509 |
} |
| 510 |
|
| 511 |
void |
| 512 |
AP4_File_Destroy(AP4_File* self) |
| 513 |
{ |
| 514 |
delete self; |
| 515 |
} |
| 516 |
|
| 517 |
AP4_File* |
| 518 |
AP4_File_Create(AP4_Movie* movie) |
| 519 |
{ |
| 520 |
return new AP4_File(movie); |
| 521 |
} |
| 522 |
|
| 523 |
AP4_File* |
| 524 |
AP4_File_FromStream(AP4_ByteStream* stream, int moov_only) |
| 525 |
{ |
| 526 |
return new AP4_File(*stream, moov_only?true:false); |
| 527 |
} |
| 528 |
|
| 529 |
/*---------------------------------------------------------------------- |
| 530 |
| AP4_Movie implementation |
| 531 |
+---------------------------------------------------------------------*/ |
| 532 |
AP4_Cardinal |
| 533 |
AP4_Movie_GetTrackCount(AP4_Movie* self) |
| 534 |
{ |
| 535 |
return self->GetTracks().ItemCount(); |
| 536 |
} |
| 537 |
|
| 538 |
AP4_Track* |
| 539 |
AP4_Movie_GetTrackByIndex(AP4_Movie* self, AP4_Ordinal index) |
| 540 |
{ |
| 541 |
AP4_Track* track = NULL; |
| 542 |
if (AP4_FAILED(self->GetTracks().Get(index, track))) { |
| 543 |
return NULL; |
| 544 |
} else { |
| 545 |
return track; |
| 546 |
} |
| 547 |
} |
| 548 |
|
| 549 |
AP4_Track* |
| 550 |
AP4_Movie_GetTrackById(AP4_Movie* self, AP4_UI32 track_id) |
| 551 |
{ |
| 552 |
return self->GetTrack(track_id); |
| 553 |
} |
| 554 |
|
| 555 |
AP4_Track* |
| 556 |
AP4_Movie_GetTrackByType(AP4_Movie* self, int type, AP4_Ordinal index) |
| 557 |
{ |
| 558 |
return self->GetTrack((AP4_Track::Type) type, index); |
| 559 |
} |
| 560 |
|
| 561 |
AP4_UI32 |
| 562 |
AP4_Movie_GetTimeScale(AP4_Movie* self) |
| 563 |
{ |
| 564 |
return self->GetTimeScale(); |
| 565 |
} |
| 566 |
|
| 567 |
AP4_UI64 |
| 568 |
AP4_Movie_GetDuration(AP4_Movie* self) |
| 569 |
{ |
| 570 |
return self->GetDuration(); |
| 571 |
} |
| 572 |
|
| 573 |
AP4_UI32 |
| 574 |
AP4_Movie_GetDurationMs(AP4_Movie* self) |
| 575 |
{ |
| 576 |
return self->GetDurationMs(); |
| 577 |
} |
| 578 |
|
| 579 |
void |
| 580 |
AP4_Movie_Destroy(AP4_Movie* self) |
| 581 |
{ |
| 582 |
delete self; |
| 583 |
} |
| 584 |
|
| 585 |
AP4_Result |
| 586 |
AP4_Movie_AddTrack(AP4_Movie* self, AP4_Track* track) |
| 587 |
{ |
| 588 |
return self->AddTrack(track); |
| 589 |
} |
| 590 |
|
| 591 |
AP4_Movie* |
| 592 |
AP4_Movie_Create(AP4_UI32 time_scale) |
| 593 |
{ |
| 594 |
return new AP4_Movie(time_scale); |
| 595 |
} |
| 596 |
|
| 597 |
/*---------------------------------------------------------------------- |
| 598 |
| AP4_Track implementation |
| 599 |
+---------------------------------------------------------------------*/ |
| 600 |
int |
| 601 |
AP4_Track_GetType(AP4_Track* self) |
| 602 |
{ |
| 603 |
return self->GetType(); |
| 604 |
} |
| 605 |
|
| 606 |
AP4_UI32 |
| 607 |
AP4_Track_GetHandlerType(AP4_Track* self) |
| 608 |
{ |
| 609 |
return self->GetHandlerType(); |
| 610 |
} |
| 611 |
|
| 612 |
AP4_UI64 |
| 613 |
AP4_Track_GetDuration(AP4_Track* self) |
| 614 |
{ |
| 615 |
return self->GetDuration(); |
| 616 |
} |
| 617 |
|
| 618 |
AP4_UI32 |
| 619 |
AP4_Track_GetDurationMs(AP4_Track* self) |
| 620 |
{ |
| 621 |
return self->GetDurationMs(); |
| 622 |
} |
| 623 |
|
| 624 |
AP4_Cardinal |
| 625 |
AP4_Track_GetSampleCount(AP4_Track* self) |
| 626 |
{ |
| 627 |
return self->GetSampleCount(); |
| 628 |
} |
| 629 |
|
| 630 |
AP4_Result |
| 631 |
AP4_Track_GetSample(AP4_Track* self, AP4_Ordinal index, AP4_Sample* sample) |
| 632 |
{ |
| 633 |
return self->GetSample(index, *sample); |
| 634 |
} |
| 635 |
|
| 636 |
AP4_Result |
| 637 |
AP4_Track_ReadSample(AP4_Track* self, |
| 638 |
AP4_Ordinal index, |
| 639 |
AP4_Sample* sample, |
| 640 |
AP4_DataBuffer* data) |
| 641 |
{ |
| 642 |
return self->ReadSample(index, *sample, *data); |
| 643 |
} |
| 644 |
|
| 645 |
AP4_Result |
| 646 |
AP4_Track_GetSampleIndexForTimeStampMs(AP4_Track* self, |
| 647 |
AP4_UI32 ts, |
| 648 |
AP4_Ordinal* index) |
| 649 |
{ |
| 650 |
return self->GetSampleIndexForTimeStampMs(ts, *index); |
| 651 |
} |
| 652 |
|
| 653 |
AP4_Ordinal |
| 654 |
AP4_Track_GetNearestSyncSampleIndex(AP4_Track* self, AP4_Ordinal index, AP4_Boolean before) |
| 655 |
{ |
| 656 |
return self->GetNearestSyncSampleIndex(index, before==AP4_TRUE); |
| 657 |
} |
| 658 |
|
| 659 |
AP4_SampleDescription* |
| 660 |
AP4_Track_GetSampleDescription(AP4_Track* self, AP4_Ordinal index) |
| 661 |
{ |
| 662 |
return self->GetSampleDescription(index); |
| 663 |
} |
| 664 |
|
| 665 |
AP4_UI32 |
| 666 |
AP4_Track_GetId(AP4_Track* self) |
| 667 |
{ |
| 668 |
return self->GetId(); |
| 669 |
} |
| 670 |
|
| 671 |
AP4_Result |
| 672 |
AP4_Track_SetId(AP4_Track* self, AP4_UI32 track_id) |
| 673 |
{ |
| 674 |
return self->SetId(track_id); |
| 675 |
} |
| 676 |
|
| 677 |
AP4_Result |
| 678 |
AP4_Track_SetMovieTimeScale(AP4_Track* self, AP4_UI32 time_scale) |
| 679 |
{ |
| 680 |
return self->SetMovieTimeScale(time_scale); |
| 681 |
} |
| 682 |
|
| 683 |
AP4_UI32 |
| 684 |
AP4_Track_GetMediaTimeScale(AP4_Track* self) |
| 685 |
{ |
| 686 |
return self->GetMediaTimeScale(); |
| 687 |
} |
| 688 |
|
| 689 |
AP4_UI64 |
| 690 |
AP4_Track_GetMediaDuration(AP4_Track* self) |
| 691 |
{ |
| 692 |
return self->GetMediaDuration(); |
| 693 |
} |
| 694 |
|
| 695 |
const char* |
| 696 |
AP4_Track_GetName(AP4_Track* self) |
| 697 |
{ |
| 698 |
return self->GetTrackName(); |
| 699 |
} |
| 700 |
|
| 701 |
const char* |
| 702 |
AP4_Track_GetLanguage(AP4_Track* self) |
| 703 |
{ |
| 704 |
return self->GetTrackLanguage(); |
| 705 |
} |
| 706 |
|
| 707 |
void |
| 708 |
AP4_Track_Destroy(AP4_Track* self) |
| 709 |
{ |
| 710 |
delete self; |
| 711 |
} |
| 712 |
|
| 713 |
AP4_Track* |
| 714 |
AP4_Track_Create(int type, |
| 715 |
AP4_SyntheticSampleTable* sample_table, |
| 716 |
AP4_UI32 track_id, |
| 717 |
AP4_UI32 movie_time_scale, /* 0 = use default */ |
| 718 |
AP4_UI32 track_duration, /* in the movie time scale */ |
| 719 |
AP4_UI32 media_time_scale, |
| 720 |
AP4_UI32 media_duration, /* in the media time scale */ |
| 721 |
const char* language, |
| 722 |
AP4_UI32 width, |
| 723 |
AP4_UI32 height) |
| 724 |
{ |
| 725 |
return new AP4_Track((AP4_Track::Type) type, |
| 726 |
sample_table, |
| 727 |
track_id, |
| 728 |
movie_time_scale, |
| 729 |
track_duration, |
| 730 |
media_time_scale, |
| 731 |
media_duration, |
| 732 |
language, |
| 733 |
width, |
| 734 |
height); |
| 735 |
} |
| 736 |
|
| 737 |
/*---------------------------------------------------------------------- |
| 738 |
| AP4_SampleDescription implementation |
| 739 |
+---------------------------------------------------------------------*/ |
| 740 |
int |
| 741 |
AP4_SampleDescription_GetType(AP4_SampleDescription* self) |
| 742 |
{ |
| 743 |
return self->GetType(); |
| 744 |
} |
| 745 |
|
| 746 |
AP4_UI32 |
| 747 |
AP4_SampleDescription_GetFormat(AP4_SampleDescription* self) |
| 748 |
{ |
| 749 |
return self->GetFormat(); |
| 750 |
} |
| 751 |
|
| 752 |
AP4_AudioSampleDescription* |
| 753 |
AP4_SampleDescription_AsAudio(AP4_SampleDescription* self) |
| 754 |
{ |
| 755 |
return AP4_DYNAMIC_CAST(AP4_AudioSampleDescription, self); |
| 756 |
} |
| 757 |
|
| 758 |
AP4_VideoSampleDescription* |
| 759 |
AP4_SampleDescription_AsVideo(AP4_SampleDescription* self) |
| 760 |
{ |
| 761 |
return AP4_DYNAMIC_CAST(AP4_VideoSampleDescription, self); |
| 762 |
} |
| 763 |
|
| 764 |
AP4_AvcSampleDescription* |
| 765 |
AP4_SampleDescription_AsAvc(AP4_SampleDescription* self) |
| 766 |
{ |
| 767 |
return AP4_DYNAMIC_CAST(AP4_AvcSampleDescription, self); |
| 768 |
} |
| 769 |
|
| 770 |
AP4_MpegSampleDescription* |
| 771 |
AP4_SampleDescription_AsMpeg(AP4_SampleDescription* self) |
| 772 |
{ |
| 773 |
return AP4_DYNAMIC_CAST(AP4_MpegSampleDescription, self); |
| 774 |
} |
| 775 |
|
| 776 |
AP4_MpegAudioSampleDescription* |
| 777 |
AP4_SampleDescription_AsMpegAudio(AP4_SampleDescription* self) |
| 778 |
{ |
| 779 |
return AP4_DYNAMIC_CAST(AP4_MpegAudioSampleDescription, self); |
| 780 |
} |
| 781 |
|
| 782 |
AP4_UI32 |
| 783 |
AP4_AudioSampleDescription_GetSampleRate(AP4_AudioSampleDescription* self) |
| 784 |
{ |
| 785 |
return self->GetSampleRate(); |
| 786 |
} |
| 787 |
|
| 788 |
AP4_UI16 |
| 789 |
AP4_AudioSampleDescription_GetSampleSize(AP4_AudioSampleDescription* self) |
| 790 |
{ |
| 791 |
return self->GetSampleSize(); |
| 792 |
} |
| 793 |
|
| 794 |
AP4_UI16 |
| 795 |
AP4_AudioSampleDescription_GetChannelCount(AP4_AudioSampleDescription* self) |
| 796 |
{ |
| 797 |
return self->GetChannelCount(); |
| 798 |
} |
| 799 |
|
| 800 |
AP4_UI32 |
| 801 |
AP4_VideoSampleDescription_GetWidth(AP4_VideoSampleDescription* self) |
| 802 |
{ |
| 803 |
return self->GetWidth(); |
| 804 |
} |
| 805 |
|
| 806 |
|
| 807 |
AP4_UI16 |
| 808 |
AP4_VideoSampleDescription_GetHeight(AP4_VideoSampleDescription* self) |
| 809 |
{ |
| 810 |
return self->GetHeight(); |
| 811 |
} |
| 812 |
|
| 813 |
AP4_UI16 |
| 814 |
AP4_VideoSampleDescription_GetDepth(AP4_VideoSampleDescription* self) |
| 815 |
{ |
| 816 |
return self->GetDepth(); |
| 817 |
} |
| 818 |
|
| 819 |
const char* |
| 820 |
AP4_VideoSampleDescription_GetCompressorName(AP4_VideoSampleDescription* self) |
| 821 |
{ |
| 822 |
return self->GetCompressorName(); |
| 823 |
} |
| 824 |
|
| 825 |
AP4_UI08 |
| 826 |
AP4_AvcSampleDescription_GetConfigurationVersion(AP4_AvcSampleDescription* self) |
| 827 |
{ |
| 828 |
return self->GetConfigurationVersion(); |
| 829 |
} |
| 830 |
|
| 831 |
AP4_UI08 |
| 832 |
AP4_AvcSampleDescription_GetProfile(AP4_AvcSampleDescription* self) |
| 833 |
{ |
| 834 |
return self->GetProfile(); |
| 835 |
} |
| 836 |
|
| 837 |
AP4_UI08 |
| 838 |
AP4_AvcSampleDescription_GetLevel(AP4_AvcSampleDescription* self) |
| 839 |
{ |
| 840 |
return self->GetLevel(); |
| 841 |
} |
| 842 |
|
| 843 |
AP4_UI08 |
| 844 |
AP4_AvcSampleDescription_GetProfileCompatibility(AP4_AvcSampleDescription* self) |
| 845 |
{ |
| 846 |
return self->GetProfileCompatibility(); |
| 847 |
} |
| 848 |
|
| 849 |
AP4_UI08 |
| 850 |
AP4_AvcSampleDescription_GetNaluLengthSize(AP4_AvcSampleDescription* self) |
| 851 |
{ |
| 852 |
return self->GetNaluLengthSize(); |
| 853 |
} |
| 854 |
|
| 855 |
AP4_Cardinal |
| 856 |
AP4_AvcSampleDescription_GetSequenceParameterCount(AP4_AvcSampleDescription* self) |
| 857 |
{ |
| 858 |
return self->GetSequenceParameters().ItemCount(); |
| 859 |
} |
| 860 |
|
| 861 |
const AP4_DataBuffer* |
| 862 |
AP4_AvcSampleDescription_GetSequenceParameter(AP4_AvcSampleDescription* self, |
| 863 |
AP4_Ordinal index) |
| 864 |
{ |
| 865 |
AP4_Array<AP4_DataBuffer>& params = self->GetSequenceParameters(); |
| 866 |
if (index >= params.ItemCount()) { |
| 867 |
return NULL; |
| 868 |
} else { |
| 869 |
return ¶ms[index]; |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
AP4_Cardinal |
| 874 |
AP4_AvcSampleDescription_GetPictureParameterCount(AP4_AvcSampleDescription* self) |
| 875 |
{ |
| 876 |
return self->GetPictureParameters().ItemCount(); |
| 877 |
} |
| 878 |
|
| 879 |
const AP4_DataBuffer* |
| 880 |
AP4_AvcSampleDescription_GetPictureParameter(AP4_AvcSampleDescription* self, |
| 881 |
AP4_Ordinal index) |
| 882 |
{ |
| 883 |
AP4_Array<AP4_DataBuffer>& params = self->GetPictureParameters(); |
| 884 |
if (index >= params.ItemCount()) { |
| 885 |
return NULL; |
| 886 |
} else { |
| 887 |
return ¶ms[index]; |
| 888 |
} |
| 889 |
} |
| 890 |
|
| 891 |
const AP4_DataBuffer* |
| 892 |
AP4_AvcSampleDescription_GetRawBytes(AP4_AvcSampleDescription* self) |
| 893 |
{ |
| 894 |
return &self->GetRawBytes(); |
| 895 |
} |
| 896 |
|
| 897 |
const char* |
| 898 |
AP4_AvcSampleDescription_GetProfileName(AP4_UI08 profile) |
| 899 |
{ |
| 900 |
return AP4_AvcSampleDescription::GetProfileName(profile); |
| 901 |
} |
| 902 |
|
| 903 |
AP4_UI08 |
| 904 |
AP4_MpegSampleDescription_GetStreamType(AP4_MpegSampleDescription* self) |
| 905 |
{ |
| 906 |
return self->GetStreamType(); |
| 907 |
} |
| 908 |
|
| 909 |
AP4_UI08 |
| 910 |
AP4_MpegSampleDescription_GetObjectTypeId(AP4_MpegSampleDescription* self) |
| 911 |
{ |
| 912 |
return self->GetObjectTypeId(); |
| 913 |
} |
| 914 |
|
| 915 |
AP4_UI32 |
| 916 |
AP4_MpegSampleDescription_GetBufferSize(AP4_MpegSampleDescription* self) |
| 917 |
{ |
| 918 |
return self->GetBufferSize(); |
| 919 |
} |
| 920 |
|
| 921 |
AP4_UI32 |
| 922 |
AP4_MpegSampleDescription_GetMaxBitrate(AP4_MpegSampleDescription* self) |
| 923 |
{ |
| 924 |
return self->GetMaxBitrate(); |
| 925 |
} |
| 926 |
|
| 927 |
AP4_UI32 |
| 928 |
AP4_MpegSampleDescription_GetAvgBitrate(AP4_MpegSampleDescription* self) |
| 929 |
{ |
| 930 |
return self->GetAvgBitrate(); |
| 931 |
} |
| 932 |
|
| 933 |
const AP4_DataBuffer* |
| 934 |
AP4_MpegSampleDescription_GetDecoderInfo(AP4_MpegSampleDescription* self) |
| 935 |
{ |
| 936 |
return &self->GetDecoderInfo(); |
| 937 |
} |
| 938 |
|
| 939 |
AP4_UI08 |
| 940 |
AP4_MpegAudioSampleDescription_GetMpeg4AudioObjectType(AP4_MpegAudioSampleDescription* self) |
| 941 |
{ |
| 942 |
return self->GetMpeg4AudioObjectType(); |
| 943 |
} |
| 944 |
|
| 945 |
const char* |
| 946 |
AP4_MpegAudioSampleDescription_GetMpegAudioObjectTypeString(AP4_UI08 type) |
| 947 |
{ |
| 948 |
return AP4_MpegAudioSampleDescription::GetMpeg4AudioObjectTypeString(type); |
| 949 |
} |
| 950 |
|
| 951 |
AP4_SampleDescription* |
| 952 |
AP4_ProtectedSampleDescription_GetOriginalSampleDescription(AP4_ProtectedSampleDescription* self) |
| 953 |
{ |
| 954 |
return self->GetOriginalSampleDescription(); |
| 955 |
} |
| 956 |
|
| 957 |
AP4_UI32 |
| 958 |
AP4_ProtectedSampleDescription_GetOriginalFormat(AP4_ProtectedSampleDescription* self) |
| 959 |
{ |
| 960 |
return self->GetOriginalFormat(); |
| 961 |
} |
| 962 |
|
| 963 |
AP4_UI32 |
| 964 |
AP4_ProtectedSampleDescription_GetSchemeType(AP4_ProtectedSampleDescription* self) |
| 965 |
{ |
| 966 |
return self->GetSchemeType(); |
| 967 |
} |
| 968 |
|
| 969 |
AP4_UI32 |
| 970 |
AP4_ProtectedSampleDescription_GetSchemeVersion(AP4_ProtectedSampleDescription* self) |
| 971 |
{ |
| 972 |
return self->GetSchemeVersion(); |
| 973 |
} |
| 974 |
|
| 975 |
const char* |
| 976 |
AP4_ProtectedSampleDescription_GetSchemeUri(AP4_ProtectedSampleDescription* self) |
| 977 |
{ |
| 978 |
return self->GetSchemeUri().GetChars(); |
| 979 |
} |
| 980 |
|
| 981 |
void |
| 982 |
AP4_SampleDescription_Destroy(AP4_SampleDescription* self) |
| 983 |
{ |
| 984 |
delete self; |
| 985 |
} |
| 986 |
|
| 987 |
AP4_SampleDescription* |
| 988 |
AP4_MpegVideoSampleDescription_Create(AP4_UI08 oti, |
| 989 |
AP4_UI16 width, |
| 990 |
AP4_UI16 height, |
| 991 |
AP4_UI16 depth, |
| 992 |
const char* compressor_name, |
| 993 |
const AP4_Byte* decoder_info, |
| 994 |
AP4_Size decoder_info_size, |
| 995 |
AP4_UI32 buffer_size, |
| 996 |
AP4_UI32 max_bitrate, |
| 997 |
AP4_UI32 avg_bitrate) |
| 998 |
{ |
| 999 |
AP4_DataBuffer info(decoder_info, decoder_info_size); |
| 1000 |
return new AP4_MpegVideoSampleDescription(oti, |
| 1001 |
width, |
| 1002 |
height, |
| 1003 |
depth, |
| 1004 |
compressor_name, |
| 1005 |
&info, |
| 1006 |
buffer_size, |
| 1007 |
max_bitrate, |
| 1008 |
avg_bitrate); |
| 1009 |
} |
| 1010 |
|
| 1011 |
AP4_SampleDescription* |
| 1012 |
AP4_MpegAudioSampleDescription_Create(AP4_UI08 oti, |
| 1013 |
AP4_UI32 sample_rate, |
| 1014 |
AP4_UI32 sample_size, |
| 1015 |
AP4_UI32 channel_count, |
| 1016 |
const AP4_Byte* decoder_info, |
| 1017 |
AP4_Size decoder_info_size, |
| 1018 |
AP4_UI32 buffer_size, |
| 1019 |
AP4_UI32 max_bitrate, |
| 1020 |
AP4_UI32 avg_bitrate) |
| 1021 |
{ |
| 1022 |
AP4_DataBuffer info(decoder_info, decoder_info_size); |
| 1023 |
return new AP4_MpegAudioSampleDescription(oti, |
| 1024 |
sample_rate, |
| 1025 |
sample_size, |
| 1026 |
channel_count, |
| 1027 |
&info, |
| 1028 |
buffer_size, |
| 1029 |
max_bitrate, |
| 1030 |
avg_bitrate); |
| 1031 |
} |
| 1032 |
|
| 1033 |
AP4_SampleDescription* |
| 1034 |
AP4_MpegSystemSampleDescription_Create(AP4_UI08 stream_type, |
| 1035 |
AP4_UI08 oti, |
| 1036 |
const AP4_Byte* decoder_info, |
| 1037 |
AP4_Size decoder_info_size, |
| 1038 |
AP4_UI32 buffer_size, |
| 1039 |
AP4_UI32 max_bitrate, |
| 1040 |
AP4_UI32 avg_bitrate) |
| 1041 |
{ |
| 1042 |
AP4_DataBuffer info(decoder_info, decoder_info_size); |
| 1043 |
return new AP4_MpegSystemSampleDescription(stream_type, |
| 1044 |
oti, |
| 1045 |
&info, |
| 1046 |
buffer_size, |
| 1047 |
max_bitrate, |
| 1048 |
avg_bitrate); |
| 1049 |
} |
| 1050 |
|
| 1051 |
AP4_SampleDescription* |
| 1052 |
AP4_AvcSampleDescription_Create(AP4_UI32 format, |
| 1053 |
AP4_UI16 width, |
| 1054 |
AP4_UI16 height, |
| 1055 |
AP4_UI16 depth, |
| 1056 |
const char* compressor_name, |
| 1057 |
AP4_UI08 profile, |
| 1058 |
AP4_UI08 level, |
| 1059 |
AP4_UI08 profile_compatibility, |
| 1060 |
AP4_UI08 nalu_length_size, |
| 1061 |
AP4_UI08 chroma_format, |
| 1062 |
AP4_UI08 bit_depth_luma_minus8, |
| 1063 |
AP4_UI08 bit_depth_chroma_minus8, |
| 1064 |
AP4_DataBuffer** sequence_parameters, |
| 1065 |
AP4_Size sequence_parameter_count, |
| 1066 |
AP4_DataBuffer** picture_parameters, |
| 1067 |
AP4_Size picture_parameter_count) |
| 1068 |
{ |
| 1069 |
AP4_Array<AP4_DataBuffer> sequence_params; |
| 1070 |
AP4_Array<AP4_DataBuffer> picture_params; |
| 1071 |
AP4_Ordinal i; |
| 1072 |
|
| 1073 |
for (i=0; i<sequence_parameter_count; i++) { |
| 1074 |
sequence_params.Append(*sequence_parameters[i]); |
| 1075 |
} |
| 1076 |
for (i=0; i<picture_parameter_count; i++) { |
| 1077 |
picture_params.Append(*picture_parameters[i]); |
| 1078 |
} |
| 1079 |
|
| 1080 |
return new AP4_AvcSampleDescription(format, |
| 1081 |
width, |
| 1082 |
height, |
| 1083 |
depth, |
| 1084 |
compressor_name, |
| 1085 |
profile, |
| 1086 |
level, |
| 1087 |
profile_compatibility, |
| 1088 |
nalu_length_size, |
| 1089 |
chroma_format, |
| 1090 |
bit_depth_luma_minus8, |
| 1091 |
bit_depth_chroma_minus8, |
| 1092 |
sequence_params, |
| 1093 |
picture_params); |
| 1094 |
} |
| 1095 |
|
| 1096 |
/*---------------------------------------------------------------------- |
| 1097 |
| AP4_Sample implementation |
| 1098 |
+---------------------------------------------------------------------*/ |
| 1099 |
AP4_Result |
| 1100 |
AP4_Sample_ReadData(AP4_Sample* self, AP4_DataBuffer* data) |
| 1101 |
{ |
| 1102 |
return self->ReadData(*data); |
| 1103 |
} |
| 1104 |
|
| 1105 |
AP4_Result |
| 1106 |
AP4_Sample_ReadPartialData(AP4_Sample* self, |
| 1107 |
AP4_DataBuffer* data, |
| 1108 |
AP4_Size size, |
| 1109 |
AP4_Size offset) |
| 1110 |
{ |
| 1111 |
return self->ReadData(*data, size, offset); |
| 1112 |
} |
| 1113 |
|
| 1114 |
AP4_ByteStream* |
| 1115 |
AP4_Sample_GetDataStream(AP4_Sample* self) |
| 1116 |
{ |
| 1117 |
return self->GetDataStream(); |
| 1118 |
} |
| 1119 |
|
| 1120 |
void |
| 1121 |
AP4_Sample_SetDataStream(AP4_Sample* self, AP4_ByteStream* stream) |
| 1122 |
{ |
| 1123 |
self->SetDataStream(*stream); |
| 1124 |
} |
| 1125 |
|
| 1126 |
AP4_Position |
| 1127 |
AP4_Sample_GetOffset(AP4_Sample* self) |
| 1128 |
{ |
| 1129 |
return self->GetOffset(); |
| 1130 |
} |
| 1131 |
|
| 1132 |
void |
| 1133 |
AP4_Sample_SetOffset(AP4_Sample* self, AP4_Position offset) |
| 1134 |
{ |
| 1135 |
self->SetOffset(offset); |
| 1136 |
} |
| 1137 |
|
| 1138 |
AP4_Size |
| 1139 |
AP4_Sample_GetSize(AP4_Sample* self) |
| 1140 |
{ |
| 1141 |
return self->GetSize(); |
| 1142 |
} |
| 1143 |
|
| 1144 |
void |
| 1145 |
AP4_Sample_SetSize(AP4_Sample* self, AP4_Size size) |
| 1146 |
{ |
| 1147 |
self->SetSize(size); |
| 1148 |
} |
| 1149 |
|
| 1150 |
AP4_Ordinal |
| 1151 |
AP4_Sample_GetDescriptionIndex(AP4_Sample* self) |
| 1152 |
{ |
| 1153 |
return self->GetDescriptionIndex(); |
| 1154 |
} |
| 1155 |
|
| 1156 |
void |
| 1157 |
AP4_Sample_SetDescriptionIndex(AP4_Sample* self, AP4_Ordinal index) |
| 1158 |
{ |
| 1159 |
self->SetDescriptionIndex(index); |
| 1160 |
} |
| 1161 |
|
| 1162 |
AP4_UI64 |
| 1163 |
AP4_Sample_GetDts(AP4_Sample* self) |
| 1164 |
{ |
| 1165 |
return self->GetDts(); |
| 1166 |
} |
| 1167 |
|
| 1168 |
void |
| 1169 |
AP4_SampleSetDts(AP4_Sample* self, AP4_UI64 dts) |
| 1170 |
{ |
| 1171 |
self->SetDts(dts); |
| 1172 |
} |
| 1173 |
|
| 1174 |
AP4_UI64 |
| 1175 |
AP4_Sample_GetCts(AP4_Sample* self) |
| 1176 |
{ |
| 1177 |
return self->GetCts(); |
| 1178 |
} |
| 1179 |
|
| 1180 |
void |
| 1181 |
AP4_Sample_SetCts(AP4_Sample* self, AP4_UI64 cts) |
| 1182 |
{ |
| 1183 |
self->SetCts(cts); |
| 1184 |
} |
| 1185 |
|
| 1186 |
AP4_UI32 |
| 1187 |
AP4_Sample_GetDuration(AP4_Sample* self) |
| 1188 |
{ |
| 1189 |
return self->GetDuration(); |
| 1190 |
} |
| 1191 |
|
| 1192 |
void |
| 1193 |
AP4_Sample_SetDuration(AP4_Sample* self, AP4_UI32 duration) |
| 1194 |
{ |
| 1195 |
self->SetDuration(duration); |
| 1196 |
} |
| 1197 |
|
| 1198 |
int |
| 1199 |
AP4_Sample_IsSync(AP4_Sample* self) |
| 1200 |
{ |
| 1201 |
return self->IsSync(); |
| 1202 |
} |
| 1203 |
|
| 1204 |
void |
| 1205 |
AP4_Sample_SetSync(AP4_Sample* self, int is_sync) |
| 1206 |
{ |
| 1207 |
self->SetSync(is_sync?true:false); |
| 1208 |
} |
| 1209 |
|
| 1210 |
void |
| 1211 |
AP4_Sample_Destroy(AP4_Sample* self) |
| 1212 |
{ |
| 1213 |
delete self; |
| 1214 |
} |
| 1215 |
|
| 1216 |
AP4_Sample* |
| 1217 |
AP4_Sample_CreateEmpty(void) |
| 1218 |
{ |
| 1219 |
return new AP4_Sample(); |
| 1220 |
} |
| 1221 |
|
| 1222 |
AP4_Sample* |
| 1223 |
AP4_Sample_Create(AP4_ByteStream* data_stream, |
| 1224 |
AP4_Position offset, |
| 1225 |
AP4_Size size, |
| 1226 |
AP4_UI32 duration, |
| 1227 |
AP4_Ordinal description_index, |
| 1228 |
AP4_UI32 dts, |
| 1229 |
AP4_UI32 cts_delta, |
| 1230 |
int is_sync) |
| 1231 |
{ |
| 1232 |
return new AP4_Sample(*data_stream, |
| 1233 |
offset, |
| 1234 |
size, |
| 1235 |
duration, |
| 1236 |
description_index, |
| 1237 |
dts, |
| 1238 |
cts_delta, |
| 1239 |
is_sync?true:false); |
| 1240 |
} |
| 1241 |
|
| 1242 |
AP4_Sample* |
| 1243 |
AP4_Sample_Clone(const AP4_Sample* other) |
| 1244 |
{ |
| 1245 |
return new AP4_Sample(*other); |
| 1246 |
} |
| 1247 |
|
| 1248 |
/*---------------------------------------------------------------------- |
| 1249 |
| AP4_SyntheticSampleTable implementation |
| 1250 |
+---------------------------------------------------------------------*/ |
| 1251 |
AP4_Result |
| 1252 |
AP4_SyntheticSampleTable_AddSampleDescription(AP4_SyntheticSampleTable* self, |
| 1253 |
AP4_SampleDescription* desc) |
| 1254 |
{ |
| 1255 |
return self->AddSampleDescription(desc); |
| 1256 |
} |
| 1257 |
|
| 1258 |
AP4_Result |
| 1259 |
AP4_SyntheticSampleTable_AddSample(AP4_SyntheticSampleTable* self, |
| 1260 |
AP4_ByteStream* data_stream, |
| 1261 |
AP4_Position offset, |
| 1262 |
AP4_Size size, |
| 1263 |
AP4_UI32 duration, |
| 1264 |
AP4_Ordinal desc_index, |
| 1265 |
AP4_UI32 dts, |
| 1266 |
AP4_UI32 cts_delta, |
| 1267 |
int is_sync) |
| 1268 |
{ |
| 1269 |
return self->AddSample(*data_stream, |
| 1270 |
offset, |
| 1271 |
size, |
| 1272 |
duration, |
| 1273 |
desc_index, |
| 1274 |
dts, |
| 1275 |
cts_delta, |
| 1276 |
is_sync?true:false); |
| 1277 |
} |
| 1278 |
|
| 1279 |
void |
| 1280 |
AP4_SyntheticSampleTable_Destroy(AP4_SyntheticSampleTable* self) |
| 1281 |
{ |
| 1282 |
delete self; |
| 1283 |
} |
| 1284 |
|
| 1285 |
AP4_SyntheticSampleTable* |
| 1286 |
AP4_SyntheticSampleTable_Create(AP4_Cardinal chunk_size) |
| 1287 |
{ |
| 1288 |
return new AP4_SyntheticSampleTable(chunk_size); |
| 1289 |
} |
| 1290 |
|
| 1291 |
/*---------------------------------------------------------------------- |
| 1292 |
| AP4_DelegatorAtomInspector |
| 1293 |
+---------------------------------------------------------------------*/ |
| 1294 |
class AP4_DelegatorAtomInspector : public AP4_AtomInspector |
| 1295 |
{ |
| 1296 |
public: |
| 1297 |
AP4_DelegatorAtomInspector(AP4_AtomInspectorDelegate* delegate) : |
| 1298 |
m_Delegate(delegate) {} |
| 1299 |
~AP4_DelegatorAtomInspector(); |
| 1300 |
void StartElement(const char* name, const char* extra); |
| 1301 |
void EndElement(); |
| 1302 |
void AddField(const char* name, AP4_UI64 value, FormatHint hint); |
| 1303 |
void AddFieldF(const char* name, float value, FormatHint hint); |
| 1304 |
void AddField(const char* name, const char* value, FormatHint hint); |
| 1305 |
void AddField(const char* name, |
| 1306 |
const unsigned char* bytes, |
| 1307 |
AP4_Size byte_count, |
| 1308 |
FormatHint hint); |
| 1309 |
private: |
| 1310 |
AP4_AtomInspectorDelegate* m_Delegate; |
| 1311 |
}; |
| 1312 |
|
| 1313 |
AP4_DelegatorAtomInspector::~AP4_DelegatorAtomInspector() |
| 1314 |
{ |
| 1315 |
if (m_Delegate->Destroy) { |
| 1316 |
m_Delegate->Destroy(m_Delegate); |
| 1317 |
} |
| 1318 |
} |
| 1319 |
|
| 1320 |
void |
| 1321 |
AP4_DelegatorAtomInspector::StartElement(const char* name, const char* extra) |
| 1322 |
{ |
| 1323 |
m_Delegate->StartElement(m_Delegate, name, extra); |
| 1324 |
} |
| 1325 |
|
| 1326 |
void |
| 1327 |
AP4_DelegatorAtomInspector::EndElement() |
| 1328 |
{ |
| 1329 |
m_Delegate->EndElement(m_Delegate); |
| 1330 |
} |
| 1331 |
|
| 1332 |
void |
| 1333 |
AP4_DelegatorAtomInspector::AddField(const char* name, |
| 1334 |
AP4_UI64 value, |
| 1335 |
FormatHint hint) |
| 1336 |
{ |
| 1337 |
m_Delegate->AddIntField(m_Delegate, name, value, hint); |
| 1338 |
} |
| 1339 |
|
| 1340 |
void |
| 1341 |
AP4_DelegatorAtomInspector::AddFieldF(const char* name, |
| 1342 |
float value, |
| 1343 |
FormatHint hint) |
| 1344 |
{ |
| 1345 |
m_Delegate->AddFloatField(m_Delegate, name, value, hint); |
| 1346 |
} |
| 1347 |
|
| 1348 |
void |
| 1349 |
AP4_DelegatorAtomInspector::AddField(const char* name, |
| 1350 |
const char* value, |
| 1351 |
FormatHint hint) |
| 1352 |
{ |
| 1353 |
m_Delegate->AddStringField(m_Delegate, name, value, hint); |
| 1354 |
} |
| 1355 |
|
| 1356 |
void |
| 1357 |
AP4_DelegatorAtomInspector::AddField(const char* name, |
| 1358 |
const AP4_Byte* bytes, |
| 1359 |
AP4_Size byte_count, |
| 1360 |
FormatHint hint) |
| 1361 |
{ |
| 1362 |
m_Delegate->AddBytesField(m_Delegate, name, bytes, byte_count, hint); |
| 1363 |
} |
| 1364 |
|
| 1365 |
/*---------------------------------------------------------------------- |
| 1366 |
| AP4_AtomInspector implementation |
| 1367 |
+---------------------------------------------------------------------*/ |
| 1368 |
void |
| 1369 |
AP4_AtomInspector_Destroy(AP4_AtomInspector* self) |
| 1370 |
{ |
| 1371 |
delete self; |
| 1372 |
} |
| 1373 |
|
| 1374 |
AP4_AtomInspector* |
| 1375 |
AP4_PrintInspector_Create(AP4_ByteStream* stream) |
| 1376 |
{ |
| 1377 |
return new AP4_PrintInspector(*stream); |
| 1378 |
} |
| 1379 |
|
| 1380 |
AP4_AtomInspector* |
| 1381 |
AP4_AtomInspector_FromDelegate(AP4_AtomInspectorDelegate* delegate) |
| 1382 |
{ |
| 1383 |
return new AP4_DelegatorAtomInspector(delegate); |
| 1384 |
} |
| 1385 |
|
| 1386 |
|
| 1387 |
|