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

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

Issue 2051073002: Remove RED support from WebRtcVoiceEngine/MediaChannel (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 6 months 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') | no next file » | 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 18 matching lines...) Expand all
29 using testing::Return; 29 using testing::Return;
30 using testing::StrictMock; 30 using testing::StrictMock;
31 31
32 namespace { 32 namespace {
33 33
34 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1); 34 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1);
35 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1); 35 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1);
36 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2); 36 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2);
37 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1); 37 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1);
38 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1); 38 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1);
39 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1);
40 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1); 39 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1);
41 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1); 40 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1);
42 const cricket::AudioCodec kTelephoneEventCodec(106, 41 const cricket::AudioCodec kTelephoneEventCodec(106,
43 "telephone-event", 42 "telephone-event",
44 8000, 43 8000,
45 0, 44 0,
46 1); 45 1);
47 const uint32_t kSsrc1 = 0x99; 46 const uint32_t kSsrc1 = 0x99;
48 const uint32_t kSsrc2 = 2; 47 const uint32_t kSsrc2 = 2;
49 const uint32_t kSsrc3 = 3; 48 const uint32_t kSsrc3 = 3;
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 webrtc::RtpParameters new_params = channel_->GetRtpReceiveParameters(kSsrc1); 1033 webrtc::RtpParameters new_params = channel_->GetRtpReceiveParameters(kSsrc1);
1035 EXPECT_EQ(initial_params, channel_->GetRtpReceiveParameters(kSsrc1)); 1034 EXPECT_EQ(initial_params, channel_->GetRtpReceiveParameters(kSsrc1));
1036 } 1035 }
1037 1036
1038 // Test that we apply codecs properly. 1037 // Test that we apply codecs properly.
1039 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { 1038 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) {
1040 EXPECT_TRUE(SetupSendStream()); 1039 EXPECT_TRUE(SetupSendStream());
1041 cricket::AudioSendParameters parameters; 1040 cricket::AudioSendParameters parameters;
1042 parameters.codecs.push_back(kIsacCodec); 1041 parameters.codecs.push_back(kIsacCodec);
1043 parameters.codecs.push_back(kPcmuCodec); 1042 parameters.codecs.push_back(kPcmuCodec);
1044 parameters.codecs.push_back(kRedCodec); 1043 parameters.codecs.push_back(kCn8000Codec);
1045 parameters.codecs[0].id = 96; 1044 parameters.codecs[0].id = 96;
1046 parameters.codecs[0].bitrate = 48000; 1045 parameters.codecs[0].bitrate = 48000;
1047 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1046 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1048 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); 1047 EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
1049 int channel_num = voe_.GetLastChannel(); 1048 int channel_num = voe_.GetLastChannel();
1050 webrtc::CodecInst gcodec; 1049 webrtc::CodecInst gcodec;
1051 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1050 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1052 EXPECT_EQ(96, gcodec.pltype); 1051 EXPECT_EQ(96, gcodec.pltype);
1053 EXPECT_EQ(48000, gcodec.rate); 1052 EXPECT_EQ(48000, gcodec.rate);
1054 EXPECT_STREQ("ISAC", gcodec.plname); 1053 EXPECT_STREQ("ISAC", gcodec.plname);
1055 EXPECT_FALSE(voe_.GetVAD(channel_num)); 1054 EXPECT_FALSE(voe_.GetVAD(channel_num));
1056 EXPECT_FALSE(voe_.GetRED(channel_num));
1057 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 1055 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
1058 EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true)); 1056 EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true));
1059 EXPECT_FALSE(channel_->CanInsertDtmf()); 1057 EXPECT_FALSE(channel_->CanInsertDtmf());
1060 } 1058 }
1061 1059
1062 // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried 1060 // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried
1063 // to apply. 1061 // to apply.
1064 TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { 1062 TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) {
1065 EXPECT_TRUE(SetupSendStream()); 1063 EXPECT_TRUE(SetupSendStream());
1066 cricket::AudioSendParameters parameters; 1064 cricket::AudioSendParameters parameters;
1067 parameters.codecs.push_back(kIsacCodec); 1065 parameters.codecs.push_back(kIsacCodec);
1068 parameters.codecs.push_back(kPcmuCodec); 1066 parameters.codecs.push_back(kPcmuCodec);
1069 parameters.codecs.push_back(kRedCodec); 1067 parameters.codecs.push_back(kCn8000Codec);
1070 parameters.codecs[0].id = 96; 1068 parameters.codecs[0].id = 96;
1071 parameters.codecs[0].bitrate = 48000; 1069 parameters.codecs[0].bitrate = 48000;
1072 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1070 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1073 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); 1071 EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
1074 // Calling SetSendCodec again with same codec which is already set. 1072 // Calling SetSendCodec again with same codec which is already set.
1075 // In this case media channel shouldn't send codec to VoE. 1073 // In this case media channel shouldn't send codec to VoE.
1076 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1074 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1077 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); 1075 EXPECT_EQ(1, voe_.GetNumSetSendCodecs());
1078 } 1076 }
1079 1077
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { 1966 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) {
1969 EXPECT_TRUE(SetupSendStream()); 1967 EXPECT_TRUE(SetupSendStream());
1970 int channel_num = voe_.GetLastChannel(); 1968 int channel_num = voe_.GetLastChannel();
1971 cricket::AudioSendParameters parameters; 1969 cricket::AudioSendParameters parameters;
1972 parameters.codecs.push_back(kIsacCodec); 1970 parameters.codecs.push_back(kIsacCodec);
1973 parameters.codecs.push_back(kPcmuCodec); 1971 parameters.codecs.push_back(kPcmuCodec);
1974 // TODO(juberti): cn 32000 1972 // TODO(juberti): cn 32000
1975 parameters.codecs.push_back(kCn16000Codec); 1973 parameters.codecs.push_back(kCn16000Codec);
1976 parameters.codecs.push_back(kCn8000Codec); 1974 parameters.codecs.push_back(kCn8000Codec);
1977 parameters.codecs.push_back(kTelephoneEventCodec); 1975 parameters.codecs.push_back(kTelephoneEventCodec);
1978 parameters.codecs.push_back(kRedCodec);
1979 parameters.codecs[0].id = 96; 1976 parameters.codecs[0].id = 96;
1980 parameters.codecs[2].id = 97; // wideband CN 1977 parameters.codecs[2].id = 97; // wideband CN
1981 parameters.codecs[4].id = 98; // DTMF 1978 parameters.codecs[4].id = 98; // DTMF
1982 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1979 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1983 webrtc::CodecInst gcodec; 1980 webrtc::CodecInst gcodec;
1984 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1981 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1985 EXPECT_EQ(96, gcodec.pltype); 1982 EXPECT_EQ(96, gcodec.pltype);
1986 EXPECT_STREQ("ISAC", gcodec.plname); 1983 EXPECT_STREQ("ISAC", gcodec.plname);
1987 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1984 EXPECT_TRUE(voe_.GetVAD(channel_num));
1988 EXPECT_FALSE(voe_.GetRED(channel_num));
1989 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 1985 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
1990 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1986 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1991 EXPECT_TRUE(channel_->CanInsertDtmf()); 1987 EXPECT_TRUE(channel_->CanInsertDtmf());
1992 } 1988 }
1993 1989
1994 // Test that we set VAD and DTMF types correctly as callee. 1990 // Test that we set VAD and DTMF types correctly as callee.
1995 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { 1991 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
1996 EXPECT_TRUE(SetupChannel()); 1992 EXPECT_TRUE(SetupChannel());
1997 cricket::AudioSendParameters parameters; 1993 cricket::AudioSendParameters parameters;
1998 parameters.codecs.push_back(kIsacCodec); 1994 parameters.codecs.push_back(kIsacCodec);
1999 parameters.codecs.push_back(kPcmuCodec); 1995 parameters.codecs.push_back(kPcmuCodec);
2000 // TODO(juberti): cn 32000 1996 // TODO(juberti): cn 32000
2001 parameters.codecs.push_back(kCn16000Codec); 1997 parameters.codecs.push_back(kCn16000Codec);
2002 parameters.codecs.push_back(kCn8000Codec); 1998 parameters.codecs.push_back(kCn8000Codec);
2003 parameters.codecs.push_back(kTelephoneEventCodec); 1999 parameters.codecs.push_back(kTelephoneEventCodec);
2004 parameters.codecs.push_back(kRedCodec);
2005 parameters.codecs[0].id = 96; 2000 parameters.codecs[0].id = 96;
2006 parameters.codecs[2].id = 97; // wideband CN 2001 parameters.codecs[2].id = 97; // wideband CN
2007 parameters.codecs[4].id = 98; // DTMF 2002 parameters.codecs[4].id = 98; // DTMF
2008 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2003 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2009 EXPECT_TRUE(channel_->AddSendStream( 2004 EXPECT_TRUE(channel_->AddSendStream(
2010 cricket::StreamParams::CreateLegacy(kSsrc1))); 2005 cricket::StreamParams::CreateLegacy(kSsrc1)));
2011 int channel_num = voe_.GetLastChannel(); 2006 int channel_num = voe_.GetLastChannel();
2012 2007
2013 webrtc::CodecInst gcodec; 2008 webrtc::CodecInst gcodec;
2014 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 2009 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2015 EXPECT_EQ(96, gcodec.pltype); 2010 EXPECT_EQ(96, gcodec.pltype);
2016 EXPECT_STREQ("ISAC", gcodec.plname); 2011 EXPECT_STREQ("ISAC", gcodec.plname);
2017 EXPECT_TRUE(voe_.GetVAD(channel_num)); 2012 EXPECT_TRUE(voe_.GetVAD(channel_num));
2018 EXPECT_FALSE(voe_.GetRED(channel_num));
2019 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 2013 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
2020 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 2014 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
2021 EXPECT_TRUE(channel_->CanInsertDtmf()); 2015 EXPECT_TRUE(channel_->CanInsertDtmf());
2022 } 2016 }
2023 2017
2024 // Test that we only apply VAD if we have a CN codec that matches the 2018 // Test that we only apply VAD if we have a CN codec that matches the
2025 // send codec clockrate. 2019 // send codec clockrate.
2026 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { 2020 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) {
2027 EXPECT_TRUE(SetupSendStream()); 2021 EXPECT_TRUE(SetupSendStream());
2028 int channel_num = voe_.GetLastChannel(); 2022 int channel_num = voe_.GetLastChannel();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 // Test that we perform case-insensitive matching of codec names. 2055 // Test that we perform case-insensitive matching of codec names.
2062 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { 2056 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) {
2063 EXPECT_TRUE(SetupSendStream()); 2057 EXPECT_TRUE(SetupSendStream());
2064 int channel_num = voe_.GetLastChannel(); 2058 int channel_num = voe_.GetLastChannel();
2065 cricket::AudioSendParameters parameters; 2059 cricket::AudioSendParameters parameters;
2066 parameters.codecs.push_back(kIsacCodec); 2060 parameters.codecs.push_back(kIsacCodec);
2067 parameters.codecs.push_back(kPcmuCodec); 2061 parameters.codecs.push_back(kPcmuCodec);
2068 parameters.codecs.push_back(kCn16000Codec); 2062 parameters.codecs.push_back(kCn16000Codec);
2069 parameters.codecs.push_back(kCn8000Codec); 2063 parameters.codecs.push_back(kCn8000Codec);
2070 parameters.codecs.push_back(kTelephoneEventCodec); 2064 parameters.codecs.push_back(kTelephoneEventCodec);
2071 parameters.codecs.push_back(kRedCodec);
2072 parameters.codecs[0].name = "iSaC"; 2065 parameters.codecs[0].name = "iSaC";
2073 parameters.codecs[0].id = 96; 2066 parameters.codecs[0].id = 96;
2074 parameters.codecs[2].id = 97; // wideband CN 2067 parameters.codecs[2].id = 97; // wideband CN
2075 parameters.codecs[4].id = 98; // DTMF 2068 parameters.codecs[4].id = 98; // DTMF
2076 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2069 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2077 webrtc::CodecInst gcodec; 2070 webrtc::CodecInst gcodec;
2078 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 2071 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2079 EXPECT_EQ(96, gcodec.pltype); 2072 EXPECT_EQ(96, gcodec.pltype);
2080 EXPECT_STREQ("ISAC", gcodec.plname); 2073 EXPECT_STREQ("ISAC", gcodec.plname);
2081 EXPECT_TRUE(voe_.GetVAD(channel_num)); 2074 EXPECT_TRUE(voe_.GetVAD(channel_num));
2082 EXPECT_FALSE(voe_.GetRED(channel_num));
2083 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 2075 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
2084 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 2076 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
2085 EXPECT_TRUE(channel_->CanInsertDtmf()); 2077 EXPECT_TRUE(channel_->CanInsertDtmf());
2086 } 2078 }
2087 2079
2088 // Test that we set up RED correctly as caller.
2089 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) {
2090 EXPECT_TRUE(SetupSendStream());
2091 int channel_num = voe_.GetLastChannel();
2092 cricket::AudioSendParameters parameters;
2093 parameters.codecs.push_back(kRedCodec);
2094 parameters.codecs.push_back(kIsacCodec);
2095 parameters.codecs.push_back(kPcmuCodec);
2096 parameters.codecs[0].id = 127;
2097 parameters.codecs[0].params[""] = "96/96";
2098 parameters.codecs[1].id = 96;
2099 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2100 webrtc::CodecInst gcodec;
2101 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2102 EXPECT_EQ(96, gcodec.pltype);
2103 EXPECT_STREQ("ISAC", gcodec.plname);
2104 EXPECT_TRUE(voe_.GetRED(channel_num));
2105 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
2106 }
2107
2108 // Test that we set up RED correctly as callee.
2109 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) {
2110 EXPECT_TRUE(SetupChannel());
2111 cricket::AudioSendParameters parameters;
2112 parameters.codecs.push_back(kRedCodec);
2113 parameters.codecs.push_back(kIsacCodec);
2114 parameters.codecs.push_back(kPcmuCodec);
2115 parameters.codecs[0].id = 127;
2116 parameters.codecs[0].params[""] = "96/96";
2117 parameters.codecs[1].id = 96;
2118 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2119 EXPECT_TRUE(channel_->AddSendStream(
2120 cricket::StreamParams::CreateLegacy(kSsrc1)));
2121 int channel_num = voe_.GetLastChannel();
2122 webrtc::CodecInst gcodec;
2123 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2124 EXPECT_EQ(96, gcodec.pltype);
2125 EXPECT_STREQ("ISAC", gcodec.plname);
2126 EXPECT_TRUE(voe_.GetRED(channel_num));
2127 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
2128 }
2129
2130 // Test that we set up RED correctly if params are omitted.
2131 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) {
2132 EXPECT_TRUE(SetupSendStream());
2133 int channel_num = voe_.GetLastChannel();
2134 cricket::AudioSendParameters parameters;
2135 parameters.codecs.push_back(kRedCodec);
2136 parameters.codecs.push_back(kIsacCodec);
2137 parameters.codecs.push_back(kPcmuCodec);
2138 parameters.codecs[0].id = 127;
2139 parameters.codecs[1].id = 96;
2140 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2141 webrtc::CodecInst gcodec;
2142 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2143 EXPECT_EQ(96, gcodec.pltype);
2144 EXPECT_STREQ("ISAC", gcodec.plname);
2145 EXPECT_TRUE(voe_.GetRED(channel_num));
2146 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
2147 }
2148
2149 // Test that we ignore RED if the parameters aren't named the way we expect.
2150 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) {
2151 EXPECT_TRUE(SetupSendStream());
2152 int channel_num = voe_.GetLastChannel();
2153 cricket::AudioSendParameters parameters;
2154 parameters.codecs.push_back(kRedCodec);
2155 parameters.codecs.push_back(kIsacCodec);
2156 parameters.codecs.push_back(kPcmuCodec);
2157 parameters.codecs[0].id = 127;
2158 parameters.codecs[0].params["ABC"] = "96/96";
2159 parameters.codecs[1].id = 96;
2160 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2161 webrtc::CodecInst gcodec;
2162 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2163 EXPECT_EQ(96, gcodec.pltype);
2164 EXPECT_STREQ("ISAC", gcodec.plname);
2165 EXPECT_FALSE(voe_.GetRED(channel_num));
2166 }
2167
2168 // Test that we ignore RED if it uses different primary/secondary encoding.
2169 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) {
2170 EXPECT_TRUE(SetupSendStream());
2171 int channel_num = voe_.GetLastChannel();
2172 cricket::AudioSendParameters parameters;
2173 parameters.codecs.push_back(kRedCodec);
2174 parameters.codecs.push_back(kIsacCodec);
2175 parameters.codecs.push_back(kPcmuCodec);
2176 parameters.codecs[0].id = 127;
2177 parameters.codecs[0].params[""] = "96/0";
2178 parameters.codecs[1].id = 96;
2179 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2180 webrtc::CodecInst gcodec;
2181 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2182 EXPECT_EQ(96, gcodec.pltype);
2183 EXPECT_STREQ("ISAC", gcodec.plname);
2184 EXPECT_FALSE(voe_.GetRED(channel_num));
2185 }
2186
2187 // Test that we ignore RED if it uses more than 2 encodings.
2188 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) {
2189 EXPECT_TRUE(SetupSendStream());
2190 int channel_num = voe_.GetLastChannel();
2191 cricket::AudioSendParameters parameters;
2192 parameters.codecs.push_back(kRedCodec);
2193 parameters.codecs.push_back(kIsacCodec);
2194 parameters.codecs.push_back(kPcmuCodec);
2195 parameters.codecs[0].id = 127;
2196 parameters.codecs[0].params[""] = "96/96/96";
2197 parameters.codecs[1].id = 96;
2198 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2199 webrtc::CodecInst gcodec;
2200 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2201 EXPECT_EQ(96, gcodec.pltype);
2202 EXPECT_STREQ("ISAC", gcodec.plname);
2203 EXPECT_FALSE(voe_.GetRED(channel_num));
2204 }
2205
2206 // Test that we ignore RED if it has bogus codec ids.
2207 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) {
2208 EXPECT_TRUE(SetupSendStream());
2209 int channel_num = voe_.GetLastChannel();
2210 cricket::AudioSendParameters parameters;
2211 parameters.codecs.push_back(kRedCodec);
2212 parameters.codecs.push_back(kIsacCodec);
2213 parameters.codecs.push_back(kPcmuCodec);
2214 parameters.codecs[0].id = 127;
2215 parameters.codecs[0].params[""] = "ABC/ABC";
2216 parameters.codecs[1].id = 96;
2217 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2218 webrtc::CodecInst gcodec;
2219 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2220 EXPECT_EQ(96, gcodec.pltype);
2221 EXPECT_STREQ("ISAC", gcodec.plname);
2222 EXPECT_FALSE(voe_.GetRED(channel_num));
2223 }
2224
2225 // Test that we ignore RED if it refers to a codec that is not present.
2226 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) {
2227 EXPECT_TRUE(SetupSendStream());
2228 int channel_num = voe_.GetLastChannel();
2229 cricket::AudioSendParameters parameters;
2230 parameters.codecs.push_back(kRedCodec);
2231 parameters.codecs.push_back(kIsacCodec);
2232 parameters.codecs.push_back(kPcmuCodec);
2233 parameters.codecs[0].id = 127;
2234 parameters.codecs[0].params[""] = "97/97";
2235 parameters.codecs[1].id = 96;
2236 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2237 webrtc::CodecInst gcodec;
2238 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
2239 EXPECT_EQ(96, gcodec.pltype);
2240 EXPECT_STREQ("ISAC", gcodec.plname);
2241 EXPECT_FALSE(voe_.GetRED(channel_num));
2242 }
2243
2244 class WebRtcVoiceEngineWithSendSideBweTest : public WebRtcVoiceEngineTestFake { 2080 class WebRtcVoiceEngineWithSendSideBweTest : public WebRtcVoiceEngineTestFake {
2245 public: 2081 public:
2246 WebRtcVoiceEngineWithSendSideBweTest() 2082 WebRtcVoiceEngineWithSendSideBweTest()
2247 : WebRtcVoiceEngineTestFake("WebRTC-Audio-SendSideBwe/Enabled/") {} 2083 : WebRtcVoiceEngineTestFake("WebRTC-Audio-SendSideBwe/Enabled/") {}
2248 }; 2084 };
2249 2085
2250 TEST_F(WebRtcVoiceEngineWithSendSideBweTest, 2086 TEST_F(WebRtcVoiceEngineWithSendSideBweTest,
2251 SupportsTransportSequenceNumberHeaderExtension) { 2087 SupportsTransportSequenceNumberHeaderExtension) {
2252 cricket::RtpCapabilities capabilities = engine_->GetCapabilities(); 2088 cricket::RtpCapabilities capabilities = engine_->GetCapabilities();
2253 ASSERT_FALSE(capabilities.header_extensions.empty()); 2089 ASSERT_FALSE(capabilities.header_extensions.empty());
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
3574 cricket::AudioCodec(96, "ILBC", 8000, 0, 1), nullptr)); 3410 cricket::AudioCodec(96, "ILBC", 8000, 0, 1), nullptr));
3575 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3411 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3576 cricket::AudioCodec(96, "iLBC", 8000, 0, 1), nullptr)); 3412 cricket::AudioCodec(96, "iLBC", 8000, 0, 1), nullptr));
3577 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3413 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3578 cricket::AudioCodec(96, "PCMU", 8000, 0, 1), nullptr)); 3414 cricket::AudioCodec(96, "PCMU", 8000, 0, 1), nullptr));
3579 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3415 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3580 cricket::AudioCodec(96, "PCMA", 8000, 0, 1), nullptr)); 3416 cricket::AudioCodec(96, "PCMA", 8000, 0, 1), nullptr));
3581 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3417 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3582 cricket::AudioCodec(96, "G722", 8000, 0, 1), nullptr)); 3418 cricket::AudioCodec(96, "G722", 8000, 0, 1), nullptr));
3583 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3419 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3584 cricket::AudioCodec(96, "red", 8000, 0, 1), nullptr));
3585 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3586 cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr)); 3420 cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr));
3587 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3421 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3588 cricket::AudioCodec(96, "CN", 16000, 0, 1), nullptr)); 3422 cricket::AudioCodec(96, "CN", 16000, 0, 1), nullptr));
3589 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3423 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3590 cricket::AudioCodec(96, "CN", 8000, 0, 1), nullptr)); 3424 cricket::AudioCodec(96, "CN", 8000, 0, 1), nullptr));
3591 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3425 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3592 cricket::AudioCodec(96, "telephone-event", 8000, 0, 1), nullptr)); 3426 cricket::AudioCodec(96, "telephone-event", 8000, 0, 1), nullptr));
3593 // Check codecs with an id by id. 3427 // Check codecs with an id by id.
3594 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( 3428 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
3595 cricket::AudioCodec(0, "", 8000, 0, 1), nullptr)); // PCMU 3429 cricket::AudioCodec(0, "", 8000, 0, 1), nullptr)); // PCMU
(...skipping 27 matching lines...) Expand all
3623 } else if (it->name == "CN" && it->clockrate == 32000) { 3457 } else if (it->name == "CN" && it->clockrate == 32000) {
3624 EXPECT_EQ(106, it->id); 3458 EXPECT_EQ(106, it->id);
3625 } else if (it->name == "ISAC" && it->clockrate == 16000) { 3459 } else if (it->name == "ISAC" && it->clockrate == 16000) {
3626 EXPECT_EQ(103, it->id); 3460 EXPECT_EQ(103, it->id);
3627 } else if (it->name == "ISAC" && it->clockrate == 32000) { 3461 } else if (it->name == "ISAC" && it->clockrate == 32000) {
3628 EXPECT_EQ(104, it->id); 3462 EXPECT_EQ(104, it->id);
3629 } else if (it->name == "G722" && it->clockrate == 8000) { 3463 } else if (it->name == "G722" && it->clockrate == 8000) {
3630 EXPECT_EQ(9, it->id); 3464 EXPECT_EQ(9, it->id);
3631 } else if (it->name == "telephone-event") { 3465 } else if (it->name == "telephone-event") {
3632 EXPECT_EQ(126, it->id); 3466 EXPECT_EQ(126, it->id);
3633 } else if (it->name == "red") {
3634 EXPECT_EQ(127, it->id);
3635 } else if (it->name == "opus") { 3467 } else if (it->name == "opus") {
3636 EXPECT_EQ(111, it->id); 3468 EXPECT_EQ(111, it->id);
3637 ASSERT_TRUE(it->params.find("minptime") != it->params.end()); 3469 ASSERT_TRUE(it->params.find("minptime") != it->params.end());
3638 EXPECT_EQ("10", it->params.find("minptime")->second); 3470 EXPECT_EQ("10", it->params.find("minptime")->second);
3639 ASSERT_TRUE(it->params.find("useinbandfec") != it->params.end()); 3471 ASSERT_TRUE(it->params.find("useinbandfec") != it->params.end());
3640 EXPECT_EQ("1", it->params.find("useinbandfec")->second); 3472 EXPECT_EQ("1", it->params.find("useinbandfec")->second);
3641 } 3473 }
3642 } 3474 }
3643 } 3475 }
3644 3476
(...skipping 25 matching lines...) Expand all
3670 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { 3502 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
3671 cricket::WebRtcVoiceEngine engine(nullptr); 3503 cricket::WebRtcVoiceEngine engine(nullptr);
3672 std::unique_ptr<webrtc::Call> call( 3504 std::unique_ptr<webrtc::Call> call(
3673 webrtc::Call::Create(webrtc::Call::Config())); 3505 webrtc::Call::Create(webrtc::Call::Config()));
3674 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3506 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3675 cricket::AudioOptions(), call.get()); 3507 cricket::AudioOptions(), call.get());
3676 cricket::AudioRecvParameters parameters; 3508 cricket::AudioRecvParameters parameters;
3677 parameters.codecs = engine.codecs(); 3509 parameters.codecs = engine.codecs();
3678 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3510 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3679 } 3511 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698