Add full stack test cases with a fake network pipe.

R=pbos@webrtc.org
BUG=1872

Review URL: https://webrtc-codereview.appspot.com/20889004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6634 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2014-07-09 11:29:06 +00:00
parent e9cefdef68
commit b8e9e44eac
5 changed files with 122 additions and 37 deletions

View File

@ -104,8 +104,8 @@ void FakeNetworkPipe::SendPacket(const uint8_t* data, size_t data_length) {
if (packet_receiver_ == NULL)
return;
CriticalSectionScoped crit(lock_.get());
if (config_.queue_length > 0 &&
capacity_link_.size() >= config_.queue_length) {
if (config_.queue_length_packets > 0 &&
capacity_link_.size() >= config_.queue_length_packets) {
// Too many packet on the link, drop this one.
++dropped_packets_;
return;

View File

@ -33,14 +33,14 @@ class FakeNetworkPipe {
public:
struct Config {
Config()
: queue_length(0),
: queue_length_packets(0),
queue_delay_ms(0),
delay_standard_deviation_ms(0),
link_capacity_kbps(0),
loss_percent(0) {
}
// Queue length in number of packets.
size_t queue_length;
size_t queue_length_packets;
// Delay in addition to capacity induced delay.
int queue_delay_ms;
// Standard deviation of the extra delay.

View File

@ -65,7 +65,7 @@ void DeleteMemory(uint8_t* data, int length) { delete [] data; }
// Test the capacity link and verify we get as many packets as we expect.
TEST_F(FakeNetworkPipeTest, CapacityTest) {
FakeNetworkPipe::Config config;
config.queue_length = 20;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
pipe->SetReceiver(receiver_.get());
@ -107,7 +107,7 @@ TEST_F(FakeNetworkPipeTest, CapacityTest) {
// Test the extra network delay.
TEST_F(FakeNetworkPipeTest, ExtraDelayTest) {
FakeNetworkPipe::Config config;
config.queue_length = 20;
config.queue_length_packets = 20;
config.queue_delay_ms = 100;
config.link_capacity_kbps = 80;
scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
@ -144,7 +144,7 @@ TEST_F(FakeNetworkPipeTest, ExtraDelayTest) {
// packets too quickly.
TEST_F(FakeNetworkPipeTest, QueueLengthTest) {
FakeNetworkPipe::Config config;
config.queue_length = 2;
config.queue_length_packets = 2;
config.link_capacity_kbps = 80;
scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
pipe->SetReceiver(receiver_.get());
@ -167,7 +167,7 @@ TEST_F(FakeNetworkPipeTest, QueueLengthTest) {
// Test we get statistics as expected.
TEST_F(FakeNetworkPipeTest, StatisticsTest) {
FakeNetworkPipe::Config config;
config.queue_length = 2;
config.queue_length_packets = 2;
config.queue_delay_ms = 20;
config.link_capacity_kbps = 80;
scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
@ -197,7 +197,7 @@ TEST_F(FakeNetworkPipeTest, StatisticsTest) {
// delivery times change accordingly.
TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
FakeNetworkPipe::Config config;
config.queue_length = 20;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
pipe->SetReceiver(receiver_.get());
@ -255,7 +255,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
// delivery times change accordingly.
TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
FakeNetworkPipe::Config config;
config.queue_length = 20;
config.queue_length_packets = 20;
config.link_capacity_kbps = 80;
scoped_ptr<FakeNetworkPipe> pipe(new FakeNetworkPipe(config));
pipe->SetReceiver(receiver_.get());

View File

@ -35,7 +35,7 @@
namespace webrtc {
static const int kFullStackTestDurationSecs = 10;
static const int kFullStackTestDurationSecs = 60;
struct FullStackTestParams {
const char* test_label;
@ -44,14 +44,17 @@ struct FullStackTestParams {
size_t width, height;
int fps;
} clip;
unsigned int bitrate;
int min_bitrate_bps;
int target_bitrate_bps;
int max_bitrate_bps;
double avg_psnr_threshold;
double avg_ssim_threshold;
FakeNetworkPipe::Config link;
};
class FullStackTest : public test::CallTest {
protected:
void TestWithoutPacketLoss(const FullStackTestParams& params);
void RunTest(const FullStackTestParams& params);
};
class VideoAnalyzer : public PacketReceiver,
@ -367,19 +370,21 @@ class VideoAnalyzer : public PacketReceiver,
const scoped_ptr<EventWrapper> done_;
};
void FullStackTest::TestWithoutPacketLoss(const FullStackTestParams& params) {
test::DirectTransport transport;
void FullStackTest::RunTest(const FullStackTestParams& params) {
test::DirectTransport send_transport(params.link);
test::DirectTransport recv_transport(params.link);
VideoAnalyzer analyzer(NULL,
&transport,
&send_transport,
params.test_label,
params.avg_psnr_threshold,
params.avg_ssim_threshold,
kFullStackTestDurationSecs * params.clip.fps);
CreateCalls(Call::Config(&analyzer), Call::Config(&analyzer));
CreateCalls(Call::Config(&analyzer), Call::Config(&recv_transport));
analyzer.SetReceiver(receiver_call_->Receiver());
transport.SetReceiver(&analyzer);
send_transport.SetReceiver(&analyzer);
recv_transport.SetReceiver(sender_call_->Receiver());
CreateSendConfig(1);
@ -391,8 +396,9 @@ void FullStackTest::TestWithoutPacketLoss(const FullStackTestParams& params) {
VideoStream* stream = &video_streams_[0];
stream->width = params.clip.width;
stream->height = params.clip.height;
stream->min_bitrate_bps = stream->target_bitrate_bps =
stream->max_bitrate_bps = params.bitrate * 1000;
stream->min_bitrate_bps = params.min_bitrate_bps;
stream->target_bitrate_bps = params.target_bitrate_bps;
stream->max_bitrate_bps = params.max_bitrate_bps;
stream->max_framerate = params.clip.fps;
CreateMatchingReceiveConfigs();
@ -418,32 +424,111 @@ void FullStackTest::TestWithoutPacketLoss(const FullStackTestParams& params) {
analyzer.Wait();
transport.StopSending();
send_transport.StopSending();
recv_transport.StopSending();
Stop();
DestroyStreams();
}
FullStackTestParams paris_qcif = {"net_delay_0_0_plr_0",
{"paris_qcif", 176, 144, 30},
300,
36.0,
0.96};
// TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
FullStackTestParams foreman_cif = {"foreman_cif_net_delay_0_0_plr_0",
{"foreman_cif", 352, 288, 30},
700,
0.0,
0.0};
TEST_F(FullStackTest, ParisQcifWithoutPacketLoss) {
TestWithoutPacketLoss(paris_qcif);
FullStackTestParams paris_qcif = {"net_delay_0_0_plr_0",
{"paris_qcif", 176, 144, 30},
300000,
300000,
300000,
36.0,
0.96
};
RunTest(paris_qcif);
}
TEST_F(FullStackTest, ForemanCifWithoutPacketLoss) {
TestWithoutPacketLoss(foreman_cif);
// TODO(pbos): Decide on psnr/ssim thresholds for foreman_cif.
FullStackTestParams foreman_cif = {"foreman_cif_net_delay_0_0_plr_0",
{"foreman_cif", 352, 288, 30},
700000,
700000,
700000,
0.0,
0.0
};
RunTest(foreman_cif);
}
TEST_F(FullStackTest, ForemanCif500kbps) {
FullStackTestParams foreman_cif = {"foreman_cif_500kbps",
{"foreman_cif", 352, 288, 30},
30000,
500000,
2000000,
0.0,
0.0
};
foreman_cif.link.queue_length_packets = 0;
foreman_cif.link.queue_delay_ms = 0;
foreman_cif.link.link_capacity_kbps = 500;
RunTest(foreman_cif);
}
TEST_F(FullStackTest, ForemanCif500kbpsLimitedQueue) {
FullStackTestParams foreman_cif = {"foreman_cif_500kbps_32pkts_queue",
{"foreman_cif", 352, 288, 30},
30000,
500000,
2000000,
0.0,
0.0
};
foreman_cif.link.queue_length_packets = 32;
foreman_cif.link.queue_delay_ms = 0;
foreman_cif.link.link_capacity_kbps = 500;
RunTest(foreman_cif);
}
TEST_F(FullStackTest, ForemanCif500kbps100ms) {
FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms",
{"foreman_cif", 352, 288, 30},
30000,
500000,
2000000,
0.0,
0.0
};
foreman_cif.link.queue_length_packets = 0;
foreman_cif.link.queue_delay_ms = 100;
foreman_cif.link.link_capacity_kbps = 500;
RunTest(foreman_cif);
}
TEST_F(FullStackTest, ForemanCif500kbps100msLimitedQueue) {
FullStackTestParams foreman_cif = {"foreman_cif_500kbps_100ms_32pkts_queue",
{"foreman_cif", 352, 288, 30},
30000,
500000,
2000000,
0.0,
0.0
};
foreman_cif.link.queue_length_packets = 32;
foreman_cif.link.queue_delay_ms = 100;
foreman_cif.link.link_capacity_kbps = 500;
RunTest(foreman_cif);
}
TEST_F(FullStackTest, ForemanCif1000kbps100msLimitedQueue) {
FullStackTestParams foreman_cif = {"foreman_cif_1000kbps_100ms_32pkts_queue",
{"foreman_cif", 352, 288, 30},
30000,
2000000,
2000000,
0.0,
0.0
};
foreman_cif.link.queue_length_packets = 32;
foreman_cif.link.queue_delay_ms = 100;
foreman_cif.link.link_capacity_kbps = 1000;
RunTest(foreman_cif);
}
} // namespace webrtc

View File

@ -220,7 +220,7 @@ LowRateStreamObserver::LowRateStreamObserver(
kRemoteBitrateEstimatorMinBitrateBps));
forward_transport_config_.link_capacity_kbps =
kHighBandwidthLimitBps / 1000;
forward_transport_config_.queue_length = 100; // Something large.
forward_transport_config_.queue_length_packets = 100; // Something large.
test::DirectTransport::SetConfig(forward_transport_config_);
test::DirectTransport::SetReceiver(this);
}