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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const cricket::AudioOptions* options = nullptr) { | 213 const cricket::AudioOptions* options = nullptr) { |
214 EXPECT_CALL(apm_, set_output_will_be_muted(!enable)); | 214 EXPECT_CALL(apm_, set_output_will_be_muted(!enable)); |
215 ASSERT_TRUE(channel_); | 215 ASSERT_TRUE(channel_); |
216 if (enable && options) { | 216 if (enable && options) { |
217 EXPECT_CALL(apm_, ApplyConfig(testing::_)); | 217 EXPECT_CALL(apm_, ApplyConfig(testing::_)); |
218 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); | 218 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); |
219 } | 219 } |
220 EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, options, source)); | 220 EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, options, source)); |
221 } | 221 } |
222 | 222 |
223 void TestInsertDtmf(uint32_t ssrc, bool caller) { | 223 void TestInsertDtmf(uint32_t ssrc, bool caller, |
| 224 const cricket::AudioCodec& codec) { |
224 EXPECT_TRUE(SetupChannel()); | 225 EXPECT_TRUE(SetupChannel()); |
225 if (caller) { | 226 if (caller) { |
226 // If this is a caller, local description will be applied and add the | 227 // If this is a caller, local description will be applied and add the |
227 // send stream. | 228 // send stream. |
228 EXPECT_TRUE(channel_->AddSendStream( | 229 EXPECT_TRUE(channel_->AddSendStream( |
229 cricket::StreamParams::CreateLegacy(kSsrc1))); | 230 cricket::StreamParams::CreateLegacy(kSsrc1))); |
230 } | 231 } |
231 | 232 |
232 // Test we can only InsertDtmf when the other side supports telephone-event. | 233 // Test we can only InsertDtmf when the other side supports telephone-event. |
233 SetSendParameters(send_parameters_); | 234 SetSendParameters(send_parameters_); |
234 SetSend(true); | 235 SetSend(true); |
235 EXPECT_FALSE(channel_->CanInsertDtmf()); | 236 EXPECT_FALSE(channel_->CanInsertDtmf()); |
236 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111)); | 237 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111)); |
237 send_parameters_.codecs.push_back(kTelephoneEventCodec1); | 238 send_parameters_.codecs.push_back(codec); |
238 SetSendParameters(send_parameters_); | 239 SetSendParameters(send_parameters_); |
239 EXPECT_TRUE(channel_->CanInsertDtmf()); | 240 EXPECT_TRUE(channel_->CanInsertDtmf()); |
240 | 241 |
241 if (!caller) { | 242 if (!caller) { |
242 // If this is callee, there's no active send channel yet. | 243 // If this is callee, there's no active send channel yet. |
243 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123)); | 244 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123)); |
244 EXPECT_TRUE(channel_->AddSendStream( | 245 EXPECT_TRUE(channel_->AddSendStream( |
245 cricket::StreamParams::CreateLegacy(kSsrc1))); | 246 cricket::StreamParams::CreateLegacy(kSsrc1))); |
246 } | 247 } |
247 | 248 |
248 // Check we fail if the ssrc is invalid. | 249 // Check we fail if the ssrc is invalid. |
249 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111)); | 250 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111)); |
250 | 251 |
251 // Test send. | 252 // Test send. |
252 cricket::FakeAudioSendStream::TelephoneEvent telephone_event = | 253 cricket::FakeAudioSendStream::TelephoneEvent telephone_event = |
253 GetSendStream(kSsrc1).GetLatestTelephoneEvent(); | 254 GetSendStream(kSsrc1).GetLatestTelephoneEvent(); |
254 EXPECT_EQ(-1, telephone_event.payload_type); | 255 EXPECT_EQ(-1, telephone_event.payload_type); |
255 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123)); | 256 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123)); |
256 telephone_event = GetSendStream(kSsrc1).GetLatestTelephoneEvent(); | 257 telephone_event = GetSendStream(kSsrc1).GetLatestTelephoneEvent(); |
257 EXPECT_EQ(kTelephoneEventCodec1.id, telephone_event.payload_type); | 258 EXPECT_EQ(codec.id, telephone_event.payload_type); |
| 259 EXPECT_EQ(codec.clockrate, telephone_event.payload_frequency); |
258 EXPECT_EQ(2, telephone_event.event_code); | 260 EXPECT_EQ(2, telephone_event.event_code); |
259 EXPECT_EQ(123, telephone_event.duration_ms); | 261 EXPECT_EQ(123, telephone_event.duration_ms); |
260 } | 262 } |
261 | 263 |
262 // Test that send bandwidth is set correctly. | 264 // Test that send bandwidth is set correctly. |
263 // |codec| is the codec under test. | 265 // |codec| is the codec under test. |
264 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth(). | 266 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth(). |
265 // |expected_result| is the expected result from SetMaxSendBandwidth(). | 267 // |expected_result| is the expected result from SetMaxSendBandwidth(). |
266 // |expected_bitrate| is the expected audio bitrate afterward. | 268 // |expected_bitrate| is the expected audio bitrate afterward. |
267 void TestMaxSendBandwidth(const cricket::AudioCodec& codec, | 269 void TestMaxSendBandwidth(const cricket::AudioCodec& codec, |
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 const auto& gcodec = GetSendStreamConfig(kSsrc1).send_codec_spec.codec_inst; | 1878 const auto& gcodec = GetSendStreamConfig(kSsrc1).send_codec_spec.codec_inst; |
1877 EXPECT_EQ(96, gcodec.pltype); | 1879 EXPECT_EQ(96, gcodec.pltype); |
1878 EXPECT_STREQ("ISAC", gcodec.plname); | 1880 EXPECT_STREQ("ISAC", gcodec.plname); |
1879 EXPECT_TRUE(channel_->CanInsertDtmf()); | 1881 EXPECT_TRUE(channel_->CanInsertDtmf()); |
1880 } | 1882 } |
1881 | 1883 |
1882 // Test that payload type range is limited for telephone-event codec. | 1884 // Test that payload type range is limited for telephone-event codec. |
1883 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) { | 1885 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) { |
1884 EXPECT_TRUE(SetupSendStream()); | 1886 EXPECT_TRUE(SetupSendStream()); |
1885 cricket::AudioSendParameters parameters; | 1887 cricket::AudioSendParameters parameters; |
1886 parameters.codecs.push_back(kTelephoneEventCodec1); | 1888 parameters.codecs.push_back(kTelephoneEventCodec2); |
1887 parameters.codecs.push_back(kIsacCodec); | 1889 parameters.codecs.push_back(kIsacCodec); |
1888 parameters.codecs[0].id = 0; // DTMF | 1890 parameters.codecs[0].id = 0; // DTMF |
1889 parameters.codecs[1].id = 96; | 1891 parameters.codecs[1].id = 96; |
1890 SetSendParameters(parameters); | 1892 SetSendParameters(parameters); |
1891 EXPECT_TRUE(channel_->CanInsertDtmf()); | 1893 EXPECT_TRUE(channel_->CanInsertDtmf()); |
1892 parameters.codecs[0].id = 128; // DTMF | 1894 parameters.codecs[0].id = 128; // DTMF |
1893 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 1895 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
1894 EXPECT_FALSE(channel_->CanInsertDtmf()); | 1896 EXPECT_FALSE(channel_->CanInsertDtmf()); |
1895 parameters.codecs[0].id = 127; | 1897 parameters.codecs[0].id = 127; |
1896 SetSendParameters(parameters); | 1898 SetSendParameters(parameters); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 | 1946 |
1945 // Test that we set VAD and DTMF types correctly as callee. | 1947 // Test that we set VAD and DTMF types correctly as callee. |
1946 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { | 1948 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { |
1947 EXPECT_TRUE(SetupChannel()); | 1949 EXPECT_TRUE(SetupChannel()); |
1948 cricket::AudioSendParameters parameters; | 1950 cricket::AudioSendParameters parameters; |
1949 parameters.codecs.push_back(kIsacCodec); | 1951 parameters.codecs.push_back(kIsacCodec); |
1950 parameters.codecs.push_back(kPcmuCodec); | 1952 parameters.codecs.push_back(kPcmuCodec); |
1951 // TODO(juberti): cn 32000 | 1953 // TODO(juberti): cn 32000 |
1952 parameters.codecs.push_back(kCn16000Codec); | 1954 parameters.codecs.push_back(kCn16000Codec); |
1953 parameters.codecs.push_back(kCn8000Codec); | 1955 parameters.codecs.push_back(kCn8000Codec); |
1954 parameters.codecs.push_back(kTelephoneEventCodec1); | 1956 parameters.codecs.push_back(kTelephoneEventCodec2); |
1955 parameters.codecs[0].id = 96; | 1957 parameters.codecs[0].id = 96; |
1956 parameters.codecs[2].id = 97; // wideband CN | 1958 parameters.codecs[2].id = 97; // wideband CN |
1957 parameters.codecs[4].id = 98; // DTMF | 1959 parameters.codecs[4].id = 98; // DTMF |
1958 SetSendParameters(parameters); | 1960 SetSendParameters(parameters); |
1959 EXPECT_TRUE(channel_->AddSendStream( | 1961 EXPECT_TRUE(channel_->AddSendStream( |
1960 cricket::StreamParams::CreateLegacy(kSsrc1))); | 1962 cricket::StreamParams::CreateLegacy(kSsrc1))); |
1961 | 1963 |
1962 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec; | 1964 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec; |
1963 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); | 1965 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); |
1964 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); | 1966 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2724 // Add recv stream 2 should work. | 2726 // Add recv stream 2 should work. |
2725 EXPECT_TRUE(AddRecvStream(2)); | 2727 EXPECT_TRUE(AddRecvStream(2)); |
2726 int new_channel = voe_.GetLastChannel(); | 2728 int new_channel = voe_.GetLastChannel(); |
2727 EXPECT_NE(channel, new_channel); | 2729 EXPECT_NE(channel, new_channel); |
2728 // The last created channel is deleted too. | 2730 // The last created channel is deleted too. |
2729 EXPECT_EQ(0, voe_.DeleteChannel(new_channel)); | 2731 EXPECT_EQ(0, voe_.DeleteChannel(new_channel)); |
2730 } | 2732 } |
2731 | 2733 |
2732 // Test the InsertDtmf on default send stream as caller. | 2734 // Test the InsertDtmf on default send stream as caller. |
2733 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { | 2735 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { |
2734 TestInsertDtmf(0, true); | 2736 TestInsertDtmf(0, true, kTelephoneEventCodec1); |
2735 } | 2737 } |
2736 | 2738 |
2737 // Test the InsertDtmf on default send stream as callee | 2739 // Test the InsertDtmf on default send stream as callee |
2738 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { | 2740 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { |
2739 TestInsertDtmf(0, false); | 2741 TestInsertDtmf(0, false, kTelephoneEventCodec2); |
2740 } | 2742 } |
2741 | 2743 |
2742 // Test the InsertDtmf on specified send stream as caller. | 2744 // Test the InsertDtmf on specified send stream as caller. |
2743 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { | 2745 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { |
2744 TestInsertDtmf(kSsrc1, true); | 2746 TestInsertDtmf(kSsrc1, true, kTelephoneEventCodec2); |
2745 } | 2747 } |
2746 | 2748 |
2747 // Test the InsertDtmf on specified send stream as callee. | 2749 // Test the InsertDtmf on specified send stream as callee. |
2748 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { | 2750 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { |
2749 TestInsertDtmf(kSsrc1, false); | 2751 TestInsertDtmf(kSsrc1, false, kTelephoneEventCodec1); |
2750 } | 2752 } |
2751 | 2753 |
2752 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { | 2754 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
2753 EXPECT_TRUE(SetupSendStream()); | 2755 EXPECT_TRUE(SetupSendStream()); |
2754 EXPECT_CALL(adm_, | 2756 EXPECT_CALL(adm_, |
2755 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); | 2757 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); |
2756 EXPECT_CALL(adm_, | 2758 EXPECT_CALL(adm_, |
2757 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); | 2759 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); |
2758 EXPECT_CALL(adm_, | 2760 EXPECT_CALL(adm_, |
2759 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); | 2761 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3549 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3551 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); |
3550 webrtc::RtcEventLogNullImpl event_log; | 3552 webrtc::RtcEventLogNullImpl event_log; |
3551 std::unique_ptr<webrtc::Call> call( | 3553 std::unique_ptr<webrtc::Call> call( |
3552 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3554 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3553 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3555 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3554 cricket::AudioOptions(), call.get()); | 3556 cricket::AudioOptions(), call.get()); |
3555 cricket::AudioRecvParameters parameters; | 3557 cricket::AudioRecvParameters parameters; |
3556 parameters.codecs = engine.recv_codecs(); | 3558 parameters.codecs = engine.recv_codecs(); |
3557 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3559 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3558 } | 3560 } |
OLD | NEW |