blob: ce08cd5f6ad5d273b4fdd95cb00af860775005af [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:
25 PeerConnectionDelegateAdapter(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:
magjed63bafd62017-02-27 07:04:25 -080061 __weak 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
66@interface RTCPeerConnection ()
67
Yura Yaroshevichc806c1d2018-06-21 12:51:11 +030068/** The factory used to create this RTCPeerConnection */
69@property(nonatomic, readonly) RTCPeerConnectionFactory *factory;
70
hjonf396f602016-02-11 16:19:06 -080071/** The native PeerConnectionInterface created during construction. */
Yves Gerey665174f2018-06-19 15:03:05 +020072@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface>
73 nativePeerConnection;
hjonf396f602016-02-11 16:19:06 -080074
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070075/** Initialize an RTCPeerConnection with a configuration, constraints, and
76 * delegate.
77 */
Yves Gerey665174f2018-06-19 15:03:05 +020078- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
79 configuration:(RTCConfiguration *)configuration
80 constraints:(RTCMediaConstraints *)constraints
81 delegate:(nullable id<RTCPeerConnectionDelegate>)delegate
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070082 NS_DESIGNATED_INITIALIZER;
83
hjonf396f602016-02-11 16:19:06 -080084+ (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
Yves Gerey665174f2018-06-19 15:03:05 +020085 (RTCSignalingState)state;
hjonf396f602016-02-11 16:19:06 -080086
87+ (RTCSignalingState)signalingStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020088 (webrtc::PeerConnectionInterface::SignalingState)nativeState;
hjonf396f602016-02-11 16:19:06 -080089
90+ (NSString *)stringForSignalingState:(RTCSignalingState)state;
91
Yves Gerey665174f2018-06-19 15:03:05 +020092+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
93 (RTCIceConnectionState)state;
hjonf396f602016-02-11 16:19:06 -080094
Jonas Olssoncfddbb72018-11-15 16:52:45 +010095+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
96 (RTCPeerConnectionState)state;
97
hjonf396f602016-02-11 16:19:06 -080098+ (RTCIceConnectionState)iceConnectionStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020099 (webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800100
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100101+ (RTCPeerConnectionState)connectionStateForNativeState:
102 (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState;
103
hjonf396f602016-02-11 16:19:06 -0800104+ (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
105
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100106+ (NSString *)stringForConnectionState:(RTCPeerConnectionState)state;
107
Yves Gerey665174f2018-06-19 15:03:05 +0200108+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
109 (RTCIceGatheringState)state;
hjonf396f602016-02-11 16:19:06 -0800110
111+ (RTCIceGatheringState)iceGatheringStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200112 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800113
114+ (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state;
115
Yves Gerey665174f2018-06-19 15:03:05 +0200116+ (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel:
117 (RTCStatsOutputLevel)level;
hjonf396f602016-02-11 16:19:06 -0800118
hjonf396f602016-02-11 16:19:06 -0800119@end
120
121NS_ASSUME_NONNULL_END