Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1296)

Unified Diff: media/cdm/cdm_adapter.cc

Issue 1673383002: Add allocator interface for use by cdm_adapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add MEDIA_CDM_EXPORT for Windows Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cdm/cdm_adapter.h ('k') | media/cdm/cdm_adapter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/cdm_adapter.cc
diff --git a/media/cdm/cdm_adapter.cc b/media/cdm/cdm_adapter.cc
index fb89e1a2db31d1400c70011f81203e6e0f5c8f30..a25e7f99304a0de5063449686e58bd1b5225e812 100644
--- a/media/cdm/cdm_adapter.cc
+++ b/media/cdm/cdm_adapter.cc
@@ -25,7 +25,7 @@
#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_allocator.h"
#include "media/cdm/cdm_helpers.h"
#include "media/cdm/cdm_wrapper.h"
#include "ui/gfx/geometry/rect.h"
@@ -325,6 +325,7 @@ void CdmAdapter::Create(
const std::string& key_system,
const base::FilePath& cdm_path,
const CdmConfig& cdm_config,
+ scoped_ptr<CdmAllocator> allocator,
const SessionMessageCB& session_message_cb,
const SessionClosedCB& session_closed_cb,
const LegacySessionErrorCB& legacy_session_error_cb,
@@ -338,10 +339,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, std::move(allocator), session_message_cb,
+ session_closed_cb, legacy_session_error_cb, session_keys_change_cb,
+ session_expiration_update_cb);
// |cdm| ownership passed to the promise.
scoped_ptr<CdmInitializedPromise> cdm_created_promise(
@@ -353,6 +354,7 @@ void CdmAdapter::Create(
CdmAdapter::CdmAdapter(
const std::string& key_system,
const CdmConfig& cdm_config,
+ scoped_ptr<CdmAllocator> allocator,
const SessionMessageCB& session_message_cb,
const SessionClosedCB& session_closed_cb,
const LegacySessionErrorCB& legacy_session_error_cb,
@@ -367,6 +369,7 @@ CdmAdapter::CdmAdapter(
session_expiration_update_cb_(session_expiration_update_cb),
audio_samples_per_second_(0),
audio_channel_layout_(CHANNEL_LAYOUT_NONE),
+ allocator_(std::move(allocator)),
task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_factory_(this) {
DCHECK(!key_system_.empty());
@@ -375,6 +378,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() {}
@@ -663,7 +667,7 @@ void CdmAdapter::DecryptAndDecodeVideo(
cdm::InputBuffer input_buffer;
std::vector<cdm::SubsampleEntry> subsamples;
- scoped_ptr<VideoFrameImpl> video_frame(new VideoFrameImpl());
+ scoped_ptr<VideoFrameImpl> video_frame = allocator_->CreateCdmVideoFrame();
ToCdmInputBuffer(encrypted, &subsamples, &input_buffer);
cdm::Status status =
@@ -675,17 +679,8 @@ 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()));
+ scoped_refptr<VideoFrame> decoded_frame =
+ video_frame->TransformToVideoFrame(natural_size_);
video_decode_cb.Run(Decryptor::kSuccess, decoded_frame);
}
@@ -712,7 +707,7 @@ void CdmAdapter::DeinitializeDecoder(StreamType stream_type) {
cdm::Buffer* CdmAdapter::Allocate(uint32_t capacity) {
DCHECK(task_runner_->BelongsToCurrentThread());
- return CdmBuffer::Create(capacity);
+ return allocator_->CreateCdmBuffer(capacity);
}
void CdmAdapter::SetTimer(int64_t delay_ms, void* context) {
« no previous file with comments | « media/cdm/cdm_adapter.h ('k') | media/cdm/cdm_adapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698