OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/mp4/box_definitions.h" | 5 #include "media/mp4/box_definitions.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/mp4/box_reader.h" | 8 #include "media/mp4/es_descriptor.h" |
9 #include "media/mp4/fourccs.h" | |
10 #include "media/mp4/rcheck.h" | 9 #include "media/mp4/rcheck.h" |
11 | 10 |
12 namespace media { | 11 namespace media { |
13 namespace mp4 { | 12 namespace mp4 { |
14 | 13 |
15 bool FileType::Parse(BoxReader* reader) { | 14 bool FileType::Parse(BoxReader* reader) { |
16 RCHECK(reader->ReadFourCC(&major_brand) && reader->Read4(&minor_version)); | 15 RCHECK(reader->ReadFourCC(&major_brand) && reader->Read4(&minor_version)); |
17 size_t num_brands = (reader->size() - reader->pos()) / sizeof(FourCC); | 16 size_t num_brands = (reader->size() - reader->pos()) / sizeof(FourCC); |
18 return reader->SkipBytes(sizeof(FourCC) * num_brands); // compatible_brands | 17 return reader->SkipBytes(sizeof(FourCC) * num_brands); // compatible_brands |
19 } | 18 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // (http://crbug.com/132351) | 381 // (http://crbug.com/132351) |
383 // | 382 // |
384 // if (format == FOURCC_AVC1 || | 383 // if (format == FOURCC_AVC1 || |
385 // (format == FOURCC_ENCV && | 384 // (format == FOURCC_ENCV && |
386 // sinf.format.format == FOURCC_AVC1)) { | 385 // sinf.format.format == FOURCC_AVC1)) { |
387 RCHECK(reader->ReadChild(&avcc)); | 386 RCHECK(reader->ReadChild(&avcc)); |
388 // } | 387 // } |
389 return true; | 388 return true; |
390 } | 389 } |
391 | 390 |
| 391 ElementaryStreamDescriptor::ElementaryStreamDescriptor() {} |
| 392 |
| 393 ElementaryStreamDescriptor::~ElementaryStreamDescriptor() {} |
| 394 |
| 395 FourCC ElementaryStreamDescriptor::BoxType() const { |
| 396 return FOURCC_ESDS; |
| 397 } |
| 398 |
| 399 bool ElementaryStreamDescriptor::Parse(BoxReader* reader) { |
| 400 std::vector<uint8> data; |
| 401 ESDescriptor es_desc; |
| 402 |
| 403 RCHECK(reader->ReadFullBoxHeader()); |
| 404 RCHECK(reader->ReadVec(&data, reader->size() - reader->pos())); |
| 405 RCHECK(es_desc.Parse(data)); |
| 406 |
| 407 object_type = es_desc.object_type(); |
| 408 |
| 409 RCHECK(aac.Parse(es_desc.decoder_specific_info())); |
| 410 |
| 411 return true; |
| 412 } |
| 413 |
392 AudioSampleEntry::AudioSampleEntry() | 414 AudioSampleEntry::AudioSampleEntry() |
393 : format(FOURCC_NULL), | 415 : format(FOURCC_NULL), |
394 data_reference_index(0), | 416 data_reference_index(0), |
395 channelcount(0), | 417 channelcount(0), |
396 samplesize(0), | 418 samplesize(0), |
397 samplerate(0) {} | 419 samplerate(0) {} |
398 | 420 |
399 AudioSampleEntry::~AudioSampleEntry() {} | 421 AudioSampleEntry::~AudioSampleEntry() {} |
| 422 |
400 FourCC AudioSampleEntry::BoxType() const { | 423 FourCC AudioSampleEntry::BoxType() const { |
401 DCHECK(false) << "AudioSampleEntry should be parsed according to the " | 424 DCHECK(false) << "AudioSampleEntry should be parsed according to the " |
402 << "handler type recovered in its Media ancestor."; | 425 << "handler type recovered in its Media ancestor."; |
403 return FOURCC_NULL; | 426 return FOURCC_NULL; |
404 } | 427 } |
405 | 428 |
406 bool AudioSampleEntry::Parse(BoxReader* reader) { | 429 bool AudioSampleEntry::Parse(BoxReader* reader) { |
407 format = reader->type(); | 430 format = reader->type(); |
408 RCHECK(reader->SkipBytes(6) && | 431 RCHECK(reader->SkipBytes(6) && |
409 reader->Read2(&data_reference_index) && | 432 reader->Read2(&data_reference_index) && |
410 reader->SkipBytes(8) && | 433 reader->SkipBytes(8) && |
411 reader->Read2(&channelcount) && | 434 reader->Read2(&channelcount) && |
412 reader->Read2(&samplesize) && | 435 reader->Read2(&samplesize) && |
413 reader->SkipBytes(4) && | 436 reader->SkipBytes(4) && |
414 reader->Read4(&samplerate)); | 437 reader->Read4(&samplerate)); |
415 // Convert from 16.16 fixed point to integer | 438 // Convert from 16.16 fixed point to integer |
416 samplerate >>= 16; | 439 samplerate >>= 16; |
417 | 440 |
418 RCHECK(reader->ScanChildren()); | 441 RCHECK(reader->ScanChildren()); |
419 if (format == FOURCC_ENCA) { | 442 if (format == FOURCC_ENCA) { |
420 RCHECK(reader->ReadChild(&sinf)); | 443 RCHECK(reader->ReadChild(&sinf)); |
421 } | 444 } |
| 445 RCHECK(reader->ReadChild(&esds)); |
422 return true; | 446 return true; |
423 } | 447 } |
424 | 448 |
425 MediaHeader::MediaHeader() | 449 MediaHeader::MediaHeader() |
426 : creation_time(0), | 450 : creation_time(0), |
427 modification_time(0), | 451 modification_time(0), |
428 timescale(0), | 452 timescale(0), |
429 duration(0) {} | 453 duration(0) {} |
430 MediaHeader::~MediaHeader() {} | 454 MediaHeader::~MediaHeader() {} |
431 FourCC MediaHeader::BoxType() const { return FOURCC_MDHD; } | 455 FourCC MediaHeader::BoxType() const { return FOURCC_MDHD; } |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 bool MovieFragment::Parse(BoxReader* reader) { | 718 bool MovieFragment::Parse(BoxReader* reader) { |
695 RCHECK(reader->ScanChildren() && | 719 RCHECK(reader->ScanChildren() && |
696 reader->ReadChild(&header) && | 720 reader->ReadChild(&header) && |
697 reader->ReadChildren(&tracks) && | 721 reader->ReadChildren(&tracks) && |
698 reader->MaybeReadChildren(&pssh)); | 722 reader->MaybeReadChildren(&pssh)); |
699 return true; | 723 return true; |
700 } | 724 } |
701 | 725 |
702 } // namespace mp4 | 726 } // namespace mp4 |
703 } // namespace media | 727 } // namespace media |
OLD | NEW |