diff --git a/packager/media/base/status.h b/packager/media/base/status.h index 209b479f42..210168a522 100644 --- a/packager/media/base/status.h +++ b/packager/media/base/status.h @@ -160,12 +160,6 @@ class Status { extern std::ostream& operator<<(std::ostream& os, const Status& x); -// Status success comparison. -// This is better than CHECK((val).ok()) because the embedded -// error string gets printed by the CHECK_EQ. -#define CHECK_OK(val) CHECK_EQ(Status::OK, (val)) -#define DCHECK_OK(val) DCHECK_EQ(Status::OK, (val)) - } // namespace media } // namespace edash_packager diff --git a/packager/media/base/status_unittest.cc b/packager/media/base/status_unittest.cc index 23591e7d57..d10e1c9b36 100644 --- a/packager/media/base/status_unittest.cc +++ b/packager/media/base/status_unittest.cc @@ -41,16 +41,6 @@ TEST(Status, ConstructorOK) { CheckStatus(Status(error::OK, "msg"), error::OK, ""); } -TEST(Status, CheckOK) { - CHECK_OK(Status()); -} - -TEST(Status, CheckOKDeath) { - Status status(error::UNKNOWN, "Status Unknown"); - ASSERT_DEATH(CHECK_OK(status), "Status Unknown"); - ASSERT_DEATH(CHECK_OK(status) << "Foo1234", "Foo1234"); -} - TEST(Status, SetError) { Status status; status.SetError(error::CANCELLED, "message"); diff --git a/packager/media/filters/h264_parser_unittest.cc b/packager/media/filters/h264_parser_unittest.cc index 98871bb0e1..3b5bc05c1d 100644 --- a/packager/media/filters/h264_parser_unittest.cc +++ b/packager/media/filters/h264_parser_unittest.cc @@ -4,10 +4,8 @@ #include -#include "packager/base/command_line.h" -#include "packager/base/files/memory_mapped_file.h" #include "packager/base/logging.h" -#include "packager/base/path_service.h" +#include "packager/base/stl_util.h" #include "packager/base/strings/string_number_conversions.h" #include "packager/media/test/test_data_util.h" #include "packager/media/filters/h264_parser.h" @@ -16,16 +14,13 @@ namespace edash_packager { namespace media { TEST(H264ParserTest, StreamFileParsing) { - base::FilePath file_path = GetTestDataFilePath("test-25fps.h264"); + std::vector buffer = ReadTestDataFile("test-25fps.h264"); + // Number of NALUs in the test stream to be parsed. int num_nalus = 759; - base::MemoryMappedFile stream; - ASSERT_TRUE(stream.Initialize(file_path)) - << "Couldn't open stream file: " << file_path.MaybeAsASCII(); - H264Parser parser; - parser.SetStream(stream.data(), stream.length()); + parser.SetStream(vector_as_array(&buffer), buffer.size()); // Parse until the end of stream/unsupported stream/error in stream is found. int num_parsed_nalus = 0; diff --git a/packager/media/formats/mp2t/es_parser_h264_unittest.cc b/packager/media/formats/mp2t/es_parser_h264_unittest.cc index 66c9dad6e6..b88ae1dc71 100644 --- a/packager/media/formats/mp2t/es_parser_h264_unittest.cc +++ b/packager/media/formats/mp2t/es_parser_h264_unittest.cc @@ -8,10 +8,8 @@ #include #include "packager/base/bind.h" -#include "packager/base/command_line.h" -#include "packager/base/files/memory_mapped_file.h" #include "packager/base/logging.h" -#include "packager/base/path_service.h" +#include "packager/base/stl_util.h" #include "packager/media/base/media_sample.h" #include "packager/media/base/timestamp.h" #include "packager/media/filters/h264_parser.h" @@ -150,19 +148,17 @@ class EsParserH264Test : public testing::Test { }; void EsParserH264Test::LoadStream(const char* filename) { - base::FilePath file_path = GetTestDataFilePath(filename); - - base::MemoryMappedFile stream_without_aud; - ASSERT_TRUE(stream_without_aud.Initialize(file_path)) - << "Couldn't open stream file: " << file_path.MaybeAsASCII(); + std::vector buffer = ReadTestDataFile(filename); // The input file does not have AUDs. - std::vector access_units_without_aud = GetAccessUnits( - stream_without_aud.data(), stream_without_aud.length()); + std::vector access_units_without_aud = + GetAccessUnits(vector_as_array(&buffer), buffer.size()); ASSERT_GT(access_units_without_aud.size(), 0u); - AppendAUD(stream_without_aud.data(), stream_without_aud.length(), + AppendAUD(vector_as_array(&buffer), + buffer.size(), access_units_without_aud, - stream_, access_units_); + stream_, + access_units_); } void EsParserH264Test::ProcessPesPackets( diff --git a/packager/media/formats/mp4/box_definitions.cc b/packager/media/formats/mp4/box_definitions.cc index cfb6a51275..7c4eadd36c 100644 --- a/packager/media/formats/mp4/box_definitions.cc +++ b/packager/media/formats/mp4/box_definitions.cc @@ -32,21 +32,24 @@ const uint32_t kVideoResolution = 0x00480000; // 72 dpi. const uint16_t kVideoFrameCount = 1; const uint16_t kVideoDepth = 0x0018; +// Utility functions to check if the 64bit integers can fit in 32bit integer. bool IsFitIn32Bits(uint64_t a) { return a <= std::numeric_limits::max(); } + bool IsFitIn32Bits(int64_t a) { return a <= std::numeric_limits::max() && a >= std::numeric_limits::min(); } -bool IsFitIn32Bits(uint64_t a, uint64_t b) { - return IsFitIn32Bits(a) && IsFitIn32Bits(b); + +template +bool IsFitIn32Bits(T1 a1, T2 a2) { + return IsFitIn32Bits(a1) && IsFitIn32Bits(a2); } -bool IsFitIn32Bits(uint64_t a, int64_t b) { - return IsFitIn32Bits(a) && IsFitIn32Bits(b); -} -bool IsFitIn32Bits(uint64_t a, uint64_t b, uint64_t c) { - return IsFitIn32Bits(a) && IsFitIn32Bits(b) && IsFitIn32Bits(c); + +template +bool IsFitIn32Bits(T1 a1, T2 a2, T3 a3) { + return IsFitIn32Bits(a1) && IsFitIn32Bits(a2) && IsFitIn32Bits(a3); } } // namespace diff --git a/packager/mpd/base/xml/xml_node.cc b/packager/mpd/base/xml/xml_node.cc index df6cb3be06..25d7441607 100644 --- a/packager/mpd/base/xml/xml_node.cc +++ b/packager/mpd/base/xml/xml_node.cc @@ -10,6 +10,7 @@ #include #include "packager/base/logging.h" +#include "packager/base/macros.h" #include "packager/base/stl_util.h" #include "packager/base/strings/string_number_conversions.h" #include "packager/mpd/base/media_info.pb.h"