| 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 13 matching lines...) Expand all Loading... |
| 24 // forwards decryptor calls to it. | 24 // forwards decryptor calls to it. |
| 25 // TODO(xhwang): Currently we don't support run-time switching among decryptor | 25 // TODO(xhwang): Currently we don't support run-time switching among decryptor |
| 26 // objects. Fix this when needed. | 26 // objects. Fix this when needed. |
| 27 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! | 27 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! |
| 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); | |
| 36 virtual ~ProxyDecryptor(); | 35 virtual ~ProxyDecryptor(); |
| 37 | 36 |
| 38 // Only call this once. | 37 // Only call this once. |
| 39 bool InitializeCDM(const std::string& key_system); | 38 bool InitializeCDM(const std::string& key_system); |
| 40 | 39 |
| 41 // Requests the ProxyDecryptor to notify the decryptor when it's ready through | 40 // Requests the ProxyDecryptor to notify the decryptor when it's ready through |
| 42 // the |decryptor_ready_cb| provided. | 41 // the |decryptor_ready_cb| provided. |
| 43 // If |decryptor_ready_cb| is null, the existing callback will be fired with | 42 // If |decryptor_ready_cb| is null, the existing callback will be fired with |
| 44 // NULL immediately and reset. | 43 // NULL immediately and reset. |
| 45 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); | 44 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 #endif // defined(ENABLE_PEPPER_CDMS) | 65 #endif // defined(ENABLE_PEPPER_CDMS) |
| 67 | 66 |
| 68 // Callbacks for firing key events. | 67 // Callbacks for firing key events. |
| 69 void KeyAdded(const std::string& session_id); | 68 void KeyAdded(const std::string& session_id); |
| 70 void KeyError(const std::string& session_id, | 69 void KeyError(const std::string& session_id, |
| 71 media::MediaKeys::KeyError error_code, | 70 media::MediaKeys::KeyError error_code, |
| 72 int system_code); | 71 int system_code); |
| 73 void KeyMessage(const std::string& session_id, | 72 void KeyMessage(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& session_id, | |
| 77 const std::string& type, | |
| 78 scoped_ptr<uint8[]> init_data, int init_data_size); | |
| 79 | 75 |
| 80 // Needed to create the PpapiDecryptor. | 76 // Needed to create the PpapiDecryptor. |
| 81 WebKit::WebMediaPlayerClient* web_media_player_client_; | 77 WebKit::WebMediaPlayerClient* web_media_player_client_; |
| 82 WebKit::WebFrame* web_frame_; | 78 WebKit::WebFrame* web_frame_; |
| 83 | 79 |
| 84 // Callbacks for firing key events. | 80 // Callbacks for firing key events. |
| 85 media::KeyAddedCB key_added_cb_; | 81 media::KeyAddedCB key_added_cb_; |
| 86 media::KeyErrorCB key_error_cb_; | 82 media::KeyErrorCB key_error_cb_; |
| 87 media::KeyMessageCB key_message_cb_; | 83 media::KeyMessageCB key_message_cb_; |
| 88 media::NeedKeyCB need_key_cb_; | |
| 89 | 84 |
| 90 // Protects the |decryptor_|. Note that |decryptor_| itself should be thread | 85 // Protects the |decryptor_|. Note that |decryptor_| itself should be thread |
| 91 // safe as per the Decryptor interface. | 86 // safe as per the Decryptor interface. |
| 92 base::Lock lock_; | 87 base::Lock lock_; |
| 93 | 88 |
| 94 media::DecryptorReadyCB decryptor_ready_cb_; | 89 media::DecryptorReadyCB decryptor_ready_cb_; |
| 95 | 90 |
| 96 // The real MediaKeys that manages key operations for the ProxyDecryptor. | 91 // The real MediaKeys that manages key operations for the ProxyDecryptor. |
| 97 // This pointer is protected by the |lock_|. | 92 // This pointer is protected by the |lock_|. |
| 98 scoped_ptr<media::MediaKeys> media_keys_; | 93 scoped_ptr<media::MediaKeys> media_keys_; |
| 99 | 94 |
| 100 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; | 95 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; |
| 101 | 96 |
| 102 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); | 97 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); |
| 103 }; | 98 }; |
| 104 | 99 |
| 105 } // namespace webkit_media | 100 } // namespace webkit_media |
| 106 | 101 |
| 107 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 102 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
| OLD | NEW |