xref: /aosp_15_r20/external/webrtc/rtc_tools/network_tester/config_reader.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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 
11 #ifndef RTC_TOOLS_NETWORK_TESTER_CONFIG_READER_H_
12 #define RTC_TOOLS_NETWORK_TESTER_CONFIG_READER_H_
13 
14 #include <fstream>
15 #include <string>
16 
17 #include "absl/types/optional.h"
18 #include "rtc_base/ignore_wundef.h"
19 
20 #ifdef WEBRTC_NETWORK_TESTER_PROTO
21 RTC_PUSH_IGNORING_WUNDEF()
22 #include "rtc_tools/network_tester/network_tester_config.pb.h"
23 RTC_POP_IGNORING_WUNDEF()
24 using webrtc::network_tester::config::NetworkTesterAllConfigs;
25 #else
26 class NetworkTesterConfigs;
27 #endif  // WEBRTC_NETWORK_TESTER_PROTO
28 
29 namespace webrtc {
30 
31 class ConfigReader {
32  public:
33   struct Config {
34     int packet_send_interval_ms;
35     int packet_size;
36     int execution_time_ms;
37   };
38   explicit ConfigReader(const std::string& config_file_path);
39   ~ConfigReader();
40 
41   ConfigReader(const ConfigReader&) = delete;
42   ConfigReader& operator=(const ConfigReader&) = delete;
43 
44   absl::optional<Config> GetNextConfig();
45 
46  private:
47   NetworkTesterAllConfigs proto_all_configs_;
48   int proto_config_index_;
49 };
50 
51 }  // namespace webrtc
52 
53 #endif  // RTC_TOOLS_NETWORK_TESTER_CONFIG_READER_H_
54