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) { | |
308 bool expect_success = true; | |
ddorwin
2016/01/23 00:38:56
nit: Might be better for symmetry to put this insi
servolk
2016/02/10 18:58:50
Done (fixed also the inverse logic below for consi
| |
303 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 309 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
304 TEST_F(MP4StreamParserTest, HEVC_in_MP4_container) { | 310 EXPECT_MEDIA_LOG(VideoCodecLog("hevc")); |
ddorwin
2016/01/23 00:38:56
Is there a reason we don't have these for the audi
servolk
2016/02/10 18:58:50
In case of HEVC we do some trivial parsing of the
| |
311 #else | |
312 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.6401f")); | 328 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.6401f")); |
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.6401e")); | 349 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.6401e")); |
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 bool expect_success = true; | |
360 #if !BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
361 expect_success = false; | |
362 EXPECT_MEDIA_LOG(ErrorLog("Unsupported audio format 0x61632d33 in stsd box")); | |
363 #endif | |
364 | |
350 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); | 365 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); |
351 scoped_refptr<DecoderBuffer> buffer = | 366 scoped_refptr<DecoderBuffer> buffer = |
352 ReadTestDataFile("bear-ac3-only-frag.mp4"); | 367 ReadTestDataFile("bear-ac3-only-frag.mp4"); |
353 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 368 EXPECT_EQ(expect_success, |
369 AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | |
354 } | 370 } |
355 | 371 |
356 TEST_F(MP4StreamParserTest, DemuxingEAC3) { | 372 TEST_F(MP4StreamParserTest, DemuxingEAC3) { |
357 std::set<int> audio_object_types; | 373 std::set<int> audio_object_types; |
358 audio_object_types.insert(kEAC3); | 374 audio_object_types.insert(kEAC3); |
359 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 375 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
376 | |
377 bool expect_success = true; | |
378 #if !BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
379 expect_success = false; | |
380 EXPECT_MEDIA_LOG(ErrorLog("Unsupported audio format 0x65632d33 in stsd box")); | |
381 #endif | |
382 | |
360 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); | 383 InitializeParserAndExpectLiveness(DemuxerStream::LIVENESS_RECORDED); |
361 scoped_refptr<DecoderBuffer> buffer = | 384 scoped_refptr<DecoderBuffer> buffer = |
362 ReadTestDataFile("bear-eac3-only-frag.mp4"); | 385 ReadTestDataFile("bear-eac3-only-frag.mp4"); |
363 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 386 EXPECT_EQ(expect_success, |
387 AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | |
364 } | 388 } |
365 #endif | |
366 | 389 |
367 } // namespace mp4 | 390 } // namespace mp4 |
368 } // namespace media | 391 } // namespace media |
OLD | NEW |