blob: 7ccecdd84ce668e35c2eff77042734d36cb23aac [file] [log] [blame]
minyue939df962017-04-19 01:58:38 -07001/*
2 * Copyright 2017 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_
12#define RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_
minyue939df962017-04-19 01:58:38 -070013
14#include <memory>
15#include <string>
16
Artem Titovd15a5752021-02-10 14:31:24 +010017#include "api/sequence_checker.h"
Danil Chapovalov3993b182019-03-27 19:42:15 +010018#include "api/task_queue/task_queue_factory.h"
Steve Anton10542f22019-01-11 09:11:00 -080019#include "rtc_base/constructor_magic.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "rtc_base/ignore_wundef.h"
Mirko Bonadei20e4c802020-11-23 11:07:42 +010021#include "rtc_base/system/no_unique_address.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "rtc_base/task_queue.h"
minyue939df962017-04-19 01:58:38 -070023
24#ifdef WEBRTC_NETWORK_TESTER_PROTO
25RTC_PUSH_IGNORING_WUNDEF()
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#include "rtc_tools/network_tester/network_tester_packet.pb.h"
minyue939df962017-04-19 01:58:38 -070027RTC_POP_IGNORING_WUNDEF()
28using webrtc::network_tester::packet::NetworkTesterPacket;
29#else
30class NetworkTesterPacket;
31#endif // WEBRTC_NETWORK_TESTER_PROTO
32
33namespace webrtc {
34
35class TestController;
36
37class PacketSender {
38 public:
39 PacketSender(TestController* test_controller,
40 const std::string& config_file_path);
41 ~PacketSender();
42
43 void StartSending();
44 void StopSending();
45 bool IsSending() const;
46
47 void SendPacket();
48
49 int64_t GetSendIntervalMs() const;
50 void UpdateTestSetting(size_t packet_size, int64_t send_interval_ms);
51
52 private:
Mirko Bonadei20e4c802020-11-23 11:07:42 +010053 RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_queue_checker_;
Niels Möller1e062892018-02-07 10:18:32 +010054 size_t packet_size_ RTC_GUARDED_BY(worker_queue_checker_);
55 int64_t send_interval_ms_ RTC_GUARDED_BY(worker_queue_checker_);
56 int64_t sequence_number_ RTC_GUARDED_BY(worker_queue_checker_);
57 bool sending_ RTC_GUARDED_BY(worker_queue_checker_);
minyue939df962017-04-19 01:58:38 -070058 const std::string config_file_path_;
59 TestController* const test_controller_;
Danil Chapovalov3993b182019-03-27 19:42:15 +010060 std::unique_ptr<TaskQueueFactory> task_queue_factory_;
minyue939df962017-04-19 01:58:38 -070061 rtc::TaskQueue worker_queue_;
62
63 RTC_DISALLOW_COPY_AND_ASSIGN(PacketSender);
64};
65
66} // namespace webrtc
67
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020068#endif // RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_