Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_MEDIA_CRYPTO_CLEAR_KEY_CDM_H_ | |
| 6 #define WEBKIT_MEDIA_CRYPTO_CLEAR_KEY_CDM_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "media/base/decryptor_client.h" | |
| 14 #include "media/crypto/aes_decryptor.h" | |
| 15 #include "webkit/media/crypto/content_decryption_module.h" | |
| 16 | |
| 17 namespace media { | |
| 18 class DecoderBuffer; | |
| 19 } | |
| 20 | |
| 21 namespace webkit_media { | |
| 22 | |
| 23 // ClearKey implementation of the cdm::ContentDecryptionModule interface. | |
| 24 // This implementation assumes that all method calls are made subsequently. | |
|
ddorwin
2012/08/16 05:00:35
subsequently doesn't seem right. Were you thinking
xhwang
2012/08/16 17:19:01
I believe it's thread-safe now. Remove this commen
| |
| 25 // Simultaneous method calls are not supported. | |
|
ddorwin
2012/08/16 05:00:35
Is this still accurate? Is it just the session man
xhwang
2012/08/16 17:19:01
It should be thread safe now.
| |
| 26 class ClearKeyCdm : public cdm::ContentDecryptionModule { | |
| 27 public: | |
| 28 ClearKeyCdm(); | |
| 29 virtual ~ClearKeyCdm(); | |
| 30 | |
| 31 // ContentDecryptionModule implementation. | |
| 32 virtual Status GenerateKeyRequest(const uint8_t* init_data, | |
| 33 int init_data_size, | |
| 34 char** session_id, | |
| 35 int* session_id_size, | |
| 36 uint8_t** key_request, | |
| 37 int* key_request_size, | |
| 38 char** default_url, | |
| 39 int* default_url_size) OVERRIDE; | |
| 40 | |
| 41 virtual Status AddKey(const char* session_id, | |
| 42 int session_id_size, | |
| 43 const uint8_t* key, | |
| 44 int key_size) OVERRIDE; | |
| 45 | |
| 46 virtual Status CancelKeyRequest(const char* session_id, | |
| 47 int session_id_size) OVERRIDE; | |
| 48 | |
| 49 virtual Status Decrypt(const char* session_id, | |
| 50 int session_id_size, | |
| 51 const cdm::InputBuffer& encrypted_buffer, | |
| 52 cdm::OutputBuffer* decrypted_buffer) OVERRIDE; | |
| 53 | |
| 54 private: | |
| 55 class Client : public media::DecryptorClient { | |
| 56 public: | |
| 57 enum Status { | |
| 58 kKeyAdded, | |
| 59 kKeyError, | |
| 60 kKeyMessage, | |
| 61 kNeedKey | |
| 62 }; | |
| 63 | |
| 64 Client(); | |
| 65 virtual ~Client(); | |
| 66 | |
| 67 Status status() { return status_; } | |
| 68 const std::string& session_id() { return session_id_; } | |
| 69 const uint8* key_message() { return key_message_.get(); } | |
| 70 int key_message_length() { return key_message_length_; } | |
| 71 const std::string& default_url() { return default_url_; } | |
| 72 | |
| 73 // Resets the Client to a clean state. | |
| 74 void Reset(); | |
| 75 | |
| 76 // media::DecryptorClient implementation. | |
| 77 virtual void KeyAdded(const std::string& key_system, | |
| 78 const std::string& session_id) OVERRIDE; | |
| 79 virtual void KeyError(const std::string& key_system, | |
| 80 const std::string& session_id, | |
| 81 media::Decryptor::KeyError error_code, | |
| 82 int system_code) OVERRIDE; | |
| 83 virtual void KeyMessage(const std::string& key_system, | |
| 84 const std::string& session_id, | |
| 85 scoped_array<uint8> message, | |
| 86 int message_length, | |
| 87 const std::string& default_url) OVERRIDE; | |
| 88 virtual void NeedKey(const std::string& key_system, | |
| 89 const std::string& session_id, | |
| 90 scoped_array<uint8> init_data, | |
| 91 int init_data_length) OVERRIDE; | |
| 92 | |
| 93 private: | |
| 94 Status status_; | |
| 95 std::string session_id_; | |
| 96 scoped_array<uint8> key_message_; | |
| 97 int key_message_length_; | |
| 98 std::string default_url_; | |
| 99 }; | |
| 100 | |
| 101 Client client_; | |
| 102 media::AesDecryptor decryptor_; | |
| 103 }; | |
| 104 | |
| 105 } // namespace webkit_media | |
| 106 | |
| 107 #endif // WEBKIT_MEDIA_CRYPTO_CLEAR_KEY_CDM_H_ | |
| OLD | NEW |