Commit 654644c8 authored by kmarshall's avatar kmarshall Committed by Commit bot

Upstreaming review for Media Router Mojo interface.

R=xhwang@chromium.org
BUG=464205

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

Cr-Commit-Position: refs/heads/master@{#327387}
parent 890b6874
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
# #
import("//testing/test.gni") import("//testing/test.gni")
import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
source_set("router") { source_set("router") {
deps = [ deps = [
...@@ -66,6 +67,12 @@ source_set("unit_tests") { ...@@ -66,6 +67,12 @@ source_set("unit_tests") {
] ]
} }
mojom("mojo_bindings") {
sources = [
"media_router.mojom",
]
}
# Optional standalone test binary, for faster isolated builds. # Optional standalone test binary, for faster isolated builds.
test("unit_tests_main") { test("unit_tests_main") {
deps = [ deps = [
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
'<(DEPTH)', '<(DEPTH)',
], ],
'dependencies': [ 'dependencies': [
':media_router_mojo',
'<(DEPTH)/base/base.gyp:base', '<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/url/url.gyp:url_lib', '<(DEPTH)/url/url.gyp:url_lib',
], ],
...@@ -38,5 +39,16 @@ ...@@ -38,5 +39,16 @@
'route_id_manager.h', 'route_id_manager.h',
], ],
}, },
{
# Mojo compiler for the Media Router internal API.
'target_name': 'media_router_mojo',
'type': 'none',
'sources': [
'media_router.mojom',
],
'includes': [
'../../../../third_party/mojo/mojom_bindings_generator.gypi',
],
},
], ],
} }
// Copyright 2015 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.
module media_router.interfaces;
// Represents an output sink to which media can be routed.
struct MediaSink {
// The sink identifier, e.g. "rs71w7mFzYLFlabir_qO4NHl6SUc."
string sink_id;
// The human-readable name, e.g. "Janet's Chromecast".
string name;
};
// Should be kept in sync with media_route.h.
struct MediaRoute {
// The ID of this media route, e.g. "r_PR1O_blkC9dsKp-tb1ti8qurOo".
string media_route_id;
// The ID of the media source being sent through this media route.
// May be missing if route is not local.
string? media_source;
// The sink that is rendering the media content.
MediaSink media_sink;
// Human readable description of this route, e.g.
// "Tab casting".
string description;
// An icon that is associated with this media source.
string? icon_url;
// Specifies that the route is requested locally.
bool is_local;
};
// Notifications or an actionable events to be shown to the user.
// When is_blocking is true, media router UI shows issue only:
//
// Title
// Message
// default_action_button secondary_action_button
//
// When is_blocking is false, media router UI uses banner:
//
// Title default_action_link secondary_action_link
//
// above receiver list if route_id is not provided; otherwise it is
// above route detail and controls.
struct Issue {
enum Severity {
FATAL,
WARNING,
NOTIFICATION
};
enum ActionType {
OK,
CANCEL,
DISMISS,
LEARN_MORE
};
// If set, the ID of the route to which this issue pertains.
// If not set (default), then this is a global issue.
string? route_id;
Severity severity;
// When true, the issue must be presented to the user and resolved
// before other actions are allowed.
bool is_blocking;
// Short description about the issue.
string title;
// Message about issue detail or how to handle issue.
// Messages should be suitable for end users to decide which actions to take.
string? message;
ActionType default_action;
array<ActionType>? secondary_actions;
// A help page to be opened if users select learn_more.
string? help_url;
};
// Modeled after the MediaRouter interface defined in
// chrome/browser/media/router/media_router.h
interface MediaRouter {
// Initiates a media route from |media_source| to |sink_id|.
// If the operation was successful, |route| will be defined and
// |error_text| will be null.
// If the operation failed, |route| will be null and |error_text|
// will be set.
CreateRoute(string media_source, string sink_id) =>
(MediaRoute? route, string? error_text);
// Closes the route specified by |route_id|.
CloseRoute(string route_id);
// Sends |message| with optional |extra_info_json| via the media route
// |media_route_id|.
PostMessage(string media_route_id, string message);
// Starts querying for sinks capable of displaying |media_source|.
StartObservingMediaSinks(string media_source);
// Stops querying sinks for |media_source|.
StopObservingMediaSinks(string media_source);
// Starts reporting the state of active media routes via
// OnRoutesUpdated(). Querying will continue until
// StopObservingMediaRoutes() is called.
StartObservingMediaRoutes();
// Stops querying the state of all media routes.
StopObservingMediaRoutes();
// "Clears" an issue after it is addressed.
ClearIssue(string issue_id);
};
// Interface for a service which observes state changes across media
// sources, sinks, and issues.
interface MediaRouterObserver {
// Registers MediaRouter functionality with the remote end.
// Allows the browser-side MediaRouter to dispatch MediaRouter methods
// to providers.
// Returns a string that uniquely identifies the Media Router browser
// process.
ProvideMediaRouter(MediaRouter media_router) => (string instance_id);
// Called when the Media Route Manager receives a new list of sinks.
OnSinksReceived(string media_source, array<MediaSink> sinks);
// Called when the Media Route Manager receives a route message.
OnMessage(string media_source, string message);
// Called when issues are reported for media routes.
OnIssue(Issue issue);
// Called when list of routes has been updated.
OnRoutesUpdated(array<MediaRoute> routes);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment