mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-16 07:10:38 +01:00

This CL makes it possible to change transport routes while running a scenario based test. To make this possible in a consistent manner, the scenario test framework is modified to only allow shared transport for all streams between two CallClients. This is what typically is done in practice and it is quite complex to even reason about the implications of using mixed transports for a single call. Bug: webrtc:9718 Change-Id: Ib836928feed98aa2bbbe0295e158157a6518348b Reviewed-on: https://webrtc-review.googlesource.com/c/107200 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25287}
58 lines
2.3 KiB
C++
58 lines
2.3 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#include "test/scenario/scenario.h"
|
|
#include "test/gtest.h"
|
|
namespace webrtc {
|
|
namespace test {
|
|
TEST(ScenarioTest, StartsAndStopsWithoutErrors) {
|
|
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);
|
|
auto route = s.CreateRoutes(alice, {alice_net}, bob, {bob_net});
|
|
|
|
VideoStreamConfig video_stream_config;
|
|
s.CreateVideoStream(route->forward(), video_stream_config);
|
|
s.CreateVideoStream(route->reverse(), video_stream_config);
|
|
|
|
AudioStreamConfig audio_stream_config;
|
|
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;
|
|
s.CreateAudioStream(route->forward(), audio_stream_config);
|
|
s.CreateAudioStream(route->reverse(), audio_stream_config);
|
|
|
|
CrossTrafficConfig cross_traffic_config;
|
|
s.CreateCrossTraffic({alice_net}, cross_traffic_config);
|
|
|
|
bool packet_received = false;
|
|
s.NetworkDelayedAction({alice_net, bob_net}, 100,
|
|
[&packet_received] { packet_received = true; });
|
|
bool bitrate_changed = false;
|
|
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
|