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

Side by Side Diff: webrtc/voice_engine/test/auto_test/voe_conference_test.cc

Issue 1236793003: Add LoudestFilter in ConferenceTransport (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fixing an indentation Created 5 years, 4 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
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <queue> 11 #include <queue>
12 12
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "webrtc/base/format_macros.h" 14 #include "webrtc/base/format_macros.h"
15 #include "webrtc/base/timeutils.h" 15 #include "webrtc/base/timeutils.h"
16 #include "webrtc/system_wrappers/interface/sleep.h" 16 #include "webrtc/system_wrappers/interface/sleep.h"
17 #include "webrtc/test/testsupport/fileutils.h"
17 #include "webrtc/voice_engine/test/auto_test/fakes/conference_transport.h" 18 #include "webrtc/voice_engine/test/auto_test/fakes/conference_transport.h"
18 19
19 namespace { 20 namespace {
20 static const int kRttMs = 25; 21 static const int kRttMs = 25;
Andrew MacDonald 2015/08/13 19:48:11 This block should not be indented. Also, static o
21 22
22 static bool IsNear(int ref, int comp, int error) { 23 static bool IsNear(int ref, int comp, int error) {
23 return (ref - comp <= error) && (comp - ref >= -error); 24 return (ref - comp <= error) && (comp - ref >= -error);
24 } 25 }
26
27 static void CreateSilenceFile(const std::string& silence_file) {
28 FILE* fid = fopen(silence_file.c_str(), "wb");
29 int16_t temp = 0;
Andrew MacDonald 2015/08/13 19:48:11 nit: const int16_t zero = 0;
30 for (int i = 0; i < 32000; i++) {
Andrew MacDonald 2015/08/13 19:48:11 nit: ++i Is 32000 fixed? Should either be a file-
31 // Write 1 second, but it does not matter since the file will be looped.
32 fwrite(&temp, 2, 1, fid);
Andrew MacDonald 2015/08/13 19:48:11 sizeof(int16_t)
33 }
34 fclose(fid);
35 }
36
37 static const std::string kInputFileName =
Andrew MacDonald 2015/08/13 19:48:11 Variables with static storage duration must be POD
38 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
39 static const webrtc::FileFormats kInputFormat =
40 webrtc::kFileFormatPcm32kHzFile;
25 } 41 }
26 42
27 namespace voetest { 43 namespace voetest {
28 44
29 TEST(VoeConferenceTest, RttAndStartNtpTime) { 45 TEST(VoeConferenceTest, RttAndStartNtpTime) {
30 struct Stats { 46 struct Stats {
31 Stats(int64_t rtt_receiver_1, int64_t rtt_receiver_2, int64_t ntp_delay) 47 Stats(int64_t rtt_receiver_1, int64_t rtt_receiver_2, int64_t ntp_delay)
32 : rtt_receiver_1_(rtt_receiver_1), 48 : rtt_receiver_1_(rtt_receiver_1),
33 rtt_receiver_2_(rtt_receiver_2), 49 rtt_receiver_2_(rtt_receiver_2),
34 ntp_delay_(ntp_delay) { 50 ntp_delay_(ntp_delay) {
35 } 51 }
36 int64_t rtt_receiver_1_; 52 int64_t rtt_receiver_1_;
37 int64_t rtt_receiver_2_; 53 int64_t rtt_receiver_2_;
38 int64_t ntp_delay_; 54 int64_t ntp_delay_;
39 }; 55 };
40 56
41 const int kDelayMs = 987; 57 const int kDelayMs = 987;
42 ConferenceTransport trans; 58 ConferenceTransport trans;
43 trans.SetRtt(kRttMs); 59 trans.SetRtt(kRttMs);
44 60
45 unsigned int id_1 = trans.AddStream(); 61 unsigned int id_1 = trans.AddStream(kInputFileName, kInputFormat);
46 unsigned int id_2 = trans.AddStream(); 62 unsigned int id_2 = trans.AddStream(kInputFileName, kInputFormat);
47 63
48 EXPECT_TRUE(trans.StartPlayout(id_1)); 64 EXPECT_TRUE(trans.StartPlayout(id_1));
49 // Start NTP time is the time when a stream is played out, rather than 65 // Start NTP time is the time when a stream is played out, rather than
50 // when it is added. 66 // when it is added.
51 webrtc::SleepMs(kDelayMs); 67 webrtc::SleepMs(kDelayMs);
52 EXPECT_TRUE(trans.StartPlayout(id_2)); 68 EXPECT_TRUE(trans.StartPlayout(id_2));
53 69
54 const int kMaxRunTimeMs = 25000; 70 const int kMaxRunTimeMs = 25000;
55 const int kNeedSuccessivePass = 3; 71 const int kNeedSuccessivePass = 3;
56 const int kStatsRequestIntervalMs = 1000; 72 const int kStatsRequestIntervalMs = 1000;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 printf("The most recent values (RTT for receiver 1, RTT for receiver 2, " 114 printf("The most recent values (RTT for receiver 1, RTT for receiver 2, "
99 "NTP delay between receiver 1 and 2) are (from oldest):\n"); 115 "NTP delay between receiver 1 and 2) are (from oldest):\n");
100 while (!stats_buffer.empty()) { 116 while (!stats_buffer.empty()) {
101 Stats stats = stats_buffer.front(); 117 Stats stats = stats_buffer.front();
102 printf("(%" PRId64 ", %" PRId64 ", %" PRId64 ")\n", stats.rtt_receiver_1_, 118 printf("(%" PRId64 ", %" PRId64 ", %" PRId64 ")\n", stats.rtt_receiver_1_,
103 stats.rtt_receiver_2_, stats.ntp_delay_); 119 stats.rtt_receiver_2_, stats.ntp_delay_);
104 stats_buffer.pop(); 120 stats_buffer.pop();
105 } 121 }
106 } 122 }
107 } 123 }
124
125
126 TEST(VoeConferenceTest, ReceivedPackets) {
127 const int kPackets = 50;
128 const int kPacketDurationMs = 20; // Correspond to Opus.
129 const std::string silence_file =
130 webrtc::test::TempFilename(webrtc::test::OutputPath(), "silence");
131 CreateSilenceFile(silence_file);
132
133 {
134 ConferenceTransport trans;
135 // Add silence to stream 0, so that it will be filtered out.
136 unsigned int id_0 = trans.AddStream(silence_file, kInputFormat);
137 unsigned int id_1 = trans.AddStream(kInputFileName, kInputFormat);
138 unsigned int id_2 = trans.AddStream(kInputFileName, kInputFormat);
139 unsigned int id_3 = trans.AddStream(kInputFileName, kInputFormat);
140
141 EXPECT_TRUE(trans.StartPlayout(id_0));
142 EXPECT_TRUE(trans.StartPlayout(id_1));
143 EXPECT_TRUE(trans.StartPlayout(id_2));
144 EXPECT_TRUE(trans.StartPlayout(id_3));
145
146 webrtc::SleepMs(kPacketDurationMs * kPackets);
147
148 webrtc::CallStatistics stats_0;
149 webrtc::CallStatistics stats_1;
150 webrtc::CallStatistics stats_2;
151 webrtc::CallStatistics stats_3;
152 EXPECT_TRUE(trans.GetReceiverStatistics(id_0, &stats_0));
153 EXPECT_TRUE(trans.GetReceiverStatistics(id_1, &stats_1));
154 EXPECT_TRUE(trans.GetReceiverStatistics(id_2, &stats_2));
155 EXPECT_TRUE(trans.GetReceiverStatistics(id_3, &stats_3));
156
157 // We expect stream 0 to be filtered out totally, but since it may join the
158 // call earlier than other streams and the beginning packets might have got
159 // through. So we only expect |packetsReceived| to be close to zero.
160 EXPECT_NEAR(stats_0.packetsReceived, 0, 2);
161 // We expect |packetsReceived| to match |kPackets|, but the actual value
162 // depends on the sleep timer. So we allow a small off from |kPackets|.
163 EXPECT_NEAR(stats_1.packetsReceived, kPackets, 2);
164 EXPECT_NEAR(stats_2.packetsReceived, kPackets, 2);
165 EXPECT_NEAR(stats_3.packetsReceived, kPackets, 2);
166 }
167
168 remove(silence_file.c_str());
169 }
170
108 } // namespace voetest 171 } // namespace voetest
OLDNEW
« no previous file with comments | « webrtc/voice_engine/test/auto_test/fakes/loudest_filter.cc ('k') | webrtc/voice_engine/voice_engine.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698