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(); | |
| 763 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | |
| 764 } | 762 } |
| 765 | 763 |
| 766 // Test that we can add a codec while playing. | 764 // Test that we can add a codec while playing. |
| 767 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { | 765 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { |
| 768 EXPECT_TRUE(SetupRecvStream()); | 766 EXPECT_TRUE(SetupRecvStream()); |
| 769 cricket::AudioRecvParameters parameters; | 767 cricket::AudioRecvParameters parameters; |
| 770 parameters.codecs.push_back(kIsacCodec); | 768 parameters.codecs.push_back(kIsacCodec); |
| 771 parameters.codecs.push_back(kCn16000Codec); | 769 parameters.codecs.push_back(kCn16000Codec); |
| 772 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 770 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 773 EXPECT_TRUE(channel_->SetPlayout(true)); | 771 channel_->SetPlayout(true); |
| 774 | 772 |
| 775 parameters.codecs.push_back(kOpusCodec); | 773 parameters.codecs.push_back(kOpusCodec); |
| 776 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 774 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 777 int channel_num = voe_.GetLastChannel(); | |
| 778 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | |
|
aleloi
2016/08/04 09:08:31
voe_ is a fake WebRTCVoiceEngine, which is a Voice
the sun
2016/08/04 09:44:44
I suggest you instead implement the Start()/Stop()
aleloi
2016/08/04 11:38:59
I did exactly as you suggested. The tests are back
| |
| 779 webrtc::CodecInst gcodec; | 775 webrtc::CodecInst gcodec; |
| 780 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &gcodec)); | 776 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &gcodec)); |
| 781 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); | 777 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); |
| 782 } | 778 } |
| 783 | 779 |
| 784 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { | 780 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { |
| 785 EXPECT_TRUE(SetupSendStream()); | 781 EXPECT_TRUE(SetupSendStream()); |
| 786 | 782 |
| 787 // Test that when autobw is enabled, bitrate is kept as the default | 783 // Test that when autobw is enabled, bitrate is kept as the default |
| 788 // value. autobw is enabled for the following tests because the target | 784 // value. autobw is enabled for the following tests because the target |
| (...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2163 // Turn off sending. | 2159 // Turn off sending. |
| 2164 SetSend(channel_, false); | 2160 SetSend(channel_, false); |
| 2165 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); | 2161 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); |
| 2166 | 2162 |
| 2167 // Changing RTP header extensions will recreate the AudioSendStream. | 2163 // Changing RTP header extensions will recreate the AudioSendStream. |
| 2168 send_parameters_.extensions.clear(); | 2164 send_parameters_.extensions.clear(); |
| 2169 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2165 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2170 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); | 2166 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); |
| 2171 } | 2167 } |
| 2172 | 2168 |
| 2173 // Test that we can create a channel and start playing out on it. | |
| 2174 TEST_F(WebRtcVoiceEngineTestFake, Playout) { | |
| 2175 EXPECT_TRUE(SetupRecvStream()); | |
| 2176 int channel_num = voe_.GetLastChannel(); | |
| 2177 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | |
| 2178 EXPECT_TRUE(channel_->SetPlayout(true)); | |
| 2179 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | |
| 2180 EXPECT_TRUE(channel_->SetPlayout(false)); | |
| 2181 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | |
| 2182 } | |
| 2183 | |
| 2184 // Test that we can add and remove send streams. | 2169 // Test that we can add and remove send streams. |
| 2185 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { | 2170 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { |
| 2186 SetupForMultiSendStream(); | 2171 SetupForMultiSendStream(); |
| 2187 | 2172 |
| 2188 // Set the global state for sending. | 2173 // Set the global state for sending. |
| 2189 SetSend(channel_, true); | 2174 SetSend(channel_, true); |
| 2190 | 2175 |
| 2191 for (uint32_t ssrc : kSsrcs4) { | 2176 for (uint32_t ssrc : kSsrcs4) { |
| 2192 EXPECT_TRUE(channel_->AddSendStream( | 2177 EXPECT_TRUE(channel_->AddSendStream( |
| 2193 cricket::StreamParams::CreateLegacy(ssrc))); | 2178 cricket::StreamParams::CreateLegacy(ssrc))); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2321 cricket::VoiceMediaInfo info; | 2306 cricket::VoiceMediaInfo info; |
| 2322 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2307 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2323 SetAudioReceiveStreamStats(); | 2308 SetAudioReceiveStreamStats(); |
| 2324 EXPECT_EQ(true, channel_->GetStats(&info)); | 2309 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2325 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size()); | 2310 EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size()); |
| 2326 EXPECT_EQ(1u, info.receivers.size()); | 2311 EXPECT_EQ(1u, info.receivers.size()); |
| 2327 VerifyVoiceReceiverInfo(info.receivers[0]); | 2312 VerifyVoiceReceiverInfo(info.receivers[0]); |
| 2328 } | 2313 } |
| 2329 } | 2314 } |
| 2330 | 2315 |
| 2331 // 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. | |
| 2333 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { | |
| 2334 EXPECT_TRUE(SetupSendStream()); | |
| 2335 int channel_num1 = voe_.GetLastChannel(); | |
| 2336 | |
| 2337 // Start playout without a receive stream. | |
| 2338 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
| 2339 EXPECT_TRUE(channel_->SetPlayout(true)); | |
| 2340 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | |
| 2341 | |
| 2342 // Adding another stream should enable playout on the new stream only. | |
| 2343 EXPECT_TRUE(AddRecvStream(kSsrc2)); | |
| 2344 int channel_num2 = voe_.GetLastChannel(); | |
| 2345 SetSend(channel_, true); | |
| 2346 EXPECT_TRUE(GetSendStream(kSsrc1).IsSending()); | |
| 2347 | |
| 2348 // Make sure only the new stream is played out. | |
| 2349 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | |
| 2350 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | |
| 2351 | |
| 2352 // Adding yet another stream should have stream 2 and 3 enabled for playout. | |
| 2353 EXPECT_TRUE(AddRecvStream(kSsrc3)); | |
| 2354 int channel_num3 = voe_.GetLastChannel(); | |
| 2355 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | |
| 2356 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | |
| 2357 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); | |
| 2358 | |
| 2359 // Stop sending. | |
| 2360 SetSend(channel_, false); | |
| 2361 EXPECT_FALSE(GetSendStream(kSsrc1).IsSending()); | |
| 2362 | |
| 2363 // Stop playout. | |
| 2364 EXPECT_TRUE(channel_->SetPlayout(false)); | |
| 2365 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | |
| 2366 EXPECT_FALSE(voe_.GetPlayout(channel_num2)); | |
| 2367 EXPECT_FALSE(voe_.GetPlayout(channel_num3)); | |
| 2368 | |
| 2369 // Restart playout and make sure only recv streams are played out. | |
| 2370 EXPECT_TRUE(channel_->SetPlayout(true)); | |
| 2371 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | |
| 2372 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | |
| 2373 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); | |
| 2374 | |
| 2375 // Now remove the recv streams and verify that the send stream doesn't play. | |
| 2376 EXPECT_TRUE(channel_->RemoveRecvStream(3)); | |
| 2377 EXPECT_TRUE(channel_->RemoveRecvStream(2)); | |
| 2378 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | |
| 2379 } | |
| 2380 | |
| 2381 // Test that we can create a channel configured for Codian bridges, | 2316 // Test that we can create a channel configured for Codian bridges, |
| 2382 // and start sending on it. | 2317 // and start sending on it. |
| 2383 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { | 2318 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { |
| 2384 EXPECT_TRUE(SetupSendStream()); | 2319 EXPECT_TRUE(SetupSendStream()); |
| 2385 cricket::AudioOptions options_adjust_agc; | 2320 cricket::AudioOptions options_adjust_agc; |
| 2386 options_adjust_agc.adjust_agc_delta = rtc::Optional<int>(-10); | 2321 options_adjust_agc.adjust_agc_delta = rtc::Optional<int>(-10); |
| 2387 webrtc::AgcConfig agc_config; | 2322 webrtc::AgcConfig agc_config; |
| 2388 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2323 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
| 2389 EXPECT_EQ(0, agc_config.targetLeveldBOv); | 2324 EXPECT_EQ(0, agc_config.targetLeveldBOv); |
| 2390 send_parameters_.options = options_adjust_agc; | 2325 send_parameters_.options = options_adjust_agc; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2734 // Test the InsertDtmf on specified send stream as caller. | 2669 // Test the InsertDtmf on specified send stream as caller. |
| 2735 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { | 2670 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { |
| 2736 TestInsertDtmf(kSsrc1, true); | 2671 TestInsertDtmf(kSsrc1, true); |
| 2737 } | 2672 } |
| 2738 | 2673 |
| 2739 // Test the InsertDtmf on specified send stream as callee. | 2674 // Test the InsertDtmf on specified send stream as callee. |
| 2740 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { | 2675 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { |
| 2741 TestInsertDtmf(kSsrc1, false); | 2676 TestInsertDtmf(kSsrc1, false); |
| 2742 } | 2677 } |
| 2743 | 2678 |
| 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) { | 2679 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
| 2757 EXPECT_TRUE(SetupSendStream()); | 2680 EXPECT_TRUE(SetupSendStream()); |
| 2758 EXPECT_CALL(adm_, | 2681 EXPECT_CALL(adm_, |
| 2759 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); | 2682 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); |
| 2760 EXPECT_CALL(adm_, | 2683 EXPECT_CALL(adm_, |
| 2761 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); | 2684 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); |
| 2762 EXPECT_CALL(adm_, | 2685 EXPECT_CALL(adm_, |
| 2763 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); | 2686 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); |
| 2764 bool ec_enabled; | 2687 bool ec_enabled; |
| 2765 webrtc::EcModes ec_mode; | 2688 webrtc::EcModes ec_mode; |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3519 cricket::WebRtcVoiceEngine engine( | 3442 cricket::WebRtcVoiceEngine engine( |
| 3520 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3443 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); |
| 3521 std::unique_ptr<webrtc::Call> call( | 3444 std::unique_ptr<webrtc::Call> call( |
| 3522 webrtc::Call::Create(webrtc::Call::Config())); | 3445 webrtc::Call::Create(webrtc::Call::Config())); |
| 3523 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3446 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
| 3524 cricket::AudioOptions(), call.get()); | 3447 cricket::AudioOptions(), call.get()); |
| 3525 cricket::AudioRecvParameters parameters; | 3448 cricket::AudioRecvParameters parameters; |
| 3526 parameters.codecs = engine.recv_codecs(); | 3449 parameters.codecs = engine.recv_codecs(); |
| 3527 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3450 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3528 } | 3451 } |
| OLD | NEW |