Chromium Code Reviews| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))), | 197 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))), |
| 198 is_cdm_attached_(false), | 198 is_cdm_attached_(false), |
| 199 #if defined(OS_ANDROID) // WMPI_CAST | 199 #if defined(OS_ANDROID) // WMPI_CAST |
| 200 cast_impl_(this, client_, params.context_3d_cb()), | 200 cast_impl_(this, client_, params.context_3d_cb()), |
| 201 #endif | 201 #endif |
| 202 volume_(1.0), | 202 volume_(1.0), |
| 203 volume_multiplier_(1.0), | 203 volume_multiplier_(1.0), |
| 204 renderer_factory_(std::move(renderer_factory)), | 204 renderer_factory_(std::move(renderer_factory)), |
| 205 surface_manager_(params.surface_manager()), | 205 surface_manager_(params.surface_manager()), |
| 206 suppress_destruction_errors_(false), | 206 suppress_destruction_errors_(false), |
| 207 can_suspend_state_(CanSuspendState::UNKNOWN) { | 207 can_suspend_state_(params.allow_idle_suspend() ? CanSuspendState::UNKNOWN |
| 208 : CanSuspendState::NO) { | |
| 208 DCHECK(!adjust_allocated_memory_cb_.is_null()); | 209 DCHECK(!adjust_allocated_memory_cb_.is_null()); |
| 209 DCHECK(renderer_factory_); | 210 DCHECK(renderer_factory_); |
| 210 DCHECK(client_); | 211 DCHECK(client_); |
| 211 | 212 |
| 212 if (delegate_) | 213 if (delegate_) |
| 213 delegate_id_ = delegate_->AddObserver(this); | 214 delegate_id_ = delegate_->AddObserver(this); |
| 214 | 215 |
| 215 media_log_->AddEvent( | 216 media_log_->AddEvent( |
| 216 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 217 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 217 | 218 |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1445 ReportMemoryUsage(); | 1446 ReportMemoryUsage(); |
| 1446 } | 1447 } |
| 1447 } | 1448 } |
| 1448 | 1449 |
| 1449 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) { | 1450 void WebMediaPlayerImpl::SetSuspendState(bool is_suspended) { |
| 1450 // Do not change the state after an error has occurred. | 1451 // Do not change the state after an error has occurred. |
| 1451 // TODO(sandersd): Update PipelineController to remove the need for this. | 1452 // TODO(sandersd): Update PipelineController to remove the need for this. |
| 1452 if (IsNetworkStateError(network_state_)) | 1453 if (IsNetworkStateError(network_state_)) |
| 1453 return; | 1454 return; |
| 1454 | 1455 |
| 1456 if (can_suspend_state_ == CanSuspendState::NO) | |
| 1457 return; | |
| 1458 | |
| 1455 #if defined(OS_MACOSX) || defined(OS_WIN) | 1459 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 1456 // TODO(sandersd): Idle suspend is disabled on OSX and Windows for hardware | 1460 // TODO(sandersd): Idle suspend is disabled on OSX and Windows for hardware |
| 1457 // decoding / opaque video frames since these frames are owned by the decoder | 1461 // decoding / opaque video frames since these frames are owned by the decoder |
| 1458 // in the GPU process. http://crbug.com/595716 and http://crbug.com/602708 | 1462 // in the GPU process. http://crbug.com/595716 and http://crbug.com/602708 |
| 1459 if (can_suspend_state_ == CanSuspendState::UNKNOWN) { | 1463 if (can_suspend_state_ == CanSuspendState::UNKNOWN) { |
| 1460 scoped_refptr<VideoFrame> frame = GetCurrentFrameFromCompositor(); | 1464 scoped_refptr<VideoFrame> frame = GetCurrentFrameFromCompositor(); |
| 1461 if (frame) { | 1465 if (frame) { |
| 1462 can_suspend_state_ = | 1466 can_suspend_state_ = |
| 1463 frame->metadata()->IsTrue(VideoFrameMetadata::DECODER_OWNS_FRAME) | 1467 frame->metadata()->IsTrue(VideoFrameMetadata::DECODER_OWNS_FRAME) |
| 1464 ? CanSuspendState::NO | 1468 ? CanSuspendState::NO |
| 1465 : CanSuspendState::YES; | 1469 : CanSuspendState::YES; |
| 1466 } | 1470 } |
| 1467 } | 1471 } |
| 1468 #else | 1472 #else |
| 1469 can_suspend_state_ = CanSuspendState::YES; | 1473 can_suspend_state_ = CanSuspendState::YES; |
| 1470 #endif | 1474 #endif |
| 1471 | 1475 |
| 1472 if (can_suspend_state_ == CanSuspendState::NO) | |
|
sandersd (OOO until July 31)
2016/05/12 17:48:11
Still need this here due to line 1468.
halliwell
2016/05/12 18:11:59
Doh, yes. Done.
| |
| 1473 return; | |
| 1474 | |
| 1475 if (is_suspended) { | 1476 if (is_suspended) { |
| 1476 pipeline_controller_.Suspend(); | 1477 pipeline_controller_.Suspend(); |
| 1477 } else { | 1478 } else { |
| 1478 pipeline_controller_.Resume(); | 1479 pipeline_controller_.Resume(); |
| 1479 } | 1480 } |
| 1480 } | 1481 } |
| 1481 | 1482 |
| 1482 WebMediaPlayerImpl::PlayState | 1483 WebMediaPlayerImpl::PlayState |
| 1483 WebMediaPlayerImpl::UpdatePlayState_ComputePlayState(bool is_remote, | 1484 WebMediaPlayerImpl::UpdatePlayState_ComputePlayState(bool is_remote, |
| 1484 bool is_backgrounded) { | 1485 bool is_backgrounded) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1592 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1593 << ", Video: " << stats.video_memory_usage << ", DataSource: " |
| 1593 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1594 << (data_source_ ? data_source_->GetMemoryUsage() : 0) |
| 1594 << ", Demuxer: " << demuxer_memory_usage; | 1595 << ", Demuxer: " << demuxer_memory_usage; |
| 1595 | 1596 |
| 1596 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1597 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
| 1597 last_reported_memory_usage_ = current_memory_usage; | 1598 last_reported_memory_usage_ = current_memory_usage; |
| 1598 adjust_allocated_memory_cb_.Run(delta); | 1599 adjust_allocated_memory_cb_.Run(delta); |
| 1599 } | 1600 } |
| 1600 | 1601 |
| 1601 } // namespace media | 1602 } // namespace media |
| OLD | NEW |