blob: 00f2ef783491f9f2b2dd68b2937a9c1c9d4f6b87 [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
Jaehyun Kod2110982021-11-30 19:01:43 +090051 void OnIceCandidateError(const std::string &address,
52 int port,
53 const std::string &url,
54 int error_code,
55 const std::string &error_text) override;
56
Yves Gerey665174f2018-06-19 15:03:05 +020057 void OnIceCandidatesRemoved(const std::vector<cricket::Candidate> &candidates) override;
Honghai Zhangda2ba4d2016-05-23 11:53:14 -070058
Alex Drake43faee02019-08-12 16:27:34 -070059 void OnIceSelectedCandidatePairChanged(const cricket::CandidatePairChangeEvent &event) override;
60
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030061 void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver,
Yves Gerey665174f2018-06-19 15:03:05 +020062 const std::vector<rtc::scoped_refptr<MediaStreamInterface>> &streams) override;
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030063
Zeke Chin8de502b2018-08-21 11:41:07 -070064 void OnRemoveTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver) override;
65
hjonf396f602016-02-11 16:19:06 -080066 private:
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020067 __weak RTC_OBJC_TYPE(RTCPeerConnection) * peer_connection_;
hjonf396f602016-02-11 16:19:06 -080068};
69
Yves Gerey665174f2018-06-19 15:03:05 +020070} // namespace webrtc
Yury Yaroshevich19a6e942022-03-11 09:22:08 +010071@protocol RTC_OBJC_TYPE
72(RTCSSLCertificateVerifier);
hjonf396f602016-02-11 16:19:06 -080073
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020074@interface RTC_OBJC_TYPE (RTCPeerConnection)
75()
hjonf396f602016-02-11 16:19:06 -080076
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020077 /** The factory used to create this RTCPeerConnection */
78 @property(nonatomic, readonly) RTC_OBJC_TYPE(RTCPeerConnectionFactory) *
79 factory;
Yura Yaroshevichc806c1d2018-06-21 12:51:11 +030080
hjonf396f602016-02-11 16:19:06 -080081/** The native PeerConnectionInterface created during construction. */
Yves Gerey665174f2018-06-19 15:03:05 +020082@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface>
83 nativePeerConnection;
hjonf396f602016-02-11 16:19:06 -080084
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070085/** Initialize an RTCPeerConnection with a configuration, constraints, and
86 * delegate.
87 */
Yury Yaroshevich19a6e942022-03-11 09:22:08 +010088- (nullable instancetype)
89 initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
90 configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
91 constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
92 certificateVerifier:(nullable id<RTC_OBJC_TYPE(RTCSSLCertificateVerifier)>)certificateVerifier
93 delegate:(nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate;
Jonas Oreland285f83d2020-02-07 10:30:08 +010094
95/** Initialize an RTCPeerConnection with a configuration, constraints,
96 * delegate and PeerConnectionDependencies.
97 */
Yura Yaroshevichd140c8f2021-03-02 23:25:10 +030098- (nullable instancetype)
99 initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
100 configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
101 constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
102 dependencies:(std::unique_ptr<webrtc::PeerConnectionDependencies>)dependencies
103 delegate:(nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -0700104 NS_DESIGNATED_INITIALIZER;
105
hjonf396f602016-02-11 16:19:06 -0800106+ (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
Yves Gerey665174f2018-06-19 15:03:05 +0200107 (RTCSignalingState)state;
hjonf396f602016-02-11 16:19:06 -0800108
109+ (RTCSignalingState)signalingStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200110 (webrtc::PeerConnectionInterface::SignalingState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800111
112+ (NSString *)stringForSignalingState:(RTCSignalingState)state;
113
Yves Gerey665174f2018-06-19 15:03:05 +0200114+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
115 (RTCIceConnectionState)state;
hjonf396f602016-02-11 16:19:06 -0800116
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100117+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
118 (RTCPeerConnectionState)state;
119
hjonf396f602016-02-11 16:19:06 -0800120+ (RTCIceConnectionState)iceConnectionStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200121 (webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800122
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100123+ (RTCPeerConnectionState)connectionStateForNativeState:
124 (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState;
125
hjonf396f602016-02-11 16:19:06 -0800126+ (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
127
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100128+ (NSString *)stringForConnectionState:(RTCPeerConnectionState)state;
129
Yves Gerey665174f2018-06-19 15:03:05 +0200130+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
131 (RTCIceGatheringState)state;
hjonf396f602016-02-11 16:19:06 -0800132
133+ (RTCIceGatheringState)iceGatheringStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200134 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800135
136+ (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state;
137
Yves Gerey665174f2018-06-19 15:03:05 +0200138+ (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel:
139 (RTCStatsOutputLevel)level;
hjonf396f602016-02-11 16:19:06 -0800140
hjonf396f602016-02-11 16:19:06 -0800141@end
142
143NS_ASSUME_NONNULL_END