blob: 32a98306ef6238fcbf1bc4d3021345f771e13e1f [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
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
tkchin@webrtc.orgff273322014-04-30 18:32:33 +000030@class RTCDataChannel;
31@class RTCDataChannelInit;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000032@class RTCICECandidate;
33@class RTCICEServers;
34@class RTCMediaConstraints;
35@class RTCMediaStream;
tkchin@webrtc.org19b1be12014-04-22 21:05:38 +000036@class RTCMediaStreamTrack;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000037@class RTCSessionDescription;
tkchin@webrtc.orgec3d8ec2014-04-21 18:47:24 +000038@protocol RTCSessionDescriptionDelegate;
tkchin@webrtc.org19b1be12014-04-22 21:05:38 +000039@protocol RTCStatsDelegate;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040
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
47
tkchin@webrtc.orgacca6752014-05-30 22:26:06 +000048@property(nonatomic, weak) id<RTCPeerConnectionDelegate> delegate;
49
henrike@webrtc.org28e20752013-07-10 00:45:36 +000050// Accessor methods to active local streams.
51@property(nonatomic, strong, readonly) NSArray *localStreams;
52
53// The local description.
54@property(nonatomic, assign, readonly) RTCSessionDescription *localDescription;
55
56// The remote description.
57@property(nonatomic, assign, readonly) RTCSessionDescription *remoteDescription;
58
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;
63
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
68 constraints:(RTCMediaConstraints *)constraints;
69
70// Remove a MediaStream from this PeerConnection.
71// Note that a SessionDescription negotiation is need before the
72// remote peer is notified.
73- (void)removeStream:(RTCMediaStream *)stream;
74
tkchin@webrtc.orgff273322014-04-30 18:32:33 +000075// Create a data channel.
76- (RTCDataChannel*)createDataChannelWithLabel:(NSString*)label
77 config:(RTCDataChannelInit*)config;
78
henrike@webrtc.org28e20752013-07-10 00:45:36 +000079// Create a new offer.
tkchin@webrtc.orgec3d8ec2014-04-21 18:47:24 +000080// Success or failure will be reported via RTCSessionDescriptionDelegate.
81- (void)createOfferWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
henrike@webrtc.org28e20752013-07-10 00:45:36 +000082 constraints:(RTCMediaConstraints *)constraints;
83
84// Create an answer to an offer.
tkchin@webrtc.orgec3d8ec2014-04-21 18:47:24 +000085// Success or failure will be reported via RTCSessionDescriptionDelegate.
86- (void)createAnswerWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
henrike@webrtc.org28e20752013-07-10 00:45:36 +000087 constraints:(RTCMediaConstraints *)constraints;
88
89// Sets the local session description.
tkchin@webrtc.orgec3d8ec2014-04-21 18:47:24 +000090// Success or failure will be reported via RTCSessionDescriptionDelegate.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000091- (void)
tkchin@webrtc.orgec3d8ec2014-04-21 18:47:24 +000092 setLocalDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
henrike@webrtc.org28e20752013-07-10 00:45:36 +000093 sessionDescription:(RTCSessionDescription *)sdp;
94
95// Sets the remote session description.
tkchin@webrtc.orgec3d8ec2014-04-21 18:47:24 +000096// Success or failure will be reported via RTCSessionDescriptionDelegate.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000097- (void)
tkchin@webrtc.orgec3d8ec2014-04-21 18:47:24 +000098 setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
henrike@webrtc.org28e20752013-07-10 00:45:36 +000099 sessionDescription:(RTCSessionDescription *)sdp;
100
101// Restarts or updates the ICE Agent process of gathering local candidates
102// and pinging remote candidates.
103- (BOOL)updateICEServers:(NSArray *)servers
104 constraints:(RTCMediaConstraints *)constraints;
105
106// Provides a remote candidate to the ICE Agent.
107- (BOOL)addICECandidate:(RTCICECandidate *)candidate;
108
109// Terminates all media and closes the transport.
110- (void)close;
111
tkchin@webrtc.org19b1be12014-04-22 21:05:38 +0000112// Gets statistics for the media track. If |mediaStreamTrack| is nil statistics
113// are gathered for all tracks.
114// Statistics information will be reported via RTCStatsDelegate.
115- (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate
116 mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack
117 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000118
119#ifndef DOXYGEN_SHOULD_SKIP_THIS
120// Disallow init and don't add to documentation
121- (id)init __attribute__(
122 (unavailable("init is not a supported initializer for this class.")));
123#endif /* DOXYGEN_SHOULD_SKIP_THIS */
124
125@end