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

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

Issue 1810763002: Connect Mojo AudioDecoder service to the Mojo service factory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@spitzer-audio-service-stub
Patch Set: Passed scoped_refptr by value instead of const ref Created 4 years, 9 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/service_factory_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/mojo/services/service_factory_impl.h" 5 #include "media/mojo/services/service_factory_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/cdm_factory.h" 8 #include "media/base/cdm_factory.h"
9 #include "media/base/media_log.h" 9 #include "media/base/media_log.h"
10 #include "media/base/renderer_factory.h" 10 #include "media/base/renderer_factory.h"
11 #include "media/mojo/services/mojo_audio_decoder_service.h"
11 #include "media/mojo/services/mojo_cdm_service.h" 12 #include "media/mojo/services/mojo_cdm_service.h"
12 #include "media/mojo/services/mojo_media_client.h" 13 #include "media/mojo/services/mojo_media_client.h"
13 #include "media/mojo/services/mojo_renderer_service.h" 14 #include "media/mojo/services/mojo_renderer_service.h"
14 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" 15 #include "mojo/shell/public/interfaces/interface_provider.mojom.h"
15 16
16 namespace media { 17 namespace media {
17 18
18 ServiceFactoryImpl::ServiceFactoryImpl( 19 ServiceFactoryImpl::ServiceFactoryImpl(
19 mojo::InterfaceRequest<interfaces::ServiceFactory> request, 20 mojo::InterfaceRequest<interfaces::ServiceFactory> request,
20 mojo::shell::mojom::InterfaceProvider* interfaces, 21 mojo::shell::mojom::InterfaceProvider* interfaces,
21 scoped_refptr<MediaLog> media_log, 22 scoped_refptr<MediaLog> media_log,
22 scoped_ptr<mojo::MessageLoopRef> parent_app_refcount, 23 scoped_ptr<mojo::MessageLoopRef> parent_app_refcount,
23 MojoMediaClient* mojo_media_client) 24 MojoMediaClient* mojo_media_client)
24 : binding_(this, std::move(request)), 25 : binding_(this, std::move(request)),
25 interfaces_(interfaces), 26 interfaces_(interfaces),
26 media_log_(media_log), 27 media_log_(media_log),
27 parent_app_refcount_(std::move(parent_app_refcount)), 28 parent_app_refcount_(std::move(parent_app_refcount)),
28 mojo_media_client_(mojo_media_client) { 29 mojo_media_client_(mojo_media_client) {
29 DVLOG(1) << __FUNCTION__; 30 DVLOG(1) << __FUNCTION__;
30 } 31 }
31 32
32 ServiceFactoryImpl::~ServiceFactoryImpl() { 33 ServiceFactoryImpl::~ServiceFactoryImpl() {
33 DVLOG(1) << __FUNCTION__; 34 DVLOG(1) << __FUNCTION__;
34 } 35 }
35 36
36 // interfaces::ServiceFactory implementation. 37 // interfaces::ServiceFactory implementation.
38
39 void ServiceFactoryImpl::CreateAudioDecoder(
40 mojo::InterfaceRequest<interfaces::AudioDecoder> request) {
41 scoped_refptr<base::SingleThreadTaskRunner> task_runner(
42 base::MessageLoop::current()->task_runner());
43
44 scoped_ptr<AudioDecoder> audio_decoder =
45 mojo_media_client_->CreateAudioDecoder(task_runner);
46 if (!audio_decoder) {
47 LOG(ERROR) << "AudioDecoder creation failed.";
48 return;
49 }
50
51 new MojoAudioDecoderService(std::move(audio_decoder), std::move(request));
52 }
53
37 void ServiceFactoryImpl::CreateRenderer( 54 void ServiceFactoryImpl::CreateRenderer(
38 mojo::InterfaceRequest<interfaces::Renderer> request) { 55 mojo::InterfaceRequest<interfaces::Renderer> request) {
39 // The created object is owned by the pipe. 56 // The created object is owned by the pipe.
40 // The audio and video sinks are owned by the client. 57 // The audio and video sinks are owned by the client.
41 scoped_refptr<base::SingleThreadTaskRunner> task_runner( 58 scoped_refptr<base::SingleThreadTaskRunner> task_runner(
42 base::MessageLoop::current()->task_runner()); 59 base::MessageLoop::current()->task_runner());
43 AudioRendererSink* audio_renderer_sink = 60 AudioRendererSink* audio_renderer_sink =
44 mojo_media_client_->CreateAudioRendererSink(); 61 mojo_media_client_->CreateAudioRendererSink();
45 VideoRendererSink* video_renderer_sink = 62 VideoRendererSink* video_renderer_sink =
46 mojo_media_client_->CreateVideoRendererSink(task_runner); 63 mojo_media_client_->CreateVideoRendererSink(task_runner);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 99
83 CdmFactory* ServiceFactoryImpl::GetCdmFactory() { 100 CdmFactory* ServiceFactoryImpl::GetCdmFactory() {
84 if (!cdm_factory_) { 101 if (!cdm_factory_) {
85 cdm_factory_ = mojo_media_client_->CreateCdmFactory(interfaces_); 102 cdm_factory_ = mojo_media_client_->CreateCdmFactory(interfaces_);
86 LOG_IF(ERROR, !cdm_factory_) << "CdmFactory not available."; 103 LOG_IF(ERROR, !cdm_factory_) << "CdmFactory not available.";
87 } 104 }
88 return cdm_factory_.get(); 105 return cdm_factory_.get();
89 } 106 }
90 107
91 } // namespace media 108 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/service_factory_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698