Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2707973005: Remove Media.UnderflowCount, add Media.UnderflowDuration for MSE. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 #endif 227 #endif
228 volume_(1.0), 228 volume_(1.0),
229 volume_multiplier_(1.0), 229 volume_multiplier_(1.0),
230 renderer_factory_(std::move(renderer_factory)), 230 renderer_factory_(std::move(renderer_factory)),
231 surface_manager_(params.surface_manager()), 231 surface_manager_(params.surface_manager()),
232 overlay_surface_id_(SurfaceManager::kNoSurfaceID), 232 overlay_surface_id_(SurfaceManager::kNoSurfaceID),
233 suppress_destruction_errors_(false), 233 suppress_destruction_errors_(false),
234 suspend_enabled_(params.allow_suspend()), 234 suspend_enabled_(params.allow_suspend()),
235 use_fallback_path_(false), 235 use_fallback_path_(false),
236 is_encrypted_(false), 236 is_encrypted_(false),
237 underflow_count_(0),
238 preroll_attempt_pending_(false), 237 preroll_attempt_pending_(false),
239 observer_(params.media_observer()), 238 observer_(params.media_observer()),
240 max_keyframe_distance_to_disable_background_video_( 239 max_keyframe_distance_to_disable_background_video_(
241 params.max_keyframe_distance_to_disable_background_video()), 240 params.max_keyframe_distance_to_disable_background_video()),
242 enable_instant_source_buffer_gc_( 241 enable_instant_source_buffer_gc_(
243 params.enable_instant_source_buffer_gc()) { 242 params.enable_instant_source_buffer_gc()) {
244 DCHECK(!adjust_allocated_memory_cb_.is_null()); 243 DCHECK(!adjust_allocated_memory_cb_.is_null());
245 DCHECK(renderer_factory_); 244 DCHECK(renderer_factory_);
246 DCHECK(client_); 245 DCHECK(client_);
247 DCHECK(delegate_); 246 DCHECK(delegate_);
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 #else 1103 #else
1105 paused_time_ = pipeline_.GetMediaTime(); 1104 paused_time_ = pipeline_.GetMediaTime();
1106 #endif 1105 #endif
1107 } else { 1106 } else {
1108 DCHECK(watch_time_reporter_); 1107 DCHECK(watch_time_reporter_);
1109 watch_time_reporter_->OnPlaying(); 1108 watch_time_reporter_->OnPlaying();
1110 } 1109 }
1111 if (time_updated) 1110 if (time_updated)
1112 should_notify_time_changed_ = true; 1111 should_notify_time_changed_ = true;
1113 1112
1114 // Reset underflow count upon seek; this prevents looping videos and user 1113 // Reset underflow duration upon seek; this prevents looping videos and user
1115 // actions from artificially inflating the underflow count. 1114 // actions from artificially inflating the duration.
1116 underflow_count_ = 0; 1115 underflow_timer_.reset();
1117 1116
1118 // Background video optimizations are delayed when shown/hidden if pipeline 1117 // Background video optimizations are delayed when shown/hidden if pipeline
1119 // is seeking. 1118 // is seeking.
1120 UpdateBackgroundVideoOptimizationState(); 1119 UpdateBackgroundVideoOptimizationState();
1121 } 1120 }
1122 1121
1123 void WebMediaPlayerImpl::OnPipelineSuspended() { 1122 void WebMediaPlayerImpl::OnPipelineSuspended() {
1124 #if defined(OS_ANDROID) 1123 #if defined(OS_ANDROID)
1125 if (isRemote()) { 1124 if (isRemote()) {
1126 scoped_refptr<VideoFrame> frame = cast_impl_.GetCastingBanner(); 1125 scoped_refptr<VideoFrame> frame = cast_impl_.GetCastingBanner();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 1276
1278 // Ignore buffering state changes until we've completed all outstanding 1277 // Ignore buffering state changes until we've completed all outstanding
1279 // operations. 1278 // operations.
1280 if (!pipeline_controller_.IsStable()) 1279 if (!pipeline_controller_.IsStable())
1281 return; 1280 return;
1282 1281
1283 media_log_->AddEvent(media_log_->CreateBufferingStateChangedEvent( 1282 media_log_->AddEvent(media_log_->CreateBufferingStateChangedEvent(
1284 "pipeline_buffering_state", state)); 1283 "pipeline_buffering_state", state));
1285 1284
1286 if (state == BUFFERING_HAVE_ENOUGH) { 1285 if (state == BUFFERING_HAVE_ENOUGH) {
1287 if (data_source_ && 1286 if (highest_ready_state_ < WebMediaPlayer::ReadyStateHaveEnoughData) {
1288 highest_ready_state_ < WebMediaPlayer::ReadyStateHaveEnoughData) { 1287 // Record a zero value for underflow histogram so that the histogram
1289 DCHECK_EQ(underflow_count_, 0);
1290 // Record a zero value for underflow histograms so that the histogram
1291 // includes playbacks which never encounter an underflow event. 1288 // includes playbacks which never encounter an underflow event.
1292 UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", 0); 1289 RecordUnderflowDuration(base::TimeDelta());
1293 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", base::TimeDelta());
1294 } 1290 }
1295 1291
1296 // TODO(chcunningham): Monitor playback position vs buffered. Potentially 1292 // TODO(chcunningham): Monitor playback position vs buffered. Potentially
1297 // transition to HAVE_FUTURE_DATA here if not enough is buffered. 1293 // transition to HAVE_FUTURE_DATA here if not enough is buffered.
1298 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); 1294 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
1299 1295
1300 // Let the DataSource know we have enough data. It may use this information 1296 // Let the DataSource know we have enough data. It may use this information
1301 // to release unused network connections. 1297 // to release unused network connections.
1302 if (data_source_) 1298 if (data_source_)
1303 data_source_->OnBufferingHaveEnough(false); 1299 data_source_->OnBufferingHaveEnough(false);
1304 1300
1305 // Blink expects a timeChanged() in response to a seek(). 1301 // Blink expects a timeChanged() in response to a seek().
1306 if (should_notify_time_changed_) { 1302 if (should_notify_time_changed_) {
1307 should_notify_time_changed_ = false; 1303 should_notify_time_changed_ = false;
1308 client_->timeChanged(); 1304 client_->timeChanged();
1309 } 1305 }
1310 1306
1311 // Once we have enough, start reporting the total memory usage. We'll also 1307 // Once we have enough, start reporting the total memory usage. We'll also
1312 // report once playback starts. 1308 // report once playback starts.
1313 ReportMemoryUsage(); 1309 ReportMemoryUsage();
1314 1310
1315 // Report the amount of time it took to leave the underflow state. Don't 1311 // Report the amount of time it took to leave the underflow state.
1316 // bother to report this for MSE playbacks since it's out of our control. 1312 if (underflow_timer_) {
1317 if (underflow_timer_ && data_source_) { 1313 RecordUnderflowDuration(underflow_timer_->Elapsed());
1318 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration",
1319 underflow_timer_->Elapsed());
1320 underflow_timer_.reset(); 1314 underflow_timer_.reset();
1321 } 1315 }
1322 } else { 1316 } else {
1323 // Buffering has underflowed. 1317 // Buffering has underflowed.
1324 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING); 1318 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING);
1325 1319
1326 // Report the number of times we've entered the underflow state. Only report 1320 // Report the number of times we've entered the underflow state. Only report
1327 // for src= playback since for MSE it's out of our control. Ensure we only 1321 // for src= playback since for MSE it's out of our control. Ensure we only
1328 // report the value when transitioning from HAVE_ENOUGH to HAVE_NOTHING. 1322 // report the value when transitioning from HAVE_ENOUGH to HAVE_NOTHING.
1329 if (data_source_ && 1323 if (data_source_ &&
1330 ready_state_ == WebMediaPlayer::ReadyStateHaveEnoughData) { 1324 ready_state_ == WebMediaPlayer::ReadyStateHaveEnoughData) {
1331 UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", ++underflow_count_);
1332 underflow_timer_.reset(new base::ElapsedTimer()); 1325 underflow_timer_.reset(new base::ElapsedTimer());
1333 } 1326 }
1334 1327
1335 // It shouldn't be possible to underflow if we've not advanced past 1328 // It shouldn't be possible to underflow if we've not advanced past
1336 // HAVE_CURRENT_DATA. 1329 // HAVE_CURRENT_DATA.
1337 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData); 1330 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData);
1338 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData); 1331 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData);
1339 } 1332 }
1340 1333
1341 UpdatePlayState(); 1334 UpdatePlayState();
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 time_to_first_frame); 2286 time_to_first_frame);
2294 } 2287 }
2295 } 2288 }
2296 2289
2297 void WebMediaPlayerImpl::SwitchRenderer(bool disable_pipeline_auto_suspend) { 2290 void WebMediaPlayerImpl::SwitchRenderer(bool disable_pipeline_auto_suspend) {
2298 DCHECK(main_task_runner_->BelongsToCurrentThread()); 2291 DCHECK(main_task_runner_->BelongsToCurrentThread());
2299 disable_pipeline_auto_suspend_ = disable_pipeline_auto_suspend; 2292 disable_pipeline_auto_suspend_ = disable_pipeline_auto_suspend;
2300 ScheduleRestart(); 2293 ScheduleRestart();
2301 } 2294 }
2302 2295
2296 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) {
2297 DCHECK(data_source_ || chunk_demuxer_);
2298 if (data_source_)
2299 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration);
2300 else
2301 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration);
2302 }
2303
2303 } // namespace media 2304 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698