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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "media/cdm/cdm_buffer_impl.h" 5 #include "media/cdm/cdm_buffer_impl.h"
6 6
7 #include "base/bind.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/cdm/cdm_helpers.h"
8 10
9 namespace media { 11 namespace media {
10 12
11 // static 13 // static
12 CdmBuffer* CdmBuffer::Create(uint32_t capacity) { 14 CdmBufferImpl* CdmBufferImpl::Create(uint32_t capacity) {
13 DCHECK(capacity); 15 DCHECK(capacity);
14 return new CdmBuffer(capacity); 16 return new CdmBufferImpl(capacity);
15 } 17 }
16 18
17 CdmBuffer::CdmBuffer(uint32_t capacity) : buffer_(capacity), size_(0) {} 19 CdmBufferImpl::CdmBufferImpl(uint32_t capacity) : buffer_(capacity), size_(0) {}
18 20
19 CdmBuffer::~CdmBuffer() {} 21 CdmBufferImpl::~CdmBufferImpl() {}
20 22
21 void CdmBuffer::Destroy() { 23 void CdmBufferImpl::Destroy() {
22 delete this; 24 delete this;
23 } 25 }
24 26
25 uint32_t CdmBuffer::Capacity() const { 27 uint32_t CdmBufferImpl::Capacity() const {
26 return buffer_.size(); 28 return buffer_.size();
27 } 29 }
28 30
29 uint8_t* CdmBuffer::Data() { 31 uint8_t* CdmBufferImpl::Data() {
30 return buffer_.data(); 32 return buffer_.data();
31 } 33 }
32 34
33 void CdmBuffer::SetSize(uint32_t size) { 35 void CdmBufferImpl::SetSize(uint32_t size) {
34 DCHECK(size <= Capacity()); 36 DCHECK(size <= Capacity());
35 size_ = size > Capacity() ? 0 : size; 37 size_ = size > Capacity() ? 0 : size;
36 } 38 }
37 39
38 uint32_t CdmBuffer::Size() const { 40 uint32_t CdmBufferImpl::Size() const {
39 return size_; 41 return size_;
40 } 42 }
41 43
44 scoped_refptr<VideoFrame> CdmBufferImpl::MakeVideoFrame(
45 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.
46 gfx::Size natural_size) {
47 gfx::Size frame_size(video_frame->Size().width, video_frame->Size().height);
48 scoped_refptr<VideoFrame> frame = VideoFrame::WrapExternalYuvData(
49 PIXEL_FORMAT_YV12, frame_size, gfx::Rect(frame_size), natural_size,
50 video_frame->Stride(VideoFrameImpl::kYPlane),
51 video_frame->Stride(VideoFrameImpl::kUPlane),
52 video_frame->Stride(VideoFrameImpl::kVPlane),
53 buffer_.data() + video_frame->PlaneOffset(VideoFrameImpl::kYPlane),
54 buffer_.data() + video_frame->PlaneOffset(VideoFrameImpl::kUPlane),
55 buffer_.data() + video_frame->PlaneOffset(VideoFrameImpl::kVPlane),
56 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.
57
58 // This memory needs to remain around until |frame| is destroyed.
59 frame->AddDestructionObserver(
60 base::Bind(&CdmBufferImpl::Destroy, base::Unretained(this)));
61 return frame;
62 }
63
42 } // namespace media 64 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698