Chromium Code Reviews| Index: media/cdm/cdm_adapter.cc |
| diff --git a/media/cdm/cdm_adapter.cc b/media/cdm/cdm_adapter.cc |
| index fb89e1a2db31d1400c70011f81203e6e0f5c8f30..4832edc278015f40639e47ae2b6bfe99ca72e0a6 100644 |
| --- a/media/cdm/cdm_adapter.cc |
| +++ b/media/cdm/cdm_adapter.cc |
| @@ -25,7 +25,8 @@ |
| #include "media/base/video_decoder_config.h" |
| #include "media/base/video_frame.h" |
| #include "media/base/video_types.h" |
| -#include "media/cdm/cdm_buffer_impl.h" |
| +#include "media/cdm/cdm_buffer.h" |
| +#include "media/cdm/cdm_buffer_allocator.h" |
| #include "media/cdm/cdm_helpers.h" |
| #include "media/cdm/cdm_wrapper.h" |
| #include "ui/gfx/geometry/rect.h" |
| @@ -330,7 +331,8 @@ void CdmAdapter::Create( |
| const LegacySessionErrorCB& legacy_session_error_cb, |
| const SessionKeysChangeCB& session_keys_change_cb, |
| const SessionExpirationUpdateCB& session_expiration_update_cb, |
| - const CdmCreatedCB& cdm_created_cb) { |
| + const CdmCreatedCB& cdm_created_cb, |
| + CdmBufferAllocator* allocator) { |
|
xhwang
2016/02/09 18:27:32
who owns the allocator?
xhwang
2016/02/09 18:27:32
The |allocator| seems an input, while the callback
jrummell
2016/02/11 01:39:38
Done.
jrummell
2016/02/11 01:39:38
Changed to scoped_ptr<> to be clear.
|
| DCHECK(!key_system.empty()); |
| DCHECK(!session_message_cb.is_null()); |
| DCHECK(!session_closed_cb.is_null()); |
| @@ -338,10 +340,10 @@ void CdmAdapter::Create( |
| DCHECK(!session_keys_change_cb.is_null()); |
| DCHECK(!session_expiration_update_cb.is_null()); |
| - scoped_refptr<CdmAdapter> cdm = |
| - new CdmAdapter(key_system, cdm_config, session_message_cb, |
| - session_closed_cb, legacy_session_error_cb, |
| - session_keys_change_cb, session_expiration_update_cb); |
| + scoped_refptr<CdmAdapter> cdm = new CdmAdapter( |
| + key_system, cdm_config, session_message_cb, session_closed_cb, |
| + legacy_session_error_cb, session_keys_change_cb, |
| + session_expiration_update_cb, allocator); |
| // |cdm| ownership passed to the promise. |
| scoped_ptr<CdmInitializedPromise> cdm_created_promise( |
| @@ -357,7 +359,8 @@ CdmAdapter::CdmAdapter( |
| const SessionClosedCB& session_closed_cb, |
| const LegacySessionErrorCB& legacy_session_error_cb, |
| const SessionKeysChangeCB& session_keys_change_cb, |
| - const SessionExpirationUpdateCB& session_expiration_update_cb) |
| + const SessionExpirationUpdateCB& session_expiration_update_cb, |
| + CdmBufferAllocator* allocator) |
| : key_system_(key_system), |
| cdm_config_(cdm_config), |
| session_message_cb_(session_message_cb), |
| @@ -367,6 +370,7 @@ CdmAdapter::CdmAdapter( |
| session_expiration_update_cb_(session_expiration_update_cb), |
| audio_samples_per_second_(0), |
| audio_channel_layout_(CHANNEL_LAYOUT_NONE), |
| + allocator_(allocator), |
| task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| weak_factory_(this) { |
| DCHECK(!key_system_.empty()); |
| @@ -375,6 +379,7 @@ CdmAdapter::CdmAdapter( |
| DCHECK(!legacy_session_error_cb_.is_null()); |
| DCHECK(!session_keys_change_cb_.is_null()); |
| DCHECK(!session_expiration_update_cb_.is_null()); |
| + DCHECK(allocator_); |
| } |
| CdmAdapter::~CdmAdapter() {} |
| @@ -675,17 +680,10 @@ void CdmAdapter::DecryptAndDecodeVideo( |
| return; |
| } |
| - uint8_t* frame_data = video_frame->FrameBuffer()->Data(); |
| - gfx::Size frame_size(video_frame->Size().width, video_frame->Size().height); |
| - scoped_refptr<VideoFrame> decoded_frame = VideoFrame::WrapExternalYuvData( |
| - PIXEL_FORMAT_YV12, frame_size, gfx::Rect(frame_size), natural_size_, |
| - video_frame->Stride(VideoFrameImpl::kYPlane), |
| - video_frame->Stride(VideoFrameImpl::kUPlane), |
| - video_frame->Stride(VideoFrameImpl::kVPlane), |
| - frame_data + video_frame->PlaneOffset(VideoFrameImpl::kYPlane), |
| - frame_data + video_frame->PlaneOffset(VideoFrameImpl::kUPlane), |
| - frame_data + video_frame->PlaneOffset(VideoFrameImpl::kVPlane), |
| - base::TimeDelta::FromMicroseconds(video_frame->Timestamp())); |
| + CdmBuffer* cdm_buffer = |
| + reinterpret_cast<CdmBuffer*>(video_frame->FrameBuffer()); |
|
xhwang
2016/02/09 18:27:32
Can we do static cast?
jrummell
2016/02/11 01:39:38
Done (now moved elsewhere).
|
| + scoped_refptr<VideoFrame> decoded_frame = |
| + cdm_buffer->MakeVideoFrame(video_frame.get(), natural_size_); |
| video_decode_cb.Run(Decryptor::kSuccess, decoded_frame); |
| } |
| @@ -712,7 +710,7 @@ void CdmAdapter::DeinitializeDecoder(StreamType stream_type) { |
| cdm::Buffer* CdmAdapter::Allocate(uint32_t capacity) { |
| DCHECK(task_runner_->BelongsToCurrentThread()); |
| - return CdmBuffer::Create(capacity); |
| + return allocator_->Allocate(capacity); |
| } |
| void CdmAdapter::SetTimer(int64_t delay_ms, void* context) { |