Don't restart streams in scenario tests.
This CL changes the behavior for RunFor and RunUntil so they do not anymore restart the underlying streams every time they are called. This has a side effect on the semantics of the calls. Previously, both RunUntil and RunFor would restart the session and run until the given time had passed. Now RunFor will still run for the provided duration, however, to make the name of RunUntil more correct, it will run until the time since start is equal to the max_duration parameter. An extra overload of RunUntil was added to allow using this behavior without providing an ending condition. Bug: webrtc:9510 Change-Id: I9fe56a44116907fba3d102894b5c96af2ba6cffb Reviewed-on: https://webrtc-review.googlesource.com/c/111502 Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25726}
This commit is contained in:
parent
0e4dfcbcf4
commit
49a7843030
@ -152,6 +152,7 @@ SendAudioStream::~SendAudioStream() {
|
||||
|
||||
void SendAudioStream::Start() {
|
||||
send_stream_->Start();
|
||||
sender_->call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp);
|
||||
}
|
||||
|
||||
ColumnPrinter SendAudioStream::StatsPrinter() {
|
||||
@ -192,6 +193,11 @@ ReceiveAudioStream::~ReceiveAudioStream() {
|
||||
receiver_->call_->DestroyAudioReceiveStream(receive_stream_);
|
||||
}
|
||||
|
||||
void ReceiveAudioStream::Start() {
|
||||
receive_stream_->Start();
|
||||
receiver_->call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp);
|
||||
}
|
||||
|
||||
AudioStreamPair::~AudioStreamPair() = default;
|
||||
|
||||
AudioStreamPair::AudioStreamPair(
|
||||
|
||||
@ -50,6 +50,7 @@ class ReceiveAudioStream {
|
||||
public:
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(ReceiveAudioStream);
|
||||
~ReceiveAudioStream();
|
||||
void Start();
|
||||
|
||||
private:
|
||||
friend class Scenario;
|
||||
|
||||
@ -75,6 +75,8 @@ Scenario::Scenario(std::string file_name, bool real_time)
|
||||
}
|
||||
|
||||
Scenario::~Scenario() {
|
||||
if (start_time_.IsFinite())
|
||||
Stop();
|
||||
if (!real_time_mode_)
|
||||
rtc::SetClockForTesting(nullptr);
|
||||
}
|
||||
@ -305,35 +307,18 @@ void Scenario::At(TimeDelta offset, std::function<void()> function) {
|
||||
}
|
||||
|
||||
void Scenario::RunFor(TimeDelta duration) {
|
||||
RunUntil(duration, TimeDelta::PlusInfinity(), []() { return false; });
|
||||
RunUntil(Duration() + duration);
|
||||
}
|
||||
|
||||
void Scenario::RunUntil(TimeDelta max_duration) {
|
||||
RunUntil(max_duration, TimeDelta::PlusInfinity(), []() { return false; });
|
||||
}
|
||||
|
||||
void Scenario::RunUntil(TimeDelta max_duration,
|
||||
TimeDelta poll_interval,
|
||||
std::function<bool()> exit_function) {
|
||||
start_time_ = Timestamp::us(clock_->TimeInMicroseconds());
|
||||
for (auto& activity : repeated_activities_) {
|
||||
activity->SetStartTime(start_time_);
|
||||
}
|
||||
|
||||
for (auto& stream_pair : video_streams_)
|
||||
stream_pair->receive()->receive_stream_->Start();
|
||||
for (auto& stream_pair : audio_streams_)
|
||||
stream_pair->receive()->receive_stream_->Start();
|
||||
for (auto& stream_pair : video_streams_) {
|
||||
if (stream_pair->config_.autostart) {
|
||||
stream_pair->send()->Start();
|
||||
}
|
||||
}
|
||||
for (auto& stream_pair : audio_streams_) {
|
||||
if (stream_pair->config_.autostart) {
|
||||
stream_pair->send()->Start();
|
||||
}
|
||||
}
|
||||
for (auto& call : clients_) {
|
||||
call->call_->SignalChannelNetworkState(MediaType::AUDIO, kNetworkUp);
|
||||
call->call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp);
|
||||
}
|
||||
if (start_time_.IsInfinite())
|
||||
Start();
|
||||
|
||||
rtc::Event done_;
|
||||
while (!exit_function() && Duration() < max_duration) {
|
||||
@ -363,6 +348,32 @@ void Scenario::RunUntil(TimeDelta max_duration,
|
||||
1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Scenario::Start() {
|
||||
start_time_ = Timestamp::us(clock_->TimeInMicroseconds());
|
||||
for (auto& activity : repeated_activities_) {
|
||||
activity->SetStartTime(start_time_);
|
||||
}
|
||||
|
||||
for (auto& stream_pair : video_streams_)
|
||||
stream_pair->receive()->Start();
|
||||
for (auto& stream_pair : audio_streams_)
|
||||
stream_pair->receive()->Start();
|
||||
for (auto& stream_pair : video_streams_) {
|
||||
if (stream_pair->config_.autostart) {
|
||||
stream_pair->send()->Start();
|
||||
}
|
||||
}
|
||||
for (auto& stream_pair : audio_streams_) {
|
||||
if (stream_pair->config_.autostart) {
|
||||
stream_pair->send()->Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Scenario::Stop() {
|
||||
RTC_DCHECK(start_time_.IsFinite());
|
||||
for (auto& stream_pair : video_streams_) {
|
||||
stream_pair->send()->video_capturer_->Stop();
|
||||
stream_pair->send()->send_stream_->Stop();
|
||||
@ -373,6 +384,7 @@ void Scenario::RunUntil(TimeDelta max_duration,
|
||||
stream_pair->receive()->receive_stream_->Stop();
|
||||
for (auto& stream_pair : audio_streams_)
|
||||
stream_pair->receive()->receive_stream_->Stop();
|
||||
start_time_ = Timestamp::PlusInfinity();
|
||||
}
|
||||
|
||||
Timestamp Scenario::Now() {
|
||||
@ -380,6 +392,8 @@ Timestamp Scenario::Now() {
|
||||
}
|
||||
|
||||
TimeDelta Scenario::Duration() {
|
||||
if (start_time_.IsInfinite())
|
||||
return TimeDelta::Zero();
|
||||
return Now() - start_time_;
|
||||
}
|
||||
|
||||
|
||||
@ -140,9 +140,12 @@ class Scenario {
|
||||
// Runs the scenario for the given time or until the exit function returns
|
||||
// true.
|
||||
void RunFor(TimeDelta duration);
|
||||
void RunUntil(TimeDelta max_duration);
|
||||
void RunUntil(TimeDelta max_duration,
|
||||
TimeDelta probe_interval,
|
||||
std::function<bool()> exit_function);
|
||||
void Start();
|
||||
void Stop();
|
||||
|
||||
// Triggers sending of dummy packets over the given nodes.
|
||||
void TriggerPacketBurst(std::vector<NetworkNode*> over_nodes,
|
||||
|
||||
@ -256,6 +256,7 @@ SendVideoStream::~SendVideoStream() {
|
||||
void SendVideoStream::Start() {
|
||||
send_stream_->Start();
|
||||
video_capturer_->Start();
|
||||
sender_->call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp);
|
||||
}
|
||||
|
||||
void SendVideoStream::UpdateConfig(
|
||||
@ -375,6 +376,11 @@ ReceiveVideoStream::~ReceiveVideoStream() {
|
||||
receiver_->call_->DestroyFlexfecReceiveStream(flecfec_stream_);
|
||||
}
|
||||
|
||||
void ReceiveVideoStream::Start() {
|
||||
receive_stream_->Start();
|
||||
receiver_->call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp);
|
||||
}
|
||||
|
||||
VideoStreamPair::~VideoStreamPair() = default;
|
||||
|
||||
VideoStreamPair::VideoStreamPair(CallClient* sender,
|
||||
|
||||
@ -65,6 +65,7 @@ class ReceiveVideoStream {
|
||||
public:
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(ReceiveVideoStream);
|
||||
~ReceiveVideoStream();
|
||||
void Start();
|
||||
|
||||
private:
|
||||
friend class Scenario;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user