blob: 558cf07dce926261d72afa4c5359b9f9ef593f93 [file] [log] [blame]
hjonf396f602016-02-11 16:19:06 -08001/*
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 Carlsson7bca8ca2018-08-30 09:30:29 +020011#import "RTCPeerConnection.h"
hjonf396f602016-02-11 16:19:06 -080012
Steve Anton10542f22019-01-11 09:11:00 -080013#include "api/peer_connection_interface.h"
hjonf396f602016-02-11 16:19:06 -080014
15NS_ASSUME_NONNULL_BEGIN
16
17namespace webrtc {
18
19/**
20 * These objects are created by RTCPeerConnectionFactory to wrap an
21 * id<RTCPeerConnectionDelegate> and call methods on that interface.
22 */
23class PeerConnectionDelegateAdapter : public PeerConnectionObserver {
hjonf396f602016-02-11 16:19:06 -080024 public:
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020025 PeerConnectionDelegateAdapter(RTC_OBJC_TYPE(RTCPeerConnection) * peerConnection);
Mirko Bonadei17aff352018-07-26 12:20:40 +020026 ~PeerConnectionDelegateAdapter() override;
hjonf396f602016-02-11 16:19:06 -080027
Yves Gerey665174f2018-06-19 15:03:05 +020028 void OnSignalingChange(PeerConnectionInterface::SignalingState new_state) override;
hjonf396f602016-02-11 16:19:06 -080029
deadbeefd5f41ce2016-06-08 13:31:45 -070030 void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) override;
hjonf396f602016-02-11 16:19:06 -080031
deadbeefd5f41ce2016-06-08 13:31:45 -070032 void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) override;
hjonf396f602016-02-11 16:19:06 -080033
Steve Anton8cb344a2018-02-27 15:34:53 -080034 void OnTrack(rtc::scoped_refptr<RtpTransceiverInterface> transceiver) override;
35
Yves Gerey665174f2018-06-19 15:03:05 +020036 void OnDataChannel(rtc::scoped_refptr<DataChannelInterface> data_channel) override;
hjonf396f602016-02-11 16:19:06 -080037
38 void OnRenegotiationNeeded() override;
39
Yves Gerey665174f2018-06-19 15:03:05 +020040 void OnIceConnectionChange(PeerConnectionInterface::IceConnectionState new_state) override;
hjonf396f602016-02-11 16:19:06 -080041
Qingsi Wang36e31472019-05-29 11:37:26 -070042 void OnStandardizedIceConnectionChange(
43 PeerConnectionInterface::IceConnectionState new_state) override;
44
Jonas Olssoncfddbb72018-11-15 16:52:45 +010045 void OnConnectionChange(PeerConnectionInterface::PeerConnectionState new_state) override;
46
Yves Gerey665174f2018-06-19 15:03:05 +020047 void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override;
hjonf396f602016-02-11 16:19:06 -080048
49 void OnIceCandidate(const IceCandidateInterface *candidate) override;
50
Yves Gerey665174f2018-06-19 15:03:05 +020051 void OnIceCandidatesRemoved(const std::vector<cricket::Candidate> &candidates) override;
Honghai Zhangda2ba4d2016-05-23 11:53:14 -070052
Alex Drake43faee02019-08-12 16:27:34 -070053 void OnIceSelectedCandidatePairChanged(const cricket::CandidatePairChangeEvent &event) override;
54
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030055 void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver,
Yves Gerey665174f2018-06-19 15:03:05 +020056 const std::vector<rtc::scoped_refptr<MediaStreamInterface>> &streams) override;
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030057
Zeke Chin8de502b2018-08-21 11:41:07 -070058 void OnRemoveTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver) override;
59
hjonf396f602016-02-11 16:19:06 -080060 private:
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020061 __weak RTC_OBJC_TYPE(RTCPeerConnection) * peer_connection_;
hjonf396f602016-02-11 16:19:06 -080062};
63
Yves Gerey665174f2018-06-19 15:03:05 +020064} // namespace webrtc
hjonf396f602016-02-11 16:19:06 -080065
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020066@interface RTC_OBJC_TYPE (RTCPeerConnection)
67()
hjonf396f602016-02-11 16:19:06 -080068
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020069 /** The factory used to create this RTCPeerConnection */
70 @property(nonatomic, readonly) RTC_OBJC_TYPE(RTCPeerConnectionFactory) *
71 factory;
Yura Yaroshevichc806c1d2018-06-21 12:51:11 +030072
hjonf396f602016-02-11 16:19:06 -080073/** The native PeerConnectionInterface created during construction. */
Yves Gerey665174f2018-06-19 15:03:05 +020074@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface>
75 nativePeerConnection;
hjonf396f602016-02-11 16:19:06 -080076
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070077/** Initialize an RTCPeerConnection with a configuration, constraints, and
78 * delegate.
79 */
Yura Yaroshevichd140c8f2021-03-02 23:25:10 +030080- (nullable instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
81 configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
82 constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
83 delegate:
84 (nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate;
Jonas Oreland285f83d2020-02-07 10:30:08 +010085
86/** Initialize an RTCPeerConnection with a configuration, constraints,
87 * delegate and PeerConnectionDependencies.
88 */
Yura Yaroshevichd140c8f2021-03-02 23:25:10 +030089- (nullable instancetype)
90 initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
91 configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
92 constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
93 dependencies:(std::unique_ptr<webrtc::PeerConnectionDependencies>)dependencies
94 delegate:(nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070095 NS_DESIGNATED_INITIALIZER;
96
hjonf396f602016-02-11 16:19:06 -080097+ (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
Yves Gerey665174f2018-06-19 15:03:05 +020098 (RTCSignalingState)state;
hjonf396f602016-02-11 16:19:06 -080099
100+ (RTCSignalingState)signalingStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200101 (webrtc::PeerConnectionInterface::SignalingState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800102
103+ (NSString *)stringForSignalingState:(RTCSignalingState)state;
104
Yves Gerey665174f2018-06-19 15:03:05 +0200105+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
106 (RTCIceConnectionState)state;
hjonf396f602016-02-11 16:19:06 -0800107
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100108+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
109 (RTCPeerConnectionState)state;
110
hjonf396f602016-02-11 16:19:06 -0800111+ (RTCIceConnectionState)iceConnectionStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200112 (webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800113
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100114+ (RTCPeerConnectionState)connectionStateForNativeState:
115 (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState;
116
hjonf396f602016-02-11 16:19:06 -0800117+ (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
118
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100119+ (NSString *)stringForConnectionState:(RTCPeerConnectionState)state;
120
Yves Gerey665174f2018-06-19 15:03:05 +0200121+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
122 (RTCIceGatheringState)state;
hjonf396f602016-02-11 16:19:06 -0800123
124+ (RTCIceGatheringState)iceGatheringStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200125 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800126
127+ (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state;
128
Yves Gerey665174f2018-06-19 15:03:05 +0200129+ (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel:
130 (RTCStatsOutputLevel)level;
hjonf396f602016-02-11 16:19:06 -0800131
hjonf396f602016-02-11 16:19:06 -0800132@end
133
134NS_ASSUME_NONNULL_END