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

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

Issue 2115143002: Transition media element to HAVE_CURRENT_DATA upon underflow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 4 years, 5 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 | « no previous file | media/blink/webmediaplayer_impl_unittest.cc » ('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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 1028
1029 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { 1029 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) {
1030 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; 1030 DVLOG(1) << __FUNCTION__ << "(" << state << ")";
1031 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1031 DCHECK(main_task_runner_->BelongsToCurrentThread());
1032 1032
1033 // Ignore buffering state changes until we've completed all outstanding 1033 // Ignore buffering state changes until we've completed all outstanding
1034 // operations. 1034 // operations.
1035 if (!pipeline_controller_.IsStable()) 1035 if (!pipeline_controller_.IsStable())
1036 return; 1036 return;
1037 1037
1038 // TODO(scherkus): Handle other buffering states when Pipeline starts using 1038 if (state == BUFFERING_HAVE_ENOUGH) {
1039 // them and translate them ready state changes http://crbug.com/144683 1039 // TODO(chcunningham): Monitor playback position vs buffered. Potentially
1040 DCHECK_EQ(state, BUFFERING_HAVE_ENOUGH); 1040 // transition to HAVE_FUTURE_DATA here if not enough is buffered.
1041 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); 1041 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
1042 1042
1043 // Let the DataSource know we have enough data. It may use this information to 1043 // Let the DataSource know we have enough data. It may use this information
1044 // release unused network connections. 1044 // to release unused network connections.
1045 if (data_source_) 1045 if (data_source_)
1046 data_source_->OnBufferingHaveEnough(false); 1046 data_source_->OnBufferingHaveEnough(false);
1047 1047
1048 // Blink expects a timeChanged() in response to a seek(). 1048 // Blink expects a timeChanged() in response to a seek().
1049 if (should_notify_time_changed_) 1049 if (should_notify_time_changed_)
1050 client_->timeChanged(); 1050 client_->timeChanged();
1051 1051
1052 // Once we have enough, start reporting the total memory usage. We'll also 1052 // Once we have enough, start reporting the total memory usage. We'll also
1053 // report once playback starts. 1053 // report once playback starts.
1054 ReportMemoryUsage(); 1054 ReportMemoryUsage();
1055 } else {
1056 // Buffering has underflowed.
1057 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING);
1058 // It shouldn't be possible to underflow if we've not advanced past
1059 // HAVE_CURRENT_DATA.
1060 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData);
1061 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData);
1062 }
1055 1063
1056 UpdatePlayState(); 1064 UpdatePlayState();
1057 } 1065 }
1058 1066
1059 void WebMediaPlayerImpl::OnDurationChange() { 1067 void WebMediaPlayerImpl::OnDurationChange() {
1060 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1068 DCHECK(main_task_runner_->BelongsToCurrentThread());
1061 1069
1062 // TODO(sandersd): We should call delegate_->DidPlay() with the new duration, 1070 // TODO(sandersd): We should call delegate_->DidPlay() with the new duration,
1063 // especially if it changed from <5s to >5s. 1071 // especially if it changed from <5s to >5s.
1064 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) 1072 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing)
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 if (isRemote()) 1698 if (isRemote())
1691 return; 1699 return;
1692 #endif 1700 #endif
1693 1701
1694 // Idle timeout chosen arbitrarily. 1702 // Idle timeout chosen arbitrarily.
1695 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), 1703 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5),
1696 this, &WebMediaPlayerImpl::OnPause); 1704 this, &WebMediaPlayerImpl::OnPause);
1697 } 1705 }
1698 1706
1699 } // namespace media 1707 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698