| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void SetSink(Sink* sink) override {} | 100 void SetSink(Sink* sink) override {} |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 class WebRtcVoiceEngineTestFake : public testing::Test { | 103 class WebRtcVoiceEngineTestFake : public testing::Test { |
| 104 public: | 104 public: |
| 105 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} | 105 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} |
| 106 | 106 |
| 107 explicit WebRtcVoiceEngineTestFake(const char* field_trials) | 107 explicit WebRtcVoiceEngineTestFake(const char* field_trials) |
| 108 : call_(webrtc::Call::Config(&event_log_)), voe_(&apm_), | 108 : call_(webrtc::Call::Config(&event_log_)), voe_(&apm_), |
| 109 override_field_trials_(field_trials) { | 109 override_field_trials_(field_trials) { |
| 110 auto factory = webrtc::MockAudioDecoderFactory::CreateUnusedFactory(); | |
| 111 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); | 110 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); |
| 112 EXPECT_CALL(adm_, Release()).WillOnce(Return(0)); | 111 EXPECT_CALL(adm_, Release()).WillOnce(Return(0)); |
| 113 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false)); | 112 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false)); |
| 114 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false)); | 113 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false)); |
| 115 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false)); | 114 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false)); |
| 116 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 115 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
| 117 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 116 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
| 118 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); | 117 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); |
| 119 engine_.reset(new cricket::WebRtcVoiceEngine(&adm_, factory, nullptr, | 118 // TODO(kwiberg): We should use a mock AudioDecoderFactory, but a bunch of |
| 120 new FakeVoEWrapper(&voe_))); | 119 // the tests here probe the specific set of codecs provided by the builtin |
| 120 // factory. Those tests should probably be moved elsewhere. |
| 121 engine_.reset(new cricket::WebRtcVoiceEngine( |
| 122 &adm_, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, |
| 123 new FakeVoEWrapper(&voe_))); |
| 121 send_parameters_.codecs.push_back(kPcmuCodec); | 124 send_parameters_.codecs.push_back(kPcmuCodec); |
| 122 recv_parameters_.codecs.push_back(kPcmuCodec); | 125 recv_parameters_.codecs.push_back(kPcmuCodec); |
| 123 } | 126 } |
| 124 | 127 |
| 125 bool SetupChannel() { | 128 bool SetupChannel() { |
| 126 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 129 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
| 127 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 130 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
| 128 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), | 131 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), |
| 129 cricket::AudioOptions()); | 132 cricket::AudioOptions()); |
| 130 return (channel_ != nullptr); | 133 return (channel_ != nullptr); |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 EXPECT_STREQ("telephone-event", gcodec.plname); | 869 EXPECT_STREQ("telephone-event", gcodec.plname); |
| 867 } | 870 } |
| 868 | 871 |
| 869 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { | 872 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { |
| 870 EXPECT_TRUE(SetupRecvStream()); | 873 EXPECT_TRUE(SetupRecvStream()); |
| 871 cricket::AudioRecvParameters parameters; | 874 cricket::AudioRecvParameters parameters; |
| 872 parameters.codecs.push_back(kIsacCodec); | 875 parameters.codecs.push_back(kIsacCodec); |
| 873 parameters.codecs[0].id = 106; // collide with existing CN 32k | 876 parameters.codecs[0].id = 106; // collide with existing CN 32k |
| 874 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 877 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 875 | 878 |
| 876 int channel_num2 = voe_.GetLastChannel(); | 879 const auto& dm = GetRecvStreamConfig(kSsrc1).decoder_map; |
| 877 webrtc::CodecInst gcodec; | 880 ASSERT_EQ(1, dm.count(106)); |
| 878 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); | 881 EXPECT_EQ(webrtc::SdpAudioFormat("isac", 16000, 1), dm.at(106)); |
| 879 gcodec.plfreq = 16000; | |
| 880 gcodec.channels = 1; | |
| 881 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); | |
| 882 EXPECT_EQ(106, gcodec.pltype); | |
| 883 EXPECT_STREQ("ISAC", gcodec.plname); | |
| 884 } | 882 } |
| 885 | 883 |
| 886 // Test that we can apply the same set of codecs again while playing. | 884 // Test that we can apply the same set of codecs again while playing. |
| 887 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { | 885 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { |
| 888 EXPECT_TRUE(SetupRecvStream()); | 886 EXPECT_TRUE(SetupRecvStream()); |
| 889 cricket::AudioRecvParameters parameters; | 887 cricket::AudioRecvParameters parameters; |
| 890 parameters.codecs.push_back(kIsacCodec); | 888 parameters.codecs.push_back(kIsacCodec); |
| 891 parameters.codecs.push_back(kCn16000Codec); | 889 parameters.codecs.push_back(kCn16000Codec); |
| 892 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 890 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 893 channel_->SetPlayout(true); | 891 channel_->SetPlayout(true); |
| (...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3676 nullptr, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); | 3674 nullptr, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); |
| 3677 webrtc::RtcEventLogNullImpl event_log; | 3675 webrtc::RtcEventLogNullImpl event_log; |
| 3678 std::unique_ptr<webrtc::Call> call( | 3676 std::unique_ptr<webrtc::Call> call( |
| 3679 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3677 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
| 3680 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3678 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
| 3681 cricket::AudioOptions(), call.get()); | 3679 cricket::AudioOptions(), call.get()); |
| 3682 cricket::AudioRecvParameters parameters; | 3680 cricket::AudioRecvParameters parameters; |
| 3683 parameters.codecs = engine.recv_codecs(); | 3681 parameters.codecs = engine.recv_codecs(); |
| 3684 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3682 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3685 } | 3683 } |
| OLD | NEW |