summaryrefslogtreecommitdiffstats
path: root/media/base/pipeline.cc
diff options
context:
space:
mode:
authortkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 04:14:24 +0000
committertkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 04:14:24 +0000
commite04e01b5c5fff56d4b3959e14ec7d4392b8ad3f1 (patch)
treeda6b923f1e83391fd882c5fe0fa634f74a0053d1 /media/base/pipeline.cc
parentba30c18a957290ff02ab9872a1a9dd8c4ee2f14a (diff)
downloadchromium_src-e04e01b5c5fff56d4b3959e14ec7d4392b8ad3f1.zip
chromium_src-e04e01b5c5fff56d4b3959e14ec7d4392b8ad3f1.tar.gz
chromium_src-e04e01b5c5fff56d4b3959e14ec7d4392b8ad3f1.tar.bz2
Revert 136486 - Delete DownloadRateMonitor since it's never worked right.
(and it complicates other things I want to do) LayoutTests/media/video-error-does-not-exist.html crashes by r136486. BUG=73609 Review URL: https://chromiumcodereview.appspot.com/10382109 TBR=fischman@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136500 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/pipeline.cc')
-rw-r--r--media/base/pipeline.cc43
1 files changed, 40 insertions, 3 deletions
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
index d465e2d..29a8dd0 100644
--- a/media/base/pipeline.cc
+++ b/media/base/pipeline.cc
@@ -71,7 +71,8 @@ Pipeline::Pipeline(MessageLoop* message_loop, MediaLog* media_log)
waiting_for_clock_update_(false),
state_(kCreated),
current_bytes_(0),
- creation_time_(base::Time::Now()) {
+ creation_time_(base::Time::Now()),
+ is_downloading_data_(false) {
media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated));
ResetState();
media_log_->AddEvent(
@@ -116,6 +117,8 @@ void Pipeline::Seek(base::TimeDelta time,
base::AutoLock auto_lock(lock_);
CHECK(running_) << "Media pipeline isn't running";
+ download_rate_monitor_.Stop();
+
message_loop_->PostTask(FROM_HERE, base::Bind(
&Pipeline::SeekTask, this, time, seek_cb));
}
@@ -225,12 +228,12 @@ void Pipeline::GetNaturalVideoSize(gfx::Size* out_size) const {
bool Pipeline::IsStreaming() const {
base::AutoLock auto_lock(lock_);
- return !demuxer_->IsSeekable();
+ return streaming_;
}
bool Pipeline::IsLocalSource() const {
base::AutoLock auto_lock(lock_);
- return demuxer_->IsLocalSource();
+ return local_source_;
}
PipelineStatistics Pipeline::GetStatistics() const {
@@ -267,6 +270,8 @@ void Pipeline::ResetState() {
playback_rate_change_pending_ = false;
buffered_bytes_ = 0;
buffered_time_ranges_.clear();
+ streaming_ = false;
+ local_source_ = false;
total_bytes_ = 0;
natural_size_.SetSize(0, 0);
volume_ = 1.0f;
@@ -278,6 +283,7 @@ void Pipeline::ResetState() {
waiting_for_clock_update_ = false;
audio_disabled_ = false;
clock_->Reset();
+ download_rate_monitor_.Reset();
}
void Pipeline::SetState(State next_state) {
@@ -446,6 +452,7 @@ void Pipeline::SetTotalBytes(int64 total_bytes) {
base::AutoLock auto_lock(lock_);
total_bytes_ = total_bytes;
+ download_rate_monitor_.set_total_bytes(total_bytes_);
}
void Pipeline::SetBufferedBytes(int64 buffered_bytes) {
@@ -455,6 +462,7 @@ void Pipeline::SetBufferedBytes(int64 buffered_bytes) {
if (buffered_bytes < current_bytes_)
current_bytes_ = buffered_bytes;
buffered_bytes_ = buffered_bytes;
+ download_rate_monitor_.SetBufferedBytes(buffered_bytes, base::Time::Now());
UpdateBufferedTimeRanges_Locked();
}
@@ -496,6 +504,11 @@ void Pipeline::SetNetworkActivity(bool is_downloading_data) {
if (is_downloading_data)
type = DOWNLOAD_CONTINUED;
+ {
+ base::AutoLock auto_lock(lock_);
+ download_rate_monitor_.SetNetworkActivity(is_downloading_data);
+ }
+
message_loop_->PostTask(FROM_HERE, base::Bind(
&Pipeline::NotifyNetworkEventTask, this, type));
media_log_->AddEvent(
@@ -960,6 +973,20 @@ void Pipeline::FilterStateTransitionTask() {
StartClockIfWaitingForTimeUpdate_Locked();
}
+ // Start monitoring rate of downloading.
+ int bitrate = 0;
+ if (demuxer_) {
+ bitrate = demuxer_->GetBitrate();
+ local_source_ = demuxer_->IsLocalSource();
+ streaming_ = !demuxer_->IsSeekable();
+ }
+ // Needs to be locked because most other calls to |download_rate_monitor_|
+ // occur on the renderer thread.
+ download_rate_monitor_.Start(
+ base::Bind(&Pipeline::OnCanPlayThrough, this),
+ bitrate, streaming_, local_source_);
+ download_rate_monitor_.SetBufferedBytes(buffered_bytes_, base::Time::Now());
+
if (IsPipelineStopPending()) {
// We had a pending stop request need to be honored right now.
TearDownPipeline();
@@ -1306,6 +1333,16 @@ void Pipeline::OnAudioUnderflow() {
audio_renderer_->ResumeAfterUnderflow(true);
}
+void Pipeline::OnCanPlayThrough() {
+ message_loop_->PostTask(FROM_HERE, base::Bind(
+ &Pipeline::NotifyCanPlayThrough, this));
+}
+
+void Pipeline::NotifyCanPlayThrough() {
+ DCHECK(message_loop_->BelongsToCurrentThread());
+ NotifyNetworkEventTask(CAN_PLAY_THROUGH);
+}
+
void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
lock_.AssertAcquired();
if (!waiting_for_clock_update_)