OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_CDM_PPAPI_CDM_HELPERS_H_ | 5 #ifndef MEDIA_CDM_PPAPI_CDM_HELPERS_H_ |
6 #define MEDIA_CDM_PPAPI_CDM_HELPERS_H_ | 6 #define MEDIA_CDM_PPAPI_CDM_HELPERS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // pp::Buffer_Dev. | 26 // pp::Buffer_Dev. |
27 // This class holds a reference to the Buffer_Dev throughout its lifetime. | 27 // This class holds a reference to the Buffer_Dev throughout its lifetime. |
28 // TODO(xhwang): Find a better name. It's confusing to have PpbBuffer, | 28 // TODO(xhwang): Find a better name. It's confusing to have PpbBuffer, |
29 // pp::Buffer_Dev and PPB_Buffer_Dev. | 29 // pp::Buffer_Dev and PPB_Buffer_Dev. |
30 class PpbBuffer : public cdm::Buffer { | 30 class PpbBuffer : public cdm::Buffer { |
31 public: | 31 public: |
32 static PpbBuffer* Create(const pp::Buffer_Dev& buffer, uint32_t buffer_id, | 32 static PpbBuffer* Create(const pp::Buffer_Dev& buffer, uint32_t buffer_id, |
33 PpbBufferAllocator* allocator); | 33 PpbBufferAllocator* allocator); |
34 | 34 |
35 // cdm::Buffer implementation. | 35 // cdm::Buffer implementation. |
36 virtual void Destroy() OVERRIDE; | 36 virtual void Destroy() override; |
37 virtual uint32_t Capacity() const OVERRIDE; | 37 virtual uint32_t Capacity() const override; |
38 virtual uint8_t* Data() OVERRIDE; | 38 virtual uint8_t* Data() override; |
39 virtual void SetSize(uint32_t size) OVERRIDE; | 39 virtual void SetSize(uint32_t size) override; |
40 virtual uint32_t Size() const OVERRIDE { return size_; } | 40 virtual uint32_t Size() const override { return size_; } |
41 | 41 |
42 // Takes the |buffer_| from this class and returns it. | 42 // Takes the |buffer_| from this class and returns it. |
43 // Note: The caller must ensure |allocator->Release()| is called later so that | 43 // Note: The caller must ensure |allocator->Release()| is called later so that |
44 // the buffer can be reused by the allocator. | 44 // the buffer can be reused by the allocator. |
45 // Since pp::Buffer_Dev is ref-counted, the caller now holds one reference to | 45 // Since pp::Buffer_Dev is ref-counted, the caller now holds one reference to |
46 // the buffer and this class holds no reference. Note that other references | 46 // the buffer and this class holds no reference. Note that other references |
47 // may still exist. For example, PpbBufferAllocator always holds a reference | 47 // may still exist. For example, PpbBufferAllocator always holds a reference |
48 // to all allocated buffers. | 48 // to all allocated buffers. |
49 pp::Buffer_Dev TakeBuffer(); | 49 pp::Buffer_Dev TakeBuffer(); |
50 | 50 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 FreeBufferMap free_buffers_; | 90 FreeBufferMap free_buffers_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(PpbBufferAllocator); | 92 DISALLOW_COPY_AND_ASSIGN(PpbBufferAllocator); |
93 }; | 93 }; |
94 | 94 |
95 class DecryptedBlockImpl : public cdm::DecryptedBlock { | 95 class DecryptedBlockImpl : public cdm::DecryptedBlock { |
96 public: | 96 public: |
97 DecryptedBlockImpl() : buffer_(NULL), timestamp_(0) {} | 97 DecryptedBlockImpl() : buffer_(NULL), timestamp_(0) {} |
98 virtual ~DecryptedBlockImpl() { if (buffer_) buffer_->Destroy(); } | 98 virtual ~DecryptedBlockImpl() { if (buffer_) buffer_->Destroy(); } |
99 | 99 |
100 virtual void SetDecryptedBuffer(cdm::Buffer* buffer) OVERRIDE { | 100 virtual void SetDecryptedBuffer(cdm::Buffer* buffer) override { |
101 buffer_ = static_cast<PpbBuffer*>(buffer); | 101 buffer_ = static_cast<PpbBuffer*>(buffer); |
102 } | 102 } |
103 virtual cdm::Buffer* DecryptedBuffer() OVERRIDE { return buffer_; } | 103 virtual cdm::Buffer* DecryptedBuffer() override { return buffer_; } |
104 | 104 |
105 virtual void SetTimestamp(int64_t timestamp) OVERRIDE { | 105 virtual void SetTimestamp(int64_t timestamp) override { |
106 timestamp_ = timestamp; | 106 timestamp_ = timestamp; |
107 } | 107 } |
108 virtual int64_t Timestamp() const OVERRIDE { return timestamp_; } | 108 virtual int64_t Timestamp() const override { return timestamp_; } |
109 | 109 |
110 private: | 110 private: |
111 PpbBuffer* buffer_; | 111 PpbBuffer* buffer_; |
112 int64_t timestamp_; | 112 int64_t timestamp_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(DecryptedBlockImpl); | 114 DISALLOW_COPY_AND_ASSIGN(DecryptedBlockImpl); |
115 }; | 115 }; |
116 | 116 |
117 class VideoFrameImpl : public cdm::VideoFrame { | 117 class VideoFrameImpl : public cdm::VideoFrame { |
118 public: | 118 public: |
119 VideoFrameImpl(); | 119 VideoFrameImpl(); |
120 virtual ~VideoFrameImpl(); | 120 virtual ~VideoFrameImpl(); |
121 | 121 |
122 virtual void SetFormat(cdm::VideoFormat format) OVERRIDE { | 122 virtual void SetFormat(cdm::VideoFormat format) override { |
123 format_ = format; | 123 format_ = format; |
124 } | 124 } |
125 virtual cdm::VideoFormat Format() const OVERRIDE { return format_; } | 125 virtual cdm::VideoFormat Format() const override { return format_; } |
126 | 126 |
127 virtual void SetSize(cdm::Size size) OVERRIDE { size_ = size; } | 127 virtual void SetSize(cdm::Size size) override { size_ = size; } |
128 virtual cdm::Size Size() const OVERRIDE { return size_; } | 128 virtual cdm::Size Size() const override { return size_; } |
129 | 129 |
130 virtual void SetFrameBuffer(cdm::Buffer* frame_buffer) OVERRIDE { | 130 virtual void SetFrameBuffer(cdm::Buffer* frame_buffer) override { |
131 frame_buffer_ = static_cast<PpbBuffer*>(frame_buffer); | 131 frame_buffer_ = static_cast<PpbBuffer*>(frame_buffer); |
132 } | 132 } |
133 virtual cdm::Buffer* FrameBuffer() OVERRIDE { return frame_buffer_; } | 133 virtual cdm::Buffer* FrameBuffer() override { return frame_buffer_; } |
134 | 134 |
135 virtual void SetPlaneOffset(cdm::VideoFrame::VideoPlane plane, | 135 virtual void SetPlaneOffset(cdm::VideoFrame::VideoPlane plane, |
136 uint32_t offset) OVERRIDE { | 136 uint32_t offset) override { |
137 PP_DCHECK(plane < kMaxPlanes); | 137 PP_DCHECK(plane < kMaxPlanes); |
138 plane_offsets_[plane] = offset; | 138 plane_offsets_[plane] = offset; |
139 } | 139 } |
140 virtual uint32_t PlaneOffset(VideoPlane plane) OVERRIDE { | 140 virtual uint32_t PlaneOffset(VideoPlane plane) override { |
141 PP_DCHECK(plane < kMaxPlanes); | 141 PP_DCHECK(plane < kMaxPlanes); |
142 return plane_offsets_[plane]; | 142 return plane_offsets_[plane]; |
143 } | 143 } |
144 | 144 |
145 virtual void SetStride(VideoPlane plane, uint32_t stride) OVERRIDE { | 145 virtual void SetStride(VideoPlane plane, uint32_t stride) override { |
146 PP_DCHECK(plane < kMaxPlanes); | 146 PP_DCHECK(plane < kMaxPlanes); |
147 strides_[plane] = stride; | 147 strides_[plane] = stride; |
148 } | 148 } |
149 virtual uint32_t Stride(VideoPlane plane) OVERRIDE { | 149 virtual uint32_t Stride(VideoPlane plane) override { |
150 PP_DCHECK(plane < kMaxPlanes); | 150 PP_DCHECK(plane < kMaxPlanes); |
151 return strides_[plane]; | 151 return strides_[plane]; |
152 } | 152 } |
153 | 153 |
154 virtual void SetTimestamp(int64_t timestamp) OVERRIDE { | 154 virtual void SetTimestamp(int64_t timestamp) override { |
155 timestamp_ = timestamp; | 155 timestamp_ = timestamp; |
156 } | 156 } |
157 virtual int64_t Timestamp() const OVERRIDE { return timestamp_; } | 157 virtual int64_t Timestamp() const override { return timestamp_; } |
158 | 158 |
159 private: | 159 private: |
160 // The video buffer format. | 160 // The video buffer format. |
161 cdm::VideoFormat format_; | 161 cdm::VideoFormat format_; |
162 | 162 |
163 // Width and height of the video frame. | 163 // Width and height of the video frame. |
164 cdm::Size size_; | 164 cdm::Size size_; |
165 | 165 |
166 // The video frame buffer. | 166 // The video frame buffer. |
167 PpbBuffer* frame_buffer_; | 167 PpbBuffer* frame_buffer_; |
(...skipping 14 matching lines...) Expand all Loading... |
182 | 182 |
183 class AudioFramesImpl : public cdm::AudioFrames_2 { | 183 class AudioFramesImpl : public cdm::AudioFrames_2 { |
184 public: | 184 public: |
185 AudioFramesImpl() : buffer_(NULL), format_(cdm::kUnknownAudioFormat) {} | 185 AudioFramesImpl() : buffer_(NULL), format_(cdm::kUnknownAudioFormat) {} |
186 virtual ~AudioFramesImpl() { | 186 virtual ~AudioFramesImpl() { |
187 if (buffer_) | 187 if (buffer_) |
188 buffer_->Destroy(); | 188 buffer_->Destroy(); |
189 } | 189 } |
190 | 190 |
191 // AudioFrames implementation. | 191 // AudioFrames implementation. |
192 virtual void SetFrameBuffer(cdm::Buffer* buffer) OVERRIDE { | 192 virtual void SetFrameBuffer(cdm::Buffer* buffer) override { |
193 buffer_ = static_cast<PpbBuffer*>(buffer); | 193 buffer_ = static_cast<PpbBuffer*>(buffer); |
194 } | 194 } |
195 virtual cdm::Buffer* FrameBuffer() OVERRIDE { | 195 virtual cdm::Buffer* FrameBuffer() override { |
196 return buffer_; | 196 return buffer_; |
197 } | 197 } |
198 virtual void SetFormat(cdm::AudioFormat format) OVERRIDE { | 198 virtual void SetFormat(cdm::AudioFormat format) override { |
199 format_ = format; | 199 format_ = format; |
200 } | 200 } |
201 virtual cdm::AudioFormat Format() const OVERRIDE { | 201 virtual cdm::AudioFormat Format() const override { |
202 return format_; | 202 return format_; |
203 } | 203 } |
204 | 204 |
205 cdm::Buffer* PassFrameBuffer() { | 205 cdm::Buffer* PassFrameBuffer() { |
206 PpbBuffer* temp_buffer = buffer_; | 206 PpbBuffer* temp_buffer = buffer_; |
207 buffer_ = NULL; | 207 buffer_ = NULL; |
208 return temp_buffer; | 208 return temp_buffer; |
209 } | 209 } |
210 | 210 |
211 private: | 211 private: |
212 PpbBuffer* buffer_; | 212 PpbBuffer* buffer_; |
213 cdm::AudioFormat format_; | 213 cdm::AudioFormat format_; |
214 | 214 |
215 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); | 215 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); |
216 }; | 216 }; |
217 | 217 |
218 } // namespace media | 218 } // namespace media |
219 | 219 |
220 #endif // MEDIA_CDM_PPAPI_CDM_HELPERS_H_ | 220 #endif // MEDIA_CDM_PPAPI_CDM_HELPERS_H_ |
OLD | NEW |