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

Side by Side Diff: webkit/media/crypto/ppapi/content_decryption_module.h

Issue 10899021: Add CDM video decoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_
6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_
7 7
8 #if defined(_MSC_VER) 8 #if defined(_MSC_VER)
9 typedef unsigned char uint8_t; 9 typedef unsigned char uint8_t;
10 typedef unsigned int uint32_t; 10 typedef unsigned int uint32_t;
11 typedef int int32_t;
11 typedef __int64 int64_t; 12 typedef __int64 int64_t;
12 #else 13 #else
13 #include <stdint.h> 14 #include <stdint.h>
14 #endif 15 #endif
15 16
17 #include "base/time.h"
16 #include "webkit/media/crypto/ppapi/cdm_export.h" 18 #include "webkit/media/crypto/ppapi/cdm_export.h"
17 19
18 namespace cdm { 20 namespace cdm {
19 class ContentDecryptionModule; 21 class ContentDecryptionModule;
20 } 22 }
21 23
22 extern "C" { 24 extern "C" {
23 CDM_EXPORT cdm::ContentDecryptionModule* CreateCdmInstance(); 25 CDM_EXPORT cdm::ContentDecryptionModule* CreateCdmInstance();
24 CDM_EXPORT void DestroyCdmInstance(cdm::ContentDecryptionModule* instance); 26 CDM_EXPORT void DestroyCdmInstance(cdm::ContentDecryptionModule* instance);
25 CDM_EXPORT const char* GetCdmVersion(); 27 CDM_EXPORT const char* GetCdmVersion();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 : data(NULL), 124 : data(NULL),
123 data_size(0), 125 data_size(0),
124 timestamp(0) {} 126 timestamp(0) {}
125 127
126 const uint8_t* data; // Pointer to the beginning of the output data. 128 const uint8_t* data; // Pointer to the beginning of the output data.
127 uint32_t data_size; // Size (in bytes) of |data|. 129 uint32_t data_size; // Size (in bytes) of |data|.
128 130
129 int64_t timestamp; // Presentation timestamp in microseconds. 131 int64_t timestamp; // Presentation timestamp in microseconds.
130 }; 132 };
131 133
134 struct VideoFrame {
135 // Surface formats roughly based on FOURCC labels, see:
136 // http://www.fourcc.org/rgb.php
137 // http://www.fourcc.org/yuv.php
138 enum Format {
ddorwin 2012/08/29 17:33:49 Maybe ColorFormat or something like that. Unless "
Tom Finegan 2012/08/30 17:09:23 From src/media, but went with ColorFormat because
139 INVALID = 0, // Invalid format value. Used for error reporting.
ddorwin 2012/08/29 17:33:49 Check the naming in style guide. Might need more c
Tom Finegan 2012/08/30 17:09:23 From src/media. Fixed this, and discarded everythi
140 RGB32, // 32bpp RGB packed with extra byte 8:8:8.
141 YV12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
ddorwin 2012/08/29 17:33:49 Should probably align comments in this case.
Tom Finegan 2012/08/30 17:09:23 Done.
142 YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples.
143 EMPTY, // An empty frame.
ddorwin 2012/08/29 17:33:49 Why is EMPTY in the middle of YVU items? Should it
Tom Finegan 2012/08/30 17:09:23 From src/media.
144 I420, // 12bpp YVU planar 1x1 Y, 2x2 UV samples.
145 };
146
147 struct Size {
148 Size() : width(0), height(0) {}
149 Size(int32_t width, int32_t height) : width(width), height(height) {}
150
151 int32_t width;
152 int32_t height;
153 };
154
155 const static int32_t kMaxPlanes = 3;
156
157 VideoFrame() : format(INVALID) {
158 for (int i = 0; i < kMaxPlanes; ++i) {
159 strides[i] = 0;
160 data[i] = NULL;
161 }
162 }
163
164 Format format;
165
166 // Width and height of the video frame.
167 Size data_size;
ddorwin 2012/08/29 17:33:49 frame_size. data doesn't seem right.
Tom Finegan 2012/08/30 17:09:23 From src/media, but I prefer frame_size. Done.
168
169 // Array of strides for each plane, typically greater or equal to the width
170 // of the surface divided by the horizontal sampling period. Note that
171 // strides can be negative.
172 int32_t strides[kMaxPlanes];
173
174 // Array of data pointers to each plane.
175 uint8_t* data[kMaxPlanes];
176
177 base::TimeDelta timestamp; // Presentation timestamp in microseconds.
178 };
179
180 struct VideoDecoderConfig {
181 enum VideoCodec {
182 kUnknownVideoCodec = 0,
ddorwin 2012/08/29 17:33:49 This name is inconsistent with the rest.
Tom Finegan 2012/08/30 17:09:23 From src/media. Dropped everything but unknown, h2
183 kCodecH264,
ddorwin 2012/08/29 17:33:49 kName vs. NAME for Format. Pick one - see style gu
Tom Finegan 2012/08/30 17:09:23 The naming inconsistency is due to src/media ances
184 kCodecVC1,
ddorwin 2012/08/29 17:33:49 We're not going to support these 4, so remove them
Tom Finegan 2012/08/30 17:09:23 Done.
185 kCodecMPEG2,
186 kCodecMPEG4,
187 kCodecTheora,
188 kCodecVP8
189 };
190
191 enum VideoCodecProfile {
192 VIDEO_CODEC_PROFILE_UNKNOWN = -1,
193 H264PROFILE_MIN = 0,
ddorwin 2012/08/29 17:33:49 I wonder if Chrome supports all these.
Tom Finegan 2012/08/30 17:09:23 From src/media, and probably something we should l
194 H264PROFILE_BASELINE = H264PROFILE_MIN,
195 H264PROFILE_MAIN = 1,
196 H264PROFILE_EXTENDED = 2,
197 H264PROFILE_HIGH = 3,
198 H264PROFILE_HIGH10PROFILE = 4,
199 H264PROFILE_HIGH422PROFILE = 5,
200 H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
201 H264PROFILE_SCALABLEBASELINE = 7,
202 H264PROFILE_SCALABLEHIGH = 8,
203 H264PROFILE_STEREOHIGH = 9,
204 H264PROFILE_MULTIVIEWHIGH = 10,
205 H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH,
206 VP8PROFILE_MIN = 11,
207 VP8PROFILE_MAIN = VP8PROFILE_MIN,
208 VP8PROFILE_MAX = VP8PROFILE_MAIN,
209 VIDEO_CODEC_PROFILE_MAX = VP8PROFILE_MAX
210 };
211
212 VideoCodec codec;
213 VideoCodecProfile profile;
214 VideoFrame::Format format;
ddorwin 2012/08/29 17:33:49 Why do both the frame and config have a format and
Tom Finegan 2012/08/30 17:09:23 From src/media. I think this is because we need a
ddorwin 2012/09/02 21:39:07 It seems this would only be used for error checkin
215 VideoFrame::Size coded_size;
ddorwin 2012/08/29 17:33:49 coded? encoded? compressed?
Tom Finegan 2012/08/30 17:09:23 Done, s/coded_size/frame_size/.
216 uint8_t* extra_data;
ddorwin 2012/08/29 17:33:49 What is this?
Tom Finegan 2012/08/30 17:09:23 From src/media. Comment from media/base/video_dec
ddorwin 2012/09/02 21:39:07 Will we definitely need this? If so, we should pro
217 int32_t extra_data_size;
218
219 VideoDecoderConfig()
220 : codec(kUnknownVideoCodec),
221 profile(VIDEO_CODEC_PROFILE_UNKNOWN),
222 format(VideoFrame::INVALID),
223 coded_size(0, 0),
224 extra_data(NULL),
225 extra_data_size(0) {}
226 };
227
132 class ContentDecryptionModule { 228 class ContentDecryptionModule {
133 public: 229 public:
134 // Generates a |key_request| given the |init_data|. 230 // Generates a |key_request| given the |init_data|.
135 // Returns kSuccess if the key request was successfully generated, 231 // Returns kSuccess if the key request was successfully generated,
136 // in which case the callee should have allocated memory for the output 232 // in which case the callee should have allocated memory for the output
137 // parameters (e.g |session_id| in |key_request|) and passed the ownership 233 // parameters (e.g |session_id| in |key_request|) and passed the ownership
138 // to the caller. 234 // to the caller.
139 // Returns kErrorUnknown otherwise, in which case the output parameters should 235 // Returns kErrorUnknown otherwise, in which case the output parameters should
140 // not be used by the caller. 236 // not be used by the caller.
141 // 237 //
(...skipping 29 matching lines...) Expand all
171 // to decrypt. 267 // to decrypt.
172 // Returns kErrorUnknown if any other error happened. 268 // Returns kErrorUnknown if any other error happened.
173 // In these two cases, |decrypted_buffer| should not be used by the caller. 269 // In these two cases, |decrypted_buffer| should not be used by the caller.
174 // 270 //
175 // TODO(xhwang): It's not safe to pass the ownership of the dynamically 271 // TODO(xhwang): It's not safe to pass the ownership of the dynamically
176 // allocated memory over library boundaries. Fix it after related PPAPI change 272 // allocated memory over library boundaries. Fix it after related PPAPI change
177 // and sample CDM are landed. 273 // and sample CDM are landed.
178 virtual Status Decrypt(const InputBuffer& encrypted_buffer, 274 virtual Status Decrypt(const InputBuffer& encrypted_buffer,
179 OutputBuffer* decrypted_buffer) = 0; 275 OutputBuffer* decrypted_buffer) = 0;
180 276
277 // Initializes the CDM video decoder with |video_decoder_config|. This
ddorwin 2012/08/29 17:33:49 To keep Decrypt* together, I would move this above
Tom Finegan 2012/08/30 17:09:23 Done.
278 // function must be called before DecryptAndDecode is called.
279 // Returns kSuccess if the |video_decoder_config| is supported and the CDM
280 // video decoder is successfully initialized.
281 // Returns kErrorUnknown otherwise.
282 virtual Status InitializeVideoDecoder(
283 const VideoDecoderConfig& video_decoder_config) = 0;
284
285 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a
286 // |video_frame|. Upon end-of-stream, the caller should call this function
287 // repeatedly with empty |encrypted_buffer| (where |data| is NULL) until
288 // only empty (|format| being EMPTY) |video_frame| can be produced.
ddorwin 2012/08/29 17:33:49 Do we need a Flush() if no longer care about the f
Tom Finegan 2012/08/30 17:09:23 We might need it for seeking, added.
289 // Returns kSuccess if decryption and decoding both succeeded, in which case
290 // the callee should have filled the |video_frame| and passed the ownership of
291 // |data| in |video_frame| to the caller.
292 // Returns kErrorNoKey if the CDM did not have the necessary decryption key
293 // to decrypt.
294 // Returns kErrorUnknown if any other (decryption or decoding) error happened.
295 // In these two cases, |video_frame| should not be used by the caller.
296 //
297 // TODO(xhwang): It's not safe to pass the ownership of the dynamically
298 // allocated memory over library boundaries. Fix it after related PPAPI change
299 // and sample CDM are landed.
300 virtual Status DecryptAndDecode(const InputBuffer& encrypted_buffer,
301 VideoFrame* video_frame) = 0;
302
181 virtual ~ContentDecryptionModule() {} 303 virtual ~ContentDecryptionModule() {}
182 }; 304 };
183 305
184 } // namespace cdm 306 } // namespace cdm
185 307
186 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ 308 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698