2018-09-27 13:47:01 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright 2018 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.
|
|
|
|
|
*/
|
2019-04-01 09:18:14 +02:00
|
|
|
#include <atomic>
|
2018-09-27 13:47:01 +02:00
|
|
|
|
|
|
|
|
#include "test/scenario/scenario.h"
|
|
|
|
|
#include "test/gtest.h"
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
|
|
|
|
TEST(ScenarioTest, StartsAndStopsWithoutErrors) {
|
2019-04-01 09:18:14 +02:00
|
|
|
std::atomic<bool> packet_received(false);
|
|
|
|
|
std::atomic<bool> bitrate_changed(false);
|
2018-09-27 13:47:01 +02:00
|
|
|
Scenario s;
|
|
|
|
|
CallClientConfig call_client_config;
|
|
|
|
|
call_client_config.transport.rates.start_rate = DataRate::kbps(300);
|
|
|
|
|
auto* alice = s.CreateClient("alice", call_client_config);
|
|
|
|
|
auto* bob = s.CreateClient("bob", call_client_config);
|
|
|
|
|
NetworkNodeConfig network_config;
|
|
|
|
|
auto alice_net = s.CreateSimulationNode(network_config);
|
|
|
|
|
auto bob_net = s.CreateSimulationNode(network_config);
|
2018-10-22 11:49:03 +02:00
|
|
|
auto route = s.CreateRoutes(alice, {alice_net}, bob, {bob_net});
|
2018-09-27 13:47:01 +02:00
|
|
|
|
|
|
|
|
VideoStreamConfig video_stream_config;
|
2018-10-22 11:49:03 +02:00
|
|
|
s.CreateVideoStream(route->forward(), video_stream_config);
|
|
|
|
|
s.CreateVideoStream(route->reverse(), video_stream_config);
|
2018-09-27 13:47:01 +02:00
|
|
|
|
|
|
|
|
AudioStreamConfig audio_stream_config;
|
2018-10-11 19:48:05 +02:00
|
|
|
audio_stream_config.encoder.min_rate = DataRate::kbps(6);
|
|
|
|
|
audio_stream_config.encoder.max_rate = DataRate::kbps(64);
|
|
|
|
|
audio_stream_config.encoder.allocate_bitrate = true;
|
|
|
|
|
audio_stream_config.stream.in_bandwidth_estimation = false;
|
2018-10-22 11:49:03 +02:00
|
|
|
s.CreateAudioStream(route->forward(), audio_stream_config);
|
|
|
|
|
s.CreateAudioStream(route->reverse(), audio_stream_config);
|
2018-09-27 13:47:01 +02:00
|
|
|
|
|
|
|
|
CrossTrafficConfig cross_traffic_config;
|
|
|
|
|
s.CreateCrossTraffic({alice_net}, cross_traffic_config);
|
|
|
|
|
|
|
|
|
|
s.NetworkDelayedAction({alice_net, bob_net}, 100,
|
|
|
|
|
[&packet_received] { packet_received = true; });
|
|
|
|
|
s.Every(TimeDelta::ms(10), [alice, bob, &bitrate_changed] {
|
|
|
|
|
if (alice->GetStats().send_bandwidth_bps != 300000 &&
|
|
|
|
|
bob->GetStats().send_bandwidth_bps != 300000)
|
|
|
|
|
bitrate_changed = true;
|
|
|
|
|
});
|
|
|
|
|
s.RunUntil(TimeDelta::seconds(2), TimeDelta::ms(5),
|
|
|
|
|
[&bitrate_changed, &packet_received] {
|
|
|
|
|
return packet_received && bitrate_changed;
|
|
|
|
|
});
|
|
|
|
|
EXPECT_TRUE(packet_received);
|
|
|
|
|
EXPECT_TRUE(bitrate_changed);
|
|
|
|
|
}
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|