From 25b1038f5d77f94ddff4de57fd66f81b027dd1b7 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Fri, 21 Mar 2014 10:26:49 -0700 Subject: [PATCH] Enable warnings and warnings-as-errors The warnings and warnings-as-errors are enabled by set chromium_code to 1. Chromium build disables warnings and warnings-as-errors by default on external contents. And fix the errors with them enabled. Mostly defined but not used, sign-unsign comparison, unsigned string formatting, and return value not used etc. Change-Id: I305b63924955a84172e98e0ebfe5aba0f11bdb37 --- app/packager_main.cc | 4 +-- media/base/aes_encryptor.cc | 2 +- media/base/buffer_writer_unittest.cc | 11 +++---- media/base/demuxer.cc | 2 +- media/base/fake_prng.cc | 2 +- media/base/http_fetcher_unittest.cc | 1 - media/base/media_base.gyp | 4 +++ media/base/media_stream.cc | 2 +- media/base/stream_info.cc | 2 +- media/base/stream_info.h | 4 +-- media/base/widevine_encryptor_source.cc | 2 +- media/event/media_event.gyp | 4 +++ media/event/muxer_listener.h | 2 +- .../vod_media_info_dump_muxer_listener.cc | 10 ------- media/event/vod_muxer_listener_internal.cc | 2 +- media/event/vod_muxer_listener_internal.h | 2 +- media/file/file.gyp | 4 +++ media/mp4/aac_audio_specific_config.cc | 2 +- .../mp4/aac_audio_specific_config_unittest.cc | 30 +++++++++---------- media/mp4/box_buffer.h | 2 +- media/mp4/box_definitions.cc | 9 +++--- media/mp4/box_definitions_unittest.cc | 6 ++-- media/mp4/box_reader.cc | 6 ++-- media/mp4/box_reader.h | 6 ++-- media/mp4/chunk_info_iterator_unittest.cc | 2 +- media/mp4/composition_offset_iterator.cc | 2 +- media/mp4/composition_offset_iterator.h | 4 +-- .../composition_offset_iterator_unittest.cc | 7 ++--- media/mp4/decoding_time_iterator_unittest.cc | 2 +- media/mp4/mp4.gyp | 4 +++ media/mp4/mp4_fragmenter.cc | 2 +- media/mp4/mp4_fragmenter.h | 10 +++---- media/mp4/mp4_media_parser.h | 4 +-- media/mp4/mp4_segmenter.cc | 4 +-- media/mp4/track_run_iterator.cc | 1 - media/test/media_test.gyp | 4 +++ media/test/packager_test.cc | 4 +-- mpd/base/mpd_builder_unittest.cc | 4 +-- mpd/base/mpd_utils.h | 2 +- mpd/base/xml/xml_node.cc | 2 +- mpd/mpd.gyp | 4 +++ packager.gyp | 4 +++ 42 files changed, 102 insertions(+), 85 deletions(-) diff --git a/app/packager_main.cc b/app/packager_main.cc index 5f80965262..865541ecec 100644 --- a/app/packager_main.cc +++ b/app/packager_main.cc @@ -36,9 +36,9 @@ const char kUsage[] = namespace media { void DumpStreamInfo(const std::vector& streams) { - printf("Found %d stream(s).\n", streams.size()); + printf("Found %zu stream(s).\n", streams.size()); for (size_t i = 0; i < streams.size(); ++i) - printf("Stream [%d] %s\n", i, streams[i]->info()->ToString().c_str()); + printf("Stream [%zu] %s\n", i, streams[i]->info()->ToString().c_str()); } // Create and initialize encryptor source. diff --git a/media/base/aes_encryptor.cc b/media/base/aes_encryptor.cc index 367c96e726..9ab61c2fee 100644 --- a/media/base/aes_encryptor.cc +++ b/media/base/aes_encryptor.cc @@ -109,7 +109,7 @@ void AesCtrEncryptor::UpdateIv() { counter_ = iv_; counter_.resize(AES_BLOCK_SIZE, 0); } else { - DCHECK_EQ(16, iv_.size()); + DCHECK_EQ(16u, iv_.size()); // Even though the block counter portion of the counter (bytes 8 to 15) is // treated as a 64-bit number, it is recommended that the initialization // vector is treated as a 128-bit number when calculating the next diff --git a/media/base/buffer_writer_unittest.cc b/media/base/buffer_writer_unittest.cc index 7d0f0d1087..0aacd83f38 100644 --- a/media/base/buffer_writer_unittest.cc +++ b/media/base/buffer_writer_unittest.cc @@ -98,7 +98,7 @@ TEST_F(BufferWriterTest, AppendNBytes) { TEST_F(BufferWriterTest, AppendEmptyVector) { std::vector v; writer_->AppendVector(v); - ASSERT_EQ(0, writer_->Size()); + ASSERT_EQ(0u, writer_->Size()); } TEST_F(BufferWriterTest, AppendVector) { @@ -157,7 +157,7 @@ TEST_F(BufferWriterTest, Clear) { writer_->AppendInt(kuint32); ASSERT_EQ(sizeof(kuint32), writer_->Size()); writer_->Clear(); - ASSERT_EQ(0, writer_->Size()); + ASSERT_EQ(0u, writer_->Size()); } TEST_F(BufferWriterTest, WriteToFile) { @@ -170,15 +170,16 @@ TEST_F(BufferWriterTest, WriteToFile) { writer_->AppendArray(kuint8Array, sizeof(kuint8Array)); ASSERT_EQ(sizeof(kuint8Array), writer_->Size()); ASSERT_OK(writer_->WriteToFile(output_file)); - ASSERT_EQ(0, writer_->Size()); + ASSERT_EQ(0u, writer_->Size()); ASSERT_TRUE(output_file->Close()); // Read the file and verify. File* const input_file = File::Open(path.value().c_str(), "r"); ASSERT_TRUE(input_file != NULL); std::vector data_read(sizeof(kuint8Array), 0); - EXPECT_EQ(sizeof(kuint8Array), - input_file->Read(&data_read[0], data_read.size())); + EXPECT_EQ( + sizeof(kuint8Array), + static_cast(input_file->Read(&data_read[0], data_read.size()))); ASSERT_TRUE(input_file->Close()); for (size_t i = 0; i < sizeof(kuint8Array); ++i) diff --git a/media/base/demuxer.cc b/media/base/demuxer.cc index 7c1523c540..ed19cf2e79 100644 --- a/media/base/demuxer.cc +++ b/media/base/demuxer.cc @@ -17,7 +17,7 @@ #include "media/mp4/mp4_media_parser.h" namespace { -const int kBufSize = 0x40000; // 256KB. +const size_t kBufSize = 0x40000; // 256KB. } namespace media { diff --git a/media/base/fake_prng.cc b/media/base/fake_prng.cc index 74ef19e5b4..6b86c6e8db 100644 --- a/media/base/fake_prng.cc +++ b/media/base/fake_prng.cc @@ -23,7 +23,7 @@ int FakeBytes(uint8* buf, int num) { DCHECK(buf); DCHECK(g_rand_source_fp); - if (fread(buf, 1, num, g_rand_source_fp) < num) { + if (fread(buf, 1, num, g_rand_source_fp) < static_cast(num)) { LOG(ERROR) << "Ran out of fake PRNG data"; return 0; } diff --git a/media/base/http_fetcher_unittest.cc b/media/base/http_fetcher_unittest.cc index aaf1ed2269..d2b9e46529 100644 --- a/media/base/http_fetcher_unittest.cc +++ b/media/base/http_fetcher_unittest.cc @@ -12,7 +12,6 @@ #include "media/base/status_test_util.h" namespace { -const int kHttpOK = 200; const int kHttpNotFound = 404; const char kTestUrl[] = "http://packager-test.appspot.com/http_test"; diff --git a/media/base/media_base.gyp b/media/base/media_base.gyp index 946b77d986..1af7470254 100644 --- a/media/base/media_base.gyp +++ b/media/base/media_base.gyp @@ -5,6 +5,10 @@ # https://developers.google.com/open-source/licenses/bsd { + 'variables': { + # Compile as chromium code to enable warnings and warnings-as-errors. + 'chromium_code': 1, + }, 'target_defaults': { 'include_dirs': [ '../..', diff --git a/media/base/media_stream.cc b/media/base/media_stream.cc index 6af62dcf53..c9d2f6c5f1 100644 --- a/media/base/media_stream.cc +++ b/media/base/media_stream.cc @@ -80,7 +80,7 @@ Status MediaStream::Start(MediaStreamOperation operation) { } else { // We need to disconnect all its peer streams which are not connected // to a muxer. - for (int i = 0; i < demuxer_->streams().size(); ++i) { + for (size_t i = 0; i < demuxer_->streams().size(); ++i) { Status status = demuxer_->streams()[i]->Start(operation); if (!status.ok()) return status; diff --git a/media/base/stream_info.cc b/media/base/stream_info.cc index f14fda23ae..387e510ca0 100644 --- a/media/base/stream_info.cc +++ b/media/base/stream_info.cc @@ -36,7 +36,7 @@ StreamInfo::~StreamInfo() {} std::string StreamInfo::ToString() const { return base::StringPrintf( - "type: %s\n codec_string: %s\n time_scale: %d\n duration: %d " + "type: %s\n codec_string: %s\n time_scale: %d\n duration: %lu " "(%.1f seconds)\n language: %s\n is_encrypted: %s\n", (stream_type_ == kStreamAudio ? "Audio" : "Video"), codec_string_.c_str(), diff --git a/media/base/stream_info.h b/media/base/stream_info.h index bb2652824c..d92cd18a55 100644 --- a/media/base/stream_info.h +++ b/media/base/stream_info.h @@ -39,7 +39,7 @@ class StreamInfo : public base::RefCountedThreadSafe { virtual std::string ToString() const; StreamType stream_type() const { return stream_type_; } - int track_id() const { return track_id_; } + uint32 track_id() const { return track_id_; } uint32 time_scale() const { return time_scale_; } uint64 duration() const { return duration_; } const std::string& codec_string() const { return codec_string_; } @@ -58,7 +58,7 @@ class StreamInfo : public base::RefCountedThreadSafe { private: // Whether the stream is Audio or Video. StreamType stream_type_; - int track_id_; + uint32 track_id_; // The actual time is calculated as time / time_scale_ in seconds. uint32 time_scale_; // Duration base on time_scale. diff --git a/media/base/widevine_encryptor_source.cc b/media/base/widevine_encryptor_source.cc index 16e9d12331..3f43cde920 100644 --- a/media/base/widevine_encryptor_source.cc +++ b/media/base/widevine_encryptor_source.cc @@ -72,7 +72,7 @@ bool GetPssh(const base::DictionaryValue& track_dict, RCHECK(track_dict.GetList("pssh", &pssh_list)); // Invariant check. We don't want to crash in release mode if possible. // The following code handles it gracefully if GetSize() does not return 1. - DCHECK_EQ(1, pssh_list->GetSize()); + DCHECK_EQ(1u, pssh_list->GetSize()); const base::DictionaryValue* pssh_dict; RCHECK(pssh_list->GetDictionary(0, &pssh_dict)); diff --git a/media/event/media_event.gyp b/media/event/media_event.gyp index cbd033f1ec..d52b8513cf 100644 --- a/media/event/media_event.gyp +++ b/media/event/media_event.gyp @@ -5,6 +5,10 @@ # https://developers.google.com/open-source/licenses/bsd { + 'variables': { + # Compile as chromium code to enable warnings and warnings-as-errors. + 'chromium_code': 1, + }, 'target_defaults': { 'include_dirs': [ '../..', diff --git a/media/event/muxer_listener.h b/media/event/muxer_listener.h index 7cf4e80466..dc4fa75b41 100644 --- a/media/event/muxer_listener.h +++ b/media/event/muxer_listener.h @@ -15,8 +15,8 @@ namespace media { -class MuxerOptions; class StreamInfo; +struct MuxerOptions; namespace event { diff --git a/media/event/vod_media_info_dump_muxer_listener.cc b/media/event/vod_media_info_dump_muxer_listener.cc index fa11eb8c83..11b0be4bae 100644 --- a/media/event/vod_media_info_dump_muxer_listener.cc +++ b/media/event/vod_media_info_dump_muxer_listener.cc @@ -24,16 +24,6 @@ namespace { const char kEncryptedMp4Uri[] = "urn:mpeg:dash:mp4protection:2011"; const char kEncryptedMp4Value[] = "cenc"; -bool IsAnyStreamEncrypted(const std::vector& stream_infos) { - typedef std::vector::const_iterator Iterator; - for (Iterator it = stream_infos.begin(); it != stream_infos.end(); ++it) { - if ((*it)->is_encrypted()) - return true; - } - - return false; -} - // |user_scheme_id_uri| is the user specified schemeIdUri for ContentProtection. // This adds a default ContentProtection element if the container is MP4. // Returns true if a ContentProtectionXml is added to |media_info|, otherwise diff --git a/media/event/vod_muxer_listener_internal.cc b/media/event/vod_muxer_listener_internal.cc index 1e6b4b3f4e..d2fd3e4807 100644 --- a/media/event/vod_muxer_listener_internal.cc +++ b/media/event/vod_muxer_listener_internal.cc @@ -88,7 +88,7 @@ void SetMediaInfoCommonInfo(float duration_seconds, MuxerListener::ContainerType container_type, MediaInfo* media_info) { DCHECK(media_info); - DCHECK_GT(file_size, 0); + DCHECK_GT(file_size, 0u); DCHECK_GT(duration_seconds, 0.0f); media_info->set_media_duration_seconds(duration_seconds); diff --git a/media/event/vod_muxer_listener_internal.h b/media/event/vod_muxer_listener_internal.h index 5f4c03dd91..6f8ee6d731 100644 --- a/media/event/vod_muxer_listener_internal.h +++ b/media/event/vod_muxer_listener_internal.h @@ -18,8 +18,8 @@ class MediaInfo; namespace media { -class MuxerOptions; class StreamInfo; +struct MuxerOptions; namespace event { namespace internal { diff --git a/media/file/file.gyp b/media/file/file.gyp index 36014f7dd3..c4ddbf46aa 100644 --- a/media/file/file.gyp +++ b/media/file/file.gyp @@ -5,6 +5,10 @@ # https://developers.google.com/open-source/licenses/bsd { + 'variables': { + # Compile as chromium code to enable warnings and warnings-as-errors. + 'chromium_code': 1, + }, 'target_defaults': { 'include_dirs': [ '../..', diff --git a/media/mp4/aac_audio_specific_config.cc b/media/mp4/aac_audio_specific_config.cc index 640f566402..a7f02f2c24 100644 --- a/media/mp4/aac_audio_specific_config.cc +++ b/media/mp4/aac_audio_specific_config.cc @@ -138,7 +138,7 @@ uint32 AACAudioSpecificConfig::GetOutputSamplesPerSecond(bool sbr_in_mimetype) // The following code is written according to ISO 14496 Part 3 Table 1.11 and // Table 1.22. (Table 1.11 refers to the capping to 48000, Table 1.22 refers // to SBR doubling the AAC sample rate.) - DCHECK_GT(frequency_, 0); + DCHECK_GT(frequency_, 0u); return std::min(2 * frequency_, 48000u); } diff --git a/media/mp4/aac_audio_specific_config_unittest.cc b/media/mp4/aac_audio_specific_config_unittest.cc index 2da1c486b0..9dc87b13ed 100644 --- a/media/mp4/aac_audio_specific_config_unittest.cc +++ b/media/mp4/aac_audio_specific_config_unittest.cc @@ -17,8 +17,8 @@ TEST(AACAudioSpecificConfigTest, BasicProfileTest) { data.assign(buffer, buffer + sizeof(buffer)); EXPECT_TRUE(aac_audio_specific_config.Parse(data)); - EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 44100); - EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2); + EXPECT_EQ(44100u, aac_audio_specific_config.GetOutputSamplesPerSecond(false)); + EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(false)); } TEST(AACAudioSpecificConfigTest, ExtensionTest) { @@ -29,9 +29,9 @@ TEST(AACAudioSpecificConfigTest, ExtensionTest) { data.assign(buffer, buffer + sizeof(buffer)); EXPECT_TRUE(aac_audio_specific_config.Parse(data)); - EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 48000); - EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000); - EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2); + EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(false)); + EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(true)); + EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(false)); } // Test implicit SBR with mono channel config. @@ -48,12 +48,12 @@ TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig0) { EXPECT_TRUE(aac_audio_specific_config.Parse(data)); // Test w/o implict SBR. - EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 24000); - EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 1); + EXPECT_EQ(24000u, aac_audio_specific_config.GetOutputSamplesPerSecond(false)); + EXPECT_EQ(1u, aac_audio_specific_config.GetNumChannels(false)); // Test implicit SBR. - EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000); - EXPECT_EQ(aac_audio_specific_config.GetNumChannels(true), 2); + EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(true)); + EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(true)); } // Tests implicit SBR with a stereo channel config. @@ -67,12 +67,12 @@ TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig1) { EXPECT_TRUE(aac_audio_specific_config.Parse(data)); // Test w/o implict SBR. - EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 24000); - EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2); + EXPECT_EQ(24000u, aac_audio_specific_config.GetOutputSamplesPerSecond(false)); + EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(false)); // Test implicit SBR. - EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000); - EXPECT_EQ(aac_audio_specific_config.GetNumChannels(true), 2); + EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(true)); + EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(true)); } TEST(AACAudioSpecificConfigTest, SixChannelTest) { @@ -83,8 +83,8 @@ TEST(AACAudioSpecificConfigTest, SixChannelTest) { data.assign(buffer, buffer + sizeof(buffer)); EXPECT_TRUE(aac_audio_specific_config.Parse(data)); - EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 48000); - EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 6); + EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(false)); + EXPECT_EQ(6u, aac_audio_specific_config.GetNumChannels(false)); } TEST(AACAudioSpecificConfigTest, DataTooShortTest) { diff --git a/media/mp4/box_buffer.h b/media/mp4/box_buffer.h index 6056f919a4..9a054ce830 100644 --- a/media/mp4/box_buffer.h +++ b/media/mp4/box_buffer.h @@ -144,7 +144,7 @@ class BoxBuffer { if (reader_) return reader_->ReadChild(box); // The box is mandatory, i.e. the box size should not be 0. - DCHECK_NE(0, box->atom_size); + DCHECK_NE(0u, box->atom_size); CHECK(box->ReadWrite(this)); return true; } diff --git a/media/mp4/box_definitions.cc b/media/mp4/box_definitions.cc index a8e1b7cd5e..d69d6ae9fa 100644 --- a/media/mp4/box_definitions.cc +++ b/media/mp4/box_definitions.cc @@ -395,7 +395,7 @@ bool SampleDescription::ReadWrite(BoxBuffer* buffer) { RCHECK(audio_entries.size() == count); } } else { - DCHECK_LT(0, count); + DCHECK_LT(0u, count); if (type == kVideo) { for (uint32 i = 0; i < count; ++i) RCHECK(video_entries[i].ReadWrite(buffer)); @@ -548,8 +548,8 @@ bool CompactSampleSize::ReadWrite(BoxBuffer* buffer) { sizes[i] = size >> 4; sizes[i + 1] = size & 0x0F; } else { - DCHECK_LT(sizes[i], 16); - DCHECK_LT(sizes[i + 1], 16); + DCHECK_LT(sizes[i], 16u); + DCHECK_LT(sizes[i + 1], 16u); uint8 size = (sizes[i] << 4) | sizes[i + 1]; RCHECK(buffer->ReadWriteUInt8(&size)); } @@ -778,7 +778,7 @@ HandlerReference::~HandlerReference() {} FourCC HandlerReference::BoxType() const { return FOURCC_HDLR; } bool HandlerReference::ReadWrite(BoxBuffer* buffer) { - FourCC hdlr_type; + FourCC hdlr_type = FOURCC_NULL; std::vector handler_name; if (!buffer->Reading()) { if (type == kVideo) { @@ -791,6 +791,7 @@ bool HandlerReference::ReadWrite(BoxBuffer* buffer) { kAudioHandlerName + arraysize(kAudioHandlerName)); } else { NOTIMPLEMENTED(); + return false; } } RCHECK(FullBox::ReadWrite(buffer) && diff --git a/media/mp4/box_definitions_unittest.cc b/media/mp4/box_definitions_unittest.cc index 5169fa4a06..cf29e02d62 100644 --- a/media/mp4/box_definitions_unittest.cc +++ b/media/mp4/box_definitions_unittest.cc @@ -787,9 +787,9 @@ TYPED_TEST(BoxDefinitionsTestGeneral, Empty) { TypeParam box; LOG(INFO) << "Processing " << FourCCToString(box.BoxType()); if (this->IsOptional(&box)) { - ASSERT_EQ(0, box.ComputeSize()); + ASSERT_EQ(0u, box.ComputeSize()); } else { - ASSERT_NE(0, box.ComputeSize()); + ASSERT_NE(0u, box.ComputeSize()); } } @@ -837,7 +837,7 @@ TEST_F(BoxDefinitionsTest, TrackFragmentHeader_NoSampleSize) { TrackFragmentHeader tfhd_readback; ASSERT_TRUE(ReadBack(&tfhd_readback)); - EXPECT_EQ(0, tfhd_readback.default_sample_size); + EXPECT_EQ(0u, tfhd_readback.default_sample_size); tfhd.default_sample_size = 0; ASSERT_EQ(tfhd, tfhd_readback); } diff --git a/media/mp4/box_reader.cc b/media/mp4/box_reader.cc index 2c6fe5fad3..7f9190906a 100644 --- a/media/mp4/box_reader.cc +++ b/media/mp4/box_reader.cc @@ -14,7 +14,7 @@ namespace mp4 { BoxReader::BoxReader(const uint8* buf, size_t size) : BufferReader(buf, size), type_(FOURCC_NULL), scanned_(false) { DCHECK(buf); - DCHECK_LT(0, size); + DCHECK_LT(0u, size); } BoxReader::~BoxReader() { @@ -29,7 +29,7 @@ BoxReader::~BoxReader() { // static BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf, - const int buf_size, + const size_t buf_size, bool* err) { scoped_ptr reader(new BoxReader(buf, buf_size)); if (!reader->ReadHeader(err)) @@ -52,7 +52,7 @@ BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf, // static bool BoxReader::StartTopLevelBox(const uint8* buf, - const int buf_size, + const size_t buf_size, FourCC* type, int* box_size, bool* err) { diff --git a/media/mp4/box_reader.h b/media/mp4/box_reader.h index 036124d9ae..2a38d36da1 100644 --- a/media/mp4/box_reader.h +++ b/media/mp4/box_reader.h @@ -17,7 +17,7 @@ namespace media { namespace mp4 { -class Box; +struct Box; /// Class for reading MP4 boxes. class BoxReader : public BufferReader { @@ -35,7 +35,7 @@ class BoxReader : public BufferReader { /// available in the buffer. For MDAT box only, a BoxReader object is /// returned as long as the box header is available. static BoxReader* ReadTopLevelBox(const uint8* buf, - const int buf_size, + const size_t buf_size, bool* err); /// Read the box header from the current buffer. @@ -48,7 +48,7 @@ class BoxReader : public BufferReader { /// @return true if there is enough data to read the header and the header is /// sane, which does not imply that the entire box is in the buffer. static bool StartTopLevelBox(const uint8* buf, - const int buf_size, + const size_t buf_size, FourCC* type, int* box_size, bool* err) WARN_UNUSED_RESULT; diff --git a/media/mp4/chunk_info_iterator_unittest.cc b/media/mp4/chunk_info_iterator_unittest.cc index 08c997e3db..402ec5bc71 100644 --- a/media/mp4/chunk_info_iterator_unittest.cc +++ b/media/mp4/chunk_info_iterator_unittest.cc @@ -59,7 +59,7 @@ TEST_F(ChunkInfoIteratorTest, EmptyChunkInfo) { SampleToChunk sample_to_chunk; ChunkInfoIterator iterator(sample_to_chunk); EXPECT_FALSE(iterator.IsValid()); - EXPECT_EQ(0, iterator.LastFirstChunk()); + EXPECT_EQ(0u, iterator.LastFirstChunk()); } TEST_F(ChunkInfoIteratorTest, LastFirstChunk) { diff --git a/media/mp4/composition_offset_iterator.cc b/media/mp4/composition_offset_iterator.cc index 7c66513f59..60b8f3064c 100644 --- a/media/mp4/composition_offset_iterator.cc +++ b/media/mp4/composition_offset_iterator.cc @@ -34,7 +34,7 @@ bool CompositionOffsetIterator::IsValid() const { sample_index_ < iterator_->sample_count; } -uint32 CompositionOffsetIterator::SampleOffset(uint32 sample) const { +int32 CompositionOffsetIterator::SampleOffset(uint32 sample) const { uint32 current_sample = 0; std::vector::const_iterator it = composition_offset_table_.begin(); diff --git a/media/mp4/composition_offset_iterator.h b/media/mp4/composition_offset_iterator.h index d6e89dfbdb..ce4db69c6d 100644 --- a/media/mp4/composition_offset_iterator.h +++ b/media/mp4/composition_offset_iterator.h @@ -33,10 +33,10 @@ class CompositionOffsetIterator { bool IsValid() const; /// @return Sample offset for current sample. - uint32 sample_offset() const { return iterator_->sample_offset; } + int32 sample_offset() const { return iterator_->sample_offset; } /// @return Sample offset @a sample, 1-based. - uint32 SampleOffset(uint32 sample) const; + int32 SampleOffset(uint32 sample) const; /// @return Total number of samples. uint32 NumSamples() const; diff --git a/media/mp4/composition_offset_iterator_unittest.cc b/media/mp4/composition_offset_iterator_unittest.cc index 848070c44b..88d825388e 100644 --- a/media/mp4/composition_offset_iterator_unittest.cc +++ b/media/mp4/composition_offset_iterator_unittest.cc @@ -13,13 +13,12 @@ namespace media { namespace mp4 { const CompositionOffset kCompositionOffsets[] = - {{10, 8}, {9, 5}, {25, 7}, {48, 63}, {8, 2}}; + {{10, -8}, {9, 5}, {25, 7}, {48, 63}, {8, 2}}; class CompositionOffsetIteratorTest : public testing::Test { public: CompositionOffsetIteratorTest() { // Build composition offset table from kCompositionOffsets. - uint32 composition_offset = 0; uint32 length = sizeof(kCompositionOffsets) / sizeof(CompositionOffset); for (uint32 i = 0; i < length; ++i) { for (uint32 j = 0; j < kCompositionOffsets[i].sample_count; ++j) { @@ -35,7 +34,7 @@ class CompositionOffsetIteratorTest : public testing::Test { } protected: - std::vector composition_offset_table_; + std::vector composition_offset_table_; CompositionTimeToSample composition_time_to_sample_; scoped_ptr composition_offset_iterator_; @@ -47,7 +46,7 @@ TEST_F(CompositionOffsetIteratorTest, EmptyCompositionTime) { CompositionTimeToSample composition_time_to_sample; CompositionOffsetIterator iterator(composition_time_to_sample); EXPECT_FALSE(iterator.IsValid()); - EXPECT_EQ(0, iterator.NumSamples()); + EXPECT_EQ(0u, iterator.NumSamples()); } TEST_F(CompositionOffsetIteratorTest, NumSamples) { diff --git a/media/mp4/decoding_time_iterator_unittest.cc b/media/mp4/decoding_time_iterator_unittest.cc index 5bb30964a8..c5e5eecacd 100644 --- a/media/mp4/decoding_time_iterator_unittest.cc +++ b/media/mp4/decoding_time_iterator_unittest.cc @@ -47,7 +47,7 @@ TEST_F(DecodingTimeIteratorTest, EmptyDecodingTime) { DecodingTimeToSample decoding_time_to_sample; DecodingTimeIterator iterator(decoding_time_to_sample); EXPECT_FALSE(iterator.IsValid()); - EXPECT_EQ(0, iterator.NumSamples()); + EXPECT_EQ(0u, iterator.NumSamples()); } TEST_F(DecodingTimeIteratorTest, NumSamples) { diff --git a/media/mp4/mp4.gyp b/media/mp4/mp4.gyp index f3b27732b9..f6b211a0ce 100644 --- a/media/mp4/mp4.gyp +++ b/media/mp4/mp4.gyp @@ -5,6 +5,10 @@ # https://developers.google.com/open-source/licenses/bsd { + 'variables': { + # Compile as chromium code to enable warnings and warnings-as-errors. + 'chromium_code': 1, + }, 'target_defaults': { 'include_dirs': [ '../..', diff --git a/media/mp4/mp4_fragmenter.cc b/media/mp4/mp4_fragmenter.cc index 283680164c..a1b9f9c879 100644 --- a/media/mp4/mp4_fragmenter.cc +++ b/media/mp4/mp4_fragmenter.cc @@ -14,7 +14,7 @@ #include "media/mp4/cenc.h" namespace { -const uint64 kInvalidTime = kuint64max; +const int64 kInvalidTime = kint64max; // Optimize sample entries table. If all values in |entries| are identical, // then |entries| is cleared and the value is assigned to |default_value|; diff --git a/media/mp4/mp4_fragmenter.h b/media/mp4/mp4_fragmenter.h index adb72588b8..528e2772b3 100644 --- a/media/mp4/mp4_fragmenter.h +++ b/media/mp4/mp4_fragmenter.h @@ -21,8 +21,8 @@ class MediaSample; namespace mp4 { -class SegmentReference; -class TrackFragment; +struct SegmentReference; +struct TrackFragment; /// MP4Fragmenter is responsible for the generation of MP4 fragments, i.e. traf /// box and corresponding mdat box. The samples are also encrypted if encryption @@ -46,7 +46,7 @@ class MP4Fragmenter { ~MP4Fragmenter(); /// Add a sample to the fragmenter. - virtual Status AddSample(scoped_refptr sample); + Status AddSample(scoped_refptr sample); /// Initialize the fragment with default data. void InitializeFragment(); @@ -91,8 +91,8 @@ class MP4Fragmenter { uint64 fragment_duration_; bool normalize_presentation_timestamp_; int64 presentation_start_time_; - uint64 earliest_presentation_time_; - uint64 first_sap_time_; + int64 earliest_presentation_time_; + int64 first_sap_time_; int64 clear_time_; scoped_ptr data_; scoped_ptr aux_data_; diff --git a/media/mp4/mp4_media_parser.h b/media/mp4/mp4_media_parser.h index a744efc368..7a729e58bf 100644 --- a/media/mp4/mp4_media_parser.h +++ b/media/mp4/mp4_media_parser.h @@ -20,10 +20,10 @@ namespace media { namespace mp4 { -struct Movie; class BoxReader; -class ProtectionSystemSpecificHeader; class TrackRunIterator; +struct Movie; +struct ProtectionSystemSpecificHeader; class MP4MediaParser : public MediaParser { public: diff --git a/media/mp4/mp4_segmenter.cc b/media/mp4/mp4_segmenter.cc index 53c7c87003..edadcf9f0a 100644 --- a/media/mp4/mp4_segmenter.cc +++ b/media/mp4/mp4_segmenter.cc @@ -31,10 +31,10 @@ MP4Segmenter::MP4Segmenter(const MuxerOptions& options, scoped_ptr ftyp, scoped_ptr moov) : options_(options), - fragment_buffer_(new BufferWriter()), ftyp_(ftyp.Pass()), moov_(moov.Pass()), moof_(new MovieFragment()), + fragment_buffer_(new BufferWriter()), sidx_(new SegmentIndex()), segment_initialized_(false), end_of_segment_(false) {} @@ -44,7 +44,7 @@ MP4Segmenter::~MP4Segmenter() { STLDeleteElements(&fragmenters_); } Status MP4Segmenter::Initialize(EncryptorSource* encryptor_source, double clear_lead_in_seconds, const std::vector& streams) { - DCHECK_LT(0, streams.size()); + DCHECK_LT(0u, streams.size()); moof_->header.sequence_number = 0; moof_->tracks.resize(streams.size()); diff --git a/media/mp4/track_run_iterator.cc b/media/mp4/track_run_iterator.cc index c8b83ced5d..0ae7eeb284 100644 --- a/media/mp4/track_run_iterator.cc +++ b/media/mp4/track_run_iterator.cc @@ -172,7 +172,6 @@ bool TrackRunIterator::Init() { trak->media.information.sample_table.chunk_large_offset.offsets; int64 run_start_dts = 0; - int64 run_data_offset = 0; uint32 num_samples = sample_size.sample_count; uint32 num_chunks = chunk_offset_vector.size(); diff --git a/media/test/media_test.gyp b/media/test/media_test.gyp index f1ad4254a2..b5c3f742f1 100644 --- a/media/test/media_test.gyp +++ b/media/test/media_test.gyp @@ -5,6 +5,10 @@ # https://developers.google.com/open-source/licenses/bsd { + 'variables': { + # Compile as chromium code to enable warnings and warnings-as-errors. + 'chromium_code': 1, + }, 'target_defaults': { 'include_dirs': [ '../..', diff --git a/media/test/packager_test.cc b/media/test/packager_test.cc index 3fa0f3ef0f..6171dd41b0 100644 --- a/media/test/packager_test.cc +++ b/media/test/packager_test.cc @@ -206,7 +206,7 @@ TEST_P(PackagerTestBasic, MP4MuxerSingleSegmentEncrypted) { // Expect the output to be encrypted. Demuxer demuxer(GetFullPath(kOutputVideo), decryptor_source_); ASSERT_OK(demuxer.Initialize()); - ASSERT_EQ(1, demuxer.streams().size()); + ASSERT_EQ(1u, demuxer.streams().size()); EXPECT_TRUE(demuxer.streams()[0]->info()->is_encrypted()); } @@ -279,7 +279,7 @@ TEST_P(PackagerTest, MP4MuxerMultipleSegmentsUnencrypted) { ASSERT_TRUE(base::ReadFileToString(segment_path, &segment_content)); int bytes_written = file_util::AppendToFile( output_path, segment_content.data(), segment_content.size()); - ASSERT_EQ(segment_content.size(), bytes_written); + ASSERT_EQ(segment_content.size(), static_cast(bytes_written)); ++segment_index; } diff --git a/mpd/base/mpd_builder_unittest.cc b/mpd/base/mpd_builder_unittest.cc index 624003a98c..6317882ce3 100644 --- a/mpd/base/mpd_builder_unittest.cc +++ b/mpd/base/mpd_builder_unittest.cc @@ -41,7 +41,7 @@ TEST_F(StaticMpdBuilderTest, Video) { Representation* video_representation = video_adaptation_set->AddRepresentation(video_media_info); - ASSERT_TRUE(video_adaptation_set); + ASSERT_TRUE(video_representation); EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputVideo1)); } @@ -63,7 +63,7 @@ TEST_F(StaticMpdBuilderTest, VideoAndAudio) { Representation* video_representation = video_adaptation_set->AddRepresentation(video_media_info); - ASSERT_TRUE(video_adaptation_set); + ASSERT_TRUE(video_representation); EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputAudio1AndVideo1)); } diff --git a/mpd/base/mpd_utils.h b/mpd/base/mpd_utils.h index 6f0d34b84e..3a478b7048 100644 --- a/mpd/base/mpd_utils.h +++ b/mpd/base/mpd_utils.h @@ -17,7 +17,7 @@ namespace dash_packager { -class ContentProtectionElement; +struct ContentProtectionElement; bool HasVODOnlyFields(const MediaInfo& media_info); diff --git a/mpd/base/xml/xml_node.cc b/mpd/base/xml/xml_node.cc index 4e2d297ed4..e311c96cc6 100644 --- a/mpd/base/xml/xml_node.cc +++ b/mpd/base/xml/xml_node.cc @@ -171,7 +171,7 @@ bool XmlNode::AddChild(ScopedXmlPtr::type child) { // Reaching here means the ownership of |child| transfered to |node_|. // Release the pointer so that it doesn't get destructed in this scope. - child.release(); + ignore_result(child.release()); return true; } diff --git a/mpd/mpd.gyp b/mpd/mpd.gyp index 06fb119356..4cbc1fae82 100644 --- a/mpd/mpd.gyp +++ b/mpd/mpd.gyp @@ -7,6 +7,10 @@ # GYP file for any MPD generation targets. { + 'variables': { + # Compile as chromium code to enable warnings and warnings-as-errors. + 'chromium_code': 1, + }, 'target_defaults': { 'include_dirs': [ '..', diff --git a/packager.gyp b/packager.gyp index ea1f887d66..723f2e9dd5 100644 --- a/packager.gyp +++ b/packager.gyp @@ -5,6 +5,10 @@ # https://developers.google.com/open-source/licenses/bsd { + 'variables': { + # Compile as chromium code to enable warnings and warnings-as-errors. + 'chromium_code': 1, + }, 'target_defaults': { 'include_dirs': [ '.',