| OLD | NEW |
| 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 12 matching lines...) Expand all Loading... |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "webrtc/base/byteorder.h" | 28 #include "webrtc/base/byteorder.h" |
| 29 #include "webrtc/base/gunit.h" | 29 #include "webrtc/base/gunit.h" |
| 30 #include "webrtc/call.h" | 30 #include "webrtc/call.h" |
| 31 #include "talk/media/base/constants.h" | 31 #include "talk/media/base/constants.h" |
| 32 #include "talk/media/base/fakemediaengine.h" | 32 #include "talk/media/base/fakemediaengine.h" |
| 33 #include "talk/media/base/fakemediaprocessor.h" | |
| 34 #include "talk/media/base/fakenetworkinterface.h" | 33 #include "talk/media/base/fakenetworkinterface.h" |
| 35 #include "talk/media/base/fakertp.h" | 34 #include "talk/media/base/fakertp.h" |
| 36 #include "talk/media/webrtc/fakewebrtccall.h" | 35 #include "talk/media/webrtc/fakewebrtccall.h" |
| 37 #include "talk/media/webrtc/fakewebrtcvoiceengine.h" | 36 #include "talk/media/webrtc/fakewebrtcvoiceengine.h" |
| 38 #include "talk/media/webrtc/webrtcvoiceengine.h" | 37 #include "talk/media/webrtc/webrtcvoiceengine.h" |
| 39 #include "webrtc/p2p/base/fakesession.h" | 38 #include "webrtc/p2p/base/fakesession.h" |
| 40 #include "talk/session/media/channel.h" | 39 #include "talk/session/media/channel.h" |
| 41 | 40 |
| 42 // Tests for the WebRtcVoiceEngine/VoiceChannel code. | 41 // Tests for the WebRtcVoiceEngine/VoiceChannel code. |
| 43 | 42 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 62 static uint32 kSsrc2 = 0x98; | 61 static uint32 kSsrc2 = 0x98; |
| 63 | 62 |
| 64 class FakeVoEWrapper : public cricket::VoEWrapper { | 63 class FakeVoEWrapper : public cricket::VoEWrapper { |
| 65 public: | 64 public: |
| 66 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) | 65 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) |
| 67 : cricket::VoEWrapper(engine, // processing | 66 : cricket::VoEWrapper(engine, // processing |
| 68 engine, // base | 67 engine, // base |
| 69 engine, // codec | 68 engine, // codec |
| 70 engine, // dtmf | 69 engine, // dtmf |
| 71 engine, // hw | 70 engine, // hw |
| 72 engine, // media | |
| 73 engine, // neteq | 71 engine, // neteq |
| 74 engine, // network | 72 engine, // network |
| 75 engine, // rtp | 73 engine, // rtp |
| 76 engine, // sync | 74 engine, // sync |
| 77 engine) { // volume | 75 engine) { // volume |
| 78 } | 76 } |
| 79 }; | 77 }; |
| 80 | 78 |
| 81 class FakeVoETraceWrapper : public cricket::VoETraceWrapper { | 79 class FakeVoETraceWrapper : public cricket::VoETraceWrapper { |
| 82 public: | 80 public: |
| (...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2596 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2594 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2597 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2595 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
| 2598 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2596 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2599 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 2597 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
| 2600 EXPECT_TRUE(channel_->SetPlayout(true)); | 2598 EXPECT_TRUE(channel_->SetPlayout(true)); |
| 2601 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); | 2599 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); |
| 2602 EXPECT_TRUE(channel_->SetPlayout(false)); | 2600 EXPECT_TRUE(channel_->SetPlayout(false)); |
| 2603 EXPECT_FALSE(channel_->SetPlayout(true)); | 2601 EXPECT_FALSE(channel_->SetPlayout(true)); |
| 2604 } | 2602 } |
| 2605 | 2603 |
| 2606 // Test that the Registering/Unregistering with the | |
| 2607 // webrtcvoiceengine works as expected | |
| 2608 TEST_F(WebRtcVoiceEngineTestFake, RegisterVoiceProcessor) { | |
| 2609 EXPECT_TRUE(SetupEngine()); | |
| 2610 EXPECT_TRUE(channel_->AddRecvStream( | |
| 2611 cricket::StreamParams::CreateLegacy(kSsrc2))); | |
| 2612 cricket::FakeMediaProcessor vp_1; | |
| 2613 cricket::FakeMediaProcessor vp_2; | |
| 2614 | |
| 2615 EXPECT_FALSE(engine_.RegisterProcessor(kSsrc2, &vp_1, cricket::MPD_TX)); | |
| 2616 EXPECT_TRUE(engine_.RegisterProcessor(kSsrc2, &vp_1, cricket::MPD_RX)); | |
| 2617 EXPECT_TRUE(engine_.RegisterProcessor(kSsrc2, &vp_2, cricket::MPD_RX)); | |
| 2618 voe_.TriggerProcessPacket(cricket::MPD_RX); | |
| 2619 voe_.TriggerProcessPacket(cricket::MPD_TX); | |
| 2620 | |
| 2621 EXPECT_TRUE(voe_.IsExternalMediaProcessorRegistered()); | |
| 2622 EXPECT_EQ(1, vp_1.voice_frame_count()); | |
| 2623 EXPECT_EQ(1, vp_2.voice_frame_count()); | |
| 2624 | |
| 2625 EXPECT_TRUE(engine_.UnregisterProcessor(kSsrc2, | |
| 2626 &vp_2, | |
| 2627 cricket::MPD_RX)); | |
| 2628 voe_.TriggerProcessPacket(cricket::MPD_RX); | |
| 2629 EXPECT_TRUE(voe_.IsExternalMediaProcessorRegistered()); | |
| 2630 EXPECT_EQ(1, vp_2.voice_frame_count()); | |
| 2631 EXPECT_EQ(2, vp_1.voice_frame_count()); | |
| 2632 | |
| 2633 EXPECT_TRUE(engine_.UnregisterProcessor(kSsrc2, | |
| 2634 &vp_1, | |
| 2635 cricket::MPD_RX)); | |
| 2636 voe_.TriggerProcessPacket(cricket::MPD_RX); | |
| 2637 EXPECT_FALSE(voe_.IsExternalMediaProcessorRegistered()); | |
| 2638 EXPECT_EQ(2, vp_1.voice_frame_count()); | |
| 2639 | |
| 2640 EXPECT_FALSE(engine_.RegisterProcessor(kSsrc1, &vp_1, cricket::MPD_RX)); | |
| 2641 EXPECT_TRUE(engine_.RegisterProcessor(kSsrc1, &vp_1, cricket::MPD_TX)); | |
| 2642 voe_.TriggerProcessPacket(cricket::MPD_RX); | |
| 2643 voe_.TriggerProcessPacket(cricket::MPD_TX); | |
| 2644 EXPECT_TRUE(voe_.IsExternalMediaProcessorRegistered()); | |
| 2645 EXPECT_EQ(3, vp_1.voice_frame_count()); | |
| 2646 | |
| 2647 EXPECT_TRUE(engine_.UnregisterProcessor(kSsrc1, | |
| 2648 &vp_1, | |
| 2649 cricket::MPD_RX_AND_TX)); | |
| 2650 voe_.TriggerProcessPacket(cricket::MPD_TX); | |
| 2651 EXPECT_FALSE(voe_.IsExternalMediaProcessorRegistered()); | |
| 2652 EXPECT_EQ(3, vp_1.voice_frame_count()); | |
| 2653 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); | |
| 2654 EXPECT_FALSE(engine_.RegisterProcessor(kSsrc2, &vp_1, cricket::MPD_RX)); | |
| 2655 EXPECT_FALSE(voe_.IsExternalMediaProcessorRegistered()); | |
| 2656 | |
| 2657 // Test that we can register a processor on the receive channel on SSRC 0. | |
| 2658 // This tests the 1:1 case when the receive SSRC is unknown. | |
| 2659 EXPECT_TRUE(engine_.RegisterProcessor(0, &vp_1, cricket::MPD_RX)); | |
| 2660 voe_.TriggerProcessPacket(cricket::MPD_RX); | |
| 2661 EXPECT_TRUE(voe_.IsExternalMediaProcessorRegistered()); | |
| 2662 EXPECT_EQ(4, vp_1.voice_frame_count()); | |
| 2663 EXPECT_TRUE(engine_.UnregisterProcessor(0, | |
| 2664 &vp_1, | |
| 2665 cricket::MPD_RX)); | |
| 2666 | |
| 2667 // The following tests test that FindChannelNumFromSsrc is doing | |
| 2668 // what we expect. | |
| 2669 // pick an invalid ssrc and make sure we can't register | |
| 2670 EXPECT_FALSE(engine_.RegisterProcessor(99, | |
| 2671 &vp_1, | |
| 2672 cricket::MPD_RX)); | |
| 2673 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
| 2674 EXPECT_TRUE(engine_.RegisterProcessor(1, | |
| 2675 &vp_1, | |
| 2676 cricket::MPD_RX)); | |
| 2677 EXPECT_TRUE(engine_.UnregisterProcessor(1, | |
| 2678 &vp_1, | |
| 2679 cricket::MPD_RX)); | |
| 2680 EXPECT_FALSE(engine_.RegisterProcessor(1, | |
| 2681 &vp_1, | |
| 2682 cricket::MPD_TX)); | |
| 2683 EXPECT_TRUE(channel_->RemoveRecvStream(1)); | |
| 2684 } | |
| 2685 | |
| 2686 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { | 2604 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
| 2687 EXPECT_TRUE(SetupEngine()); | 2605 EXPECT_TRUE(SetupEngine()); |
| 2688 | 2606 |
| 2689 bool ec_enabled; | 2607 bool ec_enabled; |
| 2690 webrtc::EcModes ec_mode; | 2608 webrtc::EcModes ec_mode; |
| 2691 bool ec_metrics_enabled; | 2609 bool ec_metrics_enabled; |
| 2692 webrtc::AecmModes aecm_mode; | 2610 webrtc::AecmModes aecm_mode; |
| 2693 bool cng_enabled; | 2611 bool cng_enabled; |
| 2694 bool agc_enabled; | 2612 bool agc_enabled; |
| 2695 webrtc::AgcModes agc_mode; | 2613 webrtc::AgcModes agc_mode; |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3455 cricket::WebRtcVoiceEngine engine; | 3373 cricket::WebRtcVoiceEngine engine; |
| 3456 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3374 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
| 3457 rtc::scoped_ptr<webrtc::Call> call( | 3375 rtc::scoped_ptr<webrtc::Call> call( |
| 3458 webrtc::Call::Create(webrtc::Call::Config())); | 3376 webrtc::Call::Create(webrtc::Call::Config())); |
| 3459 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), | 3377 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), |
| 3460 call.get()); | 3378 call.get()); |
| 3461 cricket::AudioRecvParameters parameters; | 3379 cricket::AudioRecvParameters parameters; |
| 3462 parameters.codecs = engine.codecs(); | 3380 parameters.codecs = engine.codecs(); |
| 3463 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3381 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3464 } | 3382 } |
| OLD | NEW |