scenario_connection.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2019 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 TEST_PEER_SCENARIO_SCENARIO_CONNECTION_H_
  11. #define TEST_PEER_SCENARIO_SCENARIO_CONNECTION_H_
  12. #include <functional>
  13. #include <memory>
  14. #include <string>
  15. #include <vector>
  16. #include "api/candidate.h"
  17. #include "api/jsep.h"
  18. #include "p2p/base/transport_description.h"
  19. #include "test/network/network_emulation_manager.h"
  20. namespace webrtc {
  21. // ScenarioIceConnection provides the transport level functionality of a
  22. // PeerConnection for use in peer connection scenario tests. This allows
  23. // implementing custom server side behavior in tests.
  24. class ScenarioIceConnection {
  25. public:
  26. class IceConnectionObserver {
  27. public:
  28. // Called on network thread.
  29. virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet) = 0;
  30. // Called on signaling thread.
  31. virtual void OnIceCandidates(
  32. const std::string& mid,
  33. const std::vector<cricket::Candidate>& candidates) = 0;
  34. protected:
  35. ~IceConnectionObserver() = default;
  36. };
  37. static std::unique_ptr<ScenarioIceConnection> Create(
  38. test::NetworkEmulationManagerImpl* net,
  39. IceConnectionObserver* observer);
  40. virtual ~ScenarioIceConnection() = default;
  41. // Posts tasks to send packets to network thread.
  42. virtual void SendRtpPacket(rtc::ArrayView<const uint8_t> packet_view) = 0;
  43. virtual void SendRtcpPacket(rtc::ArrayView<const uint8_t> packet_view) = 0;
  44. // Used for ICE configuration, called on signaling thread.
  45. virtual void SetRemoteSdp(SdpType type, const std::string& remote_sdp) = 0;
  46. virtual void SetLocalSdp(SdpType type, const std::string& local_sdp) = 0;
  47. virtual EmulatedEndpoint* endpoint() = 0;
  48. virtual const cricket::TransportDescription& transport_description()
  49. const = 0;
  50. };
  51. } // namespace webrtc
  52. #endif // TEST_PEER_SCENARIO_SCENARIO_CONNECTION_H_