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