Move MinPositive to call.h as discussed here: https://codereview.chromium.org/2888303005/#msg19
TBR=stefan@webrtc.org
BUG=webrtc:7395
Review-Url: https://codereview.webrtc.org/2924393002
Cr-Original-Commit-Position: refs/heads/master@{#18599}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: a5e0df643828c1d16ce3b508849d0c4ed6130081
diff --git a/call/call.cc b/call/call.cc
index c4ce716..7aeb924 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -949,20 +949,6 @@
UpdateCurrentBitrateConfig(mask.start_bitrate_bps);
}
-namespace {
-
-static int MinPositive(int a, int b) {
- if (a <= 0) {
- return b;
- }
- if (b <= 0) {
- return a;
- }
- return std::min(a, b);
-}
-
-} // namespace
-
void Call::UpdateCurrentBitrateConfig(const rtc::Optional<int>& new_start) {
Config::BitrateConfig updated;
updated.min_bitrate_bps =
diff --git a/call/call.h b/call/call.h
index 0647989..5aa0836 100644
--- a/call/call.h
+++ b/call/call.h
@@ -10,6 +10,7 @@
#ifndef WEBRTC_CALL_CALL_H_
#define WEBRTC_CALL_CALL_H_
+#include <algorithm>
#include <memory>
#include <string>
#include <vector>
@@ -39,6 +40,19 @@
DATA
};
+// Like std::min, but considers non-positive values to be unset.
+// TODO(zstein): Remove once all callers use rtc::Optional.
+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);
+}
+
class PacketReceiver {
public:
enum DeliveryStatus {
diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h
index 1206ccc..354b6e4 100644
--- a/media/base/mediachannel.h
+++ b/media/base/mediachannel.h
@@ -11,7 +11,6 @@
#ifndef WEBRTC_MEDIA_BASE_MEDIACHANNEL_H_
#define WEBRTC_MEDIA_BASE_MEDIACHANNEL_H_
-#include <algorithm>
#include <memory>
#include <string>
#include <vector>
@@ -81,17 +80,6 @@
return ost.str();
}
-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);
-}
-
// Construction-time settings, passed on when creating
// MediaChannels.
struct MediaConfig {
diff --git a/media/engine/webrtcvideoengine.cc b/media/engine/webrtcvideoengine.cc
index 9a2865b..852fa39 100644
--- a/media/engine/webrtcvideoengine.cc
+++ b/media/engine/webrtcvideoengine.cc
@@ -1984,8 +1984,8 @@
int stream_max_bitrate = parameters_.max_bitrate_bps;
if (rtp_parameters_.encodings[0].max_bitrate_bps) {
stream_max_bitrate =
- MinPositive(*(rtp_parameters_.encodings[0].max_bitrate_bps),
- parameters_.max_bitrate_bps);
+ webrtc::MinPositive(*(rtp_parameters_.encodings[0].max_bitrate_bps),
+ parameters_.max_bitrate_bps);
}
int codec_max_bitrate_kbps;
diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc
index 1f197a3..0fef4fd 100644
--- a/media/engine/webrtcvoiceengine.cc
+++ b/media/engine/webrtcvoiceengine.cc
@@ -181,9 +181,10 @@
const webrtc::AudioCodecSpec& spec) {
// If application-configured bitrate is set, take minimum of that and SDP
// bitrate.
- const int bps = rtp_max_bitrate_bps
- ? MinPositive(max_send_bitrate_bps, *rtp_max_bitrate_bps)
- : max_send_bitrate_bps;
+ const int bps =
+ rtp_max_bitrate_bps
+ ? webrtc::MinPositive(max_send_bitrate_bps, *rtp_max_bitrate_bps)
+ : max_send_bitrate_bps;
if (bps <= 0) {
return rtc::Optional<int>(spec.info.default_bitrate_bps);
}