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 class ClearKeyCdm : public ContentDecryptionModule { | |
| 22 public: | |
| 23 ClearKeyCdm(); | |
| 24 virtual ~ClearKeyCdm(); | |
| 25 | |
| 26 // Reset the |decryption_status_| and |decrypted_buffer|. | |
|
ddorwin
2012/08/15 20:15:00
Why would we need to do this? Who is calling it if
| |
| 27 void Reset(); | |
| 28 | |
| 29 // ContentDecryptionModule implementation. | |
| 30 virtual CdmStatus GenerateKeyRequest(const uint8_t* init_data, | |
| 31 int init_data_size, | |
| 32 char** session_id, | |
| 33 int* session_id_size, | |
| 34 uint8_t** key_request, | |
| 35 int* key_request_size, | |
| 36 char** default_url, | |
| 37 int* default_url_size) OVERRIDE; | |
|
Tom Finegan
2012/08/15 20:02:42
Do we want to wrap all of these up in a struct?
xhwang
2012/08/16 02:32:40
This probably will change as the spec changes. I'd
| |
| 38 | |
| 39 virtual CdmStatus AddKey(const char* session_id, | |
| 40 int session_id_size, | |
| 41 const uint8_t* key, | |
| 42 int key_size) OVERRIDE; | |
| 43 | |
| 44 virtual CdmStatus CancelKeyRequest(const char* session_id, | |
| 45 int session_id_size) OVERRIDE; | |
|
Tom Finegan
2012/08/15 20:02:42
Is the size param necessary? I think we can probab
xhwang
2012/08/16 02:32:40
Good point. I use size here to be consistent with
| |
| 46 | |
| 47 virtual CdmStatus Decrypt(const char* session_id, | |
| 48 int session_id_size, | |
|
Tom Finegan
2012/08/15 20:02:42
Ditto.
| |
| 49 const InputBuffer& encrypted_buffer, | |
|
ddorwin
2012/08/15 20:15:00
I now realize that InputBuffer is in the global na
xhwang
2012/08/16 02:32:40
Put it in cdm namespace.
| |
| 50 OutputBuffer* decrypted_buffer) OVERRIDE; | |
| 51 | |
| 52 private: | |
| 53 class Client : public media::DecryptorClient { | |
| 54 public: | |
| 55 enum Status { | |
| 56 kKeyAdded, | |
| 57 kKeyError, | |
| 58 kKeyMessage, | |
| 59 kNeedKey | |
| 60 }; | |
| 61 | |
| 62 Client(); | |
| 63 virtual ~Client(); | |
| 64 | |
| 65 Status status() { return status_; } | |
| 66 const std::string& session_id() { return session_id_; } | |
| 67 const uint8* key_message() { return key_message_.get(); } | |
| 68 int key_message_length() { return key_message_length_; } | |
| 69 const std::string& default_url() { return default_url_; } | |
| 70 | |
| 71 // Resets the Client to a clean state. | |
| 72 void Reset(); | |
| 73 | |
| 74 // media::DecryptorClient implementation. | |
| 75 virtual void KeyAdded(const std::string& key_system, | |
| 76 const std::string& session_id) OVERRIDE; | |
| 77 virtual void KeyError(const std::string& key_system, | |
| 78 const std::string& session_id, | |
| 79 media::Decryptor::KeyError error_code, | |
| 80 int system_code) OVERRIDE; | |
| 81 virtual void KeyMessage(const std::string& key_system, | |
| 82 const std::string& session_id, | |
| 83 scoped_array<uint8> message, | |
| 84 int message_length, | |
| 85 const std::string& default_url) OVERRIDE; | |
| 86 virtual void NeedKey(const std::string& key_system, | |
| 87 const std::string& session_id, | |
| 88 scoped_array<uint8> init_data, | |
| 89 int init_data_length) OVERRIDE; | |
| 90 | |
| 91 private: | |
| 92 Status status_; | |
| 93 std::string session_id_; | |
| 94 scoped_array<uint8> key_message_; | |
| 95 int key_message_length_; | |
| 96 std::string default_url_; | |
| 97 }; | |
| 98 | |
| 99 // Callback that is passed in decryptor_->Decrypt(). | |
| 100 void OnBufferDecrpted(media::Decryptor::Status status, | |
|
Tom Finegan
2012/08/15 20:02:42
s/Decrpted/Decrypted/
xhwang
2012/08/16 02:32:40
Done.
| |
| 101 const scoped_refptr<media::DecoderBuffer>& buffer); | |
| 102 | |
| 103 Client client_; | |
| 104 media::AesDecryptor decryptor_; | |
| 105 media::Decryptor::Status decryption_status_; | |
|
ddorwin
2012/08/15 20:15:00
I wonder why these two are members instead of tran
xhwang
2012/08/16 02:32:40
Done.
| |
| 106 scoped_refptr<media::DecoderBuffer> decrypted_buffer_; | |
| 107 }; | |
| 108 | |
| 109 #endif // WEBKIT_MEDIA_CRYPTO_CLEAR_KEY_CDM_H_ | |
| OLD | NEW |