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 // The <code>chrome.displaySource</code> API creates a Display |
| 6 // session using WebMediaStreamTrack as sources. |
| 7 namespace displaySource { |
| 8 enum ErrorType { |
| 9 // Cannot create media pipeline from the given media stream which could be |
| 10 // appropriate for a Display session (e.g., necessary codecs are missing |
| 11 // on the platform). |
| 12 create_media_pipeline_error, |
| 13 |
| 14 // A new Display session cannot be started before the existing one is |
| 15 // terminated. |
| 16 exceeded_session_limit_error, |
| 17 |
| 18 // Could not establish connection to the sink. |
| 19 establish_connection_error, |
| 20 |
| 21 // The capabilities of this Display Source and the connected |
| 22 // sink do not fit (e.g. the sink cannot play the media content of |
| 23 // the formats given by the source). |
| 24 capabilities_negotiation_error, |
| 25 |
| 26 // There was an error while packetizing and sending the media content. |
| 27 media_send_error, |
| 28 |
| 29 // The TCP connection with sink has dropped unexpectedly. |
| 30 connection_error, |
| 31 |
| 32 // An unexpected message has arrived from the sink. |
| 33 unexpected_message_error, |
| 34 |
| 35 // The sink became unresponsive. |
| 36 timeout_error, |
| 37 |
| 38 // Unspecified error. |
| 39 unknown_error |
| 40 }; |
| 41 |
| 42 dictionary ErrorInfo { |
| 43 ErrorType type; |
| 44 DOMString? description; |
| 45 }; |
| 46 |
| 47 enum SinkState { |
| 48 // Connected using this Display Source (i.e., there is an active session) |
| 49 Connected, |
| 50 // In process of connection to this Display Source |
| 51 Connecting, |
| 52 // Disconnected from this Display Source |
| 53 Disconnected |
| 54 }; |
| 55 |
| 56 dictionary SinkInfo { |
| 57 // Id of the sink. It is guaranteed to be unique during the browser session. |
| 58 long id; |
| 59 // Human readable name of the sink. |
| 60 DOMString name; |
| 61 // State of the sink. |
| 62 SinkState state; |
| 63 }; |
| 64 |
| 65 enum AuthenticationMethod { |
| 66 // Push Button Config authentication method. |
| 67 PBC, |
| 68 // PIN authentication method. |
| 69 PIN |
| 70 }; |
| 71 |
| 72 dictionary AuthenticationInfo { |
| 73 // Authentication method. |
| 74 AuthenticationMethod method; |
| 75 // Authentication data (e.g. PIN value). |
| 76 DOMString? data; |
| 77 }; |
| 78 |
| 79 dictionary StartSessionInfo { |
| 80 // Id of the sink to connect. |
| 81 long sinkId; |
| 82 // Authentication information. |
| 83 AuthenticationInfo? authenticationInfo; |
| 84 // The source audio track. |
| 85 [instanceOf=MediaStreamTrack] object? audioTrack; |
| 86 // The source audio track. |
| 87 [instanceOf=MediaStreamTrack] object? videoTrack; |
| 88 }; |
| 89 |
| 90 callback GetSinksCallback = void (SinkInfo[] result); |
| 91 callback RequestAuthenticationCallback = void (AuthenticationInfo result); |
| 92 callback TerminateSessionCallback = void (); |
| 93 |
| 94 interface Functions { |
| 95 // Queries the list of the currently available Display sinks. |
| 96 // |
| 97 // |callback| : Called when the request is completed. The argument list |
| 98 // is empty if no available sinks were found. |
| 99 static void getAvailableSinks(GetSinksCallback callback); |
| 100 |
| 101 // Queries authentication data from the sink device. |
| 102 // |
| 103 // |sinkId| : Id of the sink |
| 104 // |callback| : Called when authentication info retrieved from the sink. |
| 105 // The argument |method| field contains the authentication method required |
| 106 // by the sink for connection; the |data| field can be null or can contain |
| 107 // some supplementary data provided by the sink. If authentication info |
| 108 // cannot be retrieved from the sink the "chrome.runtime.lastError" property |
| 109 // is defined. |
| 110 static void requestAuthentication(long sinkId, |
| 111 RequestAuthenticationCallback callback); |
| 112 |
| 113 // Creates a Display session using the provided StartSessionInfo instance. |
| 114 // The input argument fields must be initialized as described below: |
| 115 // The |sinkId| must be a valid id of a sink (obtained via |
| 116 // ‘getAvailableSinks’). |
| 117 // |
| 118 // The |audioTrack| or |videoTrack| must be of type MediaStreamTrack. |
| 119 // Either |audioTrack| or |videoTrack| can be null but not both. This |
| 120 // means creating a session with only audio or video. |
| 121 // |
| 122 // The |authenticationInfo| can be null if no additional authentication data |
| 123 // are required by the sink; otherwise its |data| field must contain the |
| 124 // required authentication data (e.g. PIN value) and its |method| field must |
| 125 // be the same as one obtained from ‘requestAuthentication’. |
| 126 [nocompile] static void startSession(StartSessionInfo sessionInfo); |
| 127 |
| 128 // Terminates the active Display session. |
| 129 // |sinkId| : Id of the connected sink. |
| 130 // |callback| : Called when the session is terminated. |
| 131 [nocompile] static void terminateSession( |
| 132 long sinkId, optional TerminateSessionCallback callback); |
| 133 }; |
| 134 |
| 135 interface Events { |
| 136 // Event fired when the available sinks are modified (either their amount |
| 137 // or properties) |
| 138 // |sinks| the list of all currently available sinks |
| 139 static void onSinksUpdated(SinkInfo[] sinks); |
| 140 // Event fired when the Display session is started. |
| 141 // |sinkId| Id of the peer sink |
| 142 [nocompile] static void onSessionStarted(long sinkId); |
| 143 // Event fired when the Display session is terminated. |
| 144 // |sinkId| Id of the peer sink |
| 145 [nocompile] static void onSessionTerminated(long sinkId); |
| 146 // Event fired when an error occurs. |
| 147 // |sinkId| Id of the peer sink |
| 148 // |errorInfo| error description |
| 149 [nocompile] static void onSessionErrorOccured(long sinkId, |
| 150 ErrorInfo errorInfo); |
| 151 }; |
| 152 }; |
OLD | NEW |