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

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

Issue 1256803004: Control combined_audio_video_bwe with config bool. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 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') | webrtc/audio_receive_stream.h » ('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 3363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 EXPECT_EQ(kSyncLabel, 3374 EXPECT_EQ(kSyncLabel,
3375 call.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) 3375 call.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group)
3376 << "SyncGroup should be set based on sync_label"; 3376 << "SyncGroup should be set based on sync_label";
3377 EXPECT_EQ(kSyncLabel, 3377 EXPECT_EQ(kSyncLabel,
3378 call.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) 3378 call.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group)
3379 << "SyncGroup should be set based on sync_label"; 3379 << "SyncGroup should be set based on sync_label";
3380 3380
3381 media_channel->SetCall(nullptr); 3381 media_channel->SetCall(nullptr);
3382 } 3382 }
3383 3383
3384 TEST_F(WebRtcVoiceEngineTestFake, ChangeCombinedBweOption_Call) { 3384 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) {
3385 // Test that changing the combined_audio_video_bwe option results in the 3385 // Test that changing the combined_audio_video_bwe option results in the
3386 // expected state changes on an associated Call. 3386 // expected state changes on an associated Call.
3387 cricket::FakeCall call(webrtc::Call::Config(nullptr)); 3387 cricket::FakeCall call(webrtc::Call::Config(nullptr));
3388 const uint32 kAudioSsrc1 = 223; 3388 const uint32 kAudioSsrc1 = 223;
3389 const uint32 kAudioSsrc2 = 224; 3389 const uint32 kAudioSsrc2 = 224;
3390 3390
3391 EXPECT_TRUE(SetupEngine()); 3391 EXPECT_TRUE(SetupEngine());
3392 cricket::WebRtcVoiceMediaChannel* media_channel = 3392 cricket::WebRtcVoiceMediaChannel* media_channel =
3393 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3393 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3394 const auto& rtp_extensions = engine_.rtp_header_extensions(); 3394 const auto& rtp_extensions = engine_.rtp_header_extensions();
3395 media_channel->SetRecvRtpHeaderExtensions(rtp_extensions); 3395 media_channel->SetRecvRtpHeaderExtensions(rtp_extensions);
3396 media_channel->SetCall(&call); 3396 media_channel->SetCall(&call);
3397 EXPECT_TRUE(media_channel->AddRecvStream( 3397 EXPECT_TRUE(media_channel->AddRecvStream(
3398 cricket::StreamParams::CreateLegacy(kAudioSsrc1))); 3398 cricket::StreamParams::CreateLegacy(kAudioSsrc1)));
3399 EXPECT_TRUE(media_channel->AddRecvStream( 3399 EXPECT_TRUE(media_channel->AddRecvStream(
3400 cricket::StreamParams::CreateLegacy(kAudioSsrc2))); 3400 cricket::StreamParams::CreateLegacy(kAudioSsrc2)));
3401 3401
3402 // Combined BWE should not be set up yet (no RTP extensions). 3402 // Combined BWE should not be set up yet.
3403 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3403 EXPECT_EQ(2, call.GetAudioReceiveStreams().size());
3404 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc1) 3404 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1)
3405 ->GetConfig() 3405 ->GetConfig()
3406 .rtp.extensions.empty()); 3406 .combined_audio_video_bwe);
3407 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc2) 3407 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2)
3408 ->GetConfig() 3408 ->GetConfig()
3409 .rtp.extensions.empty()); 3409 .combined_audio_video_bwe);
3410 3410
3411 // Enable combined BWE option - now it should be set up. 3411 // Enable combined BWE option - now it should be set up.
3412 cricket::AudioOptions options; 3412 cricket::AudioOptions options;
3413 options.combined_audio_video_bwe.Set(true); 3413 options.combined_audio_video_bwe.Set(true);
3414 EXPECT_TRUE(media_channel->SetOptions(options)); 3414 EXPECT_TRUE(media_channel->SetOptions(options));
3415 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3415 EXPECT_EQ(2, call.GetAudioReceiveStreams().size());
3416 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1) 3416 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc1)
3417 ->GetConfig() 3417 ->GetConfig()
3418 .rtp.extensions.empty()); 3418 .combined_audio_video_bwe);
3419 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2) 3419 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc2)
3420 ->GetConfig() 3420 ->GetConfig()
3421 .rtp.extensions.empty()); 3421 .combined_audio_video_bwe);
3422 3422
3423 // Disable combined BWE option - should be disabled again. 3423 // Disable combined BWE option - should be disabled again.
3424 options.combined_audio_video_bwe.Set(false); 3424 options.combined_audio_video_bwe.Set(false);
3425 EXPECT_TRUE(media_channel->SetOptions(options)); 3425 EXPECT_TRUE(media_channel->SetOptions(options));
3426 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3426 EXPECT_EQ(2, call.GetAudioReceiveStreams().size());
3427 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc1) 3427 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1)
3428 ->GetConfig() 3428 ->GetConfig()
3429 .rtp.extensions.empty()); 3429 .combined_audio_video_bwe);
3430 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc2) 3430 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2)
3431 ->GetConfig() 3431 ->GetConfig()
3432 .rtp.extensions.empty()); 3432 .combined_audio_video_bwe);
3433 3433
3434 media_channel->SetCall(nullptr); 3434 media_channel->SetCall(nullptr);
3435 } 3435 }
3436 3436
3437 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBwe_Call) { 3437 TEST_F(WebRtcVoiceEngineTestFake, SetCall) {
stefan-webrtc 2015/07/24 09:57:46 Rename
3438 // Test that calling SetCall() on the voice media channel results in the 3438 // Test that calling SetCall() on the voice media channel results in the
3439 // expected state changes in Call. 3439 // expected state changes in Call.
3440 cricket::FakeCall call(webrtc::Call::Config(nullptr)); 3440 cricket::FakeCall call(webrtc::Call::Config(nullptr));
3441 cricket::FakeCall call2(webrtc::Call::Config(nullptr)); 3441 cricket::FakeCall call2(webrtc::Call::Config(nullptr));
3442 const uint32 kAudioSsrc1 = 223; 3442 const uint32 kAudioSsrc1 = 223;
3443 const uint32 kAudioSsrc2 = 224; 3443 const uint32 kAudioSsrc2 = 224;
3444 3444
3445 EXPECT_TRUE(SetupEngine()); 3445 EXPECT_TRUE(SetupEngine());
3446 cricket::WebRtcVoiceMediaChannel* media_channel = 3446 cricket::WebRtcVoiceMediaChannel* media_channel =
3447 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3447 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3448 cricket::AudioOptions options;
3449 options.combined_audio_video_bwe.Set(true);
3450 EXPECT_TRUE(media_channel->SetOptions(options));
3451 EXPECT_TRUE(media_channel->AddRecvStream( 3448 EXPECT_TRUE(media_channel->AddRecvStream(
3452 cricket::StreamParams::CreateLegacy(kAudioSsrc1))); 3449 cricket::StreamParams::CreateLegacy(kAudioSsrc1)));
3453 EXPECT_TRUE(media_channel->AddRecvStream( 3450 EXPECT_TRUE(media_channel->AddRecvStream(
3454 cricket::StreamParams::CreateLegacy(kAudioSsrc2))); 3451 cricket::StreamParams::CreateLegacy(kAudioSsrc2)));
3455 3452
3456 // Combined BWE should not be set up yet. 3453 // Combined BWE should not be set up yet.
3457 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); 3454 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3458 3455
3459 // Register - should be enabled. 3456 // Register - should be enabled.
3460 media_channel->SetCall(&call); 3457 media_channel->SetCall(&call);
3461 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3458 EXPECT_EQ(2, call.GetAudioReceiveStreams().size());
3462 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc1)); 3459 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc1));
3463 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc2)); 3460 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc2));
3464 3461
3465 // Re-register - should now be enabled on new call. 3462 // Re-register - should now be enabled on new call.
3466 media_channel->SetCall(&call2); 3463 media_channel->SetCall(&call2);
3467 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); 3464 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3468 EXPECT_EQ(2, call2.GetAudioReceiveStreams().size()); 3465 EXPECT_EQ(2, call2.GetAudioReceiveStreams().size());
3469 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc1)); 3466 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc1));
3470 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc2)); 3467 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc2));
3471 3468
3472 // Unregister - should be disabled again. 3469 // Unregister - should be disabled again.
3473 media_channel->SetCall(nullptr); 3470 media_channel->SetCall(nullptr);
3474 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); 3471 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3475 } 3472 }
3476 3473
3477 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams_Call) { 3474 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
3478 // Test that adding receive streams after enabling combined bandwidth 3475 // Test that adding receive streams after enabling combined bandwidth
3479 // estimation will correctly configure each channel. 3476 // estimation will correctly configure each channel.
3480 cricket::FakeCall call(webrtc::Call::Config(nullptr)); 3477 cricket::FakeCall call(webrtc::Call::Config(nullptr));
3481 3478
3482 EXPECT_TRUE(SetupEngine()); 3479 EXPECT_TRUE(SetupEngine());
3483 cricket::WebRtcVoiceMediaChannel* media_channel = 3480 cricket::WebRtcVoiceMediaChannel* media_channel =
3484 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3481 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3485 media_channel->SetCall(&call); 3482 media_channel->SetCall(&call);
3486 cricket::AudioOptions options; 3483 cricket::AudioOptions options;
3487 options.combined_audio_video_bwe.Set(true); 3484 options.combined_audio_video_bwe.Set(true);
3488 EXPECT_TRUE(media_channel->SetOptions(options)); 3485 EXPECT_TRUE(media_channel->SetOptions(options));
3489 3486
3490 static const uint32 kSsrcs[] = {1, 2, 3, 4}; 3487 static const uint32 kSsrcs[] = {1, 2, 3, 4};
3491 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { 3488 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) {
3492 EXPECT_TRUE(media_channel->AddRecvStream( 3489 EXPECT_TRUE(media_channel->AddRecvStream(
3493 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); 3490 cricket::StreamParams::CreateLegacy(kSsrcs[i])));
3494 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kSsrcs[i])); 3491 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kSsrcs[i]));
3492 EXPECT_TRUE(call.GetAudioReceiveStream(kSsrcs[i])
3493 ->GetConfig()
3494 .combined_audio_video_bwe);
3495 } 3495 }
3496 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call.GetAudioReceiveStreams().size()); 3496 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call.GetAudioReceiveStreams().size());
3497 3497
3498 media_channel->SetCall(nullptr); 3498 media_channel->SetCall(nullptr);
3499 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); 3499 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3500 } 3500 }
3501 3501
3502 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweExtensions_Call) { 3502 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
3503 // Test that setting the header extensions results in the expected state 3503 // Test that setting the header extensions results in the expected state
3504 // changes on an associated Call. 3504 // changes on an associated Call.
3505 cricket::FakeCall call(webrtc::Call::Config(nullptr)); 3505 cricket::FakeCall call(webrtc::Call::Config(nullptr));
3506 std::vector<uint32> ssrcs; 3506 std::vector<uint32> ssrcs;
3507 ssrcs.push_back(223); 3507 ssrcs.push_back(223);
3508 ssrcs.push_back(224); 3508 ssrcs.push_back(224);
3509 3509
3510 EXPECT_TRUE(SetupEngine()); 3510 EXPECT_TRUE(SetupEngine());
3511 cricket::WebRtcVoiceMediaChannel* media_channel = 3511 cricket::WebRtcVoiceMediaChannel* media_channel =
3512 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3512 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3513 media_channel->SetCall(&call); 3513 media_channel->SetCall(&call);
3514 cricket::AudioOptions options;
3515 options.combined_audio_video_bwe.Set(true);
3516 EXPECT_TRUE(media_channel->SetOptions(options));
3517 for (uint32 ssrc : ssrcs) { 3514 for (uint32 ssrc : ssrcs) {
3518 EXPECT_TRUE(media_channel->AddRecvStream( 3515 EXPECT_TRUE(media_channel->AddRecvStream(
3519 cricket::StreamParams::CreateLegacy(ssrc))); 3516 cricket::StreamParams::CreateLegacy(ssrc)));
3520 } 3517 }
3521 3518
3522 // Combined BWE should be set up, but with no configured extensions. 3519 // Combined BWE should be set up, but with no configured extensions.
3523 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); 3520 EXPECT_EQ(2, call.GetAudioReceiveStreams().size());
3524 for (uint32 ssrc : ssrcs) { 3521 for (uint32 ssrc : ssrcs) {
3525 const auto* s = call.GetAudioReceiveStream(ssrc); 3522 const auto* s = call.GetAudioReceiveStream(ssrc);
3526 EXPECT_NE(nullptr, s); 3523 EXPECT_NE(nullptr, s);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3659 // deleting logic, i.e., deleting |send_ch| will reset the associate send 3656 // deleting logic, i.e., deleting |send_ch| will reset the associate send
3660 // channel of |recv_ch|.This is not a common case, since, normally, only the 3657 // channel of |recv_ch|.This is not a common case, since, normally, only the
3661 // default channel can be associated. However, the default is not deletable. 3658 // default channel can be associated. However, the default is not deletable.
3662 // So we force the |recv_ch| to associate with a non-default channel. 3659 // So we force the |recv_ch| to associate with a non-default channel.
3663 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch)); 3660 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch));
3664 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch); 3661 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch);
3665 3662
3666 EXPECT_TRUE(channel_->RemoveSendStream(2)); 3663 EXPECT_TRUE(channel_->RemoveSendStream(2));
3667 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); 3664 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1);
3668 } 3665 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | webrtc/audio_receive_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698