From 8095e21c96d673c27c7c6a6d37f8d5a9f57a9051 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Wed, 15 Jan 2014 16:52:07 -0800 Subject: [PATCH] Clean up clang compilation errors. Clang from Chromium enforces Chromium styles: http://www.chromium.org/developers/coding-style, http://www.chromium.org/developers/coding-style/chromium-style-checker-errors. Change-Id: I8070739489a8109380578d1797801e981d119793 --- media/base/audio_stream_info.cc | 5 ++++- media/base/audio_stream_info.h | 4 ++-- media/base/muxer_options.cc | 18 ++++++++++++++++++ media/base/muxer_options.h | 3 +++ media/base/rsa_test_data.cc | 3 +++ media/base/rsa_test_data.h | 3 +++ media/base/stream_info.h | 5 ++++- media/base/video_stream_info.h | 4 ++-- media/mp4/box_definitions.cc | 19 ++++++++++--------- media/mp4/box_definitions_unittest.cc | 20 ++++++++++---------- media/mp4/box_reader_unittest.cc | 6 +++--- media/mp4/mp4_general_segmenter.h | 2 +- media/mp4/mp4_vod_segmenter.h | 2 +- packager.gyp | 2 ++ 14 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 media/base/muxer_options.cc diff --git a/media/base/audio_stream_info.cc b/media/base/audio_stream_info.cc index 1c7fdaf99f..a0e0e41119 100644 --- a/media/base/audio_stream_info.cc +++ b/media/base/audio_stream_info.cc @@ -6,6 +6,7 @@ #include +#include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "media/base/limits.h" @@ -66,8 +67,10 @@ std::string AudioStreamInfo::GetCodecString(AudioCodec codec, return "opus"; case kCodecAAC: return "mp4a.40." + base::UintToString(audio_object_type); + default: + NOTIMPLEMENTED() << "Codec: " << codec; + return "unknown"; } - return "unknown"; } } // namespace media diff --git a/media/base/audio_stream_info.h b/media/base/audio_stream_info.h index 9fb6a0ff6a..e04cd20139 100644 --- a/media/base/audio_stream_info.h +++ b/media/base/audio_stream_info.h @@ -47,8 +47,6 @@ class AudioStreamInfo : public StreamInfo { size_t extra_data_size, bool is_encrypted); - virtual ~AudioStreamInfo(); - // Returns true if this object has appropriate configuration values, false // otherwise. virtual bool IsValidConfig() const OVERRIDE; @@ -69,6 +67,8 @@ class AudioStreamInfo : public StreamInfo { static std::string GetCodecString(AudioCodec codec, uint8 audio_object_type); private: + virtual ~AudioStreamInfo(); + AudioCodec codec_; uint8 sample_bits_; uint8 num_channels_; diff --git a/media/base/muxer_options.cc b/media/base/muxer_options.cc new file mode 100644 index 0000000000..3882805d10 --- /dev/null +++ b/media/base/muxer_options.cc @@ -0,0 +1,18 @@ +// Copyright (c) 2013 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/base/muxer_options.h" + +namespace media { + +MuxerOptions::MuxerOptions() + : single_segment(false), + segment_duration(0), + fragment_duration(0), + segment_sap_aligned(false), + fragment_sap_aligned(false), + num_subsegments_per_sidx(0) {} +MuxerOptions::~MuxerOptions() {} + +} // namespace media diff --git a/media/base/muxer_options.h b/media/base/muxer_options.h index f215fb8d62..8a2e58a6fa 100644 --- a/media/base/muxer_options.h +++ b/media/base/muxer_options.h @@ -10,6 +10,9 @@ namespace media { struct MuxerOptions { + MuxerOptions(); + ~MuxerOptions(); + // Generate a single segment for each media presentation. This option // should be set for on demand profile. bool single_segment; diff --git a/media/base/rsa_test_data.cc b/media/base/rsa_test_data.cc index ea0caea621..7255b2c00f 100644 --- a/media/base/rsa_test_data.cc +++ b/media/base/rsa_test_data.cc @@ -443,6 +443,9 @@ const uint8 kTestSignature_2048[] = { namespace media { +RsaTestSet::RsaTestSet() {} +RsaTestSet::~RsaTestSet() {} + RsaTestData::RsaTestData() { test_set_3072_bits_.test_message = kTestMessage; test_set_3072_bits_.public_key.assign( diff --git a/media/base/rsa_test_data.h b/media/base/rsa_test_data.h index 0e7d1b2734..17e278010e 100644 --- a/media/base/rsa_test_data.h +++ b/media/base/rsa_test_data.h @@ -15,6 +15,9 @@ namespace media { // Self generated test vector to verify algorithm stability. struct RsaTestSet { + RsaTestSet(); + ~RsaTestSet(); + std::string public_key; std::string private_key; std::string test_message; diff --git a/media/base/stream_info.h b/media/base/stream_info.h index 109a8c0eb4..21cac2700d 100644 --- a/media/base/stream_info.h +++ b/media/base/stream_info.h @@ -28,7 +28,6 @@ class StreamInfo : public base::RefCountedThreadSafe { const uint8* extra_data, size_t extra_data_size, bool is_encrypted); - virtual ~StreamInfo(); // Returns true if this object has appropriate configuration values, false // otherwise. @@ -50,6 +49,10 @@ class StreamInfo : public base::RefCountedThreadSafe { void set_duration(int duration) { duration_ = duration; } + protected: + friend class base::RefCountedThreadSafe; + virtual ~StreamInfo(); + private: // Whether the stream is Audio or Video. StreamType stream_type_; diff --git a/media/base/video_stream_info.h b/media/base/video_stream_info.h index c4c19aeee8..3cf63c202e 100644 --- a/media/base/video_stream_info.h +++ b/media/base/video_stream_info.h @@ -38,8 +38,6 @@ class VideoStreamInfo : public StreamInfo { size_t extra_data_size, bool is_encrypted); - virtual ~VideoStreamInfo(); - // Returns true if this object has appropriate configuration values, false // otherwise. virtual bool IsValidConfig() const OVERRIDE; @@ -60,6 +58,8 @@ class VideoStreamInfo : public StreamInfo { uint8 level); private: + virtual ~VideoStreamInfo(); + VideoCodec codec_; uint16 width_; uint16 height_; diff --git a/media/mp4/box_definitions.cc b/media/mp4/box_definitions.cc index d4644bc17a..eff2b1f3c6 100644 --- a/media/mp4/box_definitions.cc +++ b/media/mp4/box_definitions.cc @@ -538,19 +538,20 @@ bool CompactSampleSize::ReadWrite(BoxBuffer* buffer) { buffer->ReadWriteUInt32(&sample_count)); // Reserve one more entry if field size is 4 bits. - sizes.resize(sample_count + (field_size == 4 ? 1 : 0)); + sizes.resize(sample_count + (field_size == 4 ? 1 : 0), 0); switch (field_size) { case 4: - for (uint32 i = 0; i < sample_count; ++i) { - uint8 size; - if (!buffer->Reading()) { - DCHECK(sizes[i] < 16 && sizes[i+1] < 16); - size = (sizes[i] << 4) | (++i < sample_count ? sizes[i] : 0); - } - RCHECK(buffer->ReadWriteUInt8(&size)); + for (uint32 i = 0; i < sample_count; i += 2) { if (buffer->Reading()) { + uint8 size = 0; + RCHECK(buffer->ReadWriteUInt8(&size)); sizes[i] = size >> 4; - sizes[++i] = size & 0x0F; + sizes[i + 1] = size & 0x0F; + } else { + DCHECK_LT(sizes[i], 16); + DCHECK_LT(sizes[i + 1], 16); + uint8 size = (sizes[i] << 4) | sizes[i + 1]; + RCHECK(buffer->ReadWriteUInt8(&size)); } } break; diff --git a/media/mp4/box_definitions_unittest.cc b/media/mp4/box_definitions_unittest.cc index 392e00264b..2b6091dc3e 100644 --- a/media/mp4/box_definitions_unittest.cc +++ b/media/mp4/box_definitions_unittest.cc @@ -752,39 +752,39 @@ TYPED_TEST_CASE(BoxDefinitionsTestGeneral, Boxes); TYPED_TEST(BoxDefinitionsTestGeneral, WriteReadbackCompare) { TypeParam box; LOG(INFO) << "Processing " << FourCCToString(box.BoxType()); - Fill(&box); + this->Fill(&box); box.Write(this->buffer_.get()); TypeParam box_readback; - ASSERT_TRUE(ReadBack(&box_readback)); + ASSERT_TRUE(this->ReadBack(&box_readback)); ASSERT_EQ(box, box_readback); } TYPED_TEST(BoxDefinitionsTestGeneral, WriteModifyWrite) { TypeParam box; LOG(INFO) << "Processing " << FourCCToString(box.BoxType()); - Fill(&box); + this->Fill(&box); // Save the expected version set earlier in function |Fill|, then clear // the version, expecting box.Write set version as expected. - uint8 version = GetAndClearVersion(&box); + uint8 version = this->GetAndClearVersion(&box); box.Write(this->buffer_.get()); - EXPECT_EQ(version, GetAndClearVersion(&box)); + EXPECT_EQ(version, this->GetAndClearVersion(&box)); this->buffer_->Clear(); - Modify(&box); - version = GetAndClearVersion(&box); + this->Modify(&box); + version = this->GetAndClearVersion(&box); box.Write(this->buffer_.get()); - EXPECT_EQ(version, GetAndClearVersion(&box)); + EXPECT_EQ(version, this->GetAndClearVersion(&box)); TypeParam box_readback; - ASSERT_TRUE(ReadBack(&box_readback)); + ASSERT_TRUE(this->ReadBack(&box_readback)); ASSERT_EQ(box, box_readback); } TYPED_TEST(BoxDefinitionsTestGeneral, Empty) { TypeParam box; LOG(INFO) << "Processing " << FourCCToString(box.BoxType()); - if (IsOptional(&box)) { + if (this->IsOptional(&box)) { ASSERT_EQ(0, box.ComputeSize()); } else { ASSERT_NE(0, box.ComputeSize()); diff --git a/media/mp4/box_reader_unittest.cc b/media/mp4/box_reader_unittest.cc index 1816bf6584..1a758dfaf4 100644 --- a/media/mp4/box_reader_unittest.cc +++ b/media/mp4/box_reader_unittest.cc @@ -33,7 +33,7 @@ struct FreeBox : Box { return true; } virtual FourCC BoxType() const OVERRIDE { return FOURCC_FREE; } - virtual uint32 ComputeSize() { + virtual uint32 ComputeSize() OVERRIDE { NOTIMPLEMENTED(); return 0; } @@ -44,7 +44,7 @@ struct PsshBox : Box { return buffer->ReadWriteUInt32(&val); } virtual FourCC BoxType() const OVERRIDE { return FOURCC_PSSH; } - virtual uint32 ComputeSize() { + virtual uint32 ComputeSize() OVERRIDE { NOTIMPLEMENTED(); return 0; } @@ -70,7 +70,7 @@ struct SkipBox : FullBox { return buffer->TryReadWriteChild(&empty); } virtual FourCC BoxType() const OVERRIDE { return FOURCC_SKIP; } - virtual uint32 ComputeSize() { + virtual uint32 ComputeSize() OVERRIDE { NOTIMPLEMENTED(); return 0; } diff --git a/media/mp4/mp4_general_segmenter.h b/media/mp4/mp4_general_segmenter.h index 489b0e7a25..2a2ecddd39 100644 --- a/media/mp4/mp4_general_segmenter.h +++ b/media/mp4/mp4_general_segmenter.h @@ -32,7 +32,7 @@ class MP4GeneralSegmenter : public MP4Segmenter { MP4GeneralSegmenter(const MuxerOptions& options, scoped_ptr ftyp, scoped_ptr moov); - ~MP4GeneralSegmenter(); + virtual ~MP4GeneralSegmenter(); // MP4Segmenter implementations. virtual Status Initialize(EncryptorSource* encryptor_source, diff --git a/media/mp4/mp4_vod_segmenter.h b/media/mp4/mp4_vod_segmenter.h index d4b7a70c2d..0ba5cfd558 100644 --- a/media/mp4/mp4_vod_segmenter.h +++ b/media/mp4/mp4_vod_segmenter.h @@ -29,7 +29,7 @@ class MP4VODSegmenter : public MP4Segmenter { MP4VODSegmenter(const MuxerOptions& options, scoped_ptr ftyp, scoped_ptr moov); - ~MP4VODSegmenter(); + virtual ~MP4VODSegmenter(); // MP4Segmenter implementations. virtual Status Initialize(EncryptorSource* encryptor_source, diff --git a/packager.gyp b/packager.gyp index e374486028..dd3a5759a3 100644 --- a/packager.gyp +++ b/packager.gyp @@ -47,6 +47,8 @@ 'media/base/media_stream.h', 'media/base/muxer.cc', 'media/base/muxer.h', + 'media/base/muxer_options.cc', + 'media/base/muxer_options.h', 'media/base/rsa_key.cc', 'media/base/rsa_key.h', 'media/base/status.cc',