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

Unified Diff: webkit/media/crypto/ppapi/content_decryption_module.h

Issue 10900007: Add video decoding support in the CDM interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace uint8 with uint8_t. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
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..dda12fe808dca04bd9d306f5c2850770112f5db1 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,94 @@ struct OutputBuffer {
int64_t timestamp; // Presentation timestamp in microseconds.
};
+struct VideoFrame {
scherkus (not reviewing) 2012/09/01 12:33:08 this looks copied from media/base/video_frame.h c
xhwang 2012/09/01 13:05:24 Done.
+ // Surface formats roughly based on FOURCC labels, see:
+ // http://www.fourcc.org/rgb.php
+ // http://www.fourcc.org/yuv.php
+ enum Format {
+ INVALID = 0, // Invalid format value. Used for error reporting.
+ RGB32, // 32bpp RGB packed with extra byte 8:8:8.
+ YV12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
+ YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples.
+ EMPTY, // An empty frame.
+ I420, // 12bpp YVU planar 1x1 Y, 2x2 UV samples.
+ };
+
+ 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(INVALID),
+ 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 {
+ enum VideoCodec {
+ kUnknownVideoCodec = 0,
+ kCodecH264,
+ kCodecVC1,
+ kCodecMPEG2,
+ kCodecMPEG4,
+ kCodecTheora,
scherkus (not reviewing) 2012/09/01 12:33:08 ditto
xhwang 2012/09/01 13:05:24 Done.
+ kCodecVP8
+ };
+
+ enum VideoCodecProfile {
+ VIDEO_CODEC_PROFILE_UNKNOWN = -1,
+ H264PROFILE_MIN = 0,
+ H264PROFILE_BASELINE = H264PROFILE_MIN,
+ H264PROFILE_MAIN = 1,
+ H264PROFILE_EXTENDED = 2,
+ H264PROFILE_HIGH = 3,
+ H264PROFILE_HIGH10PROFILE = 4,
+ H264PROFILE_HIGH422PROFILE = 5,
+ H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
+ H264PROFILE_SCALABLEBASELINE = 7,
+ H264PROFILE_SCALABLEHIGH = 8,
+ H264PROFILE_STEREOHIGH = 9,
+ H264PROFILE_MULTIVIEWHIGH = 10,
+ H264PROFILE_MAX = H264PROFILE_MULTIVIEWHIGH,
+ VP8PROFILE_MIN = 11,
+ VP8PROFILE_MAIN = VP8PROFILE_MIN,
+ VP8PROFILE_MAX = VP8PROFILE_MAIN,
+ VIDEO_CODEC_PROFILE_MAX = VP8PROFILE_MAX
+ };
+
+ 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 +267,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.
scherkus (not reviewing) 2012/09/01 12:33:08 append () to function names in comments
xhwang 2012/09/01 13:05:24 Done.
+ // 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.
+ // 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.
+ // 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
+ // stopped.
+ // Returns kSuccess if the video decoder is successfully stopped.
+ // Returns kErrorUnknown otherwise.
+ virtual Status StopVideoDecoder() = 0;
+
virtual ~ContentDecryptionModule() {}
};
« webkit/media/crypto/ppapi/clear_key_cdm.cc ('K') | « webkit/media/crypto/ppapi/clear_key_cdm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698