webrtc_m130/test/network/schedulable_network_behavior.h
Per Kjellander a0d1a51217 Reland "Add SchedulableNetworkBehavior and tests."
This reverts commit 045589e64c2058caf2d246f5dfa51c8f1fadfd03.

Reason for revert: Test flakiness fixed in https://webrtc-review.googlesource.com/c/src/+/352660

Original change's description:
> Revert "Add SchedulableNetworkBehavior and tests."
>
> This reverts commit 06815534d2da29a7f41cad2eaab6d2103f0138c2.
>
> Reason for revert: Seems to break importer...
>
> Original change's description:
> > Add SchedulableNetworkBehavior and tests.
> >
> > This is a network behaviour that can change its parameters over time as specified with a schedule proto.
> >
> > Bug: webrtc:14525
> > Change-Id: Idd34cc48c8e3e8311975615f2c3dc3ffb522a708
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/352140
> > Reviewed-by: Björn Terelius <terelius@webrtc.org>
> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> > Commit-Queue: Per Kjellander <perkj@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#42390}
>
> Bug: webrtc:14525
> Change-Id: I4386ffb7629198c74249e416076cab3b4c23a79b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/352501
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Per Kjellander <perkj@webrtc.org>
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Cr-Commit-Position: refs/heads/main@{#42391}

Bug: webrtc:14525
Change-Id: I68f536c67ab15d97fa59700ce6c3c4b9edc1d1b9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/352681
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42403}
2024-05-29 13:17:07 +00:00

57 lines
2.1 KiB
C++

/*
* Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef TEST_NETWORK_SCHEDULABLE_NETWORK_BEHAVIOR_H_
#define TEST_NETWORK_SCHEDULABLE_NETWORK_BEHAVIOR_H_
#include "api/sequence_checker.h"
#include "api/test/network_emulation/network_config_schedule.pb.h"
#include "api/test/simulated_network.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "rtc_base/task_utils/repeating_task.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
#include "test/network/simulated_network.h"
namespace webrtc {
// Network behaviour implementation where parameters change over time as
// specified with a schedule proto.
class SchedulableNetworkBehavior : public SimulatedNetwork {
public:
SchedulableNetworkBehavior(network_behaviour::NetworkConfigSchedule schedule,
Clock& clock);
bool EnqueuePacket(PacketInFlightInfo packet_info) override;
private:
TimeDelta UpdateConfigAndReschedule();
SequenceChecker sequence_checker_;
const network_behaviour::NetworkConfigSchedule schedule_;
Timestamp first_send_time_ RTC_GUARDED_BY(&sequence_checker_) =
Timestamp::MinusInfinity();
Clock& clock_ RTC_GUARDED_BY(&sequence_checker_);
BuiltInNetworkBehaviorConfig config_ RTC_GUARDED_BY(&sequence_checker_);
// Index of the next schedule item to apply.
int next_schedule_index_ RTC_GUARDED_BY(&sequence_checker_) = 0;
// Total time from the first sent packet, until the last time the schedule
// repeat.
TimeDelta wrap_time_delta_ RTC_GUARDED_BY(&sequence_checker_) =
TimeDelta::Zero();
RepeatingTaskHandle schedule_task_ RTC_GUARDED_BY(&sequence_checker_);
};
} // namespace webrtc
#endif // TEST_NETWORK_SCHEDULABLE_NETWORK_BEHAVIOR_H_