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

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

Issue 2337473002: Multi frequency DTMF support - receiver 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
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 24 matching lines...) Expand all
35 35
36 namespace { 36 namespace {
37 37
38 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1); 38 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1);
39 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1); 39 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1);
40 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2); 40 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2);
41 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1); 41 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1);
42 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1); 42 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1);
43 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1); 43 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1);
44 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1); 44 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1);
45 const cricket::AudioCodec kTelephoneEventCodec(106, 45 const cricket::AudioCodec
46 "telephone-event", 46 kTelephoneEventCodec1(106, "telephone-event", 8000, 0, 1);
47 8000, 47 const cricket::AudioCodec
48 0, 48 kTelephoneEventCodec2(107, "telephone-event", 32000, 0, 1);
49 1); 49
50 const uint32_t kSsrc1 = 0x99; 50 const uint32_t kSsrc1 = 0x99;
51 const uint32_t kSsrc2 = 2; 51 const uint32_t kSsrc2 = 2;
52 const uint32_t kSsrc3 = 3; 52 const uint32_t kSsrc3 = 3;
53 const uint32_t kSsrc4 = 0x42; 53 const uint32_t kSsrc4 = 0x42;
54 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; 54 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 };
55 55
56 constexpr int kRtpHistoryMs = 5000; 56 constexpr int kRtpHistoryMs = 5000;
57 57
58 class FakeVoEWrapper : public cricket::VoEWrapper { 58 class FakeVoEWrapper : public cricket::VoEWrapper {
59 public: 59 public:
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // send stream. 228 // send stream.
229 EXPECT_TRUE(channel_->AddSendStream( 229 EXPECT_TRUE(channel_->AddSendStream(
230 cricket::StreamParams::CreateLegacy(kSsrc1))); 230 cricket::StreamParams::CreateLegacy(kSsrc1)));
231 } 231 }
232 232
233 // 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.
234 SetSendParameters(send_parameters_); 234 SetSendParameters(send_parameters_);
235 SetSend(true); 235 SetSend(true);
236 EXPECT_FALSE(channel_->CanInsertDtmf()); 236 EXPECT_FALSE(channel_->CanInsertDtmf());
237 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111)); 237 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111));
238 send_parameters_.codecs.push_back(kTelephoneEventCodec); 238 send_parameters_.codecs.push_back(kTelephoneEventCodec1);
239 SetSendParameters(send_parameters_); 239 SetSendParameters(send_parameters_);
240 EXPECT_TRUE(channel_->CanInsertDtmf()); 240 EXPECT_TRUE(channel_->CanInsertDtmf());
241 241
242 if (!caller) { 242 if (!caller) {
243 // If this is callee, there's no active send channel yet. 243 // If this is callee, there's no active send channel yet.
244 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123)); 244 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123));
245 EXPECT_TRUE(channel_->AddSendStream( 245 EXPECT_TRUE(channel_->AddSendStream(
246 cricket::StreamParams::CreateLegacy(kSsrc1))); 246 cricket::StreamParams::CreateLegacy(kSsrc1)));
247 } 247 }
248 248
249 // Check we fail if the ssrc is invalid. 249 // Check we fail if the ssrc is invalid.
250 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111)); 250 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111));
251 251
252 // Test send. 252 // Test send.
253 cricket::FakeAudioSendStream::TelephoneEvent telephone_event = 253 cricket::FakeAudioSendStream::TelephoneEvent telephone_event =
254 GetSendStream(kSsrc1).GetLatestTelephoneEvent(); 254 GetSendStream(kSsrc1).GetLatestTelephoneEvent();
255 EXPECT_EQ(-1, telephone_event.payload_type); 255 EXPECT_EQ(-1, telephone_event.payload_type);
256 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123)); 256 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123));
257 telephone_event = GetSendStream(kSsrc1).GetLatestTelephoneEvent(); 257 telephone_event = GetSendStream(kSsrc1).GetLatestTelephoneEvent();
258 EXPECT_EQ(kTelephoneEventCodec.id, telephone_event.payload_type); 258 EXPECT_EQ(kTelephoneEventCodec1.id, telephone_event.payload_type);
259 EXPECT_EQ(2, telephone_event.event_code); 259 EXPECT_EQ(2, telephone_event.event_code);
260 EXPECT_EQ(123, telephone_event.duration_ms); 260 EXPECT_EQ(123, telephone_event.duration_ms);
261 } 261 }
262 262
263 // Test that send bandwidth is set correctly. 263 // Test that send bandwidth is set correctly.
264 // |codec| is the codec under test. 264 // |codec| is the codec under test.
265 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth(). 265 // |max_bitrate| is a parameter to set to SetMaxSendBandwidth().
266 // |expected_result| is the expected result from SetMaxSendBandwidth(). 266 // |expected_result| is the expected result from SetMaxSendBandwidth().
267 // |expected_bitrate| is the expected audio bitrate afterward. 267 // |expected_bitrate| is the expected audio bitrate afterward.
268 void TestMaxSendBandwidth(const cricket::AudioCodec& codec, 268 void TestMaxSendBandwidth(const cricket::AudioCodec& codec,
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 // Tests that we can find codecs by name or id, and that we interpret the 627 // Tests that we can find codecs by name or id, and that we interpret the
628 // clockrate and bitrate fields properly. 628 // clockrate and bitrate fields properly.
629 TEST_F(WebRtcVoiceEngineTestFake, FindCodec) { 629 TEST_F(WebRtcVoiceEngineTestFake, FindCodec) {
630 cricket::AudioCodec codec; 630 cricket::AudioCodec codec;
631 webrtc::CodecInst codec_inst; 631 webrtc::CodecInst codec_inst;
632 // Find PCMU with explicit clockrate and bitrate. 632 // Find PCMU with explicit clockrate and bitrate.
633 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kPcmuCodec, &codec_inst)); 633 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kPcmuCodec, &codec_inst));
634 // Find ISAC with explicit clockrate and 0 bitrate. 634 // Find ISAC with explicit clockrate and 0 bitrate.
635 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kIsacCodec, &codec_inst)); 635 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kIsacCodec, &codec_inst));
636 // Find telephone-event with explicit clockrate and 0 bitrate. 636 // Find telephone-event with explicit clockrate and 0 bitrate.
637 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kTelephoneEventCodec, 637 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kTelephoneEventCodec1,
638 &codec_inst));
639 // Find telephone-event with explicit clockrate and 0 bitrate.
640 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kTelephoneEventCodec2,
638 &codec_inst)); 641 &codec_inst));
639 // Find ISAC with a different payload id. 642 // Find ISAC with a different payload id.
640 codec = kIsacCodec; 643 codec = kIsacCodec;
641 codec.id = 127; 644 codec.id = 127;
642 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); 645 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst));
643 EXPECT_EQ(codec.id, codec_inst.pltype); 646 EXPECT_EQ(codec.id, codec_inst.pltype);
644 // Find PCMU with a 0 clockrate. 647 // Find PCMU with a 0 clockrate.
645 codec = kPcmuCodec; 648 codec = kPcmuCodec;
646 codec.clockrate = 0; 649 codec.clockrate = 0;
647 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); 650 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst));
(...skipping 12 matching lines...) Expand all
660 EXPECT_EQ(codec.id, codec_inst.pltype); 663 EXPECT_EQ(codec.id, codec_inst.pltype);
661 EXPECT_EQ(32000, codec_inst.rate); 664 EXPECT_EQ(32000, codec_inst.rate);
662 } 665 }
663 666
664 // Test that we set our inbound codecs properly, including changing PT. 667 // Test that we set our inbound codecs properly, including changing PT.
665 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { 668 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) {
666 EXPECT_TRUE(SetupChannel()); 669 EXPECT_TRUE(SetupChannel());
667 cricket::AudioRecvParameters parameters; 670 cricket::AudioRecvParameters parameters;
668 parameters.codecs.push_back(kIsacCodec); 671 parameters.codecs.push_back(kIsacCodec);
669 parameters.codecs.push_back(kPcmuCodec); 672 parameters.codecs.push_back(kPcmuCodec);
670 parameters.codecs.push_back(kTelephoneEventCodec); 673 parameters.codecs.push_back(kTelephoneEventCodec1);
671 parameters.codecs[0].id = 106; // collide with existing telephone-event 674 parameters.codecs.push_back(kTelephoneEventCodec2);
675 parameters.codecs[0].id = 106; // collide with existing CN 32k
672 parameters.codecs[2].id = 126; 676 parameters.codecs[2].id = 126;
673 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 677 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
674 EXPECT_TRUE(AddRecvStream(kSsrc1)); 678 EXPECT_TRUE(AddRecvStream(kSsrc1));
675 int channel_num = voe_.GetLastChannel(); 679 int channel_num = voe_.GetLastChannel();
680
676 webrtc::CodecInst gcodec; 681 webrtc::CodecInst gcodec;
677 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); 682 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
678 gcodec.plfreq = 16000; 683 gcodec.plfreq = 16000;
679 gcodec.channels = 1; 684 gcodec.channels = 1;
680 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); 685 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
681 EXPECT_EQ(106, gcodec.pltype); 686 EXPECT_EQ(106, gcodec.pltype);
682 EXPECT_STREQ("ISAC", gcodec.plname); 687 EXPECT_STREQ("ISAC", gcodec.plname);
688
683 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event"); 689 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event");
684 gcodec.plfreq = 8000; 690 gcodec.plfreq = 8000;
685 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); 691 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
686 EXPECT_EQ(126, gcodec.pltype); 692 EXPECT_EQ(126, gcodec.pltype);
687 EXPECT_STREQ("telephone-event", gcodec.plname); 693 EXPECT_STREQ("telephone-event", gcodec.plname);
694
695 gcodec.plfreq = 32000;
696 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
697 EXPECT_EQ(107, gcodec.pltype);
698 EXPECT_STREQ("telephone-event", gcodec.plname);
688 } 699 }
689 700
690 // Test that we fail to set an unknown inbound codec. 701 // Test that we fail to set an unknown inbound codec.
691 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) { 702 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsUnsupportedCodec) {
692 EXPECT_TRUE(SetupChannel()); 703 EXPECT_TRUE(SetupChannel());
693 cricket::AudioRecvParameters parameters; 704 cricket::AudioRecvParameters parameters;
694 parameters.codecs.push_back(kIsacCodec); 705 parameters.codecs.push_back(kIsacCodec);
695 parameters.codecs.push_back(cricket::AudioCodec(127, "XYZ", 32000, 0, 1)); 706 parameters.codecs.push_back(cricket::AudioCodec(127, "XYZ", 32000, 0, 1));
696 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); 707 EXPECT_FALSE(channel_->SetRecvParameters(parameters));
697 } 708 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); 780 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus));
770 EXPECT_EQ(111, opus.pltype); 781 EXPECT_EQ(111, opus.pltype);
771 } 782 }
772 783
773 // Test that changes to recv codecs are applied to all streams. 784 // Test that changes to recv codecs are applied to all streams.
774 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { 785 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) {
775 EXPECT_TRUE(SetupChannel()); 786 EXPECT_TRUE(SetupChannel());
776 cricket::AudioRecvParameters parameters; 787 cricket::AudioRecvParameters parameters;
777 parameters.codecs.push_back(kIsacCodec); 788 parameters.codecs.push_back(kIsacCodec);
778 parameters.codecs.push_back(kPcmuCodec); 789 parameters.codecs.push_back(kPcmuCodec);
779 parameters.codecs.push_back(kTelephoneEventCodec); 790 parameters.codecs.push_back(kTelephoneEventCodec1);
780 parameters.codecs[0].id = 106; // collide with existing telephone-event 791 parameters.codecs.push_back(kTelephoneEventCodec2);
792 parameters.codecs[0].id = 106; // collide with existing CN 32k
781 parameters.codecs[2].id = 126; 793 parameters.codecs[2].id = 126;
782 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 794 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
783 EXPECT_TRUE(AddRecvStream(kSsrc1)); 795 EXPECT_TRUE(AddRecvStream(kSsrc1));
784 int channel_num2 = voe_.GetLastChannel(); 796 int channel_num2 = voe_.GetLastChannel();
797
785 webrtc::CodecInst gcodec; 798 webrtc::CodecInst gcodec;
786 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); 799 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
787 gcodec.plfreq = 16000; 800 gcodec.plfreq = 16000;
788 gcodec.channels = 1; 801 gcodec.channels = 1;
789 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 802 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
790 EXPECT_EQ(106, gcodec.pltype); 803 EXPECT_EQ(106, gcodec.pltype);
791 EXPECT_STREQ("ISAC", gcodec.plname); 804 EXPECT_STREQ("ISAC", gcodec.plname);
805
792 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event"); 806 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event");
793 gcodec.plfreq = 8000; 807 gcodec.plfreq = 8000;
794 gcodec.channels = 1; 808 gcodec.channels = 1;
795 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 809 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
796 EXPECT_EQ(126, gcodec.pltype); 810 EXPECT_EQ(126, gcodec.pltype);
797 EXPECT_STREQ("telephone-event", gcodec.plname); 811 EXPECT_STREQ("telephone-event", gcodec.plname);
812
813 gcodec.plfreq = 32000;
814 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
815 EXPECT_EQ(107, gcodec.pltype);
816 EXPECT_STREQ("telephone-event", gcodec.plname);
798 } 817 }
799 818
800 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { 819 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) {
801 EXPECT_TRUE(SetupRecvStream()); 820 EXPECT_TRUE(SetupRecvStream());
802 cricket::AudioRecvParameters parameters; 821 cricket::AudioRecvParameters parameters;
803 parameters.codecs.push_back(kIsacCodec); 822 parameters.codecs.push_back(kIsacCodec);
804 parameters.codecs[0].id = 106; // collide with existing telephone-event 823 parameters.codecs[0].id = 106; // collide with existing CN 32k
805 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 824 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
806 825
807 int channel_num2 = voe_.GetLastChannel(); 826 int channel_num2 = voe_.GetLastChannel();
808 webrtc::CodecInst gcodec; 827 webrtc::CodecInst gcodec;
809 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); 828 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
810 gcodec.plfreq = 16000; 829 gcodec.plfreq = 16000;
811 gcodec.channels = 1; 830 gcodec.channels = 1;
812 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); 831 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
813 EXPECT_EQ(106, gcodec.pltype); 832 EXPECT_EQ(106, gcodec.pltype);
814 EXPECT_STREQ("ISAC", gcodec.plname); 833 EXPECT_STREQ("ISAC", gcodec.plname);
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 EXPECT_TRUE(SetupSendStream()); 1861 EXPECT_TRUE(SetupSendStream());
1843 cricket::AudioSendParameters parameters; 1862 cricket::AudioSendParameters parameters;
1844 EXPECT_FALSE(channel_->SetSendParameters(parameters)); 1863 EXPECT_FALSE(channel_->SetSendParameters(parameters));
1845 } 1864 }
1846 1865
1847 // Test that we can set send codecs even with telephone-event codec as the first 1866 // Test that we can set send codecs even with telephone-event codec as the first
1848 // one on the list. 1867 // one on the list.
1849 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { 1868 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) {
1850 EXPECT_TRUE(SetupSendStream()); 1869 EXPECT_TRUE(SetupSendStream());
1851 cricket::AudioSendParameters parameters; 1870 cricket::AudioSendParameters parameters;
1852 parameters.codecs.push_back(kTelephoneEventCodec); 1871 parameters.codecs.push_back(kTelephoneEventCodec1);
1853 parameters.codecs.push_back(kIsacCodec); 1872 parameters.codecs.push_back(kIsacCodec);
1854 parameters.codecs.push_back(kPcmuCodec); 1873 parameters.codecs.push_back(kPcmuCodec);
1855 parameters.codecs[0].id = 98; // DTMF 1874 parameters.codecs[0].id = 98; // DTMF
1856 parameters.codecs[1].id = 96; 1875 parameters.codecs[1].id = 96;
1857 SetSendParameters(parameters); 1876 SetSendParameters(parameters);
1858 const auto& gcodec = GetSendStreamConfig(kSsrc1).send_codec_spec.codec_inst; 1877 const auto& gcodec = GetSendStreamConfig(kSsrc1).send_codec_spec.codec_inst;
1859 EXPECT_EQ(96, gcodec.pltype); 1878 EXPECT_EQ(96, gcodec.pltype);
1860 EXPECT_STREQ("ISAC", gcodec.plname); 1879 EXPECT_STREQ("ISAC", gcodec.plname);
1861 EXPECT_TRUE(channel_->CanInsertDtmf()); 1880 EXPECT_TRUE(channel_->CanInsertDtmf());
1862 } 1881 }
1863 1882
1864 // Test that payload type range is limited for telephone-event codec. 1883 // Test that payload type range is limited for telephone-event codec.
1865 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) { 1884 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFPayloadTypeOutOfRange) {
1866 EXPECT_TRUE(SetupSendStream()); 1885 EXPECT_TRUE(SetupSendStream());
1867 cricket::AudioSendParameters parameters; 1886 cricket::AudioSendParameters parameters;
1868 parameters.codecs.push_back(kTelephoneEventCodec); 1887 parameters.codecs.push_back(kTelephoneEventCodec1);
1869 parameters.codecs.push_back(kIsacCodec); 1888 parameters.codecs.push_back(kIsacCodec);
1870 parameters.codecs[0].id = 0; // DTMF 1889 parameters.codecs[0].id = 0; // DTMF
1871 parameters.codecs[1].id = 96; 1890 parameters.codecs[1].id = 96;
1872 SetSendParameters(parameters); 1891 SetSendParameters(parameters);
1873 EXPECT_TRUE(channel_->CanInsertDtmf()); 1892 EXPECT_TRUE(channel_->CanInsertDtmf());
1874 parameters.codecs[0].id = 128; // DTMF 1893 parameters.codecs[0].id = 128; // DTMF
1875 EXPECT_FALSE(channel_->SetSendParameters(parameters)); 1894 EXPECT_FALSE(channel_->SetSendParameters(parameters));
1876 EXPECT_FALSE(channel_->CanInsertDtmf()); 1895 EXPECT_FALSE(channel_->CanInsertDtmf());
1877 parameters.codecs[0].id = 127; 1896 parameters.codecs[0].id = 127;
1878 SetSendParameters(parameters); 1897 SetSendParameters(parameters);
(...skipping 23 matching lines...) Expand all
1902 1921
1903 // Test that we set VAD and DTMF types correctly as caller. 1922 // Test that we set VAD and DTMF types correctly as caller.
1904 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { 1923 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) {
1905 EXPECT_TRUE(SetupSendStream()); 1924 EXPECT_TRUE(SetupSendStream());
1906 cricket::AudioSendParameters parameters; 1925 cricket::AudioSendParameters parameters;
1907 parameters.codecs.push_back(kIsacCodec); 1926 parameters.codecs.push_back(kIsacCodec);
1908 parameters.codecs.push_back(kPcmuCodec); 1927 parameters.codecs.push_back(kPcmuCodec);
1909 // TODO(juberti): cn 32000 1928 // TODO(juberti): cn 32000
1910 parameters.codecs.push_back(kCn16000Codec); 1929 parameters.codecs.push_back(kCn16000Codec);
1911 parameters.codecs.push_back(kCn8000Codec); 1930 parameters.codecs.push_back(kCn8000Codec);
1912 parameters.codecs.push_back(kTelephoneEventCodec); 1931 parameters.codecs.push_back(kTelephoneEventCodec1);
1913 parameters.codecs[0].id = 96; 1932 parameters.codecs[0].id = 96;
1914 parameters.codecs[2].id = 97; // wideband CN 1933 parameters.codecs[2].id = 97; // wideband CN
1915 parameters.codecs[4].id = 98; // DTMF 1934 parameters.codecs[4].id = 98; // DTMF
1916 SetSendParameters(parameters); 1935 SetSendParameters(parameters);
1917 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec; 1936 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec;
1918 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); 1937 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype);
1919 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); 1938 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname);
1920 EXPECT_EQ(1, send_codec_spec.codec_inst.channels); 1939 EXPECT_EQ(1, send_codec_spec.codec_inst.channels);
1921 EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); 1940 EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq);
1922 EXPECT_EQ(97, send_codec_spec.cng_payload_type); 1941 EXPECT_EQ(97, send_codec_spec.cng_payload_type);
1923 EXPECT_EQ(webrtc::kFreq16000Hz, send_codec_spec.cng_plfreq); 1942 EXPECT_EQ(webrtc::kFreq16000Hz, send_codec_spec.cng_plfreq);
1924 EXPECT_TRUE(channel_->CanInsertDtmf()); 1943 EXPECT_TRUE(channel_->CanInsertDtmf());
1925 } 1944 }
1926 1945
1927 // Test that we set VAD and DTMF types correctly as callee. 1946 // Test that we set VAD and DTMF types correctly as callee.
1928 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { 1947 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
1929 EXPECT_TRUE(SetupChannel()); 1948 EXPECT_TRUE(SetupChannel());
1930 cricket::AudioSendParameters parameters; 1949 cricket::AudioSendParameters parameters;
1931 parameters.codecs.push_back(kIsacCodec); 1950 parameters.codecs.push_back(kIsacCodec);
1932 parameters.codecs.push_back(kPcmuCodec); 1951 parameters.codecs.push_back(kPcmuCodec);
1933 // TODO(juberti): cn 32000 1952 // TODO(juberti): cn 32000
1934 parameters.codecs.push_back(kCn16000Codec); 1953 parameters.codecs.push_back(kCn16000Codec);
1935 parameters.codecs.push_back(kCn8000Codec); 1954 parameters.codecs.push_back(kCn8000Codec);
1936 parameters.codecs.push_back(kTelephoneEventCodec); 1955 parameters.codecs.push_back(kTelephoneEventCodec1);
1937 parameters.codecs[0].id = 96; 1956 parameters.codecs[0].id = 96;
1938 parameters.codecs[2].id = 97; // wideband CN 1957 parameters.codecs[2].id = 97; // wideband CN
1939 parameters.codecs[4].id = 98; // DTMF 1958 parameters.codecs[4].id = 98; // DTMF
1940 SetSendParameters(parameters); 1959 SetSendParameters(parameters);
1941 EXPECT_TRUE(channel_->AddSendStream( 1960 EXPECT_TRUE(channel_->AddSendStream(
1942 cricket::StreamParams::CreateLegacy(kSsrc1))); 1961 cricket::StreamParams::CreateLegacy(kSsrc1)));
1943 1962
1944 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec; 1963 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec;
1945 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); 1964 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype);
1946 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); 1965 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 } 2018 }
2000 2019
2001 // Test that we perform case-insensitive matching of codec names. 2020 // Test that we perform case-insensitive matching of codec names.
2002 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { 2021 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) {
2003 EXPECT_TRUE(SetupSendStream()); 2022 EXPECT_TRUE(SetupSendStream());
2004 cricket::AudioSendParameters parameters; 2023 cricket::AudioSendParameters parameters;
2005 parameters.codecs.push_back(kIsacCodec); 2024 parameters.codecs.push_back(kIsacCodec);
2006 parameters.codecs.push_back(kPcmuCodec); 2025 parameters.codecs.push_back(kPcmuCodec);
2007 parameters.codecs.push_back(kCn16000Codec); 2026 parameters.codecs.push_back(kCn16000Codec);
2008 parameters.codecs.push_back(kCn8000Codec); 2027 parameters.codecs.push_back(kCn8000Codec);
2009 parameters.codecs.push_back(kTelephoneEventCodec); 2028 parameters.codecs.push_back(kTelephoneEventCodec1);
2010 parameters.codecs[0].name = "iSaC"; 2029 parameters.codecs[0].name = "iSaC";
2011 parameters.codecs[0].id = 96; 2030 parameters.codecs[0].id = 96;
2012 parameters.codecs[2].id = 97; // wideband CN 2031 parameters.codecs[2].id = 97; // wideband CN
2013 parameters.codecs[4].id = 98; // DTMF 2032 parameters.codecs[4].id = 98; // DTMF
2014 SetSendParameters(parameters); 2033 SetSendParameters(parameters);
2015 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec; 2034 const auto& send_codec_spec = GetSendStreamConfig(kSsrc1).send_codec_spec;
2016 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); 2035 EXPECT_EQ(96, send_codec_spec.codec_inst.pltype);
2017 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); 2036 EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname);
2018 EXPECT_EQ(1, send_codec_spec.codec_inst.channels); 2037 EXPECT_EQ(1, send_codec_spec.codec_inst.channels);
2019 EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); 2038 EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq);
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
3397 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3416 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3398 cricket::AudioCodec(96, "ILBC", 8000, 0, 1), nullptr)); 3417 cricket::AudioCodec(96, "ILBC", 8000, 0, 1), nullptr));
3399 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3418 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3400 cricket::AudioCodec(96, "iLBC", 8000, 0, 1), nullptr)); 3419 cricket::AudioCodec(96, "iLBC", 8000, 0, 1), nullptr));
3401 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3420 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3402 cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr)); 3421 cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr));
3403 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3422 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3404 cricket::AudioCodec(96, "CN", 16000, 0, 1), nullptr)); 3423 cricket::AudioCodec(96, "CN", 16000, 0, 1), nullptr));
3405 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3424 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3406 cricket::AudioCodec(96, "telephone-event", 8000, 0, 1), nullptr)); 3425 cricket::AudioCodec(96, "telephone-event", 8000, 0, 1), nullptr));
3426 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3427 cricket::AudioCodec(96, "telephone-event", 16000, 0, 1), nullptr));
3428 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3429 cricket::AudioCodec(96, "telephone-event", 32000, 0, 1), nullptr));
3430 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3431 cricket::AudioCodec(96, "telephone-event", 48000, 0, 1), nullptr));
3407 // Check codecs with an id by id. 3432 // Check codecs with an id by id.
3408 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3433 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3409 cricket::AudioCodec(0, "", 8000, 0, 1), nullptr)); // PCMU 3434 cricket::AudioCodec(0, "", 8000, 0, 1), nullptr)); // PCMU
3410 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3435 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3411 cricket::AudioCodec(8, "", 8000, 0, 1), nullptr)); // PCMA 3436 cricket::AudioCodec(8, "", 8000, 0, 1), nullptr)); // PCMA
3412 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3437 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3413 cricket::AudioCodec(9, "", 8000, 0, 1), nullptr)); // G722 3438 cricket::AudioCodec(9, "", 8000, 0, 1), nullptr)); // G722
3414 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3439 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3415 cricket::AudioCodec(13, "", 8000, 0, 1), nullptr)); // CN 3440 cricket::AudioCodec(13, "", 8000, 0, 1), nullptr)); // CN
3416 // Check sample/bitrate matching. 3441 // Check sample/bitrate matching.
3417 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3442 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3418 cricket::AudioCodec(0, "PCMU", 8000, 64000, 1), nullptr)); 3443 cricket::AudioCodec(0, "PCMU", 8000, 64000, 1), nullptr));
3419 // Check that bad codecs fail. 3444 // Check that bad codecs fail.
3420 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( 3445 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst(
3421 cricket::AudioCodec(99, "ABCD", 0, 0, 1), nullptr)); 3446 cricket::AudioCodec(99, "ABCD", 0, 0, 1), nullptr));
3422 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( 3447 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst(
3423 cricket::AudioCodec(88, "", 0, 0, 1), nullptr)); 3448 cricket::AudioCodec(88, "", 0, 0, 1), nullptr));
3424 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( 3449 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst(
3425 cricket::AudioCodec(0, "", 0, 0, 2), nullptr)); 3450 cricket::AudioCodec(0, "", 0, 0, 2), nullptr));
3426 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( 3451 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst(
3427 cricket::AudioCodec(0, "", 5000, 0, 1), nullptr)); 3452 cricket::AudioCodec(0, "", 5000, 0, 1), nullptr));
3428 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( 3453 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst(
3429 cricket::AudioCodec(0, "", 0, 5000, 1), nullptr)); 3454 cricket::AudioCodec(0, "", 0, 5000, 1), nullptr));
3430 3455
3431 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. 3456 // Verify the payload id of common audio codecs, including CN, ISAC, and G722.
3432 // TODO(ossu): Why are the payload types of codecs with non-static payload 3457 // TODO(ossu): Why are the payload types of codecs with non-static payload
3433 // type assignments checked here? It shouldn't really matter. 3458 // type assignments checked here? It shouldn't really matter.
3434 cricket::WebRtcVoiceEngine engine( 3459 cricket::WebRtcVoiceEngine engine(
3435 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); 3460 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory());
3436 for (std::vector<cricket::AudioCodec>::const_iterator it = 3461 for (const cricket::AudioCodec& codec : engine.send_codecs()) {
3437 engine.send_codecs().begin(); 3462 if (codec.name == "CN" && codec.clockrate == 16000) {
3438 it != engine.send_codecs().end(); ++it) { 3463 EXPECT_EQ(105, codec.id);
3439 if (it->name == "CN" && it->clockrate == 16000) { 3464 } else if (codec.name == "CN" && codec.clockrate == 32000) {
3440 EXPECT_EQ(105, it->id); 3465 EXPECT_EQ(106, codec.id);
3441 } else if (it->name == "CN" && it->clockrate == 32000) { 3466 } else if (codec.name == "ISAC" && codec.clockrate == 16000) {
3442 EXPECT_EQ(106, it->id); 3467 EXPECT_EQ(103, codec.id);
3443 } else if (it->name == "ISAC" && it->clockrate == 16000) { 3468 } else if (codec.name == "ISAC" && codec.clockrate == 32000) {
3444 EXPECT_EQ(103, it->id); 3469 EXPECT_EQ(104, codec.id);
3445 } else if (it->name == "ISAC" && it->clockrate == 32000) { 3470 } else if (codec.name == "G722" && codec.clockrate == 8000) {
3446 EXPECT_EQ(104, it->id); 3471 EXPECT_EQ(9, codec.id);
3447 } else if (it->name == "G722" && it->clockrate == 8000) { 3472 } else if (codec.name == "telephone-event" && codec.clockrate == 8000) {
3448 EXPECT_EQ(9, it->id); 3473 EXPECT_EQ(126, codec.id);
3449 } else if (it->name == "telephone-event") { 3474 // TODO(solenberg): 16k, 32k, 48k DTMF should be dynamically assigned.
3450 EXPECT_EQ(126, it->id); 3475 // Remove these checks once both send and receive side assigns payload types
3451 } else if (it->name == "opus") { 3476 // dynamically.
3452 EXPECT_EQ(111, it->id); 3477 } else if (codec.name == "telephone-event" && codec.clockrate == 16000) {
3453 ASSERT_TRUE(it->params.find("minptime") != it->params.end()); 3478 EXPECT_EQ(113, codec.id);
3454 EXPECT_EQ("10", it->params.find("minptime")->second); 3479 } else if (codec.name == "telephone-event" && codec.clockrate == 32000) {
3455 ASSERT_TRUE(it->params.find("useinbandfec") != it->params.end()); 3480 EXPECT_EQ(112, codec.id);
3456 EXPECT_EQ("1", it->params.find("useinbandfec")->second); 3481 } else if (codec.name == "telephone-event" && codec.clockrate == 48000) {
3482 EXPECT_EQ(110, codec.id);
3483 } else if (codec.name == "opus") {
3484 EXPECT_EQ(111, codec.id);
3485 ASSERT_TRUE(codec.params.find("minptime") != codec.params.end());
3486 EXPECT_EQ("10", codec.params.find("minptime")->second);
3487 ASSERT_TRUE(codec.params.find("useinbandfec") != codec.params.end());
3488 EXPECT_EQ("1", codec.params.find("useinbandfec")->second);
3457 } 3489 }
3458 } 3490 }
3459 } 3491 }
3460 3492
3461 // Tests that VoE supports at least 32 channels 3493 // Tests that VoE supports at least 32 channels
3462 TEST(WebRtcVoiceEngineTest, Has32Channels) { 3494 TEST(WebRtcVoiceEngineTest, Has32Channels) {
3463 cricket::WebRtcVoiceEngine engine( 3495 cricket::WebRtcVoiceEngine engine(
3464 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory()); 3496 nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory());
3465 webrtc::RtcEventLogNullImpl event_log; 3497 webrtc::RtcEventLogNullImpl event_log;
3466 std::unique_ptr<webrtc::Call> call( 3498 std::unique_ptr<webrtc::Call> call(
(...skipping 30 matching lines...) Expand all
3497 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); 3529 nullptr, webrtc::CreateBuiltinAudioDecoderFactory());
3498 webrtc::RtcEventLogNullImpl event_log; 3530 webrtc::RtcEventLogNullImpl event_log;
3499 std::unique_ptr<webrtc::Call> call( 3531 std::unique_ptr<webrtc::Call> call(
3500 webrtc::Call::Create(webrtc::Call::Config(&event_log))); 3532 webrtc::Call::Create(webrtc::Call::Config(&event_log)));
3501 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3533 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3502 cricket::AudioOptions(), call.get()); 3534 cricket::AudioOptions(), call.get());
3503 cricket::AudioRecvParameters parameters; 3535 cricket::AudioRecvParameters parameters;
3504 parameters.codecs = engine.recv_codecs(); 3536 parameters.codecs = engine.recv_codecs();
3505 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3537 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3506 } 3538 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | webrtc/modules/audio_coding/acm2/acm_codec_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698