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

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

Issue 1287423004: MediaCodecPlayer implementation (stage 5 - reconfiguration) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-cleanuptest
Patch Set: Made a helper method for advancing AU queue, report starvation if cannot advance whether we drain d… Created 5 years, 4 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
Index: media/base/android/media_codec_decoder_unittest.cc
diff --git a/media/base/android/media_codec_decoder_unittest.cc b/media/base/android/media_codec_decoder_unittest.cc
index aabb9ba88b725b1e2195625d8ec79a807618c3f8..41940d6171ed221996b07440e8619fdbd8f4791f 100644
--- a/media/base/android/media_codec_decoder_unittest.cc
+++ b/media/base/android/media_codec_decoder_unittest.cc
@@ -149,6 +149,7 @@ class MediaCodecDecoderTest : public testing::Test {
// Decoder callbacks.
void OnDataRequested();
void OnStarvation() { is_starved_ = true; }
+ void OnDecoderDrained() {}
void OnStopDone() { is_stopped_ = true; }
void OnError() { DVLOG(0) << "MediaCodecDecoderTest::" << __FUNCTION__; }
void OnUpdateCurrentTime(base::TimeDelta now_playing,
@@ -169,12 +170,16 @@ class MediaCodecDecoderTest : public testing::Test {
}
}
- void OnVideoSizeChanged(const gfx::Size& video_size) {}
+ void OnVideoSizeChanged(const gfx::Size& video_size) {
+ video_size_ = video_size;
+ }
+
void OnVideoCodecCreated() {}
scoped_ptr<MediaCodecDecoder> decoder_;
scoped_ptr<TestDataFactory> data_factory_;
Minimax<base::TimeDelta> pts_stat_;
+ gfx::Size video_size_;
private:
bool is_timeout_expired() const { return is_timeout_expired_; }
@@ -235,6 +240,8 @@ void MediaCodecDecoderTest::CreateAudioDecoder() {
task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested,
base::Unretained(this)),
base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)),
+ base::Bind(&MediaCodecDecoderTest::OnDecoderDrained,
+ base::Unretained(this)),
base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)),
base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)),
base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime,
@@ -249,6 +256,8 @@ void MediaCodecDecoderTest::CreateVideoDecoder() {
task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested,
base::Unretained(this)),
base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)),
+ base::Bind(&MediaCodecDecoderTest::OnDecoderDrained,
+ base::Unretained(this)),
base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)),
base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)),
base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime,
@@ -660,4 +669,59 @@ TEST_F(MediaCodecDecoderTest, DISABLED_AudioStarvationAndStop) {
EXPECT_FALSE(decoder_->IsCompleted());
}
+TEST_F(MediaCodecDecoderTest, VideoFirstUnitIsReconfig) {
+ SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
+
+ // Test that the kConfigChanged unit that comes before the first data unit
+ // gets processed, i.e. is not lost.
+
+ CreateVideoDecoder();
+
+ base::TimeDelta duration = base::TimeDelta::FromMilliseconds(200);
+ base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1000);
+ SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration)));
+
+ // Ask factory to produce initial configuration unit. The configuraton will
+ // be factory.GetConfigs().
+ data_factory_->RequestInitialConfigs();
+
+ // Create am alternative configuration (we just alter video size).
+ DemuxerConfigs alt_configs = data_factory_->GetConfigs();
+ alt_configs.video_size = gfx::Size(100, 100);
+
+ // Pass the alternative configuration to decoder.
+ decoder_->SetDemuxerConfigs(alt_configs);
+
+ // Prefetch.
+ decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
+ base::Unretained(this), true));
+
+ EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
+ base::Unretained(this))));
+
+ // Current implementation reports the new video size after
+ // SetDemuxerConfigs(), verify that it is alt size.
+ EXPECT_EQ(alt_configs.video_size, video_size_);
+
+ SetVideoSurface();
+
+ // Configure.
+ EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure());
+
+ // Start.
+ EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0)));
+
+ // Wait for completion.
+ EXPECT_TRUE(WaitForCondition(
+ base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)),
+ timeout));
+
+ EXPECT_TRUE(decoder_->IsStopped());
+ EXPECT_TRUE(decoder_->IsCompleted());
+ EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max());
+
+ // Check that the reported video size is the one from the in-stream configs.
+ EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_);
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698