| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/bind.h" |
| 6 #include "base/logging.h" |
| 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "base/timer/timer.h" |
| 9 #include "media/base/android/media_codec_audio_decoder.h" |
| 10 #include "media/base/android/media_codec_bridge.h" |
| 11 #include "media/base/android/media_codec_video_decoder.h" |
| 12 #include "media/base/android/test_data_factory.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/gl/android/surface_texture.h" |
| 15 |
| 16 namespace media { |
| 17 |
| 18 // Helper macro to skip the test if MediaCodecBridge isn't available. |
| 19 #define SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE() \ |
| 20 do { \ |
| 21 if (!MediaCodecBridge::IsAvailable()) { \ |
| 22 VLOG(0) << "Could not run test - not supported on device."; \ |
| 23 return; \ |
| 24 } \ |
| 25 } while (0) |
| 26 |
| 27 namespace { |
| 28 |
| 29 const base::TimeDelta kDefaultTimeout = base::TimeDelta::FromMilliseconds(200); |
| 30 const base::TimeDelta kAudioFramePeriod = base::TimeDelta::FromMilliseconds(20); |
| 31 const base::TimeDelta kVideoFramePeriod = base::TimeDelta::FromMilliseconds(20); |
| 32 |
| 33 class AudioFactory : public TestDataFactory { |
| 34 public: |
| 35 AudioFactory(const base::TimeDelta& duration); |
| 36 DemuxerConfigs GetConfigs(); |
| 37 |
| 38 protected: |
| 39 void ModifyAccessUnit(int index_in_chunk, AccessUnit* unit) override; |
| 40 }; |
| 41 |
| 42 class VideoFactory : public TestDataFactory { |
| 43 public: |
| 44 VideoFactory(const base::TimeDelta& duration); |
| 45 DemuxerConfigs GetConfigs(); |
| 46 |
| 47 protected: |
| 48 void ModifyAccessUnit(int index_in_chunk, AccessUnit* unit) override; |
| 49 }; |
| 50 |
| 51 AudioFactory::AudioFactory(const base::TimeDelta& duration) |
| 52 : TestDataFactory("vorbis-packet-%d", duration, kAudioFramePeriod) { |
| 53 } |
| 54 |
| 55 DemuxerConfigs AudioFactory::GetConfigs() { |
| 56 return TestDataFactory::CreateAudioConfigs(kCodecVorbis, duration_); |
| 57 } |
| 58 |
| 59 void AudioFactory::ModifyAccessUnit(int index_in_chunk, AccessUnit* unit) { |
| 60 // Vorbis needs 4 extra bytes padding on Android to decode properly. Check |
| 61 // NuMediaExtractor.cpp in Android source code. |
| 62 uint8 padding[4] = {0xff, 0xff, 0xff, 0xff}; |
| 63 unit->data.insert(unit->data.end(), padding, padding + 4); |
| 64 } |
| 65 |
| 66 VideoFactory::VideoFactory(const base::TimeDelta& duration) |
| 67 : TestDataFactory("h264-320x180-frame-%d", duration, kVideoFramePeriod) { |
| 68 } |
| 69 |
| 70 DemuxerConfigs VideoFactory::GetConfigs() { |
| 71 return TestDataFactory::CreateVideoConfigs(kCodecH264, duration_, |
| 72 gfx::Size(320, 180)); |
| 73 } |
| 74 |
| 75 void VideoFactory::ModifyAccessUnit(int index_in_chunk, AccessUnit* unit) { |
| 76 // The frames are taken from High profile and some are B-frames. |
| 77 // The first 4 frames appear in the file in the following order: |
| 78 // |
| 79 // Frames: I P B P |
| 80 // Decoding order: 0 1 2 3 |
| 81 // Presentation order: 0 2 1 4(3) |
| 82 // |
| 83 // I keep the last PTS to be 3 for simplicity. |
| 84 |
| 85 // Swap pts for second and third frames. |
| 86 if (index_in_chunk == 1) // second frame |
| 87 unit->timestamp += frame_period_; |
| 88 if (index_in_chunk == 2) // third frame |
| 89 unit->timestamp -= frame_period_; |
| 90 |
| 91 if (index_in_chunk == 0) |
| 92 unit->is_key_frame = true; |
| 93 } |
| 94 |
| 95 // Class that computes statistics: number of calls, minimum and maximum values. |
| 96 // It is used for PTS statistics to verify that playback did actually happen. |
| 97 |
| 98 template <typename T> |
| 99 class Minimax { |
| 100 public: |
| 101 Minimax() : num_values_(0) {} |
| 102 ~Minimax() {} |
| 103 |
| 104 void AddValue(const T& value) { |
| 105 ++num_values_; |
| 106 if (value < min_) |
| 107 min_ = value; |
| 108 else if (max_ < value) |
| 109 max_ = value; |
| 110 } |
| 111 |
| 112 const T& min() const { return min_; } |
| 113 const T& max() const { return max_; } |
| 114 int num_values() const { return num_values_; } |
| 115 |
| 116 private: |
| 117 T min_; |
| 118 T max_; |
| 119 int num_values_; |
| 120 }; |
| 121 |
| 122 } // namespace (anonymous) |
| 123 |
| 124 // The test fixture for MediaCodecDecoder |
| 125 |
| 126 class MediaCodecDecoderTest : public testing::Test { |
| 127 public: |
| 128 MediaCodecDecoderTest(); |
| 129 ~MediaCodecDecoderTest() override; |
| 130 |
| 131 // Conditions we wait for. |
| 132 bool is_prefetched() const { return is_prefetched_; } |
| 133 bool is_stopped() const { return is_stopped_; } |
| 134 bool is_starved() const { return is_starved_; } |
| 135 |
| 136 // Prefetch callback has to be public. |
| 137 void SetPrefetched() { is_prefetched_ = true; } |
| 138 |
| 139 protected: |
| 140 typedef base::Callback<bool()> Predicate; |
| 141 |
| 142 typedef base::Callback<void(const DemuxerData&)> DataAvailableCallback; |
| 143 |
| 144 // Waits for condition to become true or for timeout to expire. |
| 145 // Returns true if the condition becomes true. |
| 146 bool WaitForCondition(const Predicate& condition, |
| 147 const base::TimeDelta& timeout = kDefaultTimeout); |
| 148 |
| 149 void SetDataFactory(scoped_refptr<TestDataFactory> factory) { |
| 150 data_factory_ = factory; |
| 151 } |
| 152 |
| 153 void CreateAudioDecoder(); |
| 154 void CreateVideoDecoder(); |
| 155 void SetVideoSurface(); |
| 156 |
| 157 // Decoder callbacks. |
| 158 void OnDataRequested(); |
| 159 void OnStarvation() { is_starved_ = true; } |
| 160 void OnStopDone() { is_stopped_ = true; } |
| 161 void OnError() {} |
| 162 void OnUpdateCurrentTime(base::TimeDelta now_playing, |
| 163 base::TimeDelta last_buffered) { |
| 164 pts_stat_.AddValue(now_playing); |
| 165 } |
| 166 void OnVideoSizeChanged(const gfx::Size& video_size) {} |
| 167 void OnVideoCodecCreated() {} |
| 168 |
| 169 scoped_ptr<MediaCodecDecoder> decoder_; |
| 170 scoped_refptr<TestDataFactory> data_factory_; |
| 171 Minimax<base::TimeDelta> pts_stat_; |
| 172 |
| 173 private: |
| 174 bool is_timeout_expired() const { return is_timeout_expired_; } |
| 175 void SetTimeoutExpired(bool value) { is_timeout_expired_ = value; } |
| 176 |
| 177 base::MessageLoop message_loop_; |
| 178 bool is_timeout_expired_; |
| 179 |
| 180 bool is_prefetched_; |
| 181 bool is_stopped_; |
| 182 bool is_starved_; |
| 183 |
| 184 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 185 DataAvailableCallback data_available_cb_; |
| 186 scoped_refptr<gfx::SurfaceTexture> surface_texture_; |
| 187 |
| 188 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoderTest); |
| 189 }; |
| 190 |
| 191 MediaCodecDecoderTest::MediaCodecDecoderTest() |
| 192 : is_timeout_expired_(false), |
| 193 is_prefetched_(false), |
| 194 is_stopped_(false), |
| 195 is_starved_(false), |
| 196 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
| 197 } |
| 198 |
| 199 MediaCodecDecoderTest::~MediaCodecDecoderTest() {} |
| 200 |
| 201 bool MediaCodecDecoderTest::WaitForCondition(const Predicate& condition, |
| 202 const base::TimeDelta& timeout) { |
| 203 // Let the message_loop_ process events. |
| 204 // We start the timer and RunUntilIdle() until it signals. |
| 205 |
| 206 SetTimeoutExpired(false); |
| 207 |
| 208 base::Timer timer(false, false); |
| 209 timer.Start(FROM_HERE, timeout, |
| 210 base::Bind(&MediaCodecDecoderTest::SetTimeoutExpired, |
| 211 base::Unretained(this), true)); |
| 212 |
| 213 do { |
| 214 if (condition.Run()) { |
| 215 timer.Stop(); |
| 216 return true; |
| 217 } |
| 218 message_loop_.RunUntilIdle(); |
| 219 } while (!is_timeout_expired()); |
| 220 |
| 221 DCHECK(!timer.IsRunning()); |
| 222 return false; |
| 223 } |
| 224 |
| 225 void MediaCodecDecoderTest::CreateAudioDecoder() { |
| 226 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecAudioDecoder( |
| 227 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, |
| 228 base::Unretained(this)), |
| 229 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), |
| 230 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), |
| 231 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), |
| 232 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, |
| 233 base::Unretained(this)))); |
| 234 |
| 235 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, |
| 236 base::Unretained(decoder_.get())); |
| 237 } |
| 238 |
| 239 void MediaCodecDecoderTest::CreateVideoDecoder() { |
| 240 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecVideoDecoder( |
| 241 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, |
| 242 base::Unretained(this)), |
| 243 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), |
| 244 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), |
| 245 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), |
| 246 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, |
| 247 base::Unretained(this)), |
| 248 base::Bind(&MediaCodecDecoderTest::OnVideoSizeChanged, |
| 249 base::Unretained(this)), |
| 250 base::Bind(&MediaCodecDecoderTest::OnVideoCodecCreated, |
| 251 base::Unretained(this)))); |
| 252 |
| 253 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, |
| 254 base::Unretained(decoder_.get())); |
| 255 } |
| 256 |
| 257 void MediaCodecDecoderTest::OnDataRequested() { |
| 258 if (!data_factory_) |
| 259 return; |
| 260 |
| 261 DemuxerData data; |
| 262 base::TimeDelta delay; |
| 263 data_factory_->CreateChunk(&data, &delay); |
| 264 |
| 265 task_runner_->PostDelayedTask(FROM_HERE, base::Bind(data_available_cb_, data), |
| 266 delay); |
| 267 } |
| 268 |
| 269 void MediaCodecDecoderTest::SetVideoSurface() { |
| 270 surface_texture_ = gfx::SurfaceTexture::Create(0); |
| 271 gfx::ScopedJavaSurface surface(surface_texture_.get()); |
| 272 ASSERT_NE(nullptr, decoder_.get()); |
| 273 MediaCodecVideoDecoder* video_decoder = |
| 274 static_cast<MediaCodecVideoDecoder*>(decoder_.get()); |
| 275 video_decoder->SetPendingSurface(surface.Pass()); |
| 276 } |
| 277 |
| 278 TEST_F(MediaCodecDecoderTest, AudioPrefetch) { |
| 279 CreateAudioDecoder(); |
| 280 |
| 281 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 282 SetDataFactory(scoped_refptr<TestDataFactory>(new AudioFactory(duration))); |
| 283 |
| 284 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 285 base::Unretained(this))); |
| 286 |
| 287 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 288 base::Unretained(this)))); |
| 289 } |
| 290 |
| 291 TEST_F(MediaCodecDecoderTest, VideoPrefetch) { |
| 292 CreateVideoDecoder(); |
| 293 |
| 294 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 295 SetDataFactory(scoped_refptr<TestDataFactory>(new VideoFactory(duration))); |
| 296 |
| 297 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 298 base::Unretained(this))); |
| 299 |
| 300 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 301 base::Unretained(this)))); |
| 302 } |
| 303 |
| 304 TEST_F(MediaCodecDecoderTest, AudioConfigureNoParams) { |
| 305 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 306 |
| 307 CreateAudioDecoder(); |
| 308 |
| 309 // Cannot configure without config parameters. |
| 310 EXPECT_EQ(MediaCodecDecoder::CONFIG_FAILURE, decoder_->Configure()); |
| 311 } |
| 312 |
| 313 TEST_F(MediaCodecDecoderTest, AudioConfigureValidParams) { |
| 314 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 315 |
| 316 CreateAudioDecoder(); |
| 317 |
| 318 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 319 scoped_refptr<AudioFactory> factory(new AudioFactory(duration)); |
| 320 decoder_->SetDemuxerConfigs(factory->GetConfigs()); |
| 321 |
| 322 EXPECT_EQ(MediaCodecDecoder::CONFIG_OK, decoder_->Configure()); |
| 323 } |
| 324 |
| 325 TEST_F(MediaCodecDecoderTest, VideoConfigureNoParams) { |
| 326 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 327 |
| 328 CreateVideoDecoder(); |
| 329 |
| 330 // Cannot configure without config parameters. |
| 331 EXPECT_EQ(MediaCodecDecoder::CONFIG_FAILURE, decoder_->Configure()); |
| 332 } |
| 333 |
| 334 TEST_F(MediaCodecDecoderTest, VideoConfigureNoSurface) { |
| 335 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 336 |
| 337 CreateVideoDecoder(); |
| 338 |
| 339 // decoder_->Configure() searches back for the key frame. |
| 340 // We have to prefetch decoder. |
| 341 |
| 342 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 343 scoped_refptr<VideoFactory> factory(new VideoFactory(duration)); |
| 344 SetDataFactory(factory); |
| 345 |
| 346 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 347 base::Unretained(this))); |
| 348 |
| 349 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 350 base::Unretained(this)))); |
| 351 |
| 352 decoder_->SetDemuxerConfigs(factory->GetConfigs()); |
| 353 |
| 354 // Surface is not set, Configure() should fail. |
| 355 |
| 356 EXPECT_EQ(MediaCodecDecoder::CONFIG_FAILURE, decoder_->Configure()); |
| 357 } |
| 358 |
| 359 TEST_F(MediaCodecDecoderTest, VideoConfigureInvalidSurface) { |
| 360 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 361 |
| 362 CreateVideoDecoder(); |
| 363 |
| 364 // decoder_->Configure() searches back for the key frame. |
| 365 // We have to prefetch decoder. |
| 366 |
| 367 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 368 scoped_refptr<VideoFactory> factory(new VideoFactory(duration)); |
| 369 SetDataFactory(factory); |
| 370 |
| 371 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 372 base::Unretained(this))); |
| 373 |
| 374 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 375 base::Unretained(this)))); |
| 376 |
| 377 decoder_->SetDemuxerConfigs(factory->GetConfigs()); |
| 378 |
| 379 // Prepare the surface. |
| 380 scoped_refptr<gfx::SurfaceTexture> surface_texture( |
| 381 gfx::SurfaceTexture::Create(0)); |
| 382 gfx::ScopedJavaSurface surface(surface_texture.get()); |
| 383 |
| 384 // Release the surface texture. |
| 385 surface_texture = NULL; |
| 386 |
| 387 MediaCodecVideoDecoder* video_decoder = |
| 388 static_cast<MediaCodecVideoDecoder*>(decoder_.get()); |
| 389 video_decoder->SetPendingSurface(surface.Pass()); |
| 390 |
| 391 EXPECT_EQ(MediaCodecDecoder::CONFIG_FAILURE, decoder_->Configure()); |
| 392 } |
| 393 |
| 394 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) { |
| 395 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 396 |
| 397 CreateVideoDecoder(); |
| 398 |
| 399 // decoder_->Configure() searches back for the key frame. |
| 400 // We have to prefetch decoder. |
| 401 |
| 402 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 403 scoped_refptr<VideoFactory> factory(new VideoFactory(duration)); |
| 404 SetDataFactory(factory); |
| 405 |
| 406 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 407 base::Unretained(this))); |
| 408 |
| 409 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 410 base::Unretained(this)))); |
| 411 |
| 412 decoder_->SetDemuxerConfigs(factory->GetConfigs()); |
| 413 |
| 414 SetVideoSurface(); |
| 415 |
| 416 // Now we can expect Configure() to succeed. |
| 417 |
| 418 EXPECT_EQ(MediaCodecDecoder::CONFIG_OK, decoder_->Configure()); |
| 419 } |
| 420 |
| 421 TEST_F(MediaCodecDecoderTest, AudioStartWithoutConfigure) { |
| 422 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 423 |
| 424 CreateAudioDecoder(); |
| 425 |
| 426 // Decoder has to be prefetched and configured before the start. |
| 427 |
| 428 // Wrong state: not prefetched |
| 429 EXPECT_FALSE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
| 430 |
| 431 // Do the prefetch. |
| 432 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 433 scoped_refptr<AudioFactory> factory(new AudioFactory(duration)); |
| 434 SetDataFactory(factory); |
| 435 |
| 436 // Prefetch to avoid starvation at the beginning of playback. |
| 437 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 438 base::Unretained(this))); |
| 439 |
| 440 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 441 base::Unretained(this)))); |
| 442 |
| 443 // Still, decoder is not configured. |
| 444 EXPECT_FALSE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
| 445 } |
| 446 |
| 447 TEST_F(MediaCodecDecoderTest, AudioPlayTillCompletion) { |
| 448 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 449 |
| 450 CreateAudioDecoder(); |
| 451 |
| 452 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 453 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(600); |
| 454 scoped_refptr<AudioFactory> factory(new AudioFactory(duration)); |
| 455 SetDataFactory(factory); |
| 456 |
| 457 // Prefetch to avoid starvation at the beginning of playback. |
| 458 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 459 base::Unretained(this))); |
| 460 |
| 461 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 462 base::Unretained(this)))); |
| 463 |
| 464 decoder_->SetDemuxerConfigs(factory->GetConfigs()); |
| 465 |
| 466 EXPECT_EQ(MediaCodecDecoder::CONFIG_OK, decoder_->Configure()); |
| 467 |
| 468 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
| 469 |
| 470 EXPECT_TRUE(WaitForCondition( |
| 471 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), |
| 472 timeout)); |
| 473 |
| 474 EXPECT_TRUE(decoder_->IsStopped()); |
| 475 EXPECT_TRUE(decoder_->IsCompleted()); |
| 476 |
| 477 // It is hard to properly estimate minimum and maximum values because |
| 478 // reported times are different from PTS. |
| 479 EXPECT_EQ(25, pts_stat_.num_values()); |
| 480 } |
| 481 |
| 482 TEST_F(MediaCodecDecoderTest, VideoPlayTillCompletion) { |
| 483 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 484 |
| 485 CreateVideoDecoder(); |
| 486 |
| 487 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| 488 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(600); |
| 489 scoped_refptr<VideoFactory> factory(new VideoFactory(duration)); |
| 490 SetDataFactory(factory); |
| 491 |
| 492 // Prefetch |
| 493 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 494 base::Unretained(this))); |
| 495 |
| 496 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 497 base::Unretained(this)))); |
| 498 |
| 499 decoder_->SetDemuxerConfigs(factory->GetConfigs()); |
| 500 |
| 501 SetVideoSurface(); |
| 502 |
| 503 EXPECT_EQ(MediaCodecDecoder::CONFIG_OK, decoder_->Configure()); |
| 504 |
| 505 EXPECT_TRUE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); |
| 506 |
| 507 EXPECT_TRUE(WaitForCondition( |
| 508 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)), |
| 509 timeout)); |
| 510 |
| 511 EXPECT_TRUE(decoder_->IsStopped()); |
| 512 EXPECT_TRUE(decoder_->IsCompleted()); |
| 513 |
| 514 EXPECT_EQ(26, pts_stat_.num_values()); |
| 515 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); |
| 516 } |
| 517 |
| 518 } // namespace media |
| OLD | NEW |