| 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); | |
| 106 | 105 |
| 107 if (running_) { | 106 if (running_) { |
| 108 VLOG(1) << "Media pipeline is already running"; | 107 VLOG(1) << "Media pipeline is already running"; |
| 109 return false; | 108 return false; |
| 110 } | 109 } |
| 111 | 110 |
| 112 if (collection->IsEmpty()) { | 111 if (collection->IsEmpty()) { |
| 113 return false; | 112 return false; |
| 114 } | 113 } |
| 115 | 114 |
| 116 // Kick off initialization! | 115 // Kick off initialization! |
| 117 running_ = true; | 116 running_ = true; |
| 118 message_loop_->PostTask( | 117 message_loop_->PostTask( |
| 119 FROM_HERE, | 118 FROM_HERE, |
| 120 base::Bind(&PipelineImpl::StartTask, this, | 119 base::Bind(&PipelineImpl::StartTask, this, |
| 121 filter_collection.release(), | 120 base::Passed(&collection), |
| 122 url, | 121 url, |
| 123 start_callback)); | 122 start_callback)); |
| 124 return true; | 123 return true; |
| 125 } | 124 } |
| 126 | 125 |
| 127 void PipelineImpl::Stop(const PipelineStatusCB& stop_callback) { | 126 void PipelineImpl::Stop(const PipelineStatusCB& stop_callback) { |
| 128 base::AutoLock auto_lock(lock_); | 127 base::AutoLock auto_lock(lock_); |
| 129 if (!running_) { | 128 if (!running_) { |
| 130 VLOG(1) << "Media pipeline has already stopped"; | 129 VLOG(1) << "Media pipeline has already stopped"; |
| 131 return; | 130 return; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 // Called from any thread. | 618 // Called from any thread. |
| 620 void PipelineImpl::OnUpdateStatistics(const PipelineStatistics& stats) { | 619 void PipelineImpl::OnUpdateStatistics(const PipelineStatistics& stats) { |
| 621 base::AutoLock auto_lock(lock_); | 620 base::AutoLock auto_lock(lock_); |
| 622 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; | 621 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; |
| 623 statistics_.video_bytes_decoded += stats.video_bytes_decoded; | 622 statistics_.video_bytes_decoded += stats.video_bytes_decoded; |
| 624 statistics_.video_frames_decoded += stats.video_frames_decoded; | 623 statistics_.video_frames_decoded += stats.video_frames_decoded; |
| 625 statistics_.video_frames_dropped += stats.video_frames_dropped; | 624 statistics_.video_frames_dropped += stats.video_frames_dropped; |
| 626 media_log_->QueueStatisticsUpdatedEvent(statistics_); | 625 media_log_->QueueStatisticsUpdatedEvent(statistics_); |
| 627 } | 626 } |
| 628 | 627 |
| 629 void PipelineImpl::StartTask(FilterCollection* filter_collection, | 628 void PipelineImpl::StartTask(scoped_ptr<FilterCollection> filter_collection, |
| 630 const std::string& url, | 629 const std::string& url, |
| 631 const PipelineStatusCB& start_callback) { | 630 const PipelineStatusCB& start_callback) { |
| 632 DCHECK_EQ(MessageLoop::current(), message_loop_); | 631 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 633 DCHECK_EQ(kCreated, state_); | 632 DCHECK_EQ(kCreated, state_); |
| 634 filter_collection_.reset(filter_collection); | 633 filter_collection_ = filter_collection.Pass(); |
| 635 url_ = url; | 634 url_ = url; |
| 636 seek_callback_ = start_callback; | 635 seek_callback_ = start_callback; |
| 637 | 636 |
| 638 // Kick off initialization. | 637 // Kick off initialization. |
| 639 pipeline_init_state_.reset(new PipelineInitState()); | 638 pipeline_init_state_.reset(new PipelineInitState()); |
| 640 pipeline_init_state_->composite_ = new CompositeFilter(message_loop_); | 639 pipeline_init_state_->composite_ = new CompositeFilter(message_loop_); |
| 641 pipeline_init_state_->composite_->set_host(this); | 640 pipeline_init_state_->composite_->set_host(this); |
| 642 | 641 |
| 643 SetState(kInitDemuxer); | 642 SetState(kInitDemuxer); |
| 644 InitializeDemuxer(); | 643 InitializeDemuxer(); |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 message_loop_->PostTask(FROM_HERE, | 1423 message_loop_->PostTask(FROM_HERE, |
| 1425 base::Bind(&PipelineImpl::NotifyCanPlayThrough, this)); | 1424 base::Bind(&PipelineImpl::NotifyCanPlayThrough, this)); |
| 1426 } | 1425 } |
| 1427 | 1426 |
| 1428 void PipelineImpl::NotifyCanPlayThrough() { | 1427 void PipelineImpl::NotifyCanPlayThrough() { |
| 1429 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1428 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 1430 NotifyNetworkEventTask(CAN_PLAY_THROUGH); | 1429 NotifyNetworkEventTask(CAN_PLAY_THROUGH); |
| 1431 } | 1430 } |
| 1432 | 1431 |
| 1433 } // namespace media | 1432 } // namespace media |
| OLD | NEW |