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

Side by Side Diff: media/mojo/clients/mojo_cdm.cc

Issue 2425663003: media: Use native CDM enum types in media mojo interfaces (Closed)
Patch Set: comments addressed 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
« no previous file with comments | « media/mojo/clients/mojo_cdm.h ('k') | media/mojo/clients/mojo_decryptor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/mojo/clients/mojo_cdm.h" 5 #include "media/mojo/clients/mojo_cdm.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "media/mojo/interfaces/decryptor.mojom.h" 21 #include "media/mojo/interfaces/decryptor.mojom.h"
22 #include "services/service_manager/public/cpp/connect.h" 22 #include "services/service_manager/public/cpp/connect.h"
23 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" 23 #include "services/service_manager/public/interfaces/interface_provider.mojom.h"
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 namespace media { 26 namespace media {
27 27
28 template <typename PromiseType> 28 template <typename PromiseType>
29 static void RejectPromise(std::unique_ptr<PromiseType> promise, 29 static void RejectPromise(std::unique_ptr<PromiseType> promise,
30 mojom::CdmPromiseResultPtr result) { 30 mojom::CdmPromiseResultPtr result) {
31 promise->reject(static_cast<MediaKeys::Exception>(result->exception), 31 promise->reject(result->exception, result->system_code,
32 result->system_code, result->error_message); 32 result->error_message);
33 } 33 }
34 34
35 // static 35 // static
36 void MojoCdm::Create( 36 void MojoCdm::Create(
37 const std::string& key_system, 37 const std::string& key_system,
38 const GURL& security_origin, 38 const GURL& security_origin,
39 const media::CdmConfig& cdm_config, 39 const media::CdmConfig& cdm_config,
40 mojom::ContentDecryptionModulePtr remote_cdm, 40 mojom::ContentDecryptionModulePtr remote_cdm,
41 const media::SessionMessageCB& session_message_cb, 41 const media::SessionMessageCB& session_message_cb,
42 const media::SessionClosedCB& session_closed_cb, 42 const media::SessionClosedCB& session_closed_cb,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 void MojoCdm::CreateSessionAndGenerateRequest( 147 void MojoCdm::CreateSessionAndGenerateRequest(
148 SessionType session_type, 148 SessionType session_type,
149 EmeInitDataType init_data_type, 149 EmeInitDataType init_data_type,
150 const std::vector<uint8_t>& init_data, 150 const std::vector<uint8_t>& init_data,
151 std::unique_ptr<NewSessionCdmPromise> promise) { 151 std::unique_ptr<NewSessionCdmPromise> promise) {
152 DVLOG(2) << __FUNCTION__; 152 DVLOG(2) << __FUNCTION__;
153 DCHECK(thread_checker_.CalledOnValidThread()); 153 DCHECK(thread_checker_.CalledOnValidThread());
154 154
155 remote_cdm_->CreateSessionAndGenerateRequest( 155 remote_cdm_->CreateSessionAndGenerateRequest(
156 static_cast<mojom::ContentDecryptionModule::SessionType>(session_type), 156 session_type, init_data_type, init_data,
157 static_cast<mojom::ContentDecryptionModule::InitDataType>(init_data_type), 157 base::Bind(&MojoCdm::OnNewSessionCdmPromiseResult, base::Unretained(this),
158 init_data, base::Bind(&MojoCdm::OnNewSessionCdmPromiseResult, 158 base::Passed(&promise)));
159 base::Unretained(this), base::Passed(&promise)));
160 } 159 }
161 160
162 void MojoCdm::LoadSession(SessionType session_type, 161 void MojoCdm::LoadSession(SessionType session_type,
163 const std::string& session_id, 162 const std::string& session_id,
164 std::unique_ptr<NewSessionCdmPromise> promise) { 163 std::unique_ptr<NewSessionCdmPromise> promise) {
165 DVLOG(2) << __FUNCTION__; 164 DVLOG(2) << __FUNCTION__;
166 DCHECK(thread_checker_.CalledOnValidThread()); 165 DCHECK(thread_checker_.CalledOnValidThread());
167 166
168 remote_cdm_->LoadSession( 167 remote_cdm_->LoadSession(
169 static_cast<mojom::ContentDecryptionModule::SessionType>(session_type), 168 session_type, session_id,
170 session_id, base::Bind(&MojoCdm::OnNewSessionCdmPromiseResult, 169 base::Bind(&MojoCdm::OnNewSessionCdmPromiseResult, base::Unretained(this),
171 base::Unretained(this), base::Passed(&promise))); 170 base::Passed(&promise)));
172 } 171 }
173 172
174 void MojoCdm::UpdateSession(const std::string& session_id, 173 void MojoCdm::UpdateSession(const std::string& session_id,
175 const std::vector<uint8_t>& response, 174 const std::vector<uint8_t>& response,
176 std::unique_ptr<SimpleCdmPromise> promise) { 175 std::unique_ptr<SimpleCdmPromise> promise) {
177 DVLOG(2) << __FUNCTION__; 176 DVLOG(2) << __FUNCTION__;
178 DCHECK(thread_checker_.CalledOnValidThread()); 177 DCHECK(thread_checker_.CalledOnValidThread());
179 178
180 remote_cdm_->UpdateSession( 179 remote_cdm_->UpdateSession(
181 session_id, response, 180 session_id, response,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 227 }
229 228
230 int MojoCdm::GetCdmId() const { 229 int MojoCdm::GetCdmId() const {
231 base::AutoLock auto_lock(lock_); 230 base::AutoLock auto_lock(lock_);
232 // Can be called on a different thread. 231 // Can be called on a different thread.
233 DCHECK_NE(CdmContext::kInvalidCdmId, cdm_id_); 232 DCHECK_NE(CdmContext::kInvalidCdmId, cdm_id_);
234 return cdm_id_; 233 return cdm_id_;
235 } 234 }
236 235
237 void MojoCdm::OnSessionMessage(const std::string& session_id, 236 void MojoCdm::OnSessionMessage(const std::string& session_id,
238 mojom::CdmMessageType message_type, 237 MessageType message_type,
239 const std::vector<uint8_t>& message) { 238 const std::vector<uint8_t>& message) {
240 DVLOG(2) << __FUNCTION__; 239 DVLOG(2) << __FUNCTION__;
241 DCHECK(thread_checker_.CalledOnValidThread()); 240 DCHECK(thread_checker_.CalledOnValidThread());
242 241
243 session_message_cb_.Run( 242 session_message_cb_.Run(session_id, message_type, message);
244 session_id, static_cast<MediaKeys::MessageType>(message_type), message);
245 } 243 }
246 244
247 void MojoCdm::OnSessionClosed(const std::string& session_id) { 245 void MojoCdm::OnSessionClosed(const std::string& session_id) {
248 DVLOG(2) << __FUNCTION__; 246 DVLOG(2) << __FUNCTION__;
249 DCHECK(thread_checker_.CalledOnValidThread()); 247 DCHECK(thread_checker_.CalledOnValidThread());
250 248
251 session_closed_cb_.Run(session_id); 249 session_closed_cb_.Run(session_id);
252 } 250 }
253 251
254 void MojoCdm::OnSessionKeysChange( 252 void MojoCdm::OnSessionKeysChange(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 std::unique_ptr<NewSessionCdmPromise> promise, 333 std::unique_ptr<NewSessionCdmPromise> promise,
336 mojom::CdmPromiseResultPtr result, 334 mojom::CdmPromiseResultPtr result,
337 const std::string& session_id) { 335 const std::string& session_id) {
338 if (result->success) 336 if (result->success)
339 promise->resolve(session_id); 337 promise->resolve(session_id);
340 else 338 else
341 RejectPromise(std::move(promise), std::move(result)); 339 RejectPromise(std::move(promise), std::move(result));
342 } 340 }
343 341
344 } // namespace media 342 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/clients/mojo_cdm.h ('k') | media/mojo/clients/mojo_decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698