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

Side by Side Diff: media/base/pipeline_impl.cc

Issue 269002: Report stalled event correctly for <video> (Closed)
Patch Set: comments Created 11 years, 2 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 (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names,
6 // potential deadlocks, etc... 6 // potential deadlocks, etc...
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/condition_variable.h" 9 #include "base/condition_variable.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 case kSeeking: 150 case kSeeking:
151 case kStarting: 151 case kStarting:
152 case kStarted: 152 case kStarted:
153 case kEnded: 153 case kEnded:
154 return true; 154 return true;
155 default: 155 default:
156 return false; 156 return false;
157 } 157 }
158 } 158 }
159 159
160 bool PipelineImpl::IsNetworkActive() const {
161 AutoLock auto_lock(lock_);
162 return network_activity_;
163 }
164
160 bool PipelineImpl::IsRendered(const std::string& major_mime_type) const { 165 bool PipelineImpl::IsRendered(const std::string& major_mime_type) const {
161 AutoLock auto_lock(lock_); 166 AutoLock auto_lock(lock_);
162 bool is_rendered = (rendered_mime_types_.find(major_mime_type) != 167 bool is_rendered = (rendered_mime_types_.find(major_mime_type) !=
163 rendered_mime_types_.end()); 168 rendered_mime_types_.end());
164 return is_rendered; 169 return is_rendered;
165 } 170 }
166 171
167 float PipelineImpl::GetPlaybackRate() const { 172 float PipelineImpl::GetPlaybackRate() const {
168 AutoLock auto_lock(lock_); 173 AutoLock auto_lock(lock_);
169 return playback_rate_; 174 return playback_rate_;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 << "Permanent callbacks should be set before the pipeline has started"; 282 << "Permanent callbacks should be set before the pipeline has started";
278 ended_callback_.reset(ended_callback); 283 ended_callback_.reset(ended_callback);
279 } 284 }
280 285
281 void PipelineImpl::SetPipelineErrorCallback(PipelineCallback* error_callback) { 286 void PipelineImpl::SetPipelineErrorCallback(PipelineCallback* error_callback) {
282 DCHECK(!IsRunning()) 287 DCHECK(!IsRunning())
283 << "Permanent callbacks should be set before the pipeline has started"; 288 << "Permanent callbacks should be set before the pipeline has started";
284 error_callback_.reset(error_callback); 289 error_callback_.reset(error_callback);
285 } 290 }
286 291
292 void PipelineImpl::SetNetworkEventCallback(PipelineCallback* network_callback) {
293 DCHECK(!IsRunning())
294 << "Permanent callbacks should be set before the pipeline has started";
295 network_callback_.reset(network_callback);
296 }
297
287 void PipelineImpl::ResetState() { 298 void PipelineImpl::ResetState() {
288 AutoLock auto_lock(lock_); 299 AutoLock auto_lock(lock_);
289 const base::TimeDelta kZero; 300 const base::TimeDelta kZero;
290 running_ = false; 301 running_ = false;
291 duration_ = kZero; 302 duration_ = kZero;
292 buffered_time_ = kZero; 303 buffered_time_ = kZero;
293 buffered_bytes_ = 0; 304 buffered_bytes_ = 0;
294 streaming_ = false; 305 streaming_ = false;
295 loaded_ = false; 306 loaded_ = false;
296 total_bytes_ = 0; 307 total_bytes_ = 0;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 message_loop_->PostTask(FROM_HERE, 421 message_loop_->PostTask(FROM_HERE,
411 NewRunnableMethod(this, &PipelineImpl::NotifyEndedTask)); 422 NewRunnableMethod(this, &PipelineImpl::NotifyEndedTask));
412 } 423 }
413 424
414 void PipelineImpl::SetLoaded(bool loaded) { 425 void PipelineImpl::SetLoaded(bool loaded) {
415 DCHECK(IsRunning()); 426 DCHECK(IsRunning());
416 AutoLock auto_lock(lock_); 427 AutoLock auto_lock(lock_);
417 loaded_ = loaded; 428 loaded_ = loaded;
418 } 429 }
419 430
431 void PipelineImpl::SetNetworkActivity(bool network_activity) {
432 DCHECK(IsRunning());
433 {
434 AutoLock auto_lock(lock_);
435 network_activity_ = network_activity;
436 }
437 message_loop_->PostTask(FROM_HERE,
438 NewRunnableMethod(this, &PipelineImpl::NotifyNetworkEventTask));
439 }
440
420 void PipelineImpl::BroadcastMessage(FilterMessage message) { 441 void PipelineImpl::BroadcastMessage(FilterMessage message) {
421 DCHECK(IsRunning()); 442 DCHECK(IsRunning());
422 443
423 // Broadcast the message on the message loop. 444 // Broadcast the message on the message loop.
424 message_loop_->PostTask(FROM_HERE, 445 message_loop_->PostTask(FROM_HERE,
425 NewRunnableMethod(this, &PipelineImpl::BroadcastMessageTask, 446 NewRunnableMethod(this, &PipelineImpl::BroadcastMessageTask,
426 message)); 447 message));
427 } 448 }
428 449
429 void PipelineImpl::InsertRenderedMimeType(const std::string& major_mime_type) { 450 void PipelineImpl::InsertRenderedMimeType(const std::string& major_mime_type) {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 return; 732 return;
712 } 733 }
713 734
714 // Transition to ended, executing the callback if present. 735 // Transition to ended, executing the callback if present.
715 state_ = kEnded; 736 state_ = kEnded;
716 if (ended_callback_.get()) { 737 if (ended_callback_.get()) {
717 ended_callback_->Run(); 738 ended_callback_->Run();
718 } 739 }
719 } 740 }
720 741
742 void PipelineImpl::NotifyNetworkEventTask() {
743 DCHECK_EQ(MessageLoop::current(), message_loop_);
744 if (network_callback_.get()) {
745 network_callback_->Run();
746 }
747 }
748
721 void PipelineImpl::BroadcastMessageTask(FilterMessage message) { 749 void PipelineImpl::BroadcastMessageTask(FilterMessage message) {
722 DCHECK_EQ(MessageLoop::current(), message_loop_); 750 DCHECK_EQ(MessageLoop::current(), message_loop_);
723 751
724 // TODO(kylep): This is a horribly ugly hack, but we have no better way to 752 // TODO(kylep): This is a horribly ugly hack, but we have no better way to
725 // log that audio is not and will not be working. 753 // log that audio is not and will not be working.
726 if (message == media::kMsgDisableAudio) { 754 if (message == media::kMsgDisableAudio) {
727 // |rendered_mime_types_| is read through public methods so we need to lock 755 // |rendered_mime_types_| is read through public methods so we need to lock
728 // this variable. 756 // this variable.
729 AutoLock auto_lock(lock_); 757 AutoLock auto_lock(lock_);
730 rendered_mime_types_.erase(mime_type::kMajorTypeAudio); 758 rendered_mime_types_.erase(mime_type::kMajorTypeAudio);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 989
962 // Reset the pipeline, which will decrement a reference to this object. 990 // Reset the pipeline, which will decrement a reference to this object.
963 // We will get destroyed as soon as the remaining tasks finish executing. 991 // We will get destroyed as soon as the remaining tasks finish executing.
964 // To be safe, we'll set our pipeline reference to NULL. 992 // To be safe, we'll set our pipeline reference to NULL.
965 filters_.clear(); 993 filters_.clear();
966 filter_types_.clear(); 994 filter_types_.clear();
967 STLDeleteElements(&filter_threads_); 995 STLDeleteElements(&filter_threads_);
968 } 996 }
969 997
970 } // namespace media 998 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698