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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 #if defined(OS_ANDROID) // WMPI_CAST | 218 #if defined(OS_ANDROID) // WMPI_CAST |
219 cast_impl_(this, client_, params.context_3d_cb()), | 219 cast_impl_(this, client_, params.context_3d_cb()), |
220 #endif | 220 #endif |
221 volume_(1.0), | 221 volume_(1.0), |
222 volume_multiplier_(1.0), | 222 volume_multiplier_(1.0), |
223 renderer_factory_(std::move(renderer_factory)), | 223 renderer_factory_(std::move(renderer_factory)), |
224 surface_manager_(params.surface_manager()), | 224 surface_manager_(params.surface_manager()), |
225 overlay_surface_id_(SurfaceManager::kNoSurfaceID), | 225 overlay_surface_id_(SurfaceManager::kNoSurfaceID), |
226 suppress_destruction_errors_(false), | 226 suppress_destruction_errors_(false), |
227 can_suspend_state_(CanSuspendState::UNKNOWN), | 227 can_suspend_state_(CanSuspendState::UNKNOWN), |
228 is_encrypted_(false) { | 228 is_encrypted_(false), |
| 229 underflow_count_(0) { |
229 DCHECK(!adjust_allocated_memory_cb_.is_null()); | 230 DCHECK(!adjust_allocated_memory_cb_.is_null()); |
230 DCHECK(renderer_factory_); | 231 DCHECK(renderer_factory_); |
231 DCHECK(client_); | 232 DCHECK(client_); |
232 | 233 |
233 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | 234 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( |
234 switches::kForceVideoOverlays); | 235 switches::kForceVideoOverlays); |
235 | 236 |
236 if (delegate_) | 237 if (delegate_) |
237 delegate_id_ = delegate_->AddObserver(this); | 238 delegate_id_ = delegate_->AddObserver(this); |
238 | 239 |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 if (data_source_) | 1092 if (data_source_) |
1092 data_source_->OnBufferingHaveEnough(false); | 1093 data_source_->OnBufferingHaveEnough(false); |
1093 | 1094 |
1094 // Blink expects a timeChanged() in response to a seek(). | 1095 // Blink expects a timeChanged() in response to a seek(). |
1095 if (should_notify_time_changed_) | 1096 if (should_notify_time_changed_) |
1096 client_->timeChanged(); | 1097 client_->timeChanged(); |
1097 | 1098 |
1098 // Once we have enough, start reporting the total memory usage. We'll also | 1099 // Once we have enough, start reporting the total memory usage. We'll also |
1099 // report once playback starts. | 1100 // report once playback starts. |
1100 ReportMemoryUsage(); | 1101 ReportMemoryUsage(); |
| 1102 |
| 1103 // Report the amount of time it took to leave the underflow state. Don't |
| 1104 // bother to report this for MSE playbacks since it's out of our control. |
| 1105 if (underflow_timer_ && data_source_) { |
| 1106 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", |
| 1107 underflow_timer_->Elapsed()); |
| 1108 underflow_timer_.reset(); |
| 1109 } |
1101 } else { | 1110 } else { |
1102 // Buffering has underflowed. | 1111 // Buffering has underflowed. |
1103 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING); | 1112 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING); |
1104 // It shouldn't be possible to underflow if we've not advanced past | 1113 // It shouldn't be possible to underflow if we've not advanced past |
1105 // HAVE_CURRENT_DATA. | 1114 // HAVE_CURRENT_DATA. |
1106 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData); | 1115 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData); |
1107 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData); | 1116 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData); |
| 1117 |
| 1118 // Report the number of times we've entered the underflow state. Only report |
| 1119 // for src= playback since for MSE it's out of our control. |
| 1120 if (data_source_) { |
| 1121 UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", ++underflow_count_); |
| 1122 underflow_timer_.reset(new base::ElapsedTimer()); |
| 1123 } |
1108 } | 1124 } |
1109 | 1125 |
1110 UpdatePlayState(); | 1126 UpdatePlayState(); |
1111 } | 1127 } |
1112 | 1128 |
1113 void WebMediaPlayerImpl::OnDurationChange() { | 1129 void WebMediaPlayerImpl::OnDurationChange() { |
1114 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1130 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1115 | 1131 |
1116 // TODO(sandersd): We should call delegate_->DidPlay() with the new duration, | 1132 // TODO(sandersd): We should call delegate_->DidPlay() with the new duration, |
1117 // especially if it changed from <5s to >5s. | 1133 // especially if it changed from <5s to >5s. |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 pipeline_metadata_.natural_size, | 1806 pipeline_metadata_.natural_size, |
1791 base::Bind(&GetCurrentTimeInternal, this))); | 1807 base::Bind(&GetCurrentTimeInternal, this))); |
1792 watch_time_reporter_->OnVolumeChange(volume_); | 1808 watch_time_reporter_->OnVolumeChange(volume_); |
1793 if (delegate_ && delegate_->IsHidden()) | 1809 if (delegate_ && delegate_->IsHidden()) |
1794 watch_time_reporter_->OnHidden(); | 1810 watch_time_reporter_->OnHidden(); |
1795 else | 1811 else |
1796 watch_time_reporter_->OnShown(); | 1812 watch_time_reporter_->OnShown(); |
1797 } | 1813 } |
1798 | 1814 |
1799 } // namespace media | 1815 } // namespace media |
OLD | NEW |