Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: webrtc/audio/test/audio_stats_test.cc

Issue 3008273002: Replace voe_conference_test. (Closed)
Patch Set: rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/audio/test/audio_end_to_end_test.h"
12 #include "webrtc/rtc_base/safe_compare.h"
13 #include "webrtc/system_wrappers/include/sleep.h"
14 #include "webrtc/test/gtest.h"
15
16 namespace webrtc {
17 namespace test {
18 namespace {
19
20 bool IsNear(int reference, int v) {
21 // Margin is 10%.
22 const int error = reference / 10 + 1;
23 return std::abs(reference - v) <= error;
24 }
25
26 class NoLossTest : public AudioEndToEndTest {
27 public:
28 const int kTestDurationMs = 8000;
29 const int kBytesSent = 69351;
30 const int32_t kPacketsSent = 400;
31 const int64_t kRttMs = 100;
32
33 NoLossTest() = default;
34
35 FakeNetworkPipe::Config GetNetworkPipeConfig() const override {
36 FakeNetworkPipe::Config pipe_config;
37 pipe_config.queue_delay_ms = kRttMs / 2;
38 return pipe_config;
39 }
40
41 void PerformTest() override {
42 SleepMs(kTestDurationMs);
43 send_audio_device()->StopRecording();
44 AudioEndToEndTest::PerformTest();
45 }
46
47 void OnStreamsStopped() override {
48 AudioSendStream::Stats send_stats = send_stream()->GetStats();
49 EXPECT_PRED2(IsNear, kBytesSent, send_stats.bytes_sent);
50 EXPECT_PRED2(IsNear, kPacketsSent, send_stats.packets_sent);
51 EXPECT_EQ(0, send_stats.packets_lost);
52 EXPECT_EQ(0.0f, send_stats.fraction_lost);
53 EXPECT_EQ("opus", send_stats.codec_name);
54 // send_stats.jitter_ms
55 EXPECT_PRED2(IsNear, kRttMs, send_stats.rtt_ms);
56 // Send level is 0 because it is cleared in TransmitMixer::StopSend().
57 EXPECT_EQ(0, send_stats.audio_level);
58 // send_stats.total_input_energy
59 // send_stats.total_input_duration
60 EXPECT_EQ(-1.0f, send_stats.aec_quality_min);
61 EXPECT_EQ(-1, send_stats.echo_delay_median_ms);
62 EXPECT_EQ(-1, send_stats.echo_delay_std_ms);
63 EXPECT_EQ(-100, send_stats.echo_return_loss);
64 EXPECT_EQ(-100, send_stats.echo_return_loss_enhancement);
65 EXPECT_EQ(0.0f, send_stats.residual_echo_likelihood);
66 EXPECT_EQ(0.0f, send_stats.residual_echo_likelihood_recent_max);
67 EXPECT_EQ(false, send_stats.typing_noise_detected);
68
69 AudioReceiveStream::Stats recv_stats = receive_stream()->GetStats();
70 EXPECT_PRED2(IsNear, kBytesSent, recv_stats.bytes_rcvd);
71 EXPECT_PRED2(IsNear, kPacketsSent, recv_stats.packets_rcvd);
72 EXPECT_EQ(0u, recv_stats.packets_lost);
73 EXPECT_EQ(0.0f, recv_stats.fraction_lost);
74 EXPECT_EQ("opus", send_stats.codec_name);
75 // recv_stats.jitter_ms
76 // recv_stats.jitter_buffer_ms
77 EXPECT_EQ(20u, recv_stats.jitter_buffer_preferred_ms);
78 // recv_stats.delay_estimate_ms
79 // Receive level is 0 because it is cleared in Channel::StopPlayout().
80 EXPECT_EQ(0, recv_stats.audio_level);
81 // recv_stats.total_output_energy
82 // recv_stats.total_samples_received
83 // recv_stats.total_output_duration
84 // recv_stats.concealed_samples
85 // recv_stats.expand_rate
86 // recv_stats.speech_expand_rate
87 EXPECT_EQ(0.0, recv_stats.secondary_decoded_rate);
88 EXPECT_EQ(0.0, recv_stats.secondary_discarded_rate);
89 EXPECT_EQ(0.0, recv_stats.accelerate_rate);
90 EXPECT_EQ(0.0, recv_stats.preemptive_expand_rate);
91 EXPECT_EQ(0, recv_stats.decoding_calls_to_silence_generator);
92 // recv_stats.decoding_calls_to_neteq
93 // recv_stats.decoding_normal
94 // recv_stats.decoding_plc
95 EXPECT_EQ(0, recv_stats.decoding_cng);
96 // recv_stats.decoding_plc_cng
97 // recv_stats.decoding_muted_output
98 // Capture start time is -1 because we do not have an associated send stream
99 // on the receiver side.
100 EXPECT_EQ(-1, recv_stats.capture_start_ntp_time_ms);
101
102 // Match these stats between caller and receiver.
103 EXPECT_EQ(send_stats.local_ssrc, recv_stats.remote_ssrc);
104 EXPECT_EQ(*send_stats.codec_payload_type, *recv_stats.codec_payload_type);
105 EXPECT_TRUE(rtc::SafeEq(send_stats.ext_seqnum, recv_stats.ext_seqnum));
106 }
107 };
108 } // namespace
109
110 using AudioStatsTest = CallTest;
111
112 TEST_F(AudioStatsTest, NoLoss) {
113 NoLossTest test;
114 RunBaseTest(&test);
115 }
116
117 } // namespace test
118 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/test/audio_end_to_end_test.cc ('k') | webrtc/audio/test/low_bandwidth_audio_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698