Skip to content

Commit

Permalink
media: scaffolding and plumbing for MojoRenderer{Impl, Service}
Browse files Browse the repository at this point in the history
* Add skeleton client-side and service-side MediaRenderer pieces with basic plumbing and connections but no real logic.
* model a media::DemuxerStream in a mojom to clean up MediaRenderer interface and line-up with RendererImpl expectations.
* add DecoderConfig plumbing support
* add a basic unittest verifying things do actually hook up
* consolidate around 'media_mojo_' naming in media.gyp and add media_mojo target to build all this stuff.

BUG=410451

Review URL: https://codereview.chromium.org/551963004

Cr-Commit-Position: refs/heads/master@{#295579}
  • Loading branch information
tim authored and Commit bot committed Sep 18, 2014
1 parent 48f08c4 commit 09f86c0
Show file tree
Hide file tree
Showing 21 changed files with 1,426 additions and 36 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ group("root") {
"//media",
"//media/blink",
"//media/cast",
"//media/mojo",
"//mojo",
"//net",
"//pdf",
Expand Down
71 changes: 64 additions & 7 deletions media/media.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,11 +1016,12 @@
},
{
# GN version: //media/mojo/interfaces
'target_name': 'mojo_media_bindings',
'target_name': 'media_mojo_bindings',
'type': 'static_library',
'sources': [
'mojo/interfaces/media_types.mojom',
'mojo/interfaces/media_renderer.mojom',
'mojo/interfaces/demuxer_stream.mojom',
],
'includes': [
'../mojo/public/tools/bindings/mojom_bindings_generator.gypi'
Expand All @@ -1033,33 +1034,57 @@
],
},
{
'target_name': 'mojo_media_lib',
'target_name': 'media_mojo_lib',
'type': 'static_library',
'includes': [
'../mojo/mojo_variables.gypi',
],
'dependencies': [
'media',
'mojo_media_bindings',
'media_mojo_bindings',
'../base/base.gyp:base',
'../mojo/mojo_base.gyp:mojo_environment_chromium',
'<(mojo_system_for_component)',
],
'export_dependent_settings': [
'mojo_media_bindings',
'media_mojo_bindings',
],
'sources': [
'mojo/services/media_type_converters.cc',
'mojo/services/media_type_converters.h',
'mojo/services/mojo_demuxer_stream_impl.cc',
'mojo/services/mojo_demuxer_stream_impl.h',
'mojo/services/mojo_renderer_impl.cc',
'mojo/services/mojo_renderer_impl.h',
],
},
{
'target_name': 'mojo_media_lib_unittests',
'target_name': 'media_mojo_renderer_app',
'type': 'loadable_module',
'includes': [
'../mojo/mojo_variables.gypi',
],
'dependencies': [
'../base/base.gyp:base',
'../mojo/mojo_base.gyp:mojo_application_chromium',
'<(mojo_system_for_loadable_module)',
'media_mojo_lib',
'shared_memory_support',
],
'sources': [
'mojo/services/mojo_demuxer_stream_adapter.cc',
'mojo/services/mojo_demuxer_stream_adapter.h',
'mojo/services/mojo_renderer_service.cc',
'mojo/services/mojo_renderer_service.h',
],
},
{
'target_name': 'media_mojo_lib_unittests',
'type': '<(gtest_target_type)',
'dependencies': [
'media',
'mojo_media_bindings',
'mojo_media_lib',
'media_mojo_bindings',
'media_mojo_lib',
'../base/base.gyp:base',
'../base/base.gyp:test_support_base',
'../testing/gtest.gyp:gtest',
Expand All @@ -1069,7 +1094,39 @@
'sources': [
'mojo/services/media_type_converters_unittest.cc',
],
},
{
'target_name': 'media_mojo_renderer_apptest',
'type': 'loadable_module',
'includes': [
'../mojo/mojo_variables.gypi',
],
'dependencies': [
'media',
'media_mojo_bindings',
'media_mojo_lib',
'media_mojo_renderer_app',
'media_test_support',
'../base/base.gyp:base',
'../base/base.gyp:test_support_base',
'../testing/gtest.gyp:gtest',
'../mojo/mojo_base.gyp:mojo_application_chromium',
'<(mojo_system_for_loadable_module)',
],
'sources': [
'mojo/services/renderer_unittest.cc',
],
},
{
'target_name': 'media_mojo',
'type': 'none',
'dependencies': [
'media_mojo_lib',
'media_mojo_lib_unittests',
'media_mojo_renderer_app',
'media_mojo_renderer_apptest',
]
},
{
# GN version: //media:media_unittests
'target_name': 'media_unittests',
Expand Down
17 changes: 17 additions & 0 deletions media/mojo/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.

group("mojo") {
public_deps = [
"//media/mojo/interfaces",
"//media/mojo/services",
]
}

group("tests") {
testonly = true
deps = [
"//media/mojo/services:tests"
]
}
1 change: 1 addition & 0 deletions media/mojo/DEPS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include_rules = [
"+mojo/application",
"+mojo/public",
]
3 changes: 2 additions & 1 deletion media/mojo/interfaces/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import("//mojo/public/tools/bindings/mojom.gni")

# GYP version: media/media.gyp:mojo_media_bindings
mojom("media") {
mojom("interfaces") {
sources = [
"media_types.mojom",
"media_renderer.mojom",
"demuxer_stream.mojom",
]
}
54 changes: 54 additions & 0 deletions media/mojo/interfaces/demuxer_stream.mojom
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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.

import "media/mojo/interfaces/media_types.mojom"

module mojo {

// DemuxerStream is modeled after media::DemuxerStream using mojo in order to
// enable proxying between a media::Pipeline and media::Renderer living in two
// different applications.
[Client=DemuxerStreamClient]
interface DemuxerStream {
// See media::DemuxerStream for descriptions.
enum Type {
UNKNOWN,
AUDIO,
LAST_TYPE = AUDIO
};

// See media::DemuxerStream for descriptions.
enum Status {
OK = 0,
ABORTED,
CONFIG_CHANGED,
};

// Request a MediaDecoderBuffer from this stream for decoding and rendering.
// When available, the callback will be invoked with a Status and |response|
// buffer. See media::DemuxerStream::ReadCB for explanation of fields.
//
// TODO(tim): Remove this method in favor of initializing the
// DemuxerStreamClient with a DataPipeConsumerHandle once we have a framed
// DataPipe that we can serialize [|status| | response|]* over directly.
Read() => (Status status, MediaDecoderBuffer response);
};

interface DemuxerStreamClient {
// Informs the client that the stream is ready for reading. If |pipe| is
// present, it means the client should read
//
// [ |DemuxerStream::Status| |MediaDecoderBuffer| ]
//
// payloads from the DataPipe directly. If |pipe| is NULL, it means the
// client needs to use DemuxerStream::Read() directly to obtain buffers.
OnStreamReady(handle<data_pipe_consumer>? pipe);

// A new AudioDecoderConfig is available. Will be sent by the DemuxerStream
// whenever a DemuxerStream::STATUS_CONFIG_CHANGED is observed (either
// in a Read() callback or over the DataPipe).
OnAudioDecoderConfigChanged(AudioDecoderConfig config);
};

} // module mojo
13 changes: 3 additions & 10 deletions media/mojo/interfaces/media_renderer.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import "media/mojo/interfaces/demuxer_stream.mojom"
import "media/mojo/interfaces/media_types.mojom"

module mojo {

[Client=MediaRendererClient]
interface MediaRenderer {
// Initializes the Renderer, calling back upon completion.
// Initializes the Renderer with |stream|, calling back upon completion.
// NOTE: If an error occurs, MediaRendererClient::OnError() will be called
// before the callback is executed.
Initialize() => ();

// Decodes and renders |buffer|, calling back when more data is required.
// NOTE: If an error occurs, MediaRendererClient::OnError() will be called
// before the callback is executed.
// TODO(tim): Switch decoding model to use framed data pipe when available.
// In that world, the signalling for more would be implicit by a writable
// pipe handle on the client side so this entire method + callback goes away.
DecodeAndRender(MediaDecoderBuffer buffer) => ();
Initialize(DemuxerStream stream) => ();

// Discards any buffered data, executing callback when completed.
// NOTE: If an error occurs, MediaRendererClient::OnError() can be called
Expand Down
94 changes: 87 additions & 7 deletions media/mojo/interfaces/media_types.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,98 @@

module mojo {

// See media/base/buffering_state.h for descriptions.
// Kept in sync with media::BufferingState via COMPILE_ASSERTs.
enum BufferingState {
// Indicates that there is no data buffered.
//
// Typical reason is data underflow and hence playback should be paused.
HAVE_NOTHING,

// Indicates that enough data has been buffered.
//
// Typical reason is enough data has been prerolled to start playback.
HAVE_ENOUGH,
};

// See media/base/audio_decoder_config.h for descriptions.
// Kept in sync with media::AudioCodec via COMPILE_ASSERTs.
enum AudioCodec {
UNKNOWN = 0,
AAC = 1,
MP3 = 2,
PCM = 3,
Vorbis = 4,
FLAC = 5,
AMR_NB = 6,
AMR_WB = 7,
PCM_MULAW = 8,
GSM_MS = 9,
PCM_S16BE = 10,
PCM_S24BE = 11,
Opus = 12,
// EAC3 = 13,
PCM_ALAW = 14,
MAX = PCM_ALAW,
};

// See media/base/channel_layout.h for descriptions.
// Kept in sync with media::ChannelLayout via COMPILE_ASSERTs.
// TODO(tim): The bindings generators will always prepend the enum name, should
// mojom therefore allow enum values starting with numbers?
enum ChannelLayout {
k_NONE = 0,
k_UNSUPPORTED = 1,
k_MONO = 2,
k_STEREO = 3,
k_2_1 = 4,
k_SURROUND = 5,
k_4_0 = 6,
k_2_2 = 7,
k_QUAD = 8,
k_5_0 = 9,
k_5_1 = 10,
k_5_0_BACK = 11,
k_5_1_BACK = 12,
k_7_0 = 13,
k_7_1 = 14,
k_7_1_WIDE = 15,
k_STEREO_DOWNMIX = 16,
k_2POINT1 = 17,
k_3_1 = 18,
k_4_1 = 19,
k_6_0 = 20,
k_6_0_FRONT = 21,
k_HEXAGONAL = 22,
k_6_1 = 23,
k_6_1_BACK = 24,
k_6_1_FRONT = 25,
k_7_0_FRONT = 26,
k_7_1_WIDE_BACK = 27,
k_OCTAGONAL = 28,
k_DISCRETE = 29,
k_STEREO_AND_KEYBOARD_MIC = 30,
k_MAX = k_STEREO_AND_KEYBOARD_MIC
};

// See media/base/sample_format.h for descriptions.
// Kept in sync with media::SampleFormat via COMPILE_ASSERTs.
enum SampleFormat {
UNKNOWN = 0,
U8,
S16,
S32,
F32,
PlanarS16,
PlanarF32,
Max = PlanarF32,
};

// This defines a mojo transport format for media::AudioDecoderConfig.
// See media/base/audio_decoder_config.h for descriptions.
struct AudioDecoderConfig {
AudioCodec codec;
SampleFormat sample_format;
ChannelLayout channel_layout;
int32 samples_per_second;
uint8[]? extra_data;
int64 seek_preroll_usec;
int32 codec_delay;
};

// This defines a mojo transport format for media::DecoderBuffer.
struct MediaDecoderBuffer {
// See media/base/buffers.h for details.
Expand Down
Loading

0 comments on commit 09f86c0

Please sign in to comment.