blob: ffc1118e20dc183eaef65755ea4b63fdc2dce3d9 [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
Danil Chapovalov3993b182019-03-27 19:42:15 +010017#include "api/task_queue/task_queue_factory.h"
Steve Anton10542f22019-01-11 09:11:00 -080018#include "rtc_base/constructor_magic.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/ignore_wundef.h"
Sebastian Janssonb55015e2019-04-09 13:44:04 +020020#include "rtc_base/synchronization/sequence_checker.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "rtc_base/task_queue.h"
minyue939df962017-04-19 01:58:38 -070022
23#ifdef WEBRTC_NETWORK_TESTER_PROTO
24RTC_PUSH_IGNORING_WUNDEF()
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020025#include "rtc_tools/network_tester/network_tester_packet.pb.h"
minyue939df962017-04-19 01:58:38 -070026RTC_POP_IGNORING_WUNDEF()
27using webrtc::network_tester::packet::NetworkTesterPacket;
28#else
29class NetworkTesterPacket;
30#endif // WEBRTC_NETWORK_TESTER_PROTO
31
32namespace webrtc {
33
34class TestController;
35
36class 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 Janssonb55015e2019-04-09 13:44:04 +020052 SequenceChecker worker_queue_checker_;
Niels Möller1e062892018-02-07 10:18:32 +010053 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_);
minyue939df962017-04-19 01:58:38 -070057 const std::string config_file_path_;
58 TestController* const test_controller_;
Danil Chapovalov3993b182019-03-27 19:42:15 +010059 std::unique_ptr<TaskQueueFactory> task_queue_factory_;
minyue939df962017-04-19 01:58:38 -070060 rtc::TaskQueue worker_queue_;
61
62 RTC_DISALLOW_COPY_AND_ASSIGN(PacketSender);
63};
64
65} // namespace webrtc
66
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020067#endif // RTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_