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

Side by Side Diff: media/mojo/services/mojo_cdm_service.cc

Issue 1230313010: media: Add ServiceFactory mojo interface and implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 5 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/services/mojo_cdm_service.h ('k') | media/mojo/services/mojo_cdm_service_context.h » ('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/services/mojo_cdm_service.h" 5 #include "media/mojo/services/mojo_cdm_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "media/base/cdm_config.h" 8 #include "media/base/cdm_config.h"
9 #include "media/base/cdm_factory.h" 9 #include "media/base/cdm_factory.h"
10 #include "media/base/cdm_key_information.h" 10 #include "media/base/cdm_key_information.h"
11 #include "media/base/key_systems.h" 11 #include "media/base/key_systems.h"
12 #include "media/mojo/services/media_type_converters.h" 12 #include "media/mojo/services/media_type_converters.h"
13 #include "media/mojo/services/mojo_cdm_service_context.h" 13 #include "media/mojo/services/mojo_cdm_service_context.h"
14 #include "mojo/common/common_type_converters.h" 14 #include "mojo/common/common_type_converters.h"
15 #include "mojo/common/url_type_converters.h" 15 #include "mojo/common/url_type_converters.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace media { 18 namespace media {
19 19
20 using NewSessionMojoCdmPromise = MojoCdmPromise<std::string>; 20 using NewSessionMojoCdmPromise = MojoCdmPromise<std::string>;
21 using SimpleMojoCdmPromise = MojoCdmPromise<>; 21 using SimpleMojoCdmPromise = MojoCdmPromise<>;
22 22
23 MojoCdmService::MojoCdmService( 23 MojoCdmService::MojoCdmService(
24 MojoCdmServiceContext* context, 24 base::WeakPtr<MojoCdmServiceContext> context,
25 mojo::ServiceProvider* service_provider, 25 mojo::ServiceProvider* service_provider,
26 CdmFactory* cdm_factory, 26 CdmFactory* cdm_factory,
27 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request) 27 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request)
28 : binding_(this, request.Pass()), 28 : binding_(this, request.Pass()),
29 context_(context), 29 context_(context),
30 service_provider_(service_provider), 30 service_provider_(service_provider),
31 cdm_factory_(cdm_factory), 31 cdm_factory_(cdm_factory),
32 cdm_id_(CdmContext::kInvalidCdmId), 32 cdm_id_(CdmContext::kInvalidCdmId),
33 weak_factory_(this) { 33 weak_factory_(this) {
34 DCHECK(context_); 34 DCHECK(context_);
35 DCHECK(cdm_factory_); 35 DCHECK(cdm_factory_);
36 } 36 }
37 37
38 MojoCdmService::~MojoCdmService() { 38 MojoCdmService::~MojoCdmService() {
39 if (cdm_id_ != CdmContext::kInvalidCdmId) 39 if (cdm_id_ != CdmContext::kInvalidCdmId && context_)
40 context_->UnregisterCdm(cdm_id_); 40 context_->UnregisterCdm(cdm_id_);
41 } 41 }
42 42
43 void MojoCdmService::SetClient( 43 void MojoCdmService::SetClient(
44 interfaces::ContentDecryptionModuleClientPtr client) { 44 interfaces::ContentDecryptionModuleClientPtr client) {
45 client_ = client.Pass(); 45 client_ = client.Pass();
46 } 46 }
47 47
48 void MojoCdmService::Initialize( 48 void MojoCdmService::Initialize(
49 const mojo::String& key_system, 49 const mojo::String& key_system,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 CdmContext* MojoCdmService::GetCdmContext() { 135 CdmContext* MojoCdmService::GetCdmContext() {
136 return cdm_->GetCdmContext(); 136 return cdm_->GetCdmContext();
137 } 137 }
138 138
139 void MojoCdmService::OnCdmCreated(int cdm_id, 139 void MojoCdmService::OnCdmCreated(int cdm_id,
140 scoped_ptr<SimpleMojoCdmPromise> promise, 140 scoped_ptr<SimpleMojoCdmPromise> promise,
141 scoped_ptr<MediaKeys> cdm, 141 scoped_ptr<MediaKeys> cdm,
142 const std::string& error_message) { 142 const std::string& error_message) {
143 // TODO(xhwang): This should not happen when KeySystemInfo is properly 143 // TODO(xhwang): This should not happen when KeySystemInfo is properly
144 // populated. See http://crbug.com/469366 144 // populated. See http://crbug.com/469366
145 if (!cdm) { 145 if (!cdm || !context_) {
146 promise->reject(MediaKeys::NOT_SUPPORTED_ERROR, 0, error_message); 146 promise->reject(MediaKeys::NOT_SUPPORTED_ERROR, 0, error_message);
147 return; 147 return;
148 } 148 }
149 149
150 cdm_ = cdm.Pass(); 150 cdm_ = cdm.Pass();
151 cdm_id_ = cdm_id; 151 cdm_id_ = cdm_id;
152 context_->RegisterCdm(cdm_id_, this); 152 context_->RegisterCdm(cdm_id_, this);
153 promise->resolve(); 153 promise->resolve();
154 } 154 }
155 155
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 MediaKeys::Exception exception, 192 MediaKeys::Exception exception,
193 uint32_t system_code, 193 uint32_t system_code,
194 const std::string& error_message) { 194 const std::string& error_message) {
195 DVLOG(2) << __FUNCTION__; 195 DVLOG(2) << __FUNCTION__;
196 client_->OnLegacySessionError( 196 client_->OnLegacySessionError(
197 session_id, static_cast<interfaces::CdmException>(exception), system_code, 197 session_id, static_cast<interfaces::CdmException>(exception), system_code,
198 error_message); 198 error_message);
199 } 199 }
200 200
201 } // namespace media 201 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_cdm_service.h ('k') | media/mojo/services/mojo_cdm_service_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698