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

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

Issue 2775483004: Set max bitrate for audio send stream based on RtpParameters. (Closed)
Patch Set: fixing Created 3 years, 8 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 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 webrtc::RtpParameters initial_params = channel_->GetRtpSendParameters(kSsrcX); 1205 webrtc::RtpParameters initial_params = channel_->GetRtpSendParameters(kSsrcX);
1206 1206
1207 // We should be able to set the params we just got. 1207 // We should be able to set the params we just got.
1208 EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, initial_params)); 1208 EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, initial_params));
1209 1209
1210 // ... And this shouldn't change the params returned by GetRtpSendParameters. 1210 // ... And this shouldn't change the params returned by GetRtpSendParameters.
1211 webrtc::RtpParameters new_params = channel_->GetRtpSendParameters(kSsrcX); 1211 webrtc::RtpParameters new_params = channel_->GetRtpSendParameters(kSsrcX);
1212 EXPECT_EQ(initial_params, channel_->GetRtpSendParameters(kSsrcX)); 1212 EXPECT_EQ(initial_params, channel_->GetRtpSendParameters(kSsrcX));
1213 } 1213 }
1214 1214
1215 // Test that max_bitrate_bps in send stream config gets updated correctly when
1216 // SetRtpSendParameters is called.
1217 TEST_F(WebRtcVoiceEngineTestFake, SetRtpSendParameterUpdatesMaxBitrate) {
1218 webrtc::test::ScopedFieldTrials override_field_trials(
1219 "WebRTC-Audio-SendSideBwe/Enabled/");
1220 EXPECT_TRUE(SetupSendStream());
1221 cricket::AudioSendParameters send_parameters;
1222 send_parameters.codecs.push_back(kOpusCodec);
1223 SetSendParameters(send_parameters);
1224
1225 webrtc::RtpParameters rtp_parameters = channel_->GetRtpSendParameters(kSsrcX);
1226 // Expect empty on parameters.encodings[0].max_bitrate_bps;
1227 EXPECT_FALSE(rtp_parameters.encodings[0].max_bitrate_bps);
1228
1229 constexpr int kMaxBitrateBps = 6000;
1230 rtp_parameters.encodings[0].max_bitrate_bps =
1231 rtc::Optional<int>(kMaxBitrateBps);
1232 EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, rtp_parameters));
1233
1234 const int max_bitrate = GetSendStreamConfig(kSsrcX).max_bitrate_bps;
1235 EXPECT_EQ(max_bitrate, kMaxBitrateBps);
1236 }
1237
1238 // This test is similar to SetRtpSendParameterUpdatesMaxBitrate but with an
1239 // additional field trial.
1240 TEST_F(WebRtcVoiceEngineTestFake,
minyue-webrtc 2017/03/27 19:35:25 found a better place for this test, see PS6.
1241 SetRtpSendParameterUpdatesMaxBitrateWithOverhead) {
1242 webrtc::test::ScopedFieldTrials override_field_trials(
1243 "WebRTC-Audio-SendSideBwe/Enabled/"
1244 "WebRTC-SendSideBwe-WithOverhead/Enabled/");
1245 EXPECT_TRUE(SetupSendStream());
1246 cricket::AudioSendParameters send_parameters;
1247 send_parameters.codecs.push_back(kOpusCodec);
1248 SetSendParameters(send_parameters);
1249
1250 webrtc::RtpParameters rtp_parameters = channel_->GetRtpSendParameters(kSsrcX);
1251 // Expect empty on parameters.encodings[0].max_bitrate_bps;
1252 EXPECT_FALSE(rtp_parameters.encodings[0].max_bitrate_bps);
1253
1254 constexpr int kMaxBitrateBps = 6000;
1255 rtp_parameters.encodings[0].max_bitrate_bps =
1256 rtc::Optional<int>(kMaxBitrateBps);
1257 EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, rtp_parameters));
1258
1259 const int max_bitrate = GetSendStreamConfig(kSsrcX).max_bitrate_bps;
1260 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME
1261 constexpr int kMinOverhead = 3333;
1262 #else
1263 constexpr int kMinOverhead = 6666;
1264 #endif
1265 EXPECT_EQ(max_bitrate, kMaxBitrateBps + kMinOverhead);
1266 }
1267
1215 // Test that GetRtpReceiveParameters returns the currently configured codecs. 1268 // Test that GetRtpReceiveParameters returns the currently configured codecs.
1216 TEST_F(WebRtcVoiceEngineTestFake, GetRtpReceiveParametersCodecs) { 1269 TEST_F(WebRtcVoiceEngineTestFake, GetRtpReceiveParametersCodecs) {
1217 EXPECT_TRUE(SetupRecvStream()); 1270 EXPECT_TRUE(SetupRecvStream());
1218 cricket::AudioRecvParameters parameters; 1271 cricket::AudioRecvParameters parameters;
1219 parameters.codecs.push_back(kIsacCodec); 1272 parameters.codecs.push_back(kIsacCodec);
1220 parameters.codecs.push_back(kPcmuCodec); 1273 parameters.codecs.push_back(kPcmuCodec);
1221 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 1274 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
1222 1275
1223 webrtc::RtpParameters rtp_parameters = 1276 webrtc::RtpParameters rtp_parameters =
1224 channel_->GetRtpReceiveParameters(kSsrcX); 1277 channel_->GetRtpReceiveParameters(kSsrcX);
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after
3836 // Without this cast, the comparison turned unsigned and, thus, failed for -1. 3889 // Without this cast, the comparison turned unsigned and, thus, failed for -1.
3837 const int num_specs = static_cast<int>(specs.size()); 3890 const int num_specs = static_cast<int>(specs.size());
3838 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); 3891 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs);
3839 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); 3892 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs);
3840 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); 3893 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1);
3841 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); 3894 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs);
3842 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); 3895 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs);
3843 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); 3896 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs);
3844 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); 3897 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs);
3845 } 3898 }
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