diff --git a/packager/app/mpd_generator.cc b/packager/app/mpd_generator.cc index bd05ea541a..b1d42d6460 100644 --- a/packager/app/mpd_generator.cc +++ b/packager/app/mpd_generator.cc @@ -10,6 +10,7 @@ #include "packager/base/strings/stringprintf.h" #include "packager/mpd/util/mpd_writer.h" +namespace edash_packager { namespace { const char kUsage[] = "MPD generation driver program.\n" @@ -53,7 +54,6 @@ ExitStatus RunMpdGenerator() { base::SplitString(FLAGS_input, ',', &input_files); - if (!FLAGS_base_urls.empty()) { base::SplitString(FLAGS_base_urls, ',', &base_urls); } @@ -76,9 +76,7 @@ ExitStatus RunMpdGenerator() { return kSuccess; } -} // namespace - -int main(int argc, char** argv) { +int MpdMain(int argc, char** argv) { google::SetUsageMessage(base::StringPrintf(kUsage, argv[0])); google::ParseCommandLineFlags(&argc, &argv, true); @@ -90,3 +88,10 @@ int main(int argc, char** argv) { return RunMpdGenerator(); } + +} // namespace +} // namespace edash_packager + +int main(int argc, char** argv) { + return edash_packager::MpdMain(argc, argv); +} diff --git a/packager/app/packager_main.cc b/packager/app/packager_main.cc index b7bacbe943..2b4efc5716 100644 --- a/packager/app/packager_main.cc +++ b/packager/app/packager_main.cc @@ -281,10 +281,7 @@ bool RunPackager(const StreamDescriptorList& stream_descriptors) { return true; } -} // namespace media -} // namespace edash_packager - -int main(int argc, char** argv) { +int PackagerMain(int argc, char** argv) { google::SetUsageMessage(base::StringPrintf(kUsage, argv[0])); google::ParseCommandLineFlags(&argc, &argv, true); if (argc < 2) { @@ -298,10 +295,17 @@ int main(int argc, char** argv) { } // TODO(tinskip): Make InsertStreamDescriptor a member of // StreamDescriptorList. - edash_packager::media::StreamDescriptorList stream_descriptors; + StreamDescriptorList stream_descriptors; for (int i = 1; i < argc; ++i) { if (!InsertStreamDescriptor(argv[i], &stream_descriptors)) return 1; } - return edash_packager::media::RunPackager(stream_descriptors) ? 0 : 1; + return RunPackager(stream_descriptors) ? 0 : 1; +} + +} // namespace media +} // namespace edash_packager + +int main(int argc, char** argv) { + return edash_packager::media::PackagerMain(argc, argv); } diff --git a/packager/media/base/closure_thread_unittest.cc b/packager/media/base/closure_thread_unittest.cc index 9365342a67..2c8c65e2bf 100644 --- a/packager/media/base/closure_thread_unittest.cc +++ b/packager/media/base/closure_thread_unittest.cc @@ -112,7 +112,9 @@ TEST_F(ClosureThreadTest, NotJoined) { } // Expect death if the thread is destroyed without being started. -TEST_F(ClosureThreadTest, NotStarted) { +// Note: This test is disabled since it causes memory leak in Debug mode as the +// thread object cannot be cleaned up due to the expected death. +TEST_F(ClosureThreadTest, DISABLED_NotStarted) { ASSERT_FALSE(thread_->HasBeenStarted()); ClosureThread* thread = thread_.release(); EXPECT_DEBUG_DEATH(delete thread, ".*Check failed: HasBeenStarted.*"); diff --git a/packager/media/base/container_names_unittest.cc b/packager/media/base/container_names_unittest.cc index 0334a5a81a..d69d6269ad 100644 --- a/packager/media/base/container_names_unittest.cc +++ b/packager/media/base/container_names_unittest.cc @@ -112,6 +112,7 @@ void TestFile(MediaContainerName expected, const base::FilePath& filename) { if (base::GetFileSize(filename, &actual_size) && actual_size < read_size) read_size = actual_size; int read = base::ReadFile(filename, buffer, read_size); + ASSERT_GT(read, 0) << filename.value(); // Now verify the type. EXPECT_EQ(expected, diff --git a/packager/media/base/producer_consumer_queue_unittest.cc b/packager/media/base/producer_consumer_queue_unittest.cc index f585928924..ef331fb791 100644 --- a/packager/media/base/producer_consumer_queue_unittest.cc +++ b/packager/media/base/producer_consumer_queue_unittest.cc @@ -12,6 +12,7 @@ #include "packager/media/base/producer_consumer_queue.h" #include "packager/media/base/status_test_util.h" +namespace edash_packager { namespace { const size_t kCapacity = 10u; const int64_t kTimeout = 100; // 0.1s. @@ -26,7 +27,6 @@ bool CheckTimeApproxEqual(int64_t time_in_milliseconds, } // namespace -namespace edash_packager { namespace media { TEST(ProducerConsumerQueueTest, CheckEmpty) { diff --git a/packager/media/base/widevine_key_source.cc b/packager/media/base/widevine_key_source.cc index c5bd13692b..37234c4986 100644 --- a/packager/media/base/widevine_key_source.cc +++ b/packager/media/base/widevine_key_source.cc @@ -162,6 +162,7 @@ WidevineKeySource::~WidevineKeySource() { start_key_production_.Signal(); key_production_thread_.Join(); } + STLDeleteValues(&encryption_key_map_); } Status WidevineKeySource::FetchKeys(const std::vector& content_id, diff --git a/packager/media/base/widevine_key_source_unittest.cc b/packager/media/base/widevine_key_source_unittest.cc index 4294348702..56e2a48950 100644 --- a/packager/media/base/widevine_key_source_unittest.cc +++ b/packager/media/base/widevine_key_source_unittest.cc @@ -15,6 +15,14 @@ #include "packager/media/base/status_test_util.h" #include "packager/media/base/widevine_key_source.h" +using ::testing::_; +using ::testing::DoAll; +using ::testing::InSequence; +using ::testing::Return; +using ::testing::SetArgPointee; +using ::testing::StrEq; + +namespace edash_packager { namespace { const char kServerUrl[] = "http://www.foo.com/getcontentkey"; const char kContentId[] = "ContentFoo"; @@ -106,13 +114,6 @@ std::string GetPsshDataFromPsshBox(const std::string& pssh_box) { } // namespace -using ::testing::_; -using ::testing::DoAll; -using ::testing::InSequence; -using ::testing::Return; -using ::testing::SetArgPointee; - -namespace edash_packager { namespace media { class MockRequestSigner : public RequestSigner { @@ -223,7 +224,8 @@ TEST_F(WidevineKeySourceTest, HttpPostFailure) { Base64Encode(kMockSignature).c_str(), kSignerName); const Status kMockStatus = Status::UNKNOWN; - EXPECT_CALL(*mock_http_fetcher_, Post(kServerUrl, expected_post_data, _)) + EXPECT_CALL(*mock_http_fetcher_, + Post(StrEq(kServerUrl), expected_post_data, _)) .WillOnce(Return(kMockStatus)); CreateWidevineKeySource(); diff --git a/packager/media/event/media_event.gyp b/packager/media/event/media_event.gyp index 61adf3fff1..936e9af837 100644 --- a/packager/media/event/media_event.gyp +++ b/packager/media/event/media_event.gyp @@ -26,6 +26,7 @@ # Depends on full protobuf to read/write with TextFormat. '../../third_party/protobuf/protobuf.gyp:protobuf_full_do_not_use', '../base/media_base.gyp:base', + '../file/file.gyp:file', ], }, { @@ -41,7 +42,6 @@ '../../testing/gtest.gyp:gtest_main', # Depends on full protobuf to read/write with TextFormat. '../../third_party/protobuf/protobuf.gyp:protobuf_full_do_not_use', - '../file/file.gyp:file', 'media_event', ], }, diff --git a/packager/media/filters/h264_parser.cc b/packager/media/filters/h264_parser.cc index af11b6fae2..3136ee3984 100644 --- a/packager/media/filters/h264_parser.cc +++ b/packager/media/filters/h264_parser.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "packager/media/filters/h264_parser.h" + #include "packager/base/logging.h" #include "packager/base/memory/scoped_ptr.h" #include "packager/base/stl_util.h" -#include "packager/media/filters/h264_parser.h" - namespace edash_packager { namespace media { diff --git a/packager/media/formats/mp2t/adts_header_unittest.cc b/packager/media/formats/mp2t/adts_header_unittest.cc index 4fb7c7bf31..479d1540d9 100644 --- a/packager/media/formats/mp2t/adts_header_unittest.cc +++ b/packager/media/formats/mp2t/adts_header_unittest.cc @@ -4,6 +4,7 @@ #include +#include "packager/base/compiler_specific.h" #include "packager/base/logging.h" #include "packager/base/strings/string_number_conversions.h" #include "packager/media/formats/mp2t/adts_header.h" diff --git a/packager/media/formats/mp4/box_definitions_unittest.cc b/packager/media/formats/mp4/box_definitions_unittest.cc index 955a5f24ee..e277a893a9 100644 --- a/packager/media/formats/mp4/box_definitions_unittest.cc +++ b/packager/media/formats/mp4/box_definitions_unittest.cc @@ -48,14 +48,14 @@ class BoxDefinitionsTestGeneral : public testing::Test { } bool ReadBack(Box* box) { - BoxReader* reader = CreateReader(); + scoped_ptr reader(CreateReader()); RCHECK(reader->ScanChildren() && reader->ReadChild(box)); return true; } // FourCC for VideoSampleEntry is not a constant, e.g. could be avc1, or encv. bool ReadBack(VideoSampleEntry* video) { - BoxReader* reader = CreateReader(); + scoped_ptr reader(CreateReader()); std::vector video_entries; RCHECK(reader->ReadAllChildren(&video_entries)); RCHECK(video_entries.size() == 1); @@ -65,7 +65,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // FourCC for AudioSampleEntry is not a constant, e.g. could be mp4a, or enca. bool ReadBack(AudioSampleEntry* audio) { - BoxReader* reader = CreateReader(); + scoped_ptr reader(CreateReader()); std::vector audio_entries; RCHECK(reader->ReadAllChildren(&audio_entries)); RCHECK(audio_entries.size() == 1); @@ -77,7 +77,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // be preset before scanning the box. bool ReadBack(SampleDescription* stsd) { stsd->type = kSampleDescriptionTrackType; - BoxReader* reader = CreateReader(); + scoped_ptr reader(CreateReader()); RCHECK(reader->ScanChildren() && reader->ReadChild(stsd)); return true; } @@ -85,7 +85,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // SampleTable contains SampleDescription, which cannot parse on its own. bool ReadBack(SampleTable* stbl) { stbl->description.type = kSampleDescriptionTrackType; - BoxReader* reader = CreateReader(); + scoped_ptr reader(CreateReader()); RCHECK(reader->ScanChildren() && reader->ReadChild(stbl)); return true; } @@ -93,7 +93,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { // MediaInformation contains SampleDescription, which cannot parse on its own. bool ReadBack(MediaInformation* minf) { minf->sample_table.description.type = kSampleDescriptionTrackType; - BoxReader* reader = CreateReader(); + scoped_ptr reader(CreateReader()); RCHECK(reader->ScanChildren() && reader->ReadChild(minf)); return true; } diff --git a/packager/media/formats/mp4/mp4.gyp b/packager/media/formats/mp4/mp4.gyp index 9727fd461a..f3ddfdb7f2 100644 --- a/packager/media/formats/mp4/mp4.gyp +++ b/packager/media/formats/mp4/mp4.gyp @@ -22,7 +22,6 @@ 'box_definitions.h', 'box_reader.cc', 'box_reader.h', - 'box_writer.h', 'cenc.cc', 'cenc.h', 'chunk_info_iterator.cc', diff --git a/packager/media/formats/wvm/wvm_media_parser.cc b/packager/media/formats/wvm/wvm_media_parser.cc index 1ec80d42f3..e018fdbc5a 100644 --- a/packager/media/formats/wvm/wvm_media_parser.cc +++ b/packager/media/formats/wvm/wvm_media_parser.cc @@ -97,11 +97,9 @@ WvmMediaParser::WvmMediaParser() : is_initialized_(false), pts_(0), dts_(0), index_program_id_(0), - sha_context_(new SHA256_CTX()), media_sample_(NULL), stream_id_count_(0), decryption_key_source_(NULL) { - SHA256_Init(sha_context_); } WvmMediaParser::~WvmMediaParser() {} @@ -540,11 +538,6 @@ bool WvmMediaParser::ParseIndexEntry() { if (index_data_.size() < kIndexVersion4HeaderSize) { return false; } - if (sha_context_ != NULL) { - if (SHA256_Update(sha_context_, &index_data_[0], index_data_.size()) != 1) { - return false; - } - } const uint8_t* read_ptr_index = &index_data_[0]; if (ntohlFromBuffer(read_ptr_index) != kIndexMagic) { diff --git a/packager/media/formats/wvm/wvm_media_parser.h b/packager/media/formats/wvm/wvm_media_parser.h index 29bf7c941a..38d903b8c8 100644 --- a/packager/media/formats/wvm/wvm_media_parser.h +++ b/packager/media/formats/wvm/wvm_media_parser.h @@ -6,8 +6,6 @@ #ifndef MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_ #define MEDIA_FORMATS_WVM_WVM_MEDIA_PARSER_H_ -#include - #include #include #include @@ -237,7 +235,6 @@ class WvmMediaParser : public MediaParser { uint64_t pts_; uint64_t dts_; uint8_t index_program_id_; - SHA256_CTX* sha_context_; scoped_refptr media_sample_; PrevSampleData prev_media_sample_data_; H264ByteToUnitStreamConverter byte_to_unit_stream_converter_; diff --git a/packager/mpd/base/xml/xml_node.cc b/packager/mpd/base/xml/xml_node.cc index e5e3b5241a..df6cb3be06 100644 --- a/packager/mpd/base/xml/xml_node.cc +++ b/packager/mpd/base/xml/xml_node.cc @@ -161,13 +161,13 @@ bool PopulateSegmentTimeline(const std::list& segment_infos, for (std::list::const_iterator it = segment_infos.begin(); it != segment_infos.end(); ++it) { - XmlNode* s_element = new XmlNode("S"); - s_element->SetIntegerAttribute("t", it->start_time); - s_element->SetIntegerAttribute("d", it->duration); + XmlNode s_element("S"); + s_element.SetIntegerAttribute("t", it->start_time); + s_element.SetIntegerAttribute("d", it->duration); if (it->repeat > 0) - s_element->SetIntegerAttribute("r", it->repeat); + s_element.SetIntegerAttribute("r", it->repeat); - CHECK(segment_timeline->AddChild(s_element->PassScopedPtr())); + CHECK(segment_timeline->AddChild(s_element.PassScopedPtr())); } return true; diff --git a/packager/mpd/mpd.gyp b/packager/mpd/mpd.gyp index 2ac813712b..cdd49e8268 100644 --- a/packager/mpd/mpd.gyp +++ b/packager/mpd/mpd.gyp @@ -13,7 +13,6 @@ 'targets': [ { 'target_name': 'media_info_proto', - 'type': 'static_library', 'sources': [ 'base/media_info.proto', diff --git a/packager/mpd/test/mpd_builder_test_helper.cc b/packager/mpd/test/mpd_builder_test_helper.cc index 39b65c3597..bd5ca5ee57 100644 --- a/packager/mpd/test/mpd_builder_test_helper.cc +++ b/packager/mpd/test/mpd_builder_test_helper.cc @@ -45,7 +45,7 @@ base::FilePath GetSchemaPath() { std::string GetPathContent(const base::FilePath& file_path) { std::string content; bool file_read_to_string = base::ReadFileToString(file_path, &content); - DCHECK(file_read_to_string); + DCHECK(file_read_to_string) << file_path.value(); return content; } diff --git a/packager/mpd/test/mpd_builder_test_helper.h b/packager/mpd/test/mpd_builder_test_helper.h index 8f6fdc0e96..33c3a1678b 100644 --- a/packager/mpd/test/mpd_builder_test_helper.h +++ b/packager/mpd/test/mpd_builder_test_helper.h @@ -9,9 +9,7 @@ #include -namespace base { -class FilePath; -} +#include "packager/base/files/file_path.h" namespace edash_packager {