blob: b6440cd434a857ebd7a3216f82fb333b977b24c1 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "api/peerconnectioninterface.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
Yves Gerey665174f2018-06-19 15:03:05 +020042 void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override;
hjonf396f602016-02-11 16:19:06 -080043
44 void OnIceCandidate(const IceCandidateInterface *candidate) override;
45
Yves Gerey665174f2018-06-19 15:03:05 +020046 void OnIceCandidatesRemoved(const std::vector<cricket::Candidate> &candidates) override;
Honghai Zhangda2ba4d2016-05-23 11:53:14 -070047
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030048 void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver,
Yves Gerey665174f2018-06-19 15:03:05 +020049 const std::vector<rtc::scoped_refptr<MediaStreamInterface>> &streams) override;
Yura Yaroshevich546d7f92018-02-28 21:06:34 +030050
Zeke Chin8de502b2018-08-21 11:41:07 -070051 void OnRemoveTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver) override;
52
hjonf396f602016-02-11 16:19:06 -080053 private:
magjed63bafd62017-02-27 07:04:25 -080054 __weak RTCPeerConnection *peer_connection_;
hjonf396f602016-02-11 16:19:06 -080055};
56
Yves Gerey665174f2018-06-19 15:03:05 +020057} // namespace webrtc
hjonf396f602016-02-11 16:19:06 -080058
59@interface RTCPeerConnection ()
60
Yura Yaroshevichc806c1d2018-06-21 12:51:11 +030061/** The factory used to create this RTCPeerConnection */
62@property(nonatomic, readonly) RTCPeerConnectionFactory *factory;
63
hjonf396f602016-02-11 16:19:06 -080064/** The native PeerConnectionInterface created during construction. */
Yves Gerey665174f2018-06-19 15:03:05 +020065@property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface>
66 nativePeerConnection;
hjonf396f602016-02-11 16:19:06 -080067
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070068/** Initialize an RTCPeerConnection with a configuration, constraints, and
69 * delegate.
70 */
Yves Gerey665174f2018-06-19 15:03:05 +020071- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
72 configuration:(RTCConfiguration *)configuration
73 constraints:(RTCMediaConstraints *)constraints
74 delegate:(nullable id<RTCPeerConnectionDelegate>)delegate
Tze Kwang Chinf3cb49f2016-03-22 10:57:40 -070075 NS_DESIGNATED_INITIALIZER;
76
hjonf396f602016-02-11 16:19:06 -080077+ (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
Yves Gerey665174f2018-06-19 15:03:05 +020078 (RTCSignalingState)state;
hjonf396f602016-02-11 16:19:06 -080079
80+ (RTCSignalingState)signalingStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020081 (webrtc::PeerConnectionInterface::SignalingState)nativeState;
hjonf396f602016-02-11 16:19:06 -080082
83+ (NSString *)stringForSignalingState:(RTCSignalingState)state;
84
Yves Gerey665174f2018-06-19 15:03:05 +020085+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
86 (RTCIceConnectionState)state;
hjonf396f602016-02-11 16:19:06 -080087
88+ (RTCIceConnectionState)iceConnectionStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020089 (webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
hjonf396f602016-02-11 16:19:06 -080090
91+ (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
92
Yves Gerey665174f2018-06-19 15:03:05 +020093+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
94 (RTCIceGatheringState)state;
hjonf396f602016-02-11 16:19:06 -080095
96+ (RTCIceGatheringState)iceGatheringStateForNativeState:
Yves Gerey665174f2018-06-19 15:03:05 +020097 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
hjonf396f602016-02-11 16:19:06 -080098
99+ (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state;
100
Yves Gerey665174f2018-06-19 15:03:05 +0200101+ (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel:
102 (RTCStatsOutputLevel)level;
hjonf396f602016-02-11 16:19:06 -0800103
hjonf396f602016-02-11 16:19:06 -0800104@end
105
106NS_ASSUME_NONNULL_END