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.
16 // The sink identifier, e.g. "rs71w7mFzYLFlabir_qO4NHl6SUc."
18 // The human-readable name, e.g. "Janet's Chromecast".
20 // The type of icon to show in the UI for this media sink.
22 // True if a route is being created to this sink.
26 // Should be kept in sync with media_route.h.
28 // The ID of this media route, e.g. "r_PR1O_blkC9dsKp-tb1ti8qurOo".
29 string media_route_id;
30 // The ID of the media source being sent through this media route.
31 // May be missing if route is not local.
33 // The ID of sink that is rendering the media content.
35 // Human readable description of this route, e.g.
38 // Specifies that the route is requested locally.
40 // An optional path to an HTML page bundled bundled with the media router
41 // component extension. When set, the route can have custom route detail as
42 // well as its own route controls in the media router dialog.
43 string? custom_controller_path;
44 // Set to true if this route should be displayed for |media_sink_id| in UI.
48 // Notifications or an actionable events to be shown to the user.
49 // When is_blocking is true, media router UI shows issue only:
53 // default_action_button secondary_action_button
55 // When is_blocking is false, media router UI uses banner:
57 // Title default_action_link secondary_action_link
59 // above receiver list if route_id is not provided; otherwise it is
60 // above route detail and controls.
73 // If set, the ID of the route to which this issue pertains.
74 // If not set (default), then this is a global issue.
79 // When true, the issue must be presented to the user and resolved
80 // before other actions are allowed.
83 // Short description about the issue.
86 // Message about issue detail or how to handle issue.
87 // Messages should be suitable for end users to decide which actions to take.
90 ActionType default_action;
92 array<ActionType>? secondary_actions;
94 // A help page to be opened if users select learn_more.
103 // The type of this message.
105 // Used when the |type| is TEXT.
107 // Used when the |type| is BINARY.
111 // Modeled after the MediaRouter interface defined in
112 // chrome/browser/media/router/media_router.h
113 interface MediaRouteProvider {
114 // Initiates a media route from |media_source| to |sink_id|.
115 // The presentation ID of the route created will be |presentation_id|, but it
116 // may be overridden by a provider implementation. The presentation ID will
117 // be used by the presentation API to refer to the created route.
118 // |origin| and |tab_id| may be passed in for enforcing same-origin and/or
120 // Since int types cannot be made optional, use -1 as |tab_id| in cases where
121 // it is not applicable.
122 // If the operation was successful, |route| will be defined and
123 // |error_text| will be null.
124 // If the operation failed, |route| will be null and |error_text|
126 CreateRoute(string media_source,
128 string original_presentation_id,
130 int32 tab_id) => (MediaRoute? route, string? error_text);
132 // Joins an established route given by |presentation_id|
133 // with |media_source|.
134 // |origin| and |tab_id| are used for validating same-origin/tab scopes.
135 // (See CreateRoute for additional documentation)
136 // If the operation was successful, |route| will be defined and
137 // |error_text| will be null.
138 // If the operation failed, |route| will be null and |error_text|
140 JoinRoute(string media_source,
141 string presentation_id,
143 int32 tab_id) => (MediaRoute? route, string? error_text);
145 // Closes the route specified by |route_id|.
146 CloseRoute(string route_id);
148 // Sends |message| via the media route |media_route_id|.
149 // If the operation was successful, |sent| is true; otherwise it is false.
150 SendRouteMessage(string media_route_id, string message) => (bool sent);
152 // Sends |data| via the media route |media_route_id|.
153 // If the operation was successful, |sent| is true; otherwise it is false.
154 SendRouteBinaryMessage(string media_route_id, array<uint8> data)
157 // Starts querying for sinks capable of displaying |media_source|.
158 StartObservingMediaSinks(string media_source);
160 // Stops querying sinks for |media_source|.
161 StopObservingMediaSinks(string media_source);
163 // Starts reporting the state of active media routes via
164 // OnRoutesUpdated(). Querying will continue until
165 // StopObservingMediaRoutes() is called.
166 StartObservingMediaRoutes();
168 // Stops querying the state of all media routes.
169 StopObservingMediaRoutes();
171 // Called when the MediaRouter is ready to get the next batch of messages
172 // associated with |route_id|.
173 // |messages| returned will contain the batch of messages.
174 // |messages| will be empty if |StopListeningForRouteMessages| was invoked.
175 // |error| indicates if a permanent error occurred. If true, then subsequent
176 // calls will also return with |error| being true.
177 ListenForRouteMessages(string route_id) =>
178 (array<RouteMessage> messages, bool error);
180 // Called when there are no more listeners for messages for |route_id|.
181 // Calling this will resolve the pending |ListenForRouteMessages| callback
182 // with an empty list.
183 StopListeningForRouteMessages(string route_id);
185 // Indicates that the presentation session that was connected to route
186 // |route_id| is no longer connected to it.
187 OnPresentationSessionDetached(string route_id);
190 // Interface for a service which observes state changes across media
191 // sources, sinks, and issues.
192 interface MediaRouter {
193 // Registers a MediaRouteProvider with the MediaRouter.
194 // Returns a string that uniquely identifies the Media Router browser
196 RegisterMediaRouteProvider(MediaRouteProvider media_router_provider) =>
197 (string instance_id);
199 // Called when the Media Route Manager receives a new list of sinks.
200 OnSinksReceived(string media_source, array<MediaSink> sinks);
202 // Called when issues are reported for media routes.
203 OnIssue(Issue issue);
205 // Called when list of routes has been updated.
206 OnRoutesUpdated(array<MediaRoute> routes);