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

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

Issue 2320053004: Don't underflow for background rendering. Ensure accurate counts. (Closed)
Patch Set: Created 4 years, 3 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
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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 // Report the amount of time it took to leave the underflow state. Don't 1129 // Report the amount of time it took to leave the underflow state. Don't
1130 // bother to report this for MSE playbacks since it's out of our control. 1130 // bother to report this for MSE playbacks since it's out of our control.
1131 if (underflow_timer_ && data_source_) { 1131 if (underflow_timer_ && data_source_) {
1132 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", 1132 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration",
1133 underflow_timer_->Elapsed()); 1133 underflow_timer_->Elapsed());
1134 underflow_timer_.reset(); 1134 underflow_timer_.reset();
1135 } 1135 }
1136 } else { 1136 } else {
1137 // Buffering has underflowed. 1137 // Buffering has underflowed.
1138 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING); 1138 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING);
1139
1140 // Report the number of times we've entered the underflow state. Only report
1141 // for src= playback since for MSE it's out of our control. Ensure we only
1142 // report the value when transitioning from HAVE_ENOUGH to HAVE_NOTHING.
1143 if (data_source_ &&
1144 ready_state_ == WebMediaPlayer::ReadyStateHaveEnoughData) {
chcunningham 2016/09/09 21:27:05 I think this is fine, but I'm not sure it will hav
DaleCurtis 2016/09/09 21:51:41 Correct, that was my interpretation, but I wasn't
1145 UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", ++underflow_count_);
1146 underflow_timer_.reset(new base::ElapsedTimer());
1147 }
1148
1139 // It shouldn't be possible to underflow if we've not advanced past 1149 // It shouldn't be possible to underflow if we've not advanced past
1140 // HAVE_CURRENT_DATA. 1150 // HAVE_CURRENT_DATA.
1141 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData); 1151 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData);
1142 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData); 1152 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData);
1143
1144 // Report the number of times we've entered the underflow state. Only report
1145 // for src= playback since for MSE it's out of our control.
1146 if (data_source_) {
1147 UMA_HISTOGRAM_COUNTS_100("Media.UnderflowCount", ++underflow_count_);
1148 underflow_timer_.reset(new base::ElapsedTimer());
1149 }
1150 } 1153 }
1151 1154
1152 UpdatePlayState(); 1155 UpdatePlayState();
1153 } 1156 }
1154 1157
1155 void WebMediaPlayerImpl::OnDurationChange() { 1158 void WebMediaPlayerImpl::OnDurationChange() {
1156 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1159 DCHECK(main_task_runner_->BelongsToCurrentThread());
1157 1160
1158 // TODO(sandersd): We should call delegate_->DidPlay() with the new duration, 1161 // TODO(sandersd): We should call delegate_->DidPlay() with the new duration,
1159 // especially if it changed from <5s to >5s. 1162 // especially if it changed from <5s to >5s.
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 pipeline_metadata_.natural_size, 1816 pipeline_metadata_.natural_size,
1814 base::Bind(&GetCurrentTimeInternal, this))); 1817 base::Bind(&GetCurrentTimeInternal, this)));
1815 watch_time_reporter_->OnVolumeChange(volume_); 1818 watch_time_reporter_->OnVolumeChange(volume_);
1816 if (delegate_ && delegate_->IsHidden()) 1819 if (delegate_ && delegate_->IsHidden())
1817 watch_time_reporter_->OnHidden(); 1820 watch_time_reporter_->OnHidden();
1818 else 1821 else
1819 watch_time_reporter_->OnShown(); 1822 watch_time_reporter_->OnShown();
1820 } 1823 }
1821 1824
1822 } // namespace media 1825 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/renderers/video_renderer_impl.cc » ('j') | media/renderers/video_renderer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698