blob: 7a265351743b9244772718c1df3a27defd46fcdc [file] [log] [blame]
michaelt333d0ff2017-04-10 23:26:35 -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
11#ifndef WEBRTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_
12#define WEBRTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_
13
14#include <memory>
15#include <string>
16
17#include "webrtc/base/ignore_wundef.h"
18#include "webrtc/base/sequenced_task_checker.h"
19#include "webrtc/base/task_queue.h"
20
21#ifdef WEBRTC_NETWORK_TESTER_PROTO
22RTC_PUSH_IGNORING_WUNDEF()
23#include "webrtc/tools/network_tester/network_tester_packet.pb.h"
24RTC_POP_IGNORING_WUNDEF()
25using webrtc::network_tester::packet::NetworkTesterPacket;
26#else
27class NetworkTesterPacket;
28#endif // WEBRTC_NETWORK_TESTER_PROTO
29
30namespace webrtc {
31
32class TestController;
33
34class PacketSender {
35 public:
36 PacketSender(TestController* test_controller,
37 const std::string& config_file_path);
38 ~PacketSender();
39
40 void StartSending();
41 void StopSending();
42 bool IsSending() const;
43
44 void SendPacket();
45
46 int64_t GetSendIntervalMs() const;
47 void UpdateTestSetting(size_t packet_size, int64_t send_interval_ms);
48
49 private:
50 rtc::TaskQueue worker_queue_;
51 rtc::SequencedTaskChecker worker_queue_checker_;
52
53 size_t packet_size_;
54 int64_t send_interval_ms_;
55 int64_t sequence_number_;
56 bool sending_;
57 const std::string config_file_path_;
58 TestController* const test_controller_;
59
60 RTC_DISALLOW_COPY_AND_ASSIGN(PacketSender);
61};
62
63} // namespace webrtc
64
65#endif // WEBRTC_TOOLS_NETWORK_TESTER_PACKET_SENDER_H_