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

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: Changes 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return cdm::kInvalidAccessError; 145 return cdm::kInvalidAccessError;
146 case media::MediaKeys::QUOTA_EXCEEDED_ERROR: 146 case media::MediaKeys::QUOTA_EXCEEDED_ERROR:
147 return cdm::kQuotaExceededError; 147 return cdm::kQuotaExceededError;
148 case media::MediaKeys::UNKNOWN_ERROR: 148 case media::MediaKeys::UNKNOWN_ERROR:
149 return cdm::kUnknownError; 149 return cdm::kUnknownError;
150 case media::MediaKeys::CLIENT_ERROR: 150 case media::MediaKeys::CLIENT_ERROR:
151 return cdm::kClientError; 151 return cdm::kClientError;
152 case media::MediaKeys::OUTPUT_ERROR: 152 case media::MediaKeys::OUTPUT_ERROR:
153 return cdm::kOutputError; 153 return cdm::kOutputError;
154 } 154 }
155 NOTIMPLEMENTED(); 155 NOTREACHED();
156 return cdm::kUnknownError; 156 return cdm::kUnknownError;
157 } 157 }
158 158
159 static media::MediaKeys::SessionType ConvertSessionType( 159 static media::MediaKeys::SessionType ConvertSessionType(
160 cdm::SessionType session_type) { 160 cdm::SessionType session_type) {
161 switch (session_type) { 161 switch (session_type) {
162 case cdm::kTemporary: 162 case cdm::kTemporary:
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 NOTREACHED();
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 NOTREACHED();
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;
183 case media::CdmKeyInformation::KeyStatus::OUTPUT_DOWNSCALED: 198 case media::CdmKeyInformation::KeyStatus::OUTPUT_DOWNSCALED:
184 return cdm::kOutputDownscaled; 199 return cdm::kOutputDownscaled;
185 case media::CdmKeyInformation::KeyStatus::KEY_STATUS_PENDING: 200 case media::CdmKeyInformation::KeyStatus::KEY_STATUS_PENDING:
186 return cdm::kStatusPending; 201 return cdm::kStatusPending;
187 } 202 }
188 NOTIMPLEMENTED(); 203 NOTREACHED();
189 return cdm::kInternalError; 204 return cdm::kInternalError;
190 } 205 }
191 206
192 // Shallow copy all the key information from |keys_info| into |keys_vector|. 207 // Shallow copy all the key information from |keys_info| into |keys_vector|.
193 // |keys_vector| is only valid for the lifetime of |keys_info| because it 208 // |keys_vector| is only valid for the lifetime of |keys_info| because it
194 // contains pointers into the latter. 209 // contains pointers into the latter.
195 void ConvertCdmKeysInfo(const std::vector<media::CdmKeyInformation*>& keys_info, 210 void ConvertCdmKeysInfo(const std::vector<media::CdmKeyInformation*>& keys_info,
196 std::vector<cdm::KeyInformation>* keys_vector) { 211 std::vector<cdm::KeyInformation>* keys_vector) {
197 keys_vector->reserve(keys_info.size()); 212 keys_vector->reserve(keys_info.size());
198 for (const auto& key_info : keys_info) { 213 for (const auto& key_info : keys_info) {
(...skipping 73 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 */) {
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
« no previous file with comments | « media/cdm/ppapi/external_clear_key/clear_key_cdm.h ('k') | media/cdm/ppapi/external_clear_key/clear_key_cdm_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698