2018-09-27 13:47:01 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright 2018 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_SCENARIO_CALL_CLIENT_H_
|
|
|
|
|
#define TEST_SCENARIO_CALL_CLIENT_H_
|
2019-01-16 17:45:05 +01:00
|
|
|
|
|
|
|
|
#include <map>
|
2018-09-27 13:47:01 +02:00
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
2019-01-16 17:45:05 +01:00
|
|
|
#include <utility>
|
2018-09-27 13:47:01 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "call/call.h"
|
|
|
|
|
#include "logging/rtc_event_log/rtc_event_log.h"
|
|
|
|
|
#include "modules/audio_device/include/test_audio_device.h"
|
|
|
|
|
#include "modules/congestion_controller/test/controller_printer.h"
|
2018-10-22 11:49:03 +02:00
|
|
|
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/constructor_magic.h"
|
2019-01-16 17:25:44 +01:00
|
|
|
#include "test/logging/log_writer.h"
|
2018-09-27 13:47:01 +02:00
|
|
|
#include "test/scenario/column_printer.h"
|
2019-01-04 15:45:01 +01:00
|
|
|
#include "test/scenario/network/network_emulation.h"
|
2018-10-22 11:49:03 +02:00
|
|
|
#include "test/scenario/network_node.h"
|
2018-09-27 13:47:01 +02:00
|
|
|
#include "test/scenario/scenario_config.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
namespace test {
|
|
|
|
|
class LoggingNetworkControllerFactory
|
|
|
|
|
: public NetworkControllerFactoryInterface {
|
|
|
|
|
public:
|
2019-01-16 17:25:44 +01:00
|
|
|
LoggingNetworkControllerFactory(LogWriterFactoryInterface* log_writer_factory,
|
2018-09-27 13:47:01 +02:00
|
|
|
TransportControllerConfig config);
|
|
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(LoggingNetworkControllerFactory);
|
|
|
|
|
~LoggingNetworkControllerFactory();
|
|
|
|
|
std::unique_ptr<NetworkControllerInterface> Create(
|
|
|
|
|
NetworkControllerConfig config) override;
|
|
|
|
|
TimeDelta GetProcessInterval() const override;
|
|
|
|
|
// TODO(srte): Consider using the Columnprinter interface for this.
|
|
|
|
|
void LogCongestionControllerStats(Timestamp at_time);
|
|
|
|
|
RtcEventLog* GetEventLog() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::unique_ptr<RtcEventLog> event_log_;
|
2018-12-18 15:53:04 +01:00
|
|
|
std::unique_ptr<NetworkControllerFactoryInterface> owned_cc_factory_;
|
|
|
|
|
NetworkControllerFactoryInterface* cc_factory_ = nullptr;
|
2018-09-27 13:47:01 +02:00
|
|
|
std::unique_ptr<ControlStatePrinter> cc_printer_;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-22 11:49:03 +02:00
|
|
|
struct CallClientFakeAudio {
|
|
|
|
|
rtc::scoped_refptr<AudioProcessing> apm;
|
|
|
|
|
rtc::scoped_refptr<TestAudioDeviceModule> fake_audio_device;
|
|
|
|
|
rtc::scoped_refptr<AudioState> audio_state;
|
|
|
|
|
};
|
2018-09-27 13:47:01 +02:00
|
|
|
// CallClient represents a participant in a call scenario. It is created by the
|
|
|
|
|
// Scenario class and is used as sender and receiver when setting up a media
|
|
|
|
|
// stream session.
|
2019-01-04 15:45:01 +01:00
|
|
|
class CallClient : public EmulatedNetworkReceiverInterface {
|
2018-09-27 13:47:01 +02:00
|
|
|
public:
|
2018-12-19 13:14:41 +01:00
|
|
|
CallClient(Clock* clock,
|
2019-01-16 17:25:44 +01:00
|
|
|
std::unique_ptr<LogWriterFactoryInterface> log_writer_factory,
|
2018-12-19 13:14:41 +01:00
|
|
|
CallClientConfig config);
|
2018-09-27 13:47:01 +02:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(CallClient);
|
|
|
|
|
|
|
|
|
|
~CallClient();
|
|
|
|
|
ColumnPrinter StatsPrinter();
|
|
|
|
|
Call::Stats GetStats();
|
2018-10-22 11:49:03 +02:00
|
|
|
DataRate send_bandwidth() {
|
|
|
|
|
return DataRate::bps(GetStats().send_bandwidth_bps);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-04 15:45:01 +01:00
|
|
|
void OnPacketReceived(EmulatedIpPacket packet) override;
|
2019-01-16 17:25:44 +01:00
|
|
|
std::unique_ptr<RtcEventLogOutput> GetLogWriter(std::string name);
|
2018-09-27 13:47:01 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend class Scenario;
|
2018-10-22 11:49:03 +02:00
|
|
|
friend class CallClientPair;
|
2018-09-27 13:47:01 +02:00
|
|
|
friend class SendVideoStream;
|
2018-10-22 11:49:03 +02:00
|
|
|
friend class VideoStreamPair;
|
2018-09-27 13:47:01 +02:00
|
|
|
friend class ReceiveVideoStream;
|
|
|
|
|
friend class SendAudioStream;
|
|
|
|
|
friend class ReceiveAudioStream;
|
2018-10-22 11:49:03 +02:00
|
|
|
friend class AudioStreamPair;
|
2018-09-27 13:47:01 +02:00
|
|
|
friend class NetworkNodeTransport;
|
|
|
|
|
uint32_t GetNextVideoSsrc();
|
2019-02-20 11:16:19 +01:00
|
|
|
uint32_t GetNextVideoLocalSsrc();
|
2018-09-27 13:47:01 +02:00
|
|
|
uint32_t GetNextAudioSsrc();
|
2019-02-20 11:16:19 +01:00
|
|
|
uint32_t GetNextAudioLocalSsrc();
|
2018-09-27 13:47:01 +02:00
|
|
|
uint32_t GetNextRtxSsrc();
|
|
|
|
|
std::string GetNextPriorityId();
|
2018-11-12 16:44:16 +01:00
|
|
|
void AddExtensions(std::vector<RtpExtension> extensions);
|
2018-09-27 13:47:01 +02:00
|
|
|
|
|
|
|
|
Clock* clock_;
|
2019-01-16 17:25:44 +01:00
|
|
|
const std::unique_ptr<LogWriterFactoryInterface> log_writer_factory_;
|
2018-09-27 13:47:01 +02:00
|
|
|
LoggingNetworkControllerFactory network_controller_factory_;
|
2018-10-22 11:49:03 +02:00
|
|
|
CallClientFakeAudio fake_audio_setup_;
|
2018-09-27 13:47:01 +02:00
|
|
|
std::unique_ptr<Call> call_;
|
2018-10-22 11:49:03 +02:00
|
|
|
NetworkNodeTransport transport_;
|
|
|
|
|
RtpHeaderParser* const header_parser_;
|
2018-09-27 13:47:01 +02:00
|
|
|
|
|
|
|
|
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_;
|
2019-01-04 15:45:01 +01:00
|
|
|
// Stores the configured overhead per known destination endpoint. This is used
|
|
|
|
|
// to subtract the overhead before processing.
|
2018-10-22 11:49:03 +02:00
|
|
|
std::map<uint64_t, DataSize> route_overhead_;
|
2018-09-27 13:47:01 +02:00
|
|
|
int next_video_ssrc_index_ = 0;
|
2019-02-20 11:16:19 +01:00
|
|
|
int next_video_local_ssrc_index_ = 0;
|
2018-09-27 13:47:01 +02:00
|
|
|
int next_rtx_ssrc_index_ = 0;
|
|
|
|
|
int next_audio_ssrc_index_ = 0;
|
2019-02-20 11:16:19 +01:00
|
|
|
int next_audio_local_ssrc_index_ = 0;
|
2018-09-27 13:47:01 +02:00
|
|
|
int next_priority_index_ = 0;
|
2018-10-22 11:49:03 +02:00
|
|
|
std::map<uint32_t, MediaType> ssrc_media_types_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CallClientPair {
|
|
|
|
|
public:
|
|
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(CallClientPair);
|
|
|
|
|
~CallClientPair();
|
|
|
|
|
CallClient* first() { return first_; }
|
|
|
|
|
CallClient* second() { return second_; }
|
|
|
|
|
std::pair<CallClient*, CallClient*> forward() { return {first(), second()}; }
|
|
|
|
|
std::pair<CallClient*, CallClient*> reverse() { return {second(), first()}; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend class Scenario;
|
|
|
|
|
CallClientPair(CallClient* first, CallClient* second)
|
|
|
|
|
: first_(first), second_(second) {}
|
|
|
|
|
CallClient* const first_;
|
|
|
|
|
CallClient* const second_;
|
2018-09-27 13:47:01 +02:00
|
|
|
};
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // TEST_SCENARIO_CALL_CLIENT_H_
|