| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "media/base/pipeline_impl.h" | 8 #include "media/base/pipeline_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 const PipelineStatusCB& error_callback, | 91 const PipelineStatusCB& error_callback, |
| 92 const NetworkEventCB& network_callback) { | 92 const NetworkEventCB& network_callback) { |
| 93 DCHECK(!IsRunning()) | 93 DCHECK(!IsRunning()) |
| 94 << "Init() should be called before the pipeline has started"; | 94 << "Init() should be called before the pipeline has started"; |
| 95 ended_callback_ = ended_callback; | 95 ended_callback_ = ended_callback; |
| 96 error_callback_ = error_callback; | 96 error_callback_ = error_callback; |
| 97 network_callback_ = network_callback; | 97 network_callback_ = network_callback; |
| 98 } | 98 } |
| 99 | 99 |
| 100 // Creates the PipelineInternal and calls it's start method. | 100 // Creates the PipelineInternal and calls it's start method. |
| 101 bool PipelineImpl::Start(FilterCollection* collection, | 101 bool PipelineImpl::Start(scoped_ptr<FilterCollection> collection, |
| 102 const std::string& url, | 102 const std::string& url, |
| 103 const PipelineStatusCB& start_callback) { | 103 const PipelineStatusCB& start_callback) { |
| 104 base::AutoLock auto_lock(lock_); | 104 base::AutoLock auto_lock(lock_); |
| 105 scoped_ptr<FilterCollection> filter_collection(collection); | 105 scoped_ptr<FilterCollection> filter_collection(collection.Pass()); |
| 106 | 106 |
| 107 if (running_) { | 107 if (running_) { |
| 108 VLOG(1) << "Media pipeline is already running"; | 108 VLOG(1) << "Media pipeline is already running"; |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 if (collection->IsEmpty()) { | 112 if (collection->IsEmpty()) { |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Kick off initialization! | 116 // Kick off initialization! |
| 117 running_ = true; | 117 running_ = true; |
| 118 message_loop_->PostTask( | 118 message_loop_->PostTask( |
| 119 FROM_HERE, | 119 FROM_HERE, |
| 120 base::Bind(&PipelineImpl::StartTask, this, | 120 base::Bind(&PipelineImpl::StartTask, this, |
| 121 filter_collection.release(), | 121 base::Passed(&filter_collection), |
| 122 url, | 122 url, |
| 123 start_callback)); | 123 start_callback)); |
| 124 return true; | 124 return true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void PipelineImpl::Stop(const PipelineStatusCB& stop_callback) { | 127 void PipelineImpl::Stop(const PipelineStatusCB& stop_callback) { |
| 128 base::AutoLock auto_lock(lock_); | 128 base::AutoLock auto_lock(lock_); |
| 129 if (!running_) { | 129 if (!running_) { |
| 130 VLOG(1) << "Media pipeline has already stopped"; | 130 VLOG(1) << "Media pipeline has already stopped"; |
| 131 return; | 131 return; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 // Called from any thread. | 619 // Called from any thread. |
| 620 void PipelineImpl::OnUpdateStatistics(const PipelineStatistics& stats) { | 620 void PipelineImpl::OnUpdateStatistics(const PipelineStatistics& stats) { |
| 621 base::AutoLock auto_lock(lock_); | 621 base::AutoLock auto_lock(lock_); |
| 622 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; | 622 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; |
| 623 statistics_.video_bytes_decoded += stats.video_bytes_decoded; | 623 statistics_.video_bytes_decoded += stats.video_bytes_decoded; |
| 624 statistics_.video_frames_decoded += stats.video_frames_decoded; | 624 statistics_.video_frames_decoded += stats.video_frames_decoded; |
| 625 statistics_.video_frames_dropped += stats.video_frames_dropped; | 625 statistics_.video_frames_dropped += stats.video_frames_dropped; |
| 626 media_log_->QueueStatisticsUpdatedEvent(statistics_); | 626 media_log_->QueueStatisticsUpdatedEvent(statistics_); |
| 627 } | 627 } |
| 628 | 628 |
| 629 void PipelineImpl::StartTask(FilterCollection* filter_collection, | 629 void PipelineImpl::StartTask(scoped_ptr<FilterCollection> filter_collection, |
| 630 const std::string& url, | 630 const std::string& url, |
| 631 const PipelineStatusCB& start_callback) { | 631 const PipelineStatusCB& start_callback) { |
| 632 DCHECK_EQ(MessageLoop::current(), message_loop_); | 632 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 633 DCHECK_EQ(kCreated, state_); | 633 DCHECK_EQ(kCreated, state_); |
| 634 filter_collection_.reset(filter_collection); | 634 filter_collection_ = filter_collection.Pass(); |
| 635 url_ = url; | 635 url_ = url; |
| 636 seek_callback_ = start_callback; | 636 seek_callback_ = start_callback; |
| 637 | 637 |
| 638 // Kick off initialization. | 638 // Kick off initialization. |
| 639 pipeline_init_state_.reset(new PipelineInitState()); | 639 pipeline_init_state_.reset(new PipelineInitState()); |
| 640 pipeline_init_state_->composite_ = new CompositeFilter(message_loop_); | 640 pipeline_init_state_->composite_ = new CompositeFilter(message_loop_); |
| 641 pipeline_init_state_->composite_->set_host(this); | 641 pipeline_init_state_->composite_->set_host(this); |
| 642 | 642 |
| 643 SetState(kInitDemuxer); | 643 SetState(kInitDemuxer); |
| 644 InitializeDemuxer(); | 644 InitializeDemuxer(); |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 message_loop_->PostTask(FROM_HERE, | 1424 message_loop_->PostTask(FROM_HERE, |
| 1425 base::Bind(&PipelineImpl::NotifyCanPlayThrough, this)); | 1425 base::Bind(&PipelineImpl::NotifyCanPlayThrough, this)); |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 void PipelineImpl::NotifyCanPlayThrough() { | 1428 void PipelineImpl::NotifyCanPlayThrough() { |
| 1429 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1429 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 1430 NotifyNetworkEventTask(CAN_PLAY_THROUGH); | 1430 NotifyNetworkEventTask(CAN_PLAY_THROUGH); |
| 1431 } | 1431 } |
| 1432 | 1432 |
| 1433 } // namespace media | 1433 } // namespace media |
| OLD | NEW |