Chromium Code Reviews| 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 cdm::Allocator* allocator, |
| 30 cdm::CdmHost* host, | |
| 31 const char* key_system, | |
|
ddorwin
2012/10/26 23:00:11
I think these should be first.
Tom Finegan
2012/10/26 23:30:18
Done.
| |
| 32 int key_system_size); | |
| 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 the |key_system|, |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(const char* key_system, |
|
ddorwin
2012/10/26 23:00:11
I don't think we need key_system here. cdm_wrapper
Tom Finegan
2012/10/26 23:30:18
Done.
| |
| 216 // TODO(xhwang): It's not safe to pass the ownership of the dynamically | 219 int key_system_size, |
| 217 // allocated memory over library boundaries. Fix it after related PPAPI change | 220 const char* type, |
| 218 // and sample CDM are landed. | 221 int type_size, |
| 219 virtual Status GenerateKeyRequest(const uint8_t* init_data, | 222 const uint8_t* init_data, |
| 220 int init_data_size, | 223 int init_data_size, |
| 221 KeyMessage* key_request) = 0; | 224 KeyMessage* key_request) = 0; |
| 222 | 225 |
| 223 // Adds the |key| to the CDM to be associated with |key_id|. | 226 // Adds the |key| to the CDM to be associated with |key_id|. |
| 224 // | 227 // |
| 225 // Returns kSuccess if the key was successfully added, kSessionError | 228 // Returns kSuccess if the key was successfully added, kSessionError |
| 226 // otherwise. | 229 // otherwise. |
| 227 virtual Status AddKey(const char* session_id, | 230 virtual Status AddKey(const char* session_id, |
| 228 int session_id_size, | 231 int session_id_size, |
| 229 const uint8_t* key, | 232 const uint8_t* key, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 virtual Buffer* buffer() = 0; | 463 virtual Buffer* buffer() = 0; |
| 461 | 464 |
| 462 protected: | 465 protected: |
| 463 AudioFrames() {} | 466 AudioFrames() {} |
| 464 virtual ~AudioFrames() {} | 467 virtual ~AudioFrames() {} |
| 465 }; | 468 }; |
| 466 | 469 |
| 467 } // namespace cdm | 470 } // namespace cdm |
| 468 | 471 |
| 469 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ | 472 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_CONTENT_DECRYPTION_MODULE_H_ |
| OLD | NEW |