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 "base/synchronization/lock.h" | |
| 14 #include "media/base/decryptor_client.h" | |
| 15 #include "media/crypto/aes_decryptor.h" | |
| 16 #include "webkit/media/crypto/content_decryption_module.h" | |
| 17 | |
| 18 namespace media { | |
| 19 class DecoderBuffer; | |
| 20 } | |
| 21 | |
| 22 namespace webkit_media { | |
| 23 | |
| 24 // Clear key implementation of the cdm::ContentDecryptionModule interface. | |
| 25 class ClearKeyCdm : public cdm::ContentDecryptionModule { | |
| 26 public: | |
| 27 ClearKeyCdm(); | |
| 28 virtual ~ClearKeyCdm(); | |
| 29 | |
| 30 // ContentDecryptionModule implementation. | |
| 31 virtual Status GenerateKeyRequest(const uint8_t* init_data, | |
| 32 int init_data_size, | |
| 33 char** session_id, | |
| 34 int* session_id_size, | |
| 35 uint8_t** key_request, | |
| 36 int* key_request_size, | |
| 37 char** default_url, | |
| 38 int* default_url_size) OVERRIDE; | |
| 39 | |
| 40 virtual Status AddKey(const char* session_id, | |
| 41 int session_id_size, | |
| 42 const uint8_t* key, | |
| 43 int key_size, | |
| 44 const uint8_t* key_id, | |
| 45 int key_id_size) OVERRIDE; | |
| 46 | |
| 47 virtual Status CancelKeyRequest(const char* session_id, | |
| 48 int session_id_size) OVERRIDE; | |
| 49 | |
| 50 virtual Status Decrypt(const char* session_id, | |
| 51 int session_id_size, | |
| 52 const cdm::InputBuffer& encrypted_buffer, | |
| 53 cdm::OutputBuffer* decrypted_buffer) OVERRIDE; | |
| 54 | |
| 55 private: | |
| 56 class Client : public media::DecryptorClient { | |
| 57 public: | |
| 58 enum Status { | |
| 59 kKeyAdded, | |
| 60 kKeyError, | |
| 61 kKeyMessage, | |
| 62 kNeedKey | |
| 63 }; | |
| 64 | |
| 65 Client(); | |
| 66 virtual ~Client(); | |
| 67 | |
| 68 Status status() { return status_; } | |
| 69 const std::string& session_id() { return session_id_; } | |
| 70 const uint8* key_message() { return key_message_.get(); } | |
| 71 int key_message_length() { return key_message_length_; } | |
| 72 const std::string& default_url() { return default_url_; } | |
| 73 | |
| 74 // Resets the Client to a clean state. | |
| 75 void Reset(); | |
| 76 | |
| 77 // media::DecryptorClient implementation. | |
| 78 virtual void KeyAdded(const std::string& key_system, | |
| 79 const std::string& session_id) OVERRIDE; | |
| 80 virtual void KeyError(const std::string& key_system, | |
| 81 const std::string& session_id, | |
| 82 media::Decryptor::KeyError error_code, | |
| 83 int system_code) OVERRIDE; | |
| 84 virtual void KeyMessage(const std::string& key_system, | |
| 85 const std::string& session_id, | |
| 86 scoped_array<uint8> message, | |
| 87 int message_length, | |
| 88 const std::string& default_url) OVERRIDE; | |
| 89 virtual void NeedKey(const std::string& key_system, | |
| 90 const std::string& session_id, | |
| 91 scoped_array<uint8> init_data, | |
| 92 int init_data_length) OVERRIDE; | |
| 93 | |
| 94 private: | |
| 95 Status status_; | |
| 96 std::string session_id_; | |
| 97 scoped_array<uint8> key_message_; | |
| 98 int key_message_length_; | |
| 99 std::string default_url_; | |
| 100 }; | |
| 101 | |
| 102 Client client_; | |
| 103 media::AesDecryptor decryptor_; | |
| 104 // Protects the |client_| from being accessed by the |decryptor_| | |
| 105 // simultaneously. | |
| 106 base::Lock lock_; | |
|
ddorwin
2012/08/16 17:36:50
client_lock_?
xhwang
2012/08/20 21:09:45
Done.
| |
| 107 }; | |
| 108 | |
| 109 } // namespace webkit_media | |
| 110 | |
| 111 #endif // WEBKIT_MEDIA_CRYPTO_CLEAR_KEY_CDM_H_ | |
| OLD | NEW |