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

Side by Side Diff: media/base/android/media_codec_decoder_unittest.cc

Issue 1242913004: MediaCodecPlayer implementation (stage 3 - browser seek and surface change) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-seek
Patch Set: Fixed SeekTo() followed by Release() and added uunit tests for this case 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "base/timer/timer.h" 8 #include "base/timer/timer.h"
9 #include "media/base/android/media_codec_audio_decoder.h" 9 #include "media/base/android/media_codec_audio_decoder.h"
10 #include "media/base/android/media_codec_bridge.h" 10 #include "media/base/android/media_codec_bridge.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 task_runner_->PostDelayedTask(FROM_HERE, base::Bind(data_available_cb_, data), 270 task_runner_->PostDelayedTask(FROM_HERE, base::Bind(data_available_cb_, data),
271 delay); 271 delay);
272 } 272 }
273 273
274 void MediaCodecDecoderTest::SetVideoSurface() { 274 void MediaCodecDecoderTest::SetVideoSurface() {
275 surface_texture_ = gfx::SurfaceTexture::Create(0); 275 surface_texture_ = gfx::SurfaceTexture::Create(0);
276 gfx::ScopedJavaSurface surface(surface_texture_.get()); 276 gfx::ScopedJavaSurface surface(surface_texture_.get());
277 ASSERT_NE(nullptr, decoder_.get()); 277 ASSERT_NE(nullptr, decoder_.get());
278 MediaCodecVideoDecoder* video_decoder = 278 MediaCodecVideoDecoder* video_decoder =
279 static_cast<MediaCodecVideoDecoder*>(decoder_.get()); 279 static_cast<MediaCodecVideoDecoder*>(decoder_.get());
280 video_decoder->SetPendingSurface(surface.Pass()); 280 video_decoder->SetVideoSurface(surface.Pass());
281 } 281 }
282 282
283 TEST_F(MediaCodecDecoderTest, AudioPrefetch) { 283 TEST_F(MediaCodecDecoderTest, AudioPrefetch) {
284 CreateAudioDecoder(); 284 CreateAudioDecoder();
285 285
286 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 286 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
287 SetDataFactory(scoped_ptr<TestDataFactory>(new AudioFactory(duration))); 287 SetDataFactory(scoped_ptr<TestDataFactory>(new AudioFactory(duration)));
288 288
289 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 289 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
290 base::Unretained(this), true)); 290 base::Unretained(this), true));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 decoder_->SetDemuxerConfigs(factory->GetConfigs()); 325 decoder_->SetDemuxerConfigs(factory->GetConfigs());
326 326
327 EXPECT_EQ(MediaCodecDecoder::CONFIG_OK, decoder_->Configure()); 327 EXPECT_EQ(MediaCodecDecoder::CONFIG_OK, decoder_->Configure());
328 } 328 }
329 329
330 TEST_F(MediaCodecDecoderTest, VideoConfigureNoParams) { 330 TEST_F(MediaCodecDecoderTest, VideoConfigureNoParams) {
331 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 331 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
332 332
333 CreateVideoDecoder(); 333 CreateVideoDecoder();
334 334
335 // decoder_->Configure() searches back for the key frame.
336 // We have to prefetch decoder.
337
338 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
339 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration)));
340
341 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
342 base::Unretained(this), true));
343
344 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
345 base::Unretained(this))));
346
347 SetVideoSurface();
348
335 // Cannot configure without config parameters. 349 // Cannot configure without config parameters.
336 EXPECT_EQ(MediaCodecDecoder::CONFIG_FAILURE, decoder_->Configure()); 350 EXPECT_EQ(MediaCodecDecoder::CONFIG_FAILURE, decoder_->Configure());
337 } 351 }
338 352
339 TEST_F(MediaCodecDecoderTest, VideoConfigureNoSurface) { 353 TEST_F(MediaCodecDecoderTest, VideoConfigureNoSurface) {
340 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 354 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
341 355
342 CreateVideoDecoder(); 356 CreateVideoDecoder();
343 357
344 // decoder_->Configure() searches back for the key frame. 358 // decoder_->Configure() searches back for the key frame.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // Prepare the surface. 396 // Prepare the surface.
383 scoped_refptr<gfx::SurfaceTexture> surface_texture( 397 scoped_refptr<gfx::SurfaceTexture> surface_texture(
384 gfx::SurfaceTexture::Create(0)); 398 gfx::SurfaceTexture::Create(0));
385 gfx::ScopedJavaSurface surface(surface_texture.get()); 399 gfx::ScopedJavaSurface surface(surface_texture.get());
386 400
387 // Release the surface texture. 401 // Release the surface texture.
388 surface_texture = NULL; 402 surface_texture = NULL;
389 403
390 MediaCodecVideoDecoder* video_decoder = 404 MediaCodecVideoDecoder* video_decoder =
391 static_cast<MediaCodecVideoDecoder*>(decoder_.get()); 405 static_cast<MediaCodecVideoDecoder*>(decoder_.get());
392 video_decoder->SetPendingSurface(surface.Pass()); 406 video_decoder->SetVideoSurface(surface.Pass());
393 407
394 EXPECT_EQ(MediaCodecDecoder::CONFIG_FAILURE, decoder_->Configure()); 408 EXPECT_EQ(MediaCodecDecoder::CONFIG_FAILURE, decoder_->Configure());
395 } 409 }
396 410
397 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) { 411 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) {
398 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 412 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
399 413
400 CreateVideoDecoder(); 414 CreateVideoDecoder();
401 415
402 // decoder_->Configure() searches back for the key frame. 416 // decoder_->Configure() searches back for the key frame.
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 decoder_->RequestToStop(); 641 decoder_->RequestToStop();
628 642
629 EXPECT_TRUE(WaitForCondition( 643 EXPECT_TRUE(WaitForCondition(
630 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)))); 644 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this))));
631 645
632 EXPECT_TRUE(decoder_->IsStopped()); 646 EXPECT_TRUE(decoder_->IsStopped());
633 EXPECT_FALSE(decoder_->IsCompleted()); 647 EXPECT_FALSE(decoder_->IsCompleted());
634 } 648 }
635 649
636 } // namespace media 650 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698