| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "media/base/audio_decoder_config.h" | 13 #include "media/base/audio_decoder_config.h" |
| 14 #include "media/base/decoder_buffer.h" | 14 #include "media/base/decoder_buffer.h" |
| 15 #include "media/base/stream_parser_buffer.h" | 15 #include "media/base/stream_parser_buffer.h" |
| 16 #include "media/base/test_data_util.h" | 16 #include "media/base/test_data_util.h" |
| 17 #include "media/base/text_track_config.h" | 17 #include "media/base/text_track_config.h" |
| 18 #include "media/base/video_decoder_config.h" | 18 #include "media/base/video_decoder_config.h" |
| 19 #include "media/formats/mp4/es_descriptor.h" | 19 #include "media/formats/mp4/es_descriptor.h" |
| 20 #include "media/formats/mp4/mp4_stream_parser.h" | 20 #include "media/formats/mp4/mp4_stream_parser.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 22 |
| 23 using base::TimeDelta; | 23 using base::TimeDelta; |
| 24 | 24 |
| 25 namespace media { | 25 namespace media { |
| 26 namespace mp4 { | 26 namespace mp4 { |
| 27 | 27 |
| 28 // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed. | 28 static const char kCencInitDataType[] = "cenc"; |
| 29 static const char kMp4InitDataType[] = "video/mp4"; | |
| 30 | 29 |
| 31 class MP4StreamParserTest : public testing::Test { | 30 class MP4StreamParserTest : public testing::Test { |
| 32 public: | 31 public: |
| 33 MP4StreamParserTest() | 32 MP4StreamParserTest() |
| 34 : configs_received_(false), | 33 : configs_received_(false), |
| 35 lower_bound_( | 34 lower_bound_( |
| 36 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { | 35 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { |
| 37 std::set<int> audio_object_types; | 36 std::set<int> audio_object_types; |
| 38 audio_object_types.insert(kISO_14496_3); | 37 audio_object_types.insert(kISO_14496_3); |
| 39 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 38 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 return false; | 114 return false; |
| 116 } | 115 } |
| 117 | 116 |
| 118 lower_bound_ = second_highest_timestamp; | 117 lower_bound_ = second_highest_timestamp; |
| 119 return true; | 118 return true; |
| 120 } | 119 } |
| 121 | 120 |
| 122 void KeyNeededF(const std::string& type, | 121 void KeyNeededF(const std::string& type, |
| 123 const std::vector<uint8>& init_data) { | 122 const std::vector<uint8>& init_data) { |
| 124 DVLOG(1) << "KeyNeededF: " << init_data.size(); | 123 DVLOG(1) << "KeyNeededF: " << init_data.size(); |
| 125 EXPECT_EQ(kMp4InitDataType, type); | 124 EXPECT_EQ(kCencInitDataType, type); |
| 126 EXPECT_FALSE(init_data.empty()); | 125 EXPECT_FALSE(init_data.empty()); |
| 127 } | 126 } |
| 128 | 127 |
| 129 void NewSegmentF() { | 128 void NewSegmentF() { |
| 130 DVLOG(1) << "NewSegmentF"; | 129 DVLOG(1) << "NewSegmentF"; |
| 131 lower_bound_ = kNoDecodeTimestamp(); | 130 lower_bound_ = kNoDecodeTimestamp(); |
| 132 } | 131 } |
| 133 | 132 |
| 134 void EndOfSegmentF() { | 133 void EndOfSegmentF() { |
| 135 DVLOG(1) << "EndOfSegmentF()"; | 134 DVLOG(1) << "EndOfSegmentF()"; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // Delimiter (AUD) NALU. | 242 // Delimiter (AUD) NALU. |
| 244 TEST_F(MP4StreamParserTest, VideoSamplesStartWithAUDs) { | 243 TEST_F(MP4StreamParserTest, VideoSamplesStartWithAUDs) { |
| 245 ParseMP4File("bear-1280x720-av_with-aud-nalus_frag.mp4", 512); | 244 ParseMP4File("bear-1280x720-av_with-aud-nalus_frag.mp4", 512); |
| 246 } | 245 } |
| 247 | 246 |
| 248 // TODO(strobe): Create and test media which uses CENC auxiliary info stored | 247 // TODO(strobe): Create and test media which uses CENC auxiliary info stored |
| 249 // inside a private box | 248 // inside a private box |
| 250 | 249 |
| 251 } // namespace mp4 | 250 } // namespace mp4 |
| 252 } // namespace media | 251 } // namespace media |
| OLD | NEW |