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