henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 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 | |
tkchin@webrtc.org | ff27332 | 2014-04-30 18:32:33 +0000 | [diff] [blame] | 30 | @class RTCDataChannel; |
| 31 | @class RTCDataChannelInit; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | @class RTCICECandidate; |
| 33 | @class RTCICEServers; |
| 34 | @class RTCMediaConstraints; |
| 35 | @class RTCMediaStream; |
tkchin@webrtc.org | 19b1be1 | 2014-04-22 21:05:38 +0000 | [diff] [blame] | 36 | @class RTCMediaStreamTrack; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 37 | @class RTCSessionDescription; |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 38 | @protocol RTCSessionDescriptionDelegate; |
tkchin@webrtc.org | 19b1be1 | 2014-04-22 21:05:38 +0000 | [diff] [blame] | 39 | @protocol RTCStatsDelegate; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 | |
| 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.org | acca675 | 2014-05-30 22:26:06 +0000 | [diff] [blame] | 48 | @property(nonatomic, weak) id<RTCPeerConnectionDelegate> delegate; |
| 49 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 50 | // 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.org | ff27332 | 2014-04-30 18:32:33 +0000 | [diff] [blame] | 75 | // Create a data channel. |
| 76 | - (RTCDataChannel*)createDataChannelWithLabel:(NSString*)label |
| 77 | config:(RTCDataChannelInit*)config; |
| 78 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 79 | // Create a new offer. |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 80 | // Success or failure will be reported via RTCSessionDescriptionDelegate. |
| 81 | - (void)createOfferWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | constraints:(RTCMediaConstraints *)constraints; |
| 83 | |
| 84 | // Create an answer to an offer. |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 85 | // Success or failure will be reported via RTCSessionDescriptionDelegate. |
| 86 | - (void)createAnswerWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 87 | constraints:(RTCMediaConstraints *)constraints; |
| 88 | |
| 89 | // Sets the local session description. |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 90 | // Success or failure will be reported via RTCSessionDescriptionDelegate. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 91 | - (void) |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 92 | setLocalDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 93 | sessionDescription:(RTCSessionDescription *)sdp; |
| 94 | |
| 95 | // Sets the remote session description. |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 96 | // Success or failure will be reported via RTCSessionDescriptionDelegate. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 97 | - (void) |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 98 | setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 99 | 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.org | 19b1be1 | 2014-04-22 21:05:38 +0000 | [diff] [blame] | 112 | // 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.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 118 | |
| 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 |