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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/logging.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "media/mojo/services/mojo_renderer_service.h"
9 #include "mojo/application/application_runner_chromium.h"
10 #include "third_party/mojo/src/mojo/public/c/system/main.h"
11 #include "third_party/mojo/src/mojo/public/cpp/application/application_connection.h"
12 #include "third_party/mojo/src/mojo/public/cpp/application/application_delegate.h"
13 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h"
14 #include "third_party/mojo/src/mojo/public/cpp/application/interface_factory_impl.h"
18 class MojoMediaApplication
19 : public mojo::ApplicationDelegate
,
20 public mojo::InterfaceFactory
<mojo::MediaRenderer
> {
22 // mojo::ApplicationDelegate implementation.
23 void Initialize(mojo::ApplicationImpl
* app
) override
{
24 base::CommandLine::StringVector command_line_args
;
26 for (const auto& arg
: app
->args())
27 command_line_args
.push_back(base::UTF8ToUTF16(arg
));
28 #elif defined(OS_POSIX)
29 command_line_args
= app
->args();
32 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
33 command_line
->InitFromArgv(command_line_args
);
35 logging::LoggingSettings settings
;
36 settings
.logging_dest
= logging::LOG_TO_SYSTEM_DEBUG_LOG
;
37 logging::InitLogging(settings
);
38 // Display process ID, thread ID and timestamp in logs.
39 logging::SetLogItems(true, true, true, false);
42 bool ConfigureIncomingConnection(
43 mojo::ApplicationConnection
* connection
) override
{
44 connection
->AddService(this);
48 // mojo::InterfaceFactory<mojo::MediaRenderer> implementation.
49 void Create(mojo::ApplicationConnection
* connection
,
50 mojo::InterfaceRequest
<mojo::MediaRenderer
> request
) override
{
51 mojo::BindToRequest(new MojoRendererService(), &request
);
57 MojoResult
MojoMain(MojoHandle mojo_handle
) {
58 mojo::ApplicationRunnerChromium
runner(new media::MojoMediaApplication());
59 return runner
.Run(mojo_handle
);