| 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 "media/formats/mp4/mp4_stream_parser.h" | 5 #include "media/formats/mp4/mp4_stream_parser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 | 34 |
| 35 using ::testing::InSequence; | 35 using ::testing::InSequence; |
| 36 using ::testing::StrictMock; | 36 using ::testing::StrictMock; |
| 37 using base::TimeDelta; | 37 using base::TimeDelta; |
| 38 | 38 |
| 39 namespace media { | 39 namespace media { |
| 40 namespace mp4 { | 40 namespace mp4 { |
| 41 | 41 |
| 42 // Matchers for verifying common media log entry strings. | 42 // Matchers for verifying common media log entry strings. |
| 43 MATCHER_P(VideoCodecLog, codec_string, "") { | |
| 44 return CONTAINS_STRING(arg, "Video codec: " + std::string(codec_string)); | |
| 45 } | |
| 46 | |
| 47 MATCHER_P(AudioCodecLog, codec_string, "") { | |
| 48 return CONTAINS_STRING(arg, "Audio codec: " + std::string(codec_string)); | |
| 49 } | |
| 50 | |
| 51 MATCHER(SampleEncryptionInfoUnavailableLog, "") { | 43 MATCHER(SampleEncryptionInfoUnavailableLog, "") { |
| 52 return CONTAINS_STRING(arg, "Sample encryption info is not available."); | 44 return CONTAINS_STRING(arg, "Sample encryption info is not available."); |
| 53 } | 45 } |
| 54 | 46 |
| 55 MATCHER_P(ErrorLog, error_string, "") { | 47 MATCHER_P(ErrorLog, error_string, "") { |
| 56 return CONTAINS_STRING(arg, error_string); | 48 return CONTAINS_STRING(arg, error_string); |
| 57 } | 49 } |
| 58 | 50 |
| 59 class MP4StreamParserTest : public testing::Test { | 51 class MP4StreamParserTest : public testing::Test { |
| 60 public: | 52 public: |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 222 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
| 231 buffer->data_size(), | 223 buffer->data_size(), |
| 232 append_bytes)); | 224 append_bytes)); |
| 233 return true; | 225 return true; |
| 234 } | 226 } |
| 235 }; | 227 }; |
| 236 | 228 |
| 237 TEST_F(MP4StreamParserTest, UnalignedAppend) { | 229 TEST_F(MP4StreamParserTest, UnalignedAppend) { |
| 238 // Test small, non-segment-aligned appends (small enough to exercise | 230 // Test small, non-segment-aligned appends (small enough to exercise |
| 239 // incremental append system) | 231 // incremental append system) |
| 240 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | |
| 241 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | |
| 242 InitializeParser(); | 232 InitializeParser(); |
| 243 ParseMP4File("bear-1280x720-av_frag.mp4", 512); | 233 ParseMP4File("bear-1280x720-av_frag.mp4", 512); |
| 244 } | 234 } |
| 245 | 235 |
| 246 TEST_F(MP4StreamParserTest, BytewiseAppend) { | 236 TEST_F(MP4StreamParserTest, BytewiseAppend) { |
| 247 // Ensure no incremental errors occur when parsing | 237 // Ensure no incremental errors occur when parsing |
| 248 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | |
| 249 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | |
| 250 InitializeParser(); | 238 InitializeParser(); |
| 251 ParseMP4File("bear-1280x720-av_frag.mp4", 1); | 239 ParseMP4File("bear-1280x720-av_frag.mp4", 1); |
| 252 } | 240 } |
| 253 | 241 |
| 254 TEST_F(MP4StreamParserTest, MultiFragmentAppend) { | 242 TEST_F(MP4StreamParserTest, MultiFragmentAppend) { |
| 255 // Large size ensures multiple fragments are appended in one call (size is | 243 // Large size ensures multiple fragments are appended in one call (size is |
| 256 // larger than this particular test file) | 244 // larger than this particular test file) |
| 257 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | |
| 258 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | |
| 259 InitializeParser(); | 245 InitializeParser(); |
| 260 ParseMP4File("bear-1280x720-av_frag.mp4", 768432); | 246 ParseMP4File("bear-1280x720-av_frag.mp4", 768432); |
| 261 } | 247 } |
| 262 | 248 |
| 263 TEST_F(MP4StreamParserTest, Flush) { | 249 TEST_F(MP4StreamParserTest, Flush) { |
| 264 // Flush while reading sample data, then start a new stream. | 250 // Flush while reading sample data, then start a new stream. |
| 265 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")).Times(2); | |
| 266 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")).Times(2); | |
| 267 InitializeParser(); | 251 InitializeParser(); |
| 268 | 252 |
| 269 scoped_refptr<DecoderBuffer> buffer = | 253 scoped_refptr<DecoderBuffer> buffer = |
| 270 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 254 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
| 271 EXPECT_TRUE(AppendDataInPieces(buffer->data(), 65536, 512)); | 255 EXPECT_TRUE(AppendDataInPieces(buffer->data(), 65536, 512)); |
| 272 parser_->Flush(); | 256 parser_->Flush(); |
| 273 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 257 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
| 274 buffer->data_size(), | 258 buffer->data_size(), |
| 275 512)); | 259 512)); |
| 276 } | 260 } |
| 277 | 261 |
| 278 TEST_F(MP4StreamParserTest, Reinitialization) { | 262 TEST_F(MP4StreamParserTest, Reinitialization) { |
| 279 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")).Times(2); | |
| 280 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")).Times(2); | |
| 281 InitializeParser(); | 263 InitializeParser(); |
| 282 | 264 |
| 283 scoped_refptr<DecoderBuffer> buffer = | 265 scoped_refptr<DecoderBuffer> buffer = |
| 284 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 266 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
| 285 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 267 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
| 286 buffer->data_size(), | 268 buffer->data_size(), |
| 287 512)); | 269 512)); |
| 288 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 270 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
| 289 buffer->data_size(), | 271 buffer->data_size(), |
| 290 512)); | 272 512)); |
| 291 } | 273 } |
| 292 | 274 |
| 293 TEST_F(MP4StreamParserTest, UnknownDuration_V0_AllBitsSet) { | 275 TEST_F(MP4StreamParserTest, UnknownDuration_V0_AllBitsSet) { |
| 294 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | |
| 295 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | |
| 296 InitializeParser(); | 276 InitializeParser(); |
| 297 // 32 bit duration field in mvhd box, all bits set. | 277 // 32 bit duration field in mvhd box, all bits set. |
| 298 ParseMP4File( | 278 ParseMP4File( |
| 299 "bear-1280x720-av_frag-initsegment-mvhd_version_0-mvhd_duration_bits_all_" | 279 "bear-1280x720-av_frag-initsegment-mvhd_version_0-mvhd_duration_bits_all_" |
| 300 "set.mp4", | 280 "set.mp4", |
| 301 512); | 281 512); |
| 302 } | 282 } |
| 303 | 283 |
| 304 TEST_F(MP4StreamParserTest, MPEG2_AAC_LC) { | 284 TEST_F(MP4StreamParserTest, MPEG2_AAC_LC) { |
| 305 InSequence s; | 285 InSequence s; |
| 306 std::set<int> audio_object_types; | 286 std::set<int> audio_object_types; |
| 307 audio_object_types.insert(kISO_13818_7_AAC_LC); | 287 audio_object_types.insert(kISO_13818_7_AAC_LC); |
| 308 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 288 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
| 309 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.67")); | |
| 310 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | |
| 311 auto params = GetDefaultInitParametersExpectations(); | 289 auto params = GetDefaultInitParametersExpectations(); |
| 312 params.detected_video_track_count = 0; | 290 params.detected_video_track_count = 0; |
| 313 InitializeParserWithInitParametersExpectations(params); | 291 InitializeParserWithInitParametersExpectations(params); |
| 314 ParseMP4File("bear-mpeg2-aac-only_frag.mp4", 512); | 292 ParseMP4File("bear-mpeg2-aac-only_frag.mp4", 512); |
| 315 } | 293 } |
| 316 | 294 |
| 317 // Test that a moov box is not always required after Flush() is called. | 295 // Test that a moov box is not always required after Flush() is called. |
| 318 TEST_F(MP4StreamParserTest, NoMoovAfterFlush) { | 296 TEST_F(MP4StreamParserTest, NoMoovAfterFlush) { |
| 319 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | |
| 320 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | |
| 321 InitializeParser(); | 297 InitializeParser(); |
| 322 | 298 |
| 323 scoped_refptr<DecoderBuffer> buffer = | 299 scoped_refptr<DecoderBuffer> buffer = |
| 324 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 300 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
| 325 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 301 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
| 326 buffer->data_size(), | 302 buffer->data_size(), |
| 327 512)); | 303 512)); |
| 328 parser_->Flush(); | 304 parser_->Flush(); |
| 329 | 305 |
| 330 const int kFirstMoofOffset = 1307; | 306 const int kFirstMoofOffset = 1307; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 343 // Encrypted test mp4 files have non-zero duration and are treated as | 319 // Encrypted test mp4 files have non-zero duration and are treated as |
| 344 // recorded streams. | 320 // recorded streams. |
| 345 auto params = GetDefaultInitParametersExpectations(); | 321 auto params = GetDefaultInitParametersExpectations(); |
| 346 params.duration = base::TimeDelta::FromMicroseconds(23219); | 322 params.duration = base::TimeDelta::FromMicroseconds(23219); |
| 347 params.liveness = DemuxerStream::LIVENESS_RECORDED; | 323 params.liveness = DemuxerStream::LIVENESS_RECORDED; |
| 348 params.detected_video_track_count = 0; | 324 params.detected_video_track_count = 0; |
| 349 InitializeParserWithInitParametersExpectations(params); | 325 InitializeParserWithInitParametersExpectations(params); |
| 350 | 326 |
| 351 scoped_refptr<DecoderBuffer> buffer = | 327 scoped_refptr<DecoderBuffer> buffer = |
| 352 ReadTestDataFile("bear-1280x720-a_frag-cenc_missing-saiz-saio.mp4"); | 328 ReadTestDataFile("bear-1280x720-a_frag-cenc_missing-saiz-saio.mp4"); |
| 353 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")).Times(2); | |
| 354 EXPECT_MEDIA_LOG(SampleEncryptionInfoUnavailableLog()); | 329 EXPECT_MEDIA_LOG(SampleEncryptionInfoUnavailableLog()); |
| 355 EXPECT_FALSE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 330 EXPECT_FALSE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
| 356 } | 331 } |
| 357 | 332 |
| 358 // Test a file where all video samples start with an Access Unit | 333 // Test a file where all video samples start with an Access Unit |
| 359 // Delimiter (AUD) NALU. | 334 // Delimiter (AUD) NALU. |
| 360 TEST_F(MP4StreamParserTest, VideoSamplesStartWithAUDs) { | 335 TEST_F(MP4StreamParserTest, VideoSamplesStartWithAUDs) { |
| 361 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.4D4028")); | |
| 362 auto params = GetDefaultInitParametersExpectations(); | 336 auto params = GetDefaultInitParametersExpectations(); |
| 363 params.detected_audio_track_count = 0; | 337 params.detected_audio_track_count = 0; |
| 364 InitializeParserWithInitParametersExpectations(params); | 338 InitializeParserWithInitParametersExpectations(params); |
| 365 ParseMP4File("bear-1280x720-av_with-aud-nalus_frag.mp4", 512); | 339 ParseMP4File("bear-1280x720-av_with-aud-nalus_frag.mp4", 512); |
| 366 } | 340 } |
| 367 | 341 |
| 368 TEST_F(MP4StreamParserTest, HEVC_in_MP4_container) { | 342 TEST_F(MP4StreamParserTest, HEVC_in_MP4_container) { |
| 369 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 343 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 370 bool expect_success = true; | 344 bool expect_success = true; |
| 371 EXPECT_MEDIA_LOG(VideoCodecLog("hevc")); | |
| 372 #else | 345 #else |
| 373 bool expect_success = false; | 346 bool expect_success = false; |
| 374 EXPECT_MEDIA_LOG(ErrorLog("Parse unsupported video format hev1")); | 347 EXPECT_MEDIA_LOG(ErrorLog("Parse unsupported video format hev1")); |
| 375 #endif | 348 #endif |
| 376 auto params = GetDefaultInitParametersExpectations(); | 349 auto params = GetDefaultInitParametersExpectations(); |
| 377 params.duration = base::TimeDelta::FromMicroseconds(1002000); | 350 params.duration = base::TimeDelta::FromMicroseconds(1002000); |
| 378 params.liveness = DemuxerStream::LIVENESS_RECORDED; | 351 params.liveness = DemuxerStream::LIVENESS_RECORDED; |
| 379 params.detected_audio_track_count = 0; | 352 params.detected_audio_track_count = 0; |
| 380 InitializeParserWithInitParametersExpectations(params); | 353 InitializeParserWithInitParametersExpectations(params); |
| 381 | 354 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 394 // Encrypted test mp4 files have non-zero duration and are treated as | 367 // Encrypted test mp4 files have non-zero duration and are treated as |
| 395 // recorded streams. | 368 // recorded streams. |
| 396 auto params = GetDefaultInitParametersExpectations(); | 369 auto params = GetDefaultInitParametersExpectations(); |
| 397 params.duration = base::TimeDelta::FromMicroseconds(2736066); | 370 params.duration = base::TimeDelta::FromMicroseconds(2736066); |
| 398 params.liveness = DemuxerStream::LIVENESS_RECORDED; | 371 params.liveness = DemuxerStream::LIVENESS_RECORDED; |
| 399 params.detected_audio_track_count = 0; | 372 params.detected_audio_track_count = 0; |
| 400 InitializeParserWithInitParametersExpectations(params); | 373 InitializeParserWithInitParametersExpectations(params); |
| 401 | 374 |
| 402 scoped_refptr<DecoderBuffer> buffer = | 375 scoped_refptr<DecoderBuffer> buffer = |
| 403 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); | 376 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); |
| 404 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | |
| 405 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 377 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
| 406 } | 378 } |
| 407 | 379 |
| 408 TEST_F(MP4StreamParserTest, CencWithSampleEncryptionBox) { | 380 TEST_F(MP4StreamParserTest, CencWithSampleEncryptionBox) { |
| 409 // Encrypted test mp4 files have non-zero duration and are treated as | 381 // Encrypted test mp4 files have non-zero duration and are treated as |
| 410 // recorded streams. | 382 // recorded streams. |
| 411 auto params = GetDefaultInitParametersExpectations(); | 383 auto params = GetDefaultInitParametersExpectations(); |
| 412 params.duration = base::TimeDelta::FromMicroseconds(2736066); | 384 params.duration = base::TimeDelta::FromMicroseconds(2736066); |
| 413 params.liveness = DemuxerStream::LIVENESS_RECORDED; | 385 params.liveness = DemuxerStream::LIVENESS_RECORDED; |
| 414 params.detected_audio_track_count = 0; | 386 params.detected_audio_track_count = 0; |
| 415 InitializeParserWithInitParametersExpectations(params); | 387 InitializeParserWithInitParametersExpectations(params); |
| 416 | 388 |
| 417 scoped_refptr<DecoderBuffer> buffer = | 389 scoped_refptr<DecoderBuffer> buffer = |
| 418 ReadTestDataFile("bear-640x360-v_frag-cenc-senc.mp4"); | 390 ReadTestDataFile("bear-640x360-v_frag-cenc-senc.mp4"); |
| 419 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001E")); | |
| 420 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 391 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
| 421 } | 392 } |
| 422 | 393 |
| 423 TEST_F(MP4StreamParserTest, NaturalSizeWithoutPASP) { | 394 TEST_F(MP4StreamParserTest, NaturalSizeWithoutPASP) { |
| 424 auto params = GetDefaultInitParametersExpectations(); | 395 auto params = GetDefaultInitParametersExpectations(); |
| 425 params.duration = base::TimeDelta::FromMicroseconds(1000966); | 396 params.duration = base::TimeDelta::FromMicroseconds(1000966); |
| 426 params.liveness = DemuxerStream::LIVENESS_RECORDED; | 397 params.liveness = DemuxerStream::LIVENESS_RECORDED; |
| 427 params.detected_audio_track_count = 0; | 398 params.detected_audio_track_count = 0; |
| 428 InitializeParserWithInitParametersExpectations(params); | 399 InitializeParserWithInitParametersExpectations(params); |
| 429 | 400 |
| 430 scoped_refptr<DecoderBuffer> buffer = | 401 scoped_refptr<DecoderBuffer> buffer = |
| 431 ReadTestDataFile("bear-640x360-non_square_pixel-without_pasp.mp4"); | 402 ReadTestDataFile("bear-640x360-non_square_pixel-without_pasp.mp4"); |
| 432 | 403 |
| 433 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001E")); | |
| 434 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 404 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
| 435 EXPECT_EQ(gfx::Size(639, 360), video_decoder_config_.natural_size()); | 405 EXPECT_EQ(gfx::Size(639, 360), video_decoder_config_.natural_size()); |
| 436 } | 406 } |
| 437 | 407 |
| 438 TEST_F(MP4StreamParserTest, NaturalSizeWithPASP) { | 408 TEST_F(MP4StreamParserTest, NaturalSizeWithPASP) { |
| 439 auto params = GetDefaultInitParametersExpectations(); | 409 auto params = GetDefaultInitParametersExpectations(); |
| 440 params.duration = base::TimeDelta::FromMicroseconds(1000966); | 410 params.duration = base::TimeDelta::FromMicroseconds(1000966); |
| 441 params.liveness = DemuxerStream::LIVENESS_RECORDED; | 411 params.liveness = DemuxerStream::LIVENESS_RECORDED; |
| 442 params.detected_audio_track_count = 0; | 412 params.detected_audio_track_count = 0; |
| 443 InitializeParserWithInitParametersExpectations(params); | 413 InitializeParserWithInitParametersExpectations(params); |
| 444 | 414 |
| 445 scoped_refptr<DecoderBuffer> buffer = | 415 scoped_refptr<DecoderBuffer> buffer = |
| 446 ReadTestDataFile("bear-640x360-non_square_pixel-with_pasp.mp4"); | 416 ReadTestDataFile("bear-640x360-non_square_pixel-with_pasp.mp4"); |
| 447 | 417 |
| 448 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001E")); | |
| 449 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 418 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
| 450 EXPECT_EQ(gfx::Size(639, 360), video_decoder_config_.natural_size()); | 419 EXPECT_EQ(gfx::Size(639, 360), video_decoder_config_.natural_size()); |
| 451 } | 420 } |
| 452 | 421 |
| 453 TEST_F(MP4StreamParserTest, DemuxingAC3) { | 422 TEST_F(MP4StreamParserTest, DemuxingAC3) { |
| 454 std::set<int> audio_object_types; | 423 std::set<int> audio_object_types; |
| 455 audio_object_types.insert(kAC3); | 424 audio_object_types.insert(kAC3); |
| 456 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 425 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
| 457 | 426 |
| 458 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 427 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 EXPECT_EQ("mvex", FourCCToString(FOURCC_MVEX)); | 472 EXPECT_EQ("mvex", FourCCToString(FOURCC_MVEX)); |
| 504 | 473 |
| 505 // Invalid FOURCC should also print whenever ASCII values are printable. | 474 // Invalid FOURCC should also print whenever ASCII values are printable. |
| 506 EXPECT_EQ("fake", FourCCToString(static_cast<FourCC>(0x66616b65))); | 475 EXPECT_EQ("fake", FourCCToString(static_cast<FourCC>(0x66616b65))); |
| 507 | 476 |
| 508 // Invalid FORCC with non-printable values should not give error message. | 477 // Invalid FORCC with non-printable values should not give error message. |
| 509 EXPECT_EQ("0x66616b00", FourCCToString(static_cast<FourCC>(0x66616b00))); | 478 EXPECT_EQ("0x66616b00", FourCCToString(static_cast<FourCC>(0x66616b00))); |
| 510 } | 479 } |
| 511 | 480 |
| 512 TEST_F(MP4StreamParserTest, MediaTrackInfoSourcing) { | 481 TEST_F(MP4StreamParserTest, MediaTrackInfoSourcing) { |
| 513 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | |
| 514 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | |
| 515 InitializeParser(); | 482 InitializeParser(); |
| 516 ParseMP4File("bear-1280x720-av_frag.mp4", 4096); | 483 ParseMP4File("bear-1280x720-av_frag.mp4", 4096); |
| 517 | 484 |
| 518 EXPECT_EQ(media_tracks_->tracks().size(), 2u); | 485 EXPECT_EQ(media_tracks_->tracks().size(), 2u); |
| 519 const MediaTrack& video_track = *(media_tracks_->tracks()[0]); | 486 const MediaTrack& video_track = *(media_tracks_->tracks()[0]); |
| 520 EXPECT_EQ(video_track.type(), MediaTrack::Video); | 487 EXPECT_EQ(video_track.type(), MediaTrack::Video); |
| 521 EXPECT_EQ(video_track.bytestream_track_id(), 1); | 488 EXPECT_EQ(video_track.bytestream_track_id(), 1); |
| 522 EXPECT_EQ(video_track.kind(), "main"); | 489 EXPECT_EQ(video_track.kind(), "main"); |
| 523 EXPECT_EQ(video_track.label(), "VideoHandler"); | 490 EXPECT_EQ(video_track.label(), "VideoHandler"); |
| 524 EXPECT_EQ(video_track.language(), "und"); | 491 EXPECT_EQ(video_track.language(), "und"); |
| 525 | 492 |
| 526 const MediaTrack& audio_track = *(media_tracks_->tracks()[1]); | 493 const MediaTrack& audio_track = *(media_tracks_->tracks()[1]); |
| 527 EXPECT_EQ(audio_track.type(), MediaTrack::Audio); | 494 EXPECT_EQ(audio_track.type(), MediaTrack::Audio); |
| 528 EXPECT_EQ(audio_track.bytestream_track_id(), 2); | 495 EXPECT_EQ(audio_track.bytestream_track_id(), 2); |
| 529 EXPECT_EQ(audio_track.kind(), "main"); | 496 EXPECT_EQ(audio_track.kind(), "main"); |
| 530 EXPECT_EQ(audio_track.label(), "SoundHandler"); | 497 EXPECT_EQ(audio_track.label(), "SoundHandler"); |
| 531 EXPECT_EQ(audio_track.language(), "und"); | 498 EXPECT_EQ(audio_track.language(), "und"); |
| 532 } | 499 } |
| 533 | 500 |
| 534 TEST_F(MP4StreamParserTest, TextTrackDetection) { | 501 TEST_F(MP4StreamParserTest, TextTrackDetection) { |
| 535 auto params = GetDefaultInitParametersExpectations(); | 502 auto params = GetDefaultInitParametersExpectations(); |
| 536 params.detected_text_track_count = 1; | 503 params.detected_text_track_count = 1; |
| 537 InitializeParserWithInitParametersExpectations(params); | 504 InitializeParserWithInitParametersExpectations(params); |
| 538 | 505 |
| 539 scoped_refptr<DecoderBuffer> buffer = | 506 scoped_refptr<DecoderBuffer> buffer = |
| 540 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4"); | 507 ReadTestDataFile("bear-1280x720-avt_subt_frag.mp4"); |
| 541 | 508 |
| 542 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")); | |
| 543 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64001F")); | |
| 544 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); | 509 EXPECT_TRUE(AppendDataInPieces(buffer->data(), buffer->data_size(), 512)); |
| 545 } | 510 } |
| 546 | 511 |
| 547 TEST_F(MP4StreamParserTest, MultiTrackFile) { | 512 TEST_F(MP4StreamParserTest, MultiTrackFile) { |
| 548 auto params = GetDefaultInitParametersExpectations(); | 513 auto params = GetDefaultInitParametersExpectations(); |
| 549 params.duration = base::TimeDelta::FromMilliseconds(4248); | 514 params.duration = base::TimeDelta::FromMilliseconds(4248); |
| 550 params.liveness = DemuxerStream::LIVENESS_RECORDED; | 515 params.liveness = DemuxerStream::LIVENESS_RECORDED; |
| 551 params.detected_audio_track_count = 2; | 516 params.detected_audio_track_count = 2; |
| 552 params.detected_video_track_count = 2; | 517 params.detected_video_track_count = 2; |
| 553 InitializeParserWithInitParametersExpectations(params); | 518 InitializeParserWithInitParametersExpectations(params); |
| 554 EXPECT_MEDIA_LOG(VideoCodecLog("avc1.64000D")).Times(2); | |
| 555 EXPECT_MEDIA_LOG(AudioCodecLog("mp4a.40.2")).Times(2); | |
| 556 ParseMP4File("bbb-320x240-2video-2audio.mp4", 4096); | 519 ParseMP4File("bbb-320x240-2video-2audio.mp4", 4096); |
| 557 | 520 |
| 558 EXPECT_EQ(media_tracks_->tracks().size(), 4u); | 521 EXPECT_EQ(media_tracks_->tracks().size(), 4u); |
| 559 | 522 |
| 560 const MediaTrack& video_track1 = *(media_tracks_->tracks()[0]); | 523 const MediaTrack& video_track1 = *(media_tracks_->tracks()[0]); |
| 561 EXPECT_EQ(video_track1.type(), MediaTrack::Video); | 524 EXPECT_EQ(video_track1.type(), MediaTrack::Video); |
| 562 EXPECT_EQ(video_track1.bytestream_track_id(), 1); | 525 EXPECT_EQ(video_track1.bytestream_track_id(), 1); |
| 563 EXPECT_EQ(video_track1.kind(), "main"); | 526 EXPECT_EQ(video_track1.kind(), "main"); |
| 564 EXPECT_EQ(video_track1.label(), "VideoHandler"); | 527 EXPECT_EQ(video_track1.label(), "VideoHandler"); |
| 565 EXPECT_EQ(video_track1.language(), "und"); | 528 EXPECT_EQ(video_track1.language(), "und"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 581 const MediaTrack& audio_track2 = *(media_tracks_->tracks()[3]); | 544 const MediaTrack& audio_track2 = *(media_tracks_->tracks()[3]); |
| 582 EXPECT_EQ(audio_track2.type(), MediaTrack::Audio); | 545 EXPECT_EQ(audio_track2.type(), MediaTrack::Audio); |
| 583 EXPECT_EQ(audio_track2.bytestream_track_id(), 4); | 546 EXPECT_EQ(audio_track2.bytestream_track_id(), 4); |
| 584 EXPECT_EQ(audio_track2.kind(), ""); | 547 EXPECT_EQ(audio_track2.kind(), ""); |
| 585 EXPECT_EQ(audio_track2.label(), "SoundHandler"); | 548 EXPECT_EQ(audio_track2.label(), "SoundHandler"); |
| 586 EXPECT_EQ(audio_track2.language(), "und"); | 549 EXPECT_EQ(audio_track2.language(), "und"); |
| 587 } | 550 } |
| 588 | 551 |
| 589 } // namespace mp4 | 552 } // namespace mp4 |
| 590 } // namespace media | 553 } // namespace media |
| OLD | NEW |