hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame^] | 11 | #import "RTCPeerConnection.h" |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "api/peerconnectioninterface.h" |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 14 | |
| 15 | NS_ASSUME_NONNULL_BEGIN |
| 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | /** |
| 20 | * These objects are created by RTCPeerConnectionFactory to wrap an |
| 21 | * id<RTCPeerConnectionDelegate> and call methods on that interface. |
| 22 | */ |
| 23 | class PeerConnectionDelegateAdapter : public PeerConnectionObserver { |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 24 | public: |
| 25 | PeerConnectionDelegateAdapter(RTCPeerConnection *peerConnection); |
Mirko Bonadei | 17aff35 | 2018-07-26 12:20:40 +0200 | [diff] [blame] | 26 | ~PeerConnectionDelegateAdapter() override; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 27 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 28 | void OnSignalingChange(PeerConnectionInterface::SignalingState new_state) override; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 29 | |
deadbeef | d5f41ce | 2016-06-08 13:31:45 -0700 | [diff] [blame] | 30 | void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) override; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 31 | |
deadbeef | d5f41ce | 2016-06-08 13:31:45 -0700 | [diff] [blame] | 32 | void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) override; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 33 | |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 34 | void OnTrack(rtc::scoped_refptr<RtpTransceiverInterface> transceiver) override; |
| 35 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 36 | void OnDataChannel(rtc::scoped_refptr<DataChannelInterface> data_channel) override; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 37 | |
| 38 | void OnRenegotiationNeeded() override; |
| 39 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 40 | void OnIceConnectionChange(PeerConnectionInterface::IceConnectionState new_state) override; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 41 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 42 | void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 43 | |
| 44 | void OnIceCandidate(const IceCandidateInterface *candidate) override; |
| 45 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 46 | void OnIceCandidatesRemoved(const std::vector<cricket::Candidate> &candidates) override; |
Honghai Zhang | da2ba4d | 2016-05-23 11:53:14 -0700 | [diff] [blame] | 47 | |
Yura Yaroshevich | 546d7f9 | 2018-02-28 21:06:34 +0300 | [diff] [blame] | 48 | void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver, |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 49 | const std::vector<rtc::scoped_refptr<MediaStreamInterface>> &streams) override; |
Yura Yaroshevich | 546d7f9 | 2018-02-28 21:06:34 +0300 | [diff] [blame] | 50 | |
Zeke Chin | 8de502b | 2018-08-21 11:41:07 -0700 | [diff] [blame] | 51 | void OnRemoveTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver) override; |
| 52 | |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 53 | private: |
magjed | 63bafd6 | 2017-02-27 07:04:25 -0800 | [diff] [blame] | 54 | __weak RTCPeerConnection *peer_connection_; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 57 | } // namespace webrtc |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 58 | |
| 59 | @interface RTCPeerConnection () |
| 60 | |
Yura Yaroshevich | c806c1d | 2018-06-21 12:51:11 +0300 | [diff] [blame] | 61 | /** The factory used to create this RTCPeerConnection */ |
| 62 | @property(nonatomic, readonly) RTCPeerConnectionFactory *factory; |
| 63 | |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 64 | /** The native PeerConnectionInterface created during construction. */ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 65 | @property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface> |
| 66 | nativePeerConnection; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 67 | |
Tze Kwang Chin | f3cb49f | 2016-03-22 10:57:40 -0700 | [diff] [blame] | 68 | /** Initialize an RTCPeerConnection with a configuration, constraints, and |
| 69 | * delegate. |
| 70 | */ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 71 | - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
| 72 | configuration:(RTCConfiguration *)configuration |
| 73 | constraints:(RTCMediaConstraints *)constraints |
| 74 | delegate:(nullable id<RTCPeerConnectionDelegate>)delegate |
Tze Kwang Chin | f3cb49f | 2016-03-22 10:57:40 -0700 | [diff] [blame] | 75 | NS_DESIGNATED_INITIALIZER; |
| 76 | |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 77 | + (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState: |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 78 | (RTCSignalingState)state; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 79 | |
| 80 | + (RTCSignalingState)signalingStateForNativeState: |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 81 | (webrtc::PeerConnectionInterface::SignalingState)nativeState; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 82 | |
| 83 | + (NSString *)stringForSignalingState:(RTCSignalingState)state; |
| 84 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 85 | + (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState: |
| 86 | (RTCIceConnectionState)state; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 87 | |
| 88 | + (RTCIceConnectionState)iceConnectionStateForNativeState: |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 89 | (webrtc::PeerConnectionInterface::IceConnectionState)nativeState; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 90 | |
| 91 | + (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state; |
| 92 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 93 | + (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState: |
| 94 | (RTCIceGatheringState)state; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 95 | |
| 96 | + (RTCIceGatheringState)iceGatheringStateForNativeState: |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 97 | (webrtc::PeerConnectionInterface::IceGatheringState)nativeState; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 98 | |
| 99 | + (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state; |
| 100 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 101 | + (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel: |
| 102 | (RTCStatsOutputLevel)level; |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 103 | |
hjon | f396f60 | 2016-02-11 16:19:06 -0800 | [diff] [blame] | 104 | @end |
| 105 | |
| 106 | NS_ASSUME_NONNULL_END |