Chromium Code Reviews| 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 |