fake_peer_connection_base.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*
  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. #ifndef PC_TEST_FAKE_PEER_CONNECTION_BASE_H_
  11. #define PC_TEST_FAKE_PEER_CONNECTION_BASE_H_
  12. #include <map>
  13. #include <memory>
  14. #include <set>
  15. #include <string>
  16. #include <vector>
  17. #include "api/sctp_transport_interface.h"
  18. #include "pc/peer_connection_internal.h"
  19. namespace webrtc {
  20. // Customized PeerConnection fakes can be created by subclassing
  21. // FakePeerConnectionBase then overriding the interesting methods. This class
  22. // takes care of providing default implementations for all the pure virtual
  23. // functions specified in the interfaces.
  24. // TODO(nisse): Try to replace this with DummyPeerConnection, from
  25. // api/test/ ?
  26. class FakePeerConnectionBase : public PeerConnectionInternal {
  27. public:
  28. // PeerConnectionInterface implementation.
  29. rtc::scoped_refptr<StreamCollectionInterface> local_streams() override {
  30. return nullptr;
  31. }
  32. rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override {
  33. return nullptr;
  34. }
  35. bool AddStream(MediaStreamInterface* stream) override { return false; }
  36. void RemoveStream(MediaStreamInterface* stream) override {}
  37. RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
  38. rtc::scoped_refptr<MediaStreamTrackInterface> track,
  39. const std::vector<std::string>& stream_ids) override {
  40. return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
  41. }
  42. bool RemoveTrack(RtpSenderInterface* sender) override { return false; }
  43. RTCError RemoveTrackNew(
  44. rtc::scoped_refptr<RtpSenderInterface> sender) override {
  45. return RTCError(RTCErrorType::UNSUPPORTED_OPERATION);
  46. }
  47. RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
  48. rtc::scoped_refptr<MediaStreamTrackInterface> track) override {
  49. return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
  50. }
  51. RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
  52. rtc::scoped_refptr<MediaStreamTrackInterface> track,
  53. const RtpTransceiverInit& init) override {
  54. return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
  55. }
  56. RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
  57. cricket::MediaType media_type) override {
  58. return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
  59. }
  60. RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
  61. cricket::MediaType media_type,
  62. const RtpTransceiverInit& init) override {
  63. return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
  64. }
  65. rtc::scoped_refptr<RtpSenderInterface> CreateSender(
  66. const std::string& kind,
  67. const std::string& stream_id) override {
  68. return nullptr;
  69. }
  70. std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
  71. const override {
  72. return {};
  73. }
  74. std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
  75. const override {
  76. return {};
  77. }
  78. std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers()
  79. const override {
  80. return {};
  81. }
  82. bool GetStats(StatsObserver* observer,
  83. MediaStreamTrackInterface* track,
  84. StatsOutputLevel level) override {
  85. return false;
  86. }
  87. void GetStats(RTCStatsCollectorCallback* callback) override {}
  88. void GetStats(
  89. rtc::scoped_refptr<RtpSenderInterface> selector,
  90. rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override {}
  91. void GetStats(
  92. rtc::scoped_refptr<RtpReceiverInterface> selector,
  93. rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override {}
  94. void ClearStatsCache() override {}
  95. rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport() const {
  96. return nullptr;
  97. }
  98. rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
  99. const std::string& label,
  100. const DataChannelInit* config) override {
  101. return nullptr;
  102. }
  103. const SessionDescriptionInterface* local_description() const override {
  104. return nullptr;
  105. }
  106. const SessionDescriptionInterface* remote_description() const override {
  107. return nullptr;
  108. }
  109. const SessionDescriptionInterface* current_local_description()
  110. const override {
  111. return nullptr;
  112. }
  113. const SessionDescriptionInterface* current_remote_description()
  114. const override {
  115. return nullptr;
  116. }
  117. const SessionDescriptionInterface* pending_local_description()
  118. const override {
  119. return nullptr;
  120. }
  121. const SessionDescriptionInterface* pending_remote_description()
  122. const override {
  123. return nullptr;
  124. }
  125. void RestartIce() override {}
  126. void CreateOffer(CreateSessionDescriptionObserver* observer,
  127. const RTCOfferAnswerOptions& options) override {}
  128. void CreateAnswer(CreateSessionDescriptionObserver* observer,
  129. const RTCOfferAnswerOptions& options) override {}
  130. void SetLocalDescription(SetSessionDescriptionObserver* observer,
  131. SessionDescriptionInterface* desc) override {}
  132. void SetRemoteDescription(SetSessionDescriptionObserver* observer,
  133. SessionDescriptionInterface* desc) override {}
  134. void SetRemoteDescription(
  135. std::unique_ptr<SessionDescriptionInterface> desc,
  136. rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
  137. override {}
  138. RTCConfiguration GetConfiguration() override { return RTCConfiguration(); }
  139. RTCError SetConfiguration(
  140. const PeerConnectionInterface::RTCConfiguration& config) override {
  141. return RTCError();
  142. }
  143. bool AddIceCandidate(const IceCandidateInterface* candidate) override {
  144. return false;
  145. }
  146. bool RemoveIceCandidates(
  147. const std::vector<cricket::Candidate>& candidates) override {
  148. return false;
  149. }
  150. RTCError SetBitrate(const BitrateSettings& bitrate) override {
  151. return RTCError(RTCErrorType::UNSUPPORTED_OPERATION, "Not implemented");
  152. }
  153. void SetAudioPlayout(bool playout) override {}
  154. void SetAudioRecording(bool recording) override {}
  155. rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
  156. const std::string& mid) {
  157. return nullptr;
  158. }
  159. SignalingState signaling_state() override { return SignalingState::kStable; }
  160. IceConnectionState ice_connection_state() override {
  161. return IceConnectionState::kIceConnectionNew;
  162. }
  163. IceConnectionState standardized_ice_connection_state() override {
  164. return IceConnectionState::kIceConnectionNew;
  165. }
  166. PeerConnectionState peer_connection_state() override {
  167. return PeerConnectionState::kNew;
  168. }
  169. IceGatheringState ice_gathering_state() override {
  170. return IceGatheringState::kIceGatheringNew;
  171. }
  172. absl::optional<bool> can_trickle_ice_candidates() { return absl::nullopt; }
  173. bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
  174. int64_t output_period_ms) override {
  175. return false;
  176. }
  177. bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) override {
  178. return false;
  179. }
  180. void StopRtcEventLog() override {}
  181. void Close() override {}
  182. // PeerConnectionInternal implementation.
  183. rtc::Thread* network_thread() const override { return nullptr; }
  184. rtc::Thread* worker_thread() const override { return nullptr; }
  185. rtc::Thread* signaling_thread() const override { return nullptr; }
  186. std::string session_id() const override { return ""; }
  187. bool initial_offerer() const override { return false; }
  188. std::vector<
  189. rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
  190. GetTransceiversInternal() const override {
  191. return {};
  192. }
  193. sigslot::signal1<RtpDataChannel*>& SignalRtpDataChannelCreated() override {
  194. return SignalRtpDataChannelCreated_;
  195. }
  196. sigslot::signal1<SctpDataChannel*>& SignalSctpDataChannelCreated() override {
  197. return SignalSctpDataChannelCreated_;
  198. }
  199. cricket::RtpDataChannel* rtp_data_channel() const override { return nullptr; }
  200. absl::optional<std::string> sctp_transport_name() const override {
  201. return absl::nullopt;
  202. }
  203. std::map<std::string, std::string> GetTransportNamesByMid() const override {
  204. return {};
  205. }
  206. std::map<std::string, cricket::TransportStats> GetTransportStatsByNames(
  207. const std::set<std::string>& transport_names) override {
  208. return {};
  209. }
  210. Call::Stats GetCallStats() override { return Call::Stats(); }
  211. bool GetLocalCertificate(
  212. const std::string& transport_name,
  213. rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override {
  214. return false;
  215. }
  216. std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain(
  217. const std::string& transport_name) override {
  218. return nullptr;
  219. }
  220. bool IceRestartPending(const std::string& content_name) const override {
  221. return false;
  222. }
  223. bool NeedsIceRestart(const std::string& content_name) const override {
  224. return false;
  225. }
  226. bool GetSslRole(const std::string& content_name,
  227. rtc::SSLRole* role) override {
  228. return false;
  229. }
  230. protected:
  231. sigslot::signal1<RtpDataChannel*> SignalRtpDataChannelCreated_;
  232. sigslot::signal1<SctpDataChannel*> SignalSctpDataChannelCreated_;
  233. };
  234. } // namespace webrtc
  235. #endif // PC_TEST_FAKE_PEER_CONNECTION_BASE_H_