| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 5 #ifndef WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
| 6 #define WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 6 #define WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class ProxyDecryptor : public media::MediaKeys { | 28 class ProxyDecryptor : public media::MediaKeys { |
| 29 public: | 29 public: |
| 30 ProxyDecryptor(WebKit::WebMediaPlayerClient* web_media_player_client, | 30 ProxyDecryptor(WebKit::WebMediaPlayerClient* web_media_player_client, |
| 31 WebKit::WebFrame* web_frame, | 31 WebKit::WebFrame* web_frame, |
| 32 const media::KeyAddedCB& key_added_cb, | 32 const media::KeyAddedCB& key_added_cb, |
| 33 const media::KeyErrorCB& key_error_cb, | 33 const media::KeyErrorCB& key_error_cb, |
| 34 const media::KeyMessageCB& key_message_cb, | 34 const media::KeyMessageCB& key_message_cb, |
| 35 const media::NeedKeyCB& need_key_cb); | 35 const media::NeedKeyCB& need_key_cb); |
| 36 virtual ~ProxyDecryptor(); | 36 virtual ~ProxyDecryptor(); |
| 37 | 37 |
| 38 // Only call this once. |
| 39 bool InitializeCDM(const std::string& key_system); |
| 40 |
| 38 // Requests the ProxyDecryptor to notify the decryptor when it's ready through | 41 // Requests the ProxyDecryptor to notify the decryptor when it's ready through |
| 39 // the |decryptor_ready_cb| provided. | 42 // the |decryptor_ready_cb| provided. |
| 40 // If |decryptor_ready_cb| is null, the existing callback will be fired with | 43 // If |decryptor_ready_cb| is null, the existing callback will be fired with |
| 41 // NULL immediately and reset. | 44 // NULL immediately and reset. |
| 42 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); | 45 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); |
| 43 | 46 |
| 44 // MediaKeys implementation. | 47 // MediaKeys implementation. |
| 45 virtual bool GenerateKeyRequest(const std::string& key_system, | 48 // May only be called after InitializeCDM() succeeds. |
| 46 const std::string& type, | 49 virtual bool GenerateKeyRequest(const std::string& type, |
| 47 const uint8* init_data, | 50 const uint8* init_data, |
| 48 int init_data_length) OVERRIDE; | 51 int init_data_length) OVERRIDE; |
| 49 virtual void AddKey(const std::string& key_system, | 52 virtual void AddKey(const uint8* key, int key_length, |
| 50 const uint8* key, int key_length, | |
| 51 const uint8* init_data, int init_data_length, | 53 const uint8* init_data, int init_data_length, |
| 52 const std::string& session_id) OVERRIDE; | 54 const std::string& session_id) OVERRIDE; |
| 53 virtual void CancelKeyRequest(const std::string& key_system, | 55 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; |
| 54 const std::string& session_id) OVERRIDE; | |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 // Helper functions to create decryptors to handle the given |key_system|. | 58 // Helper functions to create decryptors to handle the given |key_system|. |
| 58 scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system); | 59 scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system); |
| 59 #if defined(ENABLE_PEPPER_CDMS) | 60 #if defined(ENABLE_PEPPER_CDMS) |
| 60 scoped_ptr<media::Decryptor> CreatePpapiDecryptor( | 61 scoped_ptr<media::Decryptor> CreatePpapiDecryptor( |
| 61 const std::string& key_system); | 62 const std::string& key_system); |
| 62 // Callback for cleaning up a Pepper CDM. | 63 // Callback for cleaning up a Pepper CDM. |
| 63 void DestroyHelperPlugin(); | 64 void DestroyHelperPlugin(); |
| 64 #endif // defined(ENABLE_PEPPER_CDMS) | 65 #endif // defined(ENABLE_PEPPER_CDMS) |
| 65 | 66 |
| 66 // Callbacks for firing key events. | 67 // Callbacks for firing key events. |
| 67 void KeyAdded(const std::string& key_system, const std::string& session_id); | 68 void KeyAdded(const std::string& session_id); |
| 68 void KeyError(const std::string& key_system, | 69 void KeyError(const std::string& session_id, |
| 69 const std::string& session_id, | |
| 70 media::MediaKeys::KeyError error_code, | 70 media::MediaKeys::KeyError error_code, |
| 71 int system_code); | 71 int system_code); |
| 72 void KeyMessage(const std::string& key_system, | 72 void KeyMessage(const std::string& session_id, |
| 73 const std::string& session_id, | |
| 74 const std::string& message, | 73 const std::string& message, |
| 75 const std::string& default_url); | 74 const std::string& default_url); |
| 76 void NeedKey(const std::string& key_system, | 75 void NeedKey(const std::string& session_id, |
| 77 const std::string& session_id, | |
| 78 const std::string& type, | 76 const std::string& type, |
| 79 scoped_ptr<uint8[]> init_data, int init_data_size); | 77 scoped_ptr<uint8[]> init_data, int init_data_size); |
| 80 | 78 |
| 81 // Needed to create the PpapiDecryptor. | 79 // Needed to create the PpapiDecryptor. |
| 82 WebKit::WebMediaPlayerClient* web_media_player_client_; | 80 WebKit::WebMediaPlayerClient* web_media_player_client_; |
| 83 WebKit::WebFrame* web_frame_; | 81 WebKit::WebFrame* web_frame_; |
| 84 | 82 |
| 85 // Callbacks for firing key events. | 83 // Callbacks for firing key events. |
| 86 media::KeyAddedCB key_added_cb_; | 84 media::KeyAddedCB key_added_cb_; |
| 87 media::KeyErrorCB key_error_cb_; | 85 media::KeyErrorCB key_error_cb_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 99 scoped_ptr<media::Decryptor> decryptor_; | 97 scoped_ptr<media::Decryptor> decryptor_; |
| 100 | 98 |
| 101 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; | 99 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; |
| 102 | 100 |
| 103 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); | 101 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); |
| 104 }; | 102 }; |
| 105 | 103 |
| 106 } // namespace webkit_media | 104 } // namespace webkit_media |
| 107 | 105 |
| 108 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 106 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
| OLD | NEW |