blob: b2c6ba892d48fb7f25077eb2ee308dedf7bdee2f [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
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030053 void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver,
Yves Gerey665174f2018-06-19 15:03:05 +020054 const std::vector<rtc::scoped_refptr<MediaStreamInterface>> &streams) override;
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030055
Zeke Chin8de502b2018-08-21 11:41:07 -070056 void OnRemoveTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver) override;
57
hjonf396f602016-02-11 16:19:06 -080058 private:
magjed63bafd62017-02-27 07:04:25 -080059 __weak RTCPeerConnection *peer_connection_;
hjonf396f602016-02-11 16:19:06 -080060};
61
Yves Gerey665174f2018-06-19 15:03:05 +020062} // namespace webrtc
hjonf396f602016-02-11 16:19:06 -080063
64@interface RTCPeerConnection ()
65
Yura Yaroshevichc806c1d2018-06-21 12:51:11 +030066/** The factory used to create this RTCPeerConnection */
67@property(nonatomic, readonly) RTCPeerConnectionFactory *factory;
68
hjonf396f602016-02-11 16:19:06 -080069/** The native PeerConnectionInterface created during construction. */
Yves Gerey665174f2018-06-19 15:03:05 +020070@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface>
71 nativePeerConnection;
hjonf396f602016-02-11 16:19:06 -080072
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070073/** Initialize an RTCPeerConnection with a configuration, constraints, and
74 * delegate.
75 */
Yves Gerey665174f2018-06-19 15:03:05 +020076- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
77 configuration:(RTCConfiguration *)configuration
78 constraints:(RTCMediaConstraints *)constraints
79 delegate:(nullable id<RTCPeerConnectionDelegate>)delegate
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070080 NS_DESIGNATED_INITIALIZER;
81
hjonf396f602016-02-11 16:19:06 -080082+ (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
Yves Gerey665174f2018-06-19 15:03:05 +020083 (RTCSignalingState)state;
hjonf396f602016-02-11 16:19:06 -080084
85+ (RTCSignalingState)signalingStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020086 (webrtc::PeerConnectionInterface::SignalingState)nativeState;
hjonf396f602016-02-11 16:19:06 -080087
88+ (NSString *)stringForSignalingState:(RTCSignalingState)state;
89
Yves Gerey665174f2018-06-19 15:03:05 +020090+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
91 (RTCIceConnectionState)state;
hjonf396f602016-02-11 16:19:06 -080092
Jonas Olssoncfddbb72018-11-15 16:52:45 +010093+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
94 (RTCPeerConnectionState)state;
95
hjonf396f602016-02-11 16:19:06 -080096+ (RTCIceConnectionState)iceConnectionStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020097 (webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
hjonf396f602016-02-11 16:19:06 -080098
Jonas Olssoncfddbb72018-11-15 16:52:45 +010099+ (RTCPeerConnectionState)connectionStateForNativeState:
100 (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState;
101
hjonf396f602016-02-11 16:19:06 -0800102+ (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
103
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100104+ (NSString *)stringForConnectionState:(RTCPeerConnectionState)state;
105
Yves Gerey665174f2018-06-19 15:03:05 +0200106+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
107 (RTCIceGatheringState)state;
hjonf396f602016-02-11 16:19:06 -0800108
109+ (RTCIceGatheringState)iceGatheringStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200110 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800111
112+ (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state;
113
Yves Gerey665174f2018-06-19 15:03:05 +0200114+ (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel:
115 (RTCStatsOutputLevel)level;
hjonf396f602016-02-11 16:19:06 -0800116
hjonf396f602016-02-11 16:19:06 -0800117@end
118
119NS_ASSUME_NONNULL_END