| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 bool is_timeout_expired_; | 220 bool is_timeout_expired_; |
| 221 | 221 |
| 222 bool is_prefetched_; | 222 bool is_prefetched_; |
| 223 bool is_stopped_; | 223 bool is_stopped_; |
| 224 bool is_starved_; | 224 bool is_starved_; |
| 225 base::TimeDelta stop_request_time_; | 225 base::TimeDelta stop_request_time_; |
| 226 | 226 |
| 227 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 227 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 228 FrameStatistics frame_statistics_; | 228 FrameStatistics frame_statistics_; |
| 229 DataAvailableCallback data_available_cb_; | 229 DataAvailableCallback data_available_cb_; |
| 230 scoped_refptr<gfx::SurfaceTexture> surface_texture_; | 230 scoped_refptr<gl::SurfaceTexture> surface_texture_; |
| 231 | 231 |
| 232 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoderTest); | 232 DISALLOW_COPY_AND_ASSIGN(MediaCodecDecoderTest); |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 MediaCodecDecoderTest::MediaCodecDecoderTest() | 235 MediaCodecDecoderTest::MediaCodecDecoderTest() |
| 236 : is_timeout_expired_(false), | 236 : is_timeout_expired_(false), |
| 237 is_prefetched_(false), | 237 is_prefetched_(false), |
| 238 is_stopped_(false), | 238 is_stopped_(false), |
| 239 is_starved_(false), | 239 is_starved_(false), |
| 240 stop_request_time_(kNoTimestamp()), | 240 stop_request_time_(kNoTimestamp()), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 DemuxerData data; | 312 DemuxerData data; |
| 313 base::TimeDelta delay; | 313 base::TimeDelta delay; |
| 314 if (!data_factory_->CreateChunk(&data, &delay)) | 314 if (!data_factory_->CreateChunk(&data, &delay)) |
| 315 return; | 315 return; |
| 316 | 316 |
| 317 task_runner_->PostDelayedTask(FROM_HERE, base::Bind(data_available_cb_, data), | 317 task_runner_->PostDelayedTask(FROM_HERE, base::Bind(data_available_cb_, data), |
| 318 delay); | 318 delay); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void MediaCodecDecoderTest::SetVideoSurface() { | 321 void MediaCodecDecoderTest::SetVideoSurface() { |
| 322 surface_texture_ = gfx::SurfaceTexture::Create(0); | 322 surface_texture_ = gl::SurfaceTexture::Create(0); |
| 323 gfx::ScopedJavaSurface surface(surface_texture_.get()); | 323 gl::ScopedJavaSurface surface(surface_texture_.get()); |
| 324 ASSERT_NE(nullptr, decoder_.get()); | 324 ASSERT_NE(nullptr, decoder_.get()); |
| 325 VideoMediaCodecDecoder* video_decoder = | 325 VideoMediaCodecDecoder* video_decoder = |
| 326 static_cast<VideoMediaCodecDecoder*>(decoder_.get()); | 326 static_cast<VideoMediaCodecDecoder*>(decoder_.get()); |
| 327 video_decoder->SetVideoSurface(std::move(surface)); | 327 video_decoder->SetVideoSurface(std::move(surface)); |
| 328 } | 328 } |
| 329 | 329 |
| 330 TEST_F(MediaCodecDecoderTest, AudioPrefetch) { | 330 TEST_F(MediaCodecDecoderTest, AudioPrefetch) { |
| 331 CreateAudioDecoder(); | 331 CreateAudioDecoder(); |
| 332 | 332 |
| 333 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); | 333 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, | 435 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, |
| 436 base::Unretained(this), true)); | 436 base::Unretained(this), true)); |
| 437 | 437 |
| 438 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, | 438 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, |
| 439 base::Unretained(this)))); | 439 base::Unretained(this)))); |
| 440 | 440 |
| 441 decoder_->SetDemuxerConfigs(GetConfigs()); | 441 decoder_->SetDemuxerConfigs(GetConfigs()); |
| 442 | 442 |
| 443 // Prepare the surface. | 443 // Prepare the surface. |
| 444 scoped_refptr<gfx::SurfaceTexture> surface_texture( | 444 scoped_refptr<gl::SurfaceTexture> surface_texture( |
| 445 gfx::SurfaceTexture::Create(0)); | 445 gl::SurfaceTexture::Create(0)); |
| 446 gfx::ScopedJavaSurface surface(surface_texture.get()); | 446 gl::ScopedJavaSurface surface(surface_texture.get()); |
| 447 | 447 |
| 448 // Release the surface texture. | 448 // Release the surface texture. |
| 449 surface_texture = NULL; | 449 surface_texture = NULL; |
| 450 | 450 |
| 451 VideoMediaCodecDecoder* video_decoder = | 451 VideoMediaCodecDecoder* video_decoder = |
| 452 static_cast<VideoMediaCodecDecoder*>(decoder_.get()); | 452 static_cast<VideoMediaCodecDecoder*>(decoder_.get()); |
| 453 video_decoder->SetVideoSurface(std::move(surface)); | 453 video_decoder->SetVideoSurface(std::move(surface)); |
| 454 | 454 |
| 455 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); | 455 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); |
| 456 } | 456 } |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 | 756 |
| 757 EXPECT_TRUE(decoder_->IsStopped()); | 757 EXPECT_TRUE(decoder_->IsStopped()); |
| 758 EXPECT_TRUE(decoder_->IsCompleted()); | 758 EXPECT_TRUE(decoder_->IsCompleted()); |
| 759 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); | 759 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); |
| 760 | 760 |
| 761 // Check that the reported video size is the one from the in-stream configs. | 761 // Check that the reported video size is the one from the in-stream configs. |
| 762 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_); | 762 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_); |
| 763 } | 763 } |
| 764 | 764 |
| 765 } // namespace media | 765 } // namespace media |
| OLD | NEW |