This is a reland of d181ee798da57ce5b955f09e8dcb755fba70b51b Original change's description: > Adds peer scenario connection interface. > > This allows implementing custom clients for test in peer connection > scenario tests. For example server side behavior. > > Bug: webrtc:10839 > Change-Id: I5627b7a4d967d401f31d2e9a8f861d0849eb0184 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151907 > Commit-Queue: Sebastian Jansson <srte@webrtc.org> > Reviewed-by: Per Kjellander <perkj@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29125} TBR=perkj@webrtc.org Bug: webrtc:10839 Change-Id: I5e0857dc7647587eab2a9b61965f627bf310b88c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152481 Reviewed-by: Sebastian Jansson <srte@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29147}
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
#ifndef TEST_PEER_SCENARIO_SCENARIO_CONNECTION_H_
|
|
#define TEST_PEER_SCENARIO_SCENARIO_CONNECTION_H_
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "api/candidate.h"
|
|
#include "api/jsep.h"
|
|
#include "p2p/base/transport_description.h"
|
|
#include "test/network/network_emulation_manager.h"
|
|
|
|
namespace webrtc {
|
|
|
|
// ScenarioIceConnection provides the transport level functionality of a
|
|
// PeerConnection for use in peer connection scenario tests. This allows
|
|
// implementing custom server side behavior in tests.
|
|
class ScenarioIceConnection {
|
|
public:
|
|
class IceConnectionObserver {
|
|
public:
|
|
// Called on network thread.
|
|
virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet) = 0;
|
|
// Called on signaling thread.
|
|
virtual void OnIceCandidates(
|
|
const std::string& mid,
|
|
const std::vector<cricket::Candidate>& candidates) = 0;
|
|
|
|
protected:
|
|
~IceConnectionObserver() = default;
|
|
};
|
|
static std::unique_ptr<ScenarioIceConnection> Create(
|
|
test::NetworkEmulationManagerImpl* net,
|
|
IceConnectionObserver* observer);
|
|
|
|
virtual ~ScenarioIceConnection() = default;
|
|
|
|
// Posts tasks to send packets to network thread.
|
|
virtual void SendRtpPacket(rtc::ArrayView<const uint8_t> packet_view) = 0;
|
|
virtual void SendRtcpPacket(rtc::ArrayView<const uint8_t> packet_view) = 0;
|
|
|
|
// Used for ICE configuration, called on signaling thread.
|
|
virtual void SetRemoteSdp(SdpType type, const std::string& remote_sdp) = 0;
|
|
virtual void SetLocalSdp(SdpType type, const std::string& local_sdp) = 0;
|
|
|
|
virtual EmulatedEndpoint* endpoint() = 0;
|
|
virtual const cricket::TransportDescription& transport_description()
|
|
const = 0;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // TEST_PEER_SCENARIO_SCENARIO_CONNECTION_H_
|