3 * Copyright 2013, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #import "RTCPeerConnectionDelegate.h"
30 @class RTCDataChannel;
31 @class RTCDataChannelInit;
32 @class RTCICECandidate;
34 @class RTCMediaConstraints;
35 @class RTCMediaStream;
36 @class RTCMediaStreamTrack;
37 @class RTCSessionDescription;
38 @protocol RTCSessionDescriptionDelegate;
39 @protocol RTCStatsDelegate;
41 // RTCPeerConnection is an ObjectiveC friendly wrapper around a PeerConnection
42 // object. See the documentation in talk/app/webrtc/peerconnectioninterface.h.
43 // or http://www.webrtc.org/reference/native-apis, which in turn is inspired by
44 // the JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and
45 // http://www.w3.org/TR/mediacapture-streams/
46 @interface RTCPeerConnection : NSObject
48 @property(nonatomic, weak) id<RTCPeerConnectionDelegate> delegate;
50 // Accessor methods to active local streams.
51 @property(nonatomic, strong, readonly) NSArray *localStreams;
53 // The local description.
54 @property(nonatomic, assign, readonly) RTCSessionDescription *localDescription;
56 // The remote description.
57 @property(nonatomic, assign, readonly) RTCSessionDescription *remoteDescription;
59 // The current signaling state.
60 @property(nonatomic, assign, readonly) RTCSignalingState signalingState;
61 @property(nonatomic, assign, readonly) RTCICEConnectionState iceConnectionState;
62 @property(nonatomic, assign, readonly) RTCICEGatheringState iceGatheringState;
64 // Add a new MediaStream to be sent on this PeerConnection.
65 // Note that a SessionDescription negotiation is needed before the
66 // remote peer can receive the stream.
67 - (BOOL)addStream:(RTCMediaStream *)stream;
69 // Remove a MediaStream from this PeerConnection.
70 // Note that a SessionDescription negotiation is need before the
71 // remote peer is notified.
72 - (void)removeStream:(RTCMediaStream *)stream;
74 // Create a data channel.
75 - (RTCDataChannel*)createDataChannelWithLabel:(NSString*)label
76 config:(RTCDataChannelInit*)config;
78 // Create a new offer.
79 // Success or failure will be reported via RTCSessionDescriptionDelegate.
80 - (void)createOfferWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
81 constraints:(RTCMediaConstraints *)constraints;
83 // Create an answer to an offer.
84 // Success or failure will be reported via RTCSessionDescriptionDelegate.
85 - (void)createAnswerWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
86 constraints:(RTCMediaConstraints *)constraints;
88 // Sets the local session description.
89 // Success or failure will be reported via RTCSessionDescriptionDelegate.
91 setLocalDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
92 sessionDescription:(RTCSessionDescription *)sdp;
94 // Sets the remote session description.
95 // Success or failure will be reported via RTCSessionDescriptionDelegate.
97 setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
98 sessionDescription:(RTCSessionDescription *)sdp;
100 // Restarts or updates the ICE Agent process of gathering local candidates
101 // and pinging remote candidates.
102 - (BOOL)updateICEServers:(NSArray *)servers
103 constraints:(RTCMediaConstraints *)constraints;
105 // Provides a remote candidate to the ICE Agent.
106 - (BOOL)addICECandidate:(RTCICECandidate *)candidate;
108 // Terminates all media and closes the transport.
111 // Gets statistics for the media track. If |mediaStreamTrack| is nil statistics
112 // are gathered for all tracks.
113 // Statistics information will be reported via RTCStatsDelegate.
114 - (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate
115 mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack
116 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel;
118 #ifndef DOXYGEN_SHOULD_SKIP_THIS
119 // Disallow init and don't add to documentation
120 - (id)init __attribute__(
121 (unavailable("init is not a supported initializer for this class.")));
122 #endif /* DOXYGEN_SHOULD_SKIP_THIS */