| 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; |
| 11 typedef int int32_t; | 11 typedef int int32_t; |
| 12 typedef __int64 int64_t; | 12 typedef __int64 int64_t; |
| 13 #else | 13 #else |
| 14 #include <stdint.h> | 14 #include <stdint.h> |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 #include "webkit/media/crypto/ppapi/cdm_export.h" | 17 #include "webkit/media/crypto/ppapi/cdm_export.h" |
| 18 | 18 |
| 19 namespace cdm { | 19 namespace cdm { |
| 20 class Allocator; | 20 class Allocator; |
| 21 class CdmHost; | 21 class CdmHost; |
| 22 class ContentDecryptionModule; | 22 class ContentDecryptionModule; |
| 23 } | 23 } |
| 24 | 24 |
| 25 extern "C" { | 25 extern "C" { |
| 26 // Caller retains ownership of arguments, which must outlive the call to | 26 // Caller retains ownership of arguments, which must outlive the call to |
| 27 // DestroyCdmInstance below. | 27 // DestroyCdmInstance below. |
| 28 CDM_EXPORT cdm::ContentDecryptionModule* CreateCdmInstance( | 28 CDM_EXPORT cdm::ContentDecryptionModule* CreateCdmInstance( |
| 29 cdm::Allocator* allocator, cdm::CdmHost* host); | 29 const char* key_system, |
| 30 int key_system_size, |
| 31 cdm::Allocator* allocator, |
| 32 cdm::CdmHost* host); |
| 30 CDM_EXPORT void DestroyCdmInstance(cdm::ContentDecryptionModule* instance); | 33 CDM_EXPORT void DestroyCdmInstance(cdm::ContentDecryptionModule* instance); |
| 31 CDM_EXPORT const char* GetCdmVersion(); | 34 CDM_EXPORT const char* GetCdmVersion(); |
| 32 } | 35 } |
| 33 | 36 |
| 34 namespace cdm { | 37 namespace cdm { |
| 35 | 38 |
| 36 class AudioFrames; | 39 class AudioFrames; |
| 37 class Buffer; | 40 class Buffer; |
| 38 class DecryptedBlock; | 41 class DecryptedBlock; |
| 39 class KeyMessage; | 42 class KeyMessage; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 kStreamTypeVideo = 1 | 200 kStreamTypeVideo = 1 |
| 198 }; | 201 }; |
| 199 | 202 |
| 200 // ContentDecryptionModule interface that all CDMs need to implement. | 203 // ContentDecryptionModule interface that all CDMs need to implement. |
| 201 // Note: ContentDecryptionModule implementations must use the allocator | 204 // Note: ContentDecryptionModule implementations must use the allocator |
| 202 // provided in CreateCdmInstance() to allocate any Buffer that needs to | 205 // provided in CreateCdmInstance() to allocate any Buffer that needs to |
| 203 // be passed back to the caller. Implementations must call Buffer::Destroy() | 206 // be passed back to the caller. Implementations must call Buffer::Destroy() |
| 204 // when a Buffer is created that will never be returned to the caller. | 207 // when a Buffer is created that will never be returned to the caller. |
| 205 class ContentDecryptionModule { | 208 class ContentDecryptionModule { |
| 206 public: | 209 public: |
| 207 // Generates a |key_request| given the |init_data|. | 210 // Generates a |key_request| given |type| and |init_data|. |
| 208 // | 211 // |
| 209 // Returns kSuccess if the key request was successfully generated, | 212 // Returns kSuccess if the key request was successfully generated, |
| 210 // in which case the callee should have allocated memory for the output | 213 // in which case the callee should have allocated memory for the output |
| 211 // parameters (e.g |session_id| in |key_request|) and passed the ownership | 214 // parameters (e.g |session_id| in |key_request|) and passed the ownership |
| 212 // to the caller. | 215 // to the caller. |
| 213 // Returns kSessionError if any error happened, in which case the | 216 // Returns kSessionError if any error happened, in which case the |
| 214 // |key_request| should not be used by the caller. | 217 // |key_request| should not be used by the caller. |
| 215 // | 218 virtual Status GenerateKeyRequest( |
| 216 // TODO(xhwang): It's not safe to pass the ownership of the dynamically | 219 const char* type, int type_size, |
| 217 // allocated memory over library boundaries. Fix it after related PPAPI change | 220 const uint8_t* init_data, int init_data_size, |
| 218 // and sample CDM are landed. | 221 KeyMessage* key_request) = 0; |
| 219 virtual Status GenerateKeyRequest(const uint8_t* init_data, | |
| 220 int init_data_size, | |
| 221 KeyMessage* key_request) = 0; | |
| 222 | 222 |
| 223 // Adds the |key| to the CDM to be associated with |key_id|. | 223 // Adds the |key| to the CDM to be associated with |key_id|. |
| 224 // | 224 // |
| 225 // Returns kSuccess if the key was successfully added, kSessionError | 225 // Returns kSuccess if the key was successfully added, kSessionError |
| 226 // otherwise. | 226 // otherwise. |
| 227 virtual Status AddKey(const char* session_id, | 227 virtual Status AddKey(const char* session_id, int session_id_size, |
| 228 int session_id_size, | 228 const uint8_t* key, int key_size, |
| 229 const uint8_t* key, | 229 const uint8_t* key_id, int key_id_size) = 0; |
| 230 int key_size, | |
| 231 const uint8_t* key_id, | |
| 232 int key_id_size) = 0; | |
| 233 | 230 |
| 234 // Cancels any pending key request made to the CDM for |session_id|. | 231 // Cancels any pending key request made to the CDM for |session_id|. |
| 235 // | 232 // |
| 236 // Returns kSuccess if all pending key requests for |session_id| were | 233 // Returns kSuccess if all pending key requests for |session_id| were |
| 237 // successfully canceled or there was no key request to be canceled, | 234 // successfully canceled or there was no key request to be canceled, |
| 238 // kSessionError otherwise. | 235 // kSessionError otherwise. |
| 239 virtual Status CancelKeyRequest(const char* session_id, | 236 virtual Status CancelKeyRequest( |
| 240 int session_id_size) = 0; | 237 const char* session_id, int session_id_size) = 0; |
| 241 | 238 |
| 242 // Optionally populates |*msg| and indicates so in |*populated|. | 239 // Optionally populates |*msg| and indicates so in |*populated|. |
| 243 virtual void TimerExpired(KeyMessage* msg, bool* populated) = 0; | 240 virtual void TimerExpired(KeyMessage* msg, bool* populated) = 0; |
| 244 | 241 |
| 245 // Decrypts the |encrypted_buffer|. | 242 // Decrypts the |encrypted_buffer|. |
| 246 // | 243 // |
| 247 // Returns kSuccess if decryption succeeded, in which case the callee | 244 // Returns kSuccess if decryption succeeded, in which case the callee |
| 248 // should have filled the |decrypted_buffer| and passed the ownership of | 245 // should have filled the |decrypted_buffer| and passed the ownership of |
| 249 // |data| in |decrypted_buffer| to the caller. | 246 // |data| in |decrypted_buffer| to the caller. |
| 250 // Returns kNoKey if the CDM did not have the necessary decryption key | 247 // Returns kNoKey if the CDM did not have the necessary decryption key |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 virtual Buffer* buffer() = 0; | 457 virtual Buffer* buffer() = 0; |
| 461 | 458 |
| 462 protected: | 459 protected: |
| 463 AudioFrames() {} | 460 AudioFrames() {} |
| 464 virtual ~AudioFrames() {} | 461 virtual ~AudioFrames() {} |
| 465 }; | 462 }; |
| 466 | 463 |
| 467 } // namespace cdm | 464 } // namespace cdm |
| 468 | 465 |
| 469 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 466 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| OLD | NEW |