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

Side by Side Diff: webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc

Issue 2378403004: Resurrected test_api_audio.cc (Closed)
Patch Set: Reorganized RtpRtcpAudioTest members. Created 4 years, 2 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/test/testAPI/test_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 <algorithm> 11 #include <algorithm>
12 #include <memory> 12 #include <memory>
13 #include <vector> 13 #include <vector>
14 #include "webrtc/test/gtest.h" 14 #include "webrtc/test/gtest.h"
15 15
16 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h" 16 #include "webrtc/modules/rtp_rtcp/test/testAPI/test_api.h"
17 17
18 #include "webrtc/base/rate_limiter.h" 18 #include "webrtc/base/rate_limiter.h"
19 #include "webrtc/common_types.h" 19 #include "webrtc/common_types.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h" 22 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h"
23 23
24 namespace webrtc { 24 namespace webrtc {
25 namespace { 25 namespace {
26 #define test_rate 64000u 26
27 const uint32_t kTestRate = 64000u;
28 const uint8_t kTestPayload[] = { 't', 'e', 's', 't' };
29 const uint8_t kPcmuPayloadType = 96;
30 const uint8_t kDtmfPayloadType = 97;
31
32 struct CngCodecSpec {
33 int payload_type;
34 int clockrate_hz;
35 };
36
37 const CngCodecSpec kCngCodecs[] = {{13, 8000},
38 {103, 16000},
39 {104, 32000},
40 {105, 48000}};
41
42 bool IsComfortNoisePayload(uint8_t payload_type) {
43 for (const auto& c : kCngCodecs) {
44 if (c.payload_type == payload_type)
45 return true;
46 }
47
48 return false;
49 }
27 50
28 class VerifyingAudioReceiver : public NullRtpData { 51 class VerifyingAudioReceiver : public NullRtpData {
29 public: 52 public:
30 int32_t OnReceivedPayloadData( 53 int32_t OnReceivedPayloadData(
31 const uint8_t* payloadData, 54 const uint8_t* payloadData,
32 size_t payloadSize, 55 size_t payloadSize,
33 const webrtc::WebRtcRTPHeader* rtpHeader) override { 56 const webrtc::WebRtcRTPHeader* rtpHeader) override {
34 if (rtpHeader->header.payloadType == 98 || 57 const uint8_t payload_type = rtpHeader->header.payloadType;
35 rtpHeader->header.payloadType == 99) { 58 if (payload_type == kPcmuPayloadType || payload_type == kDtmfPayloadType) {
36 EXPECT_EQ(4u, payloadSize); 59 EXPECT_EQ(sizeof(kTestPayload), payloadSize);
37 char str[5]; 60 // All our test vectors for PCMU and DTMF are equal to |kTestPayload|.
38 memcpy(str, payloadData, payloadSize); 61 const size_t min_size = std::min(sizeof(kTestPayload), payloadSize);
39 str[4] = 0; 62 EXPECT_EQ(0, memcmp(payloadData, kTestPayload, min_size));
40 // All our test vectors for payload type 96 and 97 even the stereo is on 63 } else if (IsComfortNoisePayload(payload_type)) {
41 // a per channel base equal to the 4 chars "test". 64 // CNG types should be recognized properly.
42 // Note there is no null termination so we add that to use the 65 EXPECT_EQ(kAudioFrameCN, rtpHeader->frameType);
43 // test EXPECT_STRCASEEQ. 66 EXPECT_TRUE(rtpHeader->type.Audio.isCNG);
44 EXPECT_STRCASEEQ("test", str);
45 return 0;
46 }
47 if (rtpHeader->header.payloadType == 100 ||
48 rtpHeader->header.payloadType == 101 ||
49 rtpHeader->header.payloadType == 102) {
50 if (rtpHeader->type.Audio.channel == 1) {
51 if (payloadData[0] == 0xff) {
52 // All our test vectors for payload type 100, 101 and 102 have the
53 // first channel data being equal to 0xff.
54 return 0;
55 }
56 }
57 ADD_FAILURE() << "This code path should never happen.";
58 return -1;
59 } 67 }
60 return 0; 68 return 0;
61 } 69 }
62 }; 70 };
63 71
64 class RTPCallback : public NullRtpFeedback { 72 class RTPCallback : public NullRtpFeedback {
65 public: 73 public:
66 int32_t OnInitializeDecoder(const int8_t payloadType, 74 int32_t OnInitializeDecoder(const int8_t payloadType,
67 const char payloadName[RTP_PAYLOAD_NAME_SIZE], 75 const char payloadName[RTP_PAYLOAD_NAME_SIZE],
68 const int frequency, 76 const int frequency,
69 const size_t channels, 77 const size_t channels,
70 const uint32_t rate) override { 78 const uint32_t rate) override {
71 if (payloadType == 96) { 79 if (payloadType == kPcmuPayloadType) {
72 EXPECT_EQ(test_rate, rate) << 80 EXPECT_EQ(kTestRate, rate) <<
73 "The rate should be 64K for this payloadType"; 81 "The rate should be 64K for this payloadType";
74 } 82 }
75 return 0; 83 return 0;
76 } 84 }
77 }; 85 };
78 86
87 } // namespace
88
79 class RtpRtcpAudioTest : public ::testing::Test { 89 class RtpRtcpAudioTest : public ::testing::Test {
80 protected: 90 protected:
81 RtpRtcpAudioTest() 91 RtpRtcpAudioTest()
82 : fake_clock(123456), retransmission_rate_limiter_(&fake_clock, 1000) { 92 : fake_clock(123456), retransmission_rate_limiter_(&fake_clock, 1000) {
83 test_CSRC[0] = 1234; 93 test_CSRC[0] = 1234;
84 test_CSRC[2] = 2345; 94 test_CSRC[2] = 2345;
85 test_ssrc = 3456; 95 test_ssrc = 3456;
86 test_timestamp = 4567; 96 test_timestamp = 4567;
87 test_sequence_number = 2345; 97 test_sequence_number = 2345;
88 } 98 }
89 ~RtpRtcpAudioTest() {} 99 ~RtpRtcpAudioTest() {}
90 100
91 void SetUp() override { 101 void SetUp() override {
92 data_receiver1 = new VerifyingAudioReceiver();
93 data_receiver2 = new VerifyingAudioReceiver();
94 rtp_callback = new RTPCallback();
95 transport1 = new LoopBackTransport();
96 transport2 = new LoopBackTransport();
97
98 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); 102 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock));
99 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); 103 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock));
100 104
101 rtp_payload_registry1_.reset(new RTPPayloadRegistry( 105 rtp_payload_registry1_.reset(new RTPPayloadRegistry(
102 RTPPayloadStrategy::CreateStrategy(true))); 106 RTPPayloadStrategy::CreateStrategy(true)));
103 rtp_payload_registry2_.reset(new RTPPayloadRegistry( 107 rtp_payload_registry2_.reset(new RTPPayloadRegistry(
104 RTPPayloadStrategy::CreateStrategy(true))); 108 RTPPayloadStrategy::CreateStrategy(true)));
105 109
106 RtpRtcp::Configuration configuration; 110 RtpRtcp::Configuration configuration;
107 configuration.audio = true; 111 configuration.audio = true;
108 configuration.clock = &fake_clock; 112 configuration.clock = &fake_clock;
109 configuration.receive_statistics = receive_statistics1_.get(); 113 configuration.receive_statistics = receive_statistics1_.get();
110 configuration.outgoing_transport = transport1; 114 configuration.outgoing_transport = &transport1;
111 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_; 115 configuration.retransmission_rate_limiter = &retransmission_rate_limiter_;
112 116
113 module1 = RtpRtcp::CreateRtpRtcp(configuration); 117 module1.reset(RtpRtcp::CreateRtpRtcp(configuration));
114 rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver( 118 rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver(
115 &fake_clock, data_receiver1, NULL, rtp_payload_registry1_.get())); 119 &fake_clock, &data_receiver1, &rtp_callback,
120 rtp_payload_registry1_.get()));
116 121
117 configuration.receive_statistics = receive_statistics2_.get(); 122 configuration.receive_statistics = receive_statistics2_.get();
118 configuration.outgoing_transport = transport2; 123 configuration.outgoing_transport = &transport2;
119 124
120 module2 = RtpRtcp::CreateRtpRtcp(configuration); 125 module2.reset(RtpRtcp::CreateRtpRtcp(configuration));
121 rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver( 126 rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver(
122 &fake_clock, data_receiver2, NULL, rtp_payload_registry2_.get())); 127 &fake_clock, &data_receiver2, &rtp_callback,
128 rtp_payload_registry2_.get()));
123 129
124 transport1->SetSendModule(module2, rtp_payload_registry2_.get(), 130 transport1.SetSendModule(module2.get(), rtp_payload_registry2_.get(),
125 rtp_receiver2_.get(), receive_statistics2_.get()); 131 rtp_receiver2_.get(), receive_statistics2_.get());
126 transport2->SetSendModule(module1, rtp_payload_registry1_.get(), 132 transport2.SetSendModule(module1.get(), rtp_payload_registry1_.get(),
127 rtp_receiver1_.get(), receive_statistics1_.get()); 133 rtp_receiver1_.get(), receive_statistics1_.get());
128 } 134 }
129 135
130 void TearDown() override { 136 void RegisterPayload(const CodecInst& codec) {
131 delete module1; 137 EXPECT_EQ(0, module1->RegisterSendPayload(codec));
132 delete module2; 138 EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
133 delete transport1; 139 codec.plname,
134 delete transport2; 140 codec.pltype,
135 delete data_receiver1; 141 codec.plfreq,
136 delete data_receiver2; 142 codec.channels,
137 delete rtp_callback; 143 codec.rate));
144 EXPECT_EQ(0, module2->RegisterSendPayload(codec));
145 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
146 codec.plname,
147 codec.pltype,
148 codec.plfreq,
149 codec.channels,
150 codec.rate));
138 } 151 }
139 152
140 RtpRtcp* module1; 153 VerifyingAudioReceiver data_receiver1;
141 RtpRtcp* module2; 154 VerifyingAudioReceiver data_receiver2;
155 RTPCallback rtp_callback;
142 std::unique_ptr<ReceiveStatistics> receive_statistics1_; 156 std::unique_ptr<ReceiveStatistics> receive_statistics1_;
143 std::unique_ptr<ReceiveStatistics> receive_statistics2_; 157 std::unique_ptr<ReceiveStatistics> receive_statistics2_;
158 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry1_;
159 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry2_;
144 std::unique_ptr<RtpReceiver> rtp_receiver1_; 160 std::unique_ptr<RtpReceiver> rtp_receiver1_;
145 std::unique_ptr<RtpReceiver> rtp_receiver2_; 161 std::unique_ptr<RtpReceiver> rtp_receiver2_;
146 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry1_; 162 std::unique_ptr<RtpRtcp> module1;
147 std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry2_; 163 std::unique_ptr<RtpRtcp> module2;
148 VerifyingAudioReceiver* data_receiver1; 164 LoopBackTransport transport1;
ossu 2016/10/05 11:44:54 Tried to put these in order of initialization but
149 VerifyingAudioReceiver* data_receiver2; 165 LoopBackTransport transport2;
150 LoopBackTransport* transport1;
151 LoopBackTransport* transport2;
152 RTPCallback* rtp_callback;
153 uint32_t test_ssrc; 166 uint32_t test_ssrc;
154 uint32_t test_timestamp; 167 uint32_t test_timestamp;
155 uint16_t test_sequence_number; 168 uint16_t test_sequence_number;
156 uint32_t test_CSRC[webrtc::kRtpCsrcSize]; 169 uint32_t test_CSRC[webrtc::kRtpCsrcSize];
157 SimulatedClock fake_clock; 170 SimulatedClock fake_clock;
158 RateLimiter retransmission_rate_limiter_; 171 RateLimiter retransmission_rate_limiter_;
159 }; 172 };
160 173
161 TEST_F(RtpRtcpAudioTest, Basic) { 174 TEST_F(RtpRtcpAudioTest, Basic) {
162 module1->SetSSRC(test_ssrc); 175 module1->SetSSRC(test_ssrc);
163 module1->SetStartTimestamp(test_timestamp); 176 module1->SetStartTimestamp(test_timestamp);
164 177
165 // Test detection at the end of a DTMF tone. 178 // Test detection at the end of a DTMF tone.
166 // EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true)); 179 // EXPECT_EQ(0, module2->SetTelephoneEventForwardToDecoder(true));
167 180
168 EXPECT_EQ(0, module1->SetSendingStatus(true)); 181 EXPECT_EQ(0, module1->SetSendingStatus(true));
169 182
170 // Start basic RTP test. 183 // Start basic RTP test.
171 184
172 // Send an empty RTP packet. 185 // Send an empty RTP packet.
173 // Should fail since we have not registered the payload type. 186 // Should fail since we have not registered the payload type.
174 EXPECT_FALSE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, 0, -1, 187 EXPECT_FALSE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech,
175 nullptr, 0, nullptr, nullptr, 188 kPcmuPayloadType, 0, -1, nullptr, 0,
176 nullptr)); 189 nullptr, nullptr, nullptr));
177 190
178 CodecInst voice_codec; 191 CodecInst voice_codec = {};
179 memset(&voice_codec, 0, sizeof(voice_codec)); 192 voice_codec.pltype = kPcmuPayloadType;
180 voice_codec.pltype = 96;
181 voice_codec.plfreq = 8000; 193 voice_codec.plfreq = 8000;
194 voice_codec.rate = kTestRate;
182 memcpy(voice_codec.plname, "PCMU", 5); 195 memcpy(voice_codec.plname, "PCMU", 5);
196 RegisterPayload(voice_codec);
183 197
184 EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec)); 198 EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech,
185 EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload( 199 kPcmuPayloadType, 0, -1, kTestPayload,
186 voice_codec.plname, 200 4, nullptr, nullptr, nullptr));
187 voice_codec.pltype,
188 voice_codec.plfreq,
189 voice_codec.channels,
190 (voice_codec.rate < 0) ? 0 : voice_codec.rate));
191 EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec));
192 voice_codec.rate = test_rate;
193 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
194 voice_codec.plname,
195 voice_codec.pltype,
196 voice_codec.plfreq,
197 voice_codec.channels,
198 (voice_codec.rate < 0) ? 0 : voice_codec.rate));
199
200 const uint8_t test[5] = "test";
201 EXPECT_EQ(true,
202 module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, 0, -1,
203 test, 4, nullptr, nullptr, nullptr));
204 201
205 EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC()); 202 EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC());
206 uint32_t timestamp; 203 uint32_t timestamp;
207 EXPECT_TRUE(rtp_receiver2_->Timestamp(&timestamp)); 204 EXPECT_TRUE(rtp_receiver2_->Timestamp(&timestamp));
208 EXPECT_EQ(test_timestamp, timestamp); 205 EXPECT_EQ(test_timestamp, timestamp);
209 } 206 }
210 207
211 TEST_F(RtpRtcpAudioTest, DTMF) { 208 TEST_F(RtpRtcpAudioTest, DTMF) {
212 CodecInst voice_codec; 209 CodecInst voice_codec = {};
213 memset(&voice_codec, 0, sizeof(voice_codec)); 210 voice_codec.pltype = kPcmuPayloadType;
214 voice_codec.pltype = 96;
215 voice_codec.plfreq = 8000; 211 voice_codec.plfreq = 8000;
212 voice_codec.rate = kTestRate;
216 memcpy(voice_codec.plname, "PCMU", 5); 213 memcpy(voice_codec.plname, "PCMU", 5);
217 214 RegisterPayload(voice_codec);
218 EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
219 EXPECT_EQ(0, rtp_receiver1_->RegisterReceivePayload(
220 voice_codec.plname,
221 voice_codec.pltype,
222 voice_codec.plfreq,
223 voice_codec.channels,
224 (voice_codec.rate < 0) ? 0 : voice_codec.rate));
225 EXPECT_EQ(0, module2->RegisterSendPayload(voice_codec));
226 voice_codec.rate = test_rate;
227 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
228 voice_codec.plname,
229 voice_codec.pltype,
230 voice_codec.plfreq,
231 voice_codec.channels,
232 (voice_codec.rate < 0) ? 0 : voice_codec.rate));
233 215
234 module1->SetSSRC(test_ssrc); 216 module1->SetSSRC(test_ssrc);
235 module1->SetStartTimestamp(test_timestamp); 217 module1->SetStartTimestamp(test_timestamp);
236 EXPECT_EQ(0, module1->SetSendingStatus(true)); 218 EXPECT_EQ(0, module1->SetSendingStatus(true));
237 219
238 // Prepare for DTMF. 220 // Prepare for DTMF.
239 voice_codec.pltype = 97; 221 voice_codec.pltype = kDtmfPayloadType;
240 voice_codec.plfreq = 8000; 222 voice_codec.plfreq = 8000;
241 memcpy(voice_codec.plname, "telephone-event", 16); 223 memcpy(voice_codec.plname, "telephone-event", 16);
242 224
243 EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec)); 225 EXPECT_EQ(0, module1->RegisterSendPayload(voice_codec));
244 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload( 226 EXPECT_EQ(0, rtp_receiver2_->RegisterReceivePayload(
245 voice_codec.plname, 227 voice_codec.plname,
246 voice_codec.pltype, 228 voice_codec.pltype,
247 voice_codec.plfreq, 229 voice_codec.plfreq,
248 voice_codec.channels, 230 voice_codec.channels,
249 (voice_codec.rate < 0) ? 0 : voice_codec.rate)); 231 voice_codec.rate));
250 232
251 // Start DTMF test. 233 // Start DTMF test.
252 int timeStamp = 160; 234 int timeStamp = 160;
253 235
254 // Send a DTMF tone using RFC 2833 (4733). 236 // Send a DTMF tone using RFC 2833 (4733).
255 for (int i = 0; i < 16; i++) { 237 for (int i = 0; i < 16; i++) {
256 EXPECT_EQ(0, module1->SendTelephoneEventOutband(i, timeStamp, 10)); 238 EXPECT_EQ(0, module1->SendTelephoneEventOutband(i, timeStamp, 10));
257 } 239 }
258 timeStamp += 160; // Prepare for next packet. 240 timeStamp += 160; // Prepare for next packet.
259 241
260 const uint8_t test[9] = "test";
261
262 // Send RTP packets for 16 tones a 160 ms 100ms 242 // Send RTP packets for 16 tones a 160 ms 100ms
263 // pause between = 2560ms + 1600ms = 4160ms 243 // pause between = 2560ms + 1600ms = 4160ms
264 for (; timeStamp <= 250 * 160; timeStamp += 160) { 244 for (; timeStamp <= 250 * 160; timeStamp += 160) {
265 EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, 245 EXPECT_TRUE(module1->SendOutgoingData(
266 timeStamp, -1, test, 4, nullptr, 246 webrtc::kAudioFrameSpeech, kPcmuPayloadType, timeStamp, -1,
267 nullptr, nullptr)); 247 kTestPayload, 4, nullptr, nullptr, nullptr));
268 fake_clock.AdvanceTimeMilliseconds(20); 248 fake_clock.AdvanceTimeMilliseconds(20);
269 module1->Process(); 249 module1->Process();
270 } 250 }
271 EXPECT_EQ(0, module1->SendTelephoneEventOutband(32, 9000, 10)); 251 EXPECT_EQ(0, module1->SendTelephoneEventOutband(32, 9000, 10));
272 252
273 for (; timeStamp <= 740 * 160; timeStamp += 160) { 253 for (; timeStamp <= 740 * 160; timeStamp += 160) {
274 EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, 254 EXPECT_TRUE(module1->SendOutgoingData(
275 timeStamp, -1, test, 4, nullptr, 255 webrtc::kAudioFrameSpeech, kPcmuPayloadType, timeStamp, -1,
276 nullptr, nullptr)); 256 kTestPayload, 4, nullptr, nullptr, nullptr));
277 fake_clock.AdvanceTimeMilliseconds(20); 257 fake_clock.AdvanceTimeMilliseconds(20);
278 module1->Process(); 258 module1->Process();
279 } 259 }
280 } 260 }
281 261
282 } // namespace 262 TEST_F(RtpRtcpAudioTest, ComfortNoise) {
263 module1->SetSSRC(test_ssrc);
264 module1->SetStartTimestamp(test_timestamp);
265
266 EXPECT_EQ(0, module1->SetSendingStatus(true));
267
268 // Register PCMU and all four comfort noise codecs
269 CodecInst voice_codec = {};
270 voice_codec.pltype = kPcmuPayloadType;
271 voice_codec.plfreq = 8000;
272 voice_codec.rate = kTestRate;
273 memcpy(voice_codec.plname, "PCMU", 5);
274 RegisterPayload(voice_codec);
275
276 for (const auto& c : kCngCodecs) {
277 CodecInst cng_codec = {};
278 cng_codec.pltype = c.payload_type;
279 cng_codec.plfreq = c.clockrate_hz;
280 memcpy(cng_codec.plname, "CN", 3);
281 RegisterPayload(cng_codec);
282 }
283
284 // Transmit comfort noise packets interleaved by PCMU packets.
285 uint32_t in_timestamp = 0;
286 for (const auto& c : kCngCodecs) {
287 uint32_t timestamp;
288 EXPECT_TRUE(module1->SendOutgoingData(
289 webrtc::kAudioFrameSpeech, kPcmuPayloadType, in_timestamp, -1,
290 kTestPayload, 4, nullptr, nullptr, nullptr));
291
292 EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC());
293 EXPECT_TRUE(rtp_receiver2_->Timestamp(&timestamp));
294 EXPECT_EQ(test_timestamp + in_timestamp, timestamp);
295 in_timestamp += 10;
296
297 EXPECT_TRUE(module1->SendOutgoingData(webrtc::kAudioFrameCN, c.payload_type,
298 in_timestamp, -1, kTestPayload, 1,
299 nullptr, nullptr, nullptr));
300
301 EXPECT_EQ(test_ssrc, rtp_receiver2_->SSRC());
302 EXPECT_TRUE(rtp_receiver2_->Timestamp(&timestamp));
303 EXPECT_EQ(test_timestamp + in_timestamp, timestamp);
304 in_timestamp += 10;
305 }
306 }
307
283 } // namespace webrtc 308 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/test/testAPI/test_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698