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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 void CreateAudioDecoder(); | 142 void CreateAudioDecoder(); |
143 void CreateVideoDecoder(); | 143 void CreateVideoDecoder(); |
144 void SetVideoSurface(); | 144 void SetVideoSurface(); |
145 void SetStopRequestAtTime(const base::TimeDelta& time) { | 145 void SetStopRequestAtTime(const base::TimeDelta& time) { |
146 stop_request_time_ = time; | 146 stop_request_time_ = time; |
147 } | 147 } |
148 | 148 |
149 // Decoder callbacks. | 149 // Decoder callbacks. |
150 void OnDataRequested(); | 150 void OnDataRequested(); |
151 void OnStarvation() { is_starved_ = true; } | 151 void OnStarvation() { is_starved_ = true; } |
| 152 void OnPrerollDone() {} |
152 void OnStopDone() { is_stopped_ = true; } | 153 void OnStopDone() { is_stopped_ = true; } |
153 void OnError() {} | 154 void OnError() {} |
154 void OnUpdateCurrentTime(base::TimeDelta now_playing, | 155 void OnUpdateCurrentTime(base::TimeDelta now_playing, |
155 base::TimeDelta last_buffered) { | 156 base::TimeDelta last_buffered) { |
156 // Add the |last_buffered| value for PTS. For video it is the same as | 157 // Add the |last_buffered| value for PTS. For video it is the same as |
157 // |now_playing| and is equal to PTS, for audio |last_buffered| should | 158 // |now_playing| and is equal to PTS, for audio |last_buffered| should |
158 // exceed PTS. | 159 // exceed PTS. |
159 pts_stat_.AddValue(last_buffered); | 160 pts_stat_.AddValue(last_buffered); |
160 | 161 |
161 if (stop_request_time_ != kNoTimestamp() && | 162 if (stop_request_time_ != kNoTimestamp() && |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 225 |
225 DCHECK(!timer.IsRunning()); | 226 DCHECK(!timer.IsRunning()); |
226 return false; | 227 return false; |
227 } | 228 } |
228 | 229 |
229 void MediaCodecDecoderTest::CreateAudioDecoder() { | 230 void MediaCodecDecoderTest::CreateAudioDecoder() { |
230 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecAudioDecoder( | 231 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecAudioDecoder( |
231 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, | 232 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, |
232 base::Unretained(this)), | 233 base::Unretained(this)), |
233 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), | 234 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), |
| 235 base::Bind(&MediaCodecDecoderTest::OnPrerollDone, base::Unretained(this)), |
234 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), | 236 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), |
235 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), | 237 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), |
236 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, | 238 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, |
237 base::Unretained(this)))); | 239 base::Unretained(this)))); |
238 | 240 |
239 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, | 241 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, |
240 base::Unretained(decoder_.get())); | 242 base::Unretained(decoder_.get())); |
241 } | 243 } |
242 | 244 |
243 void MediaCodecDecoderTest::CreateVideoDecoder() { | 245 void MediaCodecDecoderTest::CreateVideoDecoder() { |
244 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecVideoDecoder( | 246 decoder_ = scoped_ptr<MediaCodecDecoder>(new MediaCodecVideoDecoder( |
245 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, | 247 task_runner_, base::Bind(&MediaCodecDecoderTest::OnDataRequested, |
246 base::Unretained(this)), | 248 base::Unretained(this)), |
247 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), | 249 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), |
| 250 base::Bind(&MediaCodecDecoderTest::OnPrerollDone, base::Unretained(this)), |
248 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), | 251 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), |
249 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), | 252 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), |
250 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, | 253 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, |
251 base::Unretained(this)), | 254 base::Unretained(this)), |
252 base::Bind(&MediaCodecDecoderTest::OnVideoSizeChanged, | 255 base::Bind(&MediaCodecDecoderTest::OnVideoSizeChanged, |
253 base::Unretained(this)), | 256 base::Unretained(this)), |
254 base::Bind(&MediaCodecDecoderTest::OnVideoCodecCreated, | 257 base::Bind(&MediaCodecDecoderTest::OnVideoCodecCreated, |
255 base::Unretained(this)))); | 258 base::Unretained(this)))); |
256 | 259 |
257 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, | 260 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 decoder_->RequestToStop(); | 644 decoder_->RequestToStop(); |
642 | 645 |
643 EXPECT_TRUE(WaitForCondition( | 646 EXPECT_TRUE(WaitForCondition( |
644 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)))); | 647 base::Bind(&MediaCodecDecoderTest::is_stopped, base::Unretained(this)))); |
645 | 648 |
646 EXPECT_TRUE(decoder_->IsStopped()); | 649 EXPECT_TRUE(decoder_->IsStopped()); |
647 EXPECT_FALSE(decoder_->IsCompleted()); | 650 EXPECT_FALSE(decoder_->IsCompleted()); |
648 } | 651 } |
649 | 652 |
650 } // namespace media | 653 } // namespace media |
OLD | NEW |