| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| 7 | 7 |
| 8 #if defined(_MSC_VER) | 8 #if defined(_MSC_VER) |
| 9 typedef unsigned char uint8_t; | 9 typedef unsigned char uint8_t; |
| 10 typedef unsigned int uint32_t; | 10 typedef unsigned int uint32_t; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // Width and height of video frame immediately post-decode. Not all pixels | 150 // Width and height of video frame immediately post-decode. Not all pixels |
| 151 // in this region are valid. | 151 // in this region are valid. |
| 152 Size coded_size; | 152 Size coded_size; |
| 153 | 153 |
| 154 // Optional byte data required to initialize video decoders, such as H.264 | 154 // Optional byte data required to initialize video decoders, such as H.264 |
| 155 // AAVC data. | 155 // AAVC data. |
| 156 uint8_t* extra_data; | 156 uint8_t* extra_data; |
| 157 int32_t extra_data_size; | 157 int32_t extra_data_size; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 enum StreamType { |
| 161 kStreamTypeAudio = 0, |
| 162 kStreamTypeVideo = 1 |
| 163 }; |
| 164 |
| 160 // ContentDecryptionModule interface that all CDMs need to implement. | 165 // ContentDecryptionModule interface that all CDMs need to implement. |
| 161 // Note: ContentDecryptionModule implementations must use the allocator | 166 // Note: ContentDecryptionModule implementations must use the allocator |
| 162 // provided in CreateCdmInstance() to allocate any Buffer that needs to | 167 // provided in CreateCdmInstance() to allocate any Buffer that needs to |
| 163 // be passed back to the caller. Implementations must call Buffer::Destroy() | 168 // be passed back to the caller. Implementations must call Buffer::Destroy() |
| 164 // when a Buffer is created that will never be returned to the caller. | 169 // when a Buffer is created that will never be returned to the caller. |
| 165 class ContentDecryptionModule { | 170 class ContentDecryptionModule { |
| 166 public: | 171 public: |
| 167 // Generates a |key_request| given the |init_data|. | 172 // Generates a |key_request| given the |init_data|. |
| 168 // | 173 // |
| 169 // Returns kSuccess if the key request was successfully generated, | 174 // Returns kSuccess if the key request was successfully generated, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // may still be able to do Decrypt(). | 229 // may still be able to do Decrypt(). |
| 225 // | 230 // |
| 226 // TODO(tomfinegan): Determine the proper error to return here once there | 231 // TODO(tomfinegan): Determine the proper error to return here once there |
| 227 // are callers for this method. | 232 // are callers for this method. |
| 228 // | 233 // |
| 229 // TODO(xhwang): Add stream ID here and in the following video decoder | 234 // TODO(xhwang): Add stream ID here and in the following video decoder |
| 230 // functions when we need to support multiple video streams in one CDM. | 235 // functions when we need to support multiple video streams in one CDM. |
| 231 virtual Status InitializeVideoDecoder( | 236 virtual Status InitializeVideoDecoder( |
| 232 const VideoDecoderConfig& video_decoder_config) = 0; | 237 const VideoDecoderConfig& video_decoder_config) = 0; |
| 233 | 238 |
| 239 // De-initializes the CDM decoder and sets it to an uninitialized state. The |
| 240 // caller can initialize the decoder again after this call to re-initialize |
| 241 // it. This can be used to reconfigure the decoder if the configuration |
| 242 // changes. |
| 243 virtual void DeinitializeDecoder(StreamType decoder_type) = 0; |
| 244 |
| 245 // Resets the CDM decoder to an initialized clean state. All internal buffers |
| 246 // MUST be flushed. |
| 247 virtual void ResetDecoder(StreamType decoder_type) = 0; |
| 248 |
| 234 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a | 249 // Decrypts the |encrypted_buffer| and decodes the decrypted buffer into a |
| 235 // |video_frame|. Upon end-of-stream, the caller should call this function | 250 // |video_frame|. Upon end-of-stream, the caller should call this function |
| 236 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty | 251 // repeatedly with empty |encrypted_buffer| (|data| == NULL) until only empty |
| 237 // |video_frame| (|format| == kEmptyVideoFrame) is produced. | 252 // |video_frame| (|format| == kEmptyVideoFrame) is produced. |
| 238 // | 253 // |
| 239 // Returns kSuccess if decryption and decoding both succeeded, in which case | 254 // Returns kSuccess if decryption and decoding both succeeded, in which case |
| 240 // the callee should have filled the |video_frame| and passed the ownership of | 255 // the callee should have filled the |video_frame| and passed the ownership of |
| 241 // |data| in |video_frame| to the caller. | 256 // |data| in |video_frame| to the caller. |
| 242 // Returns kNoKey if the CDM did not have the necessary decryption key | 257 // Returns kNoKey if the CDM did not have the necessary decryption key |
| 243 // to decrypt. | 258 // to decrypt. |
| 244 // Returns kNeedMoreData if more data was needed by the decoder to generate | 259 // Returns kNeedMoreData if more data was needed by the decoder to generate |
| 245 // a decoded frame (e.g. during initialization). | 260 // a decoded frame (e.g. during initialization). |
| 246 // Returns kDecryptError if any decryption error happened. | 261 // Returns kDecryptError if any decryption error happened. |
| 247 // Returns kDecodeError if any decoding error happened. | 262 // Returns kDecodeError if any decoding error happened. |
| 248 // If the return value is not kSuccess, |video_frame| should be ignored by | 263 // If the return value is not kSuccess, |video_frame| should be ignored by |
| 249 // the caller. | 264 // the caller. |
| 250 virtual Status DecryptAndDecodeFrame(const InputBuffer& encrypted_buffer, | 265 virtual Status DecryptAndDecodeFrame(const InputBuffer& encrypted_buffer, |
| 251 VideoFrame* video_frame) = 0; | 266 VideoFrame* video_frame) = 0; |
| 252 | 267 |
| 253 // Resets the CDM video decoder to an initialized clean state. All internal | |
| 254 // buffers will be flushed. | |
| 255 virtual void ResetVideoDecoder() = 0; | |
| 256 | |
| 257 // Stops the CDM video decoder and sets it to an uninitialized state. The | |
| 258 // caller can call InitializeVideoDecoder() again after this call to | |
| 259 // re-initialize the video decoder. This can be used to reconfigure the | |
| 260 // video decoder if the config changes. | |
| 261 virtual void StopVideoDecoder() = 0; | |
| 262 | |
| 263 virtual ~ContentDecryptionModule() {} | 268 virtual ~ContentDecryptionModule() {} |
| 264 }; | 269 }; |
| 265 | 270 |
| 266 // Represents a buffer created by Allocator implementations. | 271 // Represents a buffer created by Allocator implementations. |
| 267 class Buffer { | 272 class Buffer { |
| 268 public: | 273 public: |
| 269 // Destroys the buffer in the same context as it was created. | 274 // Destroys the buffer in the same context as it was created. |
| 270 virtual void Destroy() = 0; | 275 virtual void Destroy() = 0; |
| 271 | 276 |
| 272 virtual uint8_t* data() = 0; | 277 virtual uint8_t* data() = 0; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 virtual int64_t timestamp() const = 0; | 372 virtual int64_t timestamp() const = 0; |
| 368 | 373 |
| 369 protected: | 374 protected: |
| 370 VideoFrame() {} | 375 VideoFrame() {} |
| 371 virtual ~VideoFrame() {} | 376 virtual ~VideoFrame() {} |
| 372 }; | 377 }; |
| 373 | 378 |
| 374 } // namespace cdm | 379 } // namespace cdm |
| 375 | 380 |
| 376 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 381 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| OLD | NEW |