| 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 "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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void SetVideoSurface(); | 176 void SetVideoSurface(); |
| 177 void SetStopRequestAtTime(const base::TimeDelta& time) { | 177 void SetStopRequestAtTime(const base::TimeDelta& time) { |
| 178 stop_request_time_ = time; | 178 stop_request_time_ = time; |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Decoder callbacks. | 181 // Decoder callbacks. |
| 182 void OnDataRequested(); | 182 void OnDataRequested(); |
| 183 void OnStarvation() { is_starved_ = true; } | 183 void OnStarvation() { is_starved_ = true; } |
| 184 void OnDecoderDrained() {} | 184 void OnDecoderDrained() {} |
| 185 void OnStopDone() { is_stopped_ = true; } | 185 void OnStopDone() { is_stopped_ = true; } |
| 186 void OnKeyRequired() {} |
| 186 void OnError() { DVLOG(0) << "MediaCodecDecoderTest::" << __FUNCTION__; } | 187 void OnError() { DVLOG(0) << "MediaCodecDecoderTest::" << __FUNCTION__; } |
| 187 void OnUpdateCurrentTime(base::TimeDelta now_playing, | 188 void OnUpdateCurrentTime(base::TimeDelta now_playing, |
| 188 base::TimeDelta last_buffered, | 189 base::TimeDelta last_buffered, |
| 189 bool postpone) { | 190 bool postpone) { |
| 190 // Add the |last_buffered| value for PTS. For video it is the same as | 191 // Add the |last_buffered| value for PTS. For video it is the same as |
| 191 // |now_playing| and is equal to PTS, for audio |last_buffered| should | 192 // |now_playing| and is equal to PTS, for audio |last_buffered| should |
| 192 // exceed PTS. | 193 // exceed PTS. |
| 193 if (postpone) | 194 if (postpone) |
| 194 return; | 195 return; |
| 195 | 196 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 269 } |
| 269 | 270 |
| 270 void MediaCodecDecoderTest::CreateAudioDecoder() { | 271 void MediaCodecDecoderTest::CreateAudioDecoder() { |
| 271 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecAudioDecoder( | 272 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecAudioDecoder( |
| 272 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, | 273 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, |
| 273 base::Unretained(this)), | 274 base::Unretained(this)), |
| 274 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), | 275 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), |
| 275 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, | 276 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, |
| 276 base::Unretained(this)), | 277 base::Unretained(this)), |
| 277 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), | 278 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), |
| 279 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)), |
| 278 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), | 280 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), |
| 279 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, | 281 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, |
| 280 base::Unretained(this)))); | 282 base::Unretained(this)))); |
| 281 | 283 |
| 282 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, | 284 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, |
| 283 base::Unretained(decoder_.get())); | 285 base::Unretained(decoder_.get())); |
| 284 } | 286 } |
| 285 | 287 |
| 286 void MediaCodecDecoderTest::CreateVideoDecoder() { | 288 void MediaCodecDecoderTest::CreateVideoDecoder() { |
| 287 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecVideoDecoder( | 289 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecVideoDecoder( |
| 288 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, | 290 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, |
| 289 base::Unretained(this)), | 291 base::Unretained(this)), |
| 290 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), | 292 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), |
| 291 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, | 293 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, |
| 292 base::Unretained(this)), | 294 base::Unretained(this)), |
| 293 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), | 295 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), |
| 296 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)), |
| 294 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), | 297 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), |
| 295 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, | 298 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, |
| 296 base::Unretained(this)), | 299 base::Unretained(this)), |
| 297 base::Bind(&MediaCodecDecoderTest::OnVideoSizeChanged, | 300 base::Bind(&MediaCodecDecoderTest::OnVideoSizeChanged, |
| 298 base::Unretained(this)), | 301 base::Unretained(this)), |
| 299 base::Bind(&MediaCodecDecoderTest::OnVideoCodecCreated, | 302 base::Bind(&MediaCodecDecoderTest::OnVideoCodecCreated, |
| 300 base::Unretained(this)))); | 303 base::Unretained(this)))); |
| 301 | 304 |
| 302 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, | 305 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, |
| 303 base::Unretained(decoder_.get())); | 306 base::Unretained(decoder_.get())); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 | 755 |
| 753 EXPECT_TRUE(decoder_->IsStopped()); | 756 EXPECT_TRUE(decoder_->IsStopped()); |
| 754 EXPECT_TRUE(decoder_->IsCompleted()); | 757 EXPECT_TRUE(decoder_->IsCompleted()); |
| 755 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); | 758 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); |
| 756 | 759 |
| 757 // Check that the reported video size is the one from the in-stream configs. | 760 // Check that the reported video size is the one from the in-stream configs. |
| 758 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_); | 761 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_); |
| 759 } | 762 } |
| 760 | 763 |
| 761 } // namespace media | 764 } // namespace media |
| OLD | NEW |