blob: 80e2faf1626afd1d0b7ac4d4f7cf88b1d9988776 [file] [log] [blame]
Sebastian Jansson98b07e92018-09-27 13:47:01 +02001/*
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 TEST_SCENARIO_CALL_CLIENT_H_
11#define TEST_SCENARIO_CALL_CLIENT_H_
12#include <memory>
13#include <string>
14#include <vector>
15
16#include "call/call.h"
17#include "logging/rtc_event_log/rtc_event_log.h"
18#include "modules/audio_device/include/test_audio_device.h"
19#include "modules/congestion_controller/test/controller_printer.h"
20#include "rtc_base/constructormagic.h"
21#include "test/scenario/column_printer.h"
22#include "test/scenario/scenario_config.h"
23
24namespace webrtc {
25
26namespace test {
27class LoggingNetworkControllerFactory
28 : public NetworkControllerFactoryInterface {
29 public:
30 LoggingNetworkControllerFactory(std::string filename,
31 TransportControllerConfig config);
32 RTC_DISALLOW_COPY_AND_ASSIGN(LoggingNetworkControllerFactory);
33 ~LoggingNetworkControllerFactory();
34 std::unique_ptr<NetworkControllerInterface> Create(
35 NetworkControllerConfig config) override;
36 TimeDelta GetProcessInterval() const override;
37 // TODO(srte): Consider using the Columnprinter interface for this.
38 void LogCongestionControllerStats(Timestamp at_time);
39 RtcEventLog* GetEventLog() const;
40
41 private:
42 std::unique_ptr<RtcEventLog> event_log_;
43 std::unique_ptr<NetworkControllerFactoryInterface> cc_factory_;
44 std::unique_ptr<ControlStatePrinter> cc_printer_;
45 FILE* cc_out_ = nullptr;
46};
47
48// CallClient represents a participant in a call scenario. It is created by the
49// Scenario class and is used as sender and receiver when setting up a media
50// stream session.
51class CallClient {
52 public:
53 CallClient(Clock* clock, std::string log_filename, CallClientConfig config);
54 RTC_DISALLOW_COPY_AND_ASSIGN(CallClient);
55
56 ~CallClient();
57 ColumnPrinter StatsPrinter();
58 Call::Stats GetStats();
59
60 private:
61 friend class Scenario;
62 friend class SendVideoStream;
63 friend class ReceiveVideoStream;
64 friend class SendAudioStream;
65 friend class ReceiveAudioStream;
66 friend class NetworkNodeTransport;
67 // TODO(srte): Consider using the Columnprinter interface for this.
68 void DeliverPacket(MediaType media_type,
69 rtc::CopyOnWriteBuffer packet,
70 Timestamp at_time);
71 uint32_t GetNextVideoSsrc();
72 uint32_t GetNextAudioSsrc();
73 uint32_t GetNextRtxSsrc();
74 std::string GetNextPriorityId();
75
76 Clock* clock_;
77 LoggingNetworkControllerFactory network_controller_factory_;
78 std::unique_ptr<Call> call_;
79
80 rtc::scoped_refptr<AudioState> InitAudio();
81
82 rtc::scoped_refptr<AudioProcessing> apm_;
83 rtc::scoped_refptr<TestAudioDeviceModule> fake_audio_device_;
84
85 std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_;
86 int next_video_ssrc_index_ = 0;
87 int next_rtx_ssrc_index_ = 0;
88 int next_audio_ssrc_index_ = 0;
89 int next_priority_index_ = 0;
90};
91} // namespace test
92} // namespace webrtc
93
94#endif // TEST_SCENARIO_CALL_CLIENT_H_