Chromium Code Reviews| Index: webkit/media/crypto/ppapi/content_decryption_module.h |
| diff --git a/webkit/media/crypto/ppapi/content_decryption_module.h b/webkit/media/crypto/ppapi/content_decryption_module.h |
| index cb21258a6fb24feb19ab45813e34f3c15fb1082d..273cd57492ebd7b6b1d33956f5714c20022bf728 100644 |
| --- a/webkit/media/crypto/ppapi/content_decryption_module.h |
| +++ b/webkit/media/crypto/ppapi/content_decryption_module.h |
| @@ -30,7 +30,8 @@ namespace cdm { |
| enum Status { |
| kSuccess = 0, |
| kErrorUnknown, |
| - kErrorNoKey |
| + kErrorNoKey, |
| + kErrorDecryptOnly |
| }; |
| // TODO(xhwang): Use int32_t instead of uint32_t for sizes here and below and |
| @@ -129,6 +130,75 @@ struct OutputBuffer { |
| int64_t timestamp; // Presentation timestamp in microseconds. |
| }; |
| +struct VideoFrame { |
| + // Surface formats based on FOURCC labels, see: |
| + // http://www.fourcc.org/yuv.php |
| + enum Format { |
| + kInvalidFormat = 0, // Invalid format value. Used for error reporting. |
| + kI420 // 12bpp YVU planar 1x1 Y, 2x2 UV samples. |
|
xhwang
2012/09/01 13:14:37
Tom: in vp8, we use I420, not YV12, correct?
|
| + }; |
| + |
| + struct Size { |
| + Size() : width(0), height(0) {} |
| + Size(int32_t width, int32_t height) : width(width), height(height) {} |
| + |
| + int32_t width; |
| + int32_t height; |
| + }; |
| + |
| + static const int32_t kMaxPlanes = 3; |
| + |
| + VideoFrame() |
| + : format(kInvalidFormat), |
| + timestamp(0) { |
| + for (int i = 0; i < kMaxPlanes; ++i) { |
| + strides[i] = 0; |
| + data[i] = NULL; |
| + } |
| + } |
| + |
| + Format format; |
| + |
| + // Width and height of the video frame. |
| + Size data_size; |
| + |
| + // Array of strides for each plane, typically greater or equal to the width |
| + // of the surface divided by the horizontal sampling period. Note that |
| + // strides can be negative. |
| + int32_t strides[kMaxPlanes]; |
| + |
| + // Array of data pointers to each plane. |
| + uint8_t* data[kMaxPlanes]; |
| + |
| + int64_t timestamp; // Presentation timestamp in microseconds. |
| +}; |
| + |
| +struct VideoDeocderConfig { |
|
scherkus (not reviewing)
2012/09/02 09:13:24
typo
xhwang
2012/09/02 10:40:33
Done.
|
| + enum VideoCodec { |
| + kUnknownVideoCodec = 0, |
| + kCodecVP8 |
| + }; |
| + |
| + enum VideoCodecProfile { |
| + kUnknownVideoCodecProfile = 0, |
| + kVp8ProfileMain |
| + }; |
| + |
| + VideoDeocderConfig() |
| + : codec(kUnknownVideoCodec), |
| + profile(kUnknownVideoCodecProfile), |
| + format(VideoFrame::kInvalidFormat), |
| + extra_data(NULL), |
| + extra_data_size() {} |
| + |
| + VideoCodec codec; |
| + VideoCodecProfile profile; |
| + VideoFrame::Format format; |
| + VideoFrame::Size coded_size; |
| + uint8_t* extra_data; |
| + int32_t extra_data_size; |
| +}; |
| + |
| class ContentDecryptionModule { |
| public: |
| // Generates a |key_request| given the |init_data|. |
| @@ -178,6 +248,47 @@ class ContentDecryptionModule { |
| virtual Status Decrypt(const InputBuffer& encrypted_buffer, |
| OutputBuffer* decrypted_buffer) = 0; |
| + // Initializes the CDM video decoder with |video_decoder_config|. This |
| + // function must be called before DecryptAndDecode() is called. |
| + // Returns kSuccess if the |video_decoder_config| is supported and the CDM |
| + // video decoder is successfully initialized. |
| + // Returns kErrorDecryptOnly if the |video_decoder_config| is not supported |
| + // but the CDM can still be used to Decrypt() the video stream. |
| + // Returns kErrorUnknown if |video_decoder_config| is not supported and the |
| + // CDM can not be used (or is not allowed) to Decrypt() the video stream. |
| + virtual Status InitializeVideoDecoder( |
| + const VideoDeocderConfig& video_decoder_config) = 0; |
| + |
| + // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a |
| + // |video_frame|. Upon end-of-stream, the caller should call this function |
| + // repeatedly with empty |encrypted_buffer| (where |data| is NULL) until |
| + // only empty (|format| being EMPTY) |video_frame| can be produced. |
|
scherkus (not reviewing)
2012/09/02 09:13:24
what's EMPTY? I only see kInvalidFormat
xhwang
2012/09/02 10:40:33
Done.
|
| + // Returns kSuccess if decryption and decoding both succeeded, in which case |
| + // the callee should have filled the |video_frame| and passed the ownership of |
| + // |data| in |video_frame| to the caller. |
|
scherkus (not reviewing)
2012/09/02 09:13:24
what about decoders with delay? the first few call
xhwang
2012/09/02 10:40:33
Done.
|
| + // Returns kErrorNoKey if the CDM did not have the necessary decryption key |
| + // to decrypt. |
| + // Returns kErrorUnknown if any other (decryption or decoding) error happened. |
| + // In these two cases, |video_frame| should not be used by the caller. |
| + // |
| + // TODO(xhwang): It's not safe to pass the ownership of the dynamically |
| + // allocated memory over library boundaries. Fix it after related PPAPI change |
| + // and sample CDM are landed. |
| + virtual Status DecryptAndDecodeVideo(const InputBuffer& encrypted_buffer, |
| + VideoFrame* video_frame) = 0; |
| + |
| + // Resets the CDM video decoder to an initialized clean state. |
| + // Returns kSuccess if the video decoder is successfully reset. |
| + // Returns kErrorUnknown otherwise. |
| + virtual Status ResetVideoDecoder() = 0; |
| + |
| + // Stops the CDM video decoder and set it to an uninitialized state. Note |
| + // that a VideoDecoder should/could not be re-initialized after it has been |
|
scherkus (not reviewing)
2012/09/02 09:13:24
should/could not -> cannot
xhwang
2012/09/02 10:40:33
Done.
|
| + // stopped. |
| + // Returns kSuccess if the video decoder is successfully stopped. |
| + // Returns kErrorUnknown otherwise. |
| + virtual Status StopVideoDecoder() = 0; |
|
scherkus (not reviewing)
2012/09/02 09:13:24
what does Stop() + kErrorUnknown mean?
xhwang
2012/09/02 10:40:33
Right, in media code the callback is a closure. Up
|
| + |
| virtual ~ContentDecryptionModule() {} |
| }; |