• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
11 #import "RTCPeerConnection.h"
12 
13 #include "api/peer_connection_interface.h"
14 
15 NS_ASSUME_NONNULL_BEGIN
16 
17 namespace webrtc {
18 
19 /**
20  * These objects are created by RTCPeerConnectionFactory to wrap an
21  * id<RTCPeerConnectionDelegate> and call methods on that interface.
22  */
23 class PeerConnectionDelegateAdapter : public PeerConnectionObserver {
24  public:
25   PeerConnectionDelegateAdapter(RTC_OBJC_TYPE(RTCPeerConnection) * peerConnection);
26   ~PeerConnectionDelegateAdapter() override;
27 
28   void OnSignalingChange(PeerConnectionInterface::SignalingState new_state) override;
29 
30   void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) override;
31 
32   void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) override;
33 
34   void OnTrack(rtc::scoped_refptr<RtpTransceiverInterface> transceiver) override;
35 
36   void OnDataChannel(rtc::scoped_refptr<DataChannelInterface> data_channel) override;
37 
38   void OnRenegotiationNeeded() override;
39 
40   void OnIceConnectionChange(PeerConnectionInterface::IceConnectionState new_state) override;
41 
42   void OnStandardizedIceConnectionChange(
43       PeerConnectionInterface::IceConnectionState new_state) override;
44 
45   void OnConnectionChange(PeerConnectionInterface::PeerConnectionState new_state) override;
46 
47   void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override;
48 
49   void OnIceCandidate(const IceCandidateInterface *candidate) override;
50 
51   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 
57   void OnIceCandidatesRemoved(const std::vector<cricket::Candidate> &candidates) override;
58 
59   void OnIceSelectedCandidatePairChanged(const cricket::CandidatePairChangeEvent &event) override;
60 
61   void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver,
62                   const std::vector<rtc::scoped_refptr<MediaStreamInterface>> &streams) override;
63 
64   void OnRemoveTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver) override;
65 
66  private:
67   __weak RTC_OBJC_TYPE(RTCPeerConnection) * peer_connection_;
68 };
69 
70 }  // namespace webrtc
71 @protocol RTC_OBJC_TYPE
72 (RTCSSLCertificateVerifier);
73 
74 @interface RTC_OBJC_TYPE (RTCPeerConnection)
75 ()
76 
77     /** The factory used to create this RTCPeerConnection */
78     @property(nonatomic, readonly) RTC_OBJC_TYPE(RTCPeerConnectionFactory) *
79     factory;
80 
81 /** The native PeerConnectionInterface created during construction. */
82 @property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface>
83     nativePeerConnection;
84 
85 /** Initialize an RTCPeerConnection with a configuration, constraints, and
86  *  delegate.
87  */
88 - (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;
94 
95 /** Initialize an RTCPeerConnection with a configuration, constraints,
96  *  delegate and PeerConnectionDependencies.
97  */
98 - (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
104     NS_DESIGNATED_INITIALIZER;
105 
106 + (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
107         (RTCSignalingState)state;
108 
109 + (RTCSignalingState)signalingStateForNativeState:
110         (webrtc::PeerConnectionInterface::SignalingState)nativeState;
111 
112 + (NSString *)stringForSignalingState:(RTCSignalingState)state;
113 
114 + (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
115         (RTCIceConnectionState)state;
116 
117 + (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
118         (RTCPeerConnectionState)state;
119 
120 + (RTCIceConnectionState)iceConnectionStateForNativeState:
121         (webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
122 
123 + (RTCPeerConnectionState)connectionStateForNativeState:
124         (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState;
125 
126 + (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
127 
128 + (NSString *)stringForConnectionState:(RTCPeerConnectionState)state;
129 
130 + (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
131         (RTCIceGatheringState)state;
132 
133 + (RTCIceGatheringState)iceGatheringStateForNativeState:
134         (webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
135 
136 + (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state;
137 
138 + (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel:
139         (RTCStatsOutputLevel)level;
140 
141 @end
142 
143 NS_ASSUME_NONNULL_END
144