minyue | 939df96 | 2017-04-19 01:58:38 -0700 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_ |
| 12 | #define RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_ |
minyue | 939df96 | 2017-04-19 01:58:38 -0700 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | |
Danil Chapovalov | 3993b18 | 2019-03-27 19:42:15 +0100 | [diff] [blame] | 17 | #include "api/task_queue/task_queue_factory.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 18 | #include "rtc_base/constructor_magic.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "rtc_base/ignore_wundef.h" |
Sebastian Jansson | b55015e | 2019-04-09 13:44:04 +0200 | [diff] [blame] | 20 | #include "rtc_base/synchronization/sequence_checker.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "rtc_base/task_queue.h" |
minyue | 939df96 | 2017-04-19 01:58:38 -0700 | [diff] [blame] | 22 | |
| 23 | #ifdef WEBRTC_NETWORK_TESTER_PROTO |
| 24 | RTC_PUSH_IGNORING_WUNDEF() |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "rtc_tools/network_tester/network_tester_packet.pb.h" |
minyue | 939df96 | 2017-04-19 01:58:38 -0700 | [diff] [blame] | 26 | RTC_POP_IGNORING_WUNDEF() |
| 27 | using webrtc::network_tester::packet::NetworkTesterPacket; |
| 28 | #else |
| 29 | class NetworkTesterPacket; |
| 30 | #endif // WEBRTC_NETWORK_TESTER_PROTO |
| 31 | |
| 32 | namespace webrtc { |
| 33 | |
| 34 | class TestController; |
| 35 | |
| 36 | class PacketSender { |
| 37 | public: |
| 38 | PacketSender(TestController* test_controller, |
| 39 | const std::string& config_file_path); |
| 40 | ~PacketSender(); |
| 41 | |
| 42 | void StartSending(); |
| 43 | void StopSending(); |
| 44 | bool IsSending() const; |
| 45 | |
| 46 | void SendPacket(); |
| 47 | |
| 48 | int64_t GetSendIntervalMs() const; |
| 49 | void UpdateTestSetting(size_t packet_size, int64_t send_interval_ms); |
| 50 | |
| 51 | private: |
Sebastian Jansson | b55015e | 2019-04-09 13:44:04 +0200 | [diff] [blame] | 52 | SequenceChecker worker_queue_checker_; |
Niels Möller | 1e06289 | 2018-02-07 10:18:32 +0100 | [diff] [blame] | 53 | size_t packet_size_ RTC_GUARDED_BY(worker_queue_checker_); |
| 54 | int64_t send_interval_ms_ RTC_GUARDED_BY(worker_queue_checker_); |
| 55 | int64_t sequence_number_ RTC_GUARDED_BY(worker_queue_checker_); |
| 56 | bool sending_ RTC_GUARDED_BY(worker_queue_checker_); |
minyue | 939df96 | 2017-04-19 01:58:38 -0700 | [diff] [blame] | 57 | const std::string config_file_path_; |
| 58 | TestController* const test_controller_; |
Danil Chapovalov | 3993b18 | 2019-03-27 19:42:15 +0100 | [diff] [blame] | 59 | std::unique_ptr<TaskQueueFactory> task_queue_factory_; |
minyue | 939df96 | 2017-04-19 01:58:38 -0700 | [diff] [blame] | 60 | rtc::TaskQueue worker_queue_; |
| 61 | |
| 62 | RTC_DISALLOW_COPY_AND_ASSIGN(PacketSender); |
| 63 | }; |
| 64 | |
| 65 | } // namespace webrtc |
| 66 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 67 | #endif // RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_ |