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

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

Issue 2534173002: Wire up x-google-{min,start,max}-bitrate to WebRtcVoiceMediaChannel. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 webrtc::RtpParameters resulting_parameters = 349 webrtc::RtpParameters resulting_parameters =
350 channel_->GetRtpSendParameters(kSsrc1); 350 channel_->GetRtpSendParameters(kSsrc1);
351 EXPECT_EQ(1UL, resulting_parameters.encodings.size()); 351 EXPECT_EQ(1UL, resulting_parameters.encodings.size());
352 EXPECT_EQ(expected_result ? stream_max : -1, 352 EXPECT_EQ(expected_result ? stream_max : -1,
353 resulting_parameters.encodings[0].max_bitrate_bps); 353 resulting_parameters.encodings[0].max_bitrate_bps);
354 354
355 // Verify that the codec settings have the expected bitrate. 355 // Verify that the codec settings have the expected bitrate.
356 EXPECT_EQ(expected_codec_bitrate, GetCodecBitrate(kSsrc1)); 356 EXPECT_EQ(expected_codec_bitrate, GetCodecBitrate(kSsrc1));
357 } 357 }
358 358
359 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate_kbps,
360 int expected_min_bitrate_bps,
361 const char* start_bitrate_kbps,
362 int expected_start_bitrate_bps,
363 const char* max_bitrate_kbps,
364 int expected_max_bitrate_bps) {
365 EXPECT_TRUE(SetupSendStream());
366 auto& codecs = send_parameters_.codecs;
367 codecs.clear();
368 codecs.push_back(kOpusCodec);
369 codecs[0].params[cricket::kCodecParamMinBitrate] = min_bitrate_kbps;
370 codecs[0].params[cricket::kCodecParamStartBitrate] = start_bitrate_kbps;
371 codecs[0].params[cricket::kCodecParamMaxBitrate] = max_bitrate_kbps;
372 SetSendParameters(send_parameters_);
373
374 EXPECT_EQ(expected_min_bitrate_bps,
375 call_.GetConfig().bitrate_config.min_bitrate_bps);
376 EXPECT_EQ(expected_start_bitrate_bps,
377 call_.GetConfig().bitrate_config.start_bitrate_bps);
378 EXPECT_EQ(expected_max_bitrate_bps,
379 call_.GetConfig().bitrate_config.max_bitrate_bps);
380 }
381
359 void TestSetSendRtpHeaderExtensions(const std::string& ext) { 382 void TestSetSendRtpHeaderExtensions(const std::string& ext) {
360 EXPECT_TRUE(SetupSendStream()); 383 EXPECT_TRUE(SetupSendStream());
361 384
362 // Ensure extensions are off by default. 385 // Ensure extensions are off by default.
363 EXPECT_EQ(0u, GetSendStreamConfig(kSsrc1).rtp.extensions.size()); 386 EXPECT_EQ(0u, GetSendStreamConfig(kSsrc1).rtp.extensions.size());
364 387
365 // Ensure unknown extensions won't cause an error. 388 // Ensure unknown extensions won't cause an error.
366 send_parameters_.extensions.push_back( 389 send_parameters_.extensions.push_back(
367 webrtc::RtpExtension("urn:ietf:params:unknownextention", 1)); 390 webrtc::RtpExtension("urn:ietf:params:unknownextention", 1));
368 SetSendParameters(send_parameters_); 391 SetSendParameters(send_parameters_);
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 // Ignore if larger than 510000. 1418 // Ignore if larger than 510000.
1396 parameters.codecs[0].params["maxaveragebitrate"] = "510001"; 1419 parameters.codecs[0].params["maxaveragebitrate"] = "510001";
1397 SetSendParameters(parameters); 1420 SetSendParameters(parameters);
1398 EXPECT_EQ(510000, GetCodecBitrate(kSsrc1)); 1421 EXPECT_EQ(510000, GetCodecBitrate(kSsrc1));
1399 1422
1400 parameters.codecs[0].params["maxaveragebitrate"] = "200000"; 1423 parameters.codecs[0].params["maxaveragebitrate"] = "200000";
1401 SetSendParameters(parameters); 1424 SetSendParameters(parameters);
1402 EXPECT_EQ(200000, GetCodecBitrate(kSsrc1)); 1425 EXPECT_EQ(200000, GetCodecBitrate(kSsrc1));
1403 } 1426 }
1404 1427
1428 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithBitrates) {
1429 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200",
1430 200000);
1431 }
1432
1433 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithHighMaxBitrate) {
1434 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000);
1435 }
1436
1437 TEST_F(WebRtcVoiceEngineTestFake,
1438 SetSendCodecsWithoutBitratesUsesCorrectDefaults) {
1439 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "", -1);
1440 }
1441
1442 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCapsMinAndStartBitrate) {
1443 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1);
1444 }
1445
1446 TEST_F(WebRtcVoiceEngineTestFake,
1447 SetMaxSendBandwidthShouldPreserveOtherBitrates) {
1448 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200",
1449 200000);
1450 send_parameters_.max_bandwidth_bps = 300000;
1451 SetSendParameters(send_parameters_);
1452 EXPECT_EQ(100000, call_.GetConfig().bitrate_config.min_bitrate_bps)
1453 << "Setting max bitrate should keep previous min bitrate.";
1454 EXPECT_EQ(-1, call_.GetConfig().bitrate_config.start_bitrate_bps)
1455 << "Setting max bitrate should not reset start bitrate.";
1456 EXPECT_EQ(300000, call_.GetConfig().bitrate_config.max_bitrate_bps);
1457 }
1458
1405 // Test that we can enable NACK with opus as caller. 1459 // Test that we can enable NACK with opus as caller.
1406 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { 1460 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) {
1407 EXPECT_TRUE(SetupSendStream()); 1461 EXPECT_TRUE(SetupSendStream());
1408 cricket::AudioSendParameters parameters; 1462 cricket::AudioSendParameters parameters;
1409 parameters.codecs.push_back(kOpusCodec); 1463 parameters.codecs.push_back(kOpusCodec);
1410 parameters.codecs[0].AddFeedbackParam( 1464 parameters.codecs[0].AddFeedbackParam(
1411 cricket::FeedbackParam(cricket::kRtcpFbParamNack, 1465 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1412 cricket::kParamValueEmpty)); 1466 cricket::kParamValueEmpty));
1413 EXPECT_EQ(0, GetSendStreamConfig(kSsrc1).rtp.nack.rtp_history_ms); 1467 EXPECT_EQ(0, GetSendStreamConfig(kSsrc1).rtp.nack.rtp_history_ms);
1414 SetSendParameters(parameters); 1468 SetSendParameters(parameters);
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); 3606 nullptr, webrtc::CreateBuiltinAudioDecoderFactory());
3553 webrtc::RtcEventLogNullImpl event_log; 3607 webrtc::RtcEventLogNullImpl event_log;
3554 std::unique_ptr<webrtc::Call> call( 3608 std::unique_ptr<webrtc::Call> call(
3555 webrtc::Call::Create(webrtc::Call::Config(&event_log))); 3609 webrtc::Call::Create(webrtc::Call::Config(&event_log)));
3556 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3610 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3557 cricket::AudioOptions(), call.get()); 3611 cricket::AudioOptions(), call.get());
3558 cricket::AudioRecvParameters parameters; 3612 cricket::AudioRecvParameters parameters;
3559 parameters.codecs = engine.recv_codecs(); 3613 parameters.codecs = engine.recv_codecs();
3560 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3614 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3561 } 3615 }
OLDNEW
« webrtc/media/engine/webrtcvoiceengine.cc ('K') | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698