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

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

Issue 555223004: Update MediaKeys interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename Created 6 years, 3 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
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 #include <string> 9 #include <string>
10 10
(...skipping 29 matching lines...) Expand all
40 // Returns true on success. 40 // Returns true on success.
41 bool Initialize( 41 bool Initialize(
42 #if defined(ENABLE_PEPPER_CDMS) 42 #if defined(ENABLE_PEPPER_CDMS)
43 const CreatePepperCdmCB& create_pepper_cdm_cb, 43 const CreatePepperCdmCB& create_pepper_cdm_cb,
44 #elif defined(ENABLE_BROWSER_CDMS) 44 #elif defined(ENABLE_BROWSER_CDMS)
45 RendererCdmManager* manager, 45 RendererCdmManager* manager,
46 #endif 46 #endif
47 const std::string& key_system, 47 const std::string& key_system,
48 const GURL& security_origin); 48 const GURL& security_origin);
49 49
50 // Provide a server certificate to be used to encrypt messages to the
xhwang 2014/09/25 05:11:47 Provide_s_
jrummell 2014/09/25 20:33:25 Done.
51 // license server. Takes ownership of |promise|.
xhwang 2014/09/25 05:11:47 nit: "Takes ownership of |promise|." is redundant
jrummell 2014/09/25 20:33:25 Done.
52 void SetServerCertificate(const uint8* server_certificate,
53 int server_certificate_length,
54 scoped_ptr<media::SimpleCdmPromise> promise);
55
50 // Creates a new session and adds it to the internal map. The caller owns the 56 // Creates a new session and adds it to the internal map. The caller owns the
51 // created session. RemoveSession() must be called when destroying it, if 57 // created session. RemoveSession() must be called when destroying it, if
52 // RegisterSession() was called. 58 // RegisterSession() was called.
53 WebContentDecryptionModuleSessionImpl* CreateSession(); 59 WebContentDecryptionModuleSessionImpl* CreateSession();
54 60
55 // Adds a session to the internal map. Called once the session is successfully 61 // Adds a session to the internal map. Called once the session is successfully
56 // initialized. Returns true if the session was registered, false if there is 62 // initialized. Returns true if the session was registered, false if there is
57 // already an existing session with the same |web_session_id|. 63 // already an existing session with the same |web_session_id|.
58 bool RegisterSession( 64 bool RegisterSession(
59 const std::string& web_session_id, 65 const std::string& web_session_id,
60 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session); 66 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session);
61 67
62 // Removes a session from the internal map. 68 // Removes a session from the internal map.
63 void RemoveSession(const std::string& web_session_id); 69 void UnregisterSession(const std::string& web_session_id);
64 70
65 // Initializes a session with the |init_data_type|, |init_data| and 71 // Initializes a session with the |init_data_type|, |init_data| and
66 // |session_type| provided. Takes ownership of |promise|. 72 // |session_type| provided. Takes ownership of |promise|.
67 void InitializeNewSession(const std::string& init_data_type, 73 void InitializeNewSession(const std::string& init_data_type,
68 const uint8* init_data, 74 const uint8* init_data,
69 int init_data_length, 75 int init_data_length,
70 media::MediaKeys::SessionType session_type, 76 media::MediaKeys::SessionType session_type,
71 scoped_ptr<media::NewSessionCdmPromise> promise); 77 scoped_ptr<media::NewSessionCdmPromise> promise);
72 78
73 // Updates the session specified by |web_session_id| with |response|. 79 // Updates the session specified by |web_session_id| with |response|.
74 // Takes ownership of |promise|. 80 // Takes ownership of |promise|.
xhwang 2014/09/25 05:11:47 ditto
jrummell 2014/09/25 20:33:25 Done.
75 void UpdateSession(const std::string& web_session_id, 81 void UpdateSession(const std::string& web_session_id,
76 const uint8* response, 82 const uint8* response,
77 int response_length, 83 int response_length,
78 scoped_ptr<media::SimpleCdmPromise> promise); 84 scoped_ptr<media::SimpleCdmPromise> promise);
79 85
80 // Releases the session specified by |web_session_id|. 86 // Closes the session specified by |web_session_id|.
81 // Takes ownership of |promise|. 87 // Takes ownership of |promise|.
xhwang 2014/09/25 05:11:47 ditto
jrummell 2014/09/25 20:33:25 Done.
82 void ReleaseSession(const std::string& web_session_id, 88 void CloseSession(const std::string& web_session_id,
83 scoped_ptr<media::SimpleCdmPromise> promise); 89 scoped_ptr<media::SimpleCdmPromise> promise);
90
91 // Remove stored session data associated with the session specified by
xhwang 2014/09/25 05:11:47 Remove_s_
jrummell 2014/09/25 20:33:25 Done.
92 // |web_session_id|. Takes ownership of |promise|.
xhwang 2014/09/25 05:11:47 ditto
jrummell 2014/09/25 20:33:25 Done.
93 void RemoveSession(const std::string& web_session_id,
94 scoped_ptr<media::SimpleCdmPromise> promise);
95
96 // Retrieve the key IDs for keys in the session that the CDM knows are
xhwang 2014/09/25 05:11:47 Retrieve_s_
jrummell 2014/09/25 20:33:25 Done.
97 // currently usable to decrypt media data.
98 void GetUsableKeyIds(const std::string& web_session_id,
99 scoped_ptr<media::KeyIdsPromise> promise);
84 100
85 // Returns the Decryptor associated with this CDM. May be NULL if no 101 // Returns the Decryptor associated with this CDM. May be NULL if no
86 // Decryptor is associated with the MediaKeys object. 102 // Decryptor is associated with the MediaKeys object.
87 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor 103 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
88 // after WebContentDecryptionModule is freed. http://crbug.com/330324 104 // after WebContentDecryptionModule is freed. http://crbug.com/330324
89 media::Decryptor* GetDecryptor(); 105 media::Decryptor* GetDecryptor();
90 106
91 // Returns a prefix to use for UMAs. 107 // Returns a prefix to use for UMAs.
92 const std::string& GetKeySystemUMAPrefix() const; 108 const std::string& GetKeySystemUMAPrefix() const;
93 109
94 #if defined(ENABLE_BROWSER_CDMS) 110 #if defined(ENABLE_BROWSER_CDMS)
95 // Returns the CDM ID associated with the |media_keys_|. May be kInvalidCdmId 111 // Returns the CDM ID associated with the |media_keys_|. May be kInvalidCdmId
96 // if no CDM ID is associated. 112 // if no CDM ID is associated.
97 int GetCdmId() const; 113 int GetCdmId() const;
98 #endif 114 #endif
99 115
100 private: 116 private:
101 friend class base::RefCounted<CdmSessionAdapter>; 117 friend class base::RefCounted<CdmSessionAdapter>;
102 typedef base::hash_map<std::string, 118 typedef base::hash_map<std::string,
103 base::WeakPtr<WebContentDecryptionModuleSessionImpl> > 119 base::WeakPtr<WebContentDecryptionModuleSessionImpl> >
104 SessionMap; 120 SessionMap;
105 121
106 ~CdmSessionAdapter(); 122 ~CdmSessionAdapter();
107 123
108 // Callbacks for firing session events. 124 // Callbacks for firing session events.
109 void OnSessionMessage(const std::string& web_session_id, 125 void OnSessionMessage(const std::string& web_session_id,
110 const std::vector<uint8>& message, 126 const std::vector<uint8>& message,
111 const GURL& destination_url); 127 const GURL& destination_url);
128 void OnSessionKeysChange(const std::string& web_session_id,
129 bool has_additional_usable_key);
130 void OnSessionExpirationChange(const std::string& web_session_id,
131 double new_expiry_time);
xhwang 2014/09/25 05:11:47 expiration is an attribute... and expirationchange
xhwang 2014/09/25 05:11:47 What is the unit of this time? I saw at one point
jrummell 2014/09/25 20:33:25 Good idea. Done.
jrummell 2014/09/25 20:33:25 Changed to OnSessionExpirationUpdate.
112 void OnSessionReady(const std::string& web_session_id); 132 void OnSessionReady(const std::string& web_session_id);
113 void OnSessionClosed(const std::string& web_session_id); 133 void OnSessionClosed(const std::string& web_session_id);
114 void OnSessionError(const std::string& web_session_id, 134 void OnSessionError(const std::string& web_session_id,
115 media::MediaKeys::Exception exception_code, 135 media::MediaKeys::Exception exception_code,
116 uint32 system_code, 136 uint32 system_code,
117 const std::string& error_message); 137 const std::string& error_message);
118 138
119 // Helper function of the callbacks. 139 // Helper function of the callbacks.
120 WebContentDecryptionModuleSessionImpl* GetSession( 140 WebContentDecryptionModuleSessionImpl* GetSession(
121 const std::string& web_session_id); 141 const std::string& web_session_id);
(...skipping 10 matching lines...) Expand all
132 152
133 // NOTE: Weak pointers must be invalidated before all other member variables. 153 // NOTE: Weak pointers must be invalidated before all other member variables.
134 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_; 154 base::WeakPtrFactory<CdmSessionAdapter> weak_ptr_factory_;
135 155
136 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter); 156 DISALLOW_COPY_AND_ASSIGN(CdmSessionAdapter);
137 }; 157 };
138 158
139 } // namespace content 159 } // namespace content
140 160
141 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_ 161 #endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698