OLD | NEW |
---|---|
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; |
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 } |
25 } | 26 } |
26 | 27 |
27 namespace voetest { | 28 namespace voetest { |
28 | 29 |
29 TEST(VoeConferenceTest, RttAndStartNtpTime) { | 30 TEST(VoeConferenceTest, RttAndStartNtpTime) { |
31 const std::string kInputFileName = | |
Andrew MacDonald
2015/08/05 16:37:07
nit: not a compile-time const.
minyue-webrtc
2015/08/06 13:31:22
Done.
minyue-webrtc
2015/08/06 14:57:14
Hi Andrew,
Per offline talk with Tina, I think I
Andrew MacDonald
2015/08/13 19:48:11
Right, it's not a compile-time const (i.e. can onl
| |
32 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); | |
33 const webrtc::FileFormats kInputFormat = webrtc::kFileFormatPcm32kHzFile; | |
34 | |
30 struct Stats { | 35 struct Stats { |
31 Stats(int64_t rtt_receiver_1, int64_t rtt_receiver_2, int64_t ntp_delay) | 36 Stats(int64_t rtt_receiver_1, int64_t rtt_receiver_2, int64_t ntp_delay) |
32 : rtt_receiver_1_(rtt_receiver_1), | 37 : rtt_receiver_1_(rtt_receiver_1), |
33 rtt_receiver_2_(rtt_receiver_2), | 38 rtt_receiver_2_(rtt_receiver_2), |
34 ntp_delay_(ntp_delay) { | 39 ntp_delay_(ntp_delay) { |
35 } | 40 } |
36 int64_t rtt_receiver_1_; | 41 int64_t rtt_receiver_1_; |
37 int64_t rtt_receiver_2_; | 42 int64_t rtt_receiver_2_; |
38 int64_t ntp_delay_; | 43 int64_t ntp_delay_; |
39 }; | 44 }; |
40 | 45 |
41 const int kDelayMs = 987; | 46 const int kDelayMs = 987; |
42 ConferenceTransport trans; | 47 ConferenceTransport trans; |
43 trans.SetRtt(kRttMs); | 48 trans.SetRtt(kRttMs); |
44 | 49 |
45 unsigned int id_1 = trans.AddStream(); | 50 unsigned int id_1 = trans.AddStream(kInputFileName, kInputFormat); |
46 unsigned int id_2 = trans.AddStream(); | 51 unsigned int id_2 = trans.AddStream(kInputFileName, kInputFormat); |
47 | 52 |
48 EXPECT_TRUE(trans.StartPlayout(id_1)); | 53 EXPECT_TRUE(trans.StartPlayout(id_1)); |
49 // Start NTP time is the time when a stream is played out, rather than | 54 // Start NTP time is the time when a stream is played out, rather than |
50 // when it is added. | 55 // when it is added. |
51 webrtc::SleepMs(kDelayMs); | 56 webrtc::SleepMs(kDelayMs); |
52 EXPECT_TRUE(trans.StartPlayout(id_2)); | 57 EXPECT_TRUE(trans.StartPlayout(id_2)); |
53 | 58 |
54 const int kMaxRunTimeMs = 25000; | 59 const int kMaxRunTimeMs = 25000; |
55 const int kNeedSuccessivePass = 3; | 60 const int kNeedSuccessivePass = 3; |
56 const int kStatsRequestIntervalMs = 1000; | 61 const int kStatsRequestIntervalMs = 1000; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 printf("The most recent values (RTT for receiver 1, RTT for receiver 2, " | 103 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"); | 104 "NTP delay between receiver 1 and 2) are (from oldest):\n"); |
100 while (!stats_buffer.empty()) { | 105 while (!stats_buffer.empty()) { |
101 Stats stats = stats_buffer.front(); | 106 Stats stats = stats_buffer.front(); |
102 printf("(%" PRId64 ", %" PRId64 ", %" PRId64 ")\n", stats.rtt_receiver_1_, | 107 printf("(%" PRId64 ", %" PRId64 ", %" PRId64 ")\n", stats.rtt_receiver_1_, |
103 stats.rtt_receiver_2_, stats.ntp_delay_); | 108 stats.rtt_receiver_2_, stats.ntp_delay_); |
104 stats_buffer.pop(); | 109 stats_buffer.pop(); |
105 } | 110 } |
106 } | 111 } |
107 } | 112 } |
113 | |
114 | |
115 TEST(VoeConferenceTest, ReceivedPackets) { | |
116 const std::string kInputFileName = | |
117 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); | |
118 const webrtc::FileFormats kInputFormat = webrtc::kFileFormatPcm32kHzFile; | |
119 const int kPackets = 50; | |
120 const int kPacketDurationMs = 20; // Correspond to Opus. | |
121 | |
122 ConferenceTransport trans; | |
123 // Add silence to stream 0, so that it will be filtered out. | |
124 unsigned int id_0 = trans.AddStream( | |
125 webrtc::test::ResourcePath("audio_coding/silence", "pcm"), | |
126 kInputFormat); | |
127 unsigned int id_1 = trans.AddStream(kInputFileName, kInputFormat); | |
128 unsigned int id_2 = trans.AddStream(kInputFileName, kInputFormat); | |
129 unsigned int id_3 = trans.AddStream(kInputFileName, kInputFormat); | |
130 | |
131 EXPECT_TRUE(trans.StartPlayout(id_0)); | |
132 EXPECT_TRUE(trans.StartPlayout(id_1)); | |
133 EXPECT_TRUE(trans.StartPlayout(id_2)); | |
134 EXPECT_TRUE(trans.StartPlayout(id_3)); | |
135 | |
136 webrtc::SleepMs(kPacketDurationMs * kPackets); | |
137 | |
138 webrtc::CallStatistics stats_0; | |
139 webrtc::CallStatistics stats_1; | |
140 webrtc::CallStatistics stats_2; | |
141 webrtc::CallStatistics stats_3; | |
142 EXPECT_TRUE(trans.GetReceiverStatistics(id_0, &stats_0)); | |
143 EXPECT_TRUE(trans.GetReceiverStatistics(id_1, &stats_1)); | |
144 EXPECT_TRUE(trans.GetReceiverStatistics(id_2, &stats_2)); | |
145 EXPECT_TRUE(trans.GetReceiverStatistics(id_3, &stats_3)); | |
146 | |
147 // Cannot be accurate since stream 0 started the earliest. | |
tlegrand-webrtc
2015/08/05 13:32:44
Can you explain this comment? I'm not following.
minyue-webrtc
2015/08/06 13:31:22
I have updated the comments.
tlegrand-webrtc
2015/08/06 14:51:55
Acknowledged.
| |
148 EXPECT_NEAR(stats_0.packetsReceived, 0, 2); | |
149 // Cannot be accurate since it replies on the sleep timer. | |
150 EXPECT_NEAR(stats_1.packetsReceived, kPackets, 2); | |
151 EXPECT_NEAR(stats_2.packetsReceived, kPackets, 2); | |
152 EXPECT_NEAR(stats_3.packetsReceived, kPackets, 2); | |
153 } | |
154 | |
108 } // namespace voetest | 155 } // namespace voetest |
OLD | NEW |