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

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

Issue 1682923003: Rename browser side MediaCodec-based decoders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reformatted to make bots happy Created 4 years, 10 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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "media/base/android/media_codec_audio_decoder.h" 12 #include "media/base/android/audio_media_codec_decoder.h"
13 #include "media/base/android/media_codec_util.h" 13 #include "media/base/android/media_codec_util.h"
14 #include "media/base/android/media_codec_video_decoder.h"
15 #include "media/base/android/media_statistics.h" 14 #include "media/base/android/media_statistics.h"
16 #include "media/base/android/sdk_media_codec_bridge.h" 15 #include "media/base/android/sdk_media_codec_bridge.h"
17 #include "media/base/android/test_data_factory.h" 16 #include "media/base/android/test_data_factory.h"
18 #include "media/base/android/test_statistics.h" 17 #include "media/base/android/test_statistics.h"
18 #include "media/base/android/video_media_codec_decoder.h"
19 #include "media/base/timestamp_constants.h" 19 #include "media/base/timestamp_constants.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/gl/android/surface_texture.h" 21 #include "ui/gl/android/surface_texture.h"
22 22
23 namespace media { 23 namespace media {
24 24
25 namespace { 25 namespace {
26 26
27 const base::TimeDelta kDefaultTimeout = base::TimeDelta::FromMilliseconds(200); 27 const base::TimeDelta kDefaultTimeout = base::TimeDelta::FromMilliseconds(200);
28 const base::TimeDelta kAudioFramePeriod = 28 const base::TimeDelta kAudioFramePeriod =
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return true; 259 return true;
260 } 260 }
261 message_loop_.RunUntilIdle(); 261 message_loop_.RunUntilIdle();
262 } while (!is_timeout_expired()); 262 } while (!is_timeout_expired());
263 263
264 DCHECK(!timer.IsRunning()); 264 DCHECK(!timer.IsRunning());
265 return false; 265 return false;
266 } 266 }
267 267
268 void MediaCodecDecoderTest::CreateAudioDecoder() { 268 void MediaCodecDecoderTest::CreateAudioDecoder() {
269 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecAudioDecoder( 269 decoder_ = scoped_ptr<MediaCodecDecoder>(new AudioMediaCodecDecoder(
270 task_runner_, &frame_statistics_, 270 task_runner_, &frame_statistics_,
271 base::Bind(&MediaCodecDecoderTest::OnDataRequested, 271 base::Bind(&MediaCodecDecoderTest::OnDataRequested,
272 base::Unretained(this)), 272 base::Unretained(this)),
273 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), 273 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)),
274 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, 274 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained,
275 base::Unretained(this)), 275 base::Unretained(this)),
276 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), 276 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)),
277 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)), 277 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)),
278 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), 278 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)),
279 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, 279 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime,
280 base::Unretained(this)))); 280 base::Unretained(this))));
281 281
282 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, 282 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable,
283 base::Unretained(decoder_.get())); 283 base::Unretained(decoder_.get()));
284 } 284 }
285 285
286 void MediaCodecDecoderTest::CreateVideoDecoder() { 286 void MediaCodecDecoderTest::CreateVideoDecoder() {
287 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecVideoDecoder( 287 decoder_ = scoped_ptr<MediaCodecDecoder>(new VideoMediaCodecDecoder(
288 task_runner_, &frame_statistics_, 288 task_runner_, &frame_statistics_,
289 base::Bind(&MediaCodecDecoderTest::OnDataRequested, 289 base::Bind(&MediaCodecDecoderTest::OnDataRequested,
290 base::Unretained(this)), 290 base::Unretained(this)),
291 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), 291 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)),
292 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, 292 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained,
293 base::Unretained(this)), 293 base::Unretained(this)),
294 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), 294 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)),
295 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)), 295 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)),
296 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), 296 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)),
297 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, 297 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime,
(...skipping 15 matching lines...) Expand all
313 return; 313 return;
314 314
315 task_runner_->PostDelayedTask(FROM_HERE, base::Bind(data_available_cb_, data), 315 task_runner_->PostDelayedTask(FROM_HERE, base::Bind(data_available_cb_, data),
316 delay); 316 delay);
317 } 317 }
318 318
319 void MediaCodecDecoderTest::SetVideoSurface() { 319 void MediaCodecDecoderTest::SetVideoSurface() {
320 surface_texture_ = gfx::SurfaceTexture::Create(0); 320 surface_texture_ = gfx::SurfaceTexture::Create(0);
321 gfx::ScopedJavaSurface surface(surface_texture_.get()); 321 gfx::ScopedJavaSurface surface(surface_texture_.get());
322 ASSERT_NE(nullptr, decoder_.get()); 322 ASSERT_NE(nullptr, decoder_.get());
323 MediaCodecVideoDecoder* video_decoder = 323 VideoMediaCodecDecoder* video_decoder =
324 static_cast<MediaCodecVideoDecoder*>(decoder_.get()); 324 static_cast<VideoMediaCodecDecoder*>(decoder_.get());
325 video_decoder->SetVideoSurface(std::move(surface)); 325 video_decoder->SetVideoSurface(std::move(surface));
326 } 326 }
327 327
328 TEST_F(MediaCodecDecoderTest, AudioPrefetch) { 328 TEST_F(MediaCodecDecoderTest, AudioPrefetch) {
329 CreateAudioDecoder(); 329 CreateAudioDecoder();
330 330
331 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 331 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
332 SetDataFactory(scoped_ptr<TestDataFactory>(new AudioFactory(duration))); 332 SetDataFactory(scoped_ptr<TestDataFactory>(new AudioFactory(duration)));
333 333
334 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 334 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 decoder_->SetDemuxerConfigs(GetConfigs()); 439 decoder_->SetDemuxerConfigs(GetConfigs());
440 440
441 // Prepare the surface. 441 // Prepare the surface.
442 scoped_refptr<gfx::SurfaceTexture> surface_texture( 442 scoped_refptr<gfx::SurfaceTexture> surface_texture(
443 gfx::SurfaceTexture::Create(0)); 443 gfx::SurfaceTexture::Create(0));
444 gfx::ScopedJavaSurface surface(surface_texture.get()); 444 gfx::ScopedJavaSurface surface(surface_texture.get());
445 445
446 // Release the surface texture. 446 // Release the surface texture.
447 surface_texture = NULL; 447 surface_texture = NULL;
448 448
449 MediaCodecVideoDecoder* video_decoder = 449 VideoMediaCodecDecoder* video_decoder =
450 static_cast<MediaCodecVideoDecoder*>(decoder_.get()); 450 static_cast<VideoMediaCodecDecoder*>(decoder_.get());
451 video_decoder->SetVideoSurface(std::move(surface)); 451 video_decoder->SetVideoSurface(std::move(surface));
452 452
453 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); 453 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr));
454 } 454 }
455 455
456 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) { 456 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) {
457 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 457 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
458 458
459 CreateVideoDecoder(); 459 CreateVideoDecoder();
460 460
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 752
753 EXPECT_TRUE(decoder_->IsStopped()); 753 EXPECT_TRUE(decoder_->IsStopped());
754 EXPECT_TRUE(decoder_->IsCompleted()); 754 EXPECT_TRUE(decoder_->IsCompleted());
755 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); 755 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max());
756 756
757 // Check that the reported video size is the one from the in-stream configs. 757 // Check that the reported video size is the one from the in-stream configs.
758 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_); 758 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_);
759 } 759 }
760 760
761 } // namespace media 761 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_audio_decoder.cc ('k') | media/base/android/media_codec_player.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698