Skip to content

Commit

Permalink
media: Make media mojo services a component
Browse files Browse the repository at this point in the history
Previously media mojo services are in multiple small source_sets. This
was okay when they are only depended by one target (i.e. content). But
now we have multiple targets depending on them. For example, content and
media/gpu both depend on cdm_services. This causes duplicate definition
of some global veriables, e.g. g_cdm_manager in mojo_cdm_service.cc.

TBR=jam@chromium.org
BUG=610904
TEST=EME playback works.

Review-Url: https://codereview.chromium.org/1968833002
Cr-Commit-Position: refs/heads/master@{#394323}
  • Loading branch information
xhwang-chromium authored and Commit bot committed May 18, 2016
1 parent 29952fa commit d3b5d3f
Show file tree
Hide file tree
Showing 20 changed files with 92 additions and 112 deletions.
2 changes: 1 addition & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ group("gn_mojo_targets") {
deps = [
"//ipc/mojo:ipc_mojo_perftests",
"//media/mojo:tests",
"//media/mojo/services:cdm_service",
"//media/mojo/services",
"//mojo:tests",
]
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ source_set("browser") {
]
deps += [ "//media/mojo/interfaces" ]
if (mojo_media_host == "browser") {
deps += [ "//media/mojo/services:application_factory" ]
deps += [ "//media/mojo/services" ]
}
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
#endif

#if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
#include "media/mojo/services/mojo_media_application_factory.h"
#include "media/mojo/services/mojo_media_application_factory.h" // nogncheck
#endif

using base::FileDescriptor;
Expand Down
2 changes: 1 addition & 1 deletion chromecast/browser/media/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ source_set("media") {
if (mojo_media_host == "browser") {
public_deps = [
"//media/mojo/interfaces",
"//media/mojo/services:application",
"//media/mojo/services",
"//services/shell/public/cpp",
]
}
Expand Down
3 changes: 1 addition & 2 deletions content/gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ source_set("gpu_sources") {
"//ipc",
"//media/gpu",
"//media/gpu/ipc/service",
"//media/mojo/services:application_factory",
"//services/shell/public/interfaces",
"//skia",
"//ui/events/ipc",
Expand All @@ -67,7 +66,7 @@ source_set("gpu_sources") {
]

if (mojo_media_host == "gpu") {
deps += [ "//media/mojo/services:application_factory" ]
deps += [ "//media/mojo/services" ]
if (is_android) {
deps += [ "//media/base/android" ]
}
Expand Down
2 changes: 1 addition & 1 deletion content/gpu/gpu_process_control_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "content/public/common/content_client.h"
#include "media/mojo/services/mojo_media_application_factory.h"
#include "media/mojo/services/mojo_media_application_factory.h" // nogncheck
#if defined(OS_ANDROID)
#include "media/base/android/media_client_android.h"
#endif
Expand Down
3 changes: 1 addition & 2 deletions content/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ static_library("content_shell_lib") {
"//gpu",
"//ipc",
"//media",
"//media/mojo/services:application_factory",
"//net",
"//net:net_resources",
"//skia",
Expand Down Expand Up @@ -266,7 +265,7 @@ static_library("content_shell_lib") {
]
}
if (mojo_media_host == "browser") {
deps += [ "//media/mojo/services:application_factory" ]
deps += [ "//media/mojo/services" ]
}

if (is_win) {
Expand Down
2 changes: 1 addition & 1 deletion content/shell/browser/shell_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#endif

#if defined(ENABLE_MOJO_MEDIA_IN_BROWSER_PROCESS)
#include "media/mojo/services/mojo_media_application_factory.h"
#include "media/mojo/services/mojo_media_application_factory.h" // nogncheck
#endif

namespace content {
Expand Down
3 changes: 1 addition & 2 deletions content/utility/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ source_set("utility") {
"//content/public/child:child_sources",
"//content/public/common:common_sources",
"//courgette:courgette_lib",
"//media/mojo/services:application_factory",
"//mojo/common",
"//mojo/public/cpp/bindings",
"//services/shell",
Expand All @@ -37,7 +36,7 @@ source_set("utility") {
]

if (mojo_media_host == "utility") {
deps += [ "//media/mojo/services:application_factory" ]
deps += [ "//media/mojo/services" ]
}
}

Expand Down
2 changes: 1 addition & 1 deletion content/utility/utility_process_control_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "content/utility/utility_thread_impl.h"

#if defined(ENABLE_MOJO_MEDIA_IN_UTILITY_PROCESS)
#include "media/mojo/services/mojo_media_application_factory.h"
#include "media/mojo/services/mojo_media_application_factory.h" // nogncheck
#endif

namespace content {
Expand Down
5 changes: 4 additions & 1 deletion media/gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,11 @@ component("gpu") {
]
}

# TODO(xhwang): This is needed for AVDA to access the CDM directly.
# Remove this dependency after VDAs are also running as part of the mojo
# media application. See http://crbug.com/522298
if (mojo_media_host == "gpu") {
deps += [ "//media/mojo/services:cdm_service" ]
deps += [ "//media/mojo/services" ]
}
}

Expand Down
2 changes: 1 addition & 1 deletion media/mojo/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test("media_mojo_unittests") {
"//media/base:test_support",
"//media/mojo/common",
"//media/mojo/interfaces",
"//media/mojo/services:cdm_service",
"//media/mojo/services",
"//mojo/edk/system",
"//mojo/edk/test:run_all_unittests",
"//testing/gmock",
Expand Down
118 changes: 30 additions & 88 deletions media/mojo/services/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,14 @@ source_set("proxy") {
]
}

source_set("cdm_service") {
deps = [
"//base",
"//media",
"//media/mojo/common",
"//media/mojo/interfaces",
"//mojo/common",
"//mojo/public/c/system:for_component",
"//services/shell/public/interfaces",
"//url",
]
component("services") {
output_name = "media_mojo_services"

sources = [
"demuxer_stream_provider_shim.cc",
"demuxer_stream_provider_shim.h",
"mojo_audio_decoder_service.cc",
"mojo_audio_decoder_service.h",
"mojo_cdm_allocator.cc",
"mojo_cdm_allocator.h",
"mojo_cdm_promise.cc",
Expand All @@ -107,103 +102,50 @@ source_set("cdm_service") {
"mojo_cdm_service_context.h",
"mojo_decryptor_service.cc",
"mojo_decryptor_service.h",
"mojo_type_trait.h",
]

if (is_android) {
sources += [
"mojo_provision_fetcher.cc",
"mojo_provision_fetcher.h",
]
}

# TODO(xhwang): Needed because targets can depend on cdm_service directly,
# which is a bit hacky since we need to access CdmService directly
# from C++ code (AVDA). In the future we'll make those decoders part of
# MojoMediaApplication, then we won't need this.
public_configs = [ ":mojo_media_config" ]

configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
}

source_set("audio_decoder_service") {
sources = [
"mojo_audio_decoder_service.cc",
"mojo_audio_decoder_service.h",
]

deps = [
":cdm_service",
"//base",
"//media",
"//media:shared_memory_support",
"//media/mojo/common",
"//media/mojo/interfaces",
"//mojo/common",
]
}

source_set("renderer_service") {
sources = [
"demuxer_stream_provider_shim.cc",
"demuxer_stream_provider_shim.h",
"mojo_demuxer_stream_adapter.cc",
"mojo_demuxer_stream_adapter.h",
"mojo_renderer_service.cc",
"mojo_renderer_service.h",
]

deps = [
":cdm_service",
"//base",
"//media",
"//media:shared_memory_support",
"//media/mojo/common",
"//media/mojo/interfaces",
"//mojo/common",
]
}

source_set("application") {
sources = [
"mojo_media_application.cc",
"mojo_media_application.h",
"mojo_media_application_factory.cc",
"mojo_media_application_factory.h",
"mojo_media_client.cc",
"mojo_media_client.h",
"mojo_renderer_service.cc",
"mojo_renderer_service.h",
"mojo_type_trait.h",
"service_factory_impl.cc",
"service_factory_impl.h",
]

defines = [ "MEDIA_MOJO_IMPLEMENTATION" ]

# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
public_configs = [ ":mojo_media_config" ]

deps = [
":audio_decoder_service",
":cdm_service",
":renderer_service",
"//base",
"//media",
"//media:shared_memory_support",
"//media/mojo/common",
"//media/mojo/interfaces",
"//mojo/common",
"//mojo/public/c/system:for_component",
"//services/shell/public/cpp",
]
}

source_set("application_factory") {
sources = [
"mojo_media_application_factory.cc",
"mojo_media_application_factory.h",
]

public_configs = [ ":mojo_media_config" ]

deps = [
":application",
"//base",
"//media",
"//services/shell/public/cpp:sources",
"//services/shell/public/interfaces",
"//url",
]

if (is_android) {
sources += [
"mojo_provision_fetcher.cc",
"mojo_provision_fetcher.h",
]
}

if (enable_test_mojo_media_client) {
defines = [ "ENABLE_TEST_MOJO_MEDIA_CLIENT" ]
defines += [ "ENABLE_TEST_MOJO_MEDIA_CLIENT" ]
sources += [
"test_mojo_media_client.cc",
"test_mojo_media_client.h",
Expand Down Expand Up @@ -231,7 +173,7 @@ mojo_native_application("media") {
]

deps = [
":application",
":services",
"//base",
"//media",
"//mojo/logging",
Expand Down
32 changes: 32 additions & 0 deletions media/mojo/services/media_mojo_export.h
Original file line number Diff line number Diff line change
@@ -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 MEDIA_MOJO_MEDIA_MOJO_EXPORT_H_
#define MEDIA_MOJO_MEDIA_MOJO_EXPORT_H_

// Define MEDIA_MOJO_EXPORT so that functionality implemented by the
// media/mojo module can be exported to consumers.

#if defined(COMPONENT_BUILD)
#if defined(WIN32)

#if defined(MEDIA_MOJO_IMPLEMENTATION)
#define MEDIA_MOJO_EXPORT __declspec(dllexport)
#else
#define MEDIA_MOJO_EXPORT __declspec(dllimport)
#endif // defined(MEDIA_IMPLEMENTATION)

#else // defined(WIN32)
#if defined(MEDIA_MOJO_IMPLEMENTATION)
#define MEDIA_MOJO_EXPORT __attribute__((visibility("default")))
#else
#define MEDIA_MOJO_EXPORT
#endif
#endif

#else // defined(COMPONENT_BUILD)
#define MEDIA_MOJO_EXPORT
#endif

#endif // MEDIA_MOJO_MEDIA_MOJO_EXPORT_H_
3 changes: 2 additions & 1 deletion media/mojo/services/mojo_cdm_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
#include "media/cdm/cdm_allocator.h"
#include "media/mojo/services/media_mojo_export.h"
#include "mojo/public/cpp/system/buffer.h"

namespace media {

// This is a CdmAllocator that creates buffers using mojo shared memory.
// The internal logic is similar to ppapi_cdm_buffer.cc.
class MojoCdmAllocator : public CdmAllocator {
class MEDIA_MOJO_EXPORT MojoCdmAllocator : public CdmAllocator {
public:
MojoCdmAllocator();
~MojoCdmAllocator() final;
Expand Down
3 changes: 2 additions & 1 deletion media/mojo/services/mojo_cdm_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/memory/weak_ptr.h"
#include "media/base/media_keys.h"
#include "media/mojo/interfaces/content_decryption_module.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
#include "media/mojo/services/mojo_cdm_promise.h"
#include "media/mojo/services/mojo_cdm_service_context.h"
#include "media/mojo/services/mojo_decryptor_service.h"
Expand All @@ -36,7 +37,7 @@ class MojoCdmService : public mojom::ContentDecryptionModule {
// render frame the caller is associated with. In the future, we should move
// all out-of-process media players into the MojoMediaApplicaiton so that we
// can use MojoCdmServiceContext (per render frame) to get the CDM.
static scoped_refptr<MediaKeys> LegacyGetCdm(int cdm_id);
static scoped_refptr<MediaKeys> MEDIA_MOJO_EXPORT LegacyGetCdm(int cdm_id);

// Constructs a MojoCdmService and strongly binds it to the |request|.
MojoCdmService(
Expand Down
8 changes: 5 additions & 3 deletions media/mojo/services/mojo_media_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#include <memory>

#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "media/mojo/interfaces/service_factory.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
#include "services/shell/public/cpp/interface_factory.h"
#include "services/shell/public/cpp/shell_client.h"
#include "services/shell/public/cpp/shell_connection_ref.h"
Expand All @@ -22,9 +24,9 @@ namespace media {
class MediaLog;
class MojoMediaClient;

class MojoMediaApplication
: public shell::ShellClient,
public shell::InterfaceFactory<mojom::ServiceFactory> {
class MEDIA_MOJO_EXPORT MojoMediaApplication
: public NON_EXPORTED_BASE(shell::ShellClient),
public NON_EXPORTED_BASE(shell::InterfaceFactory<mojom::ServiceFactory>) {
public:
MojoMediaApplication(std::unique_ptr<MojoMediaClient> mojo_media_client,
const base::Closure& quit_closure);
Expand Down
Loading

0 comments on commit d3b5d3f

Please sign in to comment.