blob: f4b27f03e189603acd009cf2f370d02f430d268b [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
Steve Antonbe5e2082018-01-24 23:29:17123 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
124 const std::string& label,
125 const DataChannelInit* config) override {
126 return nullptr;
127 }
128
129 const SessionDescriptionInterface* local_description() const override {
130 return nullptr;
131 }
132 const SessionDescriptionInterface* remote_description() const override {
133 return nullptr;
134 }
135
136 const SessionDescriptionInterface* current_local_description()
137 const override {
138 return nullptr;
139 }
140 const SessionDescriptionInterface* current_remote_description()
141 const override {
142 return nullptr;
143 }
144
145 const SessionDescriptionInterface* pending_local_description()
146 const override {
147 return nullptr;
148 }
149 const SessionDescriptionInterface* pending_remote_description()
150 const override {
151 return nullptr;
152 }
153
Henrik Boström79b69802019-07-18 09:16:56154 void RestartIce() override {}
155
Steve Antonbe5e2082018-01-24 23:29:17156 void CreateOffer(CreateSessionDescriptionObserver* observer,
Steve Antonbe5e2082018-01-24 23:29:17157 const RTCOfferAnswerOptions& options) override {}
158
159 void CreateAnswer(CreateSessionDescriptionObserver* observer,
160 const RTCOfferAnswerOptions& options) override {}
161
Steve Antonbe5e2082018-01-24 23:29:17162 void SetLocalDescription(SetSessionDescriptionObserver* observer,
163 SessionDescriptionInterface* desc) override {}
164
165 void SetRemoteDescription(SetSessionDescriptionObserver* observer,
166 SessionDescriptionInterface* desc) override {}
167
168 void SetRemoteDescription(
169 std::unique_ptr<SessionDescriptionInterface> desc,
170 rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
171 override {}
172
Steve Antonbe5e2082018-01-24 23:29:17173 RTCConfiguration GetConfiguration() override { return RTCConfiguration(); }
174
Niels Möller2579f0c2019-08-19 07:58:17175 RTCError SetConfiguration(
Steve Antonbe5e2082018-01-24 23:29:17176 const PeerConnectionInterface::RTCConfiguration& config) override {
Niels Möller2579f0c2019-08-19 07:58:17177 return RTCError();
Steve Antonbe5e2082018-01-24 23:29:17178 }
179
180 bool AddIceCandidate(const IceCandidateInterface* candidate) override {
181 return false;
182 }
183
184 bool RemoveIceCandidates(
185 const std::vector<cricket::Candidate>& candidates) override {
186 return false;
187 }
188
Niels Möller0c4f7be2018-05-07 12:01:37189 RTCError SetBitrate(const BitrateSettings& bitrate) override {
Steve Antonbe5e2082018-01-24 23:29:17190 return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
191 }
192
Steve Antonbe5e2082018-01-24 23:29:17193 void SetAudioPlayout(bool playout) override {}
194
195 void SetAudioRecording(bool recording) override {}
196
Harald Alvestrand41390472018-12-03 17:45:19197 rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
198 const std::string& mid) {
199 return nullptr;
200 }
201
Steve Antonbe5e2082018-01-24 23:29:17202 SignalingState signaling_state() override { return SignalingState::kStable; }
203
204 IceConnectionState ice_connection_state() override {
205 return IceConnectionState::kIceConnectionNew;
206 }
207
Niels Möller7b04a912019-09-13 13:41:21208 IceConnectionState standardized_ice_connection_state() override {
209 return IceConnectionState::kIceConnectionNew;
210 }
211
212 PeerConnectionState peer_connection_state() override {
213 return PeerConnectionState::kNew;
214 }
215
Steve Antonbe5e2082018-01-24 23:29:17216 IceGatheringState ice_gathering_state() override {
217 return IceGatheringState::kIceGatheringNew;
218 }
219
Harald Alvestrand61f74d92020-03-02 10:20:00220 absl::optional<bool> can_trickle_ice_candidates() { return absl::nullopt; }
221
Steve Antonbe5e2082018-01-24 23:29:17222 bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
223 int64_t output_period_ms) override {
224 return false;
225 }
226
Niels Möller7b04a912019-09-13 13:41:21227 bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) override {
228 return false;
229 }
230
Steve Antonbe5e2082018-01-24 23:29:17231 void StopRtcEventLog() override {}
232
233 void Close() override {}
234
235 // PeerConnectionInternal implementation.
236
237 rtc::Thread* network_thread() const override { return nullptr; }
238 rtc::Thread* worker_thread() const override { return nullptr; }
239 rtc::Thread* signaling_thread() const override { return nullptr; }
240
241 std::string session_id() const override { return ""; }
242
243 bool initial_offerer() const override { return false; }
244
Steve Antonbe5e2082018-01-24 23:29:17245 std::vector<
246 rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
Steve Antonb8867112018-02-13 18:07:54247 GetTransceiversInternal() const override {
Steve Antonbe5e2082018-01-24 23:29:17248 return {};
249 }
250
Steve Antonbe5e2082018-01-24 23:29:17251 sigslot::signal1<DataChannel*>& SignalDataChannelCreated() override {
252 return SignalDataChannelCreated_;
253 }
254
255 cricket::RtpDataChannel* rtp_data_channel() const override { return nullptr; }
256
257 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels()
258 const override {
259 return {};
260 }
261
Danil Chapovalov66cadcc2018-06-19 14:47:43262 absl::optional<std::string> sctp_transport_name() const override {
263 return absl::nullopt;
Steve Antonbe5e2082018-01-24 23:29:17264 }
265
Steve Anton5dfde182018-02-06 18:34:40266 std::map<std::string, std::string> GetTransportNamesByMid() const override {
267 return {};
268 }
Steve Antonbe5e2082018-01-24 23:29:17269
Steve Anton5dfde182018-02-06 18:34:40270 std::map<std::string, cricket::TransportStats> GetTransportStatsByNames(
271 const std::set<std::string>& transport_names) override {
272 return {};
Steve Antonbe5e2082018-01-24 23:29:17273 }
274
275 Call::Stats GetCallStats() override { return Call::Stats(); }
276
277 bool GetLocalCertificate(
278 const std::string& transport_name,
279 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override {
280 return false;
281 }
282
Taylor Brandstetterc3928662018-02-23 21:04:51283 std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain(
Steve Antonbe5e2082018-01-24 23:29:17284 const std::string& transport_name) override {
285 return nullptr;
286 }
287
288 bool IceRestartPending(const std::string& content_name) const override {
289 return false;
290 }
291
292 bool NeedsIceRestart(const std::string& content_name) const override {
293 return false;
294 }
295
296 bool GetSslRole(const std::string& content_name,
297 rtc::SSLRole* role) override {
298 return false;
299 }
300
301 protected:
302 sigslot::signal1<DataChannel*> SignalDataChannelCreated_;
303};
304
305} // namespace webrtc
306
Steve Anton10542f22019-01-11 17:11:00307#endif // PC_TEST_FAKE_PEER_CONNECTION_BASE_H_