blob: 7ccecdd84ce668e35c2eff77042734d36cb23aac [file] [log] [blame]
minyue939df962017-04-19 08:58:381/*
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 04:47:3111#ifndef RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_
12#define RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_
minyue939df962017-04-19 08:58:3813
14#include <memory>
15#include <string>
16
Artem Titovd15a5752021-02-10 13:31:2417#include "api/sequence_checker.h"
Danil Chapovalov3993b182019-03-27 18:42:1518#include "api/task_queue/task_queue_factory.h"
Steve Anton10542f22019-01-11 17:11:0019#include "rtc_base/constructor_magic.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3120#include "rtc_base/ignore_wundef.h"
Mirko Bonadei20e4c802020-11-23 10:07:4221#include "rtc_base/system/no_unique_address.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3122#include "rtc_base/task_queue.h"
minyue939df962017-04-19 08:58:3823
24#ifdef WEBRTC_NETWORK_TESTER_PROTO
25RTC_PUSH_IGNORING_WUNDEF()
Mirko Bonadei92ea95e2017-09-15 04:47:3126#include "rtc_tools/network_tester/network_tester_packet.pb.h"
minyue939df962017-04-19 08:58:3827RTC_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 10:07:4253 RTC_NO_UNIQUE_ADDRESS SequenceChecker worker_queue_checker_;
Niels Möller1e062892018-02-07 09:18:3254 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 08:58:3858 const std::string config_file_path_;
59 TestController* const test_controller_;
Danil Chapovalov3993b182019-03-27 18:42:1560 std::unique_ptr<TaskQueueFactory> task_queue_factory_;
minyue939df962017-04-19 08:58:3861 rtc::TaskQueue worker_queue_;
62
63 RTC_DISALLOW_COPY_AND_ASSIGN(PacketSender);
64};
65
66} // namespace webrtc
67
Mirko Bonadei92ea95e2017-09-15 04:47:3168#endif // RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_