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

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

Issue 2713883003: Merge M57: "Remove Media.UnderflowCount, add Media.UnderflowDuration for MSE." (Closed)
Patch Set: Created 3 years, 9 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 #endif 234 #endif
235 volume_(1.0), 235 volume_(1.0),
236 volume_multiplier_(1.0), 236 volume_multiplier_(1.0),
237 renderer_factory_(std::move(renderer_factory)), 237 renderer_factory_(std::move(renderer_factory)),
238 surface_manager_(params.surface_manager()), 238 surface_manager_(params.surface_manager()),
239 overlay_surface_id_(SurfaceManager::kNoSurfaceID), 239 overlay_surface_id_(SurfaceManager::kNoSurfaceID),
240 suppress_destruction_errors_(false), 240 suppress_destruction_errors_(false),
241 can_suspend_state_(CanSuspendState::UNKNOWN), 241 can_suspend_state_(CanSuspendState::UNKNOWN),
242 use_fallback_path_(false), 242 use_fallback_path_(false),
243 is_encrypted_(false), 243 is_encrypted_(false),
244 underflow_count_(0),
245 preroll_attempt_pending_(false), 244 preroll_attempt_pending_(false),
246 observer_(params.media_observer()) { 245 observer_(params.media_observer()) {
247 DCHECK(!adjust_allocated_memory_cb_.is_null()); 246 DCHECK(!adjust_allocated_memory_cb_.is_null());
248 DCHECK(renderer_factory_); 247 DCHECK(renderer_factory_);
249 DCHECK(client_); 248 DCHECK(client_);
250 249
251 tick_clock_.reset(new base::DefaultTickClock()); 250 tick_clock_.reset(new base::DefaultTickClock());
252 251
253 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 252 force_video_overlays_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
254 switches::kForceVideoOverlays); 253 switches::kForceVideoOverlays);
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 #else 1108 #else
1110 paused_time_ = pipeline_.GetMediaTime(); 1109 paused_time_ = pipeline_.GetMediaTime();
1111 #endif 1110 #endif
1112 } else { 1111 } else {
1113 DCHECK(watch_time_reporter_); 1112 DCHECK(watch_time_reporter_);
1114 watch_time_reporter_->OnPlaying(); 1113 watch_time_reporter_->OnPlaying();
1115 } 1114 }
1116 if (time_updated) 1115 if (time_updated)
1117 should_notify_time_changed_ = true; 1116 should_notify_time_changed_ = true;
1118 1117
1119 // Reset underflow count upon seek; this prevents looping videos and user 1118 // Reset underflow duration upon seek; this prevents looping videos and user
1120 // actions from artificially inflating the underflow count. 1119 // actions from artificially inflating the duration.
1121 underflow_count_ = 0; 1120 underflow_timer_.reset();
1122 1121
1123 // Background video optimizations are delayed when shown/hidden if pipeline 1122 // Background video optimizations are delayed when shown/hidden if pipeline
1124 // is seeking. 1123 // is seeking.
1125 UpdateBackgroundVideoOptimizationState(); 1124 UpdateBackgroundVideoOptimizationState();
1126 } 1125 }
1127 1126
1128 void WebMediaPlayerImpl::OnPipelineSuspended() { 1127 void WebMediaPlayerImpl::OnPipelineSuspended() {
1129 #if defined(OS_ANDROID) 1128 #if defined(OS_ANDROID)
1130 if (isRemote()) { 1129 if (isRemote()) {
1131 scoped_refptr<VideoFrame> frame = cast_impl_.GetCastingBanner(); 1130 scoped_refptr<VideoFrame> frame = cast_impl_.GetCastingBanner();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 1251
1253 // Ignore buffering state changes until we've completed all outstanding 1252 // Ignore buffering state changes until we've completed all outstanding
1254 // operations. 1253 // operations.
1255 if (!pipeline_controller_.IsStable()) 1254 if (!pipeline_controller_.IsStable())
1256 return; 1255 return;
1257 1256
1258 media_log_->AddEvent(media_log_->CreateBufferingStateChangedEvent( 1257 media_log_->AddEvent(media_log_->CreateBufferingStateChangedEvent(
1259 "pipeline_buffering_state", state)); 1258 "pipeline_buffering_state", state));
1260 1259
1261 if (state == BUFFERING_HAVE_ENOUGH) { 1260 if (state == BUFFERING_HAVE_ENOUGH) {
1262 if (data_source_ && 1261 if (highest_ready_state_ < WebMediaPlayer::ReadyStateHaveEnoughData) {
1263 highest_ready_state_ < WebMediaPlayer::ReadyStateHaveEnoughData) { 1262 // Record a zero value for underflow histogram so that the histogram
1264 DCHECK_EQ(underflow_count_, 0);
1265 // Record a zero value for underflow histograms so that the histogram
1266 // includes playbacks which never encounter an underflow event. 1263 // includes playbacks which never encounter an underflow event.
1267 UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", 0); 1264 RecordUnderflowDuration(base::TimeDelta());
1268 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", base::TimeDelta());
1269 } 1265 }
1270 1266
1271 // TODO(chcunningham): Monitor playback position vs buffered. Potentially 1267 // TODO(chcunningham): Monitor playback position vs buffered. Potentially
1272 // transition to HAVE_FUTURE_DATA here if not enough is buffered. 1268 // transition to HAVE_FUTURE_DATA here if not enough is buffered.
1273 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); 1269 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
1274 1270
1275 // Let the DataSource know we have enough data. It may use this information 1271 // Let the DataSource know we have enough data. It may use this information
1276 // to release unused network connections. 1272 // to release unused network connections.
1277 if (data_source_) 1273 if (data_source_)
1278 data_source_->OnBufferingHaveEnough(false); 1274 data_source_->OnBufferingHaveEnough(false);
1279 1275
1280 // Blink expects a timeChanged() in response to a seek(). 1276 // Blink expects a timeChanged() in response to a seek().
1281 if (should_notify_time_changed_) { 1277 if (should_notify_time_changed_) {
1282 should_notify_time_changed_ = false; 1278 should_notify_time_changed_ = false;
1283 client_->timeChanged(); 1279 client_->timeChanged();
1284 } 1280 }
1285 1281
1286 // Once we have enough, start reporting the total memory usage. We'll also 1282 // Once we have enough, start reporting the total memory usage. We'll also
1287 // report once playback starts. 1283 // report once playback starts.
1288 ReportMemoryUsage(); 1284 ReportMemoryUsage();
1289 1285
1290 // Report the amount of time it took to leave the underflow state. Don't 1286 // Report the amount of time it took to leave the underflow state.
1291 // bother to report this for MSE playbacks since it's out of our control. 1287 if (underflow_timer_) {
1292 if (underflow_timer_ && data_source_) { 1288 RecordUnderflowDuration(underflow_timer_->Elapsed());
1293 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration",
1294 underflow_timer_->Elapsed());
1295 underflow_timer_.reset(); 1289 underflow_timer_.reset();
1296 } 1290 }
1297 } else { 1291 } else {
1298 // Buffering has underflowed. 1292 // Buffering has underflowed.
1299 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING); 1293 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING);
1300 1294
1301 // Report the number of times we've entered the underflow state. Only report 1295 // Report the number of times we've entered the underflow state. Only report
1302 // for src= playback since for MSE it's out of our control. Ensure we only 1296 // for src= playback since for MSE it's out of our control. Ensure we only
1303 // report the value when transitioning from HAVE_ENOUGH to HAVE_NOTHING. 1297 // report the value when transitioning from HAVE_ENOUGH to HAVE_NOTHING.
1304 if (data_source_ && 1298 if (data_source_ &&
1305 ready_state_ == WebMediaPlayer::ReadyStateHaveEnoughData) { 1299 ready_state_ == WebMediaPlayer::ReadyStateHaveEnoughData) {
1306 UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", ++underflow_count_);
1307 underflow_timer_.reset(new base::ElapsedTimer()); 1300 underflow_timer_.reset(new base::ElapsedTimer());
1308 } 1301 }
1309 1302
1310 // It shouldn't be possible to underflow if we've not advanced past 1303 // It shouldn't be possible to underflow if we've not advanced past
1311 // HAVE_CURRENT_DATA. 1304 // HAVE_CURRENT_DATA.
1312 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData); 1305 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData);
1313 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData); 1306 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData);
1314 } 1307 }
1315 1308
1316 UpdatePlayState(); 1309 UpdatePlayState();
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 if (hasAudio()) { 2259 if (hasAudio()) {
2267 UMA_HISTOGRAM_TIMES( 2260 UMA_HISTOGRAM_TIMES(
2268 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack", 2261 "Media.Video.TimeFromForegroundToFirstFrame.DisableTrack",
2269 time_to_first_frame); 2262 time_to_first_frame);
2270 } else { 2263 } else {
2271 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused", 2264 UMA_HISTOGRAM_TIMES("Media.Video.TimeFromForegroundToFirstFrame.Paused",
2272 time_to_first_frame); 2265 time_to_first_frame);
2273 } 2266 }
2274 } 2267 }
2275 2268
2269 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) {
2270 DCHECK(data_source_ || chunk_demuxer_);
2271 if (data_source_)
2272 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration);
2273 else
2274 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration);
2275 }
2276
2276 } // namespace media 2277 } // 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