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

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

Issue 1273363005: Add send transports to individual webrtc::Call streams. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase+comment 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/webrtcvideoengine2.cc ('k') | webrtc/audio_send_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 3336 matching lines...) Expand 10 before | Expand all | Expand 10 after
3347 CoUninitialize(); 3347 CoUninitialize();
3348 delete engine; 3348 delete engine;
3349 3349
3350 // Ensure refcount is 0. 3350 // Ensure refcount is 0.
3351 EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED)); 3351 EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED));
3352 CoUninitialize(); 3352 CoUninitialize();
3353 } 3353 }
3354 #endif 3354 #endif
3355 3355
3356 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { 3356 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) {
3357 cricket::FakeCall call(webrtc::Call::Config(nullptr)); 3357 cricket::FakeCall call((webrtc::Call::Config()));
3358 const uint32 kAudioSsrc = 123; 3358 const uint32 kAudioSsrc = 123;
3359 const std::string kSyncLabel = "AvSyncLabel"; 3359 const std::string kSyncLabel = "AvSyncLabel";
3360 3360
3361 EXPECT_TRUE(SetupEngine()); 3361 EXPECT_TRUE(SetupEngine());
3362 cricket::WebRtcVoiceMediaChannel* media_channel = 3362 cricket::WebRtcVoiceMediaChannel* media_channel =
3363 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3363 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3364 media_channel->SetCall(&call); 3364 media_channel->SetCall(&call);
3365 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); 3365 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc);
3366 sp.sync_label = kSyncLabel; 3366 sp.sync_label = kSyncLabel;
3367 // Creating two channels to make sure that sync label is set properly for both 3367 // Creating two channels to make sure that sync label is set properly for both
3368 // the default voice channel and following ones. 3368 // the default voice channel and following ones.
3369 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3369 EXPECT_TRUE(channel_->AddRecvStream(sp));
3370 sp.ssrcs[0] += 1; 3370 sp.ssrcs[0] += 1;
3371 EXPECT_TRUE(channel_->AddRecvStream(sp)); 3371 EXPECT_TRUE(channel_->AddRecvStream(sp));
3372 3372
3373 ASSERT_EQ(2, call.GetAudioReceiveStreams().size()); 3373 ASSERT_EQ(2, call.GetAudioReceiveStreams().size());
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, CanChangeCombinedBweOption) { 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()));
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(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3430 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2) 3430 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2)
3431 ->GetConfig() 3431 ->GetConfig()
3432 .combined_audio_video_bwe); 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, SetCallConfiguresAudioReceiveChannels) { 3437 TEST_F(WebRtcVoiceEngineTestFake, SetCallConfiguresAudioReceiveChannels) {
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()));
3441 cricket::FakeCall call2(webrtc::Call::Config(nullptr)); 3441 cricket::FakeCall call2((webrtc::Call::Config()));
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 EXPECT_TRUE(media_channel->AddRecvStream( 3448 EXPECT_TRUE(media_channel->AddRecvStream(
3449 cricket::StreamParams::CreateLegacy(kAudioSsrc1))); 3449 cricket::StreamParams::CreateLegacy(kAudioSsrc1)));
3450 EXPECT_TRUE(media_channel->AddRecvStream( 3450 EXPECT_TRUE(media_channel->AddRecvStream(
3451 cricket::StreamParams::CreateLegacy(kAudioSsrc2))); 3451 cricket::StreamParams::CreateLegacy(kAudioSsrc2)));
(...skipping 15 matching lines...) Expand all
3467 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc2)); 3467 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc2));
3468 3468
3469 // Unregister - should be disabled again. 3469 // Unregister - should be disabled again.
3470 media_channel->SetCall(nullptr); 3470 media_channel->SetCall(nullptr);
3471 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); 3471 EXPECT_EQ(0, call.GetAudioReceiveStreams().size());
3472 } 3472 }
3473 3473
3474 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { 3474 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
3475 // Test that adding receive streams after enabling combined bandwidth 3475 // Test that adding receive streams after enabling combined bandwidth
3476 // estimation will correctly configure each channel. 3476 // estimation will correctly configure each channel.
3477 cricket::FakeCall call(webrtc::Call::Config(nullptr)); 3477 cricket::FakeCall call((webrtc::Call::Config()));
3478 3478
3479 EXPECT_TRUE(SetupEngine()); 3479 EXPECT_TRUE(SetupEngine());
3480 cricket::WebRtcVoiceMediaChannel* media_channel = 3480 cricket::WebRtcVoiceMediaChannel* media_channel =
3481 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); 3481 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
3482 media_channel->SetCall(&call); 3482 media_channel->SetCall(&call);
3483 cricket::AudioOptions options; 3483 cricket::AudioOptions options;
3484 options.combined_audio_video_bwe.Set(true); 3484 options.combined_audio_video_bwe.Set(true);
3485 EXPECT_TRUE(media_channel->SetOptions(options)); 3485 EXPECT_TRUE(media_channel->SetOptions(options));
3486 3486
3487 static const uint32 kSsrcs[] = {1, 2, 3, 4}; 3487 static const uint32 kSsrcs[] = {1, 2, 3, 4};
3488 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { 3488 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) {
3489 EXPECT_TRUE(media_channel->AddRecvStream( 3489 EXPECT_TRUE(media_channel->AddRecvStream(
3490 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); 3490 cricket::StreamParams::CreateLegacy(kSsrcs[i])));
3491 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kSsrcs[i])); 3491 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kSsrcs[i]));
3492 EXPECT_TRUE(call.GetAudioReceiveStream(kSsrcs[i]) 3492 EXPECT_TRUE(call.GetAudioReceiveStream(kSsrcs[i])
3493 ->GetConfig() 3493 ->GetConfig()
3494 .combined_audio_video_bwe); 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, ConfiguresAudioReceiveStreamRtpExtensions) { 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()));
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 for (uint32 ssrc : ssrcs) { 3514 for (uint32 ssrc : ssrcs) {
3515 EXPECT_TRUE(media_channel->AddRecvStream( 3515 EXPECT_TRUE(media_channel->AddRecvStream(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3549 const auto* s = call.GetAudioReceiveStream(ssrc); 3549 const auto* s = call.GetAudioReceiveStream(ssrc);
3550 EXPECT_NE(nullptr, s); 3550 EXPECT_NE(nullptr, s);
3551 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); 3551 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size());
3552 } 3552 }
3553 3553
3554 media_channel->SetCall(nullptr); 3554 media_channel->SetCall(nullptr);
3555 } 3555 }
3556 3556
3557 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { 3557 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) {
3558 // Test that packets are forwarded to the Call when configured accordingly. 3558 // Test that packets are forwarded to the Call when configured accordingly.
3559 cricket::FakeCall call(webrtc::Call::Config(nullptr)); 3559 cricket::FakeCall call((webrtc::Call::Config()));
3560 const uint32 kAudioSsrc = 1; 3560 const uint32 kAudioSsrc = 1;
3561 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); 3561 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame));
3562 static const unsigned char kRtcp[] = { 3562 static const unsigned char kRtcp[] = {
3563 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 3563 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
3564 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 3564 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3565 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 3565 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3566 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 3566 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
3567 }; 3567 };
3568 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); 3568 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp));
3569 3569
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3656 // 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
3657 // 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
3658 // default channel can be associated. However, the default is not deletable. 3658 // default channel can be associated. However, the default is not deletable.
3659 // 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.
3660 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch)); 3660 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch));
3661 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch); 3661 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch);
3662 3662
3663 EXPECT_TRUE(channel_->RemoveSendStream(2)); 3663 EXPECT_TRUE(channel_->RemoveSendStream(2));
3664 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); 3664 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1);
3665 } 3665 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | webrtc/audio_send_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698