Index: webkit/media/crypto/clear_key_cdm.h |
diff --git a/webkit/media/crypto/clear_key_cdm.h b/webkit/media/crypto/clear_key_cdm.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..891c18e500726877626e209799f649c55206e67b |
--- /dev/null |
+++ b/webkit/media/crypto/clear_key_cdm.h |
@@ -0,0 +1,109 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef WEBKIT_MEDIA_CRYPTO_CLEAR_KEY_CDM_H_ |
+#define WEBKIT_MEDIA_CRYPTO_CLEAR_KEY_CDM_H_ |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
+#include "base/memory/ref_counted.h" |
+#include "media/base/decryptor_client.h" |
+#include "media/crypto/aes_decryptor.h" |
+#include "webkit/media/crypto/content_decryption_module.h" |
+ |
+namespace media { |
+class DecoderBuffer; |
+} |
+ |
+class ClearKeyCdm : public ContentDecryptionModule { |
+ public: |
+ ClearKeyCdm(); |
+ virtual ~ClearKeyCdm(); |
+ |
+ // 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
|
+ void Reset(); |
+ |
+ // ContentDecryptionModule implementation. |
+ virtual CdmStatus GenerateKeyRequest(const uint8_t* init_data, |
+ int init_data_size, |
+ char** session_id, |
+ int* session_id_size, |
+ uint8_t** key_request, |
+ int* key_request_size, |
+ char** default_url, |
+ 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
|
+ |
+ virtual CdmStatus AddKey(const char* session_id, |
+ int session_id_size, |
+ const uint8_t* key, |
+ int key_size) OVERRIDE; |
+ |
+ virtual CdmStatus CancelKeyRequest(const char* session_id, |
+ 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
|
+ |
+ virtual CdmStatus Decrypt(const char* session_id, |
+ int session_id_size, |
Tom Finegan
2012/08/15 20:02:42
Ditto.
|
+ 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.
|
+ OutputBuffer* decrypted_buffer) OVERRIDE; |
+ |
+ private: |
+ class Client : public media::DecryptorClient { |
+ public: |
+ enum Status { |
+ kKeyAdded, |
+ kKeyError, |
+ kKeyMessage, |
+ kNeedKey |
+ }; |
+ |
+ Client(); |
+ virtual ~Client(); |
+ |
+ Status status() { return status_; } |
+ const std::string& session_id() { return session_id_; } |
+ const uint8* key_message() { return key_message_.get(); } |
+ int key_message_length() { return key_message_length_; } |
+ const std::string& default_url() { return default_url_; } |
+ |
+ // Resets the Client to a clean state. |
+ void Reset(); |
+ |
+ // media::DecryptorClient implementation. |
+ virtual void KeyAdded(const std::string& key_system, |
+ const std::string& session_id) OVERRIDE; |
+ virtual void KeyError(const std::string& key_system, |
+ const std::string& session_id, |
+ media::Decryptor::KeyError error_code, |
+ int system_code) OVERRIDE; |
+ virtual void KeyMessage(const std::string& key_system, |
+ const std::string& session_id, |
+ scoped_array<uint8> message, |
+ int message_length, |
+ const std::string& default_url) OVERRIDE; |
+ virtual void NeedKey(const std::string& key_system, |
+ const std::string& session_id, |
+ scoped_array<uint8> init_data, |
+ int init_data_length) OVERRIDE; |
+ |
+ private: |
+ Status status_; |
+ std::string session_id_; |
+ scoped_array<uint8> key_message_; |
+ int key_message_length_; |
+ std::string default_url_; |
+ }; |
+ |
+ // Callback that is passed in decryptor_->Decrypt(). |
+ 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.
|
+ const scoped_refptr<media::DecoderBuffer>& buffer); |
+ |
+ Client client_; |
+ media::AesDecryptor decryptor_; |
+ 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.
|
+ scoped_refptr<media::DecoderBuffer> decrypted_buffer_; |
+}; |
+ |
+#endif // WEBKIT_MEDIA_CRYPTO_CLEAR_KEY_CDM_H_ |