| Index: chromecast/media/cma/pipeline/av_pipeline_impl.cc
|
| diff --git a/chromecast/media/cma/pipeline/av_pipeline_impl.cc b/chromecast/media/cma/pipeline/av_pipeline_impl.cc
|
| index ae31b3a37923872bd6bfc372167e8fc8bff0e17b..b64b9be3970d5d120fa484ebcbe0d2e368bfcc82 100644
|
| --- a/chromecast/media/cma/pipeline/av_pipeline_impl.cc
|
| +++ b/chromecast/media/cma/pipeline/av_pipeline_impl.cc
|
| @@ -18,11 +18,7 @@
|
| #include "chromecast/media/cma/base/coded_frame_provider.h"
|
| #include "chromecast/media/cma/base/decoder_buffer_base.h"
|
| #include "chromecast/media/cma/pipeline/decrypt_util.h"
|
| -#include "chromecast/media/cma/pipeline/frame_status_cb_impl.h"
|
| -#include "chromecast/media/cma/pipeline/media_component_device_client_impl.h"
|
| #include "chromecast/public/media/cast_decrypt_config.h"
|
| -#include "chromecast/public/media/media_clock_device.h"
|
| -#include "chromecast/public/media/media_component_device.h"
|
| #include "media/base/audio_decoder_config.h"
|
| #include "media/base/bind_to_current_loop.h"
|
| #include "media/base/decrypt_config.h"
|
| @@ -37,29 +33,27 @@ const int kNoCallbackId = -1;
|
|
|
| } // namespace
|
|
|
| -AvPipelineImpl::AvPipelineImpl(MediaComponentDevice* media_component_device,
|
| +AvPipelineImpl::AvPipelineImpl(MediaPipelineBackend::Decoder* decoder,
|
| const UpdateConfigCB& update_config_cb)
|
| : update_config_cb_(update_config_cb),
|
| - media_component_device_(media_component_device),
|
| + decoder_(decoder),
|
| state_(kUninitialized),
|
| buffered_time_(::media::kNoTimestamp()),
|
| playable_buffered_time_(::media::kNoTimestamp()),
|
| enable_feeding_(false),
|
| pending_read_(false),
|
| - pending_push_(false),
|
| enable_time_update_(false),
|
| pending_time_update_task_(false),
|
| media_keys_(NULL),
|
| media_keys_callback_id_(kNoCallbackId),
|
| weak_factory_(this) {
|
| - DCHECK(media_component_device);
|
| + DCHECK(decoder_);
|
| weak_this_ = weak_factory_.GetWeakPtr();
|
| thread_checker_.DetachFromThread();
|
| }
|
|
|
| AvPipelineImpl::~AvPipelineImpl() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - media_component_device_->SetClient(nullptr);
|
|
|
| if (media_keys_ && media_keys_callback_id_ != kNoCallbackId)
|
| media_keys_->UnregisterPlayer(media_keys_callback_id_);
|
| @@ -86,46 +80,18 @@ void AvPipelineImpl::SetCodedFrameProvider(
|
| base::Bind(&AvPipelineImpl::OnFrameBuffered, weak_this_)));
|
| }
|
|
|
| -void AvPipelineImpl::SetClient(const AvPipelineClient& client) {
|
| - DCHECK(thread_checker_.CalledOnValidThread());
|
| - DCHECK_EQ(state_, kUninitialized);
|
| - client_ = client;
|
| -}
|
| -
|
| -bool AvPipelineImpl::Initialize() {
|
| - DCHECK(thread_checker_.CalledOnValidThread());
|
| - DCHECK_EQ(state_, kUninitialized);
|
| -
|
| - media_component_device_->SetClient(new MediaComponentDeviceClientImpl(
|
| - base::Bind(&AvPipelineImpl::OnEos, weak_this_)));
|
| - if (!media_component_device_->SetState(MediaComponentDevice::kStateIdle))
|
| - return false;
|
| -
|
| - return true;
|
| -}
|
| -
|
| bool AvPipelineImpl::StartPlayingFrom(
|
| base::TimeDelta time,
|
| const scoped_refptr<BufferingState>& buffering_state) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| DCHECK_EQ(state_, kFlushed);
|
|
|
| - // Media time where rendering should start
|
| - // and switch to a state where the audio device accepts incoming buffers.
|
| - if (!media_component_device_->SetStartPts(time.InMicroseconds()) ||
|
| - !media_component_device_->SetState(MediaComponentDevice::kStatePaused)) {
|
| - return false;
|
| - }
|
| -
|
| // Buffering related initialization.
|
| DCHECK(frame_provider_);
|
| buffering_state_ = buffering_state;
|
| if (buffering_state_.get())
|
| buffering_state_->SetMediaTime(time);
|
|
|
| - if (!media_component_device_->SetState(MediaComponentDevice::kStateRunning))
|
| - return false;
|
| -
|
| // Start feeding the pipeline.
|
| enable_feeding_ = true;
|
| base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| @@ -137,11 +103,9 @@ bool AvPipelineImpl::StartPlayingFrom(
|
| void AvPipelineImpl::Flush(const base::Closure& done_cb) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| DCHECK_EQ(state_, kFlushing);
|
| - DCHECK_EQ(
|
| - media_component_device_->GetState(), MediaComponentDevice::kStateRunning);
|
| +
|
| // Note: returning to idle state aborts any pending frame push.
|
| - media_component_device_->SetState(MediaComponentDevice::kStateIdle);
|
| - pending_push_ = false;
|
| + pushed_buffer_.reset();
|
|
|
| // Break the feeding loop.
|
| enable_feeding_ = false;
|
| @@ -166,18 +130,6 @@ void AvPipelineImpl::Stop() {
|
|
|
| // Stop feeding the pipeline.
|
| enable_feeding_ = false;
|
| -
|
| - // Release hardware resources on Stop.
|
| - if (media_component_device_->GetState() ==
|
| - MediaComponentDevice::kStatePaused ||
|
| - media_component_device_->GetState() ==
|
| - MediaComponentDevice::kStateRunning) {
|
| - media_component_device_->SetState(MediaComponentDevice::kStateIdle);
|
| - }
|
| - if (media_component_device_->GetState() == MediaComponentDevice::kStateIdle) {
|
| - media_component_device_->SetState(
|
| - MediaComponentDevice::kStateUninitialized);
|
| - }
|
| }
|
|
|
| void AvPipelineImpl::SetCdm(BrowserCdmCast* media_keys) {
|
| @@ -193,16 +145,6 @@ void AvPipelineImpl::SetCdm(BrowserCdmCast* media_keys) {
|
| base::Bind(&AvPipelineImpl::OnCdmDestroyed, weak_this_));
|
| }
|
|
|
| -void AvPipelineImpl::OnEos() {
|
| - DCHECK(thread_checker_.CalledOnValidThread());
|
| - CMALOG(kLogControl) << __FUNCTION__;
|
| - if (state_ != kPlaying)
|
| - return;
|
| -
|
| - if (!client_.eos_cb.is_null())
|
| - client_.eos_cb.Run();
|
| -}
|
| -
|
| void AvPipelineImpl::FetchBufferIfNeeded() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| if (!enable_feeding_)
|
| @@ -245,7 +187,7 @@ void AvPipelineImpl::ProcessPendingBuffer() {
|
| return;
|
| }
|
|
|
| - if (!pending_buffer_.get() || pending_push_)
|
| + if (!pending_buffer_.get() || pushed_buffer_)
|
| return;
|
|
|
| // Break the feeding loop when the end of stream is reached.
|
| @@ -289,21 +231,20 @@ void AvPipelineImpl::ProcessPendingBuffer() {
|
| buffering_state_->SetMaxRenderingTime(timestamp);
|
| }
|
|
|
| - MediaComponentDevice::FrameStatus status = media_component_device_->PushFrame(
|
| - decrypt_context.release(), new CastDecoderBufferImpl(pending_buffer_),
|
| - new FrameStatusCBImpl(
|
| - base::Bind(&AvPipelineImpl::OnFramePushed, weak_this_)));
|
| + DCHECK(!pushed_buffer_);
|
| + pushed_buffer_.reset(new CastDecoderBufferImpl(pending_buffer_));
|
| + MediaPipelineBackend::BufferStatus status =
|
| + decoder_->PushBuffer(decrypt_context.release(), pushed_buffer_.get());
|
| pending_buffer_ = scoped_refptr<DecoderBufferBase>();
|
|
|
| - pending_push_ = (status == MediaComponentDevice::kFramePending);
|
| - if (!pending_push_)
|
| - OnFramePushed(status);
|
| + if (status != MediaPipelineBackend::kBufferPending)
|
| + OnBufferPushed(status);
|
| }
|
|
|
| -void AvPipelineImpl::OnFramePushed(MediaComponentDevice::FrameStatus status) {
|
| +void AvPipelineImpl::OnBufferPushed(MediaPipelineBackend::BufferStatus status) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - pending_push_ = false;
|
| - if (status == MediaComponentDevice::kFrameFailed) {
|
| + pushed_buffer_.reset();
|
| + if (status == MediaPipelineBackend::kBufferFailed) {
|
| LOG(WARNING) << "AvPipelineImpl: PushFrame failed";
|
| enable_feeding_ = false;
|
| state_ = kError;
|
|
|