OLD | NEW |
| (Empty) |
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. | |
4 | |
5 module media_router.mojom; | |
6 | |
7 import "mojo/common/time.mojom"; | |
8 import "net/interfaces/ip_address.mojom"; | |
9 import "url/mojo/origin.mojom"; | |
10 import "url/mojo/url.mojom"; | |
11 | |
12 // Represents an output sink to which media can be routed. | |
13 struct MediaSink { | |
14 enum IconType { | |
15 CAST, | |
16 CAST_AUDIO, | |
17 CAST_AUDIO_GROUP, | |
18 GENERIC, | |
19 HANGOUT | |
20 }; | |
21 | |
22 // The sink identifier, e.g. "rs71w7mFzYLFlabir_qO4NHl6SUc." | |
23 string sink_id; | |
24 // The human-readable name, e.g. "Janet's Chromecast". | |
25 string name; | |
26 // Optional description of the sink. | |
27 string? description; | |
28 // Optional domain of the sink if this sink is associated with an identity. | |
29 string? domain; | |
30 // The type of icon to show in the UI for this media sink. | |
31 IconType icon_type; | |
32 // This is currently only set by MediaRouter in OnSinksDiscovered(). | |
33 MediaSinkExtraData? extra_data; | |
34 }; | |
35 | |
36 union MediaSinkExtraData { | |
37 DialMediaSink dial_media_sink; | |
38 CastMediaSink cast_media_sink; | |
39 }; | |
40 | |
41 struct DialMediaSink { | |
42 net.interfaces.IPAddress ip_address; | |
43 | |
44 // Model name of the sink, if it represents a physical device. | |
45 string model_name; | |
46 | |
47 // Used for DIAL launch | |
48 url.mojom.Url app_url; | |
49 }; | |
50 | |
51 struct CastMediaSink { | |
52 net.interfaces.IPAddress ip_address; | |
53 | |
54 // Model name of the sink, if it represents a physical device. | |
55 string model_name; | |
56 | |
57 // A bit vector representing capabilities of the sink. Meaning of capacity | |
58 // value for each bit: | |
59 // NONE: 0, | |
60 // VIDEO_OUT: 1 << 0, | |
61 // VIDEO_IN: 1 << 1, | |
62 // AUDIO_OUT: 1 << 2, | |
63 // AUDIO_IN: 1 << 3, | |
64 // DEV_MODE: 1 << 4, | |
65 // MULTIZONE_GROUP: 1 << 5 | |
66 uint8 capabilities; | |
67 | |
68 // ID of Cast channel opened by Media Router. The ID is defined by the | |
69 // chrome.cast.channel API. | |
70 int32 cast_channel_id; | |
71 }; | |
72 | |
73 // Should be kept in sync with media_route.h. | |
74 struct MediaRoute { | |
75 // The ID of this media route, e.g. "r_PR1O_blkC9dsKp-tb1ti8qurOo". | |
76 string media_route_id; | |
77 // The ID of the media source being sent through this media route. | |
78 // May be missing if route is not local. | |
79 string? media_source; | |
80 // The ID of sink that is rendering the media content. | |
81 string media_sink_id; | |
82 // Human readable description of this route, e.g. | |
83 // "Tab casting". | |
84 string description; | |
85 // Specifies that the route is requested locally. | |
86 bool is_local; | |
87 // An optional path to an HTML page bundled bundled with the media router | |
88 // component extension. When set, the route can have custom route detail as | |
89 // well as its own route controls in the media router dialog. | |
90 string? custom_controller_path; | |
91 // Set to true if this route should be displayed for |media_sink_id| in UI. | |
92 bool for_display; | |
93 // Set to true if this route was created by an incognito profile. | |
94 bool is_incognito; | |
95 // Set to true if this route corresponds to an offscreen presentation. | |
96 bool is_offscreen_presentation; | |
97 }; | |
98 | |
99 // Notifications or an actionable events to be shown to the user. | |
100 // When is_blocking is true, media router UI shows issue only: | |
101 // | |
102 // Title | |
103 // Message | |
104 // default_action_button secondary_action_button | |
105 // | |
106 // When is_blocking is false, media router UI uses banner: | |
107 // | |
108 // Title default_action_link secondary_action_link | |
109 // | |
110 // above receiver list if route_id is not provided; otherwise it is | |
111 // above route detail and controls. | |
112 struct Issue { | |
113 enum Severity { | |
114 FATAL, | |
115 WARNING, | |
116 NOTIFICATION | |
117 }; | |
118 | |
119 enum ActionType { | |
120 DISMISS, | |
121 LEARN_MORE | |
122 }; | |
123 | |
124 // If set, the ID of the route to which this issue pertains. | |
125 // If not set (default), then this is a global issue. | |
126 string? route_id; | |
127 | |
128 Severity severity; | |
129 | |
130 // When true, the issue must be presented to the user and resolved | |
131 // before other actions are allowed. | |
132 bool is_blocking; | |
133 | |
134 // Short description about the issue. | |
135 string title; | |
136 | |
137 // Message about issue detail or how to handle issue. | |
138 // Messages should be suitable for end users to decide which actions to take. | |
139 string? message; | |
140 | |
141 ActionType default_action; | |
142 | |
143 array<ActionType>? secondary_actions; | |
144 | |
145 // The ID of the help page to be opened if users select learn_more. | |
146 int32 help_page_id; | |
147 }; | |
148 | |
149 struct RouteMessage { | |
150 enum Type { | |
151 TEXT, | |
152 BINARY | |
153 }; | |
154 // The type of this message. | |
155 Type type; | |
156 // Used when the |type| is TEXT. | |
157 string? message; | |
158 // Used when the |type| is BINARY. | |
159 array<uint8>? data; | |
160 }; | |
161 | |
162 struct SinkSearchCriteria { | |
163 // Input to the search method which each Media Route Provider may interpret | |
164 // differently. | |
165 string input; | |
166 // The user's current hosted domain. | |
167 string domain; | |
168 }; | |
169 | |
170 // Keep in sync with: | |
171 // - RouteRequestResult::ResultCode in route_request_result.h | |
172 // - MediaRouteProviderResult enum in tools/metrics/histograms.xml. | |
173 // - mr.RouteRequestResultCode in route_request_error.js | |
174 // - RouteRequestResultCodeFromMojo in media_router_type_converters.cc | |
175 enum RouteRequestResultCode { | |
176 UNKNOWN_ERROR, | |
177 OK, | |
178 TIMED_OUT, | |
179 ROUTE_NOT_FOUND, | |
180 SINK_NOT_FOUND, | |
181 INVALID_ORIGIN, | |
182 INCOGNITO_MISMATCH, | |
183 NO_SUPPORTED_PROVIDER, | |
184 CANCELLED | |
185 // New values must be added here. | |
186 }; | |
187 | |
188 // Modeled after the MediaRouter interface defined in | |
189 // chrome/browser/media/router/media_router.h | |
190 interface MediaRouteProvider { | |
191 // Creates a media route from |media_source| to the sink given by |sink_id|. | |
192 // | |
193 // The presentation ID of the route created will be |presentation_id|, but it | |
194 // may be overridden by a provider implementation. The presentation ID will | |
195 // be used by the presentation API to refer to the created route. | |
196 // | |
197 // |origin| and |tab_id| may be passed in for enforcing same-origin and/or | |
198 // same-tab scopes. Use -1 as |tab_id| in cases where the request is not | |
199 // made on behalf of a tab. | |
200 // | |
201 // If |timeout| is positive, it will be used in place of the default timeout | |
202 // defined by Media Route Provider Manager. | |
203 // | |
204 // If |incognito| is true, the request was made by an incognito profile. | |
205 // | |
206 // If the operation was successful, |route| will be defined and | |
207 // |error_text| will be null. | |
208 // If the operation failed, |route| will be null and |error_text| | |
209 // will be set. | |
210 // |result| will be set to OK if successful, or an error code if an error | |
211 // occurred. | |
212 CreateRoute(string media_source, | |
213 string sink_id, | |
214 string original_presentation_id, | |
215 url.mojom.Origin origin, | |
216 int32 tab_id, | |
217 mojo.common.mojom.TimeDelta timeout, | |
218 bool incognito) => | |
219 (MediaRoute? route, | |
220 string? error_text, | |
221 RouteRequestResultCode result_code); | |
222 | |
223 // Requests a connection to an established route for |media_source| given | |
224 // by |presentation_id|. | |
225 // | |
226 // |origin| and |tab_id| are used for validating same-origin/tab scopes; | |
227 // see CreateRoute for additional documentation. | |
228 // | |
229 // If |timeout| is positive, it will be used in place of the default timeout | |
230 // defined by Media Route Provider Manager. | |
231 // | |
232 // If the route request was created by an incognito profile, | |
233 // |incognito| must be true. | |
234 // | |
235 // If the operation was successful, |route| will be defined and | |
236 // |error_text| will be null. | |
237 // If the operation failed, |route| will be null and |error_text| | |
238 // will be set. | |
239 // |result| will be set to OK if successful, or an error code if an error | |
240 // occurred. | |
241 JoinRoute(string media_source, | |
242 string presentation_id, | |
243 url.mojom.Origin origin, | |
244 int32 tab_id, | |
245 mojo.common.mojom.TimeDelta timeout, | |
246 bool incognito) => | |
247 (MediaRoute? route, | |
248 string? error_text, | |
249 RouteRequestResultCode result_code); | |
250 | |
251 // Creates a new route for |media_source| that connects to the established | |
252 // route given by |route_id|. | |
253 // | |
254 // The presentation ID of the new route will be |presentation_id|, but it may | |
255 // be overridden by a provider implementation. The presentation ID will be | |
256 // used by the presentation API to refer to the created route. | |
257 // | |
258 // |origin| and |tab_id| are used for validating same-origin/tab scopes; see | |
259 // CreateRoute for additional documentation. | |
260 // | |
261 // If |timeout| is positive, it will be used in place of the default timeout | |
262 // defined by Media Route Provider Manager; see CreateRoute for additional | |
263 // documentation. | |
264 // | |
265 // If the route request was created by an incognito profile, | |
266 // |incognito| must be true. | |
267 // | |
268 // If the operation was successful, |route| will be defined and | |
269 // |error_text| will be null. If the operation failed, |route| will be null | |
270 // and |error_text| will be set. | |
271 // | |
272 // |result| will be set to OK if successful, or an error code if an error | |
273 // occurred. | |
274 ConnectRouteByRouteId(string media_source, | |
275 string route_id, | |
276 string presentation_id, | |
277 url.mojom.Origin origin, | |
278 int32 tab_id, | |
279 mojo.common.mojom.TimeDelta timeout, | |
280 bool incognito) => | |
281 (MediaRoute? route, | |
282 string? error_text, | |
283 RouteRequestResultCode result_code); | |
284 | |
285 // Terminates the route specified by |route_id|. If the route was terminated | |
286 // successfully, |result_code| is set to OK and |error_text| is null. | |
287 // Otherwise, |result_code| is an error code and |error_text| describes the | |
288 // error. | |
289 TerminateRoute(string route_id) => | |
290 (string? error_text, RouteRequestResultCode result_code); | |
291 | |
292 // Sends |message| via the media route |media_route_id|. | |
293 // If the operation was successful, |sent| is true; otherwise it is false. | |
294 SendRouteMessage(string media_route_id, string message) => (bool sent); | |
295 | |
296 // Sends |data| via the media route |media_route_id|. | |
297 // If the operation was successful, |sent| is true; otherwise it is false. | |
298 SendRouteBinaryMessage(string media_route_id, array<uint8> data) | |
299 => (bool sent); | |
300 | |
301 // Starts querying for sinks capable of displaying |media_source|. | |
302 StartObservingMediaSinks(string media_source); | |
303 | |
304 // Stops querying sinks for |media_source|. | |
305 StopObservingMediaSinks(string media_source); | |
306 | |
307 // Starts reporting the state of active media routes via | |
308 // OnRoutesUpdated() in the context of the |media_source|. The | |
309 // |media_source| represents the application interested in the media | |
310 // routes (usually the web page from which the content originates). | |
311 // If no |media_source| is given, this should be considered an | |
312 // observer that is not associated with a media source, and thus | |
313 // cannot connect to a remote route without showing a source. The | |
314 // |media_source| should be considered when returning joinable routes in the | |
315 // OnRoutesUpdated() call. If an empty |media_source| is given, there is no | |
316 // context in which a joinable route makes sense and therefore, there should | |
317 // not be any joinable routes returned in OnRoutesUpdated(). | |
318 // Querying will continue until StopObservingMediaRoutes() is called with | |
319 // the same |media_source| (even if it's an empty string). | |
320 StartObservingMediaRoutes(string media_source); | |
321 | |
322 // Stops querying the state of all media routes in the context of | |
323 // the |media_source|. StartObservingMediaRoutes() has | |
324 // to be called with the same |media_source| for this to have any effect even | |
325 // if it's empty. Thus, StartObservingMediaRoutes(media_source) must be | |
326 // matched with StopObservingMediaRoutes(media_source). | |
327 // Calling StopObservingMediaRoutes() without a media_source will stop | |
328 // any media routes queries associated with emtpy strings (queries | |
329 // that being with StartObservingMediaRoutes()). | |
330 StopObservingMediaRoutes(string media_source); | |
331 | |
332 // Starts listening for messages from the media sink for the route given by | |
333 // |route_id|. | |
334 // |MediaRouter::OnRouteMessagesReceived| will be invoked when a batch of | |
335 // messages arrives, or when there is an error. | |
336 // |StopListeningForRouteMessages| will stop the Media Router from receiving | |
337 // further messages for |route_id|. | |
338 StartListeningForRouteMessages(string route_id); | |
339 | |
340 // Called when there are no more listeners for messages for |route_id|. | |
341 StopListeningForRouteMessages(string route_id); | |
342 | |
343 // Indicates that a PresentationConnection that was connected to route | |
344 // |route_id| has been closed (via .close(), garbage collection or | |
345 // navigation). | |
346 DetachRoute(string route_id); | |
347 | |
348 // Enables mDNS discovery. No-op if mDNS discovery is already enabled. | |
349 // Calling this will trigger a firewall prompt on Windows if there is not | |
350 // already a firewall rule for mDNS. | |
351 EnableMdnsDiscovery(); | |
352 | |
353 // Updates media sinks capable of displaying |media_source|. | |
354 UpdateMediaSinks(string media_source); | |
355 | |
356 // Indicates that the Media Router is interested in finding a sink that | |
357 // matches |search_criteria| and is compatible with the source urn | |
358 // |media_source|. |search_criteria| should contain an exact copy of the user | |
359 // input. The user's current domain is also used to search. The domain is the | |
360 // hosted domain of the user's signed-in identity, or empty if the user has no | |
361 // domain or is not signed in. | |
362 SearchSinks(string sink_id, | |
363 string media_source, | |
364 SinkSearchCriteria search_criteria) => | |
365 (string sink_id); | |
366 }; | |
367 | |
368 // Interface for a service which observes state changes across media | |
369 // sources, sinks, and issues. | |
370 interface MediaRouter { | |
371 | |
372 // Represents overall media sink availability states. | |
373 // UNAVAILABLE - No sinks are available. | |
374 // PER_SOURCE - Sinks are available, but are only compatible with specific | |
375 // media sources. | |
376 // AVAILABLE - A sink is available regardless of source. | |
377 enum SinkAvailability { | |
378 UNAVAILABLE, | |
379 PER_SOURCE, | |
380 AVAILABLE | |
381 }; | |
382 | |
383 // Keep in sync with content/public/common/presentation_info.h. | |
384 enum PresentationConnectionState { | |
385 CONNECTING, | |
386 CONNECTED, | |
387 CLOSED, | |
388 TERMINATED | |
389 }; | |
390 | |
391 // Keep in sync with content/public/common/presentation_info.h. | |
392 enum PresentationConnectionCloseReason { | |
393 CONNECTION_ERROR, | |
394 CLOSED, | |
395 WENT_AWAY | |
396 }; | |
397 | |
398 // Registers a MediaRouteProvider with the MediaRouter. | |
399 // Returns a string that uniquely identifies the Media Router browser | |
400 // process. | |
401 RegisterMediaRouteProvider(MediaRouteProvider media_router_provider) => | |
402 (string instance_id); | |
403 | |
404 // Called when the Media Route Manager receives a new list of |sinks| | |
405 // compatible with |media_source|. The result is only valid for |origins|. If | |
406 // |origins| is empty, the result is valid for any origin. | |
407 OnSinksReceived(string media_source, array<MediaSink> sinks, | |
408 array<url.mojom.Origin> origins); | |
409 | |
410 // Called when issues are reported for media routes. | |
411 OnIssue(Issue issue); | |
412 | |
413 // Called when list of routes has been updated in the context of the | |
414 // calling |media_source|. The array |joinable_route_ids| should | |
415 // contain route IDs of joinable routes found in the |routes| array. | |
416 OnRoutesUpdated(array<MediaRoute> routes, string media_source, | |
417 array<string> joinable_route_ids); | |
418 | |
419 // Called when the overall availability of media sinks has been updated. | |
420 OnSinkAvailabilityUpdated(SinkAvailability availability); | |
421 | |
422 // Called when the state of presentation connected to route |route_id| has | |
423 // changed to |state|. | |
424 OnPresentationConnectionStateChanged( | |
425 string route_id, PresentationConnectionState state); | |
426 | |
427 // Called when the presentation connected to route |route_id| has closed. | |
428 OnPresentationConnectionClosed( | |
429 string route_id, PresentationConnectionCloseReason reason, | |
430 string message); | |
431 | |
432 // Called when the a batch of messages arrives from the media sink for the | |
433 // route given by |route_id|. | |
434 // |StartListeningForRouteMessages| must be called first in order to receive | |
435 // messages. | |
436 // |route_id|: ID of route of the messages. | |
437 // |messages|: A non-empty list of messages received. | |
438 OnRouteMessagesReceived(string route_id, | |
439 array<RouteMessage> messages); | |
440 }; | |
OLD | NEW |