Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine_unittest.cc

Issue 2392883002: Multi frequency DTMF support - sender side (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | webrtc/modules/rtp_rtcp/source/dtmf_queue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 const cricket::AudioOptions* options = nullptr) { 214 const cricket::AudioOptions* options = nullptr) {
215 EXPECT_CALL(apm_, set_output_will_be_muted(!enable)); 215 EXPECT_CALL(apm_, set_output_will_be_muted(!enable));
216 ASSERT_TRUE(channel_); 216 ASSERT_TRUE(channel_);
217 if (enable && options) { 217 if (enable && options) {
218 EXPECT_CALL(apm_, ApplyConfig(testing::_)); 218 EXPECT_CALL(apm_, ApplyConfig(testing::_));
219 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); 219 EXPECT_CALL(apm_, SetExtraOptions(testing::_));
220 } 220 }
221 EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, options, source)); 221 EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, options, source));
222 } 222 }
223 223
224 void TestInsertDtmf(uint32_t ssrc, bool caller) { 224 void TestInsertDtmf(uint32_t ssrc, bool caller,
225 const cricket::AudioCodec& codec) {
225 EXPECT_TRUE(SetupChannel()); 226 EXPECT_TRUE(SetupChannel());
226 if (caller) { 227 if (caller) {
227 // If this is a caller, local description will be applied and add the 228 // If this is a caller, local description will be applied and add the
228 // send stream. 229 // send stream.
229 EXPECT_TRUE(channel_->AddSendStream( 230 EXPECT_TRUE(channel_->AddSendStream(
230 cricket::StreamParams::CreateLegacy(kSsrc1))); 231 cricket::StreamParams::CreateLegacy(kSsrc1)));
231 } 232 }
232 233
233 // Test we can only InsertDtmf when the other side supports telephone-event. 234 // Test we can only InsertDtmf when the other side supports telephone-event.
234 SetSendParameters(send_parameters_); 235 SetSendParameters(send_parameters_);
235 SetSend(true); 236 SetSend(true);
236 EXPECT_FALSE(channel_->CanInsertDtmf()); 237 EXPECT_FALSE(channel_->CanInsertDtmf());
237 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111)); 238 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111));
238 send_parameters_.codecs.push_back(kTelephoneEventCodec1); 239 send_parameters_.codecs.push_back(codec);
239 SetSendParameters(send_parameters_); 240 SetSendParameters(send_parameters_);
240 EXPECT_TRUE(channel_->CanInsertDtmf()); 241 EXPECT_TRUE(channel_->CanInsertDtmf());
241 242
242 if (!caller) { 243 if (!caller) {
243 // If this is callee, there's no active send channel yet. 244 // If this is callee, there's no active send channel yet.
244 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123)); 245 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123));
245 EXPECT_TRUE(channel_->AddSendStream( 246 EXPECT_TRUE(channel_->AddSendStream(
246 cricket::StreamParams::CreateLegacy(kSsrc1))); 247 cricket::StreamParams::CreateLegacy(kSsrc1)));
247 } 248 }
248 249
249 // Check we fail if the ssrc is invalid. 250 // Check we fail if the ssrc is invalid.
250 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111)); 251 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111));
251 252
252 // Test send. 253 // Test send.
253 cricket::FakeAudioSendStream::TelephoneEvent telephone_event = 254 cricket::FakeAudioSendStream::TelephoneEvent telephone_event =
254 GetSendStream(kSsrc1).GetLatestTelephoneEvent(); 255 GetSendStream(kSsrc1).GetLatestTelephoneEvent();
255 EXPECT_EQ(-1, telephone_event.payload_type); 256 EXPECT_EQ(-1, telephone_event.payload_type);
256 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123)); 257 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123));
257 telephone_event = GetSendStream(kSsrc1).GetLatestTelephoneEvent(); 258 telephone_event = GetSendStream(kSsrc1).GetLatestTelephoneEvent();
258 EXPECT_EQ(kTelephoneEventCodec1.id, telephone_event.payload_type); 259 EXPECT_EQ(codec.id, telephone_event.payload_type);
260 EXPECT_EQ(codec.clockrate, telephone_event.payload_frequency);
259 EXPECT_EQ(2, telephone_event.event_code); 261 EXPECT_EQ(2, telephone_event.event_code);
260 EXPECT_EQ(123, telephone_event.duration_ms); 262 EXPECT_EQ(123, telephone_event.duration_ms);
261 } 263 }
262 264
263 // Test that send bandwidth is set correctly. 265 // Test that send bandwidth is set correctly.
264 // |codec| is the codec under test. 266 // |codec| is the codec under test.
265 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth(). 267 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth().
266 // |expected_result| is the expected result from SetMaxSendBandwidth(). 268 // |expected_result| is the expected result from SetMaxSendBandwidth().
267 // |expected_bitrate| is the expected audio bitrate afterward. 269 // |expected_bitrate| is the expected audio bitrate afterward.
268 void TestMaxSendBandwidth(const cricket::AudioCodec& codec, 270 void TestMaxSendBandwidth(const cricket::AudioCodec& codec,
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 const auto& gcodec = GetSendStreamConfig(kSsrc1).send_codec_spec.codec_inst; 1879 const auto& gcodec = GetSendStreamConfig(kSsrc1).send_codec_spec.codec_inst;
1878 EXPECT_EQ(96, gcodec.pltype); 1880 EXPECT_EQ(96, gcodec.pltype);
1879 EXPECT_STREQ("ISAC", gcodec.plname); 1881 EXPECT_STREQ("ISAC", gcodec.plname);
1880 EXPECT_TRUE(channel_->CanInsertDtmf()); 1882 EXPECT_TRUE(channel_->CanInsertDtmf());
1881 } 1883 }
1882 1884
1883 // Test that payload type range is limited for telephone-event codec. 1885 // Test that payload type range is limited for telephone-event codec.
1884 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) { 1886 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) {
1885 EXPECT_TRUE(SetupSendStream()); 1887 EXPECT_TRUE(SetupSendStream());
1886 cricket::AudioSendParameters parameters; 1888 cricket::AudioSendParameters parameters;
1887 parameters.codecs.push_back(kTelephoneEventCodec1); 1889 parameters.codecs.push_back(kTelephoneEventCodec2);
1888 parameters.codecs.push_back(kIsacCodec); 1890 parameters.codecs.push_back(kIsacCodec);
1889 parameters.codecs[0].id = 0; // DTMF 1891 parameters.codecs[0].id = 0; // DTMF
1890 parameters.codecs[1].id = 96; 1892 parameters.codecs[1].id = 96;
1891 SetSendParameters(parameters); 1893 SetSendParameters(parameters);
1892 EXPECT_TRUE(channel_->CanInsertDtmf()); 1894 EXPECT_TRUE(channel_->CanInsertDtmf());
1893 parameters.codecs[0].id = 128; // DTMF 1895 parameters.codecs[0].id = 128; // DTMF
1894 EXPECT_FALSE(channel_->SetSendParameters(parameters)); 1896 EXPECT_FALSE(channel_->SetSendParameters(parameters));
1895 EXPECT_FALSE(channel_->CanInsertDtmf()); 1897 EXPECT_FALSE(channel_->CanInsertDtmf());
1896 parameters.codecs[0].id = 127; 1898 parameters.codecs[0].id = 127;
1897 SetSendParameters(parameters); 1899 SetSendParameters(parameters);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 1947
1946 // Test that we set VAD and DTMF types correctly as callee. 1948 // Test that we set VAD and DTMF types correctly as callee.
1947 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { 1949 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
1948 EXPECT_TRUE(SetupChannel()); 1950 EXPECT_TRUE(SetupChannel());
1949 cricket::AudioSendParameters parameters; 1951 cricket::AudioSendParameters parameters;
1950 parameters.codecs.push_back(kIsacCodec); 1952 parameters.codecs.push_back(kIsacCodec);
1951 parameters.codecs.push_back(kPcmuCodec); 1953 parameters.codecs.push_back(kPcmuCodec);
1952 // TODO(juberti): cn 32000 1954 // TODO(juberti): cn 32000
1953 parameters.codecs.push_back(kCn16000Codec); 1955 parameters.codecs.push_back(kCn16000Codec);
1954 parameters.codecs.push_back(kCn8000Codec); 1956 parameters.codecs.push_back(kCn8000Codec);
1955 parameters.codecs.push_back(kTelephoneEventCodec1); 1957 parameters.codecs.push_back(kTelephoneEventCodec2);
1956 parameters.codecs[0].id = 96; 1958 parameters.codecs[0].id = 96;
1957 parameters.codecs[2].id = 97; // wideband CN 1959 parameters.codecs[2].id = 97; // wideband CN
1958 parameters.codecs[4].id = 98; // DTMF 1960 parameters.codecs[4].id = 98; // DTMF
1959 SetSendParameters(parameters); 1961 SetSendParameters(parameters);
1960 EXPECT_TRUE(channel_->AddSendStream( 1962 EXPECT_TRUE(channel_->AddSendStream(
1961 cricket::StreamParams::CreateLegacy(kSsrc1))); 1963 cricket::StreamParams::CreateLegacy(kSsrc1)));
1962 1964
1963 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec; 1965 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec;
1964 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); 1966 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype);
1965 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); 1967 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname);
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
2725 // Add recv stream 2 should work. 2727 // Add recv stream 2 should work.
2726 EXPECT_TRUE(AddRecvStream(2)); 2728 EXPECT_TRUE(AddRecvStream(2));
2727 int new_channel = voe_.GetLastChannel(); 2729 int new_channel = voe_.GetLastChannel();
2728 EXPECT_NE(channel, new_channel); 2730 EXPECT_NE(channel, new_channel);
2729 // The last created channel is deleted too. 2731 // The last created channel is deleted too.
2730 EXPECT_EQ(0, voe_.DeleteChannel(new_channel)); 2732 EXPECT_EQ(0, voe_.DeleteChannel(new_channel));
2731 } 2733 }
2732 2734
2733 // Test the InsertDtmf on default send stream as caller. 2735 // Test the InsertDtmf on default send stream as caller.
2734 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { 2736 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) {
2735 TestInsertDtmf(0, true); 2737 TestInsertDtmf(0, true, kTelephoneEventCodec1);
2736 } 2738 }
2737 2739
2738 // Test the InsertDtmf on default send stream as callee 2740 // Test the InsertDtmf on default send stream as callee
2739 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { 2741 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) {
2740 TestInsertDtmf(0, false); 2742 TestInsertDtmf(0, false, kTelephoneEventCodec2);
2741 } 2743 }
2742 2744
2743 // Test the InsertDtmf on specified send stream as caller. 2745 // Test the InsertDtmf on specified send stream as caller.
2744 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { 2746 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) {
2745 TestInsertDtmf(kSsrc1, true); 2747 TestInsertDtmf(kSsrc1, true, kTelephoneEventCodec2);
2746 } 2748 }
2747 2749
2748 // Test the InsertDtmf on specified send stream as callee. 2750 // Test the InsertDtmf on specified send stream as callee.
2749 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { 2751 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) {
2750 TestInsertDtmf(kSsrc1, false); 2752 TestInsertDtmf(kSsrc1, false, kTelephoneEventCodec1);
2751 } 2753 }
2752 2754
2753 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { 2755 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) {
2754 EXPECT_TRUE(SetupSendStream()); 2756 EXPECT_TRUE(SetupSendStream());
2755 EXPECT_CALL(adm_, 2757 EXPECT_CALL(adm_,
2756 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false)); 2758 BuiltInAECIsAvailable()).Times(9).WillRepeatedly(Return(false));
2757 EXPECT_CALL(adm_, 2759 EXPECT_CALL(adm_,
2758 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false)); 2760 BuiltInAGCIsAvailable()).Times(4).WillRepeatedly(Return(false));
2759 EXPECT_CALL(adm_, 2761 EXPECT_CALL(adm_,
2760 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false)); 2762 BuiltInNSIsAvailable()).Times(2).WillRepeatedly(Return(false));
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); 3531 nullptr, webrtc::CreateBuiltinAudioDecoderFactory());
3530 webrtc::RtcEventLogNullImpl event_log; 3532 webrtc::RtcEventLogNullImpl event_log;
3531 std::unique_ptr<webrtc::Call> call( 3533 std::unique_ptr<webrtc::Call> call(
3532 webrtc::Call::Create(webrtc::Call::Config(&event_log))); 3534 webrtc::Call::Create(webrtc::Call::Config(&event_log)));
3533 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3535 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3534 cricket::AudioOptions(), call.get()); 3536 cricket::AudioOptions(), call.get());
3535 cricket::AudioRecvParameters parameters; 3537 cricket::AudioRecvParameters parameters;
3536 parameters.codecs = engine.recv_codecs(); 3538 parameters.codecs = engine.recv_codecs();
3537 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3539 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3538 } 3540 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | webrtc/modules/rtp_rtcp/source/dtmf_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698