Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 2549263002: FFmpegDemuxer should fall back to disabled streams for seeking (Closed)
Patch Set: Set start time to 0 for streams with unknown start time Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // Seeking to a position lower than the start time of either stream should 525 // Seeking to a position lower than the start time of either stream should
526 // prefer video stream for seeking. 526 // prefer video stream for seeking.
527 EXPECT_EQ(video, preferred_seeking_stream(base::TimeDelta())); 527 EXPECT_EQ(video, preferred_seeking_stream(base::TimeDelta()));
528 // Seeking to a position that has audio data, but not video, should prefer 528 // Seeking to a position that has audio data, but not video, should prefer
529 // the audio stream for seeking. 529 // the audio stream for seeking.
530 EXPECT_EQ(audio, preferred_seeking_stream(audio_start_time)); 530 EXPECT_EQ(audio, preferred_seeking_stream(audio_start_time));
531 // Seeking to a position where both audio and video streams have data should 531 // Seeking to a position where both audio and video streams have data should
532 // prefer the video stream for seeking. 532 // prefer the video stream for seeking.
533 EXPECT_EQ(video, preferred_seeking_stream(video_start_time)); 533 EXPECT_EQ(video, preferred_seeking_stream(video_start_time));
534 534
535 // A disabled stream should not be preferred for seeking. 535 // A disabled stream should be preferred only when there's no other viable
536 // option among enabled streams.
536 audio->set_enabled(false, base::TimeDelta()); 537 audio->set_enabled(false, base::TimeDelta());
537 EXPECT_EQ(video, preferred_seeking_stream(base::TimeDelta()));
538 EXPECT_EQ(video, preferred_seeking_stream(audio_start_time));
539 EXPECT_EQ(video, preferred_seeking_stream(video_start_time)); 538 EXPECT_EQ(video, preferred_seeking_stream(video_start_time));
539 // Audio stream is preferred, even though it is disabled, since video stream
540 // start time is higher than the seek target == audio_start_time in this case.
541 EXPECT_EQ(audio, preferred_seeking_stream(audio_start_time));
540 542
541 audio->set_enabled(true, base::TimeDelta()); 543 audio->set_enabled(true, base::TimeDelta());
542 video->set_enabled(false, base::TimeDelta()); 544 video->set_enabled(false, base::TimeDelta());
543 EXPECT_EQ(audio, preferred_seeking_stream(base::TimeDelta())); 545 EXPECT_EQ(audio, preferred_seeking_stream(audio_start_time));
546 EXPECT_EQ(audio, preferred_seeking_stream(video_start_time));
547
548 // When both audio and video streams are disabled and there's no enabled
549 // streams, then audio is preferred since it has lower start time.
550 audio->set_enabled(false, base::TimeDelta());
544 EXPECT_EQ(audio, preferred_seeking_stream(audio_start_time)); 551 EXPECT_EQ(audio, preferred_seeking_stream(audio_start_time));
545 EXPECT_EQ(audio, preferred_seeking_stream(video_start_time)); 552 EXPECT_EQ(audio, preferred_seeking_stream(video_start_time));
546 } 553 }
547 554
548 TEST_F(FFmpegDemuxerTest, Read_VideoPositiveStartTime) { 555 TEST_F(FFmpegDemuxerTest, Read_VideoPositiveStartTime) {
549 const int64_t kTimelineOffsetMs = 1352550896000LL; 556 const int64_t kTimelineOffsetMs = 1352550896000LL;
550 557
551 // Test the start time is the first timestamp of the video and audio stream. 558 // Test the start time is the first timestamp of the video and audio stream.
552 CreateDemuxer("nonzero-start-time.webm"); 559 CreateDemuxer("nonzero-start-time.webm");
553 InitializeDemuxerWithTimelineOffset( 560 InitializeDemuxerWithTimelineOffset(
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 EXPECT_EQ(DemuxerStream::AUDIO, stream->type()); 1471 EXPECT_EQ(DemuxerStream::AUDIO, stream->type());
1465 1472
1466 const AudioDecoderConfig& audio_config = stream->audio_decoder_config(); 1473 const AudioDecoderConfig& audio_config = stream->audio_decoder_config();
1467 EXPECT_EQ(kCodecFLAC, audio_config.codec()); 1474 EXPECT_EQ(kCodecFLAC, audio_config.codec());
1468 EXPECT_EQ(32, audio_config.bits_per_channel()); 1475 EXPECT_EQ(32, audio_config.bits_per_channel());
1469 EXPECT_EQ(CHANNEL_LAYOUT_MONO, audio_config.channel_layout()); 1476 EXPECT_EQ(CHANNEL_LAYOUT_MONO, audio_config.channel_layout());
1470 EXPECT_EQ(44100, audio_config.samples_per_second()); 1477 EXPECT_EQ(44100, audio_config.samples_per_second());
1471 EXPECT_EQ(kSampleFormatS32, audio_config.sample_format()); 1478 EXPECT_EQ(kSampleFormatS32, audio_config.sample_format());
1472 } 1479 }
1473 1480
1481 // Verify that FFmpeg demuxer falls back to choosing disabled streams for
1482 // seeking if there's no suitable enabled stream found.
1483 TEST_F(FFmpegDemuxerTest, Seek_FallbackToDisabledVideoStream) {
1484 // Input has only video stream, no audio.
1485 CreateDemuxer("bear-320x240-video-only.webm");
1486 InitializeDemuxer();
1487 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::AUDIO));
1488 DemuxerStream* vstream = demuxer_->GetStream(DemuxerStream::VIDEO);
1489 EXPECT_NE(nullptr, vstream);
1490 EXPECT_EQ(vstream, preferred_seeking_stream(base::TimeDelta()));
1491
1492 // Now pretend that video stream got disabled, e.g. due to current tab going
1493 // into background.
1494 vstream->set_enabled(false, base::TimeDelta());
1495 // Since there's no other enabled streams, the preferred seeking stream should
1496 // still be the video stream.
1497 EXPECT_EQ(vstream, preferred_seeking_stream(base::TimeDelta()));
1498 }
1499
1500 TEST_F(FFmpegDemuxerTest, Seek_FallbackToDisabledAudioStream) {
1501 CreateDemuxer("bear-320x240-audio-only.webm");
1502 InitializeDemuxer();
1503 DemuxerStream* astream = demuxer_->GetStream(DemuxerStream::AUDIO);
1504 EXPECT_NE(nullptr, astream);
1505 EXPECT_EQ(nullptr, demuxer_->GetStream(DemuxerStream::VIDEO));
1506 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta()));
1507
1508 // Now pretend that audio stream got disabled.
1509 astream->set_enabled(false, base::TimeDelta());
1510 // Since there's no other enabled streams, the preferred seeking stream should
1511 // still be the audio stream.
1512 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta()));
1513 }
1514
1474 } // namespace media 1515 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698