| OLD | NEW |
| (Empty) |
| 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 #include "webrtc/tools/network_tester/config_reader.h" | |
| 11 | |
| 12 #include <string> | |
| 13 #include <vector> | |
| 14 | |
| 15 namespace webrtc { | |
| 16 | |
| 17 ConfigReader::ConfigReader(const std::string& config_file_path) | |
| 18 : proto_config_index_(0) { | |
| 19 std::ifstream config_stream(config_file_path, | |
| 20 std::ios_base::in | std::ios_base::binary); | |
| 21 RTC_DCHECK(config_stream.is_open()); | |
| 22 RTC_DCHECK(config_stream.good()); | |
| 23 std::string config_data((std::istreambuf_iterator<char>(config_stream)), | |
| 24 (std::istreambuf_iterator<char>())); | |
| 25 if (config_data.size() > 0) { | |
| 26 proto_all_configs_.ParseFromString(config_data); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 ConfigReader::~ConfigReader() = default; | |
| 31 | |
| 32 rtc::Optional<ConfigReader::Config> ConfigReader::GetNextConfig() { | |
| 33 #ifdef WEBRTC_NETWORK_TESTER_PROTO | |
| 34 if (proto_config_index_ >= proto_all_configs_.configs_size()) | |
| 35 return rtc::Optional<Config>(); | |
| 36 auto proto_config = proto_all_configs_.configs(proto_config_index_++); | |
| 37 RTC_DCHECK(proto_config.has_packet_send_interval_ms()); | |
| 38 RTC_DCHECK(proto_config.has_packet_size()); | |
| 39 RTC_DCHECK(proto_config.has_execution_time_ms()); | |
| 40 Config config; | |
| 41 config.packet_send_interval_ms = proto_config.packet_send_interval_ms(); | |
| 42 config.packet_size = proto_config.packet_size(); | |
| 43 config.execution_time_ms = proto_config.execution_time_ms(); | |
| 44 return rtc::Optional<Config>(config); | |
| 45 #else | |
| 46 return rtc::Optional<Config>(); | |
| 47 #endif // WEBRTC_NETWORK_TESTER_PROTO | |
| 48 } | |
| 49 | |
| 50 } // namespace webrtc | |
| OLD | NEW |