OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 | 258 |
259 media_log_->AddEvent( | 259 media_log_->AddEvent( |
260 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 260 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
261 | 261 |
262 if (params.initial_cdm()) | 262 if (params.initial_cdm()) |
263 SetCdm(params.initial_cdm()); | 263 SetCdm(params.initial_cdm()); |
264 | 264 |
265 // TODO(xhwang): When we use an external Renderer, many methods won't work, | 265 // TODO(xhwang): When we use an external Renderer, many methods won't work, |
266 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 | 266 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 |
267 | 267 |
268 if (params.audio_renderer_sink().get()) { | |
DaleCurtis
2016/11/30 22:10:38
No need for .get().
| |
269 media::OutputDeviceStatus device_status = | |
270 params.audio_renderer_sink()->GetOutputDeviceInfo().device_status(); | |
271 UMA_HISTOGRAM_ENUMERATION("Media.WebMediaPlayer.SinkStatus", device_status, | |
272 OUTPUT_DEVICE_STATUS_MAX + 1); | |
273 | |
274 if (device_status == OUTPUT_DEVICE_STATUS_OK) { | |
275 audio_source_provider_ = | |
276 new WebAudioSourceProviderImpl(params.audio_renderer_sink()); | |
277 return; | |
278 } | |
279 MEDIA_LOG(ERROR, media_log_) | |
280 << "Output device error, falling back to null sink"; | |
281 } | |
268 // Use the null sink if no valid sink was provided. | 282 // Use the null sink if no valid sink was provided. |
269 audio_source_provider_ = new WebAudioSourceProviderImpl( | 283 audio_source_provider_ = |
270 params.audio_renderer_sink().get() && | 284 new WebAudioSourceProviderImpl(new NullAudioSink(media_task_runner_)); |
271 params.audio_renderer_sink() | |
272 ->GetOutputDeviceInfo() | |
273 .device_status() == OUTPUT_DEVICE_STATUS_OK | |
274 ? params.audio_renderer_sink() | |
275 : new NullAudioSink(media_task_runner_)); | |
276 } | 285 } |
277 | 286 |
278 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 287 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
279 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 288 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
280 | 289 |
281 suppress_destruction_errors_ = true; | 290 suppress_destruction_errors_ = true; |
282 if (delegate_) { | 291 if (delegate_) { |
283 delegate_->PlayerGone(delegate_id_); | 292 delegate_->PlayerGone(delegate_id_); |
284 delegate_->RemoveObserver(delegate_id_); | 293 delegate_->RemoveObserver(delegate_id_); |
285 } | 294 } |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1981 watch_time_reporter_->OnShown(); | 1990 watch_time_reporter_->OnShown(); |
1982 } | 1991 } |
1983 | 1992 |
1984 bool WebMediaPlayerImpl::IsHidden() const { | 1993 bool WebMediaPlayerImpl::IsHidden() const { |
1985 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1994 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1986 | 1995 |
1987 return delegate_ && delegate_->IsHidden(); | 1996 return delegate_ && delegate_->IsHidden(); |
1988 } | 1997 } |
1989 | 1998 |
1990 } // namespace media | 1999 } // namespace media |
OLD | NEW |