blob: 7970dd0f0fdda63329e1abe515753c23ed6552c2 [file] [log] [blame]
Steve Antonbe5e2082018-01-24 23:29:171/*
2 * Copyright 2018 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
Steve Anton10542f22019-01-11 17:11:0011#ifndef PC_TEST_FAKE_PEER_CONNECTION_BASE_H_
12#define PC_TEST_FAKE_PEER_CONNECTION_BASE_H_
Steve Antonbe5e2082018-01-24 23:29:1713
Steve Anton5dfde182018-02-06 18:34:4014#include <map>
Steve Antonbe5e2082018-01-24 23:29:1715#include <memory>
Steve Anton5dfde182018-02-06 18:34:4016#include <set>
Steve Antonbe5e2082018-01-24 23:29:1717#include <string>
18#include <vector>
19
Harald Alvestrand15845af2019-03-05 08:50:5720#include "api/sctp_transport_interface.h"
Steve Anton10542f22019-01-11 17:11:0021#include "pc/peer_connection_internal.h"
Steve Antonbe5e2082018-01-24 23:29:1722
23namespace webrtc {
24
25// Customized PeerConnection fakes can be created by subclassing
26// FakePeerConnectionBase then overriding the interesting methods. This class
27// takes care of providing default implementations for all the pure virtual
28// functions specified in the interfaces.
Niels Möllere78fd802019-09-13 12:45:5529// TODO(nisse): Try to replace this with DummyPeerConnection, from
30// api/test/ ?
Steve Antonbe5e2082018-01-24 23:29:1731class FakePeerConnectionBase : public PeerConnectionInternal {
32 public:
33 // PeerConnectionInterface implementation.
34
35 rtc::scoped_refptr<StreamCollectionInterface> local_streams() override {
36 return nullptr;
37 }
38
39 rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override {
40 return nullptr;
41 }
42
43 bool AddStream(MediaStreamInterface* stream) override { return false; }
44
45 void RemoveStream(MediaStreamInterface* stream) override {}
46
47 RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
48 rtc::scoped_refptr<MediaStreamTrackInterface> track,
Seth Hampson845e8782018-03-02 19:34:1049 const std::vector<std::string>& stream_ids) override {
Steve Antonbe5e2082018-01-24 23:29:1750 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
51 }
52
Steve Antonbe5e2082018-01-24 23:29:1753 bool RemoveTrack(RtpSenderInterface* sender) override { return false; }
54
Niels Möller7b04a912019-09-13 13:41:2155 RTCError RemoveTrackNew(
56 rtc::scoped_refptr<RtpSenderInterface> sender) override {
57 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
58 }
59
Steve Antonbe5e2082018-01-24 23:29:1760 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
61 rtc::scoped_refptr<MediaStreamTrackInterface> track) override {
62 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
63 }
64
65 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
66 rtc::scoped_refptr<MediaStreamTrackInterface> track,
67 const RtpTransceiverInit& init) override {
68 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
69 }
70
71 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
72 cricket::MediaType media_type) override {
73 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
74 }
75
76 RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
77 cricket::MediaType media_type,
78 const RtpTransceiverInit& init) override {
79 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
80 }
81
Steve Antonbe5e2082018-01-24 23:29:1782 rtc::scoped_refptr<RtpSenderInterface> CreateSender(
83 const std::string& kind,
84 const std::string& stream_id) override {
85 return nullptr;
86 }
87
88 std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
89 const override {
90 return {};
91 }
92
93 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
94 const override {
95 return {};
96 }
97
98 std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers()
99 const override {
100 return {};
101 }
102
103 bool GetStats(StatsObserver* observer,
104 MediaStreamTrackInterface* track,
105 StatsOutputLevel level) override {
106 return false;
107 }
108
109 void GetStats(RTCStatsCollectorCallback* callback) override {}
Henrik Boström1df1bf82018-03-20 12:24:20110 void GetStats(
111 rtc::scoped_refptr<RtpSenderInterface> selector,
112 rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override {}
113 void GetStats(
114 rtc::scoped_refptr<RtpReceiverInterface> selector,
115 rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override {}
Steve Antonbe5e2082018-01-24 23:29:17116
117 void ClearStatsCache() override {}
118
Harald Alvestrand15845af2019-03-05 08:50:57119 rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport() const {
120 return nullptr;
121 }
122
Harald Alvestranda9af50f2021-05-21 13:33:51123 RTCErrorOr<rtc::scoped_refptr<DataChannelInterface>> CreateDataChannelOrError(
Steve Antonbe5e2082018-01-24 23:29:17124 const std::string& label,
125 const DataChannelInit* config) override {
Harald Alvestranda9af50f2021-05-21 13:33:51126 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION,
127 "Fake function called");
Steve Antonbe5e2082018-01-24 23:29:17128 }
129
130 const SessionDescriptionInterface* local_description() const override {
131 return nullptr;
132 }
133 const SessionDescriptionInterface* remote_description() const override {
134 return nullptr;
135 }
136
137 const SessionDescriptionInterface* current_local_description()
138 const override {
139 return nullptr;
140 }
141 const SessionDescriptionInterface* current_remote_description()
142 const override {
143 return nullptr;
144 }
145
146 const SessionDescriptionInterface* pending_local_description()
147 const override {
148 return nullptr;
149 }
150 const SessionDescriptionInterface* pending_remote_description()
151 const override {
152 return nullptr;
153 }
154
Henrik Boström79b69802019-07-18 09:16:56155 void RestartIce() override {}
156
Steve Antonbe5e2082018-01-24 23:29:17157 void CreateOffer(CreateSessionDescriptionObserver* observer,
Steve Antonbe5e2082018-01-24 23:29:17158 const RTCOfferAnswerOptions& options) override {}
159
160 void CreateAnswer(CreateSessionDescriptionObserver* observer,
161 const RTCOfferAnswerOptions& options) override {}
162
Steve Antonbe5e2082018-01-24 23:29:17163 void SetLocalDescription(SetSessionDescriptionObserver* observer,
164 SessionDescriptionInterface* desc) override {}
165
166 void SetRemoteDescription(SetSessionDescriptionObserver* observer,
167 SessionDescriptionInterface* desc) override {}
168
169 void SetRemoteDescription(
170 std::unique_ptr<SessionDescriptionInterface> desc,
171 rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
172 override {}
173
Steve Antonbe5e2082018-01-24 23:29:17174 RTCConfiguration GetConfiguration() override { return RTCConfiguration(); }
175
Niels Möller2579f0c2019-08-19 07:58:17176 RTCError SetConfiguration(
Steve Antonbe5e2082018-01-24 23:29:17177 const PeerConnectionInterface::RTCConfiguration& config) override {
Niels Möller2579f0c2019-08-19 07:58:17178 return RTCError();
Steve Antonbe5e2082018-01-24 23:29:17179 }
180
181 bool AddIceCandidate(const IceCandidateInterface* candidate) override {
182 return false;
183 }
184
185 bool RemoveIceCandidates(
186 const std::vector<cricket::Candidate>& candidates) override {
187 return false;
188 }
189
Niels Möller0c4f7be2018-05-07 12:01:37190 RTCError SetBitrate(const BitrateSettings& bitrate) override {
Steve Antonbe5e2082018-01-24 23:29:17191 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
192 }
193
Steve Antonbe5e2082018-01-24 23:29:17194 void SetAudioPlayout(bool playout) override {}
195
196 void SetAudioRecording(bool recording) override {}
197
Harald Alvestrand41390472018-12-03 17:45:19198 rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
199 const std::string& mid) {
200 return nullptr;
201 }
202
Steve Antonbe5e2082018-01-24 23:29:17203 SignalingState signaling_state() override { return SignalingState::kStable; }
204
205 IceConnectionState ice_connection_state() override {
206 return IceConnectionState::kIceConnectionNew;
207 }
208
Niels Möller7b04a912019-09-13 13:41:21209 IceConnectionState standardized_ice_connection_state() override {
210 return IceConnectionState::kIceConnectionNew;
211 }
212
213 PeerConnectionState peer_connection_state() override {
214 return PeerConnectionState::kNew;
215 }
216
Steve Antonbe5e2082018-01-24 23:29:17217 IceGatheringState ice_gathering_state() override {
218 return IceGatheringState::kIceGatheringNew;
219 }
220
Harald Alvestrand61f74d92020-03-02 10:20:00221 absl::optional<bool> can_trickle_ice_candidates() { return absl::nullopt; }
222
Steve Antonbe5e2082018-01-24 23:29:17223 bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
224 int64_t output_period_ms) override {
225 return false;
226 }
227
Niels Möller7b04a912019-09-13 13:41:21228 bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) override {
229 return false;
230 }
231
Steve Antonbe5e2082018-01-24 23:29:17232 void StopRtcEventLog() override {}
233
234 void Close() override {}
235
236 // PeerConnectionInternal implementation.
237
238 rtc::Thread* network_thread() const override { return nullptr; }
239 rtc::Thread* worker_thread() const override { return nullptr; }
240 rtc::Thread* signaling_thread() const override { return nullptr; }
241
242 std::string session_id() const override { return ""; }
243
244 bool initial_offerer() const override { return false; }
245
Steve Antonbe5e2082018-01-24 23:29:17246 std::vector<
247 rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
Steve Antonb8867112018-02-13 18:07:54248 GetTransceiversInternal() const override {
Steve Antonbe5e2082018-01-24 23:29:17249 return {};
250 }
251
Taylor Brandstetter3a034e12020-07-09 22:32:34252 sigslot::signal1<SctpDataChannel*>& SignalSctpDataChannelCreated() override {
253 return SignalSctpDataChannelCreated_;
Steve Antonbe5e2082018-01-24 23:29:17254 }
255
Danil Chapovalov66cadcc2018-06-19 14:47:43256 absl::optional<std::string> sctp_transport_name() const override {
257 return absl::nullopt;
Steve Antonbe5e2082018-01-24 23:29:17258 }
259
Tomas Gunnarssonbfd9ba82021-04-18 09:55:57260 absl::optional<std::string> sctp_mid() const override {
261 return absl::nullopt;
Steve Anton5dfde182018-02-06 18:34:40262 }
Steve Antonbe5e2082018-01-24 23:29:17263
Steve Anton5dfde182018-02-06 18:34:40264 std::map<std::string, cricket::TransportStats> GetTransportStatsByNames(
265 const std::set<std::string>& transport_names) override {
266 return {};
Steve Antonbe5e2082018-01-24 23:29:17267 }
268
269 Call::Stats GetCallStats() override { return Call::Stats(); }
270
271 bool GetLocalCertificate(
272 const std::string& transport_name,
273 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override {
274 return false;
275 }
276
Taylor Brandstetterc3928662018-02-23 21:04:51277 std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain(
Steve Antonbe5e2082018-01-24 23:29:17278 const std::string& transport_name) override {
279 return nullptr;
280 }
281
282 bool IceRestartPending(const std::string& content_name) const override {
283 return false;
284 }
285
286 bool NeedsIceRestart(const std::string& content_name) const override {
287 return false;
288 }
289
290 bool GetSslRole(const std::string& content_name,
291 rtc::SSLRole* role) override {
292 return false;
293 }
294
295 protected:
Taylor Brandstetter3a034e12020-07-09 22:32:34296 sigslot::signal1<SctpDataChannel*> SignalSctpDataChannelCreated_;
Steve Antonbe5e2082018-01-24 23:29:17297};
298
299} // namespace webrtc
300
Steve Anton10542f22019-01-11 17:11:00301#endif // PC_TEST_FAKE_PEER_CONNECTION_BASE_H_