summaryrefslogtreecommitdiffstats
path: root/extensions/common/api/display_source.idl
blob: 83cfa0dec50a4d0ade43f36195101a7c48689e5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// The <code>chrome.displaySource</code> API creates a Display
// session using WebMediaStreamTrack as sources.
namespace displaySource {
  enum ErrorType {
    // Cannot create media pipeline from the given media stream which could be
    // appropriate for a Display session (e.g., necessary codecs are missing
    // on the platform).
    create_media_pipeline_error,

    // A new Display session cannot be started before the existing one is
    // terminated.
    exceeded_session_limit_error,

    // Could not establish connection to the sink.
    establish_connection_error,

    // The capabilities of this Display Source and the connected  
    // sink do not fit (e.g. the sink cannot play the media content of
    // the formats given by the source).
    capabilities_negotiation_error,

    // There was an error while packetizing and sending the media content.
    media_send_error,

    // The TCP connection with sink has dropped unexpectedly.
    connection_error,

    // An unexpected message has arrived from the sink.
    unexpected_message_error,

    // The sink became unresponsive.
    timeout_error,

    // Unspecified error.
    unknown_error
  };

  dictionary ErrorInfo {
    ErrorType type;
    DOMString? description;
  };

  enum SinkState {
    // Connected using this Display Source (i.e., there is an active session)
    Connected,
    // In process of connection to this Display Source
    Connecting,
    // Disconnected from this Display Source
    Disconnected
  };

  dictionary SinkInfo {
    // Id of the sink. It is guaranteed to be unique during the browser session.
    long id;
    // Human readable name of the sink.
    DOMString name;
    // State of the sink.
    SinkState state;
  };

  enum AuthenticationMethod {
    // Push Button Config authentication method.
    PBC,
    // PIN authentication method.
    PIN
  };

  dictionary AuthenticationInfo {
    // Authentication method.
    AuthenticationMethod method;
    // Authentication data (e.g. PIN value).
    DOMString? data;
  };

  dictionary StartSessionInfo {
    // Id of the sink to connect.
    long sinkId;
    // Authentication information.
    AuthenticationInfo? authenticationInfo;
    // The source audio track.
    [instanceOf=MediaStreamTrack] object? audioTrack;
    // The source audio track.
    [instanceOf=MediaStreamTrack] object? videoTrack;
  };

  callback GetSinksCallback = void (SinkInfo[] result);
  callback RequestAuthenticationCallback = void (AuthenticationInfo result);

  // The callback is used by <code>startSession, terminateSession</code>
  // to signal completion. The callback is called with
  // <code>chrome.runtime.lastError</code> set to error
  // message if the call has failed.
  [inline_doc] callback CallCompleteCallback = void ();
 
  interface Functions {
    // Queries the list of the currently available Display sinks.
    //
    // |callback| : Called when the request is completed. The argument list
    // is empty if no available sinks were found.
    static void getAvailableSinks(GetSinksCallback callback);

    // Queries authentication data from the sink device.
    //
    // |sinkId| : Id of the sink
    // |callback| : Called when authentication info retrieved from the sink.
    // The argument |method| field contains the authentication method required
    // by the sink for connection; the |data| field can be null or can contain
    // some supplementary data provided by the sink. If authentication info
    // cannot be retrieved from the sink the "chrome.runtime.lastError" property
    // is defined.
    static void requestAuthentication(long sinkId,
                                      RequestAuthenticationCallback callback);

    // Creates a Display session using the provided StartSessionInfo instance.
    // The input argument fields must be initialized as described below:
    // The |sinkId|  must be a valid id of a sink (obtained via
    // ‘getAvailableSinks’).
    //
    // The |audioTrack| or |videoTrack| must be of type MediaStreamTrack.
    // Either |audioTrack| or |videoTrack| can be null but not both. This
    // means creating a session with only audio or video.
    //
    // The |authenticationInfo| can be null if no additional authentication data
    // are required by the sink; otherwise its |data| field must contain the
    // required authentication data (e.g. PIN value) and its |method| field must
    // be the same as one obtained from ‘requestAuthentication’.
    // |callback| : Called when the session is started.
    [nocompile] static void startSession(
        StartSessionInfo sessionInfo, optional CallCompleteCallback callback);

    // Terminates the active Display session.
    // |sinkId| : Id of the connected sink.
    // |callback| : Called when the session is terminated.
    [nocompile] static void terminateSession(
        long sinkId, optional CallCompleteCallback callback);
  };

  interface Events {
    // Event fired when the available sinks are modified (either their amount
    // or properties)
    // |sinks| the list of all currently available sinks
    static void onSinksUpdated(SinkInfo[] sinks);
    // Event fired when the Display session is terminated.
    // |sinkId| Id of the peer sink
    [nocompile] static void onSessionTerminated(long sinkId);
    // Event fired when an error occurs.
    // |sinkId| Id of the peer sink
    // |errorInfo| error description
    [nocompile] static void onSessionErrorOccured(long sinkId,
                                                  ErrorInfo errorInfo);
  };
};