Chromium Code Reviews| 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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 } else { | |
| 1048 // Buffering has underflowed. | |
| 1049 DCHECK_EQ(state, BUFFERING_HAVE_NOTHING); | |
| 1050 // It shouldn't be possible to underflow if we've not advanced past | |
| 1051 // HAVE_CURRENT_DATA. | |
| 1052 DCHECK_GT(highest_ready_state_, WebMediaPlayer::ReadyStateHaveCurrentData); | |
| 1053 SetReadyState(WebMediaPlayer::ReadyStateHaveCurrentData); | |
| 1054 } | |
| 1047 | 1055 |
| 1048 // Blink expects a timeChanged() in response to a seek(). | 1056 // Blink expects a timeChanged() in response to a seek(). |
| 1049 if (should_notify_time_changed_) | 1057 if (should_notify_time_changed_) |
| 1050 client_->timeChanged(); | 1058 client_->timeChanged(); |
|
wolenetz
2016/07/07 21:32:03
Is timeChanged() notification also always required
sandersd (OOO until July 31)
2016/07/07 21:49:19
Changing the ready state does not directly change
chcunningham
2016/07/07 22:29:41
sandersd@, do we need to bother calling timeChange
sandersd (OOO until July 31)
2016/07/07 22:33:12
HTMLMediaElement actually hooks this to fire the '
chcunningham
2016/07/12 00:47:17
Ack. Moved this up. FYI I also moved ReportMemoryU
wolenetz
2016/07/13 22:27:54
I think this is correct.
| |
| 1051 | 1059 |
| 1052 // Once we have enough, start reporting the total memory usage. We'll also | 1060 // Once we have enough, start reporting the total memory usage. We'll also |
| 1053 // report once playback starts. | 1061 // report once playback starts. |
| 1054 ReportMemoryUsage(); | 1062 ReportMemoryUsage(); |
| 1055 | 1063 |
| 1056 UpdatePlayState(); | 1064 UpdatePlayState(); |
|
wolenetz
2016/07/07 21:32:03
Does underflow allow us to suspend if idle (stalle
sandersd (OOO until July 31)
2016/07/07 21:49:19
In general these conditions should be unchanged; t
chcunningham
2016/07/07 22:29:41
sandersd@ do we already have a test for this usual
sandersd (OOO until July 31)
2016/07/07 22:33:12
There are already tests for the main cases of note
chcunningham
2016/07/12 00:47:17
Underflow is a very different user experience then
wolenetz
2016/07/13 22:27:54
Acknowledged.
| |
| 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) |
| 1065 return; | 1073 return; |
| 1066 | 1074 |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| OLD | NEW |