| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ | 6 #define CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // appropriate session object. Callers should hold references to this class | 26 // appropriate session object. Callers should hold references to this class |
| 27 // as long as they need the CDM instance. | 27 // as long as they need the CDM instance. |
| 28 class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> { | 28 class CdmSessionAdapter : public base::RefCounted<CdmSessionAdapter> { |
| 29 public: | 29 public: |
| 30 CdmSessionAdapter(); | 30 CdmSessionAdapter(); |
| 31 | 31 |
| 32 // Returns true on success. | 32 // Returns true on success. |
| 33 bool Initialize( | 33 bool Initialize( |
| 34 #if defined(ENABLE_PEPPER_CDMS) | 34 #if defined(ENABLE_PEPPER_CDMS) |
| 35 const CreatePepperCdmCB& create_pepper_cdm_cb, | 35 const CreatePepperCdmCB& create_pepper_cdm_cb, |
| 36 #endif | 36 #elif defined(OS_ANDROID) |
| 37 int* cdm_id, |
| 38 #endif // defined(ENABLE_PEPPER_CDMS) |
| 37 const std::string& key_system); | 39 const std::string& key_system); |
| 38 | 40 |
| 39 // Creates a new session and adds it to the internal map. The caller owns the | 41 // Creates a new session and adds it to the internal map. The caller owns the |
| 40 // created session. RemoveSession() must be called when destroying it. | 42 // created session. RemoveSession() must be called when destroying it. |
| 41 WebContentDecryptionModuleSessionImpl* CreateSession( | 43 WebContentDecryptionModuleSessionImpl* CreateSession( |
| 42 blink::WebContentDecryptionModuleSession::Client* client); | 44 blink::WebContentDecryptionModuleSession::Client* client); |
| 43 | 45 |
| 44 // Removes a session from the internal map. | 46 // Removes a session from the internal map. |
| 45 void RemoveSession(uint32 session_id); | 47 void RemoveSession(uint32 session_id); |
| 46 | 48 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 | 60 |
| 59 // Releases the session specified by |session_id|. | 61 // Releases the session specified by |session_id|. |
| 60 void ReleaseSession(uint32 session_id); | 62 void ReleaseSession(uint32 session_id); |
| 61 | 63 |
| 62 // Returns the Decryptor associated with this CDM. May be NULL if no | 64 // Returns the Decryptor associated with this CDM. May be NULL if no |
| 63 // Decryptor is associated with the MediaKeys object. | 65 // Decryptor is associated with the MediaKeys object. |
| 64 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor | 66 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor |
| 65 // after WebContentDecryptionModule is freed. http://crbug.com/330324 | 67 // after WebContentDecryptionModule is freed. http://crbug.com/330324 |
| 66 media::Decryptor* GetDecryptor(); | 68 media::Decryptor* GetDecryptor(); |
| 67 | 69 |
| 70 // Returns the CDM ID associated with the |media_keys_|. May be kInvalidCdmId |
| 71 // if no CDM ID is associated. |
| 72 int GetCdmId() const; |
| 73 |
| 68 private: | 74 private: |
| 69 friend class base::RefCounted<CdmSessionAdapter>; | 75 friend class base::RefCounted<CdmSessionAdapter>; |
| 70 typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap; | 76 typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap; |
| 71 | 77 |
| 72 ~CdmSessionAdapter(); | 78 ~CdmSessionAdapter(); |
| 73 | 79 |
| 74 // Callbacks for firing session events. | 80 // Callbacks for firing session events. |
| 75 void OnSessionCreated(uint32 session_id, const std::string& web_session_id); | 81 void OnSessionCreated(uint32 session_id, const std::string& web_session_id); |
| 76 void OnSessionMessage(uint32 session_id, | 82 void OnSessionMessage(uint32 session_id, |
| 77 const std::vector<uint8>& message, | 83 const std::vector<uint8>& message, |
| 78 const std::string& destination_url); | 84 const std::string& destination_url); |
| 79 void OnSessionReady(uint32 session_id); | 85 void OnSessionReady(uint32 session_id); |
| 80 void OnSessionClosed(uint32 session_id); | 86 void OnSessionClosed(uint32 session_id); |
| 81 void OnSessionError(uint32 session_id, | 87 void OnSessionError(uint32 session_id, |
| 82 media::MediaKeys::KeyError error_code, | 88 media::MediaKeys::KeyError error_code, |
| 83 uint32 system_code); | 89 uint32 system_code); |
| 84 | 90 |
| 85 // Helper function of the callbacks. | 91 // Helper function of the callbacks. |
| 86 WebContentDecryptionModuleSessionImpl* GetSession(uint32 session_id); | 92 WebContentDecryptionModuleSessionImpl* GetSession(uint32 session_id); |
| 87 | 93 |
| 88 scoped_ptr<media::MediaKeys> media_keys_; | |
| 89 | |
| 90 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; | |
| 91 | |
| 92 SessionMap sessions_; | |
| 93 | |
| 94 // Session ID should be unique per renderer process for debugging purposes. | 94 // Session ID should be unique per renderer process for debugging purposes. |
| 95 static uint32 next_session_id_; | 95 static uint32 next_session_id_; |
| 96 | 96 |
| 97 scoped_ptr<media::MediaKeys> media_keys_; |
| 98 |
| 99 SessionMap sessions_; |
| 100 |
| 101 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; |
| 102 |
| 97 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); | 103 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); |
| 98 }; | 104 }; |
| 99 | 105 |
| 100 } // namespace content | 106 } // namespace content |
| 101 | 107 |
| 102 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ | 108 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ |
| OLD | NEW |