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

Unified Diff: media/cdm/cdm_buffer_impl.cc

Issue 1673383002: Add allocator interface for use by cdm_adapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: media/cdm/cdm_buffer_impl.cc
diff --git a/media/cdm/cdm_buffer_impl.cc b/media/cdm/cdm_buffer_impl.cc
index 2845de4bba6593f3e93ed5fe7c346803915cb8de..1c00ae8c8d6bf403a0e1298d9230a6122a9f2e98 100644
--- a/media/cdm/cdm_buffer_impl.cc
+++ b/media/cdm/cdm_buffer_impl.cc
@@ -4,39 +4,61 @@
#include "media/cdm/cdm_buffer_impl.h"
+#include "base/bind.h"
#include "base/logging.h"
+#include "media/cdm/cdm_helpers.h"
namespace media {
// static
-CdmBuffer* CdmBuffer::Create(uint32_t capacity) {
+CdmBufferImpl* CdmBufferImpl::Create(uint32_t capacity) {
DCHECK(capacity);
- return new CdmBuffer(capacity);
+ return new CdmBufferImpl(capacity);
}
-CdmBuffer::CdmBuffer(uint32_t capacity) : buffer_(capacity), size_(0) {}
+CdmBufferImpl::CdmBufferImpl(uint32_t capacity) : buffer_(capacity), size_(0) {}
-CdmBuffer::~CdmBuffer() {}
+CdmBufferImpl::~CdmBufferImpl() {}
-void CdmBuffer::Destroy() {
+void CdmBufferImpl::Destroy() {
delete this;
}
-uint32_t CdmBuffer::Capacity() const {
+uint32_t CdmBufferImpl::Capacity() const {
return buffer_.size();
}
-uint8_t* CdmBuffer::Data() {
+uint8_t* CdmBufferImpl::Data() {
return buffer_.data();
}
-void CdmBuffer::SetSize(uint32_t size) {
+void CdmBufferImpl::SetSize(uint32_t size) {
DCHECK(size <= Capacity());
size_ = size > Capacity() ? 0 : size;
}
-uint32_t CdmBuffer::Size() const {
+uint32_t CdmBufferImpl::Size() const {
return size_;
}
+scoped_refptr<VideoFrame> CdmBufferImpl::MakeVideoFrame(
+ VideoFrameImpl* video_frame,
xhwang 2016/02/09 18:27:33 Not related to this CL: VideoFrameImpl should be r
jrummell 2016/02/11 01:39:39 Acknowledged.
+ gfx::Size natural_size) {
+ gfx::Size frame_size(video_frame->Size().width, video_frame->Size().height);
+ scoped_refptr<VideoFrame> 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),
+ buffer_.data() + video_frame->PlaneOffset(VideoFrameImpl::kYPlane),
+ buffer_.data() + video_frame->PlaneOffset(VideoFrameImpl::kUPlane),
+ buffer_.data() + video_frame->PlaneOffset(VideoFrameImpl::kVPlane),
+ base::TimeDelta::FromMicroseconds(video_frame->Timestamp()));
xhwang 2016/02/09 18:27:33 It seems we can have the same implementation for n
jrummell 2016/02/11 01:39:39 Redone.
+
+ // This memory needs to remain around until |frame| is destroyed.
+ frame->AddDestructionObserver(
+ base::Bind(&CdmBufferImpl::Destroy, base::Unretained(this)));
+ return frame;
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698