Use std::min and std::max instead of self-defined functions such as rtc::_min/_max.
R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/35079004 Cr-Commit-Position: refs/heads/master@{#8347} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8347 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
9e4e524f38
commit
ff689be3c0
@ -607,8 +607,8 @@ bool WebRtcSession::Initialize(
|
||||
if (video_options_.unsignalled_recv_stream_limit.IsSet()) {
|
||||
int stream_limit;
|
||||
video_options_.unsignalled_recv_stream_limit.Get(&stream_limit);
|
||||
stream_limit = rtc::_min(kMaxUnsignalledRecvStreams, stream_limit);
|
||||
stream_limit = rtc::_max(0, stream_limit);
|
||||
stream_limit = std::min(kMaxUnsignalledRecvStreams, stream_limit);
|
||||
stream_limit = std::max(0, stream_limit);
|
||||
video_options_.unsignalled_recv_stream_limit.Set(stream_limit);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "talk/media/base/filemediaengine.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits.h>
|
||||
|
||||
#include "talk/media/base/rtpdump.h"
|
||||
@ -247,7 +248,7 @@ void RtpSenderReceiver::OnMessage(rtc::Message* pmsg) {
|
||||
if (ReadNextPacket(&rtp_dump_packet_)) {
|
||||
int wait = rtc::TimeUntil(
|
||||
start_send_time_ + rtp_dump_packet_.elapsed_time);
|
||||
wait = rtc::_max(0, wait);
|
||||
wait = std::max(0, wait);
|
||||
sender_thread_->PostDelayed(wait, this);
|
||||
} else {
|
||||
sender_thread_->Quit();
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "talk/media/base/testutils.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "talk/media/base/executablehelpers.h"
|
||||
#include "talk/media/base/rtpdump.h"
|
||||
@ -129,9 +130,8 @@ const RawRtcpPacket RtpTestUtility::kTestRawRtcpPackets[] = {
|
||||
};
|
||||
|
||||
size_t RtpTestUtility::GetTestPacketCount() {
|
||||
return rtc::_min(
|
||||
ARRAY_SIZE(kTestRawRtpPackets),
|
||||
ARRAY_SIZE(kTestRawRtcpPackets));
|
||||
return std::min(ARRAY_SIZE(kTestRawRtpPackets),
|
||||
ARRAY_SIZE(kTestRawRtcpPackets));
|
||||
}
|
||||
|
||||
bool RtpTestUtility::WriteTestPackets(
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "talk/media/base/videoadapter.h"
|
||||
|
||||
#include <limits.h> // For INT_MAX
|
||||
#include <algorithm>
|
||||
|
||||
#include "talk/media/base/constants.h"
|
||||
#include "talk/media/base/videocommon.h"
|
||||
@ -185,8 +186,8 @@ void VideoAdapter::SetInputFormat(const VideoFormat& format) {
|
||||
rtc::CritScope cs(&critical_section_);
|
||||
int64 old_input_interval = input_format_.interval;
|
||||
input_format_ = format;
|
||||
output_format_.interval = rtc::_max(
|
||||
output_format_.interval, input_format_.interval);
|
||||
output_format_.interval =
|
||||
std::max(output_format_.interval, input_format_.interval);
|
||||
if (old_input_interval != input_format_.interval) {
|
||||
LOG(LS_INFO) << "VAdapt input interval changed from "
|
||||
<< old_input_interval << " to " << input_format_.interval;
|
||||
@ -227,8 +228,8 @@ void VideoAdapter::SetOutputFormat(const VideoFormat& format) {
|
||||
int64 old_output_interval = output_format_.interval;
|
||||
output_format_ = format;
|
||||
output_num_pixels_ = output_format_.width * output_format_.height;
|
||||
output_format_.interval = rtc::_max(
|
||||
output_format_.interval, input_format_.interval);
|
||||
output_format_.interval =
|
||||
std::max(output_format_.interval, input_format_.interval);
|
||||
if (old_output_interval != output_format_.interval) {
|
||||
LOG(LS_INFO) << "VAdapt output interval changed from "
|
||||
<< old_output_interval << " to " << output_format_.interval;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#ifndef TALK_MEDIA_BASE_VIDEOCAPTURER_H_
|
||||
#define TALK_MEDIA_BASE_VIDEOCAPTURER_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -291,7 +292,7 @@ class VideoCapturer
|
||||
// resolution of 2048 x 1280.
|
||||
int screencast_max_pixels() const { return screencast_max_pixels_; }
|
||||
void set_screencast_max_pixels(int p) {
|
||||
screencast_max_pixels_ = rtc::_max(0, p);
|
||||
screencast_max_pixels_ = std::max(0, p);
|
||||
}
|
||||
|
||||
// If true, run video adaptation. By default, video adaptation is enabled
|
||||
|
@ -28,6 +28,7 @@
|
||||
#ifndef TALK_MEDIA_BASE_VIDEOFRAME_UNITTEST_H_
|
||||
#define TALK_MEDIA_BASE_VIDEOFRAME_UNITTEST_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "libyuv/convert.h"
|
||||
@ -1196,7 +1197,7 @@ class VideoFrameTest : public testing::Test {
|
||||
return;
|
||||
}
|
||||
data_ptr += kPadToHeapSized + (-(static_cast<int>(data_size)) & 4095);
|
||||
memcpy(data_ptr, sample, rtc::_min(data_size, sample_size));
|
||||
memcpy(data_ptr, sample, std::min(data_size, sample_size));
|
||||
for (int i = 0; i < repeat_; ++i) {
|
||||
EXPECT_EQ(expected_result, frame.Validate(fourcc, kWidth, kHeight,
|
||||
data_ptr,
|
||||
|
@ -33,6 +33,7 @@
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
#include "talk/media/base/constants.h"
|
||||
@ -1340,7 +1341,7 @@ bool WebRtcVideoEngine::CanSendCodec(const VideoCodec& requested,
|
||||
out->name = requested.name;
|
||||
out->preference = requested.preference;
|
||||
out->params = requested.params;
|
||||
out->framerate = rtc::_min(requested.framerate, local_max->framerate);
|
||||
out->framerate = std::min(requested.framerate, local_max->framerate);
|
||||
out->width = 0;
|
||||
out->height = 0;
|
||||
out->params = requested.params;
|
||||
|
@ -512,8 +512,7 @@ bool WebRtcVideoEngine2::CanSendCodec(const VideoCodec& requested,
|
||||
out->name = requested.name;
|
||||
out->preference = requested.preference;
|
||||
out->params = requested.params;
|
||||
out->framerate =
|
||||
rtc::_min(requested.framerate, matching_codec.framerate);
|
||||
out->framerate = std::min(requested.framerate, matching_codec.framerate);
|
||||
out->params = requested.params;
|
||||
out->feedback_params = requested.feedback_params;
|
||||
out->width = requested.width;
|
||||
|
@ -25,6 +25,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "talk/media/base/constants.h"
|
||||
#include "talk/media/base/fakenetworkinterface.h"
|
||||
#include "talk/media/base/fakevideorenderer.h"
|
||||
@ -248,7 +249,7 @@ class WebRtcVideoEngineTestFake : public testing::Test,
|
||||
EXPECT_EQ(100, gcodec.plType);
|
||||
EXPECT_EQ(width, gcodec.width);
|
||||
EXPECT_EQ(height, gcodec.height);
|
||||
EXPECT_EQ(rtc::_min(start_bitrate, max_bitrate), gcodec.startBitrate);
|
||||
EXPECT_EQ(std::min(start_bitrate, max_bitrate), gcodec.startBitrate);
|
||||
EXPECT_EQ(max_bitrate, gcodec.maxBitrate);
|
||||
EXPECT_EQ(min_bitrate, gcodec.minBitrate);
|
||||
EXPECT_EQ(fps, gcodec.maxFramerate);
|
||||
@ -2792,7 +2793,7 @@ class WebRtcVideoEngineSimulcastTestFake : public testing::Test,
|
||||
EXPECT_EQ(100, gcodec.plType);
|
||||
EXPECT_EQ(width, gcodec.width);
|
||||
EXPECT_EQ(height, gcodec.height);
|
||||
EXPECT_EQ(rtc::_min(start_bitrate, max_bitrate), gcodec.startBitrate);
|
||||
EXPECT_EQ(std::min(start_bitrate, max_bitrate), gcodec.startBitrate);
|
||||
EXPECT_EQ(max_bitrate, gcodec.maxBitrate);
|
||||
EXPECT_EQ(min_bitrate, gcodec.minBitrate);
|
||||
EXPECT_EQ(fps, gcodec.maxFramerate);
|
||||
|
@ -2887,7 +2887,7 @@ int WebRtcVoiceMediaChannel::GetOutputLevel() {
|
||||
for (ChannelMap::iterator it = receive_channels_.begin();
|
||||
it != receive_channels_.end(); ++it) {
|
||||
int level = GetOutputLevel(it->second->channel());
|
||||
highest = rtc::_max(level, highest);
|
||||
highest = std::max(level, highest);
|
||||
}
|
||||
return highest;
|
||||
}
|
||||
@ -2942,7 +2942,7 @@ bool WebRtcVoiceMediaChannel::SetOutputScaling(
|
||||
|
||||
// Scale the output volume for the collected channels. We first normalize to
|
||||
// scale the volume and then set the left and right pan.
|
||||
float scale = static_cast<float>(rtc::_max(left, right));
|
||||
float scale = static_cast<float>(std::max(left, right));
|
||||
if (scale > 0.0001f) {
|
||||
left /= scale;
|
||||
right /= scale;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "webrtc/base/bandwidthsmoother.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -20,13 +21,12 @@ BandwidthSmoother::BandwidthSmoother(int initial_bandwidth_guess,
|
||||
size_t samples_count_to_average,
|
||||
double min_sample_count_percent)
|
||||
: time_between_increase_(time_between_increase),
|
||||
percent_increase_(rtc::_max(1.0, percent_increase)),
|
||||
percent_increase_(std::max(1.0, percent_increase)),
|
||||
time_at_last_change_(0),
|
||||
bandwidth_estimation_(initial_bandwidth_guess),
|
||||
accumulator_(samples_count_to_average),
|
||||
min_sample_count_percent_(
|
||||
rtc::_min(1.0,
|
||||
rtc::_max(0.0, min_sample_count_percent))) {
|
||||
std::min(1.0, std::max(0.0, min_sample_count_percent))) {
|
||||
}
|
||||
|
||||
// Samples a new bandwidth measurement
|
||||
|
@ -111,11 +111,6 @@ typedef int socklen_t;
|
||||
|
||||
// The following only works for C++
|
||||
#ifdef __cplusplus
|
||||
namespace rtc {
|
||||
template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; }
|
||||
template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; }
|
||||
}
|
||||
|
||||
#define ALIGNP(p, t) \
|
||||
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
|
||||
((t) - 1)) & ~((t) - 1))))
|
||||
|
@ -189,13 +189,13 @@ char* ByteBuffer::ReserveWriteBuffer(size_t len) {
|
||||
}
|
||||
|
||||
void ByteBuffer::Resize(size_t size) {
|
||||
size_t len = _min(end_ - start_, size);
|
||||
size_t len = std::min(end_ - start_, size);
|
||||
if (size <= size_) {
|
||||
// Don't reallocate, just move data backwards
|
||||
memmove(bytes_, bytes_ + start_, len);
|
||||
} else {
|
||||
// Reallocate a larger buffer.
|
||||
size_ = _max(size, 3 * size_ / 2);
|
||||
size_ = std::max(size, 3 * size_ / 2);
|
||||
char* new_bytes = new char[size_];
|
||||
memcpy(new_bytes, bytes_ + start_, len);
|
||||
delete [] bytes_;
|
||||
|
@ -52,12 +52,7 @@ inline void RtcUnused(const void*) {}
|
||||
#define stricmp(x, y) strcasecmp(x, y)
|
||||
#endif
|
||||
|
||||
// TODO(fbarchard): Remove this. std::max should be used everywhere in the code.
|
||||
// NOMINMAX must be defined where we include <windows.h>.
|
||||
#define stdmax(x, y) std::max(x, y)
|
||||
#else
|
||||
#define stdmax(x, y) rtc::_max(x, y)
|
||||
#endif
|
||||
#endif // !defined(WEBRTC_WIN)
|
||||
|
||||
#define ARRAY_SIZE(x) (static_cast<int>(sizeof(x) / sizeof(x[0])))
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "webrtc/base/win32.h"
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/diskcache.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
@ -127,7 +128,7 @@ StreamInterface* DiskCache::WriteResource(const std::string& id, size_t index) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry->streams = stdmax(entry->streams, index + 1);
|
||||
entry->streams = std::max(entry->streams, index + 1);
|
||||
entry->size -= previous_size;
|
||||
total_size_ -= previous_size;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <tchar.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/diskcache.h"
|
||||
@ -45,7 +46,7 @@ bool DiskCacheWin32::InitializeEntries() {
|
||||
Entry* entry = GetOrCreateEntry(id, true);
|
||||
entry->size += find_data.nFileSizeLow;
|
||||
total_size_ += find_data.nFileSizeLow;
|
||||
entry->streams = _max(entry->streams, index + 1);
|
||||
entry->streams = std::max(entry->streams, index + 1);
|
||||
FileTimeToUnixTime(find_data.ftLastWriteTime, &entry->last_modified);
|
||||
|
||||
} while (FindNextFile(find_handle, &find_data));
|
||||
|
@ -8,6 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/httpbase.h"
|
||||
#include "webrtc/base/testutils.h"
|
||||
@ -229,7 +231,8 @@ void HttpBaseTest::ReadDocumentStreamData(const char* expected_data) {
|
||||
while (verified_length < expected_length) {
|
||||
size_t read = 0;
|
||||
char buffer[5] = { 0 };
|
||||
size_t amt_to_read = _min(expected_length - verified_length, sizeof(buffer));
|
||||
size_t amt_to_read =
|
||||
std::min(expected_length - verified_length, sizeof(buffer));
|
||||
EXPECT_EQ(SR_SUCCESS, http_stream->Read(buffer, amt_to_read, &read, NULL));
|
||||
EXPECT_EQ(amt_to_read, read);
|
||||
EXPECT_TRUE(0 == memcmp(expected_data + verified_length, buffer, read));
|
||||
|
@ -9,13 +9,12 @@
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/base/asyncsocket.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/diskcache.h"
|
||||
#include "webrtc/base/httpclient.h"
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/pathutils.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
@ -119,7 +118,7 @@ HttpCacheState HttpGetCacheState(const HttpTransaction& t) {
|
||||
if (t.response.hasHeader(HH_AGE, &s_temp)
|
||||
&& HttpStringToUInt(s_temp, (&i_temp))) {
|
||||
u_temp = static_cast<time_t>(i_temp);
|
||||
corrected_received_age = stdmax(apparent_age, u_temp);
|
||||
corrected_received_age = std::max(apparent_age, u_temp);
|
||||
}
|
||||
|
||||
time_t response_delay = response_time - request_time;
|
||||
|
@ -19,12 +19,13 @@
|
||||
#include <security.h>
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/base64.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/cryptstring.h"
|
||||
#include "webrtc/base/httpcommon.h"
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
#include "webrtc/base/socketaddress.h"
|
||||
#include "webrtc/base/stringdigest.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
@ -954,26 +955,26 @@ HttpAuthResult HttpAuthenticate(
|
||||
std::string::size_type pos = username.find('\\');
|
||||
if (pos == std::string::npos) {
|
||||
auth_id.UserLength = static_cast<unsigned long>(
|
||||
_min(sizeof(userbuf) - 1, username.size()));
|
||||
std::min(sizeof(userbuf) - 1, username.size()));
|
||||
memcpy(userbuf, username.c_str(), auth_id.UserLength);
|
||||
userbuf[auth_id.UserLength] = 0;
|
||||
auth_id.DomainLength = 0;
|
||||
domainbuf[auth_id.DomainLength] = 0;
|
||||
auth_id.PasswordLength = static_cast<unsigned long>(
|
||||
_min(sizeof(passbuf) - 1, password.GetLength()));
|
||||
std::min(sizeof(passbuf) - 1, password.GetLength()));
|
||||
memcpy(passbuf, sensitive, auth_id.PasswordLength);
|
||||
passbuf[auth_id.PasswordLength] = 0;
|
||||
} else {
|
||||
auth_id.UserLength = static_cast<unsigned long>(
|
||||
_min(sizeof(userbuf) - 1, username.size() - pos - 1));
|
||||
std::min(sizeof(userbuf) - 1, username.size() - pos - 1));
|
||||
memcpy(userbuf, username.c_str() + pos + 1, auth_id.UserLength);
|
||||
userbuf[auth_id.UserLength] = 0;
|
||||
auth_id.DomainLength = static_cast<unsigned long>(
|
||||
_min(sizeof(domainbuf) - 1, pos));
|
||||
auth_id.DomainLength =
|
||||
static_cast<unsigned long>(std::min(sizeof(domainbuf) - 1, pos));
|
||||
memcpy(domainbuf, username.c_str(), auth_id.DomainLength);
|
||||
domainbuf[auth_id.DomainLength] = 0;
|
||||
auth_id.PasswordLength = static_cast<unsigned long>(
|
||||
_min(sizeof(passbuf) - 1, password.GetLength()));
|
||||
std::min(sizeof(passbuf) - 1, password.GetLength()));
|
||||
memcpy(passbuf, sensitive, auth_id.PasswordLength);
|
||||
passbuf[auth_id.PasswordLength] = 0;
|
||||
}
|
||||
|
@ -27,10 +27,11 @@ static const int kMaxLogLineSize = 1024 - 60;
|
||||
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS) || WEBRTC_ANDROID
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <ostream>
|
||||
#include <iomanip>
|
||||
#include <limits.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -247,7 +248,7 @@ int LogMessage::GetLogToStream(StreamInterface* stream) {
|
||||
int sev = NO_LOGGING;
|
||||
for (StreamList::iterator it = streams_.begin(); it != streams_.end(); ++it) {
|
||||
if (!stream || stream == it->first) {
|
||||
sev = _min(sev, it->second);
|
||||
sev = std::min(sev, it->second);
|
||||
}
|
||||
}
|
||||
return sev;
|
||||
@ -368,7 +369,7 @@ int LogMessage::ParseLogSeverity(const std::string& value) {
|
||||
void LogMessage::UpdateMinLogSeverity() {
|
||||
int min_sev = dbg_sev_;
|
||||
for (StreamList::iterator it = streams_.begin(); it != streams_.end(); ++it) {
|
||||
min_sev = _min(dbg_sev_, it->second);
|
||||
min_sev = std::min(dbg_sev_, it->second);
|
||||
}
|
||||
min_sev_ = min_sev;
|
||||
}
|
||||
@ -524,7 +525,7 @@ void LogMultiline(LoggingSeverity level, const char* label, bool input,
|
||||
while (len > 0) {
|
||||
memset(asc_line, ' ', sizeof(asc_line));
|
||||
memset(hex_line, ' ', sizeof(hex_line));
|
||||
size_t line_len = _min(len, LINE_SIZE);
|
||||
size_t line_len = std::min(len, LINE_SIZE);
|
||||
for (size_t i = 0; i < line_len; ++i) {
|
||||
unsigned char ch = udata[i];
|
||||
asc_line[i] = isprint(ch) ? ch : '.';
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/messagequeue.h"
|
||||
@ -244,7 +246,7 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) {
|
||||
if (cmsWait == kForever) {
|
||||
cmsNext = cmsDelayNext;
|
||||
} else {
|
||||
cmsNext = _max(0, cmsTotal - cmsElapsed);
|
||||
cmsNext = std::max(0, cmsTotal - cmsElapsed);
|
||||
if ((cmsDelayNext != kForever) && (cmsDelayNext < cmsNext))
|
||||
cmsNext = cmsDelayNext;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/httpcommon.h"
|
||||
#include "webrtc/base/multipart.h"
|
||||
@ -184,7 +184,7 @@ bool MultipartStream::SetPosition(size_t position) {
|
||||
return false;
|
||||
}
|
||||
if (part_offset + part_size > position) {
|
||||
for (size_t j = i+1; j < _min(parts_.size(), current_+1); ++j) {
|
||||
for (size_t j = i + 1; j < std::min(parts_.size(), current_ + 1); ++j) {
|
||||
if (!parts_[j]->Rewind()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1547,7 +1547,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) {
|
||||
if (cmsWait == kForever) {
|
||||
cmsNext = cmsWait;
|
||||
} else {
|
||||
cmsNext = _max(0, cmsTotal - cmsElapsed);
|
||||
cmsNext = std::max(0, cmsTotal - cmsElapsed);
|
||||
}
|
||||
|
||||
// Wait for one of the events to signal
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "webrtc/base/profiler.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/timeutils.h"
|
||||
|
||||
@ -64,8 +65,8 @@ void ProfilerEvent::Stop(uint64 stop_time) {
|
||||
if (event_count_ == 0) {
|
||||
minimum_ = maximum_ = elapsed;
|
||||
} else {
|
||||
minimum_ = _min(minimum_, elapsed);
|
||||
maximum_ = _max(maximum_, elapsed);
|
||||
minimum_ = std::min(minimum_, elapsed);
|
||||
maximum_ = std::max(maximum_, elapsed);
|
||||
}
|
||||
// Online variance and mean algorithm: http://en.wikipedia.org/wiki/
|
||||
// Algorithms_for_calculating_variance#Online_algorithm
|
||||
|
@ -124,7 +124,7 @@ void ProxyBinding::Read(AsyncSocket* socket, FifoBuffer* buffer) {
|
||||
if (buffer->GetBuffered(&size) && size == 0) {
|
||||
void* p = buffer->GetWriteBuffer(&size);
|
||||
read = socket->Recv(p, size);
|
||||
buffer->ConsumeWriteBuffer(_max(read, 0));
|
||||
buffer->ConsumeWriteBuffer(std::max(read, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ void ProxyBinding::Write(AsyncSocket* socket, FifoBuffer* buffer) {
|
||||
int written;
|
||||
const void* p = buffer->GetReadData(&size);
|
||||
written = socket->Send(p, size);
|
||||
buffer->ConsumeReadData(_max(written, 0));
|
||||
buffer->ConsumeReadData(std::max(written, 0));
|
||||
}
|
||||
|
||||
void ProxyBinding::Destroy() {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#ifndef WEBRTC_BASE_ROLLINGACCUMULATOR_H_
|
||||
#define WEBRTC_BASE_ROLLINGACCUMULATOR_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
@ -99,7 +100,7 @@ class RollingAccumulator {
|
||||
"It shouldn't be possible for max_stale_ && count_ == 0");
|
||||
max_ = samples_[next_index_];
|
||||
for (size_t i = 1u; i < count_; i++) {
|
||||
max_ = _max(max_, samples_[(next_index_ + i) % max_count()]);
|
||||
max_ = std::max(max_, samples_[(next_index_ + i) % max_count()]);
|
||||
}
|
||||
max_stale_ = false;
|
||||
}
|
||||
@ -112,7 +113,7 @@ class RollingAccumulator {
|
||||
"It shouldn't be possible for min_stale_ && count_ == 0");
|
||||
min_ = samples_[next_index_];
|
||||
for (size_t i = 1u; i < count_; i++) {
|
||||
min_ = _min(min_, samples_[(next_index_ + i) % max_count()]);
|
||||
min_ = std::min(min_, samples_[(next_index_ + i) % max_count()]);
|
||||
}
|
||||
min_stale_ = false;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <security.h>
|
||||
#include <schannel.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
|
||||
@ -568,7 +569,7 @@ SChannelAdapter::Recv(void* pv, size_t cb) {
|
||||
SetError(EWOULDBLOCK);
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
size_t read = _min(cb, readable.size());
|
||||
size_t read = std::min(cb, readable.size());
|
||||
memcpy(pv, &readable[0], read);
|
||||
if (size_t remaining = readable.size() - read) {
|
||||
memmove(&readable[0], &readable[read], remaining);
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <security.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/bytebuffer.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/httpcommon.h"
|
||||
@ -66,7 +68,7 @@ int BufferedReadAdapter::Recv(void *pv, size_t cb) {
|
||||
size_t read = 0;
|
||||
|
||||
if (data_len_) {
|
||||
read = _min(cb, data_len_);
|
||||
read = std::min(cb, data_len_);
|
||||
memcpy(pv, buffer_, read);
|
||||
data_len_ -= read;
|
||||
if (data_len_ > 0) {
|
||||
@ -305,7 +307,7 @@ void AsyncHttpsProxySocket::ProcessInput(char* data, size_t* len) {
|
||||
size_t start = 0;
|
||||
for (size_t pos = start; state_ < PS_TUNNEL && pos < *len;) {
|
||||
if (state_ == PS_SKIP_BODY) {
|
||||
size_t consume = _min(*len - pos, content_length_);
|
||||
size_t consume = std::min(*len - pos, content_length_);
|
||||
pos += consume;
|
||||
start = pos;
|
||||
content_length_ -= consume;
|
||||
|
@ -14,7 +14,10 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -220,7 +223,7 @@ StreamResult StreamSegment::Read(void* buffer, size_t buffer_len,
|
||||
if (SIZE_UNKNOWN != length_) {
|
||||
if (pos_ >= length_)
|
||||
return SR_EOS;
|
||||
buffer_len = _min(buffer_len, length_ - pos_);
|
||||
buffer_len = std::min(buffer_len, length_ - pos_);
|
||||
}
|
||||
size_t backup_read;
|
||||
if (!read) {
|
||||
@ -266,7 +269,7 @@ bool StreamSegment::GetSize(size_t* size) const {
|
||||
*size -= start_;
|
||||
}
|
||||
if (SIZE_UNKNOWN != length_) {
|
||||
*size = _min(*size, length_);
|
||||
*size = std::min(*size, length_);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -276,7 +279,7 @@ bool StreamSegment::GetAvailable(size_t* size) const {
|
||||
if (!StreamAdapterInterface::GetAvailable(size))
|
||||
return false;
|
||||
if (size && (SIZE_UNKNOWN != length_))
|
||||
*size = _min(*size, length_ - pos_);
|
||||
*size = std::min(*size, length_ - pos_);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -575,7 +578,7 @@ StreamResult CircularFileStream::Read(void* buffer, size_t buffer_len,
|
||||
size_t local_read;
|
||||
if (!read) read = &local_read;
|
||||
|
||||
size_t to_read = rtc::_min(buffer_len, read_segment_available_);
|
||||
size_t to_read = std::min(buffer_len, read_segment_available_);
|
||||
rtc::StreamResult result
|
||||
= rtc::FileStream::Read(buffer, to_read, read, error);
|
||||
if (result == rtc::SR_SUCCESS) {
|
||||
@ -597,7 +600,7 @@ StreamResult CircularFileStream::Write(const void* data, size_t data_len,
|
||||
if (!written) written = &local_written;
|
||||
|
||||
size_t to_eof = max_write_size_ - position_;
|
||||
size_t to_write = rtc::_min(data_len, to_eof);
|
||||
size_t to_write = std::min(data_len, to_eof);
|
||||
rtc::StreamResult result
|
||||
= rtc::FileStream::Write(data, to_write, written, error);
|
||||
if (result == rtc::SR_SUCCESS) {
|
||||
@ -764,8 +767,8 @@ StreamResult MemoryStreamBase::Write(const void* buffer, size_t bytes,
|
||||
// Increase buffer size to the larger of:
|
||||
// a) new position rounded up to next 256 bytes
|
||||
// b) double the previous length
|
||||
size_t new_buffer_length = _max(((seek_position_ + bytes) | 0xFF) + 1,
|
||||
buffer_length_ * 2);
|
||||
size_t new_buffer_length =
|
||||
std::max(((seek_position_ + bytes) | 0xFF) + 1, buffer_length_ * 2);
|
||||
StreamResult result = DoReserve(new_buffer_length, error);
|
||||
if (SR_SUCCESS != result) {
|
||||
return result;
|
||||
@ -927,7 +930,7 @@ bool FifoBuffer::SetCapacity(size_t size) {
|
||||
if (size != buffer_length_) {
|
||||
char* buffer = new char[size];
|
||||
const size_t copy = data_length_;
|
||||
const size_t tail_copy = _min(copy, buffer_length_ - read_position_);
|
||||
const size_t tail_copy = std::min(copy, buffer_length_ - read_position_);
|
||||
memcpy(buffer, &buffer_[read_position_], tail_copy);
|
||||
memcpy(buffer + tail_copy, &buffer_[0], copy - tail_copy);
|
||||
buffer_.reset(buffer);
|
||||
@ -1068,8 +1071,8 @@ StreamResult FifoBuffer::ReadOffsetLocked(void* buffer,
|
||||
|
||||
const size_t available = data_length_ - offset;
|
||||
const size_t read_position = (read_position_ + offset) % buffer_length_;
|
||||
const size_t copy = _min(bytes, available);
|
||||
const size_t tail_copy = _min(copy, buffer_length_ - read_position);
|
||||
const size_t copy = std::min(bytes, available);
|
||||
const size_t tail_copy = std::min(copy, buffer_length_ - read_position);
|
||||
char* const p = static_cast<char*>(buffer);
|
||||
memcpy(p, &buffer_[read_position], tail_copy);
|
||||
memcpy(p + tail_copy, &buffer_[0], copy - tail_copy);
|
||||
@ -1095,8 +1098,8 @@ StreamResult FifoBuffer::WriteOffsetLocked(const void* buffer,
|
||||
const size_t available = buffer_length_ - data_length_ - offset;
|
||||
const size_t write_position = (read_position_ + data_length_ + offset)
|
||||
% buffer_length_;
|
||||
const size_t copy = _min(bytes, available);
|
||||
const size_t tail_copy = _min(copy, buffer_length_ - write_position);
|
||||
const size_t copy = std::min(bytes, available);
|
||||
const size_t tail_copy = std::min(copy, buffer_length_ - write_position);
|
||||
const char* const p = static_cast<const char*>(buffer);
|
||||
memcpy(&buffer_[write_position], p, tail_copy);
|
||||
memcpy(&buffer_[0], p + tail_copy, copy - tail_copy);
|
||||
@ -1185,7 +1188,7 @@ StreamState StringStream::GetState() const {
|
||||
|
||||
StreamResult StringStream::Read(void* buffer, size_t buffer_len,
|
||||
size_t* read, int* error) {
|
||||
size_t available = _min(buffer_len, str_.size() - read_pos_);
|
||||
size_t available = std::min(buffer_len, str_.size() - read_pos_);
|
||||
if (!available)
|
||||
return SR_EOS;
|
||||
memcpy(buffer, str_.data() + read_pos_, available);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#undef Bool
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "webrtc/base/asyncsocket.h"
|
||||
@ -223,7 +224,7 @@ public:
|
||||
if ((SS_OPENING == state_) || (readable_data_.size() <= read_block_)) {
|
||||
return SR_BLOCK;
|
||||
}
|
||||
size_t count = _min(buffer_len, readable_data_.size() - read_block_);
|
||||
size_t count = std::min(buffer_len, readable_data_.size() - read_block_);
|
||||
memcpy(buffer, &readable_data_[0], count);
|
||||
size_t new_size = readable_data_.size() - count;
|
||||
// Avoid undefined access beyond the last element of the vector.
|
||||
|
@ -283,7 +283,7 @@ int VirtualSocket::RecvFrom(void* pv, size_t cb, SocketAddress* paddr) {
|
||||
|
||||
// Return the packet at the front of the queue.
|
||||
Packet* packet = recv_buffer_.front();
|
||||
size_t data_read = _min(cb, packet->size());
|
||||
size_t data_read = std::min(cb, packet->size());
|
||||
memcpy(pv, packet->data(), data_read);
|
||||
*paddr = packet->from();
|
||||
|
||||
@ -491,7 +491,7 @@ int VirtualSocket::SendTcp(const void* pv, size_t cb) {
|
||||
error_ = EWOULDBLOCK;
|
||||
return -1;
|
||||
}
|
||||
size_t consumed = _min(cb, capacity);
|
||||
size_t consumed = std::min(cb, capacity);
|
||||
const char* cpv = static_cast<const char*>(pv);
|
||||
send_buffer_.insert(send_buffer_.end(), cpv, cpv + consumed);
|
||||
server_->SendTcp(this);
|
||||
@ -806,8 +806,9 @@ void VirtualSocketServer::SendTcp(VirtualSocket* socket) {
|
||||
|
||||
while (true) {
|
||||
size_t available = recv_buffer_capacity_ - recipient->recv_buffer_size_;
|
||||
size_t max_data_size = _min<size_t>(available, TCP_MSS - TCP_HEADER_SIZE);
|
||||
size_t data_size = _min(socket->send_buffer_.size(), max_data_size);
|
||||
size_t max_data_size =
|
||||
std::min<size_t>(available, TCP_MSS - TCP_HEADER_SIZE);
|
||||
size_t data_size = std::min(socket->send_buffer_.size(), max_data_size);
|
||||
if (0 == data_size)
|
||||
break;
|
||||
|
||||
|
@ -9,12 +9,15 @@
|
||||
*/
|
||||
|
||||
#include "webrtc/base/win32socketserver.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <ws2tcpip.h> // NOLINT
|
||||
|
||||
#include "webrtc/base/byteorder.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/winping.h"
|
||||
#include "webrtc/base/win32window.h"
|
||||
#include <ws2tcpip.h> // NOLINT
|
||||
#include "webrtc/base/winping.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -821,7 +824,8 @@ void Win32SocketServer::Pump() {
|
||||
// We use max(1, ...) to make sure we try to dispatch at least once, since
|
||||
// this allow us to process "sent" messages, not included in the size() count.
|
||||
Message msg;
|
||||
for (size_t max_messages_to_process = _max<size_t>(1, message_queue_->size());
|
||||
for (size_t max_messages_to_process =
|
||||
std::max<size_t>(1, message_queue_->size());
|
||||
max_messages_to_process > 0 && message_queue_->Get(&msg, 0, false);
|
||||
--max_messages_to_process) {
|
||||
message_queue_->Dispatch(&msg);
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <assert.h>
|
||||
#include <Iphlpapi.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/byteorder.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/ipaddress.h"
|
||||
@ -129,7 +131,7 @@ inline uint32 ReplySize(uint32 data_size, int family) {
|
||||
if (family == AF_INET) {
|
||||
// A ping error message is 8 bytes long, so make sure we allow for at least
|
||||
// 8 bytes of reply data.
|
||||
return sizeof(ICMP_ECHO_REPLY) + rtc::_max<uint32>(8, data_size);
|
||||
return sizeof(ICMP_ECHO_REPLY) + std::max<uint32>(8, data_size);
|
||||
} else if (family == AF_INET6) {
|
||||
// Per MSDN, Send6IcmpEcho2 needs at least one ICMPV6_ECHO_REPLY,
|
||||
// 8 bytes for ICMP header, _and_ an IO_BLOCK_STATUS (2 pointers),
|
||||
|
@ -517,7 +517,7 @@ class XWindowEnumerator {
|
||||
static_cast<double>(src_width);
|
||||
double scale_y = static_cast<double>(dst_height) /
|
||||
static_cast<double>(src_height);
|
||||
double scale = rtc::_min(scale_y, scale_x);
|
||||
double scale = std::min(scale_y, scale_x);
|
||||
|
||||
int scaled_width = round(src_width * scale);
|
||||
int scaled_height = round(src_height * scale);
|
||||
|
@ -25,7 +25,9 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "pseudotcpchannel.h"
|
||||
#include "webrtc/p2p/base/candidate.h"
|
||||
#include "webrtc/p2p/base/transportchannel.h"
|
||||
@ -532,7 +534,7 @@ void PseudoTcpChannel::AdjustClock(bool clear) {
|
||||
// Reset the next clock, by clearing the old and setting a new one.
|
||||
if (clear)
|
||||
worker_thread_->Clear(this, MSG_WK_CLOCK);
|
||||
worker_thread_->PostDelayed(_max(timeout, 0L), this, MSG_WK_CLOCK);
|
||||
worker_thread_->PostDelayed(std::max(timeout, 0L), this, MSG_WK_CLOCK);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,11 +79,6 @@ typedef __int64 int64;
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
namespace rtc {
|
||||
template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; }
|
||||
template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; }
|
||||
}
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#if _MSC_VER < 1700
|
||||
#define alignof(t) __alignof(t)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif // OS_MACOSX
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
|
||||
#include "base/atomicops.h"
|
||||
@ -198,7 +199,7 @@ void LogMultiline(LoggingSeverity level, const char* label, bool input,
|
||||
while (len > 0) {
|
||||
memset(asc_line, ' ', sizeof(asc_line));
|
||||
memset(hex_line, ' ', sizeof(hex_line));
|
||||
size_t line_len = _min(len, LINE_SIZE);
|
||||
size_t line_len = std::min(len, LINE_SIZE);
|
||||
for (size_t i = 0; i < line_len; ++i) {
|
||||
unsigned char ch = udata[i];
|
||||
asc_line[i] = isprint(ch) ? ch : '.';
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@ -94,8 +95,8 @@ class Candidate {
|
||||
// Limiting priority to UINT_MAX when value exceeds uint32 max.
|
||||
// This can happen for e.g. when preference = 3.
|
||||
uint64 prio_val = static_cast<uint64>(preference * 127) << 24;
|
||||
priority_ = static_cast<uint32>(
|
||||
rtc::_min(prio_val, static_cast<uint64>(UINT_MAX)));
|
||||
priority_ =
|
||||
static_cast<uint32>(std::min(prio_val, static_cast<uint64>(UINT_MAX)));
|
||||
}
|
||||
|
||||
const std::string & username() const { return username_; }
|
||||
|
@ -87,7 +87,7 @@ const uint32 DEFAULT_RTT = MAXIMUM_RTT;
|
||||
|
||||
// Computes our estimate of the RTT given the current estimate.
|
||||
inline uint32 ConservativeRTTEstimate(uint32 rtt) {
|
||||
return rtc::_max(MINIMUM_RTT, rtc::_min(MAXIMUM_RTT, 2 * rtt));
|
||||
return std::max(MINIMUM_RTT, std::min(MAXIMUM_RTT, 2 * rtt));
|
||||
}
|
||||
|
||||
// Weighting of the old rtt value to new data.
|
||||
@ -908,9 +908,9 @@ uint64 Connection::priority() const {
|
||||
g = remote_candidate_.priority();
|
||||
d = local_candidate().priority();
|
||||
}
|
||||
priority = rtc::_min(g, d);
|
||||
priority = std::min(g, d);
|
||||
priority = priority << 32;
|
||||
priority += 2 * rtc::_max(g, d) + (g > d ? 1 : 0);
|
||||
priority += 2 * std::max(g, d) + (g > d ? 1 : 0);
|
||||
}
|
||||
return priority;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
@ -150,7 +151,7 @@ inline uint16 bytes_to_short(const void* buf) {
|
||||
}
|
||||
|
||||
uint32 bound(uint32 lower, uint32 middle, uint32 upper) {
|
||||
return rtc::_min(rtc::_max(lower, middle), upper);
|
||||
return std::min(std::max(lower, middle), upper);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -303,13 +304,13 @@ void PseudoTcp::NotifyClock(uint32 now) {
|
||||
}
|
||||
|
||||
uint32 nInFlight = m_snd_nxt - m_snd_una;
|
||||
m_ssthresh = rtc::_max(nInFlight / 2, 2 * m_mss);
|
||||
m_ssthresh = std::max(nInFlight / 2, 2 * m_mss);
|
||||
//LOG(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
|
||||
m_cwnd = m_mss;
|
||||
|
||||
// Back off retransmit timer. Note: the limit is lower when connecting.
|
||||
uint32 rto_limit = (m_state < TCP_ESTABLISHED) ? DEF_RTO : MAX_RTO;
|
||||
m_rx_rto = rtc::_min(rto_limit, m_rx_rto * 2);
|
||||
m_rx_rto = std::min(rto_limit, m_rx_rto * 2);
|
||||
m_rto_base = now;
|
||||
}
|
||||
}
|
||||
@ -327,7 +328,7 @@ void PseudoTcp::NotifyClock(uint32 now) {
|
||||
m_lastsend = now;
|
||||
|
||||
// back off retransmit timer
|
||||
m_rx_rto = rtc::_min(MAX_RTO, m_rx_rto * 2);
|
||||
m_rx_rto = std::min(MAX_RTO, m_rx_rto * 2);
|
||||
}
|
||||
|
||||
// Check if it's time to send delayed acks
|
||||
@ -433,7 +434,7 @@ int PseudoTcp::Recv(char* buffer, size_t len) {
|
||||
m_rbuf.GetWriteRemaining(&available_space);
|
||||
|
||||
if (uint32(available_space) - m_rcv_wnd >=
|
||||
rtc::_min<uint32>(m_rbuf_len / 2, m_mss)) {
|
||||
std::min<uint32>(m_rbuf_len / 2, m_mss)) {
|
||||
// TODO(jbeda): !?! Not sure about this was closed business
|
||||
bool bWasClosed = (m_rcv_wnd == 0);
|
||||
m_rcv_wnd = static_cast<uint32>(available_space);
|
||||
@ -614,20 +615,23 @@ bool PseudoTcp::clock_check(uint32 now, long& nTimeout) {
|
||||
nTimeout = DEFAULT_TIMEOUT;
|
||||
|
||||
if (m_t_ack) {
|
||||
nTimeout = rtc::_min<int32>(nTimeout,
|
||||
rtc::TimeDiff(m_t_ack + m_ack_delay, now));
|
||||
nTimeout =
|
||||
std::min<int32>(nTimeout, rtc::TimeDiff(m_t_ack + m_ack_delay, now));
|
||||
}
|
||||
if (m_rto_base) {
|
||||
nTimeout = rtc::_min<int32>(nTimeout,
|
||||
rtc::TimeDiff(m_rto_base + m_rx_rto, now));
|
||||
nTimeout =
|
||||
std::min<int32>(nTimeout, rtc::TimeDiff(m_rto_base + m_rx_rto, now));
|
||||
}
|
||||
if (m_snd_wnd == 0) {
|
||||
nTimeout = rtc::_min<int32>(nTimeout, rtc::TimeDiff(m_lastsend + m_rx_rto, now));
|
||||
nTimeout =
|
||||
std::min<int32>(nTimeout, rtc::TimeDiff(m_lastsend + m_rx_rto, now));
|
||||
}
|
||||
#if PSEUDO_KEEPALIVE
|
||||
if (m_state == TCP_ESTABLISHED) {
|
||||
nTimeout = rtc::_min<int32>(nTimeout,
|
||||
rtc::TimeDiff(m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3/2 : IDLE_PING), now));
|
||||
nTimeout = std::min<int32>(
|
||||
nTimeout, rtc::TimeDiff(m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3 / 2
|
||||
: IDLE_PING),
|
||||
now));
|
||||
}
|
||||
#endif // PSEUDO_KEEPALIVE
|
||||
return true;
|
||||
@ -712,8 +716,8 @@ bool PseudoTcp::process(Segment& seg) {
|
||||
m_rx_rttvar = (3 * m_rx_rttvar + abs_err) / 4;
|
||||
m_rx_srtt = (7 * m_rx_srtt + rtt) / 8;
|
||||
}
|
||||
m_rx_rto = bound(MIN_RTO, m_rx_srtt +
|
||||
rtc::_max<uint32>(1, 4 * m_rx_rttvar), MAX_RTO);
|
||||
m_rx_rto = bound(
|
||||
MIN_RTO, m_rx_srtt + std::max<uint32>(1, 4 * m_rx_rttvar), MAX_RTO);
|
||||
#if _DEBUGMSG >= _DBG_VERBOSE
|
||||
LOG(LS_INFO) << "rtt: " << rtt
|
||||
<< " srtt: " << m_rx_srtt
|
||||
@ -750,7 +754,7 @@ bool PseudoTcp::process(Segment& seg) {
|
||||
if (m_dup_acks >= 3) {
|
||||
if (m_snd_una >= m_recover) { // NewReno
|
||||
uint32 nInFlight = m_snd_nxt - m_snd_una;
|
||||
m_cwnd = rtc::_min(m_ssthresh, nInFlight + m_mss); // (Fast Retransmit)
|
||||
m_cwnd = std::min(m_ssthresh, nInFlight + m_mss); // (Fast Retransmit)
|
||||
#if _DEBUGMSG >= _DBG_NORMAL
|
||||
LOG(LS_INFO) << "exit recovery";
|
||||
#endif // _DEBUGMSG
|
||||
@ -763,7 +767,7 @@ bool PseudoTcp::process(Segment& seg) {
|
||||
closedown(ECONNABORTED);
|
||||
return false;
|
||||
}
|
||||
m_cwnd += m_mss - rtc::_min(nAcked, m_cwnd);
|
||||
m_cwnd += m_mss - std::min(nAcked, m_cwnd);
|
||||
}
|
||||
} else {
|
||||
m_dup_acks = 0;
|
||||
@ -771,7 +775,7 @@ bool PseudoTcp::process(Segment& seg) {
|
||||
if (m_cwnd < m_ssthresh) {
|
||||
m_cwnd += m_mss;
|
||||
} else {
|
||||
m_cwnd += rtc::_max<uint32>(1, m_mss * m_mss / m_cwnd);
|
||||
m_cwnd += std::max<uint32>(1, m_mss * m_mss / m_cwnd);
|
||||
}
|
||||
}
|
||||
} else if (seg.ack == m_snd_una) {
|
||||
@ -794,7 +798,7 @@ bool PseudoTcp::process(Segment& seg) {
|
||||
}
|
||||
m_recover = m_snd_nxt;
|
||||
uint32 nInFlight = m_snd_nxt - m_snd_una;
|
||||
m_ssthresh = rtc::_max(nInFlight / 2, 2 * m_mss);
|
||||
m_ssthresh = std::max(nInFlight / 2, 2 * m_mss);
|
||||
//LOG(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss;
|
||||
m_cwnd = m_ssthresh + 3 * m_mss;
|
||||
} else if (m_dup_acks > 3) {
|
||||
@ -952,7 +956,7 @@ bool PseudoTcp::transmit(const SList::iterator& seg, uint32 now) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 nTransmit = rtc::_min(seg->len, m_mss);
|
||||
uint32 nTransmit = std::min(seg->len, m_mss);
|
||||
|
||||
while (true) {
|
||||
uint32 seq = seg->seq;
|
||||
@ -1032,14 +1036,14 @@ void PseudoTcp::attemptSend(SendFlags sflags) {
|
||||
if ((m_dup_acks == 1) || (m_dup_acks == 2)) { // Limited Transmit
|
||||
cwnd += m_dup_acks * m_mss;
|
||||
}
|
||||
uint32 nWindow = rtc::_min(m_snd_wnd, cwnd);
|
||||
uint32 nWindow = std::min(m_snd_wnd, cwnd);
|
||||
uint32 nInFlight = m_snd_nxt - m_snd_una;
|
||||
uint32 nUseable = (nInFlight < nWindow) ? (nWindow - nInFlight) : 0;
|
||||
|
||||
size_t snd_buffered = 0;
|
||||
m_sbuf.GetBuffered(&snd_buffered);
|
||||
uint32 nAvailable =
|
||||
rtc::_min(static_cast<uint32>(snd_buffered) - nInFlight, m_mss);
|
||||
std::min(static_cast<uint32>(snd_buffered) - nInFlight, m_mss);
|
||||
|
||||
if (nAvailable > nUseable) {
|
||||
if (nUseable * 4 < nWindow) {
|
||||
@ -1136,8 +1140,8 @@ PseudoTcp::adjustMTU() {
|
||||
LOG(LS_INFO) << "Adjusting mss to " << m_mss << " bytes";
|
||||
#endif // _DEBUGMSG
|
||||
// Enforce minimums on ssthresh and cwnd
|
||||
m_ssthresh = rtc::_max(m_ssthresh, 2 * m_mss);
|
||||
m_cwnd = rtc::_max(m_cwnd, m_mss);
|
||||
m_ssthresh = std::max(m_ssthresh, 2 * m_mss);
|
||||
m_cwnd = std::max(m_cwnd, m_mss);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/p2p/base/pseudotcp.h"
|
||||
@ -142,8 +143,7 @@ class PseudoTcpTestBase : public testing::Test,
|
||||
// Also drop packets that are larger than the configured MTU.
|
||||
if (rtc::CreateRandomId() % 100 < static_cast<uint32>(loss_)) {
|
||||
LOG(LS_VERBOSE) << "Randomly dropping packet, size=" << len;
|
||||
} else if (len > static_cast<size_t>(
|
||||
rtc::_min(local_mtu_, remote_mtu_))) {
|
||||
} else if (len > static_cast<size_t>(std::min(local_mtu_, remote_mtu_))) {
|
||||
LOG(LS_VERBOSE) << "Dropping packet that exceeds path MTU, size=" << len;
|
||||
} else {
|
||||
int id = (tcp == &local_) ? MSG_RPACKET : MSG_LPACKET;
|
||||
@ -159,7 +159,7 @@ class PseudoTcpTestBase : public testing::Test,
|
||||
void UpdateClock(PseudoTcp* tcp, uint32 message) {
|
||||
long interval = 0; // NOLINT
|
||||
tcp->GetNextClock(PseudoTcp::Now(), interval);
|
||||
interval = rtc::_max<int>(interval, 0L); // sometimes interval is < 0
|
||||
interval = std::max<int>(interval, 0L); // sometimes interval is < 0
|
||||
rtc::Thread::Current()->Clear(this, message);
|
||||
rtc::Thread::Current()->PostDelayed(interval, this, message);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/p2p/base/relayport.h"
|
||||
#include "webrtc/base/asyncpacketsocket.h"
|
||||
@ -775,7 +776,7 @@ void AllocateRequest::Prepare(StunMessage* request) {
|
||||
}
|
||||
|
||||
int AllocateRequest::GetNextDelay() {
|
||||
int delay = 100 * rtc::_max(1 << count_, 2);
|
||||
int delay = 100 * std::max(1 << count_, 2);
|
||||
count_ += 1;
|
||||
if (count_ == 5)
|
||||
timeout_ = true;
|
||||
|
@ -263,8 +263,8 @@ void RelayServer::OnExternalPacket(
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 length = rtc::_min(static_cast<uint32>(username_attr->length()),
|
||||
USERNAME_LENGTH);
|
||||
uint32 length =
|
||||
std::min(static_cast<uint32>(username_attr->length()), USERNAME_LENGTH);
|
||||
std::string username(username_attr->bytes(), length);
|
||||
// TODO: Check the HMAC.
|
||||
|
||||
@ -359,7 +359,7 @@ void RelayServer::HandleStunAllocate(
|
||||
const StunUInt32Attribute* lifetime_attr =
|
||||
request.GetUInt32(STUN_ATTR_LIFETIME);
|
||||
if (lifetime_attr)
|
||||
lifetime = rtc::_min(lifetime, lifetime_attr->value() * 1000);
|
||||
lifetime = std::min(lifetime, lifetime_attr->value() * 1000);
|
||||
|
||||
binding = new RelayServerBinding(this, username, "0", lifetime);
|
||||
binding->SignalTimeout.connect(this, &RelayServer::OnTimeout);
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/p2p/base/stunrequest.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/helpers.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -192,7 +193,7 @@ void StunRequest::OnMessage(rtc::Message* pmsg) {
|
||||
}
|
||||
|
||||
int StunRequest::GetNextDelay() {
|
||||
int delay = DELAY_UNIT * rtc::_min(1 << count_, DELAY_MAX_FACTOR);
|
||||
int delay = DELAY_UNIT * std::min(1 << count_, DELAY_MAX_FACTOR);
|
||||
count_ += 1;
|
||||
if (count_ == MAX_SENDS)
|
||||
timeout_ = true;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/sound/alsasoundsystem.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/sound/sounddevicelocator.h"
|
||||
#include "webrtc/sound/soundinputstreaminterface.h"
|
||||
#include "webrtc/sound/soundoutputstreaminterface.h"
|
||||
@ -660,7 +661,7 @@ StreamInterface *AlsaSoundSystem::OpenDevice(
|
||||
params.freq /
|
||||
FrameSize(params);
|
||||
// And this is what we'll actually use.
|
||||
latency = rtc::_max(latency, kMinimumLatencyUsecs);
|
||||
latency = std::max(latency, kMinimumLatencyUsecs);
|
||||
}
|
||||
|
||||
ASSERT(static_cast<int>(params.format) <
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#ifdef HAVE_LIBPULSE
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/sound/sounddevicelocator.h"
|
||||
#include "webrtc/sound/soundinputstreaminterface.h"
|
||||
#include "webrtc/sound/soundoutputstreaminterface.h"
|
||||
@ -1441,11 +1442,9 @@ SoundOutputStreamInterface *PulseAudioSoundSystem::ConnectOutputStream(
|
||||
if (latency != kNoLatencyRequirements) {
|
||||
// kLowLatency is 0, so we treat it the same as a request for zero latency.
|
||||
ssize_t bytes_per_sec = symbol_table_.pa_bytes_per_second()(&spec);
|
||||
latency = rtc::_max(
|
||||
latency,
|
||||
static_cast<int>(
|
||||
bytes_per_sec * kPlaybackLatencyMinimumMsecs /
|
||||
rtc::kNumMicrosecsPerSec));
|
||||
latency = std::max(
|
||||
latency, static_cast<int>(bytes_per_sec * kPlaybackLatencyMinimumMsecs /
|
||||
rtc::kNumMicrosecsPerSec));
|
||||
FillPlaybackBufferAttr(latency, &attr);
|
||||
pattr = &attr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user