1/*
2 * libjingle
3 * Copyright 2013, Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
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.
15 *
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.
26 */
27
28#import "RTCPeerConnectionDelegate.h"
29
30@class RTCICECandidate;
31@class RTCICEServers;
32@class RTCMediaConstraints;
33@class RTCMediaStream;
34@class RTCSessionDescription;
35@protocol RTCSessionDescriptonDelegate;
36
37// RTCPeerConnection is an ObjectiveC friendly wrapper around a PeerConnection
38// object.  See the documentation in talk/app/webrtc/peerconnectioninterface.h.
39// or http://www.webrtc.org/reference/native-apis, which in turn is inspired by
40// the JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and
41// http://www.w3.org/TR/mediacapture-streams/
42@interface RTCPeerConnection : NSObject
43
44// Accessor methods to active local streams.
45@property(nonatomic, strong, readonly) NSArray *localStreams;
46
47// The local description.
48@property(nonatomic, assign, readonly) RTCSessionDescription *localDescription;
49
50// The remote description.
51@property(nonatomic, assign, readonly) RTCSessionDescription *remoteDescription;
52
53// The current signaling state.
54@property(nonatomic, assign, readonly) RTCSignalingState signalingState;
55@property(nonatomic, assign, readonly) RTCICEConnectionState iceConnectionState;
56@property(nonatomic, assign, readonly) RTCICEGatheringState iceGatheringState;
57
58// Add a new MediaStream to be sent on this PeerConnection.
59// Note that a SessionDescription negotiation is needed before the
60// remote peer can receive the stream.
61- (BOOL)addStream:(RTCMediaStream *)stream
62      constraints:(RTCMediaConstraints *)constraints;
63
64// Remove a MediaStream from this PeerConnection.
65// Note that a SessionDescription negotiation is need before the
66// remote peer is notified.
67- (void)removeStream:(RTCMediaStream *)stream;
68
69// Create a new offer.
70// Success or failure will be reported via RTCSessionDescriptonDelegate.
71- (void)createOfferWithDelegate:(id<RTCSessionDescriptonDelegate>)delegate
72                    constraints:(RTCMediaConstraints *)constraints;
73
74// Create an answer to an offer.
75// Success or failure will be reported via RTCSessionDescriptonDelegate.
76- (void)createAnswerWithDelegate:(id<RTCSessionDescriptonDelegate>)delegate
77                     constraints:(RTCMediaConstraints *)constraints;
78
79// Sets the local session description.
80// Success or failure will be reported via RTCSessionDescriptonDelegate.
81- (void)
82    setLocalDescriptionWithDelegate:(id<RTCSessionDescriptonDelegate>)delegate
83                 sessionDescription:(RTCSessionDescription *)sdp;
84
85// Sets the remote session description.
86// Success or failure will be reported via RTCSessionDescriptonDelegate.
87- (void)
88    setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptonDelegate>)delegate
89                  sessionDescription:(RTCSessionDescription *)sdp;
90
91// Restarts or updates the ICE Agent process of gathering local candidates
92// and pinging remote candidates.
93- (BOOL)updateICEServers:(NSArray *)servers
94             constraints:(RTCMediaConstraints *)constraints;
95
96// Provides a remote candidate to the ICE Agent.
97- (BOOL)addICECandidate:(RTCICECandidate *)candidate;
98
99// Terminates all media and closes the transport.
100- (void)close;
101
102// TODO(hughv): Implement GetStats.
103
104#ifndef DOXYGEN_SHOULD_SKIP_THIS
105// Disallow init and don't add to documentation
106- (id)init __attribute__(
107    (unavailable("init is not a supported initializer for this class.")));
108#endif /* DOXYGEN_SHOULD_SKIP_THIS */
109
110@end
111