Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: webrtc/tools/network_tester/packet_sender.cc

Issue 2894673004: increase bitrate precision of the network tester. (Closed)
Patch Set: Fix for bug in SendData. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/tools/network_tester/test_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/tools/network_tester/packet_sender.h" 11 #include "webrtc/tools/network_tester/packet_sender.h"
12 12
13 #include <algorithm>
13 #include <string> 14 #include <string>
14 #include <utility> 15 #include <utility>
15 16
16 #include "webrtc/base/timeutils.h" 17 #include "webrtc/base/timeutils.h"
17 #include "webrtc/tools/network_tester/config_reader.h" 18 #include "webrtc/tools/network_tester/config_reader.h"
18 #include "webrtc/tools/network_tester/test_controller.h" 19 #include "webrtc/tools/network_tester/test_controller.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 22
22 namespace { 23 namespace {
23 24
24 class SendPacketTask : public rtc::QueuedTask { 25 class SendPacketTask : public rtc::QueuedTask {
25 public: 26 public:
26 explicit SendPacketTask(PacketSender* packet_sender) 27 explicit SendPacketTask(PacketSender* packet_sender)
27 : packet_sender_(packet_sender) {} 28 : target_time_ms_(rtc::TimeMillis()), packet_sender_(packet_sender) {}
28 29
29 private: 30 private:
30 bool Run() override { 31 bool Run() override {
31 if (packet_sender_->IsSending()) { 32 if (packet_sender_->IsSending()) {
32 packet_sender_->SendPacket(); 33 packet_sender_->SendPacket();
34 target_time_ms_ += packet_sender_->GetSendIntervalMs();
35 int64_t delay_ms = std::max(static_cast<int64_t>(0),
36 target_time_ms_ - rtc::TimeMillis());
33 rtc::TaskQueue::Current()->PostDelayedTask( 37 rtc::TaskQueue::Current()->PostDelayedTask(
34 std::unique_ptr<QueuedTask>(this), 38 std::unique_ptr<QueuedTask>(this), delay_ms);
35 packet_sender_->GetSendIntervalMs());
36 return false; 39 return false;
37 } else { 40 } else {
38 return true; 41 return true;
39 } 42 }
40 } 43 }
44 int64_t target_time_ms_;
41 PacketSender* const packet_sender_; 45 PacketSender* const packet_sender_;
42 }; 46 };
43 47
44 class UpdateTestSettingTask : public rtc::QueuedTask { 48 class UpdateTestSettingTask : public rtc::QueuedTask {
45 public: 49 public:
46 UpdateTestSettingTask(PacketSender* packet_sender, 50 UpdateTestSettingTask(PacketSender* packet_sender,
47 std::unique_ptr<ConfigReader> config_reader) 51 std::unique_ptr<ConfigReader> config_reader)
48 : packet_sender_(packet_sender), 52 : packet_sender_(packet_sender),
49 config_reader_(std::move(config_reader)) {} 53 config_reader_(std::move(config_reader)) {}
50 54
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 124 }
121 125
122 void PacketSender::UpdateTestSetting(size_t packet_size, 126 void PacketSender::UpdateTestSetting(size_t packet_size,
123 int64_t send_interval_ms) { 127 int64_t send_interval_ms) {
124 RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_queue_checker_); 128 RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_queue_checker_);
125 send_interval_ms_ = send_interval_ms; 129 send_interval_ms_ = send_interval_ms;
126 packet_size_ = packet_size; 130 packet_size_ = packet_size;
127 } 131 }
128 132
129 } // namespace webrtc 133 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/tools/network_tester/test_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698