| OLD | NEW |
| 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/cdm/ppapi_decryptor.h" | 5 #include "content/renderer/media/cdm/ppapi_decryptor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 std::move(promise)); | 107 std::move(promise)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void PpapiDecryptor::SetServerCertificate( | 110 void PpapiDecryptor::SetServerCertificate( |
| 111 const std::vector<uint8_t>& certificate, | 111 const std::vector<uint8_t>& certificate, |
| 112 std::unique_ptr<media::SimpleCdmPromise> promise) { | 112 std::unique_ptr<media::SimpleCdmPromise> promise) { |
| 113 DVLOG(2) << __func__; | 113 DVLOG(2) << __func__; |
| 114 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 114 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 115 | 115 |
| 116 if (!CdmDelegate()) { | 116 if (!CdmDelegate()) { |
| 117 promise->reject(INVALID_STATE_ERROR, 0, "CDM has failed."); | 117 promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
| 118 "CDM has failed."); |
| 118 return; | 119 return; |
| 119 } | 120 } |
| 120 | 121 |
| 121 CdmDelegate()->SetServerCertificate(certificate, std::move(promise)); | 122 CdmDelegate()->SetServerCertificate(certificate, std::move(promise)); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void PpapiDecryptor::CreateSessionAndGenerateRequest( | 125 void PpapiDecryptor::CreateSessionAndGenerateRequest( |
| 125 SessionType session_type, | 126 SessionType session_type, |
| 126 media::EmeInitDataType init_data_type, | 127 media::EmeInitDataType init_data_type, |
| 127 const std::vector<uint8_t>& init_data, | 128 const std::vector<uint8_t>& init_data, |
| 128 std::unique_ptr<media::NewSessionCdmPromise> promise) { | 129 std::unique_ptr<media::NewSessionCdmPromise> promise) { |
| 129 DVLOG(2) << __func__; | 130 DVLOG(2) << __func__; |
| 130 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 131 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 131 | 132 |
| 132 if (!CdmDelegate()) { | 133 if (!CdmDelegate()) { |
| 133 promise->reject(INVALID_STATE_ERROR, 0, "CDM has failed."); | 134 promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
| 135 "CDM has failed."); |
| 134 return; | 136 return; |
| 135 } | 137 } |
| 136 | 138 |
| 137 CdmDelegate()->CreateSessionAndGenerateRequest(session_type, init_data_type, | 139 CdmDelegate()->CreateSessionAndGenerateRequest(session_type, init_data_type, |
| 138 init_data, std::move(promise)); | 140 init_data, std::move(promise)); |
| 139 } | 141 } |
| 140 | 142 |
| 141 void PpapiDecryptor::LoadSession( | 143 void PpapiDecryptor::LoadSession( |
| 142 SessionType session_type, | 144 SessionType session_type, |
| 143 const std::string& session_id, | 145 const std::string& session_id, |
| 144 std::unique_ptr<media::NewSessionCdmPromise> promise) { | 146 std::unique_ptr<media::NewSessionCdmPromise> promise) { |
| 145 DVLOG(2) << __func__; | 147 DVLOG(2) << __func__; |
| 146 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 148 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 147 | 149 |
| 148 if (!CdmDelegate()) { | 150 if (!CdmDelegate()) { |
| 149 promise->reject(INVALID_STATE_ERROR, 0, "CDM has failed."); | 151 promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
| 152 "CDM has failed."); |
| 150 return; | 153 return; |
| 151 } | 154 } |
| 152 CdmDelegate()->LoadSession(session_type, session_id, std::move(promise)); | 155 CdmDelegate()->LoadSession(session_type, session_id, std::move(promise)); |
| 153 } | 156 } |
| 154 | 157 |
| 155 void PpapiDecryptor::UpdateSession( | 158 void PpapiDecryptor::UpdateSession( |
| 156 const std::string& session_id, | 159 const std::string& session_id, |
| 157 const std::vector<uint8_t>& response, | 160 const std::vector<uint8_t>& response, |
| 158 std::unique_ptr<media::SimpleCdmPromise> promise) { | 161 std::unique_ptr<media::SimpleCdmPromise> promise) { |
| 159 DVLOG(2) << __func__; | 162 DVLOG(2) << __func__; |
| 160 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 163 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 161 | 164 |
| 162 if (!CdmDelegate()) { | 165 if (!CdmDelegate()) { |
| 163 promise->reject(INVALID_STATE_ERROR, 0, "CDM has failed."); | 166 promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
| 167 "CDM has failed."); |
| 164 return; | 168 return; |
| 165 } | 169 } |
| 166 CdmDelegate()->UpdateSession(session_id, response, std::move(promise)); | 170 CdmDelegate()->UpdateSession(session_id, response, std::move(promise)); |
| 167 } | 171 } |
| 168 | 172 |
| 169 void PpapiDecryptor::CloseSession( | 173 void PpapiDecryptor::CloseSession( |
| 170 const std::string& session_id, | 174 const std::string& session_id, |
| 171 std::unique_ptr<media::SimpleCdmPromise> promise) { | 175 std::unique_ptr<media::SimpleCdmPromise> promise) { |
| 172 DVLOG(2) << __func__; | 176 DVLOG(2) << __func__; |
| 173 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 177 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 174 | 178 |
| 175 if (!CdmDelegate()) { | 179 if (!CdmDelegate()) { |
| 176 promise->reject(INVALID_STATE_ERROR, 0, "CDM has failed."); | 180 promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
| 181 "CDM has failed."); |
| 177 return; | 182 return; |
| 178 } | 183 } |
| 179 | 184 |
| 180 CdmDelegate()->CloseSession(session_id, std::move(promise)); | 185 CdmDelegate()->CloseSession(session_id, std::move(promise)); |
| 181 } | 186 } |
| 182 | 187 |
| 183 void PpapiDecryptor::RemoveSession( | 188 void PpapiDecryptor::RemoveSession( |
| 184 const std::string& session_id, | 189 const std::string& session_id, |
| 185 std::unique_ptr<media::SimpleCdmPromise> promise) { | 190 std::unique_ptr<media::SimpleCdmPromise> promise) { |
| 186 DVLOG(2) << __func__; | 191 DVLOG(2) << __func__; |
| 187 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 192 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 188 | 193 |
| 189 if (!CdmDelegate()) { | 194 if (!CdmDelegate()) { |
| 190 promise->reject(INVALID_STATE_ERROR, 0, "CDM has failed."); | 195 promise->reject(media::CdmPromise::INVALID_STATE_ERROR, 0, |
| 196 "CDM has failed."); |
| 191 return; | 197 return; |
| 192 } | 198 } |
| 193 | 199 |
| 194 CdmDelegate()->RemoveSession(session_id, std::move(promise)); | 200 CdmDelegate()->RemoveSession(session_id, std::move(promise)); |
| 195 } | 201 } |
| 196 | 202 |
| 197 media::CdmContext* PpapiDecryptor::GetCdmContext() { | 203 media::CdmContext* PpapiDecryptor::GetCdmContext() { |
| 198 return this; | 204 return this; |
| 199 } | 205 } |
| 200 | 206 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 440 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 435 pepper_cdm_wrapper_.reset(); | 441 pepper_cdm_wrapper_.reset(); |
| 436 } | 442 } |
| 437 | 443 |
| 438 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { | 444 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { |
| 439 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 445 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 440 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; | 446 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; |
| 441 } | 447 } |
| 442 | 448 |
| 443 } // namespace content | 449 } // namespace content |
| OLD | NEW |