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
This commit is contained in:
Kongqun Yang 2014-03-21 10:26:49 -07:00 committed by KongQun Yang
parent 0c2d7cfa33
commit 25b1038f5d
42 changed files with 102 additions and 85 deletions

View File

@ -36,9 +36,9 @@ const char kUsage[] =
namespace media { namespace media {
void DumpStreamInfo(const std::vector<MediaStream*>& streams) { void DumpStreamInfo(const std::vector<MediaStream*>& 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) 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. // Create and initialize encryptor source.

View File

@ -109,7 +109,7 @@ void AesCtrEncryptor::UpdateIv() {
counter_ = iv_; counter_ = iv_;
counter_.resize(AES_BLOCK_SIZE, 0); counter_.resize(AES_BLOCK_SIZE, 0);
} else { } 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 // 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 // treated as a 64-bit number, it is recommended that the initialization
// vector is treated as a 128-bit number when calculating the next // vector is treated as a 128-bit number when calculating the next

View File

@ -98,7 +98,7 @@ TEST_F(BufferWriterTest, AppendNBytes) {
TEST_F(BufferWriterTest, AppendEmptyVector) { TEST_F(BufferWriterTest, AppendEmptyVector) {
std::vector<uint8> v; std::vector<uint8> v;
writer_->AppendVector(v); writer_->AppendVector(v);
ASSERT_EQ(0, writer_->Size()); ASSERT_EQ(0u, writer_->Size());
} }
TEST_F(BufferWriterTest, AppendVector) { TEST_F(BufferWriterTest, AppendVector) {
@ -157,7 +157,7 @@ TEST_F(BufferWriterTest, Clear) {
writer_->AppendInt(kuint32); writer_->AppendInt(kuint32);
ASSERT_EQ(sizeof(kuint32), writer_->Size()); ASSERT_EQ(sizeof(kuint32), writer_->Size());
writer_->Clear(); writer_->Clear();
ASSERT_EQ(0, writer_->Size()); ASSERT_EQ(0u, writer_->Size());
} }
TEST_F(BufferWriterTest, WriteToFile) { TEST_F(BufferWriterTest, WriteToFile) {
@ -170,15 +170,16 @@ TEST_F(BufferWriterTest, WriteToFile) {
writer_->AppendArray(kuint8Array, sizeof(kuint8Array)); writer_->AppendArray(kuint8Array, sizeof(kuint8Array));
ASSERT_EQ(sizeof(kuint8Array), writer_->Size()); ASSERT_EQ(sizeof(kuint8Array), writer_->Size());
ASSERT_OK(writer_->WriteToFile(output_file)); ASSERT_OK(writer_->WriteToFile(output_file));
ASSERT_EQ(0, writer_->Size()); ASSERT_EQ(0u, writer_->Size());
ASSERT_TRUE(output_file->Close()); ASSERT_TRUE(output_file->Close());
// Read the file and verify. // Read the file and verify.
File* const input_file = File::Open(path.value().c_str(), "r"); File* const input_file = File::Open(path.value().c_str(), "r");
ASSERT_TRUE(input_file != NULL); ASSERT_TRUE(input_file != NULL);
std::vector<uint8> data_read(sizeof(kuint8Array), 0); std::vector<uint8> data_read(sizeof(kuint8Array), 0);
EXPECT_EQ(sizeof(kuint8Array), EXPECT_EQ(
input_file->Read(&data_read[0], data_read.size())); sizeof(kuint8Array),
static_cast<size_t>(input_file->Read(&data_read[0], data_read.size())));
ASSERT_TRUE(input_file->Close()); ASSERT_TRUE(input_file->Close());
for (size_t i = 0; i < sizeof(kuint8Array); ++i) for (size_t i = 0; i < sizeof(kuint8Array); ++i)

View File

@ -17,7 +17,7 @@
#include "media/mp4/mp4_media_parser.h" #include "media/mp4/mp4_media_parser.h"
namespace { namespace {
const int kBufSize = 0x40000; // 256KB. const size_t kBufSize = 0x40000; // 256KB.
} }
namespace media { namespace media {

View File

@ -23,7 +23,7 @@ int FakeBytes(uint8* buf, int num) {
DCHECK(buf); DCHECK(buf);
DCHECK(g_rand_source_fp); 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<size_t>(num)) {
LOG(ERROR) << "Ran out of fake PRNG data"; LOG(ERROR) << "Ran out of fake PRNG data";
return 0; return 0;
} }

View File

@ -12,7 +12,6 @@
#include "media/base/status_test_util.h" #include "media/base/status_test_util.h"
namespace { namespace {
const int kHttpOK = 200;
const int kHttpNotFound = 404; const int kHttpNotFound = 404;
const char kTestUrl[] = "http://packager-test.appspot.com/http_test"; const char kTestUrl[] = "http://packager-test.appspot.com/http_test";

View File

@ -5,6 +5,10 @@
# https://developers.google.com/open-source/licenses/bsd # 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': { 'target_defaults': {
'include_dirs': [ 'include_dirs': [
'../..', '../..',

View File

@ -80,7 +80,7 @@ Status MediaStream::Start(MediaStreamOperation operation) {
} else { } else {
// We need to disconnect all its peer streams which are not connected // We need to disconnect all its peer streams which are not connected
// to a muxer. // 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); Status status = demuxer_->streams()[i]->Start(operation);
if (!status.ok()) if (!status.ok())
return status; return status;

View File

@ -36,7 +36,7 @@ StreamInfo::~StreamInfo() {}
std::string StreamInfo::ToString() const { std::string StreamInfo::ToString() const {
return base::StringPrintf( 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", "(%.1f seconds)\n language: %s\n is_encrypted: %s\n",
(stream_type_ == kStreamAudio ? "Audio" : "Video"), (stream_type_ == kStreamAudio ? "Audio" : "Video"),
codec_string_.c_str(), codec_string_.c_str(),

View File

@ -39,7 +39,7 @@ class StreamInfo : public base::RefCountedThreadSafe<StreamInfo> {
virtual std::string ToString() const; virtual std::string ToString() const;
StreamType stream_type() const { return stream_type_; } 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_; } uint32 time_scale() const { return time_scale_; }
uint64 duration() const { return duration_; } uint64 duration() const { return duration_; }
const std::string& codec_string() const { return codec_string_; } const std::string& codec_string() const { return codec_string_; }
@ -58,7 +58,7 @@ class StreamInfo : public base::RefCountedThreadSafe<StreamInfo> {
private: private:
// Whether the stream is Audio or Video. // Whether the stream is Audio or Video.
StreamType stream_type_; StreamType stream_type_;
int track_id_; uint32 track_id_;
// The actual time is calculated as time / time_scale_ in seconds. // The actual time is calculated as time / time_scale_ in seconds.
uint32 time_scale_; uint32 time_scale_;
// Duration base on time_scale. // Duration base on time_scale.

View File

@ -72,7 +72,7 @@ bool GetPssh(const base::DictionaryValue& track_dict,
RCHECK(track_dict.GetList("pssh", &pssh_list)); RCHECK(track_dict.GetList("pssh", &pssh_list));
// Invariant check. We don't want to crash in release mode if possible. // 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. // 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; const base::DictionaryValue* pssh_dict;
RCHECK(pssh_list->GetDictionary(0, &pssh_dict)); RCHECK(pssh_list->GetDictionary(0, &pssh_dict));

View File

@ -5,6 +5,10 @@
# https://developers.google.com/open-source/licenses/bsd # 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': { 'target_defaults': {
'include_dirs': [ 'include_dirs': [
'../..', '../..',

View File

@ -15,8 +15,8 @@
namespace media { namespace media {
class MuxerOptions;
class StreamInfo; class StreamInfo;
struct MuxerOptions;
namespace event { namespace event {

View File

@ -24,16 +24,6 @@ namespace {
const char kEncryptedMp4Uri[] = "urn:mpeg:dash:mp4protection:2011"; const char kEncryptedMp4Uri[] = "urn:mpeg:dash:mp4protection:2011";
const char kEncryptedMp4Value[] = "cenc"; const char kEncryptedMp4Value[] = "cenc";
bool IsAnyStreamEncrypted(const std::vector<StreamInfo*>& stream_infos) {
typedef std::vector<StreamInfo*>::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. // |user_scheme_id_uri| is the user specified schemeIdUri for ContentProtection.
// This adds a default ContentProtection element if the container is MP4. // This adds a default ContentProtection element if the container is MP4.
// Returns true if a ContentProtectionXml is added to |media_info|, otherwise // Returns true if a ContentProtectionXml is added to |media_info|, otherwise

View File

@ -88,7 +88,7 @@ void SetMediaInfoCommonInfo(float duration_seconds,
MuxerListener::ContainerType container_type, MuxerListener::ContainerType container_type,
MediaInfo* media_info) { MediaInfo* media_info) {
DCHECK(media_info); DCHECK(media_info);
DCHECK_GT(file_size, 0); DCHECK_GT(file_size, 0u);
DCHECK_GT(duration_seconds, 0.0f); DCHECK_GT(duration_seconds, 0.0f);
media_info->set_media_duration_seconds(duration_seconds); media_info->set_media_duration_seconds(duration_seconds);

View File

@ -18,8 +18,8 @@ class MediaInfo;
namespace media { namespace media {
class MuxerOptions;
class StreamInfo; class StreamInfo;
struct MuxerOptions;
namespace event { namespace event {
namespace internal { namespace internal {

View File

@ -5,6 +5,10 @@
# https://developers.google.com/open-source/licenses/bsd # 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': { 'target_defaults': {
'include_dirs': [ 'include_dirs': [
'../..', '../..',

View File

@ -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 // 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 // Table 1.22. (Table 1.11 refers to the capping to 48000, Table 1.22 refers
// to SBR doubling the AAC sample rate.) // to SBR doubling the AAC sample rate.)
DCHECK_GT(frequency_, 0); DCHECK_GT(frequency_, 0u);
return std::min(2 * frequency_, 48000u); return std::min(2 * frequency_, 48000u);
} }

View File

@ -17,8 +17,8 @@ TEST(AACAudioSpecificConfigTest, BasicProfileTest) {
data.assign(buffer, buffer + sizeof(buffer)); data.assign(buffer, buffer + sizeof(buffer));
EXPECT_TRUE(aac_audio_specific_config.Parse(data)); EXPECT_TRUE(aac_audio_specific_config.Parse(data));
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 44100); EXPECT_EQ(44100u, aac_audio_specific_config.GetOutputSamplesPerSecond(false));
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2); EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(false));
} }
TEST(AACAudioSpecificConfigTest, ExtensionTest) { TEST(AACAudioSpecificConfigTest, ExtensionTest) {
@ -29,9 +29,9 @@ TEST(AACAudioSpecificConfigTest, ExtensionTest) {
data.assign(buffer, buffer + sizeof(buffer)); data.assign(buffer, buffer + sizeof(buffer));
EXPECT_TRUE(aac_audio_specific_config.Parse(data)); EXPECT_TRUE(aac_audio_specific_config.Parse(data));
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 48000); EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(false));
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000); EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(true));
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2); EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(false));
} }
// Test implicit SBR with mono channel config. // Test implicit SBR with mono channel config.
@ -48,12 +48,12 @@ TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig0) {
EXPECT_TRUE(aac_audio_specific_config.Parse(data)); EXPECT_TRUE(aac_audio_specific_config.Parse(data));
// Test w/o implict SBR. // Test w/o implict SBR.
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 24000); EXPECT_EQ(24000u, aac_audio_specific_config.GetOutputSamplesPerSecond(false));
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 1); EXPECT_EQ(1u, aac_audio_specific_config.GetNumChannels(false));
// Test implicit SBR. // Test implicit SBR.
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000); EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(true));
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(true), 2); EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(true));
} }
// Tests implicit SBR with a stereo channel config. // Tests implicit SBR with a stereo channel config.
@ -67,12 +67,12 @@ TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig1) {
EXPECT_TRUE(aac_audio_specific_config.Parse(data)); EXPECT_TRUE(aac_audio_specific_config.Parse(data));
// Test w/o implict SBR. // Test w/o implict SBR.
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 24000); EXPECT_EQ(24000u, aac_audio_specific_config.GetOutputSamplesPerSecond(false));
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 2); EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(false));
// Test implicit SBR. // Test implicit SBR.
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(true), 48000); EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(true));
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(true), 2); EXPECT_EQ(2u, aac_audio_specific_config.GetNumChannels(true));
} }
TEST(AACAudioSpecificConfigTest, SixChannelTest) { TEST(AACAudioSpecificConfigTest, SixChannelTest) {
@ -83,8 +83,8 @@ TEST(AACAudioSpecificConfigTest, SixChannelTest) {
data.assign(buffer, buffer + sizeof(buffer)); data.assign(buffer, buffer + sizeof(buffer));
EXPECT_TRUE(aac_audio_specific_config.Parse(data)); EXPECT_TRUE(aac_audio_specific_config.Parse(data));
EXPECT_EQ(aac_audio_specific_config.GetOutputSamplesPerSecond(false), 48000); EXPECT_EQ(48000u, aac_audio_specific_config.GetOutputSamplesPerSecond(false));
EXPECT_EQ(aac_audio_specific_config.GetNumChannels(false), 6); EXPECT_EQ(6u, aac_audio_specific_config.GetNumChannels(false));
} }
TEST(AACAudioSpecificConfigTest, DataTooShortTest) { TEST(AACAudioSpecificConfigTest, DataTooShortTest) {

View File

@ -144,7 +144,7 @@ class BoxBuffer {
if (reader_) if (reader_)
return reader_->ReadChild(box); return reader_->ReadChild(box);
// The box is mandatory, i.e. the box size should not be 0. // 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)); CHECK(box->ReadWrite(this));
return true; return true;
} }

View File

@ -395,7 +395,7 @@ bool SampleDescription::ReadWrite(BoxBuffer* buffer) {
RCHECK(audio_entries.size() == count); RCHECK(audio_entries.size() == count);
} }
} else { } else {
DCHECK_LT(0, count); DCHECK_LT(0u, count);
if (type == kVideo) { if (type == kVideo) {
for (uint32 i = 0; i < count; ++i) for (uint32 i = 0; i < count; ++i)
RCHECK(video_entries[i].ReadWrite(buffer)); RCHECK(video_entries[i].ReadWrite(buffer));
@ -548,8 +548,8 @@ bool CompactSampleSize::ReadWrite(BoxBuffer* buffer) {
sizes[i] = size >> 4; sizes[i] = size >> 4;
sizes[i + 1] = size & 0x0F; sizes[i + 1] = size & 0x0F;
} else { } else {
DCHECK_LT(sizes[i], 16); DCHECK_LT(sizes[i], 16u);
DCHECK_LT(sizes[i + 1], 16); DCHECK_LT(sizes[i + 1], 16u);
uint8 size = (sizes[i] << 4) | sizes[i + 1]; uint8 size = (sizes[i] << 4) | sizes[i + 1];
RCHECK(buffer->ReadWriteUInt8(&size)); RCHECK(buffer->ReadWriteUInt8(&size));
} }
@ -778,7 +778,7 @@ HandlerReference::~HandlerReference() {}
FourCC HandlerReference::BoxType() const { return FOURCC_HDLR; } FourCC HandlerReference::BoxType() const { return FOURCC_HDLR; }
bool HandlerReference::ReadWrite(BoxBuffer* buffer) { bool HandlerReference::ReadWrite(BoxBuffer* buffer) {
FourCC hdlr_type; FourCC hdlr_type = FOURCC_NULL;
std::vector<uint8> handler_name; std::vector<uint8> handler_name;
if (!buffer->Reading()) { if (!buffer->Reading()) {
if (type == kVideo) { if (type == kVideo) {
@ -791,6 +791,7 @@ bool HandlerReference::ReadWrite(BoxBuffer* buffer) {
kAudioHandlerName + arraysize(kAudioHandlerName)); kAudioHandlerName + arraysize(kAudioHandlerName));
} else { } else {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return false;
} }
} }
RCHECK(FullBox::ReadWrite(buffer) && RCHECK(FullBox::ReadWrite(buffer) &&

View File

@ -787,9 +787,9 @@ TYPED_TEST(BoxDefinitionsTestGeneral, Empty) {
TypeParam box; TypeParam box;
LOG(INFO) << "Processing " << FourCCToString(box.BoxType()); LOG(INFO) << "Processing " << FourCCToString(box.BoxType());
if (this->IsOptional(&box)) { if (this->IsOptional(&box)) {
ASSERT_EQ(0, box.ComputeSize()); ASSERT_EQ(0u, box.ComputeSize());
} else { } else {
ASSERT_NE(0, box.ComputeSize()); ASSERT_NE(0u, box.ComputeSize());
} }
} }
@ -837,7 +837,7 @@ TEST_F(BoxDefinitionsTest, TrackFragmentHeader_NoSampleSize) {
TrackFragmentHeader tfhd_readback; TrackFragmentHeader tfhd_readback;
ASSERT_TRUE(ReadBack(&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; tfhd.default_sample_size = 0;
ASSERT_EQ(tfhd, tfhd_readback); ASSERT_EQ(tfhd, tfhd_readback);
} }

View File

@ -14,7 +14,7 @@ namespace mp4 {
BoxReader::BoxReader(const uint8* buf, size_t size) BoxReader::BoxReader(const uint8* buf, size_t size)
: BufferReader(buf, size), type_(FOURCC_NULL), scanned_(false) { : BufferReader(buf, size), type_(FOURCC_NULL), scanned_(false) {
DCHECK(buf); DCHECK(buf);
DCHECK_LT(0, size); DCHECK_LT(0u, size);
} }
BoxReader::~BoxReader() { BoxReader::~BoxReader() {
@ -29,7 +29,7 @@ BoxReader::~BoxReader() {
// static // static
BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf, BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf,
const int buf_size, const size_t buf_size,
bool* err) { bool* err) {
scoped_ptr<BoxReader> reader(new BoxReader(buf, buf_size)); scoped_ptr<BoxReader> reader(new BoxReader(buf, buf_size));
if (!reader->ReadHeader(err)) if (!reader->ReadHeader(err))
@ -52,7 +52,7 @@ BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf,
// static // static
bool BoxReader::StartTopLevelBox(const uint8* buf, bool BoxReader::StartTopLevelBox(const uint8* buf,
const int buf_size, const size_t buf_size,
FourCC* type, FourCC* type,
int* box_size, int* box_size,
bool* err) { bool* err) {

View File

@ -17,7 +17,7 @@
namespace media { namespace media {
namespace mp4 { namespace mp4 {
class Box; struct Box;
/// Class for reading MP4 boxes. /// Class for reading MP4 boxes.
class BoxReader : public BufferReader { class BoxReader : public BufferReader {
@ -35,7 +35,7 @@ class BoxReader : public BufferReader {
/// available in the buffer. For MDAT box only, a BoxReader object is /// available in the buffer. For MDAT box only, a BoxReader object is
/// returned as long as the box header is available. /// returned as long as the box header is available.
static BoxReader* ReadTopLevelBox(const uint8* buf, static BoxReader* ReadTopLevelBox(const uint8* buf,
const int buf_size, const size_t buf_size,
bool* err); bool* err);
/// Read the box header from the current buffer. /// 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 /// @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. /// sane, which does not imply that the entire box is in the buffer.
static bool StartTopLevelBox(const uint8* buf, static bool StartTopLevelBox(const uint8* buf,
const int buf_size, const size_t buf_size,
FourCC* type, FourCC* type,
int* box_size, int* box_size,
bool* err) WARN_UNUSED_RESULT; bool* err) WARN_UNUSED_RESULT;

View File

@ -59,7 +59,7 @@ TEST_F(ChunkInfoIteratorTest, EmptyChunkInfo) {
SampleToChunk sample_to_chunk; SampleToChunk sample_to_chunk;
ChunkInfoIterator iterator(sample_to_chunk); ChunkInfoIterator iterator(sample_to_chunk);
EXPECT_FALSE(iterator.IsValid()); EXPECT_FALSE(iterator.IsValid());
EXPECT_EQ(0, iterator.LastFirstChunk()); EXPECT_EQ(0u, iterator.LastFirstChunk());
} }
TEST_F(ChunkInfoIteratorTest, LastFirstChunk) { TEST_F(ChunkInfoIteratorTest, LastFirstChunk) {

View File

@ -34,7 +34,7 @@ bool CompositionOffsetIterator::IsValid() const {
sample_index_ < iterator_->sample_count; sample_index_ < iterator_->sample_count;
} }
uint32 CompositionOffsetIterator::SampleOffset(uint32 sample) const { int32 CompositionOffsetIterator::SampleOffset(uint32 sample) const {
uint32 current_sample = 0; uint32 current_sample = 0;
std::vector<CompositionOffset>::const_iterator it = std::vector<CompositionOffset>::const_iterator it =
composition_offset_table_.begin(); composition_offset_table_.begin();

View File

@ -33,10 +33,10 @@ class CompositionOffsetIterator {
bool IsValid() const; bool IsValid() const;
/// @return Sample offset for current sample. /// @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. /// @return Sample offset @a sample, 1-based.
uint32 SampleOffset(uint32 sample) const; int32 SampleOffset(uint32 sample) const;
/// @return Total number of samples. /// @return Total number of samples.
uint32 NumSamples() const; uint32 NumSamples() const;

View File

@ -13,13 +13,12 @@ namespace media {
namespace mp4 { namespace mp4 {
const CompositionOffset kCompositionOffsets[] = 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 { class CompositionOffsetIteratorTest : public testing::Test {
public: public:
CompositionOffsetIteratorTest() { CompositionOffsetIteratorTest() {
// Build composition offset table from kCompositionOffsets. // Build composition offset table from kCompositionOffsets.
uint32 composition_offset = 0;
uint32 length = sizeof(kCompositionOffsets) / sizeof(CompositionOffset); uint32 length = sizeof(kCompositionOffsets) / sizeof(CompositionOffset);
for (uint32 i = 0; i < length; ++i) { for (uint32 i = 0; i < length; ++i) {
for (uint32 j = 0; j < kCompositionOffsets[i].sample_count; ++j) { for (uint32 j = 0; j < kCompositionOffsets[i].sample_count; ++j) {
@ -35,7 +34,7 @@ class CompositionOffsetIteratorTest : public testing::Test {
} }
protected: protected:
std::vector<uint32> composition_offset_table_; std::vector<int32> composition_offset_table_;
CompositionTimeToSample composition_time_to_sample_; CompositionTimeToSample composition_time_to_sample_;
scoped_ptr<CompositionOffsetIterator> composition_offset_iterator_; scoped_ptr<CompositionOffsetIterator> composition_offset_iterator_;
@ -47,7 +46,7 @@ TEST_F(CompositionOffsetIteratorTest, EmptyCompositionTime) {
CompositionTimeToSample composition_time_to_sample; CompositionTimeToSample composition_time_to_sample;
CompositionOffsetIterator iterator(composition_time_to_sample); CompositionOffsetIterator iterator(composition_time_to_sample);
EXPECT_FALSE(iterator.IsValid()); EXPECT_FALSE(iterator.IsValid());
EXPECT_EQ(0, iterator.NumSamples()); EXPECT_EQ(0u, iterator.NumSamples());
} }
TEST_F(CompositionOffsetIteratorTest, NumSamples) { TEST_F(CompositionOffsetIteratorTest, NumSamples) {

View File

@ -47,7 +47,7 @@ TEST_F(DecodingTimeIteratorTest, EmptyDecodingTime) {
DecodingTimeToSample decoding_time_to_sample; DecodingTimeToSample decoding_time_to_sample;
DecodingTimeIterator iterator(decoding_time_to_sample); DecodingTimeIterator iterator(decoding_time_to_sample);
EXPECT_FALSE(iterator.IsValid()); EXPECT_FALSE(iterator.IsValid());
EXPECT_EQ(0, iterator.NumSamples()); EXPECT_EQ(0u, iterator.NumSamples());
} }
TEST_F(DecodingTimeIteratorTest, NumSamples) { TEST_F(DecodingTimeIteratorTest, NumSamples) {

View File

@ -5,6 +5,10 @@
# https://developers.google.com/open-source/licenses/bsd # 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': { 'target_defaults': {
'include_dirs': [ 'include_dirs': [
'../..', '../..',

View File

@ -14,7 +14,7 @@
#include "media/mp4/cenc.h" #include "media/mp4/cenc.h"
namespace { namespace {
const uint64 kInvalidTime = kuint64max; const int64 kInvalidTime = kint64max;
// Optimize sample entries table. If all values in |entries| are identical, // Optimize sample entries table. If all values in |entries| are identical,
// then |entries| is cleared and the value is assigned to |default_value|; // then |entries| is cleared and the value is assigned to |default_value|;

View File

@ -21,8 +21,8 @@ class MediaSample;
namespace mp4 { namespace mp4 {
class SegmentReference; struct SegmentReference;
class TrackFragment; struct TrackFragment;
/// MP4Fragmenter is responsible for the generation of MP4 fragments, i.e. traf /// MP4Fragmenter is responsible for the generation of MP4 fragments, i.e. traf
/// box and corresponding mdat box. The samples are also encrypted if encryption /// box and corresponding mdat box. The samples are also encrypted if encryption
@ -46,7 +46,7 @@ class MP4Fragmenter {
~MP4Fragmenter(); ~MP4Fragmenter();
/// Add a sample to the fragmenter. /// Add a sample to the fragmenter.
virtual Status AddSample(scoped_refptr<MediaSample> sample); Status AddSample(scoped_refptr<MediaSample> sample);
/// Initialize the fragment with default data. /// Initialize the fragment with default data.
void InitializeFragment(); void InitializeFragment();
@ -91,8 +91,8 @@ class MP4Fragmenter {
uint64 fragment_duration_; uint64 fragment_duration_;
bool normalize_presentation_timestamp_; bool normalize_presentation_timestamp_;
int64 presentation_start_time_; int64 presentation_start_time_;
uint64 earliest_presentation_time_; int64 earliest_presentation_time_;
uint64 first_sap_time_; int64 first_sap_time_;
int64 clear_time_; int64 clear_time_;
scoped_ptr<BufferWriter> data_; scoped_ptr<BufferWriter> data_;
scoped_ptr<BufferWriter> aux_data_; scoped_ptr<BufferWriter> aux_data_;

View File

@ -20,10 +20,10 @@ namespace media {
namespace mp4 { namespace mp4 {
struct Movie;
class BoxReader; class BoxReader;
class ProtectionSystemSpecificHeader;
class TrackRunIterator; class TrackRunIterator;
struct Movie;
struct ProtectionSystemSpecificHeader;
class MP4MediaParser : public MediaParser { class MP4MediaParser : public MediaParser {
public: public:

View File

@ -31,10 +31,10 @@ MP4Segmenter::MP4Segmenter(const MuxerOptions& options,
scoped_ptr<FileType> ftyp, scoped_ptr<FileType> ftyp,
scoped_ptr<Movie> moov) scoped_ptr<Movie> moov)
: options_(options), : options_(options),
fragment_buffer_(new BufferWriter()),
ftyp_(ftyp.Pass()), ftyp_(ftyp.Pass()),
moov_(moov.Pass()), moov_(moov.Pass()),
moof_(new MovieFragment()), moof_(new MovieFragment()),
fragment_buffer_(new BufferWriter()),
sidx_(new SegmentIndex()), sidx_(new SegmentIndex()),
segment_initialized_(false), segment_initialized_(false),
end_of_segment_(false) {} end_of_segment_(false) {}
@ -44,7 +44,7 @@ MP4Segmenter::~MP4Segmenter() { STLDeleteElements(&fragmenters_); }
Status MP4Segmenter::Initialize(EncryptorSource* encryptor_source, Status MP4Segmenter::Initialize(EncryptorSource* encryptor_source,
double clear_lead_in_seconds, double clear_lead_in_seconds,
const std::vector<MediaStream*>& streams) { const std::vector<MediaStream*>& streams) {
DCHECK_LT(0, streams.size()); DCHECK_LT(0u, streams.size());
moof_->header.sequence_number = 0; moof_->header.sequence_number = 0;
moof_->tracks.resize(streams.size()); moof_->tracks.resize(streams.size());

View File

@ -172,7 +172,6 @@ bool TrackRunIterator::Init() {
trak->media.information.sample_table.chunk_large_offset.offsets; trak->media.information.sample_table.chunk_large_offset.offsets;
int64 run_start_dts = 0; int64 run_start_dts = 0;
int64 run_data_offset = 0;
uint32 num_samples = sample_size.sample_count; uint32 num_samples = sample_size.sample_count;
uint32 num_chunks = chunk_offset_vector.size(); uint32 num_chunks = chunk_offset_vector.size();

View File

@ -5,6 +5,10 @@
# https://developers.google.com/open-source/licenses/bsd # 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': { 'target_defaults': {
'include_dirs': [ 'include_dirs': [
'../..', '../..',

View File

@ -206,7 +206,7 @@ TEST_P(PackagerTestBasic, MP4MuxerSingleSegmentEncrypted) {
// Expect the output to be encrypted. // Expect the output to be encrypted.
Demuxer demuxer(GetFullPath(kOutputVideo), decryptor_source_); Demuxer demuxer(GetFullPath(kOutputVideo), decryptor_source_);
ASSERT_OK(demuxer.Initialize()); ASSERT_OK(demuxer.Initialize());
ASSERT_EQ(1, demuxer.streams().size()); ASSERT_EQ(1u, demuxer.streams().size());
EXPECT_TRUE(demuxer.streams()[0]->info()->is_encrypted()); EXPECT_TRUE(demuxer.streams()[0]->info()->is_encrypted());
} }
@ -279,7 +279,7 @@ TEST_P(PackagerTest, MP4MuxerMultipleSegmentsUnencrypted) {
ASSERT_TRUE(base::ReadFileToString(segment_path, &segment_content)); ASSERT_TRUE(base::ReadFileToString(segment_path, &segment_content));
int bytes_written = file_util::AppendToFile( int bytes_written = file_util::AppendToFile(
output_path, segment_content.data(), segment_content.size()); output_path, segment_content.data(), segment_content.size());
ASSERT_EQ(segment_content.size(), bytes_written); ASSERT_EQ(segment_content.size(), static_cast<size_t>(bytes_written));
++segment_index; ++segment_index;
} }

View File

@ -41,7 +41,7 @@ TEST_F(StaticMpdBuilderTest, Video) {
Representation* video_representation = Representation* video_representation =
video_adaptation_set->AddRepresentation(video_media_info); video_adaptation_set->AddRepresentation(video_media_info);
ASSERT_TRUE(video_adaptation_set); ASSERT_TRUE(video_representation);
EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputVideo1)); EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputVideo1));
} }
@ -63,7 +63,7 @@ TEST_F(StaticMpdBuilderTest, VideoAndAudio) {
Representation* video_representation = Representation* video_representation =
video_adaptation_set->AddRepresentation(video_media_info); video_adaptation_set->AddRepresentation(video_media_info);
ASSERT_TRUE(video_adaptation_set); ASSERT_TRUE(video_representation);
EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputAudio1AndVideo1)); EXPECT_NO_FATAL_FAILURE(CheckMpd(kFileNameExpectedMpdOutputAudio1AndVideo1));
} }

View File

@ -17,7 +17,7 @@
namespace dash_packager { namespace dash_packager {
class ContentProtectionElement; struct ContentProtectionElement;
bool HasVODOnlyFields(const MediaInfo& media_info); bool HasVODOnlyFields(const MediaInfo& media_info);

View File

@ -171,7 +171,7 @@ bool XmlNode::AddChild(ScopedXmlPtr<xmlNode>::type child) {
// Reaching here means the ownership of |child| transfered to |node_|. // Reaching here means the ownership of |child| transfered to |node_|.
// Release the pointer so that it doesn't get destructed in this scope. // Release the pointer so that it doesn't get destructed in this scope.
child.release(); ignore_result(child.release());
return true; return true;
} }

View File

@ -7,6 +7,10 @@
# GYP file for any MPD generation targets. # GYP file for any MPD generation targets.
{ {
'variables': {
# Compile as chromium code to enable warnings and warnings-as-errors.
'chromium_code': 1,
},
'target_defaults': { 'target_defaults': {
'include_dirs': [ 'include_dirs': [
'..', '..',

View File

@ -5,6 +5,10 @@
# https://developers.google.com/open-source/licenses/bsd # 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': { 'target_defaults': {
'include_dirs': [ 'include_dirs': [
'.', '.',