OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 } | 527 } |
528 | 528 |
529 TEST_F(FFmpegDemuxerTest, Seeking_PreferredStreamSelection) { | 529 TEST_F(FFmpegDemuxerTest, Seeking_PreferredStreamSelection) { |
530 const int64_t kTimelineOffsetMs = 1352550896000LL; | 530 const int64_t kTimelineOffsetMs = 1352550896000LL; |
531 | 531 |
532 // Test the start time is the first timestamp of the video and audio stream. | 532 // Test the start time is the first timestamp of the video and audio stream. |
533 CreateDemuxer("nonzero-start-time.webm"); | 533 CreateDemuxer("nonzero-start-time.webm"); |
534 InitializeDemuxerWithTimelineOffset( | 534 InitializeDemuxerWithTimelineOffset( |
535 base::Time::FromJsTime(kTimelineOffsetMs)); | 535 base::Time::FromJsTime(kTimelineOffsetMs)); |
536 | 536 |
537 DemuxerStream* video = GetStream(DemuxerStream::VIDEO); | 537 FFmpegDemuxerStream* video = |
538 DemuxerStream* audio = GetStream(DemuxerStream::AUDIO); | 538 static_cast<FFmpegDemuxerStream*>(GetStream(DemuxerStream::VIDEO)); |
| 539 FFmpegDemuxerStream* audio = |
| 540 static_cast<FFmpegDemuxerStream*>(GetStream(DemuxerStream::AUDIO)); |
539 | 541 |
540 const base::TimeDelta video_start_time = | 542 const base::TimeDelta video_start_time = |
541 base::TimeDelta::FromMicroseconds(400000); | 543 base::TimeDelta::FromMicroseconds(400000); |
542 const base::TimeDelta audio_start_time = | 544 const base::TimeDelta audio_start_time = |
543 base::TimeDelta::FromMicroseconds(396000); | 545 base::TimeDelta::FromMicroseconds(396000); |
544 | 546 |
545 // Seeking to a position lower than the start time of either stream should | 547 // Seeking to a position lower than the start time of either stream should |
546 // prefer video stream for seeking. | 548 // prefer video stream for seeking. |
547 EXPECT_EQ(video, preferred_seeking_stream(base::TimeDelta())); | 549 EXPECT_EQ(video, preferred_seeking_stream(base::TimeDelta())); |
548 // Seeking to a position that has audio data, but not video, should prefer | 550 // Seeking to a position that has audio data, but not video, should prefer |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 EXPECT_EQ(kSampleFormatS32, audio_config.sample_format()); | 1488 EXPECT_EQ(kSampleFormatS32, audio_config.sample_format()); |
1487 } | 1489 } |
1488 | 1490 |
1489 // Verify that FFmpeg demuxer falls back to choosing disabled streams for | 1491 // Verify that FFmpeg demuxer falls back to choosing disabled streams for |
1490 // seeking if there's no suitable enabled stream found. | 1492 // seeking if there's no suitable enabled stream found. |
1491 TEST_F(FFmpegDemuxerTest, Seek_FallbackToDisabledVideoStream) { | 1493 TEST_F(FFmpegDemuxerTest, Seek_FallbackToDisabledVideoStream) { |
1492 // Input has only video stream, no audio. | 1494 // Input has only video stream, no audio. |
1493 CreateDemuxer("bear-320x240-video-only.webm"); | 1495 CreateDemuxer("bear-320x240-video-only.webm"); |
1494 InitializeDemuxer(); | 1496 InitializeDemuxer(); |
1495 EXPECT_EQ(nullptr, GetStream(DemuxerStream::AUDIO)); | 1497 EXPECT_EQ(nullptr, GetStream(DemuxerStream::AUDIO)); |
1496 DemuxerStream* vstream = GetStream(DemuxerStream::VIDEO); | 1498 FFmpegDemuxerStream* vstream = |
| 1499 static_cast<FFmpegDemuxerStream*>(GetStream(DemuxerStream::VIDEO)); |
1497 EXPECT_NE(nullptr, vstream); | 1500 EXPECT_NE(nullptr, vstream); |
1498 EXPECT_EQ(vstream, preferred_seeking_stream(base::TimeDelta())); | 1501 EXPECT_EQ(vstream, preferred_seeking_stream(base::TimeDelta())); |
1499 | 1502 |
1500 // Now pretend that video stream got disabled, e.g. due to current tab going | 1503 // Now pretend that video stream got disabled, e.g. due to current tab going |
1501 // into background. | 1504 // into background. |
1502 vstream->set_enabled(false, base::TimeDelta()); | 1505 vstream->set_enabled(false, base::TimeDelta()); |
1503 // Since there's no other enabled streams, the preferred seeking stream should | 1506 // Since there's no other enabled streams, the preferred seeking stream should |
1504 // still be the video stream. | 1507 // still be the video stream. |
1505 EXPECT_EQ(vstream, preferred_seeking_stream(base::TimeDelta())); | 1508 EXPECT_EQ(vstream, preferred_seeking_stream(base::TimeDelta())); |
1506 } | 1509 } |
1507 | 1510 |
1508 TEST_F(FFmpegDemuxerTest, Seek_FallbackToDisabledAudioStream) { | 1511 TEST_F(FFmpegDemuxerTest, Seek_FallbackToDisabledAudioStream) { |
1509 CreateDemuxer("bear-320x240-audio-only.webm"); | 1512 CreateDemuxer("bear-320x240-audio-only.webm"); |
1510 InitializeDemuxer(); | 1513 InitializeDemuxer(); |
1511 DemuxerStream* astream = GetStream(DemuxerStream::AUDIO); | 1514 FFmpegDemuxerStream* astream = |
| 1515 static_cast<FFmpegDemuxerStream*>(GetStream(DemuxerStream::AUDIO)); |
1512 EXPECT_NE(nullptr, astream); | 1516 EXPECT_NE(nullptr, astream); |
1513 EXPECT_EQ(nullptr, GetStream(DemuxerStream::VIDEO)); | 1517 EXPECT_EQ(nullptr, GetStream(DemuxerStream::VIDEO)); |
1514 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); | 1518 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); |
1515 | 1519 |
1516 // Now pretend that audio stream got disabled. | 1520 // Now pretend that audio stream got disabled. |
1517 astream->set_enabled(false, base::TimeDelta()); | 1521 astream->set_enabled(false, base::TimeDelta()); |
1518 // Since there's no other enabled streams, the preferred seeking stream should | 1522 // Since there's no other enabled streams, the preferred seeking stream should |
1519 // still be the audio stream. | 1523 // still be the audio stream. |
1520 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); | 1524 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); |
1521 } | 1525 } |
1522 | 1526 |
1523 } // namespace media | 1527 } // namespace media |
OLD | NEW |