OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/renderers/renderer_impl.h" | 5 #include "media/renderers/renderer_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/metrics/histogram_macros.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "media/base/audio_decoder_config.h" | 18 #include "media/base/audio_decoder_config.h" |
18 #include "media/base/audio_renderer.h" | 19 #include "media/base/audio_renderer.h" |
19 #include "media/base/bind_to_current_loop.h" | 20 #include "media/base/bind_to_current_loop.h" |
20 #include "media/base/demuxer_stream_provider.h" | 21 #include "media/base/demuxer_stream_provider.h" |
21 #include "media/base/media_switches.h" | 22 #include "media/base/media_switches.h" |
22 #include "media/base/renderer_client.h" | 23 #include "media/base/renderer_client.h" |
23 #include "media/base/time_source.h" | 24 #include "media/base/time_source.h" |
24 #include "media/base/video_decoder_config.h" | 25 #include "media/base/video_decoder_config.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 DVLOG(1) << __func__; | 209 DVLOG(1) << __func__; |
209 DCHECK(task_runner_->BelongsToCurrentThread()); | 210 DCHECK(task_runner_->BelongsToCurrentThread()); |
210 | 211 |
211 if (state_ != STATE_PLAYING) { | 212 if (state_ != STATE_PLAYING) { |
212 DCHECK_EQ(state_, STATE_ERROR); | 213 DCHECK_EQ(state_, STATE_ERROR); |
213 return; | 214 return; |
214 } | 215 } |
215 | 216 |
216 time_source_->SetMediaTime(time); | 217 time_source_->SetMediaTime(time); |
217 | 218 |
218 if (audio_renderer_) | 219 if (audio_renderer_) { |
| 220 audio_preroll_start_time_ = base::TimeTicks::Now(); |
219 audio_renderer_->StartPlaying(); | 221 audio_renderer_->StartPlaying(); |
220 if (video_renderer_) | 222 } |
| 223 if (video_renderer_) { |
| 224 video_preroll_start_time_ = base::TimeTicks::Now(); |
221 video_renderer_->StartPlayingFrom(time); | 225 video_renderer_->StartPlayingFrom(time); |
| 226 } |
222 } | 227 } |
223 | 228 |
224 void RendererImpl::RestartStreamPlayback(DemuxerStream* stream, | 229 void RendererImpl::RestartStreamPlayback(DemuxerStream* stream, |
225 bool enabled, | 230 bool enabled, |
226 base::TimeDelta time) { | 231 base::TimeDelta time) { |
227 DCHECK(task_runner_->BelongsToCurrentThread()); | 232 DCHECK(task_runner_->BelongsToCurrentThread()); |
228 DCHECK(stream); | 233 DCHECK(stream); |
229 bool video = (stream->type() == DemuxerStream::VIDEO); | 234 bool video = (stream->type() == DemuxerStream::VIDEO); |
230 DVLOG(1) << __func__ << (video ? " video" : " audio") << " stream=" << stream | 235 DVLOG(1) << __func__ << (video ? " video" : " audio") << " stream=" << stream |
231 << " enabled=" << stream->enabled() << " time=" << time.InSecondsF(); | 236 << " enabled=" << stream->enabled() << " time=" << time.InSecondsF(); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 692 |
688 // Renderer underflowed. | 693 // Renderer underflowed. |
689 if (!was_waiting_for_enough_data && WaitingForEnoughData()) { | 694 if (!was_waiting_for_enough_data && WaitingForEnoughData()) { |
690 PausePlayback(); | 695 PausePlayback(); |
691 client_->OnBufferingStateChange(BUFFERING_HAVE_NOTHING); | 696 client_->OnBufferingStateChange(BUFFERING_HAVE_NOTHING); |
692 return; | 697 return; |
693 } | 698 } |
694 | 699 |
695 // Renderer prerolled. | 700 // Renderer prerolled. |
696 if (was_waiting_for_enough_data && !WaitingForEnoughData()) { | 701 if (was_waiting_for_enough_data && !WaitingForEnoughData()) { |
| 702 if (type == DemuxerStream::AUDIO && !audio_preroll_start_time_.is_null()) { |
| 703 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 704 "Media.Audio.PrerollTime", |
| 705 base::TimeTicks::Now() - audio_preroll_start_time_); |
| 706 } else if (type == DemuxerStream::VIDEO && |
| 707 !video_preroll_start_time_.is_null()) { |
| 708 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 709 "Media.Video.PrerollTime", |
| 710 base::TimeTicks::Now() - video_preroll_start_time_); |
| 711 video_preroll_start_time_ = base::TimeTicks(); |
| 712 } |
| 713 |
697 StartPlayback(); | 714 StartPlayback(); |
698 client_->OnBufferingStateChange(BUFFERING_HAVE_ENOUGH); | 715 client_->OnBufferingStateChange(BUFFERING_HAVE_ENOUGH); |
699 return; | 716 return; |
700 } | 717 } |
701 } | 718 } |
702 | 719 |
703 bool RendererImpl::WaitingForEnoughData() const { | 720 bool RendererImpl::WaitingForEnoughData() const { |
704 DCHECK(task_runner_->BelongsToCurrentThread()); | 721 DCHECK(task_runner_->BelongsToCurrentThread()); |
705 if (state_ != STATE_PLAYING) | 722 if (state_ != STATE_PLAYING) |
706 return false; | 723 return false; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 DCHECK(task_runner_->BelongsToCurrentThread()); | 856 DCHECK(task_runner_->BelongsToCurrentThread()); |
840 client_->OnVideoNaturalSizeChange(size); | 857 client_->OnVideoNaturalSizeChange(size); |
841 } | 858 } |
842 | 859 |
843 void RendererImpl::OnVideoOpacityChange(bool opaque) { | 860 void RendererImpl::OnVideoOpacityChange(bool opaque) { |
844 DCHECK(task_runner_->BelongsToCurrentThread()); | 861 DCHECK(task_runner_->BelongsToCurrentThread()); |
845 client_->OnVideoOpacityChange(opaque); | 862 client_->OnVideoOpacityChange(opaque); |
846 } | 863 } |
847 | 864 |
848 } // namespace media | 865 } // namespace media |
OLD | NEW |