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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/test/auto_test/voe_conference_test.cc
diff --git a/webrtc/voice_engine/test/auto_test/voe_conference_test.cc b/webrtc/voice_engine/test/auto_test/voe_conference_test.cc
index 20a74b46b0880147edae791ffc36161b5be8fae6..dc9c139e7c5946f5abc90330535e7d6227e7fb75 100644
--- a/webrtc/voice_engine/test/auto_test/voe_conference_test.cc
+++ b/webrtc/voice_engine/test/auto_test/voe_conference_test.cc
@@ -14,6 +14,7 @@
#include "webrtc/base/format_macros.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/system_wrappers/interface/sleep.h"
+#include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/voice_engine/test/auto_test/fakes/conference_transport.h"
namespace {
@@ -22,6 +23,21 @@ namespace {
static bool IsNear(int ref, int comp, int error) {
return (ref - comp <= error) && (comp - ref >= -error);
}
+
+ static void CreateSilenceFile(const std::string& silence_file) {
+ FILE* fid = fopen(silence_file.c_str(), "wb");
+ int16_t temp = 0;
Andrew MacDonald 2015/08/13 19:48:11 nit: const int16_t zero = 0;
+ 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-
+ // Write 1 second, but it does not matter since the file will be looped.
+ fwrite(&temp, 2, 1, fid);
Andrew MacDonald 2015/08/13 19:48:11 sizeof(int16_t)
+ }
+ fclose(fid);
+ }
+
+ static const std::string kInputFileName =
Andrew MacDonald 2015/08/13 19:48:11 Variables with static storage duration must be POD
+ webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
+ static const webrtc::FileFormats kInputFormat =
+ webrtc::kFileFormatPcm32kHzFile;
}
namespace voetest {
@@ -42,8 +58,8 @@ TEST(VoeConferenceTest, RttAndStartNtpTime) {
ConferenceTransport trans;
trans.SetRtt(kRttMs);
- unsigned int id_1 = trans.AddStream();
- unsigned int id_2 = trans.AddStream();
+ unsigned int id_1 = trans.AddStream(kInputFileName, kInputFormat);
+ unsigned int id_2 = trans.AddStream(kInputFileName, kInputFormat);
EXPECT_TRUE(trans.StartPlayout(id_1));
// Start NTP time is the time when a stream is played out, rather than
@@ -105,4 +121,51 @@ TEST(VoeConferenceTest, RttAndStartNtpTime) {
}
}
}
+
+
+TEST(VoeConferenceTest, ReceivedPackets) {
+ const int kPackets = 50;
+ const int kPacketDurationMs = 20; // Correspond to Opus.
+ const std::string silence_file =
+ webrtc::test::TempFilename(webrtc::test::OutputPath(), "silence");
+ CreateSilenceFile(silence_file);
+
+ {
+ ConferenceTransport trans;
+ // Add silence to stream 0, so that it will be filtered out.
+ unsigned int id_0 = trans.AddStream(silence_file, kInputFormat);
+ unsigned int id_1 = trans.AddStream(kInputFileName, kInputFormat);
+ unsigned int id_2 = trans.AddStream(kInputFileName, kInputFormat);
+ unsigned int id_3 = trans.AddStream(kInputFileName, kInputFormat);
+
+ EXPECT_TRUE(trans.StartPlayout(id_0));
+ EXPECT_TRUE(trans.StartPlayout(id_1));
+ EXPECT_TRUE(trans.StartPlayout(id_2));
+ EXPECT_TRUE(trans.StartPlayout(id_3));
+
+ webrtc::SleepMs(kPacketDurationMs * kPackets);
+
+ webrtc::CallStatistics stats_0;
+ webrtc::CallStatistics stats_1;
+ webrtc::CallStatistics stats_2;
+ webrtc::CallStatistics stats_3;
+ EXPECT_TRUE(trans.GetReceiverStatistics(id_0, &stats_0));
+ EXPECT_TRUE(trans.GetReceiverStatistics(id_1, &stats_1));
+ EXPECT_TRUE(trans.GetReceiverStatistics(id_2, &stats_2));
+ EXPECT_TRUE(trans.GetReceiverStatistics(id_3, &stats_3));
+
+ // We expect stream 0 to be filtered out totally, but since it may join the
+ // call earlier than other streams and the beginning packets might have got
+ // through. So we only expect |packetsReceived| to be close to zero.
+ EXPECT_NEAR(stats_0.packetsReceived, 0, 2);
+ // We expect |packetsReceived| to match |kPackets|, but the actual value
+ // depends on the sleep timer. So we allow a small off from |kPackets|.
+ EXPECT_NEAR(stats_1.packetsReceived, kPackets, 2);
+ EXPECT_NEAR(stats_2.packetsReceived, kPackets, 2);
+ EXPECT_NEAR(stats_3.packetsReceived, kPackets, 2);
+ }
+
+ remove(silence_file.c_str());
+}
+
} // namespace voetest
« 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