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
3 // found in the LICENSE file.
5 #include "media/mojo/services/service_factory_impl.h"
7 #include "base/logging.h"
8 #include "media/base/cdm_factory.h"
9 #include "media/base/media_log.h"
10 #include "media/base/renderer_factory.h"
11 #include "media/mojo/services/mojo_cdm_service.h"
12 #include "media/mojo/services/mojo_media_client.h"
13 #include "media/mojo/services/mojo_renderer_service.h"
17 ServiceFactoryImpl::ServiceFactoryImpl(
18 mojo::InterfaceRequest
<interfaces::ServiceFactory
> request
,
19 mojo::ServiceProvider
* service_provider
,
20 scoped_refptr
<MediaLog
> media_log
)
21 : binding_(this, request
.Pass()),
22 service_provider_(service_provider
),
23 media_log_(media_log
) {
24 DVLOG(1) << __FUNCTION__
;
27 ServiceFactoryImpl::~ServiceFactoryImpl() {
28 DVLOG(1) << __FUNCTION__
;
31 // interfaces::ServiceFactory implementation.
32 void ServiceFactoryImpl::CreateRenderer(
33 mojo::InterfaceRequest
<interfaces::MediaRenderer
> request
) {
34 // The created object is owned by the pipe.
35 new MojoRendererService(cdm_service_context_
.GetWeakPtr(),
36 GetRendererFactory(), media_log_
, request
.Pass());
39 void ServiceFactoryImpl::CreateCdm(
40 mojo::InterfaceRequest
<interfaces::ContentDecryptionModule
> request
) {
41 // The created object is owned by the pipe.
42 new MojoCdmService(cdm_service_context_
.GetWeakPtr(), service_provider_
,
43 GetCdmFactory(), request
.Pass());
46 RendererFactory
* ServiceFactoryImpl::GetRendererFactory() {
47 if (!renderer_factory_
)
49 MojoMediaClient::Get()->CreateRendererFactory(media_log_
);
50 return renderer_factory_
.get();
53 CdmFactory
* ServiceFactoryImpl::GetCdmFactory() {
55 cdm_factory_
= MojoMediaClient::Get()->CreateCdmFactory();
56 return cdm_factory_
.get();