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

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine_unittest.cc

Issue 1327933002: Full impl of NnChannel::SetSendParameters and NnChannel::SetRecvParameters (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 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
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channel_unittest.cc » ('j') | 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 * libjingle 2 * libjingle
3 * Copyright 2008 Google Inc. 3 * Copyright 2008 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 uint32 ssrc_; 121 uint32 ssrc_;
122 cricket::VoiceMediaChannel::Error error_; 122 cricket::VoiceMediaChannel::Error error_;
123 }; 123 };
124 124
125 WebRtcVoiceEngineTestFake() 125 WebRtcVoiceEngineTestFake()
126 : call_(webrtc::Call::Config()), 126 : call_(webrtc::Call::Config()),
127 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), 127 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)),
128 trace_wrapper_(new FakeVoETraceWrapper()), 128 trace_wrapper_(new FakeVoETraceWrapper()),
129 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), 129 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_),
130 channel_(nullptr) { 130 channel_(nullptr) {
131 send_parameters_.codecs.push_back(kPcmuCodec);
132 recv_parameters_.codecs.push_back(kPcmuCodec);
131 options_conference_.conference_mode.Set(true); 133 options_conference_.conference_mode.Set(true);
132 options_adjust_agc_.adjust_agc_delta.Set(-10); 134 options_adjust_agc_.adjust_agc_delta.Set(-10);
133 } 135 }
134 bool SetupEngineWithoutStream() { 136 bool SetupEngineWithoutStream() {
135 if (!engine_.Init(rtc::Thread::Current())) { 137 if (!engine_.Init(rtc::Thread::Current())) {
136 return false; 138 return false;
137 } 139 }
138 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 140 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
139 return (channel_ != nullptr); 141 return (channel_ != nullptr);
140 } 142 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 EXPECT_TRUE(channel_ != nullptr); 174 EXPECT_TRUE(channel_ != nullptr);
173 if (caller) { 175 if (caller) {
174 // if this is a caller, local description will be applied and add the 176 // if this is a caller, local description will be applied and add the
175 // send stream. 177 // send stream.
176 EXPECT_TRUE(channel_->AddSendStream( 178 EXPECT_TRUE(channel_->AddSendStream(
177 cricket::StreamParams::CreateLegacy(kSsrc1))); 179 cricket::StreamParams::CreateLegacy(kSsrc1)));
178 } 180 }
179 int channel_id = voe_.GetLastChannel(); 181 int channel_id = voe_.GetLastChannel();
180 182
181 // Test we can only InsertDtmf when the other side supports telephone-event. 183 // Test we can only InsertDtmf when the other side supports telephone-event.
182 std::vector<cricket::AudioCodec> codecs; 184 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
183 codecs.push_back(kPcmuCodec);
184 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
185 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 185 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
186 EXPECT_FALSE(channel_->CanInsertDtmf()); 186 EXPECT_FALSE(channel_->CanInsertDtmf());
187 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111, cricket::DF_SEND)); 187 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111, cricket::DF_SEND));
188 codecs.push_back(kTelephoneEventCodec); 188 send_parameters_.codecs.push_back(kTelephoneEventCodec);
189 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 189 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
190 EXPECT_TRUE(channel_->CanInsertDtmf()); 190 EXPECT_TRUE(channel_->CanInsertDtmf());
191 191
192 if (!caller) { 192 if (!caller) {
193 // There's no active send channel yet. 193 // There's no active send channel yet.
194 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123, cricket::DF_SEND)); 194 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123, cricket::DF_SEND));
195 EXPECT_TRUE(channel_->AddSendStream( 195 EXPECT_TRUE(channel_->AddSendStream(
196 cricket::StreamParams::CreateLegacy(kSsrc1))); 196 cricket::StreamParams::CreateLegacy(kSsrc1)));
197 } 197 }
198 198
199 // Check we fail if the ssrc is invalid. 199 // Check we fail if the ssrc is invalid.
(...skipping 20 matching lines...) Expand all
220 220
221 // Test that send bandwidth is set correctly. 221 // Test that send bandwidth is set correctly.
222 // |codec| is the codec under test. 222 // |codec| is the codec under test.
223 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth(). 223 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth().
224 // |expected_result| is the expected result from SetMaxSendBandwidth(). 224 // |expected_result| is the expected result from SetMaxSendBandwidth().
225 // |expected_bitrate| is the expected audio bitrate afterward. 225 // |expected_bitrate| is the expected audio bitrate afterward.
226 void TestSendBandwidth(const cricket::AudioCodec& codec, 226 void TestSendBandwidth(const cricket::AudioCodec& codec,
227 int max_bitrate, 227 int max_bitrate,
228 bool expected_result, 228 bool expected_result,
229 int expected_bitrate) { 229 int expected_bitrate) {
230 cricket::AudioSendParameters parameters;
231 parameters.codecs.push_back(codec);
232 parameters.max_bandwidth_bps = max_bitrate;
233 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters));
234
230 int channel_num = voe_.GetLastChannel(); 235 int channel_num = voe_.GetLastChannel();
231 std::vector<cricket::AudioCodec> codecs;
232
233 codecs.push_back(codec);
234 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
235
236 bool result = channel_->SetMaxSendBandwidth(max_bitrate);
237 EXPECT_EQ(expected_result, result);
238
239 webrtc::CodecInst temp_codec; 236 webrtc::CodecInst temp_codec;
240 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); 237 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec));
241
242 EXPECT_EQ(expected_bitrate, temp_codec.rate); 238 EXPECT_EQ(expected_bitrate, temp_codec.rate);
243 } 239 }
244 240
245 void TestSetSendRtpHeaderExtensions(const std::string& ext) { 241 void TestSetSendRtpHeaderExtensions(const std::string& ext) {
246 EXPECT_TRUE(SetupEngineWithoutStream()); 242 EXPECT_TRUE(SetupEngineWithoutStream());
247 int channel_num = voe_.GetLastChannel(); 243 int channel_num = voe_.GetLastChannel();
248 244
249 // Ensure extensions are off by default. 245 // Ensure extensions are off by default.
250 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); 246 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext));
251 247
252 std::vector<cricket::RtpHeaderExtension> extensions;
253 // Ensure unknown extensions won't cause an error. 248 // Ensure unknown extensions won't cause an error.
254 extensions.push_back(cricket::RtpHeaderExtension( 249 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension(
255 "urn:ietf:params:unknownextention", 1)); 250 "urn:ietf:params:unknownextention", 1));
256 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 251 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
257 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); 252 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext));
258 253
259 // Ensure extensions stay off with an empty list of headers. 254 // Ensure extensions stay off with an empty list of headers.
260 extensions.clear(); 255 send_parameters_.extensions.clear();
261 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 256 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
262 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); 257 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext));
263 258
264 // Ensure extension is set properly. 259 // Ensure extension is set properly.
265 const int id = 1; 260 const int id = 1;
266 extensions.push_back(cricket::RtpHeaderExtension(ext, id)); 261 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension(ext, id));
267 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 262 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
268 EXPECT_EQ(id, voe_.GetSendRtpExtensionId(channel_num, ext)); 263 EXPECT_EQ(id, voe_.GetSendRtpExtensionId(channel_num, ext));
269 264
270 // Ensure extension is set properly on new channel. 265 // Ensure extension is set properly on new channel.
271 // The first stream to occupy the default channel. 266 // The first stream to occupy the default channel.
272 EXPECT_TRUE(channel_->AddSendStream( 267 EXPECT_TRUE(channel_->AddSendStream(
273 cricket::StreamParams::CreateLegacy(123))); 268 cricket::StreamParams::CreateLegacy(123)));
274 EXPECT_TRUE(channel_->AddSendStream( 269 EXPECT_TRUE(channel_->AddSendStream(
275 cricket::StreamParams::CreateLegacy(234))); 270 cricket::StreamParams::CreateLegacy(234)));
276 int new_channel_num = voe_.GetLastChannel(); 271 int new_channel_num = voe_.GetLastChannel();
277 EXPECT_NE(channel_num, new_channel_num); 272 EXPECT_NE(channel_num, new_channel_num);
278 EXPECT_EQ(id, voe_.GetSendRtpExtensionId(new_channel_num, ext)); 273 EXPECT_EQ(id, voe_.GetSendRtpExtensionId(new_channel_num, ext));
279 274
280 // Ensure all extensions go back off with an empty list. 275 // Ensure all extensions go back off with an empty list.
281 extensions.clear(); 276 send_parameters_.codecs.push_back(kPcmuCodec);
282 EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); 277 send_parameters_.extensions.clear();
278 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
283 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); 279 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext));
284 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext)); 280 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext));
285 } 281 }
286 282
287 void TestSetRecvRtpHeaderExtensions(const std::string& ext) { 283 void TestSetRecvRtpHeaderExtensions(const std::string& ext) {
288 EXPECT_TRUE(SetupEngineWithoutStream()); 284 EXPECT_TRUE(SetupEngineWithoutStream());
289 int channel_num = voe_.GetLastChannel(); 285 int channel_num = voe_.GetLastChannel();
290 286
291 // Ensure extensions are off by default. 287 // Ensure extensions are off by default.
292 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 288 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext));
293 289
294 std::vector<cricket::RtpHeaderExtension> extensions; 290 cricket::AudioRecvParameters parameters;
295 // Ensure unknown extensions won't cause an error. 291 // Ensure unknown extensions won't cause an error.
296 extensions.push_back(cricket::RtpHeaderExtension( 292 parameters.extensions.push_back(cricket::RtpHeaderExtension(
297 "urn:ietf:params:unknownextention", 1)); 293 "urn:ietf:params:unknownextention", 1));
298 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 294 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
299 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 295 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext));
300 296
301 // Ensure extensions stay off with an empty list of headers. 297 // Ensure extensions stay off with an empty list of headers.
302 extensions.clear(); 298 parameters.extensions.clear();
303 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 299 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
304 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 300 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext));
305 301
306 // Ensure extension is set properly. 302 // Ensure extension is set properly.
307 const int id = 2; 303 const int id = 2;
308 extensions.push_back(cricket::RtpHeaderExtension(ext, id)); 304 parameters.extensions.push_back(cricket::RtpHeaderExtension(ext, id));
309 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 305 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
310 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 306 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(channel_num, ext));
311 307
312 // Ensure extension is set properly on new channel. 308 // Ensure extension is set properly on new channel.
313 // The first stream to occupy the default channel. 309 // The first stream to occupy the default channel.
314 EXPECT_TRUE(channel_->AddRecvStream( 310 EXPECT_TRUE(channel_->AddRecvStream(
315 cricket::StreamParams::CreateLegacy(345))); 311 cricket::StreamParams::CreateLegacy(345)));
316 EXPECT_TRUE(channel_->AddRecvStream( 312 EXPECT_TRUE(channel_->AddRecvStream(
317 cricket::StreamParams::CreateLegacy(456))); 313 cricket::StreamParams::CreateLegacy(456)));
318 int new_channel_num = voe_.GetLastChannel(); 314 int new_channel_num = voe_.GetLastChannel();
319 EXPECT_NE(channel_num, new_channel_num); 315 EXPECT_NE(channel_num, new_channel_num);
320 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); 316 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext));
321 317
322 // Ensure all extensions go back off with an empty list. 318 // Ensure all extensions go back off with an empty list.
323 extensions.clear(); 319 parameters.extensions.clear();
324 EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); 320 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
325 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); 321 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext));
326 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); 322 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext));
327 } 323 }
328 324
329 protected: 325 protected:
330 cricket::FakeCall call_; 326 cricket::FakeCall call_;
331 cricket::FakeWebRtcVoiceEngine voe_; 327 cricket::FakeWebRtcVoiceEngine voe_;
332 FakeVoETraceWrapper* trace_wrapper_; 328 FakeVoETraceWrapper* trace_wrapper_;
333 cricket::WebRtcVoiceEngine engine_; 329 cricket::WebRtcVoiceEngine engine_;
334 cricket::VoiceMediaChannel* channel_; 330 cricket::VoiceMediaChannel* channel_;
335 331
332 cricket::AudioSendParameters send_parameters_;
333 cricket::AudioRecvParameters recv_parameters_;
336 cricket::AudioOptions options_conference_; 334 cricket::AudioOptions options_conference_;
337 cricket::AudioOptions options_adjust_agc_; 335 cricket::AudioOptions options_adjust_agc_;
338 }; 336 };
339 337
340 // Tests that our stub library "works". 338 // Tests that our stub library "works".
341 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { 339 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) {
342 EXPECT_FALSE(voe_.IsInited()); 340 EXPECT_FALSE(voe_.IsInited());
343 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 341 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
344 EXPECT_TRUE(voe_.IsInited()); 342 EXPECT_TRUE(voe_.IsInited());
345 engine_.Terminate(); 343 engine_.Terminate();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 codec.bitrate = 32000; 408 codec.bitrate = 32000;
411 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); 409 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst));
412 EXPECT_EQ(codec.id, codec_inst.pltype); 410 EXPECT_EQ(codec.id, codec_inst.pltype);
413 EXPECT_EQ(32000, codec_inst.rate); 411 EXPECT_EQ(32000, codec_inst.rate);
414 } 412 }
415 413
416 // Test that we set our inbound codecs properly, including changing PT. 414 // Test that we set our inbound codecs properly, including changing PT.
417 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { 415 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) {
418 EXPECT_TRUE(SetupEngine()); 416 EXPECT_TRUE(SetupEngine());
419 int channel_num = voe_.GetLastChannel(); 417 int channel_num = voe_.GetLastChannel();
420 std::vector<cricket::AudioCodec> codecs; 418 cricket::AudioRecvParameters parameters;
421 codecs.push_back(kIsacCodec); 419 parameters.codecs.push_back(kIsacCodec);
422 codecs.push_back(kPcmuCodec); 420 parameters.codecs.push_back(kPcmuCodec);
423 codecs.push_back(kTelephoneEventCodec); 421 parameters.codecs.push_back(kTelephoneEventCodec);
424 codecs[0].id = 106; // collide with existing telephone-event 422 parameters.codecs[0].id = 106; // collide with existing telephone-event
425 codecs[2].id = 126; 423 parameters.codecs[2].id = 126;
426 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); 424 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
427 webrtc::CodecInst gcodec; 425 webrtc::CodecInst gcodec;
428 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); 426 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
429 gcodec.plfreq = 16000; 427 gcodec.plfreq = 16000;
430 gcodec.channels = 1; 428 gcodec.channels = 1;
431 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); 429 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
432 EXPECT_EQ(106, gcodec.pltype); 430 EXPECT_EQ(106, gcodec.pltype);
433 EXPECT_STREQ("ISAC", gcodec.plname); 431 EXPECT_STREQ("ISAC", gcodec.plname);
434 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), 432 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname),
435 "telephone-event"); 433 "telephone-event");
436 gcodec.plfreq = 8000; 434 gcodec.plfreq = 8000;
437 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); 435 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
438 EXPECT_EQ(126, gcodec.pltype); 436 EXPECT_EQ(126, gcodec.pltype);
439 EXPECT_STREQ("telephone-event", gcodec.plname); 437 EXPECT_STREQ("telephone-event", gcodec.plname);
440 } 438 }
441 439
442 // Test that we fail to set an unknown inbound codec. 440 // Test that we fail to set an unknown inbound codec.
443 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) { 441 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) {
444 EXPECT_TRUE(SetupEngine()); 442 EXPECT_TRUE(SetupEngine());
445 std::vector<cricket::AudioCodec> codecs; 443 cricket::AudioRecvParameters parameters;
446 codecs.push_back(kIsacCodec); 444 parameters.codecs.push_back(kIsacCodec);
447 codecs.push_back(cricket::AudioCodec(127, "XYZ", 32000, 0, 1, 0)); 445 parameters.codecs.push_back(cricket::AudioCodec(127, "XYZ", 32000, 0, 1, 0));
448 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); 446 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
449 } 447 }
450 448
451 // Test that we fail if we have duplicate types in the inbound list. 449 // Test that we fail if we have duplicate types in the inbound list.
452 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsDuplicatePayloadType) { 450 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsDuplicatePayloadType) {
453 EXPECT_TRUE(SetupEngine()); 451 EXPECT_TRUE(SetupEngine());
454 std::vector<cricket::AudioCodec> codecs; 452 cricket::AudioRecvParameters parameters;
455 codecs.push_back(kIsacCodec); 453 parameters.codecs.push_back(kIsacCodec);
456 codecs.push_back(kCn16000Codec); 454 parameters.codecs.push_back(kCn16000Codec);
457 codecs[1].id = kIsacCodec.id; 455 parameters.codecs[1].id = kIsacCodec.id;
458 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); 456 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
459 } 457 }
460 458
461 // Test that we can decode OPUS without stereo parameters. 459 // Test that we can decode OPUS without stereo parameters.
462 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { 460 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) {
463 EXPECT_TRUE(SetupEngine()); 461 EXPECT_TRUE(SetupEngine());
464 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 462 cricket::AudioRecvParameters parameters;
465 std::vector<cricket::AudioCodec> codecs; 463 parameters.codecs.push_back(kIsacCodec);
466 codecs.push_back(kIsacCodec); 464 parameters.codecs.push_back(kPcmuCodec);
467 codecs.push_back(kPcmuCodec); 465 parameters.codecs.push_back(kOpusCodec);
468 codecs.push_back(kOpusCodec); 466 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
469 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
470 EXPECT_TRUE(channel_->AddRecvStream( 467 EXPECT_TRUE(channel_->AddRecvStream(
471 cricket::StreamParams::CreateLegacy(kSsrc1))); 468 cricket::StreamParams::CreateLegacy(kSsrc1)));
472 int channel_num2 = voe_.GetLastChannel(); 469 int channel_num2 = voe_.GetLastChannel();
473 webrtc::CodecInst opus; 470 webrtc::CodecInst opus;
474 engine_.FindWebRtcCodec(kOpusCodec, &opus); 471 engine_.FindWebRtcCodec(kOpusCodec, &opus);
475 // Even without stereo parameters, recv codecs still specify channels = 2. 472 // Even without stereo parameters, recv codecs still specify channels = 2.
476 EXPECT_EQ(2, opus.channels); 473 EXPECT_EQ(2, opus.channels);
477 EXPECT_EQ(111, opus.pltype); 474 EXPECT_EQ(111, opus.pltype);
478 EXPECT_STREQ("opus", opus.plname); 475 EXPECT_STREQ("opus", opus.plname);
479 opus.pltype = 0; 476 opus.pltype = 0;
480 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); 477 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus));
481 EXPECT_EQ(111, opus.pltype); 478 EXPECT_EQ(111, opus.pltype);
482 } 479 }
483 480
484 // Test that we can decode OPUS with stereo = 0. 481 // Test that we can decode OPUS with stereo = 0.
485 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { 482 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) {
486 EXPECT_TRUE(SetupEngine()); 483 EXPECT_TRUE(SetupEngine());
487 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 484 cricket::AudioRecvParameters parameters;
488 std::vector<cricket::AudioCodec> codecs; 485 parameters.codecs.push_back(kIsacCodec);
489 codecs.push_back(kIsacCodec); 486 parameters.codecs.push_back(kPcmuCodec);
490 codecs.push_back(kPcmuCodec); 487 parameters.codecs.push_back(kOpusCodec);
491 codecs.push_back(kOpusCodec); 488 parameters.codecs[2].params["stereo"] = "0";
492 codecs[2].params["stereo"] = "0"; 489 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
493 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
494 EXPECT_TRUE(channel_->AddRecvStream( 490 EXPECT_TRUE(channel_->AddRecvStream(
495 cricket::StreamParams::CreateLegacy(kSsrc1))); 491 cricket::StreamParams::CreateLegacy(kSsrc1)));
496 int channel_num2 = voe_.GetLastChannel(); 492 int channel_num2 = voe_.GetLastChannel();
497 webrtc::CodecInst opus; 493 webrtc::CodecInst opus;
498 engine_.FindWebRtcCodec(kOpusCodec, &opus); 494 engine_.FindWebRtcCodec(kOpusCodec, &opus);
499 // Even when stereo is off, recv codecs still specify channels = 2. 495 // Even when stereo is off, recv codecs still specify channels = 2.
500 EXPECT_EQ(2, opus.channels); 496 EXPECT_EQ(2, opus.channels);
501 EXPECT_EQ(111, opus.pltype); 497 EXPECT_EQ(111, opus.pltype);
502 EXPECT_STREQ("opus", opus.plname); 498 EXPECT_STREQ("opus", opus.plname);
503 opus.pltype = 0; 499 opus.pltype = 0;
504 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); 500 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus));
505 EXPECT_EQ(111, opus.pltype); 501 EXPECT_EQ(111, opus.pltype);
506 } 502 }
507 503
508 // Test that we can decode OPUS with stereo = 1. 504 // Test that we can decode OPUS with stereo = 1.
509 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) { 505 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) {
510 EXPECT_TRUE(SetupEngine()); 506 EXPECT_TRUE(SetupEngine());
511 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 507 cricket::AudioRecvParameters parameters;
512 std::vector<cricket::AudioCodec> codecs; 508 parameters.codecs.push_back(kIsacCodec);
513 codecs.push_back(kIsacCodec); 509 parameters.codecs.push_back(kPcmuCodec);
514 codecs.push_back(kPcmuCodec); 510 parameters.codecs.push_back(kOpusCodec);
515 codecs.push_back(kOpusCodec); 511 parameters.codecs[2].params["stereo"] = "1";
516 codecs[2].params["stereo"] = "1"; 512 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
517 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
518 EXPECT_TRUE(channel_->AddRecvStream( 513 EXPECT_TRUE(channel_->AddRecvStream(
519 cricket::StreamParams::CreateLegacy(kSsrc1))); 514 cricket::StreamParams::CreateLegacy(kSsrc1)));
520 int channel_num2 = voe_.GetLastChannel(); 515 int channel_num2 = voe_.GetLastChannel();
521 webrtc::CodecInst opus; 516 webrtc::CodecInst opus;
522 engine_.FindWebRtcCodec(kOpusCodec, &opus); 517 engine_.FindWebRtcCodec(kOpusCodec, &opus);
523 EXPECT_EQ(2, opus.channels); 518 EXPECT_EQ(2, opus.channels);
524 EXPECT_EQ(111, opus.pltype); 519 EXPECT_EQ(111, opus.pltype);
525 EXPECT_STREQ("opus", opus.plname); 520 EXPECT_STREQ("opus", opus.plname);
526 opus.pltype = 0; 521 opus.pltype = 0;
527 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); 522 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus));
528 EXPECT_EQ(111, opus.pltype); 523 EXPECT_EQ(111, opus.pltype);
529 } 524 }
530 525
531 // Test that changes to recv codecs are applied to all streams. 526 // Test that changes to recv codecs are applied to all streams.
532 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { 527 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) {
533 EXPECT_TRUE(SetupEngine()); 528 EXPECT_TRUE(SetupEngine());
534 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 529 cricket::AudioRecvParameters parameters;
535 std::vector<cricket::AudioCodec> codecs; 530 parameters.codecs.push_back(kIsacCodec);
536 codecs.push_back(kIsacCodec); 531 parameters.codecs.push_back(kPcmuCodec);
537 codecs.push_back(kPcmuCodec); 532 parameters.codecs.push_back(kTelephoneEventCodec);
538 codecs.push_back(kTelephoneEventCodec); 533 parameters.codecs[0].id = 106; // collide with existing telephone-event
539 codecs[0].id = 106; // collide with existing telephone-event 534 parameters.codecs[2].id = 126;
540 codecs[2].id = 126; 535 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
541 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
542 EXPECT_TRUE(channel_->AddRecvStream( 536 EXPECT_TRUE(channel_->AddRecvStream(
543 cricket::StreamParams::CreateLegacy(kSsrc1))); 537 cricket::StreamParams::CreateLegacy(kSsrc1)));
544 int channel_num2 = voe_.GetLastChannel(); 538 int channel_num2 = voe_.GetLastChannel();
545 webrtc::CodecInst gcodec; 539 webrtc::CodecInst gcodec;
546 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); 540 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
547 gcodec.plfreq = 16000; 541 gcodec.plfreq = 16000;
548 gcodec.channels = 1; 542 gcodec.channels = 1;
549 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 543 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
550 EXPECT_EQ(106, gcodec.pltype); 544 EXPECT_EQ(106, gcodec.pltype);
551 EXPECT_STREQ("ISAC", gcodec.plname); 545 EXPECT_STREQ("ISAC", gcodec.plname);
552 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), 546 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname),
553 "telephone-event"); 547 "telephone-event");
554 gcodec.plfreq = 8000; 548 gcodec.plfreq = 8000;
555 gcodec.channels = 1; 549 gcodec.channels = 1;
556 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 550 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
557 EXPECT_EQ(126, gcodec.pltype); 551 EXPECT_EQ(126, gcodec.pltype);
558 EXPECT_STREQ("telephone-event", gcodec.plname); 552 EXPECT_STREQ("telephone-event", gcodec.plname);
559 } 553 }
560 554
561 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { 555 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) {
562 EXPECT_TRUE(SetupEngine()); 556 EXPECT_TRUE(SetupEngine());
563 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 557 cricket::AudioRecvParameters parameters;
564 std::vector<cricket::AudioCodec> codecs; 558 parameters.codecs.push_back(kIsacCodec);
565 codecs.push_back(kIsacCodec); 559 parameters.codecs[0].id = 106; // collide with existing telephone-event
566 codecs[0].id = 106; // collide with existing telephone-event
567
568 EXPECT_TRUE(channel_->AddRecvStream( 560 EXPECT_TRUE(channel_->AddRecvStream(
569 cricket::StreamParams::CreateLegacy(kSsrc1))); 561 cricket::StreamParams::CreateLegacy(kSsrc1)));
570 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); 562 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
571 563
572 int channel_num2 = voe_.GetLastChannel(); 564 int channel_num2 = voe_.GetLastChannel();
573 webrtc::CodecInst gcodec; 565 webrtc::CodecInst gcodec;
574 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); 566 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
575 gcodec.plfreq = 16000; 567 gcodec.plfreq = 16000;
576 gcodec.channels = 1; 568 gcodec.channels = 1;
577 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 569 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
578 EXPECT_EQ(106, gcodec.pltype); 570 EXPECT_EQ(106, gcodec.pltype);
579 EXPECT_STREQ("ISAC", gcodec.plname); 571 EXPECT_STREQ("ISAC", gcodec.plname);
580 } 572 }
581 573
582 // Test that we can apply the same set of codecs again while playing. 574 // Test that we can apply the same set of codecs again while playing.
583 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { 575 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) {
584 EXPECT_TRUE(SetupEngine()); 576 EXPECT_TRUE(SetupEngine());
585 int channel_num = voe_.GetLastChannel(); 577 cricket::AudioRecvParameters parameters;
586 std::vector<cricket::AudioCodec> codecs; 578 parameters.codecs.push_back(kIsacCodec);
587 codecs.push_back(kIsacCodec); 579 parameters.codecs.push_back(kCn16000Codec);
588 codecs.push_back(kCn16000Codec); 580 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
589 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
590 EXPECT_TRUE(channel_->SetPlayout(true)); 581 EXPECT_TRUE(channel_->SetPlayout(true));
591 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); 582 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
592 583
593 // Changing the payload type of a codec should fail. 584 // Changing the payload type of a codec should fail.
594 codecs[0].id = 127; 585 parameters.codecs[0].id = 127;
595 EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); 586 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
587 int channel_num = voe_.GetLastChannel();
596 EXPECT_TRUE(voe_.GetPlayout(channel_num)); 588 EXPECT_TRUE(voe_.GetPlayout(channel_num));
597 } 589 }
598 590
599 // Test that we can add a codec while playing. 591 // Test that we can add a codec while playing.
600 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { 592 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) {
601 EXPECT_TRUE(SetupEngine()); 593 EXPECT_TRUE(SetupEngine());
602 int channel_num = voe_.GetLastChannel(); 594 cricket::AudioRecvParameters parameters;
603 std::vector<cricket::AudioCodec> codecs; 595 parameters.codecs.push_back(kIsacCodec);
604 codecs.push_back(kIsacCodec); 596 parameters.codecs.push_back(kCn16000Codec);
605 codecs.push_back(kCn16000Codec); 597 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
606 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
607 EXPECT_TRUE(channel_->SetPlayout(true)); 598 EXPECT_TRUE(channel_->SetPlayout(true));
608 599
609 codecs.push_back(kOpusCodec); 600 parameters.codecs.push_back(kOpusCodec);
610 EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); 601 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
602 int channel_num = voe_.GetLastChannel();
611 EXPECT_TRUE(voe_.GetPlayout(channel_num)); 603 EXPECT_TRUE(voe_.GetPlayout(channel_num));
612 webrtc::CodecInst gcodec; 604 webrtc::CodecInst gcodec;
613 EXPECT_TRUE(engine_.FindWebRtcCodec(kOpusCodec, &gcodec)); 605 EXPECT_TRUE(engine_.FindWebRtcCodec(kOpusCodec, &gcodec));
614 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); 606 EXPECT_EQ(kOpusCodec.id, gcodec.pltype);
615 } 607 }
616 608
617 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { 609 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) {
618 EXPECT_TRUE(SetupEngine()); 610 EXPECT_TRUE(SetupEngine());
619 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
620 611
621 // Test that when autobw is enabled, bitrate is kept as the default 612 // Test that when autobw is enabled, bitrate is kept as the default
622 // value. autobw is enabled for the following tests because the target 613 // value. autobw is enabled for the following tests because the target
623 // bitrate is <= 0. 614 // bitrate is <= 0.
624 615
625 // ISAC, default bitrate == 32000. 616 // ISAC, default bitrate == 32000.
626 TestSendBandwidth(kIsacCodec, 0, true, 32000); 617 TestSendBandwidth(kIsacCodec, 0, true, 32000);
627 618
628 // PCMU, default bitrate == 64000. 619 // PCMU, default bitrate == 64000.
629 TestSendBandwidth(kPcmuCodec, -1, true, 64000); 620 TestSendBandwidth(kPcmuCodec, -1, true, 64000);
630 621
631 // opus, default bitrate == 64000. 622 // opus, default bitrate == 64000.
632 TestSendBandwidth(kOpusCodec, -1, true, 64000); 623 TestSendBandwidth(kOpusCodec, -1, true, 64000);
633 } 624 }
634 625
635 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { 626 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) {
636 EXPECT_TRUE(SetupEngine()); 627 EXPECT_TRUE(SetupEngine());
637 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
638 628
639 // Test that the bitrate of a multi-rate codec is always the maximum. 629 // Test that the bitrate of a multi-rate codec is always the maximum.
640 630
641 // ISAC, default bitrate == 32000. 631 // ISAC, default bitrate == 32000.
642 TestSendBandwidth(kIsacCodec, 128000, true, 128000); 632 TestSendBandwidth(kIsacCodec, 128000, true, 128000);
643 TestSendBandwidth(kIsacCodec, 16000, true, 16000); 633 TestSendBandwidth(kIsacCodec, 16000, true, 16000);
644 634
645 // opus, default bitrate == 64000. 635 // opus, default bitrate == 64000.
646 TestSendBandwidth(kOpusCodec, 96000, true, 96000); 636 TestSendBandwidth(kOpusCodec, 96000, true, 96000);
647 TestSendBandwidth(kOpusCodec, 48000, true, 48000); 637 TestSendBandwidth(kOpusCodec, 48000, true, 48000);
648 } 638 }
649 639
650 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { 640 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) {
651 EXPECT_TRUE(SetupEngine()); 641 EXPECT_TRUE(SetupEngine());
652 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
653 642
654 // Test that we can only set a maximum bitrate for a fixed-rate codec 643 // Test that we can only set a maximum bitrate for a fixed-rate codec
655 // if it's bigger than the fixed rate. 644 // if it's bigger than the fixed rate.
656 645
657 // PCMU, fixed bitrate == 64000. 646 // PCMU, fixed bitrate == 64000.
658 TestSendBandwidth(kPcmuCodec, 0, true, 64000); 647 TestSendBandwidth(kPcmuCodec, 0, true, 64000);
659 TestSendBandwidth(kPcmuCodec, 1, false, 64000); 648 TestSendBandwidth(kPcmuCodec, 1, false, 64000);
660 TestSendBandwidth(kPcmuCodec, 128000, true, 64000); 649 TestSendBandwidth(kPcmuCodec, 128000, true, 64000);
661 TestSendBandwidth(kPcmuCodec, 32000, false, 64000); 650 TestSendBandwidth(kPcmuCodec, 32000, false, 64000);
662 TestSendBandwidth(kPcmuCodec, 64000, true, 64000); 651 TestSendBandwidth(kPcmuCodec, 64000, true, 64000);
663 TestSendBandwidth(kPcmuCodec, 63999, false, 64000); 652 TestSendBandwidth(kPcmuCodec, 63999, false, 64000);
664 TestSendBandwidth(kPcmuCodec, 64001, true, 64000); 653 TestSendBandwidth(kPcmuCodec, 64001, true, 64000);
665 } 654 }
666 655
667 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { 656 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) {
668 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 657 EXPECT_TRUE(SetupEngineWithoutStream());
669 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 658 const int kDesiredBitrate = 128000;
670 EXPECT_TRUE(channel_ != nullptr); 659 cricket::AudioSendParameters parameters;
671 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); 660 parameters.codecs = engine_.codecs();
672 661 parameters.max_bandwidth_bps = kDesiredBitrate;
673 int desired_bitrate = 128000; 662 EXPECT_TRUE(channel_->SetSendParameters(parameters));
674 EXPECT_TRUE(channel_->SetMaxSendBandwidth(desired_bitrate));
675 663
676 EXPECT_TRUE(channel_->AddSendStream( 664 EXPECT_TRUE(channel_->AddSendStream(
677 cricket::StreamParams::CreateLegacy(kSsrc1))); 665 cricket::StreamParams::CreateLegacy(kSsrc1)));
678 666
679 int channel_num = voe_.GetLastChannel(); 667 int channel_num = voe_.GetLastChannel();
680 webrtc::CodecInst codec; 668 webrtc::CodecInst codec;
681 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); 669 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec));
682 EXPECT_EQ(desired_bitrate, codec.rate); 670 EXPECT_EQ(kDesiredBitrate, codec.rate);
683 } 671 }
684 672
685 // Test that bitrate cannot be set for CBR codecs. 673 // Test that bitrate cannot be set for CBR codecs.
686 // Bitrate is ignored if it is higher than the fixed bitrate. 674 // Bitrate is ignored if it is higher than the fixed bitrate.
687 // Bitrate less then the fixed bitrate is an error. 675 // Bitrate less then the fixed bitrate is an error.
688 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { 676 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) {
689 EXPECT_TRUE(SetupEngine()); 677 EXPECT_TRUE(SetupEngine());
690 EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs()));
691
692 webrtc::CodecInst codec;
693 int channel_num = voe_.GetLastChannel();
694 std::vector<cricket::AudioCodec> codecs;
695 678
696 // PCMU, default bitrate == 64000. 679 // PCMU, default bitrate == 64000.
697 codecs.push_back(kPcmuCodec); 680 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
698 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 681 int channel_num = voe_.GetLastChannel();
682 webrtc::CodecInst codec;
699 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); 683 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec));
700 EXPECT_EQ(64000, codec.rate); 684 EXPECT_EQ(64000, codec.rate);
701 EXPECT_TRUE(channel_->SetMaxSendBandwidth(128000)); 685
686 send_parameters_.max_bandwidth_bps = 128000;
687 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
702 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); 688 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec));
703 EXPECT_EQ(64000, codec.rate); 689 EXPECT_EQ(64000, codec.rate);
704 EXPECT_FALSE(channel_->SetMaxSendBandwidth(128)); 690
691 send_parameters_.max_bandwidth_bps = 128;
692 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_));
705 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); 693 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec));
706 EXPECT_EQ(64000, codec.rate); 694 EXPECT_EQ(64000, codec.rate);
707 } 695 }
708 696
709 // Test that we apply codecs properly. 697 // Test that we apply codecs properly.
710 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { 698 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) {
711 EXPECT_TRUE(SetupEngine()); 699 EXPECT_TRUE(SetupEngine());
700 cricket::AudioSendParameters parameters;
701 parameters.codecs.push_back(kIsacCodec);
702 parameters.codecs.push_back(kPcmuCodec);
703 parameters.codecs.push_back(kRedCodec);
704 parameters.codecs[0].id = 96;
705 parameters.codecs[0].bitrate = 48000;
706 EXPECT_TRUE(channel_->SetSendParameters(parameters));
707 EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
712 int channel_num = voe_.GetLastChannel(); 708 int channel_num = voe_.GetLastChannel();
713 std::vector<cricket::AudioCodec> codecs;
714 codecs.push_back(kIsacCodec);
715 codecs.push_back(kPcmuCodec);
716 codecs.push_back(kRedCodec);
717 codecs[0].id = 96;
718 codecs[0].bitrate = 48000;
719 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
720 EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
721 webrtc::CodecInst gcodec; 709 webrtc::CodecInst gcodec;
722 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 710 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
723 EXPECT_EQ(96, gcodec.pltype); 711 EXPECT_EQ(96, gcodec.pltype);
724 EXPECT_EQ(48000, gcodec.rate); 712 EXPECT_EQ(48000, gcodec.rate);
725 EXPECT_STREQ("ISAC", gcodec.plname); 713 EXPECT_STREQ("ISAC", gcodec.plname);
726 EXPECT_FALSE(voe_.GetVAD(channel_num)); 714 EXPECT_FALSE(voe_.GetVAD(channel_num));
727 EXPECT_FALSE(voe_.GetRED(channel_num)); 715 EXPECT_FALSE(voe_.GetRED(channel_num));
728 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 716 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
729 EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true)); 717 EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true));
730 EXPECT_EQ(106, voe_.GetSendTelephoneEventPayloadType(channel_num)); 718 EXPECT_EQ(106, voe_.GetSendTelephoneEventPayloadType(channel_num));
731 } 719 }
732 720
733 // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried 721 // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried
734 // to apply. 722 // to apply.
735 TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { 723 TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) {
736 EXPECT_TRUE(SetupEngine()); 724 EXPECT_TRUE(SetupEngine());
737 std::vector<cricket::AudioCodec> codecs; 725 cricket::AudioSendParameters parameters;
738 codecs.push_back(kIsacCodec); 726 parameters.codecs.push_back(kIsacCodec);
739 codecs.push_back(kPcmuCodec); 727 parameters.codecs.push_back(kPcmuCodec);
740 codecs.push_back(kRedCodec); 728 parameters.codecs.push_back(kRedCodec);
741 codecs[0].id = 96; 729 parameters.codecs[0].id = 96;
742 codecs[0].bitrate = 48000; 730 parameters.codecs[0].bitrate = 48000;
743 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 731 EXPECT_TRUE(channel_->SetSendParameters(parameters));
744 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); 732 EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
745 // Calling SetSendCodec again with same codec which is already set. 733 // Calling SetSendCodec again with same codec which is already set.
746 // In this case media channel shouldn't send codec to VoE. 734 // In this case media channel shouldn't send codec to VoE.
747 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 735 EXPECT_TRUE(channel_->SetSendParameters(parameters));
748 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); 736 EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
749 } 737 }
750 738
751 // Verify that G722 is set with 16000 samples per second to WebRTC. 739 // Verify that G722 is set with 16000 samples per second to WebRTC.
752 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { 740 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) {
753 EXPECT_TRUE(SetupEngine()); 741 EXPECT_TRUE(SetupEngine());
754 int channel_num = voe_.GetLastChannel(); 742 int channel_num = voe_.GetLastChannel();
755 std::vector<cricket::AudioCodec> codecs; 743 cricket::AudioSendParameters parameters;
756 codecs.push_back(kG722CodecSdp); 744 parameters.codecs.push_back(kG722CodecSdp);
757 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 745 EXPECT_TRUE(channel_->SetSendParameters(parameters));
758 webrtc::CodecInst gcodec; 746 webrtc::CodecInst gcodec;
759 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 747 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
760 EXPECT_STREQ("G722", gcodec.plname); 748 EXPECT_STREQ("G722", gcodec.plname);
761 EXPECT_EQ(1, gcodec.channels); 749 EXPECT_EQ(1, gcodec.channels);
762 EXPECT_EQ(16000, gcodec.plfreq); 750 EXPECT_EQ(16000, gcodec.plfreq);
763 } 751 }
764 752
765 // Test that if clockrate is not 48000 for opus, we fail. 753 // Test that if clockrate is not 48000 for opus, we fail.
766 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { 754 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) {
767 EXPECT_TRUE(SetupEngine()); 755 EXPECT_TRUE(SetupEngine());
768 std::vector<cricket::AudioCodec> codecs; 756 cricket::AudioSendParameters parameters;
769 codecs.push_back(kOpusCodec); 757 parameters.codecs.push_back(kOpusCodec);
770 codecs[0].bitrate = 0; 758 parameters.codecs[0].bitrate = 0;
771 codecs[0].clockrate = 50000; 759 parameters.codecs[0].clockrate = 50000;
772 EXPECT_FALSE(channel_->SetSendCodecs(codecs)); 760 EXPECT_FALSE(channel_->SetSendParameters(parameters));
773 } 761 }
774 762
775 // Test that if channels=0 for opus, we fail. 763 // Test that if channels=0 for opus, we fail.
776 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { 764 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) {
777 EXPECT_TRUE(SetupEngine()); 765 EXPECT_TRUE(SetupEngine());
778 std::vector<cricket::AudioCodec> codecs; 766 cricket::AudioSendParameters parameters;
779 codecs.push_back(kOpusCodec); 767 parameters.codecs.push_back(kOpusCodec);
780 codecs[0].bitrate = 0; 768 parameters.codecs[0].bitrate = 0;
781 codecs[0].channels = 0; 769 parameters.codecs[0].channels = 0;
782 EXPECT_FALSE(channel_->SetSendCodecs(codecs)); 770 EXPECT_FALSE(channel_->SetSendParameters(parameters));
783 } 771 }
784 772
785 // Test that if channels=0 for opus, we fail. 773 // Test that if channels=0 for opus, we fail.
786 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { 774 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) {
787 EXPECT_TRUE(SetupEngine()); 775 EXPECT_TRUE(SetupEngine());
788 std::vector<cricket::AudioCodec> codecs; 776 cricket::AudioSendParameters parameters;
789 codecs.push_back(kOpusCodec); 777 parameters.codecs.push_back(kOpusCodec);
790 codecs[0].bitrate = 0; 778 parameters.codecs[0].bitrate = 0;
791 codecs[0].channels = 0; 779 parameters.codecs[0].channels = 0;
792 codecs[0].params["stereo"] = "1"; 780 parameters.codecs[0].params["stereo"] = "1";
793 EXPECT_FALSE(channel_->SetSendCodecs(codecs)); 781 EXPECT_FALSE(channel_->SetSendParameters(parameters));
794 } 782 }
795 783
796 // Test that if channel is 1 for opus and there's no stereo, we fail. 784 // Test that if channel is 1 for opus and there's no stereo, we fail.
797 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { 785 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) {
798 EXPECT_TRUE(SetupEngine()); 786 EXPECT_TRUE(SetupEngine());
799 std::vector<cricket::AudioCodec> codecs; 787 cricket::AudioSendParameters parameters;
800 codecs.push_back(kOpusCodec); 788 parameters.codecs.push_back(kOpusCodec);
801 codecs[0].bitrate = 0; 789 parameters.codecs[0].bitrate = 0;
802 codecs[0].channels = 1; 790 parameters.codecs[0].channels = 1;
803 EXPECT_FALSE(channel_->SetSendCodecs(codecs)); 791 EXPECT_FALSE(channel_->SetSendParameters(parameters));
804 } 792 }
805 793
806 // Test that if channel is 1 for opus and stereo=0, we fail. 794 // Test that if channel is 1 for opus and stereo=0, we fail.
807 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { 795 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) {
808 EXPECT_TRUE(SetupEngine()); 796 EXPECT_TRUE(SetupEngine());
809 std::vector<cricket::AudioCodec> codecs; 797 cricket::AudioSendParameters parameters;
810 codecs.push_back(kOpusCodec); 798 parameters.codecs.push_back(kOpusCodec);
811 codecs[0].bitrate = 0; 799 parameters.codecs[0].bitrate = 0;
812 codecs[0].channels = 1; 800 parameters.codecs[0].channels = 1;
813 codecs[0].params["stereo"] = "0"; 801 parameters.codecs[0].params["stereo"] = "0";
814 EXPECT_FALSE(channel_->SetSendCodecs(codecs)); 802 EXPECT_FALSE(channel_->SetSendParameters(parameters));
815 } 803 }
816 804
817 // Test that if channel is 1 for opus and stereo=1, we fail. 805 // Test that if channel is 1 for opus and stereo=1, we fail.
818 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { 806 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) {
819 EXPECT_TRUE(SetupEngine()); 807 EXPECT_TRUE(SetupEngine());
820 std::vector<cricket::AudioCodec> codecs; 808 cricket::AudioSendParameters parameters;
821 codecs.push_back(kOpusCodec); 809 parameters.codecs.push_back(kOpusCodec);
822 codecs[0].bitrate = 0; 810 parameters.codecs[0].bitrate = 0;
823 codecs[0].channels = 1; 811 parameters.codecs[0].channels = 1;
824 codecs[0].params["stereo"] = "1"; 812 parameters.codecs[0].params["stereo"] = "1";
825 EXPECT_FALSE(channel_->SetSendCodecs(codecs)); 813 EXPECT_FALSE(channel_->SetSendParameters(parameters));
826 } 814 }
827 815
828 // Test that with bitrate=0 and no stereo, 816 // Test that with bitrate=0 and no stereo,
829 // channels and bitrate are 1 and 32000. 817 // channels and bitrate are 1 and 32000.
830 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { 818 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) {
831 EXPECT_TRUE(SetupEngine()); 819 EXPECT_TRUE(SetupEngine());
832 int channel_num = voe_.GetLastChannel(); 820 int channel_num = voe_.GetLastChannel();
833 std::vector<cricket::AudioCodec> codecs; 821 cricket::AudioSendParameters parameters;
834 codecs.push_back(kOpusCodec); 822 parameters.codecs.push_back(kOpusCodec);
835 codecs[0].bitrate = 0; 823 parameters.codecs[0].bitrate = 0;
836 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 824 EXPECT_TRUE(channel_->SetSendParameters(parameters));
837 webrtc::CodecInst gcodec; 825 webrtc::CodecInst gcodec;
838 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 826 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
839 EXPECT_STREQ("opus", gcodec.plname); 827 EXPECT_STREQ("opus", gcodec.plname);
840 EXPECT_EQ(1, gcodec.channels); 828 EXPECT_EQ(1, gcodec.channels);
841 EXPECT_EQ(32000, gcodec.rate); 829 EXPECT_EQ(32000, gcodec.rate);
842 } 830 }
843 831
844 // Test that with bitrate=0 and stereo=0, 832 // Test that with bitrate=0 and stereo=0,
845 // channels and bitrate are 1 and 32000. 833 // channels and bitrate are 1 and 32000.
846 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { 834 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) {
847 EXPECT_TRUE(SetupEngine()); 835 EXPECT_TRUE(SetupEngine());
848 int channel_num = voe_.GetLastChannel(); 836 int channel_num = voe_.GetLastChannel();
849 std::vector<cricket::AudioCodec> codecs; 837 cricket::AudioSendParameters parameters;
850 codecs.push_back(kOpusCodec); 838 parameters.codecs.push_back(kOpusCodec);
851 codecs[0].bitrate = 0; 839 parameters.codecs[0].bitrate = 0;
852 codecs[0].params["stereo"] = "0"; 840 parameters.codecs[0].params["stereo"] = "0";
853 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 841 EXPECT_TRUE(channel_->SetSendParameters(parameters));
854 webrtc::CodecInst gcodec; 842 webrtc::CodecInst gcodec;
855 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 843 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
856 EXPECT_STREQ("opus", gcodec.plname); 844 EXPECT_STREQ("opus", gcodec.plname);
857 EXPECT_EQ(1, gcodec.channels); 845 EXPECT_EQ(1, gcodec.channels);
858 EXPECT_EQ(32000, gcodec.rate); 846 EXPECT_EQ(32000, gcodec.rate);
859 } 847 }
860 848
861 // Test that with bitrate=invalid and stereo=0, 849 // Test that with bitrate=invalid and stereo=0,
862 // channels and bitrate are 1 and 32000. 850 // channels and bitrate are 1 and 32000.
863 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { 851 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) {
864 EXPECT_TRUE(SetupEngine()); 852 EXPECT_TRUE(SetupEngine());
865 int channel_num = voe_.GetLastChannel(); 853 int channel_num = voe_.GetLastChannel();
866 std::vector<cricket::AudioCodec> codecs; 854 cricket::AudioSendParameters parameters;
867 codecs.push_back(kOpusCodec); 855 parameters.codecs.push_back(kOpusCodec);
868 codecs[0].params["stereo"] = "0"; 856 parameters.codecs[0].params["stereo"] = "0";
869 webrtc::CodecInst gcodec; 857 webrtc::CodecInst gcodec;
870 858
871 // bitrate that's out of the range between 6000 and 510000 will be clamped. 859 // bitrate that's out of the range between 6000 and 510000 will be clamped.
872 codecs[0].bitrate = 5999; 860 parameters.codecs[0].bitrate = 5999;
873 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 861 EXPECT_TRUE(channel_->SetSendParameters(parameters));
874 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 862 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
875 EXPECT_STREQ("opus", gcodec.plname); 863 EXPECT_STREQ("opus", gcodec.plname);
876 EXPECT_EQ(1, gcodec.channels); 864 EXPECT_EQ(1, gcodec.channels);
877 EXPECT_EQ(6000, gcodec.rate); 865 EXPECT_EQ(6000, gcodec.rate);
878 866
879 codecs[0].bitrate = 510001; 867 parameters.codecs[0].bitrate = 510001;
880 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 868 EXPECT_TRUE(channel_->SetSendParameters(parameters));
881 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 869 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
882 EXPECT_STREQ("opus", gcodec.plname); 870 EXPECT_STREQ("opus", gcodec.plname);
883 EXPECT_EQ(1, gcodec.channels); 871 EXPECT_EQ(1, gcodec.channels);
884 EXPECT_EQ(510000, gcodec.rate); 872 EXPECT_EQ(510000, gcodec.rate);
885 } 873 }
886 874
887 // Test that with bitrate=0 and stereo=1, 875 // Test that with bitrate=0 and stereo=1,
888 // channels and bitrate are 2 and 64000. 876 // channels and bitrate are 2 and 64000.
889 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { 877 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) {
890 EXPECT_TRUE(SetupEngine()); 878 EXPECT_TRUE(SetupEngine());
891 int channel_num = voe_.GetLastChannel(); 879 int channel_num = voe_.GetLastChannel();
892 std::vector<cricket::AudioCodec> codecs; 880 cricket::AudioSendParameters parameters;
893 codecs.push_back(kOpusCodec); 881 parameters.codecs.push_back(kOpusCodec);
894 codecs[0].bitrate = 0; 882 parameters.codecs[0].bitrate = 0;
895 codecs[0].params["stereo"] = "1"; 883 parameters.codecs[0].params["stereo"] = "1";
896 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 884 EXPECT_TRUE(channel_->SetSendParameters(parameters));
897 webrtc::CodecInst gcodec; 885 webrtc::CodecInst gcodec;
898 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 886 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
899 EXPECT_STREQ("opus", gcodec.plname); 887 EXPECT_STREQ("opus", gcodec.plname);
900 EXPECT_EQ(2, gcodec.channels); 888 EXPECT_EQ(2, gcodec.channels);
901 EXPECT_EQ(64000, gcodec.rate); 889 EXPECT_EQ(64000, gcodec.rate);
902 } 890 }
903 891
904 // Test that with bitrate=invalid and stereo=1, 892 // Test that with bitrate=invalid and stereo=1,
905 // channels and bitrate are 2 and 64000. 893 // channels and bitrate are 2 and 64000.
906 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { 894 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) {
907 EXPECT_TRUE(SetupEngine()); 895 EXPECT_TRUE(SetupEngine());
908 int channel_num = voe_.GetLastChannel(); 896 int channel_num = voe_.GetLastChannel();
909 std::vector<cricket::AudioCodec> codecs; 897 cricket::AudioSendParameters parameters;
910 codecs.push_back(kOpusCodec); 898 parameters.codecs.push_back(kOpusCodec);
911 codecs[0].params["stereo"] = "1"; 899 parameters.codecs[0].params["stereo"] = "1";
912 webrtc::CodecInst gcodec; 900 webrtc::CodecInst gcodec;
913 901
914 // bitrate that's out of the range between 6000 and 510000 will be clamped. 902 // bitrate that's out of the range between 6000 and 510000 will be clamped.
915 codecs[0].bitrate = 5999; 903 parameters.codecs[0].bitrate = 5999;
916 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 904 EXPECT_TRUE(channel_->SetSendParameters(parameters));
917 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 905 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
918 EXPECT_STREQ("opus", gcodec.plname); 906 EXPECT_STREQ("opus", gcodec.plname);
919 EXPECT_EQ(2, gcodec.channels); 907 EXPECT_EQ(2, gcodec.channels);
920 EXPECT_EQ(6000, gcodec.rate); 908 EXPECT_EQ(6000, gcodec.rate);
921 909
922 codecs[0].bitrate = 510001; 910 parameters.codecs[0].bitrate = 510001;
923 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 911 EXPECT_TRUE(channel_->SetSendParameters(parameters));
924 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 912 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
925 EXPECT_STREQ("opus", gcodec.plname); 913 EXPECT_STREQ("opus", gcodec.plname);
926 EXPECT_EQ(2, gcodec.channels); 914 EXPECT_EQ(2, gcodec.channels);
927 EXPECT_EQ(510000, gcodec.rate); 915 EXPECT_EQ(510000, gcodec.rate);
928 } 916 }
929 917
930 // Test that with bitrate=N and stereo unset, 918 // Test that with bitrate=N and stereo unset,
931 // channels and bitrate are 1 and N. 919 // channels and bitrate are 1 and N.
932 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { 920 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) {
933 EXPECT_TRUE(SetupEngine()); 921 EXPECT_TRUE(SetupEngine());
934 int channel_num = voe_.GetLastChannel(); 922 int channel_num = voe_.GetLastChannel();
935 std::vector<cricket::AudioCodec> codecs; 923 cricket::AudioSendParameters parameters;
936 codecs.push_back(kOpusCodec); 924 parameters.codecs.push_back(kOpusCodec);
937 codecs[0].bitrate = 96000; 925 parameters.codecs[0].bitrate = 96000;
938 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 926 EXPECT_TRUE(channel_->SetSendParameters(parameters));
939 webrtc::CodecInst gcodec; 927 webrtc::CodecInst gcodec;
940 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 928 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
941 EXPECT_EQ(111, gcodec.pltype); 929 EXPECT_EQ(111, gcodec.pltype);
942 EXPECT_EQ(96000, gcodec.rate); 930 EXPECT_EQ(96000, gcodec.rate);
943 EXPECT_STREQ("opus", gcodec.plname); 931 EXPECT_STREQ("opus", gcodec.plname);
944 EXPECT_EQ(1, gcodec.channels); 932 EXPECT_EQ(1, gcodec.channels);
945 EXPECT_EQ(48000, gcodec.plfreq); 933 EXPECT_EQ(48000, gcodec.plfreq);
946 } 934 }
947 935
948 // Test that with bitrate=N and stereo=0, 936 // Test that with bitrate=N and stereo=0,
949 // channels and bitrate are 1 and N. 937 // channels and bitrate are 1 and N.
950 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { 938 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) {
951 EXPECT_TRUE(SetupEngine()); 939 EXPECT_TRUE(SetupEngine());
952 int channel_num = voe_.GetLastChannel(); 940 int channel_num = voe_.GetLastChannel();
953 std::vector<cricket::AudioCodec> codecs; 941 cricket::AudioSendParameters parameters;
954 codecs.push_back(kOpusCodec); 942 parameters.codecs.push_back(kOpusCodec);
955 codecs[0].bitrate = 30000; 943 parameters.codecs[0].bitrate = 30000;
956 codecs[0].params["stereo"] = "0"; 944 parameters.codecs[0].params["stereo"] = "0";
957 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 945 EXPECT_TRUE(channel_->SetSendParameters(parameters));
958 webrtc::CodecInst gcodec; 946 webrtc::CodecInst gcodec;
959 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 947 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
960 EXPECT_EQ(1, gcodec.channels); 948 EXPECT_EQ(1, gcodec.channels);
961 EXPECT_EQ(30000, gcodec.rate); 949 EXPECT_EQ(30000, gcodec.rate);
962 EXPECT_STREQ("opus", gcodec.plname); 950 EXPECT_STREQ("opus", gcodec.plname);
963 } 951 }
964 952
965 // Test that with bitrate=N and without any parameters, 953 // Test that with bitrate=N and without any parameters,
966 // channels and bitrate are 1 and N. 954 // channels and bitrate are 1 and N.
967 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { 955 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) {
968 EXPECT_TRUE(SetupEngine()); 956 EXPECT_TRUE(SetupEngine());
969 int channel_num = voe_.GetLastChannel(); 957 int channel_num = voe_.GetLastChannel();
970 std::vector<cricket::AudioCodec> codecs; 958 cricket::AudioSendParameters parameters;
971 codecs.push_back(kOpusCodec); 959 parameters.codecs.push_back(kOpusCodec);
972 codecs[0].bitrate = 30000; 960 parameters.codecs[0].bitrate = 30000;
973 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 961 EXPECT_TRUE(channel_->SetSendParameters(parameters));
974 webrtc::CodecInst gcodec; 962 webrtc::CodecInst gcodec;
975 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 963 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
976 EXPECT_EQ(1, gcodec.channels); 964 EXPECT_EQ(1, gcodec.channels);
977 EXPECT_EQ(30000, gcodec.rate); 965 EXPECT_EQ(30000, gcodec.rate);
978 EXPECT_STREQ("opus", gcodec.plname); 966 EXPECT_STREQ("opus", gcodec.plname);
979 } 967 }
980 968
981 // Test that with bitrate=N and stereo=1, 969 // Test that with bitrate=N and stereo=1,
982 // channels and bitrate are 2 and N. 970 // channels and bitrate are 2 and N.
983 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { 971 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) {
984 EXPECT_TRUE(SetupEngine()); 972 EXPECT_TRUE(SetupEngine());
985 int channel_num = voe_.GetLastChannel(); 973 int channel_num = voe_.GetLastChannel();
986 std::vector<cricket::AudioCodec> codecs; 974 cricket::AudioSendParameters parameters;
987 codecs.push_back(kOpusCodec); 975 parameters.codecs.push_back(kOpusCodec);
988 codecs[0].bitrate = 30000; 976 parameters.codecs[0].bitrate = 30000;
989 codecs[0].params["stereo"] = "1"; 977 parameters.codecs[0].params["stereo"] = "1";
990 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 978 EXPECT_TRUE(channel_->SetSendParameters(parameters));
991 webrtc::CodecInst gcodec; 979 webrtc::CodecInst gcodec;
992 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 980 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
993 EXPECT_EQ(2, gcodec.channels); 981 EXPECT_EQ(2, gcodec.channels);
994 EXPECT_EQ(30000, gcodec.rate); 982 EXPECT_EQ(30000, gcodec.rate);
995 EXPECT_STREQ("opus", gcodec.plname); 983 EXPECT_STREQ("opus", gcodec.plname);
996 } 984 }
997 985
998 // Test that bitrate will be overridden by the "maxaveragebitrate" parameter. 986 // Test that bitrate will be overridden by the "maxaveragebitrate" parameter.
999 // Also test that the "maxaveragebitrate" can't be set to values outside the 987 // Also test that the "maxaveragebitrate" can't be set to values outside the
1000 // range of 6000 and 510000 988 // range of 6000 and 510000
1001 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { 989 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) {
1002 EXPECT_TRUE(SetupEngine()); 990 EXPECT_TRUE(SetupEngine());
1003 int channel_num = voe_.GetLastChannel(); 991 int channel_num = voe_.GetLastChannel();
1004 std::vector<cricket::AudioCodec> codecs; 992 cricket::AudioSendParameters parameters;
1005 codecs.push_back(kOpusCodec); 993 parameters.codecs.push_back(kOpusCodec);
1006 codecs[0].bitrate = 30000; 994 parameters.codecs[0].bitrate = 30000;
1007 webrtc::CodecInst gcodec; 995 webrtc::CodecInst gcodec;
1008 996
1009 // Ignore if less than 6000. 997 // Ignore if less than 6000.
1010 codecs[0].params["maxaveragebitrate"] = "5999"; 998 parameters.codecs[0].params["maxaveragebitrate"] = "5999";
1011 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 999 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1012 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1000 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1013 EXPECT_EQ(6000, gcodec.rate); 1001 EXPECT_EQ(6000, gcodec.rate);
1014 1002
1015 // Ignore if larger than 510000. 1003 // Ignore if larger than 510000.
1016 codecs[0].params["maxaveragebitrate"] = "510001"; 1004 parameters.codecs[0].params["maxaveragebitrate"] = "510001";
1017 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1005 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1018 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1006 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1019 EXPECT_EQ(510000, gcodec.rate); 1007 EXPECT_EQ(510000, gcodec.rate);
1020 1008
1021 codecs[0].params["maxaveragebitrate"] = "200000"; 1009 parameters.codecs[0].params["maxaveragebitrate"] = "200000";
1022 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1010 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1023 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1011 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1024 EXPECT_EQ(200000, gcodec.rate); 1012 EXPECT_EQ(200000, gcodec.rate);
1025 } 1013 }
1026 1014
1027 // Test that we can enable NACK with opus as caller. 1015 // Test that we can enable NACK with opus as caller.
1028 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { 1016 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) {
1029 EXPECT_TRUE(SetupEngine()); 1017 EXPECT_TRUE(SetupEngine());
1030 int channel_num = voe_.GetLastChannel(); 1018 int channel_num = voe_.GetLastChannel();
1031 std::vector<cricket::AudioCodec> codecs; 1019 cricket::AudioSendParameters parameters;
1032 codecs.push_back(kOpusCodec); 1020 parameters.codecs.push_back(kOpusCodec);
1033 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1021 parameters.codecs[0].AddFeedbackParam(
1034 cricket::kParamValueEmpty)); 1022 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1023 cricket::kParamValueEmpty));
1035 EXPECT_FALSE(voe_.GetNACK(channel_num)); 1024 EXPECT_FALSE(voe_.GetNACK(channel_num));
1036 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1025 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1037 EXPECT_TRUE(voe_.GetNACK(channel_num)); 1026 EXPECT_TRUE(voe_.GetNACK(channel_num));
1038 } 1027 }
1039 1028
1040 // Test that we can enable NACK with opus as callee. 1029 // Test that we can enable NACK with opus as callee.
1041 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { 1030 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) {
1042 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 1031 EXPECT_TRUE(SetupEngineWithoutStream());
1043 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
1044 EXPECT_TRUE(channel_ != nullptr);
1045
1046 int channel_num = voe_.GetLastChannel(); 1032 int channel_num = voe_.GetLastChannel();
1047 std::vector<cricket::AudioCodec> codecs; 1033 cricket::AudioSendParameters parameters;
1048 codecs.push_back(kOpusCodec); 1034 parameters.codecs.push_back(kOpusCodec);
1049 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1035 parameters.codecs[0].AddFeedbackParam(
1050 cricket::kParamValueEmpty)); 1036 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1037 cricket::kParamValueEmpty));
1051 EXPECT_FALSE(voe_.GetNACK(channel_num)); 1038 EXPECT_FALSE(voe_.GetNACK(channel_num));
1052 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1039 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1053 EXPECT_FALSE(voe_.GetNACK(channel_num)); 1040 EXPECT_FALSE(voe_.GetNACK(channel_num));
1054 1041
1055 EXPECT_TRUE(channel_->AddSendStream( 1042 EXPECT_TRUE(channel_->AddSendStream(
1056 cricket::StreamParams::CreateLegacy(kSsrc1))); 1043 cricket::StreamParams::CreateLegacy(kSsrc1)));
1057 EXPECT_TRUE(voe_.GetNACK(channel_num)); 1044 EXPECT_TRUE(voe_.GetNACK(channel_num));
1058 } 1045 }
1059 1046
1060 // Test that we can enable NACK on receive streams. 1047 // Test that we can enable NACK on receive streams.
1061 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { 1048 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) {
1062 EXPECT_TRUE(SetupEngine()); 1049 EXPECT_TRUE(SetupEngine());
1063 EXPECT_TRUE(channel_->SetOptions(options_conference_));
1064 int channel_num1 = voe_.GetLastChannel(); 1050 int channel_num1 = voe_.GetLastChannel();
1065 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 1051 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
1066 int channel_num2 = voe_.GetLastChannel(); 1052 int channel_num2 = voe_.GetLastChannel();
1067 std::vector<cricket::AudioCodec> codecs; 1053 cricket::AudioSendParameters parameters;
1068 codecs.push_back(kOpusCodec); 1054 parameters.codecs.push_back(kOpusCodec);
1069 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1055 parameters.codecs[0].AddFeedbackParam(
1070 cricket::kParamValueEmpty)); 1056 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1057 cricket::kParamValueEmpty));
1071 EXPECT_FALSE(voe_.GetNACK(channel_num1)); 1058 EXPECT_FALSE(voe_.GetNACK(channel_num1));
1072 EXPECT_FALSE(voe_.GetNACK(channel_num2)); 1059 EXPECT_FALSE(voe_.GetNACK(channel_num2));
1073 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1060 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1074 EXPECT_TRUE(voe_.GetNACK(channel_num1)); 1061 EXPECT_TRUE(voe_.GetNACK(channel_num1));
1075 EXPECT_TRUE(voe_.GetNACK(channel_num2)); 1062 EXPECT_TRUE(voe_.GetNACK(channel_num2));
1076 } 1063 }
1077 1064
1078 // Test that we can disable NACK. 1065 // Test that we can disable NACK.
1079 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { 1066 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) {
1080 EXPECT_TRUE(SetupEngine()); 1067 EXPECT_TRUE(SetupEngine());
1081 int channel_num = voe_.GetLastChannel(); 1068 int channel_num = voe_.GetLastChannel();
1082 std::vector<cricket::AudioCodec> codecs; 1069 cricket::AudioSendParameters parameters;
1083 codecs.push_back(kOpusCodec); 1070 parameters.codecs.push_back(kOpusCodec);
1084 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1071 parameters.codecs[0].AddFeedbackParam(
1085 cricket::kParamValueEmpty)); 1072 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1086 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1073 cricket::kParamValueEmpty));
1074 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1087 EXPECT_TRUE(voe_.GetNACK(channel_num)); 1075 EXPECT_TRUE(voe_.GetNACK(channel_num));
1088 1076
1089 codecs.clear(); 1077 parameters.codecs.clear();
1090 codecs.push_back(kOpusCodec); 1078 parameters.codecs.push_back(kOpusCodec);
1091 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1079 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1092 EXPECT_FALSE(voe_.GetNACK(channel_num)); 1080 EXPECT_FALSE(voe_.GetNACK(channel_num));
1093 } 1081 }
1094 1082
1095 // Test that we can disable NACK on receive streams. 1083 // Test that we can disable NACK on receive streams.
1096 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { 1084 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) {
1097 EXPECT_TRUE(SetupEngine()); 1085 EXPECT_TRUE(SetupEngine());
1098 EXPECT_TRUE(channel_->SetOptions(options_conference_));
1099 int channel_num1 = voe_.GetLastChannel(); 1086 int channel_num1 = voe_.GetLastChannel();
1100 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 1087 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
1101 int channel_num2 = voe_.GetLastChannel(); 1088 int channel_num2 = voe_.GetLastChannel();
1102 std::vector<cricket::AudioCodec> codecs; 1089 cricket::AudioSendParameters parameters;
1103 codecs.push_back(kOpusCodec); 1090 parameters.codecs.push_back(kOpusCodec);
1104 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1091 parameters.codecs[0].AddFeedbackParam(
1105 cricket::kParamValueEmpty)); 1092 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1106 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1093 cricket::kParamValueEmpty));
1094 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1107 EXPECT_TRUE(voe_.GetNACK(channel_num1)); 1095 EXPECT_TRUE(voe_.GetNACK(channel_num1));
1108 EXPECT_TRUE(voe_.GetNACK(channel_num2)); 1096 EXPECT_TRUE(voe_.GetNACK(channel_num2));
1109 1097
1110 codecs.clear(); 1098 parameters.codecs.clear();
1111 codecs.push_back(kOpusCodec); 1099 parameters.codecs.push_back(kOpusCodec);
1112 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1100 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1113 EXPECT_FALSE(voe_.GetNACK(channel_num1)); 1101 EXPECT_FALSE(voe_.GetNACK(channel_num1));
1114 EXPECT_FALSE(voe_.GetNACK(channel_num2)); 1102 EXPECT_FALSE(voe_.GetNACK(channel_num2));
1115 } 1103 }
1116 1104
1117 // Test that NACK is enabled on a new receive stream. 1105 // Test that NACK is enabled on a new receive stream.
1118 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { 1106 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) {
1119 EXPECT_TRUE(SetupEngine()); 1107 EXPECT_TRUE(SetupEngine());
1120 EXPECT_TRUE(channel_->SetOptions(options_conference_));
1121 int channel_num = voe_.GetLastChannel(); 1108 int channel_num = voe_.GetLastChannel();
1122 std::vector<cricket::AudioCodec> codecs; 1109 cricket::AudioSendParameters parameters;
1123 codecs.push_back(kIsacCodec); 1110 parameters.codecs.push_back(kIsacCodec);
1124 codecs[0].AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1111 parameters.codecs.push_back(kCn16000Codec);
1125 cricket::kParamValueEmpty)); 1112 parameters.codecs[0].AddFeedbackParam(
1126 codecs.push_back(kCn16000Codec); 1113 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1127 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1114 cricket::kParamValueEmpty));
1115 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1128 EXPECT_TRUE(voe_.GetNACK(channel_num)); 1116 EXPECT_TRUE(voe_.GetNACK(channel_num));
1129 1117
1130 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 1118 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
1131 channel_num = voe_.GetLastChannel(); 1119 channel_num = voe_.GetLastChannel();
1132 EXPECT_TRUE(voe_.GetNACK(channel_num)); 1120 EXPECT_TRUE(voe_.GetNACK(channel_num));
1133 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 1121 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
1134 channel_num = voe_.GetLastChannel(); 1122 channel_num = voe_.GetLastChannel();
1135 EXPECT_TRUE(voe_.GetNACK(channel_num)); 1123 EXPECT_TRUE(voe_.GetNACK(channel_num));
1136 } 1124 }
1137 1125
1138 // Test that without useinbandfec, Opus FEC is off. 1126 // Test that without useinbandfec, Opus FEC is off.
1139 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { 1127 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) {
1140 EXPECT_TRUE(SetupEngine()); 1128 EXPECT_TRUE(SetupEngine());
1141 int channel_num = voe_.GetLastChannel(); 1129 int channel_num = voe_.GetLastChannel();
1142 std::vector<cricket::AudioCodec> codecs; 1130 cricket::AudioSendParameters parameters;
1143 codecs.push_back(kOpusCodec); 1131 parameters.codecs.push_back(kOpusCodec);
1144 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1132 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1145 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); 1133 EXPECT_FALSE(voe_.GetCodecFEC(channel_num));
1146 } 1134 }
1147 1135
1148 // Test that with useinbandfec=0, Opus FEC is off. 1136 // Test that with useinbandfec=0, Opus FEC is off.
1149 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { 1137 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) {
1150 EXPECT_TRUE(SetupEngine()); 1138 EXPECT_TRUE(SetupEngine());
1151 int channel_num = voe_.GetLastChannel(); 1139 int channel_num = voe_.GetLastChannel();
1152 std::vector<cricket::AudioCodec> codecs; 1140 cricket::AudioSendParameters parameters;
1153 codecs.push_back(kOpusCodec); 1141 parameters.codecs.push_back(kOpusCodec);
1154 codecs[0].bitrate = 0; 1142 parameters.codecs[0].bitrate = 0;
1155 codecs[0].params["useinbandfec"] = "0"; 1143 parameters.codecs[0].params["useinbandfec"] = "0";
1156 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1144 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1157 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); 1145 EXPECT_FALSE(voe_.GetCodecFEC(channel_num));
1158 webrtc::CodecInst gcodec; 1146 webrtc::CodecInst gcodec;
1159 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1147 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1160 EXPECT_STREQ("opus", gcodec.plname); 1148 EXPECT_STREQ("opus", gcodec.plname);
1161 EXPECT_EQ(1, gcodec.channels); 1149 EXPECT_EQ(1, gcodec.channels);
1162 EXPECT_EQ(32000, gcodec.rate); 1150 EXPECT_EQ(32000, gcodec.rate);
1163 } 1151 }
1164 1152
1165 // Test that with useinbandfec=1, Opus FEC is on. 1153 // Test that with useinbandfec=1, Opus FEC is on.
1166 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { 1154 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) {
1167 EXPECT_TRUE(SetupEngine()); 1155 EXPECT_TRUE(SetupEngine());
1168 int channel_num = voe_.GetLastChannel(); 1156 int channel_num = voe_.GetLastChannel();
1169 std::vector<cricket::AudioCodec> codecs; 1157 cricket::AudioSendParameters parameters;
1170 codecs.push_back(kOpusCodec); 1158 parameters.codecs.push_back(kOpusCodec);
1171 codecs[0].bitrate = 0; 1159 parameters.codecs[0].bitrate = 0;
1172 codecs[0].params["useinbandfec"] = "1"; 1160 parameters.codecs[0].params["useinbandfec"] = "1";
1173 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1161 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1174 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); 1162 EXPECT_TRUE(voe_.GetCodecFEC(channel_num));
1175 webrtc::CodecInst gcodec; 1163 webrtc::CodecInst gcodec;
1176 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1164 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1177 EXPECT_STREQ("opus", gcodec.plname); 1165 EXPECT_STREQ("opus", gcodec.plname);
1178 EXPECT_EQ(1, gcodec.channels); 1166 EXPECT_EQ(1, gcodec.channels);
1179 EXPECT_EQ(32000, gcodec.rate); 1167 EXPECT_EQ(32000, gcodec.rate);
1180 } 1168 }
1181 1169
1182 // Test that with useinbandfec=1, stereo=1, Opus FEC is on. 1170 // Test that with useinbandfec=1, stereo=1, Opus FEC is on.
1183 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { 1171 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) {
1184 EXPECT_TRUE(SetupEngine()); 1172 EXPECT_TRUE(SetupEngine());
1185 int channel_num = voe_.GetLastChannel(); 1173 int channel_num = voe_.GetLastChannel();
1186 std::vector<cricket::AudioCodec> codecs; 1174 cricket::AudioSendParameters parameters;
1187 codecs.push_back(kOpusCodec); 1175 parameters.codecs.push_back(kOpusCodec);
1188 codecs[0].bitrate = 0; 1176 parameters.codecs[0].bitrate = 0;
1189 codecs[0].params["stereo"] = "1"; 1177 parameters.codecs[0].params["stereo"] = "1";
1190 codecs[0].params["useinbandfec"] = "1"; 1178 parameters.codecs[0].params["useinbandfec"] = "1";
1191 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1179 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1192 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); 1180 EXPECT_TRUE(voe_.GetCodecFEC(channel_num));
1193 webrtc::CodecInst gcodec; 1181 webrtc::CodecInst gcodec;
1194 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1182 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1195 EXPECT_STREQ("opus", gcodec.plname); 1183 EXPECT_STREQ("opus", gcodec.plname);
1196 EXPECT_EQ(2, gcodec.channels); 1184 EXPECT_EQ(2, gcodec.channels);
1197 EXPECT_EQ(64000, gcodec.rate); 1185 EXPECT_EQ(64000, gcodec.rate);
1198 } 1186 }
1199 1187
1200 // Test that with non-Opus, codec FEC is off. 1188 // Test that with non-Opus, codec FEC is off.
1201 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { 1189 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) {
1202 EXPECT_TRUE(SetupEngine()); 1190 EXPECT_TRUE(SetupEngine());
1203 int channel_num = voe_.GetLastChannel(); 1191 int channel_num = voe_.GetLastChannel();
1204 std::vector<cricket::AudioCodec> codecs; 1192 cricket::AudioSendParameters parameters;
1205 codecs.push_back(kIsacCodec); 1193 parameters.codecs.push_back(kIsacCodec);
1206 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1194 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1207 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); 1195 EXPECT_FALSE(voe_.GetCodecFEC(channel_num));
1208 } 1196 }
1209 1197
1210 // Test the with non-Opus, even if useinbandfec=1, FEC is off. 1198 // Test the with non-Opus, even if useinbandfec=1, FEC is off.
1211 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { 1199 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) {
1212 EXPECT_TRUE(SetupEngine()); 1200 EXPECT_TRUE(SetupEngine());
1213 int channel_num = voe_.GetLastChannel(); 1201 int channel_num = voe_.GetLastChannel();
1214 std::vector<cricket::AudioCodec> codecs; 1202 cricket::AudioSendParameters parameters;
1215 codecs.push_back(kIsacCodec); 1203 parameters.codecs.push_back(kIsacCodec);
1216 codecs[0].params["useinbandfec"] = "1"; 1204 parameters.codecs[0].params["useinbandfec"] = "1";
1217 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1205 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1218 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); 1206 EXPECT_FALSE(voe_.GetCodecFEC(channel_num));
1219 } 1207 }
1220 1208
1221 // Test that Opus FEC status can be changed. 1209 // Test that Opus FEC status can be changed.
1222 TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { 1210 TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) {
1223 EXPECT_TRUE(SetupEngine()); 1211 EXPECT_TRUE(SetupEngine());
1224 int channel_num = voe_.GetLastChannel(); 1212 int channel_num = voe_.GetLastChannel();
1225 std::vector<cricket::AudioCodec> codecs; 1213 cricket::AudioSendParameters parameters;
1226 codecs.push_back(kOpusCodec); 1214 parameters.codecs.push_back(kOpusCodec);
1227 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1215 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1228 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); 1216 EXPECT_FALSE(voe_.GetCodecFEC(channel_num));
1229 codecs[0].params["useinbandfec"] = "1"; 1217 parameters.codecs[0].params["useinbandfec"] = "1";
1230 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1218 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1231 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); 1219 EXPECT_TRUE(voe_.GetCodecFEC(channel_num));
1232 } 1220 }
1233 1221
1234 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. 1222 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode.
1235 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { 1223 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) {
1236 EXPECT_TRUE(SetupEngine()); 1224 EXPECT_TRUE(SetupEngine());
1237 int channel_num = voe_.GetLastChannel(); 1225 int channel_num = voe_.GetLastChannel();
1238 std::vector<cricket::AudioCodec> codecs; 1226 cricket::AudioSendParameters parameters;
1239 codecs.push_back(kOpusCodec); 1227 parameters.codecs.push_back(kOpusCodec);
1240 codecs[0].bitrate = 0; 1228 parameters.codecs[0].bitrate = 0;
1241 codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); 1229 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000);
1242 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1230 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1243 EXPECT_EQ(cricket::kOpusBandwidthNb, 1231 EXPECT_EQ(cricket::kOpusBandwidthNb,
1244 voe_.GetMaxEncodingBandwidth(channel_num)); 1232 voe_.GetMaxEncodingBandwidth(channel_num));
1245 webrtc::CodecInst gcodec; 1233 webrtc::CodecInst gcodec;
1246 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1234 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1247 EXPECT_STREQ("opus", gcodec.plname); 1235 EXPECT_STREQ("opus", gcodec.plname);
1248 1236
1249 EXPECT_EQ(12000, gcodec.rate); 1237 EXPECT_EQ(12000, gcodec.rate);
1250 codecs[0].SetParam(cricket::kCodecParamStereo, "1"); 1238 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1");
1251 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1239 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1252 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1240 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1253 EXPECT_EQ(24000, gcodec.rate); 1241 EXPECT_EQ(24000, gcodec.rate);
1254 } 1242 }
1255 1243
1256 // Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode. 1244 // Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode.
1257 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { 1245 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) {
1258 EXPECT_TRUE(SetupEngine()); 1246 EXPECT_TRUE(SetupEngine());
1259 int channel_num = voe_.GetLastChannel(); 1247 int channel_num = voe_.GetLastChannel();
1260 std::vector<cricket::AudioCodec> codecs; 1248 cricket::AudioSendParameters parameters;
1261 codecs.push_back(kOpusCodec); 1249 parameters.codecs.push_back(kOpusCodec);
1262 codecs[0].bitrate = 0; 1250 parameters.codecs[0].bitrate = 0;
1263 codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001); 1251 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001);
1264 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1252 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1265 EXPECT_EQ(cricket::kOpusBandwidthMb, 1253 EXPECT_EQ(cricket::kOpusBandwidthMb,
1266 voe_.GetMaxEncodingBandwidth(channel_num)); 1254 voe_.GetMaxEncodingBandwidth(channel_num));
1267 webrtc::CodecInst gcodec; 1255 webrtc::CodecInst gcodec;
1268 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1256 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1269 EXPECT_STREQ("opus", gcodec.plname); 1257 EXPECT_STREQ("opus", gcodec.plname);
1270 1258
1271 EXPECT_EQ(20000, gcodec.rate); 1259 EXPECT_EQ(20000, gcodec.rate);
1272 codecs[0].SetParam(cricket::kCodecParamStereo, "1"); 1260 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1");
1273 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1261 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1274 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1262 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1275 EXPECT_EQ(40000, gcodec.rate); 1263 EXPECT_EQ(40000, gcodec.rate);
1276 } 1264 }
1277 1265
1278 // Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode. 1266 // Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode.
1279 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { 1267 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) {
1280 EXPECT_TRUE(SetupEngine()); 1268 EXPECT_TRUE(SetupEngine());
1281 int channel_num = voe_.GetLastChannel(); 1269 int channel_num = voe_.GetLastChannel();
1282 std::vector<cricket::AudioCodec> codecs; 1270 cricket::AudioSendParameters parameters;
1283 codecs.push_back(kOpusCodec); 1271 parameters.codecs.push_back(kOpusCodec);
1284 codecs[0].bitrate = 0; 1272 parameters.codecs[0].bitrate = 0;
1285 codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001); 1273 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001);
1286 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1274 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1287 EXPECT_EQ(cricket::kOpusBandwidthWb, 1275 EXPECT_EQ(cricket::kOpusBandwidthWb,
1288 voe_.GetMaxEncodingBandwidth(channel_num)); 1276 voe_.GetMaxEncodingBandwidth(channel_num));
1289 webrtc::CodecInst gcodec; 1277 webrtc::CodecInst gcodec;
1290 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1278 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1291 EXPECT_STREQ("opus", gcodec.plname); 1279 EXPECT_STREQ("opus", gcodec.plname);
1292 1280
1293 EXPECT_EQ(20000, gcodec.rate); 1281 EXPECT_EQ(20000, gcodec.rate);
1294 codecs[0].SetParam(cricket::kCodecParamStereo, "1"); 1282 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1");
1295 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1283 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1296 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1284 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1297 EXPECT_EQ(40000, gcodec.rate); 1285 EXPECT_EQ(40000, gcodec.rate);
1298 } 1286 }
1299 1287
1300 // Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode. 1288 // Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode.
1301 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { 1289 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) {
1302 EXPECT_TRUE(SetupEngine()); 1290 EXPECT_TRUE(SetupEngine());
1303 int channel_num = voe_.GetLastChannel(); 1291 int channel_num = voe_.GetLastChannel();
1304 std::vector<cricket::AudioCodec> codecs; 1292 cricket::AudioSendParameters parameters;
1305 codecs.push_back(kOpusCodec); 1293 parameters.codecs.push_back(kOpusCodec);
1306 codecs[0].bitrate = 0; 1294 parameters.codecs[0].bitrate = 0;
1307 codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001); 1295 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001);
1308 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1296 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1309 EXPECT_EQ(cricket::kOpusBandwidthSwb, 1297 EXPECT_EQ(cricket::kOpusBandwidthSwb,
1310 voe_.GetMaxEncodingBandwidth(channel_num)); 1298 voe_.GetMaxEncodingBandwidth(channel_num));
1311 webrtc::CodecInst gcodec; 1299 webrtc::CodecInst gcodec;
1312 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1300 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1313 EXPECT_STREQ("opus", gcodec.plname); 1301 EXPECT_STREQ("opus", gcodec.plname);
1314 1302
1315 EXPECT_EQ(32000, gcodec.rate); 1303 EXPECT_EQ(32000, gcodec.rate);
1316 codecs[0].SetParam(cricket::kCodecParamStereo, "1"); 1304 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1");
1317 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1305 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1318 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1306 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1319 EXPECT_EQ(64000, gcodec.rate); 1307 EXPECT_EQ(64000, gcodec.rate);
1320 } 1308 }
1321 1309
1322 // Test 24000 < maxplaybackrate triggers Opus full band mode. 1310 // Test 24000 < maxplaybackrate triggers Opus full band mode.
1323 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { 1311 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) {
1324 EXPECT_TRUE(SetupEngine()); 1312 EXPECT_TRUE(SetupEngine());
1325 int channel_num = voe_.GetLastChannel(); 1313 int channel_num = voe_.GetLastChannel();
1326 std::vector<cricket::AudioCodec> codecs; 1314 cricket::AudioSendParameters parameters;
1327 codecs.push_back(kOpusCodec); 1315 parameters.codecs.push_back(kOpusCodec);
1328 codecs[0].bitrate = 0; 1316 parameters.codecs[0].bitrate = 0;
1329 codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001); 1317 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001);
1330 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1318 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1331 EXPECT_EQ(cricket::kOpusBandwidthFb, 1319 EXPECT_EQ(cricket::kOpusBandwidthFb,
1332 voe_.GetMaxEncodingBandwidth(channel_num)); 1320 voe_.GetMaxEncodingBandwidth(channel_num));
1333 webrtc::CodecInst gcodec; 1321 webrtc::CodecInst gcodec;
1334 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1322 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1335 EXPECT_STREQ("opus", gcodec.plname); 1323 EXPECT_STREQ("opus", gcodec.plname);
1336 1324
1337 EXPECT_EQ(32000, gcodec.rate); 1325 EXPECT_EQ(32000, gcodec.rate);
1338 codecs[0].SetParam(cricket::kCodecParamStereo, "1"); 1326 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1");
1339 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1327 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1340 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1328 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1341 EXPECT_EQ(64000, gcodec.rate); 1329 EXPECT_EQ(64000, gcodec.rate);
1342 } 1330 }
1343 1331
1344 // Test Opus that without maxplaybackrate, default playback rate is used. 1332 // Test Opus that without maxplaybackrate, default playback rate is used.
1345 TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { 1333 TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) {
1346 EXPECT_TRUE(SetupEngine()); 1334 EXPECT_TRUE(SetupEngine());
1347 int channel_num = voe_.GetLastChannel(); 1335 int channel_num = voe_.GetLastChannel();
1348 std::vector<cricket::AudioCodec> codecs; 1336 cricket::AudioSendParameters parameters;
1349 codecs.push_back(kOpusCodec); 1337 parameters.codecs.push_back(kOpusCodec);
1350 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1338 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1351 EXPECT_EQ(cricket::kOpusBandwidthFb, 1339 EXPECT_EQ(cricket::kOpusBandwidthFb,
1352 voe_.GetMaxEncodingBandwidth(channel_num)); 1340 voe_.GetMaxEncodingBandwidth(channel_num));
1353 } 1341 }
1354 1342
1355 // Test the with non-Opus, maxplaybackrate has no effect. 1343 // Test the with non-Opus, maxplaybackrate has no effect.
1356 TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { 1344 TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) {
1357 EXPECT_TRUE(SetupEngine()); 1345 EXPECT_TRUE(SetupEngine());
1358 int channel_num = voe_.GetLastChannel(); 1346 int channel_num = voe_.GetLastChannel();
1359 std::vector<cricket::AudioCodec> codecs; 1347 cricket::AudioSendParameters parameters;
1360 codecs.push_back(kIsacCodec); 1348 parameters.codecs.push_back(kIsacCodec);
1361 codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000); 1349 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000);
1362 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1350 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1363 EXPECT_EQ(0, voe_.GetMaxEncodingBandwidth(channel_num)); 1351 EXPECT_EQ(0, voe_.GetMaxEncodingBandwidth(channel_num));
1364 } 1352 }
1365 1353
1366 // Test maxplaybackrate can be set on two streams. 1354 // Test maxplaybackrate can be set on two streams.
1367 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { 1355 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) {
1368 EXPECT_TRUE(SetupEngine()); 1356 EXPECT_TRUE(SetupEngine());
1369 int channel_num = voe_.GetLastChannel(); 1357 int channel_num = voe_.GetLastChannel();
1370 std::vector<cricket::AudioCodec> codecs; 1358 cricket::AudioSendParameters parameters;
1371 codecs.push_back(kOpusCodec); 1359 parameters.codecs.push_back(kOpusCodec);
1372 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1360 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1373 // Default bandwidth is 24000. 1361 // Default bandwidth is 24000.
1374 EXPECT_EQ(cricket::kOpusBandwidthFb, 1362 EXPECT_EQ(cricket::kOpusBandwidthFb,
1375 voe_.GetMaxEncodingBandwidth(channel_num)); 1363 voe_.GetMaxEncodingBandwidth(channel_num));
1376 1364
1377 codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); 1365 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000);
1378 1366
1379 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1367 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1380 EXPECT_EQ(cricket::kOpusBandwidthNb, 1368 EXPECT_EQ(cricket::kOpusBandwidthNb,
1381 voe_.GetMaxEncodingBandwidth(channel_num)); 1369 voe_.GetMaxEncodingBandwidth(channel_num));
1382 1370
1383 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc2)); 1371 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc2));
1384 channel_num = voe_.GetLastChannel(); 1372 channel_num = voe_.GetLastChannel();
1385 EXPECT_EQ(cricket::kOpusBandwidthNb, 1373 EXPECT_EQ(cricket::kOpusBandwidthNb,
1386 voe_.GetMaxEncodingBandwidth(channel_num)); 1374 voe_.GetMaxEncodingBandwidth(channel_num));
1387 } 1375 }
1388 1376
1389 // Test that with usedtx=0, Opus DTX is off. 1377 // Test that with usedtx=0, Opus DTX is off.
1390 TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { 1378 TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) {
1391 EXPECT_TRUE(SetupEngine()); 1379 EXPECT_TRUE(SetupEngine());
1392 int channel_num = voe_.GetLastChannel(); 1380 int channel_num = voe_.GetLastChannel();
1393 std::vector<cricket::AudioCodec> codecs; 1381 cricket::AudioSendParameters parameters;
1394 codecs.push_back(kOpusCodec); 1382 parameters.codecs.push_back(kOpusCodec);
1395 codecs[0].params["usedtx"] = "0"; 1383 parameters.codecs[0].params["usedtx"] = "0";
1396 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1384 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1397 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); 1385 EXPECT_FALSE(voe_.GetOpusDtx(channel_num));
1398 } 1386 }
1399 1387
1400 // Test that with usedtx=1, Opus DTX is on. 1388 // Test that with usedtx=1, Opus DTX is on.
1401 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { 1389 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) {
1402 EXPECT_TRUE(SetupEngine()); 1390 EXPECT_TRUE(SetupEngine());
1403 int channel_num = voe_.GetLastChannel(); 1391 int channel_num = voe_.GetLastChannel();
1404 std::vector<cricket::AudioCodec> codecs; 1392 cricket::AudioSendParameters parameters;
1405 codecs.push_back(kOpusCodec); 1393 parameters.codecs.push_back(kOpusCodec);
1406 codecs[0].params["usedtx"] = "1"; 1394 parameters.codecs[0].params["usedtx"] = "1";
1407 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1395 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1408 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); 1396 EXPECT_TRUE(voe_.GetOpusDtx(channel_num));
1409 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. 1397 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD.
1410 } 1398 }
1411 1399
1412 // Test that usedtx=1 works with stereo Opus. 1400 // Test that usedtx=1 works with stereo Opus.
1413 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { 1401 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) {
1414 EXPECT_TRUE(SetupEngine()); 1402 EXPECT_TRUE(SetupEngine());
1415 int channel_num = voe_.GetLastChannel(); 1403 int channel_num = voe_.GetLastChannel();
1416 std::vector<cricket::AudioCodec> codecs; 1404 cricket::AudioSendParameters parameters;
1417 codecs.push_back(kOpusCodec); 1405 parameters.codecs.push_back(kOpusCodec);
1418 codecs[0].params["usedtx"] = "1"; 1406 parameters.codecs[0].params["usedtx"] = "1";
1419 codecs[0].params["stereo"] = "1"; 1407 parameters.codecs[0].params["stereo"] = "1";
1420 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1408 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1421 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); 1409 EXPECT_TRUE(voe_.GetOpusDtx(channel_num));
1422 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. 1410 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD.
1423 } 1411 }
1424 1412
1425 // Test that usedtx=1 does not work with non Opus. 1413 // Test that usedtx=1 does not work with non Opus.
1426 TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { 1414 TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) {
1427 EXPECT_TRUE(SetupEngine()); 1415 EXPECT_TRUE(SetupEngine());
1428 int channel_num = voe_.GetLastChannel(); 1416 int channel_num = voe_.GetLastChannel();
1429 std::vector<cricket::AudioCodec> codecs; 1417 cricket::AudioSendParameters parameters;
1430 codecs.push_back(kIsacCodec); 1418 parameters.codecs.push_back(kIsacCodec);
1431 codecs[0].params["usedtx"] = "1"; 1419 parameters.codecs[0].params["usedtx"] = "1";
1432 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1420 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1433 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); 1421 EXPECT_FALSE(voe_.GetOpusDtx(channel_num));
1434 } 1422 }
1435 1423
1436 // Test that we can switch back and forth between Opus and ISAC with CN. 1424 // Test that we can switch back and forth between Opus and ISAC with CN.
1437 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { 1425 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) {
1438 EXPECT_TRUE(SetupEngine()); 1426 EXPECT_TRUE(SetupEngine());
1439 int channel_num = voe_.GetLastChannel(); 1427 int channel_num = voe_.GetLastChannel();
1440 std::vector<cricket::AudioCodec> opus_codecs; 1428 cricket::AudioSendParameters opus_parameters;
1441 opus_codecs.push_back(kOpusCodec); 1429 opus_parameters.codecs.push_back(kOpusCodec);
1442 EXPECT_TRUE(channel_->SetSendCodecs(opus_codecs)); 1430 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters));
1443 webrtc::CodecInst gcodec; 1431 webrtc::CodecInst gcodec;
1444 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1432 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1445 EXPECT_EQ(111, gcodec.pltype); 1433 EXPECT_EQ(111, gcodec.pltype);
1446 EXPECT_STREQ("opus", gcodec.plname); 1434 EXPECT_STREQ("opus", gcodec.plname);
1447 1435
1448 std::vector<cricket::AudioCodec> isac_codecs; 1436 cricket::AudioSendParameters isac_parameters;
1449 isac_codecs.push_back(kIsacCodec); 1437 isac_parameters.codecs.push_back(kIsacCodec);
1450 isac_codecs.push_back(kCn16000Codec); 1438 isac_parameters.codecs.push_back(kCn16000Codec);
1451 isac_codecs.push_back(kOpusCodec); 1439 isac_parameters.codecs.push_back(kOpusCodec);
1452 EXPECT_TRUE(channel_->SetSendCodecs(isac_codecs)); 1440 EXPECT_TRUE(channel_->SetSendParameters(isac_parameters));
1453 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1441 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1454 EXPECT_EQ(103, gcodec.pltype); 1442 EXPECT_EQ(103, gcodec.pltype);
1455 EXPECT_STREQ("ISAC", gcodec.plname); 1443 EXPECT_STREQ("ISAC", gcodec.plname);
1456 1444
1457 EXPECT_TRUE(channel_->SetSendCodecs(opus_codecs)); 1445 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters));
1458 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1446 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1459 EXPECT_EQ(111, gcodec.pltype); 1447 EXPECT_EQ(111, gcodec.pltype);
1460 EXPECT_STREQ("opus", gcodec.plname); 1448 EXPECT_STREQ("opus", gcodec.plname);
1461 } 1449 }
1462 1450
1463 // Test that we handle various ways of specifying bitrate. 1451 // Test that we handle various ways of specifying bitrate.
1464 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { 1452 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) {
1465 EXPECT_TRUE(SetupEngine()); 1453 EXPECT_TRUE(SetupEngine());
1466 int channel_num = voe_.GetLastChannel(); 1454 int channel_num = voe_.GetLastChannel();
1467 std::vector<cricket::AudioCodec> codecs; 1455 cricket::AudioSendParameters parameters;
1468 codecs.push_back(kIsacCodec); // bitrate == 32000 1456 parameters.codecs.push_back(kIsacCodec); // bitrate == 32000
1469 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1457 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1470 webrtc::CodecInst gcodec; 1458 webrtc::CodecInst gcodec;
1471 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1459 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1472 EXPECT_EQ(103, gcodec.pltype); 1460 EXPECT_EQ(103, gcodec.pltype);
1473 EXPECT_STREQ("ISAC", gcodec.plname); 1461 EXPECT_STREQ("ISAC", gcodec.plname);
1474 EXPECT_EQ(32000, gcodec.rate); 1462 EXPECT_EQ(32000, gcodec.rate);
1475 1463
1476 codecs[0].bitrate = 0; // bitrate == default 1464 parameters.codecs[0].bitrate = 0; // bitrate == default
1477 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1465 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1478 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1466 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1479 EXPECT_EQ(103, gcodec.pltype); 1467 EXPECT_EQ(103, gcodec.pltype);
1480 EXPECT_STREQ("ISAC", gcodec.plname); 1468 EXPECT_STREQ("ISAC", gcodec.plname);
1481 EXPECT_EQ(-1, gcodec.rate); 1469 EXPECT_EQ(-1, gcodec.rate);
1482 1470
1483 codecs[0].bitrate = 28000; // bitrate == 28000 1471 parameters.codecs[0].bitrate = 28000; // bitrate == 28000
1484 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1472 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1485 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1473 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1486 EXPECT_EQ(103, gcodec.pltype); 1474 EXPECT_EQ(103, gcodec.pltype);
1487 EXPECT_STREQ("ISAC", gcodec.plname); 1475 EXPECT_STREQ("ISAC", gcodec.plname);
1488 EXPECT_EQ(28000, gcodec.rate); 1476 EXPECT_EQ(28000, gcodec.rate);
1489 1477
1490 codecs[0] = kPcmuCodec; // bitrate == 64000 1478 parameters.codecs[0] = kPcmuCodec; // bitrate == 64000
1491 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1479 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1492 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1480 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1493 EXPECT_EQ(0, gcodec.pltype); 1481 EXPECT_EQ(0, gcodec.pltype);
1494 EXPECT_STREQ("PCMU", gcodec.plname); 1482 EXPECT_STREQ("PCMU", gcodec.plname);
1495 EXPECT_EQ(64000, gcodec.rate); 1483 EXPECT_EQ(64000, gcodec.rate);
1496 1484
1497 codecs[0].bitrate = 0; // bitrate == default 1485 parameters.codecs[0].bitrate = 0; // bitrate == default
1498 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1486 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1499 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1487 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1500 EXPECT_EQ(0, gcodec.pltype); 1488 EXPECT_EQ(0, gcodec.pltype);
1501 EXPECT_STREQ("PCMU", gcodec.plname); 1489 EXPECT_STREQ("PCMU", gcodec.plname);
1502 EXPECT_EQ(64000, gcodec.rate); 1490 EXPECT_EQ(64000, gcodec.rate);
1503 1491
1504 codecs[0] = kOpusCodec; 1492 parameters.codecs[0] = kOpusCodec;
1505 codecs[0].bitrate = 0; // bitrate == default 1493 parameters.codecs[0].bitrate = 0; // bitrate == default
1506 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1494 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1507 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1495 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1508 EXPECT_EQ(111, gcodec.pltype); 1496 EXPECT_EQ(111, gcodec.pltype);
1509 EXPECT_STREQ("opus", gcodec.plname); 1497 EXPECT_STREQ("opus", gcodec.plname);
1510 EXPECT_EQ(32000, gcodec.rate); 1498 EXPECT_EQ(32000, gcodec.rate);
1511 } 1499 }
1512 1500
1513 // Test that we could set packet size specified in kCodecParamPTime. 1501 // Test that we could set packet size specified in kCodecParamPTime.
1514 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { 1502 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) {
1515 EXPECT_TRUE(SetupEngine()); 1503 EXPECT_TRUE(SetupEngine());
1516 int channel_num = voe_.GetLastChannel(); 1504 int channel_num = voe_.GetLastChannel();
1517 std::vector<cricket::AudioCodec> codecs; 1505 cricket::AudioSendParameters parameters;
1518 codecs.push_back(kOpusCodec); 1506 parameters.codecs.push_back(kOpusCodec);
1519 codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Value within range. 1507 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range.
1520 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1508 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1521 webrtc::CodecInst gcodec; 1509 webrtc::CodecInst gcodec;
1522 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1510 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1523 EXPECT_EQ(1920, gcodec.pacsize); // Opus gets 40ms. 1511 EXPECT_EQ(1920, gcodec.pacsize); // Opus gets 40ms.
1524 1512
1525 codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Value below range. 1513 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Below range.
1526 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1514 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1527 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1515 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1528 EXPECT_EQ(480, gcodec.pacsize); // Opus gets 10ms. 1516 EXPECT_EQ(480, gcodec.pacsize); // Opus gets 10ms.
1529 1517
1530 codecs[0].SetParam(cricket::kCodecParamPTime, 80); // Value beyond range. 1518 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 80); // Beyond range.
1531 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1519 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1532 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1520 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1533 EXPECT_EQ(2880, gcodec.pacsize); // Opus gets 60ms. 1521 EXPECT_EQ(2880, gcodec.pacsize); // Opus gets 60ms.
1534 1522
1535 codecs[0] = kIsacCodec; // Also try Isac, and with unsupported size. 1523 parameters.codecs[0] = kIsacCodec; // Also try Isac, with unsupported size.
1536 codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Value within range. 1524 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range.
1537 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1525 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1538 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1526 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1539 EXPECT_EQ(480, gcodec.pacsize); // Isac gets 30ms as the next smallest value. 1527 EXPECT_EQ(480, gcodec.pacsize); // Isac gets 30ms as the next smallest value.
1540 1528
1541 codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP. 1529 parameters.codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP.
1542 codecs[0].SetParam(cricket::kCodecParamPTime, 40); 1530 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40);
1543 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1531 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1544 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1532 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1545 EXPECT_EQ(640, gcodec.pacsize); // G722 gets 40ms @16kHz as defined in VoE. 1533 EXPECT_EQ(640, gcodec.pacsize); // G722 gets 40ms @16kHz as defined in VoE.
1546 } 1534 }
1547 1535
1548 // Test that we fail if no codecs are specified. 1536 // Test that we fail if no codecs are specified.
1549 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { 1537 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) {
1550 EXPECT_TRUE(SetupEngine()); 1538 EXPECT_TRUE(SetupEngine());
1551 std::vector<cricket::AudioCodec> codecs; 1539 cricket::AudioSendParameters parameters;
1552 EXPECT_FALSE(channel_->SetSendCodecs(codecs)); 1540 EXPECT_FALSE(channel_->SetSendParameters(parameters));
1553 } 1541 }
1554 1542
1555 // Test that we can set send codecs even with telephone-event codec as the first 1543 // Test that we can set send codecs even with telephone-event codec as the first
1556 // one on the list. 1544 // one on the list.
1557 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { 1545 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) {
1558 EXPECT_TRUE(SetupEngine()); 1546 EXPECT_TRUE(SetupEngine());
1559 int channel_num = voe_.GetLastChannel(); 1547 int channel_num = voe_.GetLastChannel();
1560 std::vector<cricket::AudioCodec> codecs; 1548 cricket::AudioSendParameters parameters;
1561 codecs.push_back(kTelephoneEventCodec); 1549 parameters.codecs.push_back(kTelephoneEventCodec);
1562 codecs.push_back(kIsacCodec); 1550 parameters.codecs.push_back(kIsacCodec);
1563 codecs.push_back(kPcmuCodec); 1551 parameters.codecs.push_back(kPcmuCodec);
1564 codecs[0].id = 98; // DTMF 1552 parameters.codecs[0].id = 98; // DTMF
1565 codecs[1].id = 96; 1553 parameters.codecs[1].id = 96;
1566 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1554 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1567 webrtc::CodecInst gcodec; 1555 webrtc::CodecInst gcodec;
1568 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1556 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1569 EXPECT_EQ(96, gcodec.pltype); 1557 EXPECT_EQ(96, gcodec.pltype);
1570 EXPECT_STREQ("ISAC", gcodec.plname); 1558 EXPECT_STREQ("ISAC", gcodec.plname);
1571 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); 1559 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num));
1572 } 1560 }
1573 1561
1574 // Test that we can set send codecs even with CN codec as the first 1562 // Test that we can set send codecs even with CN codec as the first
1575 // one on the list. 1563 // one on the list.
1576 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { 1564 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) {
1577 EXPECT_TRUE(SetupEngine()); 1565 EXPECT_TRUE(SetupEngine());
1578 int channel_num = voe_.GetLastChannel(); 1566 int channel_num = voe_.GetLastChannel();
1579 std::vector<cricket::AudioCodec> codecs; 1567 cricket::AudioSendParameters parameters;
1580 codecs.push_back(kCn16000Codec); 1568 parameters.codecs.push_back(kCn16000Codec);
1581 codecs.push_back(kIsacCodec); 1569 parameters.codecs.push_back(kIsacCodec);
1582 codecs.push_back(kPcmuCodec); 1570 parameters.codecs.push_back(kPcmuCodec);
1583 codecs[0].id = 98; // wideband CN 1571 parameters.codecs[0].id = 98; // wideband CN
1584 codecs[1].id = 96; 1572 parameters.codecs[1].id = 96;
1585 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1573 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1586 webrtc::CodecInst gcodec; 1574 webrtc::CodecInst gcodec;
1587 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1575 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1588 EXPECT_EQ(96, gcodec.pltype); 1576 EXPECT_EQ(96, gcodec.pltype);
1589 EXPECT_STREQ("ISAC", gcodec.plname); 1577 EXPECT_STREQ("ISAC", gcodec.plname);
1590 EXPECT_EQ(98, voe_.GetSendCNPayloadType(channel_num, true)); 1578 EXPECT_EQ(98, voe_.GetSendCNPayloadType(channel_num, true));
1591 } 1579 }
1592 1580
1593 // Test that we set VAD and DTMF types correctly as caller. 1581 // Test that we set VAD and DTMF types correctly as caller.
1594 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { 1582 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) {
1595 EXPECT_TRUE(SetupEngine()); 1583 EXPECT_TRUE(SetupEngine());
1596 int channel_num = voe_.GetLastChannel(); 1584 int channel_num = voe_.GetLastChannel();
1597 std::vector<cricket::AudioCodec> codecs; 1585 cricket::AudioSendParameters parameters;
1598 codecs.push_back(kIsacCodec); 1586 parameters.codecs.push_back(kIsacCodec);
1599 codecs.push_back(kPcmuCodec); 1587 parameters.codecs.push_back(kPcmuCodec);
1600 // TODO(juberti): cn 32000 1588 // TODO(juberti): cn 32000
1601 codecs.push_back(kCn16000Codec); 1589 parameters.codecs.push_back(kCn16000Codec);
1602 codecs.push_back(kCn8000Codec); 1590 parameters.codecs.push_back(kCn8000Codec);
1603 codecs.push_back(kTelephoneEventCodec); 1591 parameters.codecs.push_back(kTelephoneEventCodec);
1604 codecs.push_back(kRedCodec); 1592 parameters.codecs.push_back(kRedCodec);
1605 codecs[0].id = 96; 1593 parameters.codecs[0].id = 96;
1606 codecs[2].id = 97; // wideband CN 1594 parameters.codecs[2].id = 97; // wideband CN
1607 codecs[4].id = 98; // DTMF 1595 parameters.codecs[4].id = 98; // DTMF
1608 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1596 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1609 webrtc::CodecInst gcodec; 1597 webrtc::CodecInst gcodec;
1610 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1598 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1611 EXPECT_EQ(96, gcodec.pltype); 1599 EXPECT_EQ(96, gcodec.pltype);
1612 EXPECT_STREQ("ISAC", gcodec.plname); 1600 EXPECT_STREQ("ISAC", gcodec.plname);
1613 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1601 EXPECT_TRUE(voe_.GetVAD(channel_num));
1614 EXPECT_FALSE(voe_.GetRED(channel_num)); 1602 EXPECT_FALSE(voe_.GetRED(channel_num));
1615 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 1603 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
1616 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1604 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1617 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); 1605 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num));
1618 } 1606 }
1619 1607
1620 // Test that we set VAD and DTMF types correctly as callee. 1608 // Test that we set VAD and DTMF types correctly as callee.
1621 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { 1609 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
1622 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 1610 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
1623 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 1611 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
1624 EXPECT_TRUE(channel_ != nullptr); 1612 EXPECT_TRUE(channel_ != nullptr);
1625 1613
1626 int channel_num = voe_.GetLastChannel(); 1614 int channel_num = voe_.GetLastChannel();
1627 std::vector<cricket::AudioCodec> codecs; 1615 cricket::AudioSendParameters parameters;
1628 codecs.push_back(kIsacCodec); 1616 parameters.codecs.push_back(kIsacCodec);
1629 codecs.push_back(kPcmuCodec); 1617 parameters.codecs.push_back(kPcmuCodec);
1630 // TODO(juberti): cn 32000 1618 // TODO(juberti): cn 32000
1631 codecs.push_back(kCn16000Codec); 1619 parameters.codecs.push_back(kCn16000Codec);
1632 codecs.push_back(kCn8000Codec); 1620 parameters.codecs.push_back(kCn8000Codec);
1633 codecs.push_back(kTelephoneEventCodec); 1621 parameters.codecs.push_back(kTelephoneEventCodec);
1634 codecs.push_back(kRedCodec); 1622 parameters.codecs.push_back(kRedCodec);
1635 codecs[0].id = 96; 1623 parameters.codecs[0].id = 96;
1636 codecs[2].id = 97; // wideband CN 1624 parameters.codecs[2].id = 97; // wideband CN
1637 codecs[4].id = 98; // DTMF 1625 parameters.codecs[4].id = 98; // DTMF
1638 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1626 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1639 EXPECT_TRUE(channel_->AddSendStream( 1627 EXPECT_TRUE(channel_->AddSendStream(
1640 cricket::StreamParams::CreateLegacy(kSsrc1))); 1628 cricket::StreamParams::CreateLegacy(kSsrc1)));
1641 1629
1642 webrtc::CodecInst gcodec; 1630 webrtc::CodecInst gcodec;
1643 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1631 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1644 EXPECT_EQ(96, gcodec.pltype); 1632 EXPECT_EQ(96, gcodec.pltype);
1645 EXPECT_STREQ("ISAC", gcodec.plname); 1633 EXPECT_STREQ("ISAC", gcodec.plname);
1646 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1634 EXPECT_TRUE(voe_.GetVAD(channel_num));
1647 EXPECT_FALSE(voe_.GetRED(channel_num)); 1635 EXPECT_FALSE(voe_.GetRED(channel_num));
1648 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 1636 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
1649 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1637 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1650 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); 1638 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num));
1651 } 1639 }
1652 1640
1653 // Test that we only apply VAD if we have a CN codec that matches the 1641 // Test that we only apply VAD if we have a CN codec that matches the
1654 // send codec clockrate. 1642 // send codec clockrate.
1655 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { 1643 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) {
1656 EXPECT_TRUE(SetupEngine()); 1644 EXPECT_TRUE(SetupEngine());
1657 int channel_num = voe_.GetLastChannel(); 1645 int channel_num = voe_.GetLastChannel();
1658 std::vector<cricket::AudioCodec> codecs; 1646 cricket::AudioSendParameters parameters;
1659 // Set ISAC(16K) and CN(16K). VAD should be activated. 1647 // Set ISAC(16K) and CN(16K). VAD should be activated.
1660 codecs.push_back(kIsacCodec); 1648 parameters.codecs.push_back(kIsacCodec);
1661 codecs.push_back(kCn16000Codec); 1649 parameters.codecs.push_back(kCn16000Codec);
1662 codecs[1].id = 97; 1650 parameters.codecs[1].id = 97;
1663 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1651 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1664 webrtc::CodecInst gcodec; 1652 webrtc::CodecInst gcodec;
1665 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1653 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1666 EXPECT_STREQ("ISAC", gcodec.plname); 1654 EXPECT_STREQ("ISAC", gcodec.plname);
1667 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1655 EXPECT_TRUE(voe_.GetVAD(channel_num));
1668 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1656 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1669 // Set PCMU(8K) and CN(16K). VAD should not be activated. 1657 // Set PCMU(8K) and CN(16K). VAD should not be activated.
1670 codecs[0] = kPcmuCodec; 1658 parameters.codecs[0] = kPcmuCodec;
1671 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1659 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1672 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1660 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1673 EXPECT_STREQ("PCMU", gcodec.plname); 1661 EXPECT_STREQ("PCMU", gcodec.plname);
1674 EXPECT_FALSE(voe_.GetVAD(channel_num)); 1662 EXPECT_FALSE(voe_.GetVAD(channel_num));
1675 // Set PCMU(8K) and CN(8K). VAD should be activated. 1663 // Set PCMU(8K) and CN(8K). VAD should be activated.
1676 codecs[1] = kCn8000Codec; 1664 parameters.codecs[1] = kCn8000Codec;
1677 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1665 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1678 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1666 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1679 EXPECT_STREQ("PCMU", gcodec.plname); 1667 EXPECT_STREQ("PCMU", gcodec.plname);
1680 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1668 EXPECT_TRUE(voe_.GetVAD(channel_num));
1681 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 1669 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
1682 // Set ISAC(16K) and CN(8K). VAD should not be activated. 1670 // Set ISAC(16K) and CN(8K). VAD should not be activated.
1683 codecs[0] = kIsacCodec; 1671 parameters.codecs[0] = kIsacCodec;
1684 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1672 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1685 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1673 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1686 EXPECT_STREQ("ISAC", gcodec.plname); 1674 EXPECT_STREQ("ISAC", gcodec.plname);
1687 EXPECT_FALSE(voe_.GetVAD(channel_num)); 1675 EXPECT_FALSE(voe_.GetVAD(channel_num));
1688 } 1676 }
1689 1677
1690 // Test that we perform case-insensitive matching of codec names. 1678 // Test that we perform case-insensitive matching of codec names.
1691 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { 1679 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) {
1692 EXPECT_TRUE(SetupEngine()); 1680 EXPECT_TRUE(SetupEngine());
1693 int channel_num = voe_.GetLastChannel(); 1681 int channel_num = voe_.GetLastChannel();
1694 std::vector<cricket::AudioCodec> codecs; 1682 cricket::AudioSendParameters parameters;
1695 codecs.push_back(kIsacCodec); 1683 parameters.codecs.push_back(kIsacCodec);
1696 codecs.push_back(kPcmuCodec); 1684 parameters.codecs.push_back(kPcmuCodec);
1697 codecs.push_back(kCn16000Codec); 1685 parameters.codecs.push_back(kCn16000Codec);
1698 codecs.push_back(kCn8000Codec); 1686 parameters.codecs.push_back(kCn8000Codec);
1699 codecs.push_back(kTelephoneEventCodec); 1687 parameters.codecs.push_back(kTelephoneEventCodec);
1700 codecs.push_back(kRedCodec); 1688 parameters.codecs.push_back(kRedCodec);
1701 codecs[0].name = "iSaC"; 1689 parameters.codecs[0].name = "iSaC";
1702 codecs[0].id = 96; 1690 parameters.codecs[0].id = 96;
1703 codecs[2].id = 97; // wideband CN 1691 parameters.codecs[2].id = 97; // wideband CN
1704 codecs[4].id = 98; // DTMF 1692 parameters.codecs[4].id = 98; // DTMF
1705 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1693 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1706 webrtc::CodecInst gcodec; 1694 webrtc::CodecInst gcodec;
1707 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1695 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1708 EXPECT_EQ(96, gcodec.pltype); 1696 EXPECT_EQ(96, gcodec.pltype);
1709 EXPECT_STREQ("ISAC", gcodec.plname); 1697 EXPECT_STREQ("ISAC", gcodec.plname);
1710 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1698 EXPECT_TRUE(voe_.GetVAD(channel_num));
1711 EXPECT_FALSE(voe_.GetRED(channel_num)); 1699 EXPECT_FALSE(voe_.GetRED(channel_num));
1712 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 1700 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
1713 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1701 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1714 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); 1702 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num));
1715 } 1703 }
1716 1704
1717 // Test that we set up RED correctly as caller. 1705 // Test that we set up RED correctly as caller.
1718 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) { 1706 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) {
1719 EXPECT_TRUE(SetupEngine()); 1707 EXPECT_TRUE(SetupEngine());
1720 int channel_num = voe_.GetLastChannel(); 1708 int channel_num = voe_.GetLastChannel();
1721 std::vector<cricket::AudioCodec> codecs; 1709 cricket::AudioSendParameters parameters;
1722 codecs.push_back(kRedCodec); 1710 parameters.codecs.push_back(kRedCodec);
1723 codecs.push_back(kIsacCodec); 1711 parameters.codecs.push_back(kIsacCodec);
1724 codecs.push_back(kPcmuCodec); 1712 parameters.codecs.push_back(kPcmuCodec);
1725 codecs[0].id = 127; 1713 parameters.codecs[0].id = 127;
1726 codecs[0].params[""] = "96/96"; 1714 parameters.codecs[0].params[""] = "96/96";
1727 codecs[1].id = 96; 1715 parameters.codecs[1].id = 96;
1728 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1716 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1729 webrtc::CodecInst gcodec; 1717 webrtc::CodecInst gcodec;
1730 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1718 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1731 EXPECT_EQ(96, gcodec.pltype); 1719 EXPECT_EQ(96, gcodec.pltype);
1732 EXPECT_STREQ("ISAC", gcodec.plname); 1720 EXPECT_STREQ("ISAC", gcodec.plname);
1733 EXPECT_TRUE(voe_.GetRED(channel_num)); 1721 EXPECT_TRUE(voe_.GetRED(channel_num));
1734 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); 1722 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
1735 } 1723 }
1736 1724
1737 // Test that we set up RED correctly as callee. 1725 // Test that we set up RED correctly as callee.
1738 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) { 1726 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) {
1739 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 1727 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
1740 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 1728 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
1741 EXPECT_TRUE(channel_ != nullptr); 1729 EXPECT_TRUE(channel_ != nullptr);
1742 1730
1743 int channel_num = voe_.GetLastChannel(); 1731 int channel_num = voe_.GetLastChannel();
1744 std::vector<cricket::AudioCodec> codecs; 1732 cricket::AudioSendParameters parameters;
1745 codecs.push_back(kRedCodec); 1733 parameters.codecs.push_back(kRedCodec);
1746 codecs.push_back(kIsacCodec); 1734 parameters.codecs.push_back(kIsacCodec);
1747 codecs.push_back(kPcmuCodec); 1735 parameters.codecs.push_back(kPcmuCodec);
1748 codecs[0].id = 127; 1736 parameters.codecs[0].id = 127;
1749 codecs[0].params[""] = "96/96"; 1737 parameters.codecs[0].params[""] = "96/96";
1750 codecs[1].id = 96; 1738 parameters.codecs[1].id = 96;
1751 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1739 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1752 EXPECT_TRUE(channel_->AddSendStream( 1740 EXPECT_TRUE(channel_->AddSendStream(
1753 cricket::StreamParams::CreateLegacy(kSsrc1))); 1741 cricket::StreamParams::CreateLegacy(kSsrc1)));
1754 webrtc::CodecInst gcodec; 1742 webrtc::CodecInst gcodec;
1755 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1743 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1756 EXPECT_EQ(96, gcodec.pltype); 1744 EXPECT_EQ(96, gcodec.pltype);
1757 EXPECT_STREQ("ISAC", gcodec.plname); 1745 EXPECT_STREQ("ISAC", gcodec.plname);
1758 EXPECT_TRUE(voe_.GetRED(channel_num)); 1746 EXPECT_TRUE(voe_.GetRED(channel_num));
1759 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); 1747 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
1760 } 1748 }
1761 1749
1762 // Test that we set up RED correctly if params are omitted. 1750 // Test that we set up RED correctly if params are omitted.
1763 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { 1751 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) {
1764 EXPECT_TRUE(SetupEngine()); 1752 EXPECT_TRUE(SetupEngine());
1765 int channel_num = voe_.GetLastChannel(); 1753 int channel_num = voe_.GetLastChannel();
1766 std::vector<cricket::AudioCodec> codecs; 1754 cricket::AudioSendParameters parameters;
1767 codecs.push_back(kRedCodec); 1755 parameters.codecs.push_back(kRedCodec);
1768 codecs.push_back(kIsacCodec); 1756 parameters.codecs.push_back(kIsacCodec);
1769 codecs.push_back(kPcmuCodec); 1757 parameters.codecs.push_back(kPcmuCodec);
1770 codecs[0].id = 127; 1758 parameters.codecs[0].id = 127;
1771 codecs[1].id = 96; 1759 parameters.codecs[1].id = 96;
1772 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1760 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1773 webrtc::CodecInst gcodec; 1761 webrtc::CodecInst gcodec;
1774 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1762 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1775 EXPECT_EQ(96, gcodec.pltype); 1763 EXPECT_EQ(96, gcodec.pltype);
1776 EXPECT_STREQ("ISAC", gcodec.plname); 1764 EXPECT_STREQ("ISAC", gcodec.plname);
1777 EXPECT_TRUE(voe_.GetRED(channel_num)); 1765 EXPECT_TRUE(voe_.GetRED(channel_num));
1778 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); 1766 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
1779 } 1767 }
1780 1768
1781 // Test that we ignore RED if the parameters aren't named the way we expect. 1769 // Test that we ignore RED if the parameters aren't named the way we expect.
1782 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { 1770 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) {
1783 EXPECT_TRUE(SetupEngine()); 1771 EXPECT_TRUE(SetupEngine());
1784 int channel_num = voe_.GetLastChannel(); 1772 int channel_num = voe_.GetLastChannel();
1785 std::vector<cricket::AudioCodec> codecs; 1773 cricket::AudioSendParameters parameters;
1786 codecs.push_back(kRedCodec); 1774 parameters.codecs.push_back(kRedCodec);
1787 codecs.push_back(kIsacCodec); 1775 parameters.codecs.push_back(kIsacCodec);
1788 codecs.push_back(kPcmuCodec); 1776 parameters.codecs.push_back(kPcmuCodec);
1789 codecs[0].id = 127; 1777 parameters.codecs[0].id = 127;
1790 codecs[0].params["ABC"] = "96/96"; 1778 parameters.codecs[0].params["ABC"] = "96/96";
1791 codecs[1].id = 96; 1779 parameters.codecs[1].id = 96;
1792 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1780 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1793 webrtc::CodecInst gcodec; 1781 webrtc::CodecInst gcodec;
1794 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1782 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1795 EXPECT_EQ(96, gcodec.pltype); 1783 EXPECT_EQ(96, gcodec.pltype);
1796 EXPECT_STREQ("ISAC", gcodec.plname); 1784 EXPECT_STREQ("ISAC", gcodec.plname);
1797 EXPECT_FALSE(voe_.GetRED(channel_num)); 1785 EXPECT_FALSE(voe_.GetRED(channel_num));
1798 } 1786 }
1799 1787
1800 // Test that we ignore RED if it uses different primary/secondary encoding. 1788 // Test that we ignore RED if it uses different primary/secondary encoding.
1801 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { 1789 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) {
1802 EXPECT_TRUE(SetupEngine()); 1790 EXPECT_TRUE(SetupEngine());
1803 int channel_num = voe_.GetLastChannel(); 1791 int channel_num = voe_.GetLastChannel();
1804 std::vector<cricket::AudioCodec> codecs; 1792 cricket::AudioSendParameters parameters;
1805 codecs.push_back(kRedCodec); 1793 parameters.codecs.push_back(kRedCodec);
1806 codecs.push_back(kIsacCodec); 1794 parameters.codecs.push_back(kIsacCodec);
1807 codecs.push_back(kPcmuCodec); 1795 parameters.codecs.push_back(kPcmuCodec);
1808 codecs[0].id = 127; 1796 parameters.codecs[0].id = 127;
1809 codecs[0].params[""] = "96/0"; 1797 parameters.codecs[0].params[""] = "96/0";
1810 codecs[1].id = 96; 1798 parameters.codecs[1].id = 96;
1811 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1799 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1812 webrtc::CodecInst gcodec; 1800 webrtc::CodecInst gcodec;
1813 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1801 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1814 EXPECT_EQ(96, gcodec.pltype); 1802 EXPECT_EQ(96, gcodec.pltype);
1815 EXPECT_STREQ("ISAC", gcodec.plname); 1803 EXPECT_STREQ("ISAC", gcodec.plname);
1816 EXPECT_FALSE(voe_.GetRED(channel_num)); 1804 EXPECT_FALSE(voe_.GetRED(channel_num));
1817 } 1805 }
1818 1806
1819 // Test that we ignore RED if it uses more than 2 encodings. 1807 // Test that we ignore RED if it uses more than 2 encodings.
1820 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { 1808 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) {
1821 EXPECT_TRUE(SetupEngine()); 1809 EXPECT_TRUE(SetupEngine());
1822 int channel_num = voe_.GetLastChannel(); 1810 int channel_num = voe_.GetLastChannel();
1823 std::vector<cricket::AudioCodec> codecs; 1811 cricket::AudioSendParameters parameters;
1824 codecs.push_back(kRedCodec); 1812 parameters.codecs.push_back(kRedCodec);
1825 codecs.push_back(kIsacCodec); 1813 parameters.codecs.push_back(kIsacCodec);
1826 codecs.push_back(kPcmuCodec); 1814 parameters.codecs.push_back(kPcmuCodec);
1827 codecs[0].id = 127; 1815 parameters.codecs[0].id = 127;
1828 codecs[0].params[""] = "96/96/96"; 1816 parameters.codecs[0].params[""] = "96/96/96";
1829 codecs[1].id = 96; 1817 parameters.codecs[1].id = 96;
1830 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1818 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1831 webrtc::CodecInst gcodec; 1819 webrtc::CodecInst gcodec;
1832 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1820 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1833 EXPECT_EQ(96, gcodec.pltype); 1821 EXPECT_EQ(96, gcodec.pltype);
1834 EXPECT_STREQ("ISAC", gcodec.plname); 1822 EXPECT_STREQ("ISAC", gcodec.plname);
1835 EXPECT_FALSE(voe_.GetRED(channel_num)); 1823 EXPECT_FALSE(voe_.GetRED(channel_num));
1836 } 1824 }
1837 1825
1838 // Test that we ignore RED if it has bogus codec ids. 1826 // Test that we ignore RED if it has bogus codec ids.
1839 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { 1827 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) {
1840 EXPECT_TRUE(SetupEngine()); 1828 EXPECT_TRUE(SetupEngine());
1841 int channel_num = voe_.GetLastChannel(); 1829 int channel_num = voe_.GetLastChannel();
1842 std::vector<cricket::AudioCodec> codecs; 1830 cricket::AudioSendParameters parameters;
1843 codecs.push_back(kRedCodec); 1831 parameters.codecs.push_back(kRedCodec);
1844 codecs.push_back(kIsacCodec); 1832 parameters.codecs.push_back(kIsacCodec);
1845 codecs.push_back(kPcmuCodec); 1833 parameters.codecs.push_back(kPcmuCodec);
1846 codecs[0].id = 127; 1834 parameters.codecs[0].id = 127;
1847 codecs[0].params[""] = "ABC/ABC"; 1835 parameters.codecs[0].params[""] = "ABC/ABC";
1848 codecs[1].id = 96; 1836 parameters.codecs[1].id = 96;
1849 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1837 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1850 webrtc::CodecInst gcodec; 1838 webrtc::CodecInst gcodec;
1851 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1839 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1852 EXPECT_EQ(96, gcodec.pltype); 1840 EXPECT_EQ(96, gcodec.pltype);
1853 EXPECT_STREQ("ISAC", gcodec.plname); 1841 EXPECT_STREQ("ISAC", gcodec.plname);
1854 EXPECT_FALSE(voe_.GetRED(channel_num)); 1842 EXPECT_FALSE(voe_.GetRED(channel_num));
1855 } 1843 }
1856 1844
1857 // Test that we ignore RED if it refers to a codec that is not present. 1845 // Test that we ignore RED if it refers to a codec that is not present.
1858 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) { 1846 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) {
1859 EXPECT_TRUE(SetupEngine()); 1847 EXPECT_TRUE(SetupEngine());
1860 int channel_num = voe_.GetLastChannel(); 1848 int channel_num = voe_.GetLastChannel();
1861 std::vector<cricket::AudioCodec> codecs; 1849 cricket::AudioSendParameters parameters;
1862 codecs.push_back(kRedCodec); 1850 parameters.codecs.push_back(kRedCodec);
1863 codecs.push_back(kIsacCodec); 1851 parameters.codecs.push_back(kIsacCodec);
1864 codecs.push_back(kPcmuCodec); 1852 parameters.codecs.push_back(kPcmuCodec);
1865 codecs[0].id = 127; 1853 parameters.codecs[0].id = 127;
1866 codecs[0].params[""] = "97/97"; 1854 parameters.codecs[0].params[""] = "97/97";
1867 codecs[1].id = 96; 1855 parameters.codecs[1].id = 96;
1868 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1856 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1869 webrtc::CodecInst gcodec; 1857 webrtc::CodecInst gcodec;
1870 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1858 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1871 EXPECT_EQ(96, gcodec.pltype); 1859 EXPECT_EQ(96, gcodec.pltype);
1872 EXPECT_STREQ("ISAC", gcodec.plname); 1860 EXPECT_STREQ("ISAC", gcodec.plname);
1873 EXPECT_FALSE(voe_.GetRED(channel_num)); 1861 EXPECT_FALSE(voe_.GetRED(channel_num));
1874 } 1862 }
1875 1863
1876 // Test support for audio level header extension. 1864 // Test support for audio level header extension.
1877 TEST_F(WebRtcVoiceEngineTestFake, SendAudioLevelHeaderExtensions) { 1865 TEST_F(WebRtcVoiceEngineTestFake, SendAudioLevelHeaderExtensions) {
1878 TestSetSendRtpHeaderExtensions(kRtpAudioLevelHeaderExtension); 1866 TestSetSendRtpHeaderExtensions(kRtpAudioLevelHeaderExtension);
1879 } 1867 }
1880 TEST_F(WebRtcVoiceEngineTestFake, RecvAudioLevelHeaderExtensions) { 1868 TEST_F(WebRtcVoiceEngineTestFake, RecvAudioLevelHeaderExtensions) {
1881 TestSetRecvRtpHeaderExtensions(kRtpAudioLevelHeaderExtension); 1869 TestSetRecvRtpHeaderExtensions(kRtpAudioLevelHeaderExtension);
1882 } 1870 }
1883 1871
1884 // Test support for absolute send time header extension. 1872 // Test support for absolute send time header extension.
1885 TEST_F(WebRtcVoiceEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) { 1873 TEST_F(WebRtcVoiceEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) {
1886 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); 1874 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension);
1887 } 1875 }
1888 TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { 1876 TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) {
1889 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); 1877 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension);
1890 } 1878 }
1891 1879
1892 // Test that we can create a channel and start sending/playing out on it. 1880 // Test that we can create a channel and start sending/playing out on it.
1893 TEST_F(WebRtcVoiceEngineTestFake, SendAndPlayout) { 1881 TEST_F(WebRtcVoiceEngineTestFake, SendAndPlayout) {
1894 EXPECT_TRUE(SetupEngine()); 1882 EXPECT_TRUE(SetupEngine());
1895 int channel_num = voe_.GetLastChannel(); 1883 int channel_num = voe_.GetLastChannel();
1896 std::vector<cricket::AudioCodec> codecs; 1884 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1897 codecs.push_back(kPcmuCodec);
1898 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
1899 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 1885 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
1900 EXPECT_TRUE(voe_.GetSend(channel_num)); 1886 EXPECT_TRUE(voe_.GetSend(channel_num));
1901 EXPECT_TRUE(channel_->SetPlayout(true)); 1887 EXPECT_TRUE(channel_->SetPlayout(true));
1902 EXPECT_TRUE(voe_.GetPlayout(channel_num)); 1888 EXPECT_TRUE(voe_.GetPlayout(channel_num));
1903 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); 1889 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING));
1904 EXPECT_FALSE(voe_.GetSend(channel_num)); 1890 EXPECT_FALSE(voe_.GetSend(channel_num));
1905 EXPECT_TRUE(channel_->SetPlayout(false)); 1891 EXPECT_TRUE(channel_->SetPlayout(false));
1906 EXPECT_FALSE(voe_.GetPlayout(channel_num)); 1892 EXPECT_FALSE(voe_.GetPlayout(channel_num));
1907 } 1893 }
1908 1894
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { 1931 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) {
1946 SetupForMultiSendStream(); 1932 SetupForMultiSendStream();
1947 1933
1948 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; 1934 static const uint32 kSsrcs4[] = {1, 2, 3, 4};
1949 // Create send streams. 1935 // Create send streams.
1950 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 1936 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
1951 EXPECT_TRUE(channel_->AddSendStream( 1937 EXPECT_TRUE(channel_->AddSendStream(
1952 cricket::StreamParams::CreateLegacy(kSsrcs4[i]))); 1938 cricket::StreamParams::CreateLegacy(kSsrcs4[i])));
1953 } 1939 }
1954 1940
1955 std::vector<cricket::AudioCodec> codecs; 1941 cricket::AudioSendParameters parameters;
1956 // Set ISAC(16K) and CN(16K). VAD should be activated. 1942 // Set ISAC(16K) and CN(16K). VAD should be activated.
1957 codecs.push_back(kIsacCodec); 1943 parameters.codecs.push_back(kIsacCodec);
1958 codecs.push_back(kCn16000Codec); 1944 parameters.codecs.push_back(kCn16000Codec);
1959 codecs[1].id = 97; 1945 parameters.codecs[1].id = 97;
1960 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1946 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1961 1947
1962 // Verify ISAC and VAD are corrected configured on all send channels. 1948 // Verify ISAC and VAD are corrected configured on all send channels.
1963 webrtc::CodecInst gcodec; 1949 webrtc::CodecInst gcodec;
1964 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 1950 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
1965 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]); 1951 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]);
1966 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1952 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1967 EXPECT_STREQ("ISAC", gcodec.plname); 1953 EXPECT_STREQ("ISAC", gcodec.plname);
1968 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1954 EXPECT_TRUE(voe_.GetVAD(channel_num));
1969 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1955 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1970 } 1956 }
1971 1957
1972 // Change to PCMU(8K) and CN(16K). VAD should not be activated. 1958 // Change to PCMU(8K) and CN(16K). VAD should not be activated.
1973 codecs[0] = kPcmuCodec; 1959 parameters.codecs[0] = kPcmuCodec;
1974 EXPECT_TRUE(channel_->SetSendCodecs(codecs)); 1960 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1975 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 1961 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
1976 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]); 1962 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]);
1977 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1963 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1978 EXPECT_STREQ("PCMU", gcodec.plname); 1964 EXPECT_STREQ("PCMU", gcodec.plname);
1979 EXPECT_FALSE(voe_.GetVAD(channel_num)); 1965 EXPECT_FALSE(voe_.GetVAD(channel_num));
1980 } 1966 }
1981 } 1967 }
1982 1968
1983 // Test we can SetSend on all send streams correctly. 1969 // Test we can SetSend on all send streams correctly.
1984 TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) { 1970 TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 // Create send streams. 2004 // Create send streams.
2019 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 2005 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
2020 EXPECT_TRUE(channel_->AddSendStream( 2006 EXPECT_TRUE(channel_->AddSendStream(
2021 cricket::StreamParams::CreateLegacy(kSsrcs4[i]))); 2007 cricket::StreamParams::CreateLegacy(kSsrcs4[i])));
2022 } 2008 }
2023 // Create a receive stream to check that none of the send streams end up in 2009 // Create a receive stream to check that none of the send streams end up in
2024 // the receive stream stats. 2010 // the receive stream stats.
2025 EXPECT_TRUE(channel_->AddRecvStream( 2011 EXPECT_TRUE(channel_->AddRecvStream(
2026 cricket::StreamParams::CreateLegacy(kSsrc2))); 2012 cricket::StreamParams::CreateLegacy(kSsrc2)));
2027 // We need send codec to be set to get all stats. 2013 // We need send codec to be set to get all stats.
2028 std::vector<cricket::AudioCodec> codecs; 2014 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2029 codecs.push_back(kPcmuCodec); 2015 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
2030 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2031 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
2032 2016
2033 cricket::VoiceMediaInfo info; 2017 cricket::VoiceMediaInfo info;
2034 EXPECT_EQ(true, channel_->GetStats(&info)); 2018 EXPECT_EQ(true, channel_->GetStats(&info));
2035 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); 2019 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size());
2036 2020
2037 // Verify the statistic information is correct. 2021 // Verify the statistic information is correct.
2038 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { 2022 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) {
2039 EXPECT_EQ(kSsrcs4[i], info.senders[i].ssrc()); 2023 EXPECT_EQ(kSsrcs4[i], info.senders[i].ssrc());
2040 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); 2024 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name);
2041 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent); 2025 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent);
(...skipping 30 matching lines...) Expand all
2072 info.receivers[0].preemptive_expand_rate); 2056 info.receivers[0].preemptive_expand_rate);
2073 } 2057 }
2074 2058
2075 // Test that we can add and remove receive streams, and do proper send/playout. 2059 // Test that we can add and remove receive streams, and do proper send/playout.
2076 // We can receive on multiple streams while sending one stream. 2060 // We can receive on multiple streams while sending one stream.
2077 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { 2061 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) {
2078 EXPECT_TRUE(SetupEngine()); 2062 EXPECT_TRUE(SetupEngine());
2079 int channel_num1 = voe_.GetLastChannel(); 2063 int channel_num1 = voe_.GetLastChannel();
2080 2064
2081 // Start playout on the default channel. 2065 // Start playout on the default channel.
2082 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2066 send_parameters_.options = options_conference_;
2067 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2083 EXPECT_TRUE(channel_->SetPlayout(true)); 2068 EXPECT_TRUE(channel_->SetPlayout(true));
2084 EXPECT_TRUE(voe_.GetPlayout(channel_num1)); 2069 EXPECT_TRUE(voe_.GetPlayout(channel_num1));
2085 2070
2086 // Adding another stream should disable playout on the default channel. 2071 // Adding another stream should disable playout on the default channel.
2087 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2072 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2088 int channel_num2 = voe_.GetLastChannel(); 2073 int channel_num2 = voe_.GetLastChannel();
2089 std::vector<cricket::AudioCodec> codecs;
2090 codecs.push_back(kPcmuCodec);
2091 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2092 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2074 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
2093 EXPECT_TRUE(voe_.GetSend(channel_num1)); 2075 EXPECT_TRUE(voe_.GetSend(channel_num1));
2094 EXPECT_FALSE(voe_.GetSend(channel_num2)); 2076 EXPECT_FALSE(voe_.GetSend(channel_num2));
2095 2077
2096 // Make sure only the new channel is played out. 2078 // Make sure only the new channel is played out.
2097 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); 2079 EXPECT_FALSE(voe_.GetPlayout(channel_num1));
2098 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); 2080 EXPECT_TRUE(voe_.GetPlayout(channel_num2));
2099 2081
2100 // Adding yet another stream should have stream 2 and 3 enabled for playout. 2082 // Adding yet another stream should have stream 2 and 3 enabled for playout.
2101 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 2083 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
(...skipping 26 matching lines...) Expand all
2128 EXPECT_TRUE(channel_->RemoveRecvStream(3)); 2110 EXPECT_TRUE(channel_->RemoveRecvStream(3));
2129 EXPECT_TRUE(channel_->RemoveRecvStream(2)); 2111 EXPECT_TRUE(channel_->RemoveRecvStream(2));
2130 2112
2131 EXPECT_TRUE(voe_.GetPlayout(channel_num1)); 2113 EXPECT_TRUE(voe_.GetPlayout(channel_num1));
2132 } 2114 }
2133 2115
2134 // Test that we can set the devices to use. 2116 // Test that we can set the devices to use.
2135 TEST_F(WebRtcVoiceEngineTestFake, SetDevices) { 2117 TEST_F(WebRtcVoiceEngineTestFake, SetDevices) {
2136 EXPECT_TRUE(SetupEngine()); 2118 EXPECT_TRUE(SetupEngine());
2137 int channel_num = voe_.GetLastChannel(); 2119 int channel_num = voe_.GetLastChannel();
2138 std::vector<cricket::AudioCodec> codecs; 2120 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2139 codecs.push_back(kPcmuCodec);
2140 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2141 2121
2142 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, 2122 cricket::Device default_dev(cricket::kFakeDefaultDeviceName,
2143 cricket::kFakeDefaultDeviceId); 2123 cricket::kFakeDefaultDeviceId);
2144 cricket::Device dev(cricket::kFakeDeviceName, 2124 cricket::Device dev(cricket::kFakeDeviceName,
2145 cricket::kFakeDeviceId); 2125 cricket::kFakeDeviceId);
2146 2126
2147 // Test SetDevices() while not sending or playing. 2127 // Test SetDevices() while not sending or playing.
2148 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); 2128 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev));
2149 2129
2150 // Test SetDevices() while sending and playing. 2130 // Test SetDevices() while sending and playing.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 EXPECT_TRUE(voe_.GetRecordingMicrophone()); 2162 EXPECT_TRUE(voe_.GetRecordingMicrophone());
2183 EXPECT_TRUE(voe_.GetSend(channel_num)); 2163 EXPECT_TRUE(voe_.GetSend(channel_num));
2184 EXPECT_TRUE(voe_.GetPlayout(channel_num)); 2164 EXPECT_TRUE(voe_.GetPlayout(channel_num));
2185 } 2165 }
2186 2166
2187 // Test that we can set the devices to use even if we failed to 2167 // Test that we can set the devices to use even if we failed to
2188 // open the initial ones. 2168 // open the initial ones.
2189 TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) { 2169 TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) {
2190 EXPECT_TRUE(SetupEngine()); 2170 EXPECT_TRUE(SetupEngine());
2191 int channel_num = voe_.GetLastChannel(); 2171 int channel_num = voe_.GetLastChannel();
2192 std::vector<cricket::AudioCodec> codecs; 2172 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2193 codecs.push_back(kPcmuCodec);
2194 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2195 2173
2196 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, 2174 cricket::Device default_dev(cricket::kFakeDefaultDeviceName,
2197 cricket::kFakeDefaultDeviceId); 2175 cricket::kFakeDefaultDeviceId);
2198 cricket::Device dev(cricket::kFakeDeviceName, 2176 cricket::Device dev(cricket::kFakeDeviceName,
2199 cricket::kFakeDeviceId); 2177 cricket::kFakeDeviceId);
2200 2178
2201 // Test that failure to open devices selected before starting 2179 // Test that failure to open devices selected before starting
2202 // send/play does not prevent opening newly selected ones after that. 2180 // send/play does not prevent opening newly selected ones after that.
2203 voe_.set_fail_start_recording_microphone(true); 2181 voe_.set_fail_start_recording_microphone(true);
2204 voe_.set_playout_fail_channel(channel_num); 2182 voe_.set_playout_fail_channel(channel_num);
(...skipping 17 matching lines...) Expand all
2222 EXPECT_TRUE(voe_.GetRecordingMicrophone()); 2200 EXPECT_TRUE(voe_.GetRecordingMicrophone());
2223 EXPECT_TRUE(voe_.GetSend(channel_num)); 2201 EXPECT_TRUE(voe_.GetSend(channel_num));
2224 EXPECT_TRUE(voe_.GetPlayout(channel_num)); 2202 EXPECT_TRUE(voe_.GetPlayout(channel_num));
2225 } 2203 }
2226 2204
2227 // Test that we can create a channel configured for multi-point conferences, 2205 // Test that we can create a channel configured for multi-point conferences,
2228 // and start sending/playing out on it. 2206 // and start sending/playing out on it.
2229 TEST_F(WebRtcVoiceEngineTestFake, ConferenceSendAndPlayout) { 2207 TEST_F(WebRtcVoiceEngineTestFake, ConferenceSendAndPlayout) {
2230 EXPECT_TRUE(SetupEngine()); 2208 EXPECT_TRUE(SetupEngine());
2231 int channel_num = voe_.GetLastChannel(); 2209 int channel_num = voe_.GetLastChannel();
2232 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2210 send_parameters_.options = options_conference_;
2233 std::vector<cricket::AudioCodec> codecs; 2211 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2234 codecs.push_back(kPcmuCodec);
2235 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2236 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2212 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
2237 EXPECT_TRUE(voe_.GetSend(channel_num)); 2213 EXPECT_TRUE(voe_.GetSend(channel_num));
2238 } 2214 }
2239 2215
2240 // Test that we can create a channel configured for Codian bridges, 2216 // Test that we can create a channel configured for Codian bridges,
2241 // and start sending/playing out on it. 2217 // and start sending/playing out on it.
2242 TEST_F(WebRtcVoiceEngineTestFake, CodianSendAndPlayout) { 2218 TEST_F(WebRtcVoiceEngineTestFake, CodianSendAndPlayout) {
2243 EXPECT_TRUE(SetupEngine()); 2219 EXPECT_TRUE(SetupEngine());
2244 int channel_num = voe_.GetLastChannel(); 2220 int channel_num = voe_.GetLastChannel();
2245 webrtc::AgcConfig agc_config; 2221 webrtc::AgcConfig agc_config;
2246 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2222 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2247 EXPECT_EQ(0, agc_config.targetLeveldBOv); 2223 EXPECT_EQ(0, agc_config.targetLeveldBOv);
2248 EXPECT_TRUE(channel_->SetOptions(options_adjust_agc_)); 2224 send_parameters_.options = options_adjust_agc_;
2249 std::vector<cricket::AudioCodec> codecs; 2225 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2250 codecs.push_back(kPcmuCodec);
2251 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2252 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2226 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
2253 EXPECT_TRUE(voe_.GetSend(channel_num)); 2227 EXPECT_TRUE(voe_.GetSend(channel_num));
2254 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2228 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2255 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated 2229 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated
2256 EXPECT_TRUE(channel_->SetPlayout(true)); 2230 EXPECT_TRUE(channel_->SetPlayout(true));
2257 EXPECT_TRUE(voe_.GetPlayout(channel_num)); 2231 EXPECT_TRUE(voe_.GetPlayout(channel_num));
2258 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); 2232 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING));
2259 EXPECT_FALSE(voe_.GetSend(channel_num)); 2233 EXPECT_FALSE(voe_.GetSend(channel_num));
2260 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2234 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2261 EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored 2235 EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored
(...skipping 24 matching lines...) Expand all
2286 options.adjust_agc_delta.Set(-10); 2260 options.adjust_agc_delta.Set(-10);
2287 EXPECT_TRUE(engine_.SetOptions(options)); 2261 EXPECT_TRUE(engine_.SetOptions(options));
2288 2262
2289 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); 2263 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
2290 EXPECT_EQ(13, agc_config.targetLeveldBOv); 2264 EXPECT_EQ(13, agc_config.targetLeveldBOv);
2291 } 2265 }
2292 2266
2293 TEST_F(WebRtcVoiceEngineTestFake, RxAgcConfigViaOptions) { 2267 TEST_F(WebRtcVoiceEngineTestFake, RxAgcConfigViaOptions) {
2294 EXPECT_TRUE(SetupEngine()); 2268 EXPECT_TRUE(SetupEngine());
2295 int channel_num = voe_.GetLastChannel(); 2269 int channel_num = voe_.GetLastChannel();
2296 cricket::AudioOptions options; 2270 send_parameters_.options.rx_agc_target_dbov.Set(6);
2297 options.rx_agc_target_dbov.Set(6); 2271 send_parameters_.options.rx_agc_digital_compression_gain.Set(0);
2298 options.rx_agc_digital_compression_gain.Set(0); 2272 send_parameters_.options.rx_agc_limiter.Set(true);
2299 options.rx_agc_limiter.Set(true); 2273 send_parameters_.options.rx_auto_gain_control.Set(true);
2300 options.rx_auto_gain_control.Set(true); 2274 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2301 EXPECT_TRUE(channel_->SetOptions(options));
2302 2275
2303 webrtc::AgcConfig agc_config; 2276 webrtc::AgcConfig agc_config;
2304 EXPECT_EQ(0, engine_.voe()->processing()->GetRxAgcConfig( 2277 EXPECT_EQ(0, engine_.voe()->processing()->GetRxAgcConfig(
2305 channel_num, agc_config)); 2278 channel_num, agc_config));
2306 EXPECT_EQ(6, agc_config.targetLeveldBOv); 2279 EXPECT_EQ(6, agc_config.targetLeveldBOv);
2307 EXPECT_EQ(0, agc_config.digitalCompressionGaindB); 2280 EXPECT_EQ(0, agc_config.digitalCompressionGaindB);
2308 EXPECT_TRUE(agc_config.limiterEnable); 2281 EXPECT_TRUE(agc_config.limiterEnable);
2309 } 2282 }
2310 2283
2311 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { 2284 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 EXPECT_EQ(kSsrc1, send_ssrc); 2326 EXPECT_EQ(kSsrc1, send_ssrc);
2354 } 2327 }
2355 2328
2356 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { 2329 TEST_F(WebRtcVoiceEngineTestFake, GetStats) {
2357 // Setup. We need send codec to be set to get all stats. 2330 // Setup. We need send codec to be set to get all stats.
2358 EXPECT_TRUE(SetupEngine()); 2331 EXPECT_TRUE(SetupEngine());
2359 // SetupEngine adds a send stream with kSsrc1, so the receive stream has to 2332 // SetupEngine adds a send stream with kSsrc1, so the receive stream has to
2360 // use a different SSRC. 2333 // use a different SSRC.
2361 EXPECT_TRUE(channel_->AddRecvStream( 2334 EXPECT_TRUE(channel_->AddRecvStream(
2362 cricket::StreamParams::CreateLegacy(kSsrc2))); 2335 cricket::StreamParams::CreateLegacy(kSsrc2)));
2363 std::vector<cricket::AudioCodec> codecs; 2336 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2364 codecs.push_back(kPcmuCodec); 2337 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
2365 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2366 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
2367 2338
2368 cricket::VoiceMediaInfo info; 2339 cricket::VoiceMediaInfo info;
2369 EXPECT_EQ(true, channel_->GetStats(&info)); 2340 EXPECT_EQ(true, channel_->GetStats(&info));
2370 EXPECT_EQ(1u, info.senders.size()); 2341 EXPECT_EQ(1u, info.senders.size());
2371 EXPECT_EQ(kSsrc1, info.senders[0].ssrc()); 2342 EXPECT_EQ(kSsrc1, info.senders[0].ssrc());
2372 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); 2343 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name);
2373 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].bytes_sent); 2344 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].bytes_sent);
2374 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_sent); 2345 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_sent);
2375 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_lost); 2346 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_lost);
2376 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[0].fraction_lost); 2347 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[0].fraction_lost);
(...skipping 26 matching lines...) Expand all
2403 (1 << 14), info.receivers[0].speech_expand_rate); 2374 (1 << 14), info.receivers[0].speech_expand_rate);
2404 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / 2375 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) /
2405 (1 << 14), info.receivers[0].secondary_decoded_rate); 2376 (1 << 14), info.receivers[0].secondary_decoded_rate);
2406 // TODO(sriniv): Add testing for more receiver fields. 2377 // TODO(sriniv): Add testing for more receiver fields.
2407 } 2378 }
2408 2379
2409 // Test that we can set the outgoing SSRC properly with multiple streams. 2380 // Test that we can set the outgoing SSRC properly with multiple streams.
2410 // SSRC is set in SetupEngine by calling AddSendStream. 2381 // SSRC is set in SetupEngine by calling AddSendStream.
2411 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { 2382 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) {
2412 EXPECT_TRUE(SetupEngine()); 2383 EXPECT_TRUE(SetupEngine());
2413 EXPECT_TRUE(channel_->SetOptions(options_conference_));
2414 int channel_num1 = voe_.GetLastChannel(); 2384 int channel_num1 = voe_.GetLastChannel();
2415 unsigned int send_ssrc; 2385 unsigned int send_ssrc;
2416 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); 2386 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc));
2417 EXPECT_EQ(kSsrc1, send_ssrc); 2387 EXPECT_EQ(kSsrc1, send_ssrc);
2418 2388
2419 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2389 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2420 int channel_num2 = voe_.GetLastChannel(); 2390 int channel_num2 = voe_.GetLastChannel();
2421 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc)); 2391 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc));
2422 EXPECT_EQ(kSsrc1, send_ssrc); 2392 EXPECT_EQ(kSsrc1, send_ssrc);
2423 } 2393 }
2424 2394
2425 // Test that the local SSRC is the same on sending and receiving channels if the 2395 // Test that the local SSRC is the same on sending and receiving channels if the
2426 // receive channel is created before the send channel. 2396 // receive channel is created before the send channel.
2427 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { 2397 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) {
2428 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 2398 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
2429 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 2399 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
2430 EXPECT_TRUE(channel_->SetOptions(options_conference_));
2431 2400
2432 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2401 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2433 int receive_channel_num = voe_.GetLastChannel(); 2402 int receive_channel_num = voe_.GetLastChannel();
2434 EXPECT_TRUE(channel_->AddSendStream( 2403 EXPECT_TRUE(channel_->AddSendStream(
2435 cricket::StreamParams::CreateLegacy(1234))); 2404 cricket::StreamParams::CreateLegacy(1234)));
2436 int send_channel_num = voe_.GetLastChannel(); 2405 int send_channel_num = voe_.GetLastChannel();
2437 2406
2438 unsigned int ssrc = 0; 2407 unsigned int ssrc = 0;
2439 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc)); 2408 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc));
2440 EXPECT_EQ(1234U, ssrc); 2409 EXPECT_EQ(1234U, ssrc);
2441 ssrc = 0; 2410 ssrc = 0;
2442 EXPECT_EQ(0, voe_.GetLocalSSRC(receive_channel_num, ssrc)); 2411 EXPECT_EQ(0, voe_.GetLocalSSRC(receive_channel_num, ssrc));
2443 EXPECT_EQ(1234U, ssrc); 2412 EXPECT_EQ(1234U, ssrc);
2444 } 2413 }
2445 2414
2446 // Test that we can properly receive packets. 2415 // Test that we can properly receive packets.
2447 TEST_F(WebRtcVoiceEngineTestFake, Recv) { 2416 TEST_F(WebRtcVoiceEngineTestFake, Recv) {
2448 EXPECT_TRUE(SetupEngine()); 2417 EXPECT_TRUE(SetupEngine());
2449 int channel_num = voe_.GetLastChannel(); 2418 int channel_num = voe_.GetLastChannel();
2450 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); 2419 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
2451 EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame, 2420 EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame,
2452 sizeof(kPcmuFrame))); 2421 sizeof(kPcmuFrame)));
2453 } 2422 }
2454 2423
2455 // Test that we can properly receive packets on multiple streams. 2424 // Test that we can properly receive packets on multiple streams.
2456 TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { 2425 TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) {
2457 EXPECT_TRUE(SetupEngine()); 2426 EXPECT_TRUE(SetupEngine());
2458 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2427 send_parameters_.options = options_conference_;
2428 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2459 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2429 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2460 int channel_num1 = voe_.GetLastChannel(); 2430 int channel_num1 = voe_.GetLastChannel();
2461 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2431 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2462 int channel_num2 = voe_.GetLastChannel(); 2432 int channel_num2 = voe_.GetLastChannel();
2463 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 2433 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
2464 int channel_num3 = voe_.GetLastChannel(); 2434 int channel_num3 = voe_.GetLastChannel();
2465 // Create packets with the right SSRCs. 2435 // Create packets with the right SSRCs.
2466 char packets[4][sizeof(kPcmuFrame)]; 2436 char packets[4][sizeof(kPcmuFrame)];
2467 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { 2437 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) {
2468 memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame)); 2438 memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame));
(...skipping 23 matching lines...) Expand all
2492 sizeof(packets[3]))); 2462 sizeof(packets[3])));
2493 EXPECT_TRUE(channel_->RemoveRecvStream(3)); 2463 EXPECT_TRUE(channel_->RemoveRecvStream(3));
2494 EXPECT_TRUE(channel_->RemoveRecvStream(2)); 2464 EXPECT_TRUE(channel_->RemoveRecvStream(2));
2495 EXPECT_TRUE(channel_->RemoveRecvStream(1)); 2465 EXPECT_TRUE(channel_->RemoveRecvStream(1));
2496 } 2466 }
2497 2467
2498 // Test that we properly handle failures to add a stream. 2468 // Test that we properly handle failures to add a stream.
2499 TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) { 2469 TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) {
2500 EXPECT_TRUE(SetupEngine()); 2470 EXPECT_TRUE(SetupEngine());
2501 voe_.set_fail_create_channel(true); 2471 voe_.set_fail_create_channel(true);
2502 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2472 send_parameters_.options = options_conference_;
2473 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2503 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2474 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2504 2475
2505 // In 1:1 call, we should not try to create a new channel. 2476 // In 1:1 call, we should not try to create a new channel.
2506 cricket::AudioOptions options_no_conference_; 2477 send_parameters_.options.conference_mode.Set(false);
2507 options_no_conference_.conference_mode.Set(false); 2478 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2508 EXPECT_TRUE(channel_->SetOptions(options_no_conference_));
2509 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2479 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2510 } 2480 }
2511 2481
2512 // Test that AddRecvStream doesn't create new channel for 1:1 call. 2482 // Test that AddRecvStream doesn't create new channel for 1:1 call.
2513 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream1On1) { 2483 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream1On1) {
2514 EXPECT_TRUE(SetupEngine()); 2484 EXPECT_TRUE(SetupEngine());
2515 int channel_num = voe_.GetLastChannel(); 2485 int channel_num = voe_.GetLastChannel();
2516 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2486 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2517 EXPECT_EQ(channel_num, voe_.GetLastChannel()); 2487 EXPECT_EQ(channel_num, voe_.GetLastChannel());
2518 } 2488 }
2519 2489
2520 // Test that after adding a recv stream, we do not decode more codecs than 2490 // Test that after adding a recv stream, we do not decode more codecs than
2521 // those previously passed into SetRecvCodecs. 2491 // those previously passed into SetRecvCodecs.
2522 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { 2492 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) {
2523 EXPECT_TRUE(SetupEngine()); 2493 EXPECT_TRUE(SetupEngine());
2524 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2494 cricket::AudioRecvParameters parameters;
2525 std::vector<cricket::AudioCodec> codecs; 2495 parameters.codecs.push_back(kIsacCodec);
2526 codecs.push_back(kIsacCodec); 2496 parameters.codecs.push_back(kPcmuCodec);
2527 codecs.push_back(kPcmuCodec); 2497 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
2528 EXPECT_TRUE(channel_->SetRecvCodecs(codecs));
2529 EXPECT_TRUE(channel_->AddRecvStream( 2498 EXPECT_TRUE(channel_->AddRecvStream(
2530 cricket::StreamParams::CreateLegacy(kSsrc1))); 2499 cricket::StreamParams::CreateLegacy(kSsrc1)));
2531 int channel_num2 = voe_.GetLastChannel(); 2500 int channel_num2 = voe_.GetLastChannel();
2532 webrtc::CodecInst gcodec; 2501 webrtc::CodecInst gcodec;
2533 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus"); 2502 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus");
2534 gcodec.plfreq = 48000; 2503 gcodec.plfreq = 48000;
2535 gcodec.channels = 2; 2504 gcodec.channels = 2;
2536 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); 2505 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec));
2537 } 2506 }
2538 2507
2539 // Test that we properly clean up any streams that were added, even if 2508 // Test that we properly clean up any streams that were added, even if
2540 // not explicitly removed. 2509 // not explicitly removed.
2541 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { 2510 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) {
2542 EXPECT_TRUE(SetupEngine()); 2511 EXPECT_TRUE(SetupEngine());
2543 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2512 send_parameters_.options = options_conference_;
2513 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2544 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2514 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2545 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2515 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2546 EXPECT_EQ(3, voe_.GetNumChannels()); // default channel + 2 added 2516 EXPECT_EQ(3, voe_.GetNumChannels()); // default channel + 2 added
2547 delete channel_; 2517 delete channel_;
2548 channel_ = NULL; 2518 channel_ = NULL;
2549 EXPECT_EQ(0, voe_.GetNumChannels()); 2519 EXPECT_EQ(0, voe_.GetNumChannels());
2550 } 2520 }
2551 2521
2552 TEST_F(WebRtcVoiceEngineTestFake, TestAddRecvStreamFailWithZeroSsrc) { 2522 TEST_F(WebRtcVoiceEngineTestFake, TestAddRecvStreamFailWithZeroSsrc) {
2553 EXPECT_TRUE(SetupEngine()); 2523 EXPECT_TRUE(SetupEngine());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2608 // Check we stop the tone if a packet arrives. 2578 // Check we stop the tone if a packet arrives.
2609 EXPECT_TRUE(channel_->PlayRingbackTone(0, true, true)); 2579 EXPECT_TRUE(channel_->PlayRingbackTone(0, true, true));
2610 EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num)); 2580 EXPECT_EQ(1, voe_.IsPlayingFileLocally(channel_num));
2611 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); 2581 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
2612 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num)); 2582 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2613 } 2583 }
2614 2584
2615 // Test that we can play a ringback tone properly in a multi-stream call. 2585 // Test that we can play a ringback tone properly in a multi-stream call.
2616 TEST_F(WebRtcVoiceEngineTestFake, PlayRingbackWithMultipleStreams) { 2586 TEST_F(WebRtcVoiceEngineTestFake, PlayRingbackWithMultipleStreams) {
2617 EXPECT_TRUE(SetupEngine()); 2587 EXPECT_TRUE(SetupEngine());
2618 EXPECT_TRUE(channel_->SetOptions(options_conference_));
2619 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2588 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2620 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2589 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2621 int channel_num = voe_.GetLastChannel(); 2590 int channel_num = voe_.GetLastChannel();
2622 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num)); 2591 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2623 // Check we fail if no ringback tone specified. 2592 // Check we fail if no ringback tone specified.
2624 EXPECT_FALSE(channel_->PlayRingbackTone(2, true, true)); 2593 EXPECT_FALSE(channel_->PlayRingbackTone(2, true, true));
2625 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num)); 2594 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2626 // Check we can set and play a ringback tone on the correct ssrc. 2595 // Check we can set and play a ringback tone on the correct ssrc.
2627 EXPECT_TRUE(channel_->SetRingbackTone( 2596 EXPECT_TRUE(channel_->SetRingbackTone(
2628 kRingbackTone, static_cast<int>(strlen(kRingbackTone)))); 2597 kRingbackTone, static_cast<int>(strlen(kRingbackTone))));
(...skipping 16 matching lines...) Expand all
2645 DeliverPacket(packet, sizeof(packet)); 2614 DeliverPacket(packet, sizeof(packet));
2646 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num)); 2615 EXPECT_EQ(0, voe_.IsPlayingFileLocally(channel_num));
2647 } 2616 }
2648 2617
2649 TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) { 2618 TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) {
2650 rtc::scoped_ptr<ChannelErrorListener> listener; 2619 rtc::scoped_ptr<ChannelErrorListener> listener;
2651 cricket::WebRtcVoiceMediaChannel* media_channel; 2620 cricket::WebRtcVoiceMediaChannel* media_channel;
2652 unsigned int ssrc = 0; 2621 unsigned int ssrc = 0;
2653 2622
2654 EXPECT_TRUE(SetupEngine()); 2623 EXPECT_TRUE(SetupEngine());
2655 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2624 send_parameters_.options = options_conference_;
2625 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2656 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2626 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
2657 2627
2658 media_channel = static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 2628 media_channel = static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
2659 listener.reset(new ChannelErrorListener(channel_)); 2629 listener.reset(new ChannelErrorListener(channel_));
2660 2630
2661 // Test on WebRtc VoE channel. 2631 // Test on WebRtc VoE channel.
2662 voe_.TriggerCallbackOnError(media_channel->voe_channel(), 2632 voe_.TriggerCallbackOnError(media_channel->voe_channel(),
2663 VE_SATURATION_WARNING); 2633 VE_SATURATION_WARNING);
2664 EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_REC_DEVICE_SATURATION, 2634 EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_REC_DEVICE_SATURATION,
2665 listener->error()); 2635 listener->error());
(...skipping 19 matching lines...) Expand all
2685 2655
2686 // Testing a non-existing channel. 2656 // Testing a non-existing channel.
2687 listener->Reset(); 2657 listener->Reset();
2688 voe_.TriggerCallbackOnError(voe_.GetLastChannel() + 2, 2658 voe_.TriggerCallbackOnError(voe_.GetLastChannel() + 2,
2689 VE_SATURATION_WARNING); 2659 VE_SATURATION_WARNING);
2690 EXPECT_EQ(0, listener->error()); 2660 EXPECT_EQ(0, listener->error());
2691 } 2661 }
2692 2662
2693 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { 2663 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) {
2694 EXPECT_TRUE(SetupEngine()); 2664 EXPECT_TRUE(SetupEngine());
2695 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 2665 send_parameters_.options = options_conference_;
2696 std::vector<cricket::AudioCodec> codecs; 2666 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2697 codecs.push_back(kPcmuCodec);
2698 EXPECT_TRUE(channel_->SetSendCodecs(codecs));
2699 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 2667 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
2700 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2668 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2701 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 2669 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
2702 EXPECT_TRUE(channel_->SetPlayout(true)); 2670 EXPECT_TRUE(channel_->SetPlayout(true));
2703 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); 2671 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1);
2704 EXPECT_TRUE(channel_->SetPlayout(false)); 2672 EXPECT_TRUE(channel_->SetPlayout(false));
2705 EXPECT_FALSE(channel_->SetPlayout(true)); 2673 EXPECT_FALSE(channel_->SetPlayout(true));
2706 } 2674 }
2707 2675
2708 // Test that the Registering/Unregistering with the 2676 // Test that the Registering/Unregistering with the
2709 // webrtcvoiceengine works as expected 2677 // webrtcvoiceengine works as expected
2710 TEST_F(WebRtcVoiceEngineTestFake, RegisterVoiceProcessor) { 2678 TEST_F(WebRtcVoiceEngineTestFake, RegisterVoiceProcessor) {
2711 EXPECT_TRUE(SetupEngine()); 2679 EXPECT_TRUE(SetupEngine());
2712 EXPECT_TRUE(channel_->SetOptions(options_conference_));
2713 EXPECT_TRUE(channel_->AddRecvStream( 2680 EXPECT_TRUE(channel_->AddRecvStream(
2714 cricket::StreamParams::CreateLegacy(kSsrc2))); 2681 cricket::StreamParams::CreateLegacy(kSsrc2)));
2715 cricket::FakeMediaProcessor vp_1; 2682 cricket::FakeMediaProcessor vp_1;
2716 cricket::FakeMediaProcessor vp_2; 2683 cricket::FakeMediaProcessor vp_2;
2717 2684
2718 EXPECT_FALSE(engine_.RegisterProcessor(kSsrc2, &vp_1, cricket::MPD_TX)); 2685 EXPECT_FALSE(engine_.RegisterProcessor(kSsrc2, &vp_1, cricket::MPD_TX));
2719 EXPECT_TRUE(engine_.RegisterProcessor(kSsrc2, &vp_1, cricket::MPD_RX)); 2686 EXPECT_TRUE(engine_.RegisterProcessor(kSsrc2, &vp_1, cricket::MPD_RX));
2720 EXPECT_TRUE(engine_.RegisterProcessor(kSsrc2, &vp_2, cricket::MPD_RX)); 2687 EXPECT_TRUE(engine_.RegisterProcessor(kSsrc2, &vp_2, cricket::MPD_RX));
2721 voe_.TriggerProcessPacket(cricket::MPD_RX); 2688 voe_.TriggerProcessPacket(cricket::MPD_RX);
2722 voe_.TriggerProcessPacket(cricket::MPD_TX); 2689 voe_.TriggerProcessPacket(cricket::MPD_TX);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 2971
3005 // Have to add a stream to make SetSend work. 2972 // Have to add a stream to make SetSend work.
3006 cricket::StreamParams stream1; 2973 cricket::StreamParams stream1;
3007 stream1.ssrcs.push_back(1); 2974 stream1.ssrcs.push_back(1);
3008 channel1->AddSendStream(stream1); 2975 channel1->AddSendStream(stream1);
3009 cricket::StreamParams stream2; 2976 cricket::StreamParams stream2;
3010 stream2.ssrcs.push_back(2); 2977 stream2.ssrcs.push_back(2);
3011 channel2->AddSendStream(stream2); 2978 channel2->AddSendStream(stream2);
3012 2979
3013 // AEC and AGC and NS 2980 // AEC and AGC and NS
3014 cricket::AudioOptions options_all; 2981 cricket::AudioSendParameters parameters_options_all = send_parameters_;
3015 options_all.echo_cancellation.Set(true); 2982 parameters_options_all.options.echo_cancellation.Set(true);
3016 options_all.auto_gain_control.Set(true); 2983 parameters_options_all.options.auto_gain_control.Set(true);
3017 options_all.noise_suppression.Set(true); 2984 parameters_options_all.options.noise_suppression.Set(true);
3018 2985 ASSERT_TRUE(channel1->SetSendParameters(parameters_options_all));
3019 ASSERT_TRUE(channel1->SetOptions(options_all)); 2986 EXPECT_EQ(parameters_options_all.options, channel1->options());
3020 cricket::AudioOptions expected_options = options_all; 2987 ASSERT_TRUE(channel2->SetSendParameters(parameters_options_all));
3021 EXPECT_EQ(expected_options, channel1->options()); 2988 EXPECT_EQ(parameters_options_all.options, channel2->options());
3022 ASSERT_TRUE(channel2->SetOptions(options_all));
3023 EXPECT_EQ(expected_options, channel2->options());
3024 2989
3025 // unset NS 2990 // unset NS
3026 cricket::AudioOptions options_no_ns; 2991 cricket::AudioSendParameters parameters_options_no_ns = send_parameters_;
3027 options_no_ns.noise_suppression.Set(false); 2992 parameters_options_no_ns.options.noise_suppression.Set(false);
3028 ASSERT_TRUE(channel1->SetOptions(options_no_ns)); 2993 ASSERT_TRUE(channel1->SetSendParameters(parameters_options_no_ns));
3029 2994 cricket::AudioOptions expected_options = parameters_options_all.options;
3030 expected_options.echo_cancellation.Set(true); 2995 expected_options.echo_cancellation.Set(true);
3031 expected_options.auto_gain_control.Set(true); 2996 expected_options.auto_gain_control.Set(true);
3032 expected_options.noise_suppression.Set(false); 2997 expected_options.noise_suppression.Set(false);
3033 EXPECT_EQ(expected_options, channel1->options()); 2998 EXPECT_EQ(expected_options, channel1->options());
3034 2999
3035 // unset AGC 3000 // unset AGC
3036 cricket::AudioOptions options_no_agc; 3001 cricket::AudioSendParameters parameters_options_no_agc = send_parameters_;
3037 options_no_agc.auto_gain_control.Set(false); 3002 parameters_options_no_agc.options.auto_gain_control.Set(false);
3038 ASSERT_TRUE(channel2->SetOptions(options_no_agc)); 3003 ASSERT_TRUE(channel2->SetSendParameters(parameters_options_no_agc));
3039
3040 expected_options.echo_cancellation.Set(true); 3004 expected_options.echo_cancellation.Set(true);
3041 expected_options.auto_gain_control.Set(false); 3005 expected_options.auto_gain_control.Set(false);
3042 expected_options.noise_suppression.Set(true); 3006 expected_options.noise_suppression.Set(true);
3043 EXPECT_EQ(expected_options, channel2->options()); 3007 EXPECT_EQ(expected_options, channel2->options());
3044 3008
3045 ASSERT_TRUE(engine_.SetOptions(options_all)); 3009 ASSERT_TRUE(engine_.SetOptions(parameters_options_all.options));
3046 bool ec_enabled; 3010 bool ec_enabled;
3047 webrtc::EcModes ec_mode; 3011 webrtc::EcModes ec_mode;
3048 bool agc_enabled; 3012 bool agc_enabled;
3049 webrtc::AgcModes agc_mode; 3013 webrtc::AgcModes agc_mode;
3050 bool ns_enabled; 3014 bool ns_enabled;
3051 webrtc::NsModes ns_mode; 3015 webrtc::NsModes ns_mode;
3052 voe_.GetEcStatus(ec_enabled, ec_mode); 3016 voe_.GetEcStatus(ec_enabled, ec_mode);
3053 voe_.GetAgcStatus(agc_enabled, agc_mode); 3017 voe_.GetAgcStatus(agc_enabled, agc_mode);
3054 voe_.GetNsStatus(ns_enabled, ns_mode); 3018 voe_.GetNsStatus(ns_enabled, ns_mode);
3055 EXPECT_TRUE(ec_enabled); 3019 EXPECT_TRUE(ec_enabled);
(...skipping 26 matching lines...) Expand all
3082 3046
3083 channel2->SetSend(cricket::SEND_NOTHING); 3047 channel2->SetSend(cricket::SEND_NOTHING);
3084 voe_.GetEcStatus(ec_enabled, ec_mode); 3048 voe_.GetEcStatus(ec_enabled, ec_mode);
3085 voe_.GetAgcStatus(agc_enabled, agc_mode); 3049 voe_.GetAgcStatus(agc_enabled, agc_mode);
3086 voe_.GetNsStatus(ns_enabled, ns_mode); 3050 voe_.GetNsStatus(ns_enabled, ns_mode);
3087 EXPECT_TRUE(ec_enabled); 3051 EXPECT_TRUE(ec_enabled);
3088 EXPECT_TRUE(agc_enabled); 3052 EXPECT_TRUE(agc_enabled);
3089 EXPECT_TRUE(ns_enabled); 3053 EXPECT_TRUE(ns_enabled);
3090 3054
3091 // Make sure settings take effect while we are sending. 3055 // Make sure settings take effect while we are sending.
3092 ASSERT_TRUE(engine_.SetOptions(options_all)); 3056 ASSERT_TRUE(engine_.SetOptions(parameters_options_all.options));
3093 cricket::AudioOptions options_no_agc_nor_ns; 3057 cricket::AudioSendParameters parameters_options_no_agc_nor_ns =
3094 options_no_agc_nor_ns.auto_gain_control.Set(false); 3058 send_parameters_;
3095 options_no_agc_nor_ns.noise_suppression.Set(false); 3059 parameters_options_no_agc_nor_ns.options.auto_gain_control.Set(false);
3060 parameters_options_no_agc_nor_ns.options.noise_suppression.Set(false);
3096 channel2->SetSend(cricket::SEND_MICROPHONE); 3061 channel2->SetSend(cricket::SEND_MICROPHONE);
3097 channel2->SetOptions(options_no_agc_nor_ns); 3062 channel2->SetSendParameters(parameters_options_no_agc_nor_ns);
3098
3099 expected_options.echo_cancellation.Set(true); 3063 expected_options.echo_cancellation.Set(true);
3100 expected_options.auto_gain_control.Set(false); 3064 expected_options.auto_gain_control.Set(false);
3101 expected_options.noise_suppression.Set(false); 3065 expected_options.noise_suppression.Set(false);
3102 EXPECT_EQ(expected_options, channel2->options()); 3066 EXPECT_EQ(expected_options, channel2->options());
3103 voe_.GetEcStatus(ec_enabled, ec_mode); 3067 voe_.GetEcStatus(ec_enabled, ec_mode);
3104 voe_.GetAgcStatus(agc_enabled, agc_mode); 3068 voe_.GetAgcStatus(agc_enabled, agc_mode);
3105 voe_.GetNsStatus(ns_enabled, ns_mode); 3069 voe_.GetNsStatus(ns_enabled, ns_mode);
3106 EXPECT_TRUE(ec_enabled); 3070 EXPECT_TRUE(ec_enabled);
3107 EXPECT_FALSE(agc_enabled); 3071 EXPECT_FALSE(agc_enabled);
3108 EXPECT_FALSE(ns_enabled); 3072 EXPECT_FALSE(ns_enabled);
3109 } 3073 }
3110 3074
3111 // This test verifies DSCP settings are properly applied on voice media channel. 3075 // This test verifies DSCP settings are properly applied on voice media channel.
3112 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { 3076 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
3113 EXPECT_TRUE(SetupEngine()); 3077 EXPECT_TRUE(SetupEngine());
3114 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel( 3078 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel(
3115 engine_.CreateChannel(&call_, cricket::AudioOptions())); 3079 engine_.CreateChannel(&call_, cricket::AudioOptions()));
3116 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( 3080 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface(
3117 new cricket::FakeNetworkInterface); 3081 new cricket::FakeNetworkInterface);
3118 channel->SetInterface(network_interface.get()); 3082 channel->SetInterface(network_interface.get());
3119 cricket::AudioOptions options; 3083 cricket::AudioSendParameters parameters = send_parameters_;
3120 options.dscp.Set(true); 3084 parameters.options.dscp.Set(true);
3121 EXPECT_TRUE(channel->SetOptions(options)); 3085 EXPECT_TRUE(channel->SetSendParameters(parameters));
3122 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); 3086 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp());
3123 // Verify previous value is not modified if dscp option is not set. 3087 // Verify previous value is not modified if dscp option is not set.
3124 cricket::AudioOptions options1; 3088 EXPECT_TRUE(channel->SetSendParameters(send_parameters_));
3125 EXPECT_TRUE(channel->SetOptions(options1));
3126 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); 3089 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp());
3127 options.dscp.Set(false); 3090 parameters.options.dscp.Set(false);
3128 EXPECT_TRUE(channel->SetOptions(options)); 3091 EXPECT_TRUE(channel->SetSendParameters(parameters));
3129 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); 3092 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
3130 } 3093 }
3131 3094
3132 // Test that GetReceiveChannelNum returns the default channel for the first 3095 // Test that GetReceiveChannelNum returns the default channel for the first
3133 // recv stream in 1-1 calls. 3096 // recv stream in 1-1 calls.
3134 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNumIn1To1Calls) { 3097 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNumIn1To1Calls) {
3135 EXPECT_TRUE(SetupEngine()); 3098 EXPECT_TRUE(SetupEngine());
3136 cricket::WebRtcVoiceMediaChannel* media_channel = 3099 cricket::WebRtcVoiceMediaChannel* media_channel =
3137 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3100 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3138 // Test that GetChannelNum returns the default channel if the SSRC is unknown. 3101 // Test that GetChannelNum returns the default channel if the SSRC is unknown.
3139 EXPECT_EQ(media_channel->voe_channel(), 3102 EXPECT_EQ(media_channel->voe_channel(),
3140 media_channel->GetReceiveChannelNum(0)); 3103 media_channel->GetReceiveChannelNum(0));
3141 cricket::StreamParams stream; 3104 cricket::StreamParams stream;
3142 stream.ssrcs.push_back(kSsrc2); 3105 stream.ssrcs.push_back(kSsrc2);
3143 EXPECT_TRUE(channel_->AddRecvStream(stream)); 3106 EXPECT_TRUE(channel_->AddRecvStream(stream));
3144 EXPECT_EQ(media_channel->voe_channel(), 3107 EXPECT_EQ(media_channel->voe_channel(),
3145 media_channel->GetReceiveChannelNum(kSsrc2)); 3108 media_channel->GetReceiveChannelNum(kSsrc2));
3146 } 3109 }
3147 3110
3148 // Test that GetReceiveChannelNum doesn't return the default channel for the 3111 // Test that GetReceiveChannelNum doesn't return the default channel for the
3149 // first recv stream in conference calls. 3112 // first recv stream in conference calls.
3150 TEST_F(WebRtcVoiceEngineTestFake, TestGetChannelNumInConferenceCalls) { 3113 TEST_F(WebRtcVoiceEngineTestFake, TestGetChannelNumInConferenceCalls) {
3151 EXPECT_TRUE(SetupEngine()); 3114 EXPECT_TRUE(SetupEngine());
3152 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 3115 send_parameters_.options = options_conference_;
3116 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3153 cricket::StreamParams stream; 3117 cricket::StreamParams stream;
3154 stream.ssrcs.push_back(kSsrc2); 3118 stream.ssrcs.push_back(kSsrc2);
3155 EXPECT_TRUE(channel_->AddRecvStream(stream)); 3119 EXPECT_TRUE(channel_->AddRecvStream(stream));
3156 cricket::WebRtcVoiceMediaChannel* media_channel = 3120 cricket::WebRtcVoiceMediaChannel* media_channel =
3157 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3121 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3158 EXPECT_LT(media_channel->voe_channel(), 3122 EXPECT_LT(media_channel->voe_channel(),
3159 media_channel->GetReceiveChannelNum(kSsrc2)); 3123 media_channel->GetReceiveChannelNum(kSsrc2));
3160 } 3124 }
3161 3125
3162 TEST_F(WebRtcVoiceEngineTestFake, SetOutputScaling) { 3126 TEST_F(WebRtcVoiceEngineTestFake, SetOutputScaling) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3185 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3222 3186
3223 // Combined BWE should be disabled. 3187 // Combined BWE should be disabled.
3224 for (uint32 ssrc : ssrcs) { 3188 for (uint32 ssrc : ssrcs) {
3225 const auto* s = call_.GetAudioReceiveStream(ssrc); 3189 const auto* s = call_.GetAudioReceiveStream(ssrc);
3226 EXPECT_NE(nullptr, s); 3190 EXPECT_NE(nullptr, s);
3227 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); 3191 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe);
3228 } 3192 }
3229 3193
3230 // Enable combined BWE option - now it should be set up. 3194 // Enable combined BWE option - now it should be set up.
3231 cricket::AudioOptions options; 3195 send_parameters_.options.combined_audio_video_bwe.Set(true);
3232 options.combined_audio_video_bwe.Set(true); 3196 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3233 EXPECT_TRUE(media_channel->SetOptions(options));
3234 for (uint32 ssrc : ssrcs) { 3197 for (uint32 ssrc : ssrcs) {
3235 const auto* s = call_.GetAudioReceiveStream(ssrc); 3198 const auto* s = call_.GetAudioReceiveStream(ssrc);
3236 EXPECT_NE(nullptr, s); 3199 EXPECT_NE(nullptr, s);
3237 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe); 3200 EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe);
3238 } 3201 }
3239 3202
3240 // Disable combined BWE option - should be disabled again. 3203 // Disable combined BWE option - should be disabled again.
3241 options.combined_audio_video_bwe.Set(false); 3204 send_parameters_.options.combined_audio_video_bwe.Set(false);
3242 EXPECT_TRUE(media_channel->SetOptions(options)); 3205 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3243 for (uint32 ssrc : ssrcs) { 3206 for (uint32 ssrc : ssrcs) {
3244 const auto* s = call_.GetAudioReceiveStream(ssrc); 3207 const auto* s = call_.GetAudioReceiveStream(ssrc);
3245 EXPECT_NE(nullptr, s); 3208 EXPECT_NE(nullptr, s);
3246 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); 3209 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe);
3247 } 3210 }
3248 3211
3249 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3212 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3250 } 3213 }
3251 3214
3252 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { 3215 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
3253 // Test that adding receive streams after enabling combined bandwidth 3216 // Test that adding receive streams after enabling combined bandwidth
3254 // estimation will correctly configure each channel. 3217 // estimation will correctly configure each channel.
3255 EXPECT_TRUE(SetupEngine()); 3218 EXPECT_TRUE(SetupEngine());
3256 cricket::WebRtcVoiceMediaChannel* media_channel = 3219 cricket::WebRtcVoiceMediaChannel* media_channel =
3257 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3220 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3258 cricket::AudioOptions options; 3221 send_parameters_.options.combined_audio_video_bwe.Set(true);
3259 options.combined_audio_video_bwe.Set(true); 3222 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3260 EXPECT_TRUE(media_channel->SetOptions(options));
3261 3223
3262 static const uint32 kSsrcs[] = {1, 2, 3, 4}; 3224 static const uint32 kSsrcs[] = {1, 2, 3, 4};
3263 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { 3225 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) {
3264 EXPECT_TRUE(media_channel->AddRecvStream( 3226 EXPECT_TRUE(media_channel->AddRecvStream(
3265 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); 3227 cricket::StreamParams::CreateLegacy(kSsrcs[i])));
3266 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); 3228 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i]));
3267 } 3229 }
3268 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); 3230 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size());
3269 } 3231 }
3270 3232
3271 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { 3233 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
3272 // Test that setting the header extensions results in the expected state 3234 // Test that setting the header extensions results in the expected state
3273 // changes on an associated Call. 3235 // changes on an associated Call.
3274 std::vector<uint32> ssrcs; 3236 std::vector<uint32> ssrcs;
3275 ssrcs.push_back(223); 3237 ssrcs.push_back(223);
3276 ssrcs.push_back(224); 3238 ssrcs.push_back(224);
3277 3239
3278 EXPECT_TRUE(SetupEngine()); 3240 EXPECT_TRUE(SetupEngine());
3279 cricket::WebRtcVoiceMediaChannel* media_channel = 3241 cricket::WebRtcVoiceMediaChannel* media_channel =
3280 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3242 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3281 cricket::AudioOptions options; 3243 send_parameters_.options.combined_audio_video_bwe.Set(true);
3282 options.combined_audio_video_bwe.Set(true); 3244 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
3283 EXPECT_TRUE(media_channel->SetOptions(options));
3284 for (uint32 ssrc : ssrcs) { 3245 for (uint32 ssrc : ssrcs) {
3285 EXPECT_TRUE(media_channel->AddRecvStream( 3246 EXPECT_TRUE(media_channel->AddRecvStream(
3286 cricket::StreamParams::CreateLegacy(ssrc))); 3247 cricket::StreamParams::CreateLegacy(ssrc)));
3287 } 3248 }
3288 3249
3289 // Combined BWE should be set up, but with no configured extensions. 3250 // Combined BWE should be set up, but with no configured extensions.
3290 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3251 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3291 for (uint32 ssrc : ssrcs) { 3252 for (uint32 ssrc : ssrcs) {
3292 const auto* s = call_.GetAudioReceiveStream(ssrc); 3253 const auto* s = call_.GetAudioReceiveStream(ssrc);
3293 EXPECT_NE(nullptr, s); 3254 EXPECT_NE(nullptr, s);
3294 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3255 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3295 } 3256 }
3296 3257
3297 // Set up receive extensions. 3258 // Set up receive extensions.
3298 const auto& e_exts = engine_.rtp_header_extensions(); 3259 const auto& e_exts = engine_.rtp_header_extensions();
3299 channel_->SetRecvRtpHeaderExtensions(e_exts); 3260 cricket::AudioRecvParameters recv_parameters;
3261 recv_parameters.extensions = e_exts;
3262 channel_->SetRecvParameters(recv_parameters);
3300 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); 3263 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size());
3301 for (uint32 ssrc : ssrcs) { 3264 for (uint32 ssrc : ssrcs) {
3302 const auto* s = call_.GetAudioReceiveStream(ssrc); 3265 const auto* s = call_.GetAudioReceiveStream(ssrc);
3303 EXPECT_NE(nullptr, s); 3266 EXPECT_NE(nullptr, s);
3304 const auto& s_exts = s->GetConfig().rtp.extensions; 3267 const auto& s_exts = s->GetConfig().rtp.extensions;
3305 EXPECT_EQ(e_exts.size(), s_exts.size()); 3268 EXPECT_EQ(e_exts.size(), s_exts.size());
3306 for (const auto& e_ext : e_exts) { 3269 for (const auto& e_ext : e_exts) {
3307 for (const auto& s_ext : s_exts) { 3270 for (const auto& s_ext : s_exts) {
3308 if (e_ext.id == s_ext.id) { 3271 if (e_ext.id == s_ext.id) {
3309 EXPECT_EQ(e_ext.uri, s_ext.name); 3272 EXPECT_EQ(e_ext.uri, s_ext.name);
3310 } 3273 }
3311 } 3274 }
3312 } 3275 }
3313 } 3276 }
3314 3277
3315 // Disable receive extensions. 3278 // Disable receive extensions.
3316 std::vector<cricket::RtpHeaderExtension> extensions; 3279 channel_->SetRecvParameters(cricket::AudioRecvParameters());
3317 channel_->SetRecvRtpHeaderExtensions(extensions);
3318 for (uint32 ssrc : ssrcs) { 3280 for (uint32 ssrc : ssrcs) {
3319 const auto* s = call_.GetAudioReceiveStream(ssrc); 3281 const auto* s = call_.GetAudioReceiveStream(ssrc);
3320 EXPECT_NE(nullptr, s); 3282 EXPECT_NE(nullptr, s);
3321 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3283 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3322 } 3284 }
3323 } 3285 }
3324 3286
3325 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { 3287 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) {
3326 // Test that packets are forwarded to the Call when configured accordingly. 3288 // Test that packets are forwarded to the Call when configured accordingly.
3327 const uint32 kAudioSsrc = 1; 3289 const uint32 kAudioSsrc = 1;
3328 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); 3290 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame));
3329 static const unsigned char kRtcp[] = { 3291 static const unsigned char kRtcp[] = {
3330 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 3292 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
3331 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 3293 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3332 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3294 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3333 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 3295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
3334 }; 3296 };
3335 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); 3297 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp));
3336 3298
3337 EXPECT_TRUE(SetupEngine()); 3299 EXPECT_TRUE(SetupEngine());
3338 cricket::WebRtcVoiceMediaChannel* media_channel = 3300 cricket::WebRtcVoiceMediaChannel* media_channel =
3339 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3301 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3340 cricket::AudioOptions options; 3302 send_parameters_.options.combined_audio_video_bwe.Set(true);
3341 options.combined_audio_video_bwe.Set(true); 3303 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3342 EXPECT_TRUE(media_channel->SetOptions(options));
3343 EXPECT_TRUE(media_channel->AddRecvStream( 3304 EXPECT_TRUE(media_channel->AddRecvStream(
3344 cricket::StreamParams::CreateLegacy(kAudioSsrc))); 3305 cricket::StreamParams::CreateLegacy(kAudioSsrc)));
3345 3306
3346 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size()); 3307 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size());
3347 const cricket::FakeAudioReceiveStream* s = 3308 const cricket::FakeAudioReceiveStream* s =
3348 call_.GetAudioReceiveStream(kAudioSsrc); 3309 call_.GetAudioReceiveStream(kAudioSsrc);
3349 EXPECT_EQ(0, s->received_packets()); 3310 EXPECT_EQ(0, s->received_packets());
3350 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); 3311 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime());
3351 EXPECT_EQ(1, s->received_packets()); 3312 EXPECT_EQ(1, s->received_packets());
3352 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); 3313 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime());
(...skipping 27 matching lines...) Expand all
3380 // Add send stream, the association remains. 3341 // Add send stream, the association remains.
3381 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); 3342 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3)));
3382 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); 3343 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1);
3383 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); 3344 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel);
3384 } 3345 }
3385 3346
3386 // In conference mode, all receive channels should be associated with the 3347 // In conference mode, all receive channels should be associated with the
3387 // default channel, since they do not send RTCP SR. 3348 // default channel, since they do not send RTCP SR.
3388 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { 3349 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) {
3389 EXPECT_TRUE(SetupEngine()); 3350 EXPECT_TRUE(SetupEngine());
3390 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 3351 send_parameters_.options = options_conference_;
3352 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3391 cricket::WebRtcVoiceMediaChannel* media_channel = 3353 cricket::WebRtcVoiceMediaChannel* media_channel =
3392 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3354 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3393 int default_channel = media_channel->voe_channel(); 3355 int default_channel = media_channel->voe_channel();
3394 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 3356 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
3395 int recv_ch = voe_.GetLastChannel(); 3357 int recv_ch = voe_.GetLastChannel();
3396 EXPECT_NE(recv_ch, default_channel); 3358 EXPECT_NE(recv_ch, default_channel);
3397 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); 3359 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel);
3398 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); 3360 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2)));
3399 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); 3361 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel);
3400 } 3362 }
3401 3363
3402 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { 3364 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) {
3403 EXPECT_TRUE(SetupEngine()); 3365 EXPECT_TRUE(SetupEngine());
3404 EXPECT_TRUE(channel_->SetOptions(options_conference_)); 3366 send_parameters_.options = options_conference_;
3367 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3405 3368
3406 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 3369 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
3407 int recv_ch = voe_.GetLastChannel(); 3370 int recv_ch = voe_.GetLastChannel();
3408 3371
3409 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); 3372 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2)));
3410 int send_ch = voe_.GetLastChannel(); 3373 int send_ch = voe_.GetLastChannel();
3411 3374
3412 // Manually associate |recv_ch| to |send_ch|. This test is to verify a 3375 // Manually associate |recv_ch| to |send_ch|. This test is to verify a
3413 // deleting logic, i.e., deleting |send_ch| will reset the associate send 3376 // deleting logic, i.e., deleting |send_ch| will reset the associate send
3414 // channel of |recv_ch|.This is not a common case, since, normally, only the 3377 // channel of |recv_ch|.This is not a common case, since, normally, only the
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3556 3519
3557 engine.Terminate(); 3520 engine.Terminate();
3558 } 3521 }
3559 3522
3560 // Test that we set our preferred codecs properly. 3523 // Test that we set our preferred codecs properly.
3561 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { 3524 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
3562 cricket::WebRtcVoiceEngine engine; 3525 cricket::WebRtcVoiceEngine engine;
3563 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3526 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3564 rtc::scoped_ptr<webrtc::Call> call( 3527 rtc::scoped_ptr<webrtc::Call> call(
3565 webrtc::Call::Create(webrtc::Call::Config())); 3528 webrtc::Call::Create(webrtc::Call::Config()));
3566 cricket::WebRtcVoiceMediaChannel channel(&engine, call.get()); 3529 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(),
3567 EXPECT_TRUE(channel.SetRecvCodecs(engine.codecs())); 3530 call.get());
3531 cricket::AudioRecvParameters parameters;
3532 parameters.codecs = engine.codecs();
3533 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3568 } 3534 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | talk/session/media/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698