Remove webrtc::MinPositive from api/.

Follow-up of https://webrtc-review.googlesource.com/c/src/+/153220,
where during code review it was suggested to move webrtc::MinPositive
out of the api/ directory.

Bug: None
Change-Id: I0c3b87a9ffd1cd205a85dddd9f44cfd95eb02206
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153480
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29220}
This commit is contained in:
Mirko Bonadei 2019-09-18 14:15:52 +02:00 committed by Commit Bot
parent 1162ba285d
commit 53227ccba9
4 changed files with 46 additions and 18 deletions

View File

@ -45,18 +45,6 @@ struct BitrateConstraints {
static constexpr int kDefaultStartBitrateBps = 300000;
};
// Like std::min, but considers non-positive values to be unset.
template <typename T>
static T MinPositive(T a, T b) {
if (a <= 0) {
return b;
}
if (b <= 0) {
return a;
}
return std::min(a, b);
}
} // namespace webrtc
#endif // API_TRANSPORT_BITRATE_SETTINGS_H_

View File

@ -14,6 +14,22 @@
#include "rtc_base/checks.h"
namespace {
// Returns its smallest positive argument. If neither argument is positive,
// returns an arbitrary nonpositive value.
int MinPositive(int a, int b) {
if (a <= 0) {
return b;
}
if (b <= 0) {
return a;
}
return std::min(a, b);
}
} // namespace
namespace webrtc {
RtpBitrateConfigurator::RtpBitrateConfigurator(
const BitrateConstraints& bitrate_config)

View File

@ -337,6 +337,19 @@ int GetMinVideoBitrateBps(webrtc::VideoCodecType type) {
}
return kMinVideoBitrateBps;
}
// Returns its smallest positive argument. If neither argument is positive,
// returns an arbitrary nonpositive value.
int MinPositive(int a, int b) {
if (a <= 0) {
return b;
}
if (b <= 0) {
return a;
}
return std::min(a, b);
}
} // namespace
// This constant is really an on/off, lower-level configurable NACK history
@ -2217,8 +2230,8 @@ WebRtcVideoChannel::WebRtcVideoSendStream::CreateVideoEncoderConfig(
if (rtp_parameters_.encodings[0].max_bitrate_bps &&
rtp_parameters_.encodings.size() == 1) {
stream_max_bitrate =
webrtc::MinPositive(*(rtp_parameters_.encodings[0].max_bitrate_bps),
parameters_.max_bitrate_bps);
MinPositive(*(rtp_parameters_.encodings[0].max_bitrate_bps),
parameters_.max_bitrate_bps);
}
// The codec max bitrate comes from the "x-google-max-bitrate" parameter

View File

@ -141,6 +141,18 @@ absl::optional<std::string> GetAudioNetworkAdaptorConfig(
return absl::nullopt;
}
// Returns its smallest positive argument. If neither argument is positive,
// returns an arbitrary nonpositive value.
int MinPositive(int a, int b) {
if (a <= 0) {
return b;
}
if (b <= 0) {
return a;
}
return std::min(a, b);
}
// |max_send_bitrate_bps| is the bitrate from "b=" in SDP.
// |rtp_max_bitrate_bps| is the bitrate from RtpSender::SetParameters.
absl::optional<int> ComputeSendBitrate(int max_send_bitrate_bps,
@ -148,10 +160,9 @@ absl::optional<int> ComputeSendBitrate(int max_send_bitrate_bps,
const webrtc::AudioCodecSpec& spec) {
// If application-configured bitrate is set, take minimum of that and SDP
// bitrate.
const int bps =
rtp_max_bitrate_bps
? webrtc::MinPositive(max_send_bitrate_bps, *rtp_max_bitrate_bps)
: max_send_bitrate_bps;
const int bps = rtp_max_bitrate_bps
? MinPositive(max_send_bitrate_bps, *rtp_max_bitrate_bps)
: max_send_bitrate_bps;
if (bps <= 0) {
return spec.info.default_bitrate_bps;
}