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

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: Compiles, does nothing. 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..dfce0fdf3f40efbd47508d294a8641e70884c83b 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,96 @@ 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 ColorFormat {
+ // Values are skipped in here to keep them synchronized with
ddorwin 2012/09/02 21:39:08 Is there a reason these need to be synchronized? A
+ // media::VideoFrame::Format.
+ kFormatInvalid = 0, // Invalid format value. Used for error reporting.
+ kFormatYv12 = 2, // 12bpp YVU planar 1x1 Y, 2x2 VU samples.
+ kFormatEmpty = 4, // An empty frame.
+ kFormatI420 = 5, // 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(kFormatInvalid) {
+ for (int i = 0; i < kMaxPlanes; ++i) {
+ strides[i] = 0;
+ data[i] = NULL;
+ }
+ }
+
+ ColorFormat format;
+
+ // Width and height of the video frame.
+ Size frame_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];
+
+ base::TimeDelta timestamp; // Presentation timestamp in microseconds.
+};
+
+struct VideoDecoderConfig {
+ enum VideoCodec {
+ kCodecUnknown = 0,
+ kCodecH264,
+ kCodecVp8 = 6 // matches value from media::VideoCodec.
+ };
+
+ 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::ColorFormat format;
ddorwin 2012/09/02 21:39:08 Odd that we have to use the other class's enum. Ma
xhwang 2012/09/04 14:50:21 Done in http://codereview.chromium.org/10900007/
+ VideoFrame::Size frame_size;
+ uint8_t* extra_data;
+ int32_t extra_data_size;
+
+ VideoDecoderConfig()
+ : codec(kCodecUnknown),
+ profile(VIDEO_CODEC_PROFILE_UNKNOWN),
+ format(VideoFrame::kFormatInvalid),
+ frame_size(0, 0),
+ extra_data(NULL),
+ extra_data_size(0) {}
+};
+
class ContentDecryptionModule {
public:
// Generates a |key_request| given the |init_data|.
@@ -163,6 +255,19 @@ class ContentDecryptionModule {
virtual Status CancelKeyRequest(const char* session_id,
int session_id_size) = 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 kErrorUnknown otherwise.
+ virtual Status InitializeVideoDecoder(
+ const VideoDecoderConfig& video_decoder_config) = 0;
+
+ // Flushes decoded video buffers stored by the CDM video decoder. This
+ // function should be called after seeking to ensure that frames decoded
+ // before seeking are not displayed.
+ virtual Status FlushVideoDecoder() = 0;
ddorwin 2012/09/02 21:39:08 Should we just have one Flush() for all streams? I
xhwang 2012/09/04 14:50:21 From media pipeline, the flush calls come from Vid
+
// Decrypts the |encrypted_buffer|.
// Returns kSuccess if decryption succeeded, in which case the callee
// should have filled the |decrypted_buffer| and passed the ownership of
@@ -178,6 +283,24 @@ class ContentDecryptionModule {
virtual Status Decrypt(const InputBuffer& encrypted_buffer,
OutputBuffer* decrypted_buffer) = 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 DecryptAndDecode(const InputBuffer& encrypted_buffer,
+ VideoFrame* video_frame) = 0;
+
virtual ~ContentDecryptionModule() {}
};

Powered by Google App Engine
This is Rietveld 408576698