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

Side by Side Diff: content/renderer/media/crypto/proxy_decryptor.cc

Issue 448893002: Update ClearKey to support CDM_6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cdm6
Patch Set: Changes2 Created 6 years, 4 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 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 #include "content/renderer/media/crypto/proxy_decryptor.h" 5 #include "content/renderer/media/crypto/proxy_decryptor.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 std::equal(data, data + header.size(), header.begin()); 95 std::equal(data, data + header.size(), header.begin());
96 } 96 }
97 97
98 bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type, 98 bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type,
99 const uint8* init_data, 99 const uint8* init_data,
100 int init_data_length) { 100 int init_data_length) {
101 DVLOG(1) << "GenerateKeyRequest()"; 101 DVLOG(1) << "GenerateKeyRequest()";
102 const char kPrefixedApiPersistentSessionHeader[] = "PERSISTENT|"; 102 const char kPrefixedApiPersistentSessionHeader[] = "PERSISTENT|";
103 const char kPrefixedApiLoadSessionHeader[] = "LOAD_SESSION|"; 103 const char kPrefixedApiLoadSessionHeader[] = "LOAD_SESSION|";
104 104
105 bool loadSession = 105 SessionCreationType session_creation_type = TemporarySession;
106 HasHeader(init_data, init_data_length, kPrefixedApiLoadSessionHeader); 106 if (HasHeader(init_data, init_data_length, kPrefixedApiLoadSessionHeader)) {
107 bool persistent = HasHeader( 107 session_creation_type = LoadSession;
108 init_data, init_data_length, kPrefixedApiPersistentSessionHeader); 108 } else if (HasHeader(init_data,
109 init_data_length,
110 kPrefixedApiPersistentSessionHeader)) {
111 session_creation_type = PersistentSession;
112 }
109 113
110 scoped_ptr<media::NewSessionCdmPromise> promise( 114 scoped_ptr<media::NewSessionCdmPromise> promise(
111 new media::NewSessionCdmPromise( 115 new media::NewSessionCdmPromise(
112 base::Bind(&ProxyDecryptor::SetSessionId, 116 base::Bind(&ProxyDecryptor::SetSessionId,
113 weak_ptr_factory_.GetWeakPtr(), 117 weak_ptr_factory_.GetWeakPtr(),
114 persistent || loadSession), 118 session_creation_type),
115 base::Bind(&ProxyDecryptor::OnSessionError, 119 base::Bind(&ProxyDecryptor::OnSessionError,
116 weak_ptr_factory_.GetWeakPtr(), 120 weak_ptr_factory_.GetWeakPtr(),
117 std::string()))); // No session id until created. 121 std::string()))); // No session id until created.
118 122
119 if (loadSession) { 123 if (session_creation_type == LoadSession) {
120 media_keys_->LoadSession( 124 media_keys_->LoadSession(
121 std::string(reinterpret_cast<const char*>( 125 std::string(reinterpret_cast<const char*>(
122 init_data + strlen(kPrefixedApiLoadSessionHeader)), 126 init_data + strlen(kPrefixedApiLoadSessionHeader)),
123 init_data_length - strlen(kPrefixedApiLoadSessionHeader)), 127 init_data_length - strlen(kPrefixedApiLoadSessionHeader)),
124 promise.Pass()); 128 promise.Pass());
125 return true; 129 return true;
126 } 130 }
127 131
128 media::MediaKeys::SessionType session_type = 132 media::MediaKeys::SessionType session_type =
129 persistent ? media::MediaKeys::PERSISTENT_SESSION 133 session_creation_type == PersistentSession
130 : media::MediaKeys::TEMPORARY_SESSION; 134 ? media::MediaKeys::PERSISTENT_SESSION
135 : media::MediaKeys::TEMPORARY_SESSION;
131 media_keys_->CreateSession( 136 media_keys_->CreateSession(
132 content_type, init_data, init_data_length, session_type, promise.Pass()); 137 content_type, init_data, init_data_length, session_type, promise.Pass());
133 return true; 138 return true;
134 } 139 }
135 140
136 void ProxyDecryptor::AddKey(const uint8* key, 141 void ProxyDecryptor::AddKey(const uint8* key,
137 int key_length, 142 int key_length,
138 const uint8* init_data, 143 const uint8* init_data,
139 int init_data_length, 144 int init_data_length,
140 const std::string& web_session_id) { 145 const std::string& web_session_id) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 break; 284 break;
280 default: 285 default:
281 // This will include all other CDM4 errors and any error generated 286 // This will include all other CDM4 errors and any error generated
282 // by CDM5 or later. 287 // by CDM5 or later.
283 error_code = media::MediaKeys::kUnknownError; 288 error_code = media::MediaKeys::kUnknownError;
284 break; 289 break;
285 } 290 }
286 key_error_cb_.Run(web_session_id, error_code, system_code); 291 key_error_cb_.Run(web_session_id, error_code, system_code);
287 } 292 }
288 293
289 void ProxyDecryptor::SetSessionId(bool persistent, 294 void ProxyDecryptor::SetSessionId(SessionCreationType session_type,
290 const std::string& web_session_id) { 295 const std::string& web_session_id) {
291 active_sessions_.insert(std::make_pair(web_session_id, persistent)); 296 // Loaded sessions are considered persistent.
297 bool is_persistent =
298 session_type == PersistentSession || session_type == LoadSession;
299 active_sessions_.insert(std::make_pair(web_session_id, is_persistent));
300
301 // For LoadSession(), generate the SessionReady event.
302 if (session_type == LoadSession)
303 OnSessionReady(web_session_id);
292 } 304 }
293 305
294 } // namespace content 306 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698