Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: media/formats/mp4/box_definitions.cc

Issue 1235793005: Deprecate LogCB in favor of using MediaLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and attempt to fix Android compilation Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/formats/mp4/box_definitions.h ('k') | media/formats/mp4/box_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/formats/mp4/box_definitions.h" 5 #include "media/formats/mp4/box_definitions.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/formats/mp4/es_descriptor.h" 8 #include "media/formats/mp4/es_descriptor.h"
9 #include "media/formats/mp4/rcheck.h" 9 #include "media/formats/mp4/rcheck.h"
10 10
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 : version(0), 402 : version(0),
403 profile_indication(0), 403 profile_indication(0),
404 profile_compatibility(0), 404 profile_compatibility(0),
405 avc_level(0), 405 avc_level(0),
406 length_size(0) {} 406 length_size(0) {}
407 407
408 AVCDecoderConfigurationRecord::~AVCDecoderConfigurationRecord() {} 408 AVCDecoderConfigurationRecord::~AVCDecoderConfigurationRecord() {}
409 FourCC AVCDecoderConfigurationRecord::BoxType() const { return FOURCC_AVCC; } 409 FourCC AVCDecoderConfigurationRecord::BoxType() const { return FOURCC_AVCC; }
410 410
411 bool AVCDecoderConfigurationRecord::Parse(BoxReader* reader) { 411 bool AVCDecoderConfigurationRecord::Parse(BoxReader* reader) {
412 return ParseInternal(reader, reader->log_cb()); 412 return ParseInternal(reader, reader->media_log());
413 } 413 }
414 414
415 bool AVCDecoderConfigurationRecord::Parse(const uint8* data, int data_size) { 415 bool AVCDecoderConfigurationRecord::Parse(const uint8* data, int data_size) {
416 BufferReader reader(data, data_size); 416 BufferReader reader(data, data_size);
417 return ParseInternal(&reader, LogCB()); 417 return ParseInternal(&reader, new MediaLog());
418 } 418 }
419 419
420 bool AVCDecoderConfigurationRecord::ParseInternal(BufferReader* reader, 420 bool AVCDecoderConfigurationRecord::ParseInternal(
421 const LogCB& log_cb) { 421 BufferReader* reader,
422 const scoped_refptr<MediaLog>& media_log) {
422 RCHECK(reader->Read1(&version) && version == 1 && 423 RCHECK(reader->Read1(&version) && version == 1 &&
423 reader->Read1(&profile_indication) && 424 reader->Read1(&profile_indication) &&
424 reader->Read1(&profile_compatibility) && 425 reader->Read1(&profile_compatibility) &&
425 reader->Read1(&avc_level)); 426 reader->Read1(&avc_level));
426 427
427 uint8 length_size_minus_one; 428 uint8 length_size_minus_one;
428 RCHECK(reader->Read1(&length_size_minus_one)); 429 RCHECK(reader->Read1(&length_size_minus_one));
429 length_size = (length_size_minus_one & 0x3) + 1; 430 length_size = (length_size_minus_one & 0x3) + 1;
430 431
431 RCHECK(length_size != 3); // Only values of 1, 2, and 4 are valid. 432 RCHECK(length_size != 3); // Only values of 1, 2, and 4 are valid.
432 433
433 uint8 num_sps; 434 uint8 num_sps;
434 RCHECK(reader->Read1(&num_sps)); 435 RCHECK(reader->Read1(&num_sps));
435 num_sps &= 0x1f; 436 num_sps &= 0x1f;
436 437
437 sps_list.resize(num_sps); 438 sps_list.resize(num_sps);
438 for (int i = 0; i < num_sps; i++) { 439 for (int i = 0; i < num_sps; i++) {
439 uint16 sps_length; 440 uint16 sps_length;
440 RCHECK(reader->Read2(&sps_length) && 441 RCHECK(reader->Read2(&sps_length) &&
441 reader->ReadVec(&sps_list[i], sps_length)); 442 reader->ReadVec(&sps_list[i], sps_length));
442 RCHECK(sps_list[i].size() > 4); 443 RCHECK(sps_list[i].size() > 4);
443 444
444 if (!log_cb.is_null()) { 445 if (media_log.get()) {
445 MEDIA_LOG(INFO, log_cb) << "Video codec: avc1." << std::hex 446 MEDIA_LOG(INFO, media_log) << "Video codec: avc1." << std::hex
446 << static_cast<int>(sps_list[i][1]) 447 << static_cast<int>(sps_list[i][1])
447 << static_cast<int>(sps_list[i][2]) 448 << static_cast<int>(sps_list[i][2])
448 << static_cast<int>(sps_list[i][3]); 449 << static_cast<int>(sps_list[i][3]);
449 } 450 }
450 } 451 }
451 452
452 uint8 num_pps; 453 uint8 num_pps;
453 RCHECK(reader->Read1(&num_pps)); 454 RCHECK(reader->Read1(&num_pps));
454 455
455 pps_list.resize(num_pps); 456 pps_list.resize(num_pps);
456 for (int i = 0; i < num_pps; i++) { 457 for (int i = 0; i < num_pps; i++) {
457 uint16 pps_length; 458 uint16 pps_length;
458 RCHECK(reader->Read2(&pps_length) && 459 RCHECK(reader->Read2(&pps_length) &&
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 std::vector<uint8> data; 532 std::vector<uint8> data;
532 ESDescriptor es_desc; 533 ESDescriptor es_desc;
533 534
534 RCHECK(reader->ReadFullBoxHeader()); 535 RCHECK(reader->ReadFullBoxHeader());
535 RCHECK(reader->ReadVec(&data, reader->size() - reader->pos())); 536 RCHECK(reader->ReadVec(&data, reader->size() - reader->pos()));
536 RCHECK(es_desc.Parse(data)); 537 RCHECK(es_desc.Parse(data));
537 538
538 object_type = es_desc.object_type(); 539 object_type = es_desc.object_type();
539 540
540 if (object_type != 0x40) { 541 if (object_type != 0x40) {
541 MEDIA_LOG(INFO, reader->log_cb()) << "Audio codec: mp4a." << std::hex 542 MEDIA_LOG(INFO, reader->media_log()) << "Audio codec: mp4a." << std::hex
542 << static_cast<int>(object_type); 543 << static_cast<int>(object_type);
543 } 544 }
544 545
545 if (es_desc.IsAAC(object_type)) 546 if (es_desc.IsAAC(object_type))
546 RCHECK(aac.Parse(es_desc.decoder_specific_info(), reader->log_cb())); 547 RCHECK(aac.Parse(es_desc.decoder_specific_info(), reader->media_log()));
547 548
548 return true; 549 return true;
549 } 550 }
550 551
551 AudioSampleEntry::AudioSampleEntry() 552 AudioSampleEntry::AudioSampleEntry()
552 : format(FOURCC_NULL), 553 : format(FOURCC_NULL),
553 data_reference_index(0), 554 data_reference_index(0),
554 channelcount(0), 555 channelcount(0),
555 samplesize(0), 556 samplesize(0),
556 samplerate(0) {} 557 samplerate(0) {}
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 } 703 }
703 704
704 Movie::Movie() : fragmented(false) {} 705 Movie::Movie() : fragmented(false) {}
705 Movie::~Movie() {} 706 Movie::~Movie() {}
706 FourCC Movie::BoxType() const { return FOURCC_MOOV; } 707 FourCC Movie::BoxType() const { return FOURCC_MOOV; }
707 708
708 bool Movie::Parse(BoxReader* reader) { 709 bool Movie::Parse(BoxReader* reader) {
709 RCHECK(reader->ScanChildren() && reader->ReadChild(&header) && 710 RCHECK(reader->ScanChildren() && reader->ReadChild(&header) &&
710 reader->ReadChildren(&tracks)); 711 reader->ReadChildren(&tracks));
711 712
712 RCHECK_MEDIA_LOGGED(reader->ReadChild(&extends), reader->log_cb(), 713 RCHECK_MEDIA_LOGGED(reader->ReadChild(&extends), reader->media_log(),
713 "Detected unfragmented MP4. Media Source Extensions " 714 "Detected unfragmented MP4. Media Source Extensions "
714 "require ISO BMFF moov to contain mvex to indicate that " 715 "require ISO BMFF moov to contain mvex to indicate that "
715 "Movie Fragments are to be expected."); 716 "Movie Fragments are to be expected.");
716 717
717 return reader->MaybeReadChildren(&pssh); 718 return reader->MaybeReadChildren(&pssh);
718 } 719 }
719 720
720 TrackFragmentDecodeTime::TrackFragmentDecodeTime() : decode_time(0) {} 721 TrackFragmentDecodeTime::TrackFragmentDecodeTime() : decode_time(0) {}
721 TrackFragmentDecodeTime::~TrackFragmentDecodeTime() {} 722 TrackFragmentDecodeTime::~TrackFragmentDecodeTime() {}
722 FourCC TrackFragmentDecodeTime::BoxType() const { return FOURCC_TFDT; } 723 FourCC TrackFragmentDecodeTime::BoxType() const { return FOURCC_TFDT; }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( 1000 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on(
1000 size_t i) const { 1001 size_t i) const {
1001 if (i >= sample_depends_on_.size()) 1002 if (i >= sample_depends_on_.size())
1002 return kSampleDependsOnUnknown; 1003 return kSampleDependsOnUnknown;
1003 1004
1004 return sample_depends_on_[i]; 1005 return sample_depends_on_[i];
1005 } 1006 }
1006 1007
1007 } // namespace mp4 1008 } // namespace mp4
1008 } // namespace media 1009 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp4/box_definitions.h ('k') | media/formats/mp4/box_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698