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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void SetSend(cricket::VoiceMediaChannel* channel, bool enable) { | 182 void SetSend(cricket::VoiceMediaChannel* channel, bool enable) { |
183 ASSERT_TRUE(channel); | 183 ASSERT_TRUE(channel); |
184 if (enable) { | 184 if (enable) { |
185 EXPECT_CALL(adm_, RecordingIsInitialized()).WillOnce(Return(false)); | 185 EXPECT_CALL(adm_, RecordingIsInitialized()).WillOnce(Return(false)); |
186 EXPECT_CALL(adm_, Recording()).WillOnce(Return(false)); | 186 EXPECT_CALL(adm_, Recording()).WillOnce(Return(false)); |
187 EXPECT_CALL(adm_, InitRecording()).WillOnce(Return(0)); | 187 EXPECT_CALL(adm_, InitRecording()).WillOnce(Return(0)); |
188 } | 188 } |
189 channel->SetSend(enable); | 189 channel->SetSend(enable); |
190 } | 190 } |
191 | 191 |
192 void TestInsertDtmf(uint32_t ssrc, bool caller) { | 192 void TestInsertDtmf(uint32_t ssrc, bool caller, |
| 193 const cricket::AudioCodec& codec) { |
193 EXPECT_TRUE(SetupChannel()); | 194 EXPECT_TRUE(SetupChannel()); |
194 if (caller) { | 195 if (caller) { |
195 // If this is a caller, local description will be applied and add the | 196 // If this is a caller, local description will be applied and add the |
196 // send stream. | 197 // send stream. |
197 EXPECT_TRUE(channel_->AddSendStream( | 198 EXPECT_TRUE(channel_->AddSendStream( |
198 cricket::StreamParams::CreateLegacy(kSsrc1))); | 199 cricket::StreamParams::CreateLegacy(kSsrc1))); |
199 } | 200 } |
200 | 201 |
201 // Test we can only InsertDtmf when the other side supports telephone-event. | 202 // Test we can only InsertDtmf when the other side supports telephone-event. |
202 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 203 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
203 SetSend(channel_, true); | 204 SetSend(channel_, true); |
204 EXPECT_FALSE(channel_->CanInsertDtmf()); | 205 EXPECT_FALSE(channel_->CanInsertDtmf()); |
205 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111)); | 206 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111)); |
206 send_parameters_.codecs.push_back(kTelephoneEventCodec1); | 207 send_parameters_.codecs.push_back(codec); |
207 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 208 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
208 EXPECT_TRUE(channel_->CanInsertDtmf()); | 209 EXPECT_TRUE(channel_->CanInsertDtmf()); |
209 | 210 |
210 if (!caller) { | 211 if (!caller) { |
211 // If this is callee, there's no active send channel yet. | 212 // If this is callee, there's no active send channel yet. |
212 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123)); | 213 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123)); |
213 EXPECT_TRUE(channel_->AddSendStream( | 214 EXPECT_TRUE(channel_->AddSendStream( |
214 cricket::StreamParams::CreateLegacy(kSsrc1))); | 215 cricket::StreamParams::CreateLegacy(kSsrc1))); |
215 } | 216 } |
216 | 217 |
217 // Check we fail if the ssrc is invalid. | 218 // Check we fail if the ssrc is invalid. |
218 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111)); | 219 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111)); |
219 | 220 |
220 // Test send. | 221 // Test send. |
221 cricket::FakeAudioSendStream::TelephoneEvent telephone_event = | 222 cricket::FakeAudioSendStream::TelephoneEvent telephone_event = |
222 GetSendStream(kSsrc1).GetLatestTelephoneEvent(); | 223 GetSendStream(kSsrc1).GetLatestTelephoneEvent(); |
223 EXPECT_EQ(-1, telephone_event.payload_type); | 224 EXPECT_EQ(-1, telephone_event.payload_type); |
224 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123)); | 225 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123)); |
225 telephone_event = GetSendStream(kSsrc1).GetLatestTelephoneEvent(); | 226 telephone_event = GetSendStream(kSsrc1).GetLatestTelephoneEvent(); |
226 EXPECT_EQ(kTelephoneEventCodec1.id, telephone_event.payload_type); | 227 EXPECT_EQ(codec.id, telephone_event.payload_type); |
| 228 EXPECT_EQ(codec.clockrate, telephone_event.payload_frequency); |
227 EXPECT_EQ(2, telephone_event.event_code); | 229 EXPECT_EQ(2, telephone_event.event_code); |
228 EXPECT_EQ(123, telephone_event.duration_ms); | 230 EXPECT_EQ(123, telephone_event.duration_ms); |
229 } | 231 } |
230 | 232 |
231 // Test that send bandwidth is set correctly. | 233 // Test that send bandwidth is set correctly. |
232 // |codec| is the codec under test. | 234 // |codec| is the codec under test. |
233 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth(). | 235 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth(). |
234 // |expected_result| is the expected result from SetMaxSendBandwidth(). | 236 // |expected_result| is the expected result from SetMaxSendBandwidth(). |
235 // |expected_bitrate| is the expected audio bitrate afterward. | 237 // |expected_bitrate| is the expected audio bitrate afterward. |
236 void TestMaxSendBandwidth(const cricket::AudioCodec& codec, | 238 void TestMaxSendBandwidth(const cricket::AudioCodec& codec, |
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 const auto& gcodec = GetSendStreamConfig(kSsrc1).send_codec_spec.codec_inst; | 1836 const auto& gcodec = GetSendStreamConfig(kSsrc1).send_codec_spec.codec_inst; |
1835 EXPECT_EQ(96, gcodec.pltype); | 1837 EXPECT_EQ(96, gcodec.pltype); |
1836 EXPECT_STREQ("ISAC", gcodec.plname); | 1838 EXPECT_STREQ("ISAC", gcodec.plname); |
1837 EXPECT_TRUE(channel_->CanInsertDtmf()); | 1839 EXPECT_TRUE(channel_->CanInsertDtmf()); |
1838 } | 1840 } |
1839 | 1841 |
1840 // Test that payload type range is limited for telephone-event codec. | 1842 // Test that payload type range is limited for telephone-event codec. |
1841 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) { | 1843 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) { |
1842 EXPECT_TRUE(SetupSendStream()); | 1844 EXPECT_TRUE(SetupSendStream()); |
1843 cricket::AudioSendParameters parameters; | 1845 cricket::AudioSendParameters parameters; |
1844 parameters.codecs.push_back(kTelephoneEventCodec1); | 1846 parameters.codecs.push_back(kTelephoneEventCodec2); |
1845 parameters.codecs.push_back(kIsacCodec); | 1847 parameters.codecs.push_back(kIsacCodec); |
1846 parameters.codecs[0].id = 0; // DTMF | 1848 parameters.codecs[0].id = 0; // DTMF |
1847 parameters.codecs[1].id = 96; | 1849 parameters.codecs[1].id = 96; |
1848 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1850 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1849 EXPECT_TRUE(channel_->CanInsertDtmf()); | 1851 EXPECT_TRUE(channel_->CanInsertDtmf()); |
1850 parameters.codecs[0].id = 128; // DTMF | 1852 parameters.codecs[0].id = 128; // DTMF |
1851 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 1853 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
1852 EXPECT_FALSE(channel_->CanInsertDtmf()); | 1854 EXPECT_FALSE(channel_->CanInsertDtmf()); |
1853 parameters.codecs[0].id = 127; | 1855 parameters.codecs[0].id = 127; |
1854 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1856 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1902 | 1904 |
1903 // Test that we set VAD and DTMF types correctly as callee. | 1905 // Test that we set VAD and DTMF types correctly as callee. |
1904 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { | 1906 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { |
1905 EXPECT_TRUE(SetupChannel()); | 1907 EXPECT_TRUE(SetupChannel()); |
1906 cricket::AudioSendParameters parameters; | 1908 cricket::AudioSendParameters parameters; |
1907 parameters.codecs.push_back(kIsacCodec); | 1909 parameters.codecs.push_back(kIsacCodec); |
1908 parameters.codecs.push_back(kPcmuCodec); | 1910 parameters.codecs.push_back(kPcmuCodec); |
1909 // TODO(juberti): cn 32000 | 1911 // TODO(juberti): cn 32000 |
1910 parameters.codecs.push_back(kCn16000Codec); | 1912 parameters.codecs.push_back(kCn16000Codec); |
1911 parameters.codecs.push_back(kCn8000Codec); | 1913 parameters.codecs.push_back(kCn8000Codec); |
1912 parameters.codecs.push_back(kTelephoneEventCodec1); | 1914 parameters.codecs.push_back(kTelephoneEventCodec2); |
1913 parameters.codecs[0].id = 96; | 1915 parameters.codecs[0].id = 96; |
1914 parameters.codecs[2].id = 97; // wideband CN | 1916 parameters.codecs[2].id = 97; // wideband CN |
1915 parameters.codecs[4].id = 98; // DTMF | 1917 parameters.codecs[4].id = 98; // DTMF |
1916 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1918 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1917 EXPECT_TRUE(channel_->AddSendStream( | 1919 EXPECT_TRUE(channel_->AddSendStream( |
1918 cricket::StreamParams::CreateLegacy(kSsrc1))); | 1920 cricket::StreamParams::CreateLegacy(kSsrc1))); |
1919 | 1921 |
1920 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec; | 1922 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec; |
1921 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); | 1923 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); |
1922 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); | 1924 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2635 // Add recv stream 2 should work. | 2637 // Add recv stream 2 should work. |
2636 EXPECT_TRUE(AddRecvStream(2)); | 2638 EXPECT_TRUE(AddRecvStream(2)); |
2637 int new_channel = voe_.GetLastChannel(); | 2639 int new_channel = voe_.GetLastChannel(); |
2638 EXPECT_NE(channel, new_channel); | 2640 EXPECT_NE(channel, new_channel); |
2639 // The last created channel is deleted too. | 2641 // The last created channel is deleted too. |
2640 EXPECT_EQ(0, voe_.DeleteChannel(new_channel)); | 2642 EXPECT_EQ(0, voe_.DeleteChannel(new_channel)); |
2641 } | 2643 } |
2642 | 2644 |
2643 // Test the InsertDtmf on default send stream as caller. | 2645 // Test the InsertDtmf on default send stream as caller. |
2644 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { | 2646 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { |
2645 TestInsertDtmf(0, true); | 2647 TestInsertDtmf(0, true, kTelephoneEventCodec1); |
2646 } | 2648 } |
2647 | 2649 |
2648 // Test the InsertDtmf on default send stream as callee | 2650 // Test the InsertDtmf on default send stream as callee |
2649 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { | 2651 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { |
2650 TestInsertDtmf(0, false); | 2652 TestInsertDtmf(0, false, kTelephoneEventCodec2); |
2651 } | 2653 } |
2652 | 2654 |
2653 // Test the InsertDtmf on specified send stream as caller. | 2655 // Test the InsertDtmf on specified send stream as caller. |
2654 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { | 2656 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { |
2655 TestInsertDtmf(kSsrc1, true); | 2657 TestInsertDtmf(kSsrc1, true, kTelephoneEventCodec2); |
2656 } | 2658 } |
2657 | 2659 |
2658 // Test the InsertDtmf on specified send stream as callee. | 2660 // Test the InsertDtmf on specified send stream as callee. |
2659 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { | 2661 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { |
2660 TestInsertDtmf(kSsrc1, false); | 2662 TestInsertDtmf(kSsrc1, false, kTelephoneEventCodec1); |
2661 } | 2663 } |
2662 | 2664 |
2663 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { | 2665 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
2664 EXPECT_TRUE(SetupSendStream()); | 2666 EXPECT_TRUE(SetupSendStream()); |
2665 EXPECT_CALL(adm_, | 2667 EXPECT_CALL(adm_, |
2666 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); | 2668 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); |
2667 EXPECT_CALL(adm_, | 2669 EXPECT_CALL(adm_, |
2668 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); | 2670 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); |
2669 EXPECT_CALL(adm_, | 2671 EXPECT_CALL(adm_, |
2670 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); | 2672 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3451 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3453 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); |
3452 webrtc::RtcEventLogNullImpl event_log; | 3454 webrtc::RtcEventLogNullImpl event_log; |
3453 std::unique_ptr<webrtc::Call> call( | 3455 std::unique_ptr<webrtc::Call> call( |
3454 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3456 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3455 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3457 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3456 cricket::AudioOptions(), call.get()); | 3458 cricket::AudioOptions(), call.get()); |
3457 cricket::AudioRecvParameters parameters; | 3459 cricket::AudioRecvParameters parameters; |
3458 parameters.codecs = engine.recv_codecs(); | 3460 parameters.codecs = engine.recv_codecs(); |
3459 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3461 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3460 } | 3462 } |
OLD | NEW |