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