blob: 3de6a9b79422f0ffa119e0a7631af8a5fef5259d [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
Jonas Olssoncfddbb72018-11-15 16:52:45 +010042 void OnConnectionChange(PeerConnectionInterface::PeerConnectionState new_state) override;
43
Yves Gerey665174f2018-06-19 15:03:05 +020044 void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override;
hjonf396f602016-02-11 16:19:06 -080045
46 void OnIceCandidate(const IceCandidateInterface *candidate) override;
47
Yves Gerey665174f2018-06-19 15:03:05 +020048 void OnIceCandidatesRemoved(const std::vector<cricket::Candidate> &candidates) override;
Honghai Zhangda2ba4d2016-05-23 11:53:14 -070049
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030050 void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver,
Yves Gerey665174f2018-06-19 15:03:05 +020051 const std::vector<rtc::scoped_refptr<MediaStreamInterface>> &streams) override;
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030052
Zeke Chin8de502b2018-08-21 11:41:07 -070053 void OnRemoveTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver) override;
54
hjonf396f602016-02-11 16:19:06 -080055 private:
magjed63bafd62017-02-27 07:04:25 -080056 __weak RTCPeerConnection *peer_connection_;
hjonf396f602016-02-11 16:19:06 -080057};
58
Yves Gerey665174f2018-06-19 15:03:05 +020059} // namespace webrtc
hjonf396f602016-02-11 16:19:06 -080060
61@interface RTCPeerConnection ()
62
Yura Yaroshevichc806c1d2018-06-21 12:51:11 +030063/** The factory used to create this RTCPeerConnection */
64@property(nonatomic, readonly) RTCPeerConnectionFactory *factory;
65
hjonf396f602016-02-11 16:19:06 -080066/** The native PeerConnectionInterface created during construction. */
Yves Gerey665174f2018-06-19 15:03:05 +020067@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface>
68 nativePeerConnection;
hjonf396f602016-02-11 16:19:06 -080069
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070070/** Initialize an RTCPeerConnection with a configuration, constraints, and
71 * delegate.
72 */
Yves Gerey665174f2018-06-19 15:03:05 +020073- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
74 configuration:(RTCConfiguration *)configuration
75 constraints:(RTCMediaConstraints *)constraints
76 delegate:(nullable id<RTCPeerConnectionDelegate>)delegate
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070077 NS_DESIGNATED_INITIALIZER;
78
hjonf396f602016-02-11 16:19:06 -080079+ (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
Yves Gerey665174f2018-06-19 15:03:05 +020080 (RTCSignalingState)state;
hjonf396f602016-02-11 16:19:06 -080081
82+ (RTCSignalingState)signalingStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020083 (webrtc::PeerConnectionInterface::SignalingState)nativeState;
hjonf396f602016-02-11 16:19:06 -080084
85+ (NSString *)stringForSignalingState:(RTCSignalingState)state;
86
Yves Gerey665174f2018-06-19 15:03:05 +020087+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
88 (RTCIceConnectionState)state;
hjonf396f602016-02-11 16:19:06 -080089
Jonas Olssoncfddbb72018-11-15 16:52:45 +010090+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
91 (RTCPeerConnectionState)state;
92
hjonf396f602016-02-11 16:19:06 -080093+ (RTCIceConnectionState)iceConnectionStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020094 (webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
hjonf396f602016-02-11 16:19:06 -080095
Jonas Olssoncfddbb72018-11-15 16:52:45 +010096+ (RTCPeerConnectionState)connectionStateForNativeState:
97 (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState;
98
hjonf396f602016-02-11 16:19:06 -080099+ (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
100
Jonas Olssoncfddbb72018-11-15 16:52:45 +0100101+ (NSString *)stringForConnectionState:(RTCPeerConnectionState)state;
102
Yves Gerey665174f2018-06-19 15:03:05 +0200103+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
104 (RTCIceGatheringState)state;
hjonf396f602016-02-11 16:19:06 -0800105
106+ (RTCIceGatheringState)iceGatheringStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +0200107 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
hjonf396f602016-02-11 16:19:06 -0800108
109+ (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state;
110
Yves Gerey665174f2018-06-19 15:03:05 +0200111+ (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel:
112 (RTCStatsOutputLevel)level;
hjonf396f602016-02-11 16:19:06 -0800113
hjonf396f602016-02-11 16:19:06 -0800114@end
115
116NS_ASSUME_NONNULL_END