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 RTCConfiguration; 31 @class RTCDataChannel; 32 @class RTCDataChannelInit; 33 @class RTCICECandidate; 34 @class RTCICEServers; 35 @class RTCMediaConstraints; 36 @class RTCMediaStream; 37 @class RTCMediaStreamTrack; 38 @class RTCSessionDescription; 39 @protocol RTCSessionDescriptionDelegate; 40 @protocol RTCStatsDelegate; 41 42 // RTCPeerConnection is an ObjectiveC friendly wrapper around a PeerConnection 43 // object. See the documentation in talk/app/webrtc/peerconnectioninterface.h. 44 // or http://www.webrtc.org/reference/native-apis, which in turn is inspired by 45 // the JS APIs: http://dev.w3.org/2011/webrtc/editor/webrtc.html and 46 // http://www.w3.org/TR/mediacapture-streams/ 47 @interface RTCPeerConnection : NSObject 48 49 @property(nonatomic, weak) id<RTCPeerConnectionDelegate> delegate; 50 51 // Accessor methods to active local streams. 52 @property(nonatomic, strong, readonly) NSArray *localStreams; 53 54 // The local description. 55 @property(nonatomic, assign, readonly) RTCSessionDescription *localDescription; 56 57 // The remote description. 58 @property(nonatomic, assign, readonly) RTCSessionDescription *remoteDescription; 59 60 // The current signaling state. 61 @property(nonatomic, assign, readonly) RTCSignalingState signalingState; 62 @property(nonatomic, assign, readonly) RTCICEConnectionState iceConnectionState; 63 @property(nonatomic, assign, readonly) RTCICEGatheringState iceGatheringState; 64 65 // Add a new MediaStream to be sent on this PeerConnection. 66 // Note that a SessionDescription negotiation is needed before the 67 // remote peer can receive the stream. 68 - (BOOL)addStream:(RTCMediaStream *)stream; 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 75 // Create a data channel. 76 - (RTCDataChannel*)createDataChannelWithLabel:(NSString*)label 77 config:(RTCDataChannelInit*)config; 78 79 // Create a new offer. 80 // Success or failure will be reported via RTCSessionDescriptionDelegate. 81 - (void)createOfferWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate 82 constraints:(RTCMediaConstraints *)constraints; 83 84 // Create an answer to an offer. 85 // Success or failure will be reported via RTCSessionDescriptionDelegate. 86 - (void)createAnswerWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate 87 constraints:(RTCMediaConstraints *)constraints; 88 89 // Sets the local session description. 90 // Success or failure will be reported via RTCSessionDescriptionDelegate. 91 - (void) 92 setLocalDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate 93 sessionDescription:(RTCSessionDescription *)sdp; 94 95 // Sets the remote session description. 96 // Success or failure will be reported via RTCSessionDescriptionDelegate. 97 - (void) 98 setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate 99 sessionDescription:(RTCSessionDescription *)sdp; 100 101 // Sets the PeerConnection's global configuration to |configuration|. 102 // Any changes to STUN/TURN servers or ICE candidate policy will affect the 103 // next gathering phase, and cause the next call to createOffer to generate 104 // new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies 105 // cannot be changed with this method. 106 - (BOOL)setConfiguration:(RTCConfiguration *)configuration; 107 108 // Provides a remote candidate to the ICE Agent. 109 - (BOOL)addICECandidate:(RTCICECandidate *)candidate; 110 111 // Terminates all media and closes the transport. 112 - (void)close; 113 114 // Gets statistics for the media track. If |mediaStreamTrack| is nil statistics 115 // are gathered for all tracks. 116 // Statistics information will be reported via RTCStatsDelegate. 117 - (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate 118 mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack 119 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel; 120 121 #ifndef DOXYGEN_SHOULD_SKIP_THIS 122 // Disallow init and don't add to documentation 123 - (id)init __attribute__( 124 (unavailable("init is not a supported initializer for this class."))); 125 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 126 127 @end 128