Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: content/renderer/media/cdm_session_adapter.h

Issue 193523002: Encrypted Media: Implement IPC based SetCdm(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Manage cdm_id_ in CdmSessionAdapter Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 #endif // defined(ENABLE_PEPPER_CDMS)
ddorwin 2014/03/25 23:04:00 nit: Comment not necessary for a simple ifdef.
xhwang 2014/03/26 06:02:04 Done.
37 const std::string& key_system); 37 const std::string& key_system);
38 38
39 // Creates a new session and adds it to the internal map. The caller owns the 39 // 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. 40 // created session. RemoveSession() must be called when destroying it.
41 WebContentDecryptionModuleSessionImpl* CreateSession( 41 WebContentDecryptionModuleSessionImpl* CreateSession(
42 blink::WebContentDecryptionModuleSession::Client* client); 42 blink::WebContentDecryptionModuleSession::Client* client);
43 43
44 // Removes a session from the internal map. 44 // Removes a session from the internal map.
45 void RemoveSession(uint32 session_id); 45 void RemoveSession(uint32 session_id);
46 46
(...skipping 11 matching lines...) Expand all
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.
96 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; 105 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_;
97 106
98 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); 107 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter);
99 }; 108 };
100 109
101 } // namespace content 110 } // namespace content
102 111
103 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ 112 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698