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

Side by Side Diff: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc

Issue 1023333002: Update External Clear Key to support CDM_8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" 5 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return media::MediaKeys::TEMPORARY_SESSION; 163 return media::MediaKeys::TEMPORARY_SESSION;
164 case cdm::kPersistentLicense: 164 case cdm::kPersistentLicense:
165 return media::MediaKeys::PERSISTENT_LICENSE_SESSION; 165 return media::MediaKeys::PERSISTENT_LICENSE_SESSION;
166 case cdm::kPersistentKeyRelease: 166 case cdm::kPersistentKeyRelease:
167 return media::MediaKeys::PERSISTENT_RELEASE_MESSAGE_SESSION; 167 return media::MediaKeys::PERSISTENT_RELEASE_MESSAGE_SESSION;
168 } 168 }
169 NOTIMPLEMENTED(); 169 NOTIMPLEMENTED();
170 return media::MediaKeys::TEMPORARY_SESSION; 170 return media::MediaKeys::TEMPORARY_SESSION;
171 } 171 }
172 172
173 // TODO(jrummell): |init_data_type| should be an enum all the way through
174 // Chromium. http://crbug.com/469228
175 static std::string ConvertInitDataType(cdm::InitDataType init_data_type) {
176 switch (init_data_type) {
177 case cdm::kCenc:
178 return "cenc";
179 case cdm::kKeyIds:
180 return "keyids";
181 case cdm::kWebM:
182 return "webm";
183 }
184 NOTIMPLEMENTED();
xhwang 2015/03/23 20:35:37 NOTREACHED()?
jrummell 2015/03/23 21:47:07 Done. I just copied what was used in the other con
185 return "keyids";
186 }
187
173 cdm::KeyStatus ConvertKeyStatus(media::CdmKeyInformation::KeyStatus status) { 188 cdm::KeyStatus ConvertKeyStatus(media::CdmKeyInformation::KeyStatus status) {
174 switch (status) { 189 switch (status) {
175 case media::CdmKeyInformation::KeyStatus::USABLE: 190 case media::CdmKeyInformation::KeyStatus::USABLE:
176 return cdm::kUsable; 191 return cdm::kUsable;
177 case media::CdmKeyInformation::KeyStatus::INTERNAL_ERROR: 192 case media::CdmKeyInformation::KeyStatus::INTERNAL_ERROR:
178 return cdm::kInternalError; 193 return cdm::kInternalError;
179 case media::CdmKeyInformation::KeyStatus::EXPIRED: 194 case media::CdmKeyInformation::KeyStatus::EXPIRED:
180 return cdm::kExpired; 195 return cdm::kExpired;
181 case media::CdmKeyInformation::KeyStatus::OUTPUT_NOT_ALLOWED: 196 case media::CdmKeyInformation::KeyStatus::OUTPUT_NOT_ALLOWED:
182 return cdm::kOutputNotAllowed; 197 return cdm::kOutputNotAllowed;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 channel_count_ = 0; 287 channel_count_ = 0;
273 bits_per_channel_ = 0; 288 bits_per_channel_ = 0;
274 samples_per_second_ = 0; 289 samples_per_second_ = 0;
275 output_timestamp_base_in_microseconds_ = kNoTimestamp; 290 output_timestamp_base_in_microseconds_ = kNoTimestamp;
276 total_samples_generated_ = 0; 291 total_samples_generated_ = 0;
277 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 292 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
278 } 293 }
279 294
280 ClearKeyCdm::~ClearKeyCdm() {} 295 ClearKeyCdm::~ClearKeyCdm() {}
281 296
282 void ClearKeyCdm::CreateSessionAndGenerateRequest(uint32 promise_id, 297 void ClearKeyCdm::Initialize(bool allow_distinctive_identifier,
283 cdm::SessionType session_type, 298 bool allow_persistent_state) {
xhwang 2015/03/23 20:35:37 Comment out /* unused_parameter */ ? https://goog
jrummell 2015/03/23 21:47:07 Done.
284 const char* init_data_type, 299 // Implementation doesn't use distinctive identifier nor save persistent data,
285 uint32 init_data_type_size, 300 // so nothing to do with these values.
286 const uint8* init_data, 301 }
287 uint32 init_data_size) { 302
303 void ClearKeyCdm::CreateSessionAndGenerateRequest(
304 uint32 promise_id,
305 cdm::SessionType session_type,
306 cdm::InitDataType init_data_type,
307 const uint8* init_data,
308 uint32 init_data_size) {
288 DVLOG(1) << __FUNCTION__; 309 DVLOG(1) << __FUNCTION__;
289 310
290 scoped_ptr<media::NewSessionCdmPromise> promise( 311 scoped_ptr<media::NewSessionCdmPromise> promise(
291 new media::CdmCallbackPromise<std::string>( 312 new media::CdmCallbackPromise<std::string>(
292 base::Bind(&ClearKeyCdm::OnSessionCreated, 313 base::Bind(&ClearKeyCdm::OnSessionCreated,
293 base::Unretained(this), 314 base::Unretained(this),
294 promise_id), 315 promise_id),
295 base::Bind(&ClearKeyCdm::OnPromiseFailed, 316 base::Bind(&ClearKeyCdm::OnPromiseFailed,
296 base::Unretained(this), 317 base::Unretained(this),
297 promise_id))); 318 promise_id)));
298 decryptor_.CreateSessionAndGenerateRequest( 319 decryptor_.CreateSessionAndGenerateRequest(
299 ConvertSessionType(session_type), 320 ConvertSessionType(session_type), ConvertInitDataType(init_data_type),
300 std::string(init_data_type, init_data_type_size), init_data, 321 init_data, init_data_size, promise.Pass());
301 init_data_size, promise.Pass());
302 322
303 if (key_system_ == kExternalClearKeyFileIOTestKeySystem) 323 if (key_system_ == kExternalClearKeyFileIOTestKeySystem)
304 StartFileIOTest(); 324 StartFileIOTest();
305 } 325 }
306 326
307 // Loads a emulated stored session. Currently only |kLoadableSessionId| 327 // Loads a emulated stored session. Currently only |kLoadableSessionId|
308 // (containing a |kLoadableSessionKey| for |kLoadableSessionKeyId|) is 328 // (containing a |kLoadableSessionKey| for |kLoadableSessionKeyId|) is
309 // supported. 329 // supported.
310 void ClearKeyCdm::LoadSession(uint32 promise_id, 330 void ClearKeyCdm::LoadSession(uint32 promise_id,
311 cdm::SessionType session_type, 331 cdm::SessionType session_type,
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 void ClearKeyCdm::OnFileIOTestComplete(bool success) { 920 void ClearKeyCdm::OnFileIOTestComplete(bool success) {
901 DVLOG(1) << __FUNCTION__ << ": " << success; 921 DVLOG(1) << __FUNCTION__ << ": " << success;
902 std::string message = GetFileIOTestResultMessage(success); 922 std::string message = GetFileIOTestResultMessage(success);
903 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(), 923 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(),
904 cdm::kLicenseRequest, message.data(), 924 cdm::kLicenseRequest, message.data(),
905 message.length(), NULL, 0); 925 message.length(), NULL, 0);
906 file_io_test_runner_.reset(); 926 file_io_test_runner_.reset();
907 } 927 }
908 928
909 } // namespace media 929 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698