2ad13948aac0df7a94c1e4ecf6a1dd2ef975d6df
[WebKit-https.git] / Source / WebCore / Modules / mediastream / RTCPeerConnection.idl
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
4  * Copyright (C) 2015, 2016 Ericsson AB. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer
14  *    in the documentation and/or other materials provided with the
15  *    distribution.
16  * 3. Neither the name of Google Inc. nor the names of its contributors
17  *    may be used to endorse or promote products derived from this
18  *    software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 [
34     ActiveDOMObject,
35     Conditional=WEB_RTC,
36     ConstructorCallWith=ScriptExecutionContext,
37     JSBuiltinConstructor,
38     InterfaceName=webkitRTCPeerConnection,
39 ] interface RTCPeerConnection : EventTarget {
40     // Private initializer
41     [PrivateIdentifier, CallWith=Document, RaisesException] void initializeWith(Dictionary parameters);
42
43     // RTP Media API extensions
44     [PrivateIdentifier, PublicIdentifier] sequence<RTCRtpSender> getSenders();
45     sequence<RTCRtpReceiver> getReceivers();
46     sequence<RTCRtpTransceiver> getTransceivers();
47
48     [PrivateIdentifier, PublicIdentifier, RaisesException] RTCRtpSender addTrack(MediaStreamTrack track, MediaStream... streams);
49     [PrivateIdentifier, PublicIdentifier, RaisesException] void removeTrack(RTCRtpSender sender);
50
51     [RaisesException] RTCRtpTransceiver addTransceiver(MediaStreamTrack track, optional RTCRtpTransceiverInit init);
52     [RaisesException] RTCRtpTransceiver addTransceiver(DOMString kind, optional RTCRtpTransceiverInit init);
53
54     // Legacy MediaSream-based API (implemented on top of the RTP Media API)
55     [JSBuiltin] sequence<MediaStream> getLocalStreams();
56     [PrivateIdentifier, PublicIdentifier] sequence<MediaStream> getRemoteStreams();
57     [JSBuiltin] MediaStream getStreamById(DOMString streamId);
58
59     [JSBuiltin] void addStream(MediaStream stream);
60     [JSBuiltin] void removeStream(MediaStream stream);
61
62     [JSBuiltin] Promise createOffer(optional Dictionary offerOptions);
63     // Legacy signature: Promise createOffer(RTCSessionDescriptionCallback successCallback
64     //                                       RTCPeerConnectionErrorCallback errorCallback,
65     //                                       optional Dictionary offerOptions);
66
67     [JSBuiltin] Promise createAnswer(optional Dictionary answerOptions);
68     // Legacy signature: Promise createAnswer(RTCSessionDescriptionCallback successCallback
69     //                                        RTCPeerConnectionErrorCallback errorCallback,
70     //                                        optional Dictionary answerOptions);
71
72     [JSBuiltin] Promise setLocalDescription(RTCSessionDescription description);
73     // Legacy signature: Promise setLocalDescription(RTCSessionDescription description
74     //                                               VoidCallback successCallback,
75     //                                               RTCPeerConnectionErrorCallback errorCallback);
76
77     readonly attribute RTCSessionDescription localDescription;
78     readonly attribute RTCSessionDescription currentLocalDescription;
79     readonly attribute RTCSessionDescription pendingLocalDescription;
80
81     [JSBuiltin] Promise setRemoteDescription(RTCSessionDescription description);
82     // Legacy signature: Promise setRemoteDescription(RTCSessionDescription description
83     //                                                VoidCallback successCallback,
84     //                                                RTCPeerConnectionErrorCallback errorCallback);
85
86     readonly attribute RTCSessionDescription remoteDescription;
87     readonly attribute RTCSessionDescription currentRemoteDescription;
88     readonly attribute RTCSessionDescription pendingRemoteDescription;
89
90     readonly attribute DOMString signalingState;
91
92     [JSBuiltin] Promise addIceCandidate(RTCIceCandidate candidate);
93     // Legacy signature: Promise addIceCandidate(RTCIceCandidate candidate
94     //                                           VoidCallback successCallback,
95     //                                           RTCPeerConnectionErrorCallback errorCallback);
96
97     readonly attribute DOMString iceGatheringState;
98     readonly attribute DOMString iceConnectionState;
99
100     RTCConfiguration getConfiguration();
101     [RaisesException] void setConfiguration(Dictionary configuration);
102
103     [JSBuiltin] Promise getStats(optional MediaStreamTrack? selector = null);
104     // Legacy signature: Promise getStats(MediaStreamTrack? selector
105     //                                    RTCStatsCallback successCallback,
106     //                                    RTCPeerConnectionErrorCallback errorCallback);
107
108     // Private API used to implement the overloaded operations above. Queued functions are called by
109     // runQueuedOperation() (defined in RTCPeerConnectionInternals.js).
110     [PrivateIdentifier] Promise queuedCreateOffer(optional Dictionary offerOptions);
111     [PrivateIdentifier] Promise queuedCreateAnswer(optional Dictionary answerOptions);
112     [PrivateIdentifier] Promise queuedSetLocalDescription(RTCSessionDescription description);
113     [PrivateIdentifier] Promise queuedSetRemoteDescription(RTCSessionDescription description);
114     [PrivateIdentifier] Promise queuedAddIceCandidate(RTCIceCandidate candidate);
115     [PrivateIdentifier] Promise privateGetStats(MediaStreamTrack? selector);
116
117     [RaisesException] RTCDataChannel createDataChannel([TreatNullAs=EmptyString] DOMString label, optional Dictionary options);
118
119     void close();
120
121     attribute EventHandler onnegotiationneeded;
122     attribute EventHandler onicecandidate;
123     attribute EventHandler onsignalingstatechange;
124     attribute EventHandler ontrack;
125     attribute EventHandler oniceconnectionstatechange;
126     attribute EventHandler onicegatheringstatechange;
127     attribute EventHandler ondatachannel;
128
129     // Legacy event handler (MediaStream-based API)
130     attribute EventHandler onaddstream;
131 };
132
133 // This enum is mirrored in RTCRtpTransceiver.idl
134 enum RTCRtpTransceiverDirection { "sendrecv", "sendonly", "recvonly", "inactive" };
135
136 dictionary RTCRtpTransceiverInit {
137     RTCRtpTransceiverDirection direction = "sendrecv";
138 };