| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // Releases the session specified by |session_id|. | 59 // Releases the session specified by |session_id|. |
| 60 void ReleaseSession(uint32 session_id); | 60 void ReleaseSession(uint32 session_id); |
| 61 | 61 |
| 62 // Returns the Decryptor associated with this CDM. May be NULL if no | 62 // Returns the Decryptor associated with this CDM. May be NULL if no |
| 63 // Decryptor is associated with the MediaKeys object. | 63 // Decryptor is associated with the MediaKeys object. |
| 64 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor | 64 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor |
| 65 // after WebContentDecryptionModule is freed. http://crbug.com/330324 | 65 // after WebContentDecryptionModule is freed. http://crbug.com/330324 |
| 66 media::Decryptor* GetDecryptor(); | 66 media::Decryptor* GetDecryptor(); |
| 67 | 67 |
| 68 #if defined(OS_ANDROID) |
| 69 // Returns the CDM ID associated with the |media_keys_|. May be kInvalidCdmId |
| 70 // if no CDM ID is associated. |
| 71 int GetCdmId() const; |
| 72 #endif |
| 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 |
| 94 // Session ID should be unique per renderer process for debugging purposes. |
| 95 static uint32 next_session_id_; |
| 96 |
| 88 scoped_ptr<media::MediaKeys> media_keys_; | 97 scoped_ptr<media::MediaKeys> media_keys_; |
| 89 | 98 |
| 90 SessionMap sessions_; | 99 SessionMap sessions_; |
| 91 | 100 |
| 92 // Session ID should be unique per renderer process for debugging purposes. | 101 #if defined(OS_ANDROID) |
| 93 static uint32 next_session_id_; | 102 int cdm_id_; |
| 103 #endif |
| 94 | 104 |
| 95 // NOTE: Weak pointers must be invalidated before all other member variables. | 105 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 96 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; | 106 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; |
| 97 | 107 |
| 98 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); | 108 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); |
| 99 }; | 109 }; |
| 100 | 110 |
| 101 } // namespace content | 111 } // namespace content |
| 102 | 112 |
| 103 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ | 113 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ |
| OLD | NEW |