Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "media/cdm/simple_cdm_allocator.h" | |
| 6 | |
| 7 #include "media/base/video_frame.h" | |
| 8 #include "media/cdm/cdm_helpers.h" | |
| 9 #include "media/cdm/simple_cdm_buffer.h" | |
| 10 #include "ui/gfx/geometry/rect.h" | |
| 11 #include "ui/gfx/geometry/size.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 class SimpleCdmVideoFrame : public VideoFrameImpl { | |
|
xhwang
2016/02/12 08:45:30
Put this in an anonymous namespace.
jrummell
2016/02/12 23:14:20
Done.
| |
| 16 public: | |
| 17 SimpleCdmVideoFrame() {} | |
| 18 ~SimpleCdmVideoFrame() final {} | |
| 19 | |
| 20 // VideoFrameImpl implementation. | |
| 21 scoped_refptr<media::VideoFrame> CreateVideoFrame( | |
| 22 gfx::Size natural_size) override { | |
|
xhwang
2016/02/12 08:45:30
s/override/final to be consistent
jrummell
2016/02/12 23:14:20
Done.
| |
| 23 DCHECK(FrameBuffer()); | |
| 24 | |
| 25 SimpleCdmBuffer* buffer = static_cast<SimpleCdmBuffer*>(FrameBuffer()); | |
| 26 gfx::Size frame_size(Size().width, Size().height); | |
| 27 scoped_refptr<media::VideoFrame> frame = | |
| 28 media::VideoFrame::WrapExternalYuvData( | |
| 29 PIXEL_FORMAT_YV12, frame_size, gfx::Rect(frame_size), natural_size, | |
| 30 Stride(kYPlane), Stride(kUPlane), Stride(kVPlane), | |
| 31 buffer->Data() + PlaneOffset(kYPlane), | |
| 32 buffer->Data() + PlaneOffset(kUPlane), | |
| 33 buffer->Data() + PlaneOffset(kVPlane), | |
| 34 base::TimeDelta::FromMicroseconds(Timestamp())); | |
| 35 | |
| 36 // The FrameBuffer needs to remain around until |frame| is destroyed. | |
| 37 frame->AddDestructionObserver( | |
| 38 base::Bind(&SimpleCdmBuffer::Destroy, base::Unretained(buffer))); | |
|
xhwang
2016/02/12 08:45:30
This is a little bit tricky. Can we add a unit tes
jrummell
2016/02/12 23:14:20
Done.
| |
| 39 | |
| 40 // Clear FrameBuffer so that SimpleCdmVideoFrame no longer has a reference | |
| 41 // to it. | |
| 42 SetFrameBuffer(nullptr); | |
| 43 return frame; | |
| 44 } | |
| 45 | |
| 46 private: | |
| 47 DISALLOW_COPY_AND_ASSIGN(SimpleCdmVideoFrame); | |
| 48 }; | |
| 49 | |
| 50 SimpleCdmAllocator::SimpleCdmAllocator() {} | |
| 51 | |
| 52 SimpleCdmAllocator::~SimpleCdmAllocator() {} | |
| 53 | |
| 54 cdm::Buffer* SimpleCdmAllocator::Allocate(uint32_t capacity) { | |
| 55 if (!capacity) | |
| 56 return nullptr; | |
| 57 | |
| 58 return SimpleCdmBuffer::Create(capacity); | |
| 59 } | |
| 60 | |
| 61 scoped_ptr<VideoFrameImpl> SimpleCdmAllocator::CreateCdmVideoFrame() { | |
| 62 return make_scoped_ptr(new SimpleCdmVideoFrame()); | |
| 63 } | |
| 64 | |
| 65 } // namespace media | |
| OLD | NEW |