OLD | NEW |
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_media_application.h" | 5 #include "media/mojo/services/mojo_media_application.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/media_log.h" | 8 #include "media/base/media_log.h" |
9 #include "media/mojo/services/mojo_media_client.h" | 9 #include "media/mojo/services/mojo_media_client.h" |
10 #include "media/mojo/services/service_factory_impl.h" | |
11 #include "mojo/application/public/cpp/application_connection.h" | 10 #include "mojo/application/public/cpp/application_connection.h" |
12 #include "mojo/application/public/cpp/application_impl.h" | |
13 | 11 |
14 namespace media { | 12 namespace media { |
15 | 13 |
16 // static | 14 // static |
17 scoped_ptr<mojo::ApplicationDelegate> MojoMediaApplication::CreateApp() { | 15 scoped_ptr<mojo::ApplicationDelegate> MojoMediaApplication::CreateApp() { |
18 // In all existing use cases we don't need to initialize logging when using | 16 // In all existing use cases we don't need to initialize logging when using |
19 // CreateApp() to create the application. We can pass |enable_logging| in | 17 // CreateApp() to create the application. We can pass |enable_logging| in |
20 // CreateApp() if this isn't the case any more in the future. | 18 // CreateApp() if this isn't the case any more in the future. |
21 return scoped_ptr<mojo::ApplicationDelegate>( | 19 return scoped_ptr<mojo::ApplicationDelegate>( |
22 new MojoMediaApplication(false, MojoMediaClient::Create())); | 20 new MojoMediaApplication(false, MojoMediaClient::Create())); |
23 } | 21 } |
24 | 22 |
25 // TODO(xhwang): Hook up MediaLog when possible. | 23 // TODO(xhwang): Hook up MediaLog when possible. |
26 MojoMediaApplication::MojoMediaApplication( | 24 MojoMediaApplication::MojoMediaApplication( |
27 bool enable_logging, | 25 bool enable_logging, |
28 scoped_ptr<MojoMediaClient> mojo_media_client) | 26 scoped_ptr<MojoMediaClient> mojo_media_client) |
29 : enable_logging_(enable_logging), | 27 : enable_logging_(enable_logging), |
30 mojo_media_client_(std::move(mojo_media_client)), | 28 media_log_(new MediaLog()), |
31 app_impl_(nullptr), | 29 service_factory_(std::move(mojo_media_client), media_log_) {} |
32 media_log_(new MediaLog()) {} | |
33 | 30 |
34 MojoMediaApplication::~MojoMediaApplication() { | 31 MojoMediaApplication::~MojoMediaApplication() { |
35 } | 32 } |
36 | 33 |
37 void MojoMediaApplication::Initialize(mojo::ApplicationImpl* app) { | 34 void MojoMediaApplication::Initialize(mojo::ApplicationImpl* app) { |
38 app_impl_ = app; | |
39 | |
40 if (enable_logging_) { | 35 if (enable_logging_) { |
41 logging::LoggingSettings settings; | 36 logging::LoggingSettings settings; |
42 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 37 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
43 logging::InitLogging(settings); | 38 logging::InitLogging(settings); |
44 // Display process ID, thread ID and timestamp in logs. | 39 // Display process ID, thread ID and timestamp in logs. |
45 logging::SetLogItems(true, true, true, false); | 40 logging::SetLogItems(true, true, true, false); |
46 } | 41 } |
47 mojo_media_client_->Initialize(); | 42 service_factory_.Initialize(app); |
48 } | 43 } |
49 | 44 |
50 bool MojoMediaApplication::ConfigureIncomingConnection( | 45 bool MojoMediaApplication::ConfigureIncomingConnection( |
51 mojo::ApplicationConnection* connection) { | 46 mojo::ApplicationConnection* connection) { |
52 connection->AddService<interfaces::ServiceFactory>(this); | 47 connection->AddService<interfaces::Renderer>(&service_factory_); |
| 48 connection->AddService<interfaces::ContentDecryptionModule>( |
| 49 &service_factory_); |
53 return true; | 50 return true; |
54 } | 51 } |
55 | 52 |
56 void MojoMediaApplication::Create( | |
57 mojo::ApplicationConnection* connection, | |
58 mojo::InterfaceRequest<interfaces::ServiceFactory> request) { | |
59 // The created object is owned by the pipe. | |
60 new ServiceFactoryImpl(request.Pass(), connection->GetServiceProvider(), | |
61 media_log_, | |
62 app_impl_->app_lifetime_helper()->CreateAppRefCount(), | |
63 mojo_media_client_.get()); | |
64 } | |
65 | |
66 } // namespace media | 53 } // namespace media |
OLD | NEW |