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

Unified Diff: media/base/android/media_source_player_unittest.cc

Issue 596093002: Let audio wait for video to finish prerolling after seek (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/media_source_player_unittest.cc
diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc
index 8050e34c2725bad12b3933dfbe42e2096f1cb0c1..a0e4d9ef26fbdea967f8caba67420da8439f17e1 100644
--- a/media/base/android/media_source_player_unittest.cc
+++ b/media/base/android/media_source_player_unittest.cc
@@ -484,7 +484,10 @@ class MediaSourcePlayerTest : public testing::Test {
void PrerollDecoderToTime(bool is_audio,
const base::TimeDelta& start_timestamp,
const base::TimeDelta& target_timestamp) {
- EXPECT_EQ(target_timestamp, player_.GetCurrentTime());
+ // It is possible that audio rolls past the |target_timestamp|. As a result,
+ // the current time may be larger than the |target_timestamp| for video as
+ // it may not be the clock manager.
+ EXPECT_TRUE(!is_audio || target_timestamp == player_.GetCurrentTime());
wolenetz 2014/09/24 20:39:04 nit: Can you more precisely capture the expectatio
qinmin 2014/09/24 22:49:50 added a boolean to indicate whether the decoder is
// |start_timestamp| must be smaller than |target_timestamp|.
EXPECT_LE(start_timestamp, target_timestamp);
DemuxerData data = is_audio ? CreateReadFromDemuxerAckForAudio(1) :
@@ -502,7 +505,7 @@ class MediaSourcePlayerTest : public testing::Test {
player_.OnDemuxerDataAvailable(data);
EXPECT_TRUE(GetMediaDecoderJob(is_audio)->is_decoding());
EXPECT_TRUE(GetMediaCodecBridge(is_audio));
- EXPECT_EQ(target_timestamp, player_.GetCurrentTime());
+ EXPECT_TRUE(!is_audio || target_timestamp == player_.GetCurrentTime());
wolenetz 2014/09/24 20:39:04 nit: ditto
qinmin 2014/09/24 22:49:50 is_clock_manager should handle the case. On 2014/
current_timestamp += 30;
WaitForDecodeDone(is_audio, !is_audio);
}
@@ -1613,21 +1616,11 @@ TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossReleaseAndStart) {
TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossConfigChange) {
SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
- // Test decoder job will resume media prerolling if interrupted by
- // |kConfigChanged| and OnDemuxerConfigsAvailable().
+ // Test decoder job will preroll the media to the seek position.
StartAudioDecoderJob();
SeekPlayerWithAbort(true, base::TimeDelta::FromMilliseconds(100));
EXPECT_TRUE(IsPrerolling(true));
- EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF());
-
- DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
wolenetz 2014/09/24 20:39:04 Do we have another test case that covers the case
qinmin 2014/09/24 22:49:50 Wierd, I didn't remember I made any change to this
-
- // In response to data request, simulate that demuxer signals config change by
- // sending an AU with |kConfigChanged|.
- DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(
- true, 0, configs);
- player_.OnDemuxerDataAvailable(data);
PrerollDecoderToTime(
true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100));
}
@@ -1654,6 +1647,58 @@ TEST_F(MediaSourcePlayerTest, PrerollContinuesAfterUnchangedConfigs) {
true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100));
}
+TEST_F(MediaSourcePlayerTest, AudioPrerollFinishesBeforeVideo) {
+ SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
+
+ // Test that after audio finishes prerolling, it will wait for video to finish
+ // prerolling before advancing together.
+ CreateNextTextureAndSetVideoSurface();
+ Start(CreateAudioVideoDemuxerConfigs());
+
+ // Initiate a seek.
+ base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(100);
+ player_.SeekTo(seek_position);
+ player_.OnDemuxerDataAvailable(CreateAbortedAck(true));
+ player_.OnDemuxerDataAvailable(CreateAbortedAck(false));
+ WaitForDecodeDone(true, true);
+
+ // Verify that the seek is requested.
+ EXPECT_EQ(1, demuxer_->num_seek_requests());
+ player_.OnDemuxerSeekDone(kNoTimestamp());
+ EXPECT_EQ(4, demuxer_->num_data_requests());
+ EXPECT_EQ(player_.GetCurrentTime().InMillisecondsF(), 100.0);
+ EXPECT_EQ(GetPrerollTimestamp().InMillisecondsF(), 100.0);
+
+ // Send both audio and video data to finish prefetching.
+ base::TimeDelta seek_ack_position = base::TimeDelta::FromMilliseconds(70);
+ DemuxerData audio_data = CreateReadFromDemuxerAckForAudio(0);
+ audio_data.access_units[0].timestamp = seek_ack_position;
+ DemuxerData video_data = CreateReadFromDemuxerAckForVideo();
+ video_data.access_units[0].timestamp = seek_ack_position;
+ player_.OnDemuxerDataAvailable(audio_data);
+ player_.OnDemuxerDataAvailable(video_data);
+ WaitForAudioDecodeDone();
+ WaitForVideoDecodeDone();
+
+ // Send audio data at and after the seek position. Audio should finish
+ // prerolling and stop decoding.
+ EXPECT_EQ(6, demuxer_->num_data_requests());
+ PrerollDecoderToTime(true, seek_position, seek_position);
+ EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding());
+ EXPECT_FALSE(IsPrerolling(true));
+ EXPECT_TRUE(IsPrerolling(false));
+
+ // Send video data to let video finish prerolling.
+ PrerollDecoderToTime(false, seek_position, seek_position);
+ EXPECT_FALSE(IsPrerolling(false));
+
+ // Both audio and video decoders should start decoding again.
+ player_.OnDemuxerDataAvailable(audio_data);
+ player_.OnDemuxerDataAvailable(video_data);
+ EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding());
+ EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding());
+}
+
TEST_F(MediaSourcePlayerTest, SimultaneousAudioVideoConfigChange) {
SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
« no previous file with comments | « media/base/android/media_source_player.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698