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