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..a2eb16db763332f22e21e9e853daee1bf09936d1 100644 |
--- a/webkit/media/crypto/ppapi/content_decryption_module.h |
+++ b/webkit/media/crypto/ppapi/content_decryption_module.h |
@@ -29,8 +29,12 @@ namespace cdm { |
enum Status { |
kSuccess = 0, |
- kErrorUnknown, |
- kErrorNoKey |
+ kDecryptOnly, // The CDM does not support doing DecryptAndDecode() for the |
+ // requested decoder config but can still be used to do |
+ // Decrypt() only. |
+ kNeedMoreData, // Decoder needs more data to produce a decoded frame/sample. |
+ kNoKey, // The decryption key is not available for decryption. |
ddorwin
2012/09/05 09:37:58
The required decryption key is not available.
xhwang
2012/09/05 14:02:00
Done.
|
+ kError |
}; |
// TODO(xhwang): Use int32_t instead of uint32_t for sizes here and below and |
@@ -129,6 +133,83 @@ struct OutputBuffer { |
int64_t timestamp; // Presentation timestamp in microseconds. |
}; |
+// Surface formats based on FOURCC labels, see: |
+// http://www.fourcc.org/yuv.php |
+enum VideoFormat { |
+ kUnknownVideoFormat = 0, // Unknown format value. Used for error reporting. |
+ kEmptyVideoFrame, // An empty frame. |
+ kYv12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples. |
+ kI420 // 12bpp YVU planar 1x1 Y, 2x2 UV samples. |
xhwang
2012/09/04 15:08:18
I am not totally clear about what formats we will
|
+}; |
+ |
+struct VideoSize { |
+ VideoSize() : width(0), height(0) {} |
+ VideoSize(int32_t width, int32_t height) : width(width), height(height) {} |
+ |
+ int32_t width; |
+ int32_t height; |
+}; |
+ |
+struct VideoFrame { |
+ static const int32_t kMaxPlanes = 3; |
+ |
+ VideoFrame() |
+ : format(kUnknownVideoFormat), |
+ timestamp(0) { |
+ for (int i = 0; i < kMaxPlanes; ++i) { |
+ strides[i] = 0; |
+ data[i] = NULL; |
+ } |
+ } |
+ |
+ VideoFormat format; |
ddorwin
2012/09/05 09:37:58
As discussed in 10899021, why do we need format an
xhwang
2012/09/05 14:02:00
In src/media, video decoder config is only used in
|
+ |
+ // Width and height of the video frame. |
+ VideoSize data_size; |
xhwang
2012/09/04 15:08:18
scherkus@: my understanding is that this is the sa
|
+ |
+ // 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 VideoDecoderConfig { |
+ enum VideoCodec { |
+ kUnknownVideoCodec = 0, |
+ kCodecVP8 |
+ }; |
+ |
+ enum VideoCodecProfile { |
+ kUnknownVideoCodecProfile = 0, |
+ kVp8ProfileMain |
+ }; |
+ |
+ VideoDecoderConfig() |
+ : codec(kUnknownVideoCodec), |
+ profile(kUnknownVideoCodecProfile), |
+ format(kUnknownVideoFormat), |
+ extra_data(NULL), |
+ extra_data_size() {} |
+ |
+ VideoCodec codec; |
+ VideoCodecProfile profile; |
+ VideoFormat format; |
+ |
+ // Width and height of video frame immediately post-decode. Not all pixels |
+ // in this region are valid. |
+ VideoSize coded_size; |
+ |
+ // Optional byte data required to initialize video decoders, such as H.264 |
+ // AAVC data. |
+ uint8_t* extra_data; |
+ int32_t extra_data_size; |
+}; |
+ |
class ContentDecryptionModule { |
public: |
// Generates a |key_request| given the |init_data|. |
@@ -136,7 +217,7 @@ class ContentDecryptionModule { |
// in which case the callee should have allocated memory for the output |
// parameters (e.g |session_id| in |key_request|) and passed the ownership |
// to the caller. |
- // Returns kErrorUnknown otherwise, in which case the output parameters should |
+ // Returns kError otherwise, in which case the output parameters should |
// not be used by the caller. |
// |
// TODO(xhwang): It's not safe to pass the ownership of the dynamically |
@@ -148,7 +229,7 @@ class ContentDecryptionModule { |
// Adds the |key| to the CDM to be associated with |key_id|. |
// Returns kSuccess if the key was successfully added. |
- // Returns kErrorUnknown otherwise. |
+ // Returns kError otherwise. |
virtual Status AddKey(const char* session_id, |
int session_id_size, |
const uint8_t* key, |
@@ -159,7 +240,7 @@ class ContentDecryptionModule { |
// Cancels any pending key request made to the CDM for |session_id|. |
// Returns kSuccess if all pending key requests for |session_id| were |
// successfully canceled or there was no key request to be canceled. |
- // Returns kErrorUnknown otherwise. |
+ // Returns kError otherwise. |
virtual Status CancelKeyRequest(const char* session_id, |
int session_id_size) = 0; |
@@ -167,10 +248,11 @@ class ContentDecryptionModule { |
// Returns kSuccess if decryption succeeded, in which case the callee |
// should have filled the |decrypted_buffer| and passed the ownership of |
// |data| in |decrypted_buffer| to the caller. |
- // Returns kErrorNoKey if the CDM did not have the necessary decryption key |
+ // Returns kNoKey if the CDM did not have the necessary decryption key |
// to decrypt. |
- // Returns kErrorUnknown if any other error happened. |
- // In these two cases, |decrypted_buffer| should not be used by the caller. |
+ // Returns kError if any other error happened. |
+ // If the return value is not kSuccess, |decrypted_buffer| should be discarded |
ddorwin
2012/09/05 09:37:58
What does "discarded" mean exactly? Ignored or des
xhwang
2012/09/05 14:02:00
Done.
|
+ // and 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 |
@@ -178,6 +260,45 @@ 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/09/05 09:37:58
In 10899021, I suggested moving this up so that De
xhwang
2012/09/05 14:02:00
I am grouping *Video* together. Later will also gr
|
+ // function must be called before DecryptAndDecodeVideo() is called. |
+ // Returns kSuccess if the |video_decoder_config| is supported and the CDM |
+ // video decoder is successfully initialized. |
+ // Returns kDecryptOnly if the |video_decoder_config| is not supported |
+ // but the CDM can still be used to Decrypt() the video stream. |
+ // Returns kError if |video_decoder_config| is not supported and the |
+ // CDM can not be used (or is not allowed) to Decrypt() the video stream. |
ddorwin
2012/09/05 09:37:58
Can "allowed" really be determined during initiali
xhwang
2012/09/05 14:02:00
Removed kDecryptOnly. If InitializeVideoDecoder()
|
+ virtual Status InitializeVideoDecoder( |
ddorwin
2012/09/05 09:37:58
Nothing to do now, but something to consider when
xhwang
2012/09/05 14:02:00
Good point. Added a todo.
|
+ 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| (|data| being NULL) until |
ddorwin
2012/09/05 09:37:58
Suggestion: The following might be easier to read.
xhwang
2012/09/05 14:02:00
Done.
|
+ // only empty |video_frame| (|format| being kEmptyVideoFrame) is 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 kNoKey if the CDM did not have the necessary decryption key |
+ // to decrypt. |
+ // Returns kNeedMoreData if more data was needed by the decoder to generate |
+ // a decoded frame (e.g. during initialization). |
+ // Returns kError if any other (decryption or decoding) error happened. |
+ // If the return value is not kSuccess, |video_frame| should be discarded and |
ddorwin
2012/09/05 09:37:58
Same wrt "discarded".
xhwang
2012/09/05 14:02:00
Done.
|
+ // 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. |
ddorwin
2012/09/05 09:37:58
... Any in-process frames are flushed.
^ or so
xhwang
2012/09/05 14:02:00
Done.
|
+ virtual void ResetVideoDecoder() = 0; |
xhwang
2012/09/04 15:08:18
In 10899021 it's changed to Flush*.
AudioDecoder/
|
+ |
+ // Stops the CDM video decoder and set it to an uninitialized state. Note |
ddorwin
2012/09/05 09:37:58
s/set/sets/
xhwang
2012/09/05 14:02:00
Done.
|
+ // that a VideoDecoder cannot be re-initialized after it has been stopped. |
xhwang
2012/09/04 15:08:18
This will not be true in the future if we need to
ddorwin
2012/09/05 09:37:58
We do. I think this is likely to be a V1 requireme
xhwang
2012/09/05 14:02:00
I chatted w/ acolwell@ offline. We are not doing s
|
+ virtual void StopVideoDecoder() = 0; |
+ |
virtual ~ContentDecryptionModule() {} |
}; |