Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 EXPECT_STREQ("ISAC", gcodec.plname); | 746 EXPECT_STREQ("ISAC", gcodec.plname); |
| 747 } | 747 } |
| 748 | 748 |
| 749 // Test that we can apply the same set of codecs again while playing. | 749 // Test that we can apply the same set of codecs again while playing. |
| 750 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { | 750 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { |
| 751 EXPECT_TRUE(SetupRecvStream()); | 751 EXPECT_TRUE(SetupRecvStream()); |
| 752 cricket::AudioRecvParameters parameters; | 752 cricket::AudioRecvParameters parameters; |
| 753 parameters.codecs.push_back(kIsacCodec); | 753 parameters.codecs.push_back(kIsacCodec); |
| 754 parameters.codecs.push_back(kCn16000Codec); | 754 parameters.codecs.push_back(kCn16000Codec); |
| 755 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 755 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 756 EXPECT_TRUE(channel_->SetPlayout(true)); | 756 channel_->SetPlayout(true); |
| 757 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 757 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 758 | 758 |
| 759 // Changing the payload type of a codec should fail. | 759 // Changing the payload type of a codec should fail. |
| 760 parameters.codecs[0].id = 127; | 760 parameters.codecs[0].id = 127; |
| 761 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); | 761 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
| 762 int channel_num = voe_.GetLastChannel(); | 762 EXPECT_TRUE(GetRecvStream(kSsrc1).started()); |
| 763 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | |
| 764 } | 763 } |
| 765 | 764 |
| 766 // Test that we can add a codec while playing. | 765 // Test that we can add a codec while playing. |
| 767 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { | 766 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { |
| 768 EXPECT_TRUE(SetupRecvStream()); | 767 EXPECT_TRUE(SetupRecvStream()); |
| 769 cricket::AudioRecvParameters parameters; | 768 cricket::AudioRecvParameters parameters; |
| 770 parameters.codecs.push_back(kIsacCodec); | 769 parameters.codecs.push_back(kIsacCodec); |
| 771 parameters.codecs.push_back(kCn16000Codec); | 770 parameters.codecs.push_back(kCn16000Codec); |
| 772 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 771 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 773 EXPECT_TRUE(channel_->SetPlayout(true)); | 772 channel_->SetPlayout(true); |
| 774 | 773 |
| 775 parameters.codecs.push_back(kOpusCodec); | 774 parameters.codecs.push_back(kOpusCodec); |
| 776 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 775 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 777 int channel_num = voe_.GetLastChannel(); | 776 EXPECT_TRUE(GetRecvStream(kSsrc1).started()); |
| 778 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | |
| 779 webrtc::CodecInst gcodec; | 777 webrtc::CodecInst gcodec; |
| 780 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &gcodec)); | 778 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &gcodec)); |
| 781 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); | 779 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); |
| 782 } | 780 } |
| 783 | 781 |
| 784 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { | 782 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { |
| 785 EXPECT_TRUE(SetupSendStream()); | 783 EXPECT_TRUE(SetupSendStream()); |
| 786 | 784 |
| 787 // Test that when autobw is enabled, bitrate is kept as the default | 785 // Test that when autobw is enabled, bitrate is kept as the default |
| 788 // value. autobw is enabled for the following tests because the target | 786 // value. autobw is enabled for the following tests because the target |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2166 | 2164 |
| 2167 // Changing RTP header extensions will recreate the AudioSendStream. | 2165 // Changing RTP header extensions will recreate the AudioSendStream. |
| 2168 send_parameters_.extensions.clear(); | 2166 send_parameters_.extensions.clear(); |
| 2169 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2167 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2170 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); | 2168 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); |
| 2171 } | 2169 } |
| 2172 | 2170 |
| 2173 // Test that we can create a channel and start playing out on it. | 2171 // Test that we can create a channel and start playing out on it. |
| 2174 TEST_F(WebRtcVoiceEngineTestFake, Playout) { | 2172 TEST_F(WebRtcVoiceEngineTestFake, Playout) { |
| 2175 EXPECT_TRUE(SetupRecvStream()); | 2173 EXPECT_TRUE(SetupRecvStream()); |
| 2176 int channel_num = voe_.GetLastChannel(); | |
| 2177 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | 2174 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
| 2178 EXPECT_TRUE(channel_->SetPlayout(true)); | 2175 channel_->SetPlayout(true); |
| 2179 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2176 EXPECT_TRUE(GetRecvStream(kSsrc1).started()); |
| 2180 EXPECT_TRUE(channel_->SetPlayout(false)); | 2177 channel_->SetPlayout(false); |
| 2181 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | 2178 EXPECT_FALSE(GetRecvStream(kSsrc1).started()); |
| 2182 } | 2179 } |
| 2183 | 2180 |
| 2184 // Test that we can add and remove send streams. | 2181 // Test that we can add and remove send streams. |
| 2185 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { | 2182 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { |
| 2186 SetupForMultiSendStream(); | 2183 SetupForMultiSendStream(); |
| 2187 | 2184 |
| 2188 // Set the global state for sending. | 2185 // Set the global state for sending. |
| 2189 SetSend(channel_, true); | 2186 SetSend(channel_, true); |
| 2190 | 2187 |
| 2191 for (uint32_t ssrc : kSsrcs4) { | 2188 for (uint32_t ssrc : kSsrcs4) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2325 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size()); | 2322 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size()); |
| 2326 EXPECT_EQ(1u, info.receivers.size()); | 2323 EXPECT_EQ(1u, info.receivers.size()); |
| 2327 VerifyVoiceReceiverInfo(info.receivers[0]); | 2324 VerifyVoiceReceiverInfo(info.receivers[0]); |
| 2328 } | 2325 } |
| 2329 } | 2326 } |
| 2330 | 2327 |
| 2331 // Test that we can add and remove receive streams, and do proper send/playout. | 2328 // Test that we can add and remove receive streams, and do proper send/playout. |
| 2332 // We can receive on multiple streams while sending one stream. | 2329 // We can receive on multiple streams while sending one stream. |
| 2333 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { | 2330 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { |
| 2334 EXPECT_TRUE(SetupSendStream()); | 2331 EXPECT_TRUE(SetupSendStream()); |
| 2335 int channel_num1 = voe_.GetLastChannel(); | |
| 2336 | 2332 |
| 2337 // Start playout without a receive stream. | 2333 // Start playout without a receive stream. |
| 2338 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2334 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2339 EXPECT_TRUE(channel_->SetPlayout(true)); | 2335 channel_->SetPlayout(true); |
| 2340 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | |
| 2341 | 2336 |
| 2342 // Adding another stream should enable playout on the new stream only. | 2337 // Adding another stream should enable playout on the new stream only. |
| 2343 EXPECT_TRUE(AddRecvStream(kSsrc2)); | 2338 EXPECT_TRUE(AddRecvStream(kSsrc2)); |
| 2344 int channel_num2 = voe_.GetLastChannel(); | |
| 2345 SetSend(channel_, true); | 2339 SetSend(channel_, true); |
| 2346 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending()); | 2340 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending()); |
| 2347 | 2341 |
| 2348 // Make sure only the new stream is played out. | 2342 // Make sure only the new stream is played out. |
| 2349 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2343 EXPECT_TRUE(GetRecvStream(kSsrc2).started()); |
| 2350 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | |
| 2351 | 2344 |
| 2352 // Adding yet another stream should have stream 2 and 3 enabled for playout. | 2345 // Adding yet another stream should have stream 2 and 3 enabled for playout. |
| 2353 EXPECT_TRUE(AddRecvStream(kSsrc3)); | 2346 EXPECT_TRUE(AddRecvStream(kSsrc3)); |
| 2354 int channel_num3 = voe_.GetLastChannel(); | 2347 EXPECT_TRUE(GetRecvStream(kSsrc2).started()); |
| 2355 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2348 EXPECT_TRUE(GetRecvStream(kSsrc3).started()); |
| 2356 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | |
| 2357 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); | |
| 2358 | 2349 |
| 2359 // Stop sending. | 2350 // Stop sending. |
| 2360 SetSend(channel_, false); | 2351 SetSend(channel_, false); |
| 2361 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); | 2352 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); |
| 2362 | 2353 |
| 2363 // Stop playout. | 2354 // Stop playout. |
| 2364 EXPECT_TRUE(channel_->SetPlayout(false)); | 2355 channel_->SetPlayout(false); |
| 2365 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2356 EXPECT_FALSE(GetRecvStream(kSsrc2).started()); |
| 2366 EXPECT_FALSE(voe_.GetPlayout(channel_num2)); | 2357 EXPECT_FALSE(GetRecvStream(kSsrc3).started()); |
| 2367 EXPECT_FALSE(voe_.GetPlayout(channel_num3)); | |
| 2368 | 2358 |
| 2369 // Restart playout and make sure only recv streams are played out. | 2359 // Restart playout and make sure only recv streams are played out. |
|
the sun
2016/08/04 12:22:18
remove "only"
aleloi
2016/08/04 12:26:09
Done.
| |
| 2370 EXPECT_TRUE(channel_->SetPlayout(true)); | 2360 channel_->SetPlayout(true); |
| 2371 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2361 EXPECT_TRUE(GetRecvStream(kSsrc2).started()); |
| 2372 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | 2362 EXPECT_TRUE(GetRecvStream(kSsrc3).started()); |
| 2373 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); | |
| 2374 | 2363 |
| 2375 // Now remove the recv streams and verify that the send stream doesn't play. | 2364 // Now remove the recv streams and verify that the send stream doesn't play. |
|
the sun
2016/08/04 12:22:18
nit: comment is wrong
aleloi
2016/08/04 12:26:09
Done.
| |
| 2376 EXPECT_TRUE(channel_->RemoveRecvStream(3)); | 2365 EXPECT_TRUE(channel_->RemoveRecvStream(3)); |
| 2377 EXPECT_TRUE(channel_->RemoveRecvStream(2)); | 2366 EXPECT_TRUE(channel_->RemoveRecvStream(2)); |
| 2378 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | |
| 2379 } | 2367 } |
| 2380 | 2368 |
| 2381 // Test that we can create a channel configured for Codian bridges, | 2369 // Test that we can create a channel configured for Codian bridges, |
| 2382 // and start sending on it. | 2370 // and start sending on it. |
| 2383 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { | 2371 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { |
| 2384 EXPECT_TRUE(SetupSendStream()); | 2372 EXPECT_TRUE(SetupSendStream()); |
| 2385 cricket::AudioOptions options_adjust_agc; | 2373 cricket::AudioOptions options_adjust_agc; |
| 2386 options_adjust_agc.adjust_agc_delta = rtc::Optional<int>(-10); | 2374 options_adjust_agc.adjust_agc_delta = rtc::Optional<int>(-10); |
| 2387 webrtc::AgcConfig agc_config; | 2375 webrtc::AgcConfig agc_config; |
| 2388 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2376 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2734 // Test the InsertDtmf on specified send stream as caller. | 2722 // Test the InsertDtmf on specified send stream as caller. |
| 2735 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { | 2723 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { |
| 2736 TestInsertDtmf(kSsrc1, true); | 2724 TestInsertDtmf(kSsrc1, true); |
| 2737 } | 2725 } |
| 2738 | 2726 |
| 2739 // Test the InsertDtmf on specified send stream as callee. | 2727 // Test the InsertDtmf on specified send stream as callee. |
| 2740 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { | 2728 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { |
| 2741 TestInsertDtmf(kSsrc1, false); | 2729 TestInsertDtmf(kSsrc1, false); |
| 2742 } | 2730 } |
| 2743 | 2731 |
| 2744 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { | |
| 2745 EXPECT_TRUE(SetupSendStream()); | |
| 2746 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
| 2747 SetSend(channel_, true); | |
| 2748 EXPECT_TRUE(AddRecvStream(2)); | |
| 2749 EXPECT_TRUE(AddRecvStream(3)); | |
| 2750 EXPECT_TRUE(channel_->SetPlayout(true)); | |
| 2751 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); | |
| 2752 EXPECT_TRUE(channel_->SetPlayout(false)); | |
| 2753 EXPECT_FALSE(channel_->SetPlayout(true)); | |
| 2754 } | |
| 2755 | |
| 2756 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { | 2732 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
| 2757 EXPECT_TRUE(SetupSendStream()); | 2733 EXPECT_TRUE(SetupSendStream()); |
| 2758 EXPECT_CALL(adm_, | 2734 EXPECT_CALL(adm_, |
| 2759 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); | 2735 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); |
| 2760 EXPECT_CALL(adm_, | 2736 EXPECT_CALL(adm_, |
| 2761 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); | 2737 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); |
| 2762 EXPECT_CALL(adm_, | 2738 EXPECT_CALL(adm_, |
| 2763 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); | 2739 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); |
| 2764 bool ec_enabled; | 2740 bool ec_enabled; |
| 2765 webrtc::EcModes ec_mode; | 2741 webrtc::EcModes ec_mode; |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3519 cricket::WebRtcVoiceEngine engine( | 3495 cricket::WebRtcVoiceEngine engine( |
| 3520 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3496 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); |
| 3521 std::unique_ptr<webrtc::Call> call( | 3497 std::unique_ptr<webrtc::Call> call( |
| 3522 webrtc::Call::Create(webrtc::Call::Config())); | 3498 webrtc::Call::Create(webrtc::Call::Config())); |
| 3523 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3499 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
| 3524 cricket::AudioOptions(), call.get()); | 3500 cricket::AudioOptions(), call.get()); |
| 3525 cricket::AudioRecvParameters parameters; | 3501 cricket::AudioRecvParameters parameters; |
| 3526 parameters.codecs = engine.recv_codecs(); | 3502 parameters.codecs = engine.recv_codecs(); |
| 3527 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3503 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3528 } | 3504 } |
| OLD | NEW |