1 // Copyright 2015 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 module media_router.interfaces;
7 // Represents an output sink to which media can be routed.
9 // The sink identifier, e.g. "rs71w7mFzYLFlabir_qO4NHl6SUc."
11 // The human-readable name, e.g. "Janet's Chromecast".
15 // Should be kept in sync with media_route.h.
17 // The ID of this media route, e.g. "r_PR1O_blkC9dsKp-tb1ti8qurOo".
18 string media_route_id;
19 // The ID of the media source being sent through this media route.
20 // May be missing if route is not local.
22 // The sink that is rendering the media content.
24 // Human readable description of this route, e.g.
27 // Specifies that the route is requested locally.
31 // Notifications or an actionable events to be shown to the user.
32 // When is_blocking is true, media router UI shows issue only:
36 // default_action_button secondary_action_button
38 // When is_blocking is false, media router UI uses banner:
40 // Title default_action_link secondary_action_link
42 // above receiver list if route_id is not provided; otherwise it is
43 // above route detail and controls.
58 // If set, the ID of the route to which this issue pertains.
59 // If not set (default), then this is a global issue.
64 // When true, the issue must be presented to the user and resolved
65 // before other actions are allowed.
68 // Short description about the issue.
71 // Message about issue detail or how to handle issue.
72 // Messages should be suitable for end users to decide which actions to take.
75 ActionType default_action;
77 array<ActionType>? secondary_actions;
79 // A help page to be opened if users select learn_more.
88 // The route ID of this message.
90 // The type of this message.
92 // Used when the |type| is TEXT.
94 // Used when the |type| is BINARY.
98 // Modeled after the MediaRouter interface defined in
99 // chrome/browser/media/router/media_router.h
100 interface MediaRouter {
101 // Initiates a media route from |media_source| to |sink_id|.
102 // The presentation ID of the route created will be |presentation_id|, but it
103 // may be overridden by a provider implementation. The presentation ID will
104 // be used by the presentation API to refer to the created route.
105 // |origin| and |tab_id| may be passed in for enforcing same-origin and/or
107 // Since int types cannot be made optional, use -1 as |tab_id| in cases where
108 // it is not applicable.
109 // If the operation was successful, |route| will be defined and
110 // |error_text| will be null.
111 // If the operation failed, |route| will be null and |error_text|
113 CreateRoute(string media_source,
115 string original_presentation_id,
117 int32 tab_id) => (MediaRoute? route, string? error_text);
119 // Joins an established route given by |presentation_id|
120 // with |media_source|.
121 // |origin| and |tab_id| are used for validating same-origin/tab scopes.
122 // (See CreateRoute for additional documentation)
123 // If the operation was successful, |route| will be defined and
124 // |error_text| will be null.
125 // If the operation failed, |route| will be null and |error_text|
127 JoinRoute(string media_source,
128 string presentation_id,
130 int32 tab_id) => (MediaRoute? route, string? error_text);
132 // Closes the route specified by |route_id|.
133 CloseRoute(string route_id);
135 // Sends |message| via the media route |media_route_id|.
136 // If the operation was successful, |sent| is true; otherwise it is false.
137 SendRouteMessage(string media_route_id, string message) => (bool sent);
139 // Starts querying for sinks capable of displaying |media_source|.
140 StartObservingMediaSinks(string media_source);
142 // Stops querying sinks for |media_source|.
143 StopObservingMediaSinks(string media_source);
145 // Starts reporting the state of active media routes via
146 // OnRoutesUpdated(). Querying will continue until
147 // StopObservingMediaRoutes() is called.
148 StartObservingMediaRoutes();
150 // Stops querying the state of all media routes.
151 StopObservingMediaRoutes();
153 // "Clears" an issue after it is addressed.
154 ClearIssue(string issue_id);
156 // Called when the MediaRouter is ready to get the next batch of messages
157 // associated with one of the |route_ids|.
158 ListenForRouteMessages(array<string> route_ids)
159 => (array<RouteMessage> messages);
162 // Interface for a service which observes state changes across media
163 // sources, sinks, and issues.
164 interface MediaRouterObserver {
165 // Registers MediaRouter functionality with the remote end.
166 // Allows the browser-side MediaRouter to dispatch MediaRouter methods
168 // Returns a string that uniquely identifies the Media Router browser
170 ProvideMediaRouter(MediaRouter media_router) => (string instance_id);
172 // Called when the Media Route Manager receives a new list of sinks.
173 OnSinksReceived(string media_source, array<MediaSink> sinks);
175 // Called when issues are reported for media routes.
176 OnIssue(Issue issue);
178 // Called when list of routes has been updated.
179 OnRoutesUpdated(array<MediaRoute> routes);