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

Side by Side Diff: media/cdm/cdm_adapter.cc

Issue 2444683002: Move MediaKeys::Exception to CdmPromise::Exception (Closed)
Patch Set: fix for media_remoting_unittests Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/cdm_adapter.h" 5 #include "media/cdm/cdm_adapter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 case EmeInitDataType::WEBM: 58 case EmeInitDataType::WEBM:
59 return cdm::kWebM; 59 return cdm::kWebM;
60 case EmeInitDataType::UNKNOWN: 60 case EmeInitDataType::UNKNOWN:
61 break; 61 break;
62 } 62 }
63 63
64 NOTREACHED(); 64 NOTREACHED();
65 return cdm::kKeyIds; 65 return cdm::kKeyIds;
66 } 66 }
67 67
68 MediaKeys::Exception ToMediaExceptionType(cdm::Error error) { 68 CdmPromise::Exception ToMediaExceptionType(cdm::Error error) {
69 switch (error) { 69 switch (error) {
70 case cdm::kNotSupportedError: 70 case cdm::kNotSupportedError:
71 return MediaKeys::NOT_SUPPORTED_ERROR; 71 return CdmPromise::NOT_SUPPORTED_ERROR;
72 case cdm::kInvalidStateError: 72 case cdm::kInvalidStateError:
73 return MediaKeys::INVALID_STATE_ERROR; 73 return CdmPromise::INVALID_STATE_ERROR;
74 case cdm::kInvalidAccessError: 74 case cdm::kInvalidAccessError:
75 return MediaKeys::INVALID_ACCESS_ERROR; 75 return CdmPromise::INVALID_ACCESS_ERROR;
76 case cdm::kQuotaExceededError: 76 case cdm::kQuotaExceededError:
77 return MediaKeys::QUOTA_EXCEEDED_ERROR; 77 return CdmPromise::QUOTA_EXCEEDED_ERROR;
78 case cdm::kUnknownError: 78 case cdm::kUnknownError:
79 return MediaKeys::UNKNOWN_ERROR; 79 return CdmPromise::UNKNOWN_ERROR;
80 case cdm::kClientError: 80 case cdm::kClientError:
81 return MediaKeys::CLIENT_ERROR; 81 return CdmPromise::CLIENT_ERROR;
82 case cdm::kOutputError: 82 case cdm::kOutputError:
83 return MediaKeys::OUTPUT_ERROR; 83 return CdmPromise::OUTPUT_ERROR;
84 } 84 }
85 85
86 NOTREACHED() << "Unexpected cdm::Error " << error; 86 NOTREACHED() << "Unexpected cdm::Error " << error;
87 return MediaKeys::UNKNOWN_ERROR; 87 return CdmPromise::UNKNOWN_ERROR;
88 } 88 }
89 89
90 MediaKeys::MessageType ToMediaMessageType(cdm::MessageType message_type) { 90 MediaKeys::MessageType ToMediaMessageType(cdm::MessageType message_type) {
91 switch (message_type) { 91 switch (message_type) {
92 case cdm::kLicenseRequest: 92 case cdm::kLicenseRequest:
93 return MediaKeys::LICENSE_REQUEST; 93 return MediaKeys::LICENSE_REQUEST;
94 case cdm::kLicenseRenewal: 94 case cdm::kLicenseRenewal:
95 return MediaKeys::LICENSE_RENEWAL; 95 return MediaKeys::LICENSE_RENEWAL;
96 case cdm::kLicenseRelease: 96 case cdm::kLicenseRelease:
97 return MediaKeys::LICENSE_RELEASE; 97 return MediaKeys::LICENSE_RELEASE;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 413
414 DVLOG(1) << "CDM instance for " + key_system + (cdm ? "" : " could not be") + 414 DVLOG(1) << "CDM instance for " + key_system + (cdm ? "" : " could not be") +
415 " created."; 415 " created.";
416 return cdm; 416 return cdm;
417 } 417 }
418 418
419 void CdmAdapter::Initialize(const base::FilePath& cdm_path, 419 void CdmAdapter::Initialize(const base::FilePath& cdm_path,
420 std::unique_ptr<media::SimpleCdmPromise> promise) { 420 std::unique_ptr<media::SimpleCdmPromise> promise) {
421 cdm_.reset(CreateCdmInstance(key_system_, cdm_path)); 421 cdm_.reset(CreateCdmInstance(key_system_, cdm_path));
422 if (!cdm_) { 422 if (!cdm_) {
423 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, 423 promise->reject(CdmPromise::INVALID_ACCESS_ERROR, 0,
424 "Unable to create CDM."); 424 "Unable to create CDM.");
425 return; 425 return;
426 } 426 }
427 427
428 cdm_->Initialize(cdm_config_.allow_distinctive_identifier, 428 cdm_->Initialize(cdm_config_.allow_distinctive_identifier,
429 cdm_config_.allow_persistent_state); 429 cdm_config_.allow_persistent_state);
430 promise->resolve(); 430 promise->resolve();
431 } 431 }
432 432
433 void CdmAdapter::SetServerCertificate( 433 void CdmAdapter::SetServerCertificate(
434 const std::vector<uint8_t>& certificate, 434 const std::vector<uint8_t>& certificate,
435 std::unique_ptr<SimpleCdmPromise> promise) { 435 std::unique_ptr<SimpleCdmPromise> promise) {
436 DCHECK(task_runner_->BelongsToCurrentThread()); 436 DCHECK(task_runner_->BelongsToCurrentThread());
437 437
438 if (certificate.size() < limits::kMinCertificateLength || 438 if (certificate.size() < limits::kMinCertificateLength ||
439 certificate.size() > limits::kMaxCertificateLength) { 439 certificate.size() > limits::kMaxCertificateLength) {
440 promise->reject(MediaKeys::INVALID_ACCESS_ERROR, 0, 440 promise->reject(CdmPromise::INVALID_ACCESS_ERROR, 0,
441 "Incorrect certificate."); 441 "Incorrect certificate.");
442 return; 442 return;
443 } 443 }
444 444
445 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); 445 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise));
446 cdm_->SetServerCertificate(promise_id, certificate.data(), 446 cdm_->SetServerCertificate(promise_id, certificate.data(),
447 certificate.size()); 447 certificate.size());
448 } 448 }
449 449
450 void CdmAdapter::CreateSessionAndGenerateRequest( 450 void CdmAdapter::CreateSessionAndGenerateRequest(
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 result_frames->push_back(frame); 939 result_frames->push_back(frame);
940 940
941 data += frame_size; 941 data += frame_size;
942 bytes_left -= frame_size; 942 bytes_left -= frame_size;
943 } while (bytes_left > 0); 943 } while (bytes_left > 0);
944 944
945 return true; 945 return true;
946 } 946 }
947 947
948 } // namespace media 948 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698