diff options
-rw-r--r-- | chrome/browser/BUILD.gn | 6 | ||||
-rw-r--r-- | chromecast/browser/cast_content_browser_client.cc | 8 | ||||
-rw-r--r-- | chromecast/media/mojo/BUILD.gn | 1 | ||||
-rw-r--r-- | chromecast/media/mojo/cast_mojo_media_client.cc | 37 | ||||
-rw-r--r-- | chromecast/media/mojo/cast_mojo_media_client.h | 32 | ||||
-rw-r--r-- | content/shell/BUILD.gn | 4 | ||||
-rw-r--r-- | media/mojo/services/BUILD.gn | 22 | ||||
-rw-r--r-- | media/mojo/services/android_mojo_media_client.cc | 30 | ||||
-rw-r--r-- | media/mojo/services/android_mojo_media_client.h | 28 | ||||
-rw-r--r-- | media/mojo/services/default_mojo_media_client.cc | 106 | ||||
-rw-r--r-- | media/mojo/services/default_mojo_media_client.h | 47 | ||||
-rw-r--r-- | media/mojo/services/main.cc | 4 | ||||
-rw-r--r-- | media/mojo/services/mojo_cdm_service_context.h | 1 | ||||
-rw-r--r-- | media/mojo/services/mojo_media_application.cc | 37 | ||||
-rw-r--r-- | media/mojo/services/mojo_media_application.h | 17 | ||||
-rw-r--r-- | media/mojo/services/mojo_media_client.h | 7 | ||||
-rw-r--r-- | media/mojo/services/mojo_renderer_factory.h | 1 |
17 files changed, 249 insertions, 139 deletions
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index cd5004b..b6d2903 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -958,8 +958,10 @@ source_set("browser") { deps += [ "//chrome/browser/media/router" ] } - if (enable_mojo_media != "none") { - deps += [ "//media/mojo/services:default_application" ] + if (enable_mojo_media == "browser") { + deps += [ "//media/mojo/services:application" ] + } else if (enable_mojo_media != "none") { + configs += [ "//media/mojo/services:enable_mojo_media_config" ] } if (enable_wayland_server) { diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc index aea55a6..12a4754 100644 --- a/chromecast/browser/cast_content_browser_client.cc +++ b/chromecast/browser/cast_content_browser_client.cc @@ -52,6 +52,7 @@ #include "ui/gl/gl_switches.h" #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) +#include "chromecast/media/mojo/cast_mojo_media_client.h" // nogncheck because of conditional dependency. #include "media/mojo/services/mojo_media_application.h" // nogncheck #endif // ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS @@ -357,9 +358,10 @@ bool CastContentBrowserClient::CanCreateWindow( void CastContentBrowserClient::RegisterInProcessMojoApplications( StaticMojoApplicationMap* apps) { #if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS) - apps->insert( - std::make_pair(GURL("mojo:media"), - base::Bind(::media::MojoMediaApplication::CreateApp))); + apps->insert(std::make_pair( + GURL("mojo:media"), + base::Bind(::media::MojoMediaApplication::CreateAppWithClient, + base::Bind(&media::CastMojoMediaClient::Create)))); #endif } diff --git a/chromecast/media/mojo/BUILD.gn b/chromecast/media/mojo/BUILD.gn index f197973..f8e8ec1 100644 --- a/chromecast/media/mojo/BUILD.gn +++ b/chromecast/media/mojo/BUILD.gn @@ -10,6 +10,7 @@ assert(enable_mojo_media == "browser") source_set("mojo") { sources = [ "cast_mojo_media_client.cc", + "cast_mojo_media_client.h", ] public_deps = [ diff --git a/chromecast/media/mojo/cast_mojo_media_client.cc b/chromecast/media/mojo/cast_mojo_media_client.cc index e239269..3a16021 100644 --- a/chromecast/media/mojo/cast_mojo_media_client.cc +++ b/chromecast/media/mojo/cast_mojo_media_client.cc @@ -2,31 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "media/mojo/services/mojo_media_application.h" +#include "chromecast/media/mojo/cast_mojo_media_client.h" -#include "media/mojo/services/mojo_media_client.h" - -namespace { -class CastMojoMediaClient : public ::media::MojoMediaClient { - public: - CastMojoMediaClient() {} - ~CastMojoMediaClient() override {} +namespace chromecast { +namespace media { - // MojoMediaClient overrides. - void Initialize() override {} - scoped_ptr<::media::RendererFactory> CreateRendererFactory( - const scoped_refptr<::media::MediaLog>& media_log) override { - return scoped_ptr<::media::RendererFactory>(); - } +CastMojoMediaClient::CastMojoMediaClient() {} - private: - DISALLOW_COPY_AND_ASSIGN(CastMojoMediaClient); -}; -} // namespace +CastMojoMediaClient::~CastMojoMediaClient() {} -namespace media { // static -scoped_ptr<MojoMediaClient> MojoMediaClient::Create() { - return make_scoped_ptr(new CastMojoMediaClient()); +scoped_ptr<::media::MojoMediaClient> CastMojoMediaClient::Create() { + return scoped_ptr<::media::MojoMediaClient>(new CastMojoMediaClient()); } + +void CastMojoMediaClient::Initialize() {} + +scoped_ptr<::media::RendererFactory> CastMojoMediaClient::CreateRendererFactory( + const scoped_refptr<::media::MediaLog>& /* media_log */) { + return scoped_ptr<::media::RendererFactory>(); +} + } // namespace media +} // namespace chromecast diff --git a/chromecast/media/mojo/cast_mojo_media_client.h b/chromecast/media/mojo/cast_mojo_media_client.h new file mode 100644 index 0000000..1f7fcde --- /dev/null +++ b/chromecast/media/mojo/cast_mojo_media_client.h @@ -0,0 +1,32 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROMECAST_MEDIA_MOJO_CAST_MOJO_MEDIA_CLIENT_H_ +#define CHROMECAST_MEDIA_MOJO_CAST_MOJO_MEDIA_CLIENT_H_ + +#include "media/mojo/services/mojo_media_client.h" + +namespace chromecast { +namespace media { + +class CastMojoMediaClient : public ::media::MojoMediaClient { + public: + CastMojoMediaClient(); + ~CastMojoMediaClient() override; + + static scoped_ptr<::media::MojoMediaClient> Create(); + + // MojoMediaClient overrides. + void Initialize() override; + scoped_ptr<::media::RendererFactory> CreateRendererFactory( + const scoped_refptr<::media::MediaLog>& media_log) override; + + private: + DISALLOW_COPY_AND_ASSIGN(CastMojoMediaClient); +}; + +} // namespace media +} // namespace chromecast + +#endif // CHROMECAST_MEDIA_MOJO_CAST_MOJO_MEDIA_CLIENT_H_ diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn index e18c0b9..4847abd 100644 --- a/content/shell/BUILD.gn +++ b/content/shell/BUILD.gn @@ -245,8 +245,8 @@ static_library("content_shell_lib") { "//ppapi:blink_test_plugin", ] } - if (enable_mojo_media != "none") { - deps += [ "//media/mojo/services:default_application" ] + if (enable_mojo_media == "browser") { + deps += [ "//media/mojo/services:application" ] } if (is_win) { diff --git a/media/mojo/services/BUILD.gn b/media/mojo/services/BUILD.gn index 0f68858..39384c9 100644 --- a/media/mojo/services/BUILD.gn +++ b/media/mojo/services/BUILD.gn @@ -150,30 +150,24 @@ source_set("application") { "service_factory_impl.h", ] - public_configs = [ ":enable_mojo_media_config" ] - - deps = [ - ":cdm_service", - ":renderer_service", - "//mojo/shell/public/cpp", - ] -} - -source_set("default_application") { if (is_android) { - sources = [ + sources += [ "android_mojo_media_client.cc", + "android_mojo_media_client.h", ] } else { - sources = [ + sources += [ "default_mojo_media_client.cc", + "default_mojo_media_client.h", ] } public_configs = [ ":enable_mojo_media_config" ] deps = [ - ":application", + ":cdm_service", + ":renderer_service", + "//mojo/shell/public/cpp", ] } @@ -203,7 +197,7 @@ mojo_native_application("media") { ] deps = [ - ":default_application", + ":application", "//mojo/logging", "//mojo/public/c/system:for_shared_library", ] diff --git a/media/mojo/services/android_mojo_media_client.cc b/media/mojo/services/android_mojo_media_client.cc index efd25c2..a7c270f 100644 --- a/media/mojo/services/android_mojo_media_client.cc +++ b/media/mojo/services/android_mojo_media_client.cc @@ -2,13 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "media/mojo/services/mojo_media_client.h" +#include "media/mojo/services/android_mojo_media_client.h" -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "media/base/android/android_cdm_factory.h" -#include "media/base/bind_to_current_loop.h" -#include "media/base/media.h" #include "media/mojo/interfaces/provision_fetcher.mojom.h" #include "media/mojo/services/mojo_provision_fetcher.h" #include "mojo/shell/public/cpp/connect.h" @@ -16,6 +12,7 @@ namespace media { namespace { + scoped_ptr<ProvisionFetcher> CreateProvisionFetcher( mojo::shell::mojom::InterfaceProvider* service_provider) { interfaces::ProvisionFetcherPtr provision_fetcher_ptr; @@ -24,24 +21,17 @@ scoped_ptr<ProvisionFetcher> CreateProvisionFetcher( new MojoProvisionFetcher(std::move(provision_fetcher_ptr))); } -class AndroidMojoMediaClient : public MojoMediaClient { - public: - AndroidMojoMediaClient() {} +} // namespace - // MojoMediaClient overrides. - scoped_ptr<CdmFactory> CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* service_provider) override { - return make_scoped_ptr(new AndroidCdmFactory( - base::Bind(&CreateProvisionFetcher, service_provider))); - } +AndroidMojoMediaClient::AndroidMojoMediaClient() {} - private: - DISALLOW_COPY_AND_ASSIGN(AndroidMojoMediaClient); -}; -} // namespace (anonymous) +AndroidMojoMediaClient::~AndroidMojoMediaClient() {} -scoped_ptr<MojoMediaClient> MojoMediaClient::Create() { - return make_scoped_ptr(new AndroidMojoMediaClient()); +// MojoMediaClient overrides. +scoped_ptr<CdmFactory> AndroidMojoMediaClient::CreateCdmFactory( + mojo::shell::mojom::InterfaceProvider* service_provider) { + return make_scoped_ptr(new AndroidCdmFactory( + base::Bind(&CreateProvisionFetcher, service_provider))); } } // namespace media diff --git a/media/mojo/services/android_mojo_media_client.h b/media/mojo/services/android_mojo_media_client.h new file mode 100644 index 0000000..11a14db --- /dev/null +++ b/media/mojo/services/android_mojo_media_client.h @@ -0,0 +1,28 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_MOJO_SERVICES_ANDROID_MOJO_MEDIA_CLIENT_H_ +#define MEDIA_MOJO_SERVICES_ANDROID_MOJO_MEDIA_CLIENT_H_ + +#include "base/macros.h" +#include "media/mojo/services/mojo_media_client.h" + +namespace media { + +class AndroidMojoMediaClient : public MojoMediaClient { + public: + AndroidMojoMediaClient(); + ~AndroidMojoMediaClient() final; + + // MojoMediaClient implementation. + scoped_ptr<CdmFactory> CreateCdmFactory( + mojo::shell::mojom::InterfaceProvider* service_provider) final; + + private: + DISALLOW_COPY_AND_ASSIGN(AndroidMojoMediaClient); +}; + +} // namespace media + +#endif // MEDIA_MOJO_SERVICES_ANDROID_MOJO_MEDIA_CLIENT_H_ diff --git a/media/mojo/services/default_mojo_media_client.cc b/media/mojo/services/default_mojo_media_client.cc index 4facbd1..c602f64 100644 --- a/media/mojo/services/default_mojo_media_client.cc +++ b/media/mojo/services/default_mojo_media_client.cc @@ -2,13 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "media/mojo/services/mojo_media_client.h" +#include "media/mojo/services/default_mojo_media_client.h" -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" #include "media/audio/audio_manager_base.h" #include "media/audio/audio_output_stream_sink.h" -#include "media/audio/fake_audio_log_factory.h" #include "media/base/audio_hardware_config.h" #include "media/base/media.h" #include "media/base/null_video_sink.h" @@ -18,72 +15,55 @@ namespace media { -namespace { -class DefaultMojoMediaClient : public MojoMediaClient { - public: - DefaultMojoMediaClient() {} - - // MojoMediaClient overrides. - void Initialize() override { - InitializeMediaLibrary(); - // TODO(dalecurtis): We should find a single owner per process for the audio - // manager or make it a lazy instance. It's not safe to call Get()/Create() - // across multiple threads... - // - // TODO(dalecurtis): Eventually we'll want something other than a fake audio - // log factory here too. We should probably at least DVLOG() such info. - AudioManager* audio_manager = AudioManager::Get(); - if (!audio_manager) - audio_manager = media::AudioManager::Create(&fake_audio_log_factory_); - - audio_hardware_config_.reset(new AudioHardwareConfig( - audio_manager->GetInputStreamParameters( - AudioManagerBase::kDefaultDeviceId), - audio_manager->GetDefaultOutputStreamParameters())); - } - - scoped_ptr<RendererFactory> CreateRendererFactory( - const scoped_refptr<MediaLog>& media_log) override { - return make_scoped_ptr(new DefaultRendererFactory(media_log, nullptr, - *audio_hardware_config_)); - } - - AudioRendererSink* CreateAudioRendererSink() override { - if (!audio_renderer_sink_) - audio_renderer_sink_ = new AudioOutputStreamSink(); +DefaultMojoMediaClient::DefaultMojoMediaClient() {} + +DefaultMojoMediaClient::~DefaultMojoMediaClient() {} + +void DefaultMojoMediaClient::Initialize() { + InitializeMediaLibrary(); + // TODO(dalecurtis): We should find a single owner per process for the audio + // manager or make it a lazy instance. It's not safe to call Get()/Create() + // across multiple threads... + // + // TODO(dalecurtis): Eventually we'll want something other than a fake audio + // log factory here too. We should probably at least DVLOG() such info. + AudioManager* audio_manager = AudioManager::Get(); + if (!audio_manager) + audio_manager = media::AudioManager::Create(&fake_audio_log_factory_); + + audio_hardware_config_.reset(new AudioHardwareConfig( + audio_manager->GetInputStreamParameters( + AudioManagerBase::kDefaultDeviceId), + audio_manager->GetDefaultOutputStreamParameters())); +} - return audio_renderer_sink_.get(); - } +scoped_ptr<RendererFactory> DefaultMojoMediaClient::CreateRendererFactory( + const scoped_refptr<MediaLog>& media_log) { + return make_scoped_ptr( + new DefaultRendererFactory(media_log, nullptr, *audio_hardware_config_)); +} - VideoRendererSink* CreateVideoRendererSink( - const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) override { - if (!video_renderer_sink_) { - video_renderer_sink_ = make_scoped_ptr( - new NullVideoSink(false, base::TimeDelta::FromSecondsD(1.0 / 60), - NullVideoSink::NewFrameCB(), task_runner)); - } +AudioRendererSink* DefaultMojoMediaClient::CreateAudioRendererSink() { + if (!audio_renderer_sink_) + audio_renderer_sink_ = new AudioOutputStreamSink(); - return video_renderer_sink_.get(); - } + return audio_renderer_sink_.get(); +} - scoped_ptr<CdmFactory> CreateCdmFactory( - mojo::shell::mojom::InterfaceProvider* /* service_provider */) override { - return make_scoped_ptr(new DefaultCdmFactory()); +VideoRendererSink* DefaultMojoMediaClient::CreateVideoRendererSink( + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { + if (!video_renderer_sink_) { + video_renderer_sink_ = make_scoped_ptr( + new NullVideoSink(false, base::TimeDelta::FromSecondsD(1.0 / 60), + NullVideoSink::NewFrameCB(), task_runner)); } - private: - FakeAudioLogFactory fake_audio_log_factory_; - scoped_ptr<AudioHardwareConfig> audio_hardware_config_; - scoped_refptr<AudioRendererSink> audio_renderer_sink_; - scoped_ptr<VideoRendererSink> video_renderer_sink_; - - DISALLOW_COPY_AND_ASSIGN(DefaultMojoMediaClient); -}; - -} // namespace (anonymous) + return video_renderer_sink_.get(); +} -scoped_ptr<MojoMediaClient> MojoMediaClient::Create() { - return make_scoped_ptr(new DefaultMojoMediaClient()); +scoped_ptr<CdmFactory> DefaultMojoMediaClient::CreateCdmFactory( + mojo::shell::mojom::InterfaceProvider* /* service_provider */) { + return make_scoped_ptr(new DefaultCdmFactory()); } } // namespace media diff --git a/media/mojo/services/default_mojo_media_client.h b/media/mojo/services/default_mojo_media_client.h new file mode 100644 index 0000000..7498e25 --- /dev/null +++ b/media/mojo/services/default_mojo_media_client.h @@ -0,0 +1,47 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_MOJO_SERVICES_DEFAULT_MOJO_MEDIA_CLIENT_H_ +#define MEDIA_MOJO_SERVICES_DEFAULT_MOJO_MEDIA_CLIENT_H_ + +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "media/audio/fake_audio_log_factory.h" +#include "media/mojo/services/mojo_media_client.h" + +namespace media { + +class AudioHardwareConfig; +class AudioRendererSink; +class VideoRendererSink; + +// Default MojoMediaClient for MojoMediaApplication. +class DefaultMojoMediaClient : public MojoMediaClient { + public: + DefaultMojoMediaClient(); + ~DefaultMojoMediaClient() final; + + // MojoMediaClient implementation. + void Initialize() final; + scoped_ptr<RendererFactory> CreateRendererFactory( + const scoped_refptr<MediaLog>& media_log) final; + AudioRendererSink* CreateAudioRendererSink() final; + VideoRendererSink* CreateVideoRendererSink( + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) final; + scoped_ptr<CdmFactory> CreateCdmFactory( + mojo::shell::mojom::InterfaceProvider* /* service_provider */) final; + + private: + FakeAudioLogFactory fake_audio_log_factory_; + scoped_ptr<AudioHardwareConfig> audio_hardware_config_; + scoped_refptr<AudioRendererSink> audio_renderer_sink_; + scoped_ptr<VideoRendererSink> video_renderer_sink_; + + DISALLOW_COPY_AND_ASSIGN(DefaultMojoMediaClient); +}; + +} // namespace media + +#endif // MEDIA_MOJO_SERVICES_DEFAULT_MOJO_MEDIA_CLIENT_H_ diff --git a/media/mojo/services/main.cc b/media/mojo/services/main.cc index b3df5c8..2ab7d06 100644 --- a/media/mojo/services/main.cc +++ b/media/mojo/services/main.cc @@ -14,8 +14,8 @@ MojoResult MojoMain(MojoHandle mojo_handle) { mojo::ApplicationRunner::InitBaseCommandLine(); mojo::InitLogging(); - scoped_ptr<mojo::ShellClient> app_delegate = + scoped_ptr<mojo::ShellClient> shell_client = media::MojoMediaApplication::CreateApp(); - mojo::ApplicationRunner runner(app_delegate.release()); + mojo::ApplicationRunner runner(shell_client.release()); return runner.Run(mojo_handle, false /* init_base */); } diff --git a/media/mojo/services/mojo_cdm_service_context.h b/media/mojo/services/mojo_cdm_service_context.h index 4b797f9..b3592be 100644 --- a/media/mojo/services/mojo_cdm_service_context.h +++ b/media/mojo/services/mojo_cdm_service_context.h @@ -12,7 +12,6 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "media/base/cdm_context.h" -#include "media/base/media_export.h" namespace media { diff --git a/media/mojo/services/mojo_media_application.cc b/media/mojo/services/mojo_media_application.cc index 74c0df5..8a92b02 100644 --- a/media/mojo/services/mojo_media_application.cc +++ b/media/mojo/services/mojo_media_application.cc @@ -12,12 +12,36 @@ #include "mojo/shell/public/cpp/connection.h" #include "mojo/shell/public/cpp/shell.h" +#if defined(OS_ANDROID) +#include "media/mojo/services/android_mojo_media_client.h" +#else +#include "media/mojo/services/default_mojo_media_client.h" +#endif + namespace media { +#if defined(OS_ANDROID) +using DefaultClient = AndroidMojoMediaClient; +#else +using DefaultClient = DefaultMojoMediaClient; +#endif + // static scoped_ptr<mojo::ShellClient> MojoMediaApplication::CreateApp() { return scoped_ptr<mojo::ShellClient>( - new MojoMediaApplication(MojoMediaClient::Create())); + new MojoMediaApplication(make_scoped_ptr(new DefaultClient()))); +} + +// static +scoped_ptr<mojo::ShellClient> MojoMediaApplication::CreateAppWithClient( + const CreateMojoMediaClientCB& create_mojo_media_client_cb) { + scoped_ptr<MojoMediaClient> mojo_media_client = + create_mojo_media_client_cb.Run(); + if (!mojo_media_client) + return nullptr; + + return scoped_ptr<mojo::ShellClient>( + new MojoMediaApplication(std::move(mojo_media_client))); } // TODO(xhwang): Hook up MediaLog when possible. @@ -25,14 +49,15 @@ MojoMediaApplication::MojoMediaApplication( scoped_ptr<MojoMediaClient> mojo_media_client) : mojo_media_client_(std::move(mojo_media_client)), shell_(nullptr), - media_log_(new MediaLog()) {} - -MojoMediaApplication::~MojoMediaApplication() { + media_log_(new MediaLog()) { + DCHECK(mojo_media_client_); } +MojoMediaApplication::~MojoMediaApplication() {} + void MojoMediaApplication::Initialize(mojo::Shell* shell, - const std::string& url, - uint32_t id) { + const std::string& /* url */, + uint32_t /* id */) { shell_ = shell; mojo_media_client_->Initialize(); } diff --git a/media/mojo/services/mojo_media_application.h b/media/mojo/services/mojo_media_application.h index 71b1e06..c1e24df 100644 --- a/media/mojo/services/mojo_media_application.h +++ b/media/mojo/services/mojo_media_application.h @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/callback.h" #include "base/memory/ref_counted.h" #include "media/mojo/interfaces/service_factory.mojom.h" #include "mojo/shell/public/cpp/interface_factory_impl.h" @@ -17,12 +18,22 @@ class MojoMediaApplication : public mojo::ShellClient, public mojo::InterfaceFactory<interfaces::ServiceFactory> { public: + // Callback to create a MojoMediaClient. + using CreateMojoMediaClientCB = base::Callback<scoped_ptr<MojoMediaClient>()>; + + // Creates MojoMediaApplication using the default MojoMediaClient. static scoped_ptr<mojo::ShellClient> CreateApp(); - explicit MojoMediaApplication(scoped_ptr<MojoMediaClient> mojo_media_client); + // Creates MojoMediaApplication using the MojoMediaClient provided by + // |create_mojo_media_client_cb|. + static scoped_ptr<mojo::ShellClient> CreateAppWithClient( + const CreateMojoMediaClientCB& create_mojo_media_client_cb); + ~MojoMediaApplication() final; private: + explicit MojoMediaApplication(scoped_ptr<MojoMediaClient> mojo_media_client); + // mojo::ShellClient implementation. void Initialize(mojo::Shell* shell, const std::string& url, @@ -33,7 +44,11 @@ class MojoMediaApplication void Create(mojo::Connection* connection, mojo::InterfaceRequest<interfaces::ServiceFactory> request) final; + // Note: Since each instance runs on a different thread, do not share a common + // MojoMediaClient with other instances to avoid threading issues. Hence using + // a scoped_ptr here. scoped_ptr<MojoMediaClient> mojo_media_client_; + mojo::Shell* shell_; scoped_refptr<MediaLog> media_log_; }; diff --git a/media/mojo/services/mojo_media_client.h b/media/mojo/services/mojo_media_client.h index 4e4d39b..2798aaa 100644 --- a/media/mojo/services/mojo_media_client.h +++ b/media/mojo/services/mojo_media_client.h @@ -5,13 +5,16 @@ #ifndef MEDIA_MOJO_SERVICES_MOJO_MEDIA_CLIENT_H_ #define MEDIA_MOJO_SERVICES_MOJO_MEDIA_CLIENT_H_ -#include "base/single_thread_task_runner.h" #include "media/base/audio_renderer_sink.h" #include "media/base/cdm_factory.h" #include "media/base/media_log.h" #include "media/base/renderer_factory.h" #include "media/base/video_renderer_sink.h" +namespace base { +class SingleThreadTaskRunner; +} + namespace mojo { namespace shell { namespace mojom { @@ -26,8 +29,6 @@ class MojoMediaClient { public: virtual ~MojoMediaClient(); - static scoped_ptr<MojoMediaClient> Create(); - // Called exactly once before any other method. virtual void Initialize(); // Returns the RendererFactory to be used by MojoRendererService. If returns diff --git a/media/mojo/services/mojo_renderer_factory.h b/media/mojo/services/mojo_renderer_factory.h index 06d6447..5e0610c 100644 --- a/media/mojo/services/mojo_renderer_factory.h +++ b/media/mojo/services/mojo_renderer_factory.h @@ -6,7 +6,6 @@ #define MEDIA_MOJO_SERVICES_MOJO_RENDERER_FACTORY_H_ #include "base/macros.h" -#include "media/base/media_export.h" #include "media/base/renderer_factory.h" #include "media/mojo/interfaces/renderer.mojom.h" #include "mojo/public/cpp/bindings/interface_ptr.h" |