| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chromecast/media/cma/pipeline/av_pipeline_impl.h" | 5 #include "chromecast/media/cma/pipeline/av_pipeline_impl.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/location.h" | 10 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 12 #include "chromecast/media/base/decrypt_context_impl.h" | 14 #include "chromecast/media/base/decrypt_context_impl.h" |
| 13 #include "chromecast/media/cdm/browser_cdm_cast.h" | 15 #include "chromecast/media/cdm/browser_cdm_cast.h" |
| 14 #include "chromecast/media/cma/base/buffering_frame_provider.h" | 16 #include "chromecast/media/cma/base/buffering_frame_provider.h" |
| 15 #include "chromecast/media/cma/base/buffering_state.h" | 17 #include "chromecast/media/cma/base/buffering_state.h" |
| 16 #include "chromecast/media/cma/base/cma_logging.h" | 18 #include "chromecast/media/cma/base/cma_logging.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 76 |
| 75 void AvPipelineImpl::SetCodedFrameProvider( | 77 void AvPipelineImpl::SetCodedFrameProvider( |
| 76 scoped_ptr<CodedFrameProvider> frame_provider, | 78 scoped_ptr<CodedFrameProvider> frame_provider, |
| 77 size_t max_buffer_size, | 79 size_t max_buffer_size, |
| 78 size_t max_frame_size) { | 80 size_t max_frame_size) { |
| 79 DCHECK_EQ(state_, kUninitialized); | 81 DCHECK_EQ(state_, kUninitialized); |
| 80 DCHECK(frame_provider); | 82 DCHECK(frame_provider); |
| 81 | 83 |
| 82 // Wrap the incoming frame provider to add some buffering capabilities. | 84 // Wrap the incoming frame provider to add some buffering capabilities. |
| 83 frame_provider_.reset(new BufferingFrameProvider( | 85 frame_provider_.reset(new BufferingFrameProvider( |
| 84 frame_provider.Pass(), | 86 std::move(frame_provider), max_buffer_size, max_frame_size, |
| 85 max_buffer_size, | |
| 86 max_frame_size, | |
| 87 base::Bind(&AvPipelineImpl::OnDataBuffered, weak_this_))); | 87 base::Bind(&AvPipelineImpl::OnDataBuffered, weak_this_))); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool AvPipelineImpl::StartPlayingFrom( | 90 bool AvPipelineImpl::StartPlayingFrom( |
| 91 base::TimeDelta time, | 91 base::TimeDelta time, |
| 92 const scoped_refptr<BufferingState>& buffering_state) { | 92 const scoped_refptr<BufferingState>& buffering_state) { |
| 93 CMALOG(kLogControl) << __FUNCTION__ << " t0=" << time.InMilliseconds(); | 93 CMALOG(kLogControl) << __FUNCTION__ << " t0=" << time.InMilliseconds(); |
| 94 DCHECK(thread_checker_.CalledOnValidThread()); | 94 DCHECK(thread_checker_.CalledOnValidThread()); |
| 95 | 95 |
| 96 // Reset the pipeline statistics. | 96 // Reset the pipeline statistics. |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 if (!pending_buffer_->end_of_stream() && buffering_state_.get()) { | 267 if (!pending_buffer_->end_of_stream() && buffering_state_.get()) { |
| 268 base::TimeDelta timestamp = | 268 base::TimeDelta timestamp = |
| 269 base::TimeDelta::FromMicroseconds(pending_buffer_->timestamp()); | 269 base::TimeDelta::FromMicroseconds(pending_buffer_->timestamp()); |
| 270 if (timestamp != ::media::kNoTimestamp()) | 270 if (timestamp != ::media::kNoTimestamp()) |
| 271 buffering_state_->SetMaxRenderingTime(timestamp); | 271 buffering_state_->SetMaxRenderingTime(timestamp); |
| 272 } | 272 } |
| 273 | 273 |
| 274 DCHECK(!pushed_buffer_); | 274 DCHECK(!pushed_buffer_); |
| 275 pushed_buffer_ = pending_buffer_; | 275 pushed_buffer_ = pending_buffer_; |
| 276 if (decrypt_context && decrypt_context->GetKeySystem() != KEY_SYSTEM_NONE) | 276 if (decrypt_context && decrypt_context->GetKeySystem() != KEY_SYSTEM_NONE) |
| 277 pushed_buffer_->set_decrypt_context(decrypt_context.Pass()); | 277 pushed_buffer_->set_decrypt_context(std::move(decrypt_context)); |
| 278 pending_buffer_ = nullptr; | 278 pending_buffer_ = nullptr; |
| 279 MediaPipelineBackend::BufferStatus status = | 279 MediaPipelineBackend::BufferStatus status = |
| 280 decoder_->PushBuffer(pushed_buffer_.get()); | 280 decoder_->PushBuffer(pushed_buffer_.get()); |
| 281 | 281 |
| 282 if (status != MediaPipelineBackend::kBufferPending) | 282 if (status != MediaPipelineBackend::kBufferPending) |
| 283 OnPushBufferComplete(status); | 283 OnPushBufferComplete(status); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void AvPipelineImpl::OnPushBufferComplete(BufferStatus status) { | 286 void AvPipelineImpl::OnPushBufferComplete(BufferStatus status) { |
| 287 DCHECK(thread_checker_.CalledOnValidThread()); | 287 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 // The frame is playable: remove it from the list of non playable frames. | 391 // The frame is playable: remove it from the list of non playable frames. |
| 392 non_playable_frames_.pop_front(); | 392 non_playable_frames_.pop_front(); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 | 395 |
| 396 } // namespace media | 396 } // namespace media |
| 397 } // namespace chromecast | 397 } // namespace chromecast |
| OLD | NEW |