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

Unified 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, 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..6ea29411fa3541c00107beeb7a2908374914cd49 100644
--- a/webkit/media/crypto/ppapi/content_decryption_module.h
+++ b/webkit/media/crypto/ppapi/content_decryption_module.h
@@ -8,11 +8,13 @@
#if defined(_MSC_VER)
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
+typedef int int32_t;
typedef __int64 int64_t;
#else
#include <stdint.h>
#endif
+#include "base/time.h"
#include "webkit/media/crypto/ppapi/cdm_export.h"
namespace cdm {
@@ -129,6 +131,100 @@ struct OutputBuffer {
int64_t timestamp; // Presentation timestamp in microseconds.
};
+struct VideoFrame {
+ // Surface formats roughly based on FOURCC labels, see:
+ // http://www.fourcc.org/rgb.php
+ // http://www.fourcc.org/yuv.php
+ 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
+ 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
+ RGB32, // 32bpp RGB packed with extra byte 8:8:8.
+ 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.
+ YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples.
+ 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.
+ 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;
+ };
+
+ const static int32_t kMaxPlanes = 3;
+
+ VideoFrame() : format(INVALID) {
+ 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;
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.
+
+ // 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];
+
+ base::TimeDelta timestamp; // Presentation timestamp in microseconds.
+};
+
+struct VideoDecoderConfig {
+ enum VideoCodec {
+ 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
+ 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
+ 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.
+ kCodecMPEG2,
+ kCodecMPEG4,
+ kCodecTheora,
+ kCodecVP8
+ };
+
+ enum VideoCodecProfile {
+ VIDEO_CODEC_PROFILE_UNKNOWN = -1,
+ 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
+ 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;
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
+ 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/.
+ 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
+ int32_t extra_data_size;
+
+ VideoDecoderConfig()
+ : codec(kUnknownVideoCodec),
+ profile(VIDEO_CODEC_PROFILE_UNKNOWN),
+ format(VideoFrame::INVALID),
+ coded_size(0, 0),
+ extra_data(NULL),
+ extra_data_size(0) {}
+};
+
class ContentDecryptionModule {
public:
// Generates a |key_request| given the |init_data|.
@@ -178,6 +274,32 @@ class ContentDecryptionModule {
virtual Status Decrypt(const InputBuffer& encrypted_buffer,
OutputBuffer* decrypted_buffer) = 0;
+ // 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.
+ // 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 kErrorUnknown otherwise.
+ virtual Status InitializeVideoDecoder(
+ const VideoDecoderConfig& 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.
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.
+ // 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 DecryptAndDecode(const InputBuffer& encrypted_buffer,
+ VideoFrame* video_frame) = 0;
+
virtual ~ContentDecryptionModule() {}
};

Powered by Google App Engine
This is Rietveld 408576698