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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 MATCHER_P(AudioCodecLog, codec_string, "") { | 41 MATCHER_P(AudioCodecLog, codec_string, "") { |
42 return CONTAINS_STRING(arg, "Audio codec: " + std::string(codec_string)); | 42 return CONTAINS_STRING(arg, "Audio codec: " + std::string(codec_string)); |
43 } | 43 } |
44 | 44 |
45 MATCHER(AuxInfoUnavailableLog, "") { | 45 MATCHER(AuxInfoUnavailableLog, "") { |
46 return CONTAINS_STRING(arg, "Aux Info is not available."); | 46 return CONTAINS_STRING(arg, "Aux Info is not available."); |
47 } | 47 } |
48 | 48 |
| 49 MATCHER_P(ErrorLog, error_string, "") { |
| 50 return CONTAINS_STRING(arg, error_string); |
| 51 } |
| 52 |
49 class MP4StreamParserTest : public testing::Test { | 53 class MP4StreamParserTest : public testing::Test { |
50 public: | 54 public: |
51 MP4StreamParserTest() | 55 MP4StreamParserTest() |
52 : media_log_(new StrictMock<MockMediaLog>()), | 56 : media_log_(new StrictMock<MockMediaLog>()), |
53 configs_received_(false), | 57 configs_received_(false), |
54 lower_bound_( | 58 lower_bound_( |
55 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { | 59 DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max())) { |
56 std::set<int> audio_object_types; | 60 std::set<int> audio_object_types; |
57 audio_object_types.insert(kISO_14496_3); | 61 audio_object_types.insert(kISO_14496_3); |
58 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 62 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 EXPECT_FALSE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 297 EXPECT_FALSE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
294 } | 298 } |
295 | 299 |
296 // Test a file where all video samples start with an Access Unit | 300 // Test a file where all video samples start with an Access Unit |
297 // Delimiter (AUD) NALU. | 301 // Delimiter (AUD) NALU. |
298 TEST_F(MP4StreamParserTest, VideoSamplesStartWithAUDs) { | 302 TEST_F(MP4StreamParserTest, VideoSamplesStartWithAUDs) { |
299 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.4D4028")); | 303 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.4D4028")); |
300 ParseMP4File("bear-1280x720-av_with-aud-nalus_frag.mp4", 512); | 304 ParseMP4File("bear-1280x720-av_with-aud-nalus_frag.mp4", 512); |
301 } | 305 } |
302 | 306 |
| 307 TEST_F(MP4StreamParserTest, HEVC_in_MP4_container) { |
303 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 308 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
304 TEST_F(MP4StreamParserTest, HEVC_in_MP4_container) { | 309 bool expect_success = true; |
| 310 EXPECT_MEDIA_LOG(VideoCodecLog("hevc")); |
| 311 #else |
| 312 bool expect_success = false; |
| 313 EXPECT_MEDIA_LOG(ErrorLog("Parse unsupported video format hev1")); |
| 314 #endif |
305 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); | 315 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); |
306 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-hevc-frag.mp4"); | 316 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-hevc-frag.mp4"); |
307 EXPECT_MEDIA_LOG(VideoCodecLog("hevc")); | 317 EXPECT_EQ(expect_success, |
308 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 318 AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
309 } | 319 } |
310 #endif | |
311 | 320 |
312 TEST_F(MP4StreamParserTest, CENC) { | 321 TEST_F(MP4StreamParserTest, CENC) { |
313 // Encrypted test mp4 files have non-zero duration and are treated as | 322 // Encrypted test mp4 files have non-zero duration and are treated as |
314 // recorded streams. | 323 // recorded streams. |
315 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); | 324 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); |
316 | 325 |
317 scoped_refptr<DecoderBuffer> buffer = | 326 scoped_refptr<DecoderBuffer> buffer = |
318 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); | 327 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); |
319 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | 328 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); |
320 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 329 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
(...skipping 14 matching lines...) Expand all Loading... |
335 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); | 344 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); |
336 | 345 |
337 scoped_refptr<DecoderBuffer> buffer = | 346 scoped_refptr<DecoderBuffer> buffer = |
338 ReadTestDataFile("bear-640x360-non_square_pixel-with_pasp.mp4"); | 347 ReadTestDataFile("bear-640x360-non_square_pixel-with_pasp.mp4"); |
339 | 348 |
340 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001E")); | 349 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001E")); |
341 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 350 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
342 EXPECT_EQ(gfx::Size(639, 360), video_decoder_config_.natural_size()); | 351 EXPECT_EQ(gfx::Size(639, 360), video_decoder_config_.natural_size()); |
343 } | 352 } |
344 | 353 |
345 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
346 TEST_F(MP4StreamParserTest, DemuxingAC3) { | 354 TEST_F(MP4StreamParserTest, DemuxingAC3) { |
347 std::set<int> audio_object_types; | 355 std::set<int> audio_object_types; |
348 audio_object_types.insert(kAC3); | 356 audio_object_types.insert(kAC3); |
349 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 357 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
| 358 |
| 359 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 360 bool expect_success = true; |
| 361 #else |
| 362 bool expect_success = false; |
| 363 EXPECT_MEDIA_LOG(ErrorLog("Unsupported audio format 0x61632d33 in stsd box")); |
| 364 #endif |
| 365 |
350 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); | 366 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); |
351 scoped_refptr<DecoderBuffer> buffer = | 367 scoped_refptr<DecoderBuffer> buffer = |
352 ReadTestDataFile("bear-ac3-only-frag.mp4"); | 368 ReadTestDataFile("bear-ac3-only-frag.mp4"); |
353 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 369 EXPECT_EQ(expect_success, |
| 370 AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
354 } | 371 } |
355 | 372 |
356 TEST_F(MP4StreamParserTest, DemuxingEAC3) { | 373 TEST_F(MP4StreamParserTest, DemuxingEAC3) { |
357 std::set<int> audio_object_types; | 374 std::set<int> audio_object_types; |
358 audio_object_types.insert(kEAC3); | 375 audio_object_types.insert(kEAC3); |
359 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 376 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
| 377 |
| 378 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 379 bool expect_success = true; |
| 380 #else |
| 381 bool expect_success = false; |
| 382 EXPECT_MEDIA_LOG(ErrorLog("Unsupported audio format 0x65632d33 in stsd box")); |
| 383 #endif |
| 384 |
360 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); | 385 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); |
361 scoped_refptr<DecoderBuffer> buffer = | 386 scoped_refptr<DecoderBuffer> buffer = |
362 ReadTestDataFile("bear-eac3-only-frag.mp4"); | 387 ReadTestDataFile("bear-eac3-only-frag.mp4"); |
363 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 388 EXPECT_EQ(expect_success, |
| 389 AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
364 } | 390 } |
365 #endif | |
366 | 391 |
367 } // namespace mp4 | 392 } // namespace mp4 |
368 } // namespace media | 393 } // namespace media |
OLD | NEW |