Convert usage of ARRAY_SIZE to arraysize.
ARRAY_SIZE is the old version of arraysize and does not cover all the cases in C++, arraysize is a copy of Chromium's version and thus have wider coverage. BUG=None R=tommi@webrtc.org Review URL: https://codereview.webrtc.org/1405023016 Cr-Commit-Position: refs/heads/master@{#10594}
This commit is contained in:
parent
e134a534cd
commit
5237aaf243
@ -29,6 +29,7 @@
|
||||
|
||||
#include "talk/app/webrtc/webrtcsdp.h"
|
||||
#include "talk/session/media/mediasession.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
|
||||
using rtc::scoped_ptr;
|
||||
@ -44,7 +45,7 @@ static const char* kSupportedTypes[] = {
|
||||
|
||||
static bool IsTypeSupported(const std::string& type) {
|
||||
bool type_supported = false;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(kSupportedTypes); ++i) {
|
||||
for (size_t i = 0; i < arraysize(kSupportedTypes); ++i) {
|
||||
if (kSupportedTypes[i] == type) {
|
||||
type_supported = true;
|
||||
break;
|
||||
|
||||
@ -46,11 +46,12 @@
|
||||
#include "talk/app/webrtc/videosource.h"
|
||||
#include "talk/app/webrtc/videotrack.h"
|
||||
#include "talk/media/sctp/sctpdataengine.h"
|
||||
#include "webrtc/p2p/client/basicportallocator.h"
|
||||
#include "talk/session/media/channelmanager.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/p2p/client/basicportallocator.h"
|
||||
#include "webrtc/system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace {
|
||||
@ -95,7 +96,7 @@ enum ServiceType {
|
||||
TURNS, // Indicates a TURN server used with a TLS session.
|
||||
INVALID, // Unknown.
|
||||
};
|
||||
static_assert(INVALID == ARRAY_SIZE(kValidIceServiceTypes),
|
||||
static_assert(INVALID == arraysize(kValidIceServiceTypes),
|
||||
"kValidIceServiceTypes must have as many strings as ServiceType "
|
||||
"has values.");
|
||||
|
||||
@ -156,7 +157,7 @@ bool GetServiceTypeAndHostnameFromUri(const std::string& in_str,
|
||||
return false;
|
||||
}
|
||||
*service_type = INVALID;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(kValidIceServiceTypes); ++i) {
|
||||
for (size_t i = 0; i < arraysize(kValidIceServiceTypes); ++i) {
|
||||
if (in_str.compare(0, colonpos, kValidIceServiceTypes[i]) == 0) {
|
||||
*service_type = static_cast<ServiceType>(i);
|
||||
break;
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
|
||||
#include "talk/app/webrtc/mediaconstraintsinterface.h"
|
||||
#include "talk/session/media/channelmanager.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
|
||||
using cricket::CaptureState;
|
||||
using webrtc::MediaConstraintsInterface;
|
||||
@ -369,7 +370,7 @@ void VideoSource::Initialize(
|
||||
} else {
|
||||
// The VideoCapturer implementation doesn't support capability
|
||||
// enumeration. We need to guess what the camera supports.
|
||||
for (int i = 0; i < ARRAY_SIZE(kVideoFormats); ++i) {
|
||||
for (int i = 0; i < arraysize(kVideoFormats); ++i) {
|
||||
formats.push_back(cricket::VideoFormat(kVideoFormats[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
#include "webrtc/p2p/base/constants.h"
|
||||
#include "webrtc/p2p/base/port.h"
|
||||
#include "talk/session/media/mediasession.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/messagedigest.h"
|
||||
@ -1525,7 +1526,7 @@ bool IsFmtpParam(const std::string& name) {
|
||||
kCodecParamMaxAverageBitrate, kCodecParamMaxPlaybackRate,
|
||||
kCodecParamAssociatedPayloadType
|
||||
};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(kFmtpParams); ++i) {
|
||||
for (size_t i = 0; i < arraysize(kFmtpParams); ++i) {
|
||||
if (_stricmp(name.c_str(), kFmtpParams[i]) == 0) {
|
||||
return true;
|
||||
}
|
||||
@ -2082,7 +2083,7 @@ void MaybeCreateStaticPayloadAudioCodecs(
|
||||
int payload_type = *it;
|
||||
if (!media_desc->HasCodec(payload_type) &&
|
||||
payload_type >= 0 &&
|
||||
payload_type < ARRAY_SIZE(kStaticPayloadAudioCodecs)) {
|
||||
payload_type < arraysize(kStaticPayloadAudioCodecs)) {
|
||||
std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name;
|
||||
int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate;
|
||||
int channels = kStaticPayloadAudioCodecs[payload_type].channels;
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
#include "talk/media/base/fakevideocapturer.h"
|
||||
#include "talk/media/base/fakevideorenderer.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/sigslot.h"
|
||||
|
||||
@ -57,7 +58,7 @@ class CaptureManagerTest : public ::testing::Test, public sigslot::has_slots<> {
|
||||
}
|
||||
void PopulateSupportedFormats() {
|
||||
std::vector<cricket::VideoFormat> formats;
|
||||
for (int i = 0; i < ARRAY_SIZE(kCameraFormats); ++i) {
|
||||
for (int i = 0; i < arraysize(kCameraFormats); ++i) {
|
||||
formats.push_back(cricket::VideoFormat(kCameraFormats[i]));
|
||||
}
|
||||
video_capturer_.ResetSupportedFormats(formats);
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
#include "talk/media/base/streamparams.h"
|
||||
#include "talk/media/base/testutils.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
|
||||
static const uint32_t kSsrcs1[] = {1};
|
||||
@ -54,8 +55,8 @@ TEST(SsrcGroup, EqualNotEqual) {
|
||||
cricket::SsrcGroup("abc", MAKE_VECTOR(kSsrcs2)),
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(ssrc_groups); ++i) {
|
||||
for (size_t j = 0; j < ARRAY_SIZE(ssrc_groups); ++j) {
|
||||
for (size_t i = 0; i < arraysize(ssrc_groups); ++i) {
|
||||
for (size_t j = 0; j < arraysize(ssrc_groups); ++j) {
|
||||
EXPECT_EQ((ssrc_groups[i] == ssrc_groups[j]), (i == j));
|
||||
EXPECT_EQ((ssrc_groups[i] != ssrc_groups[j]), (i != j));
|
||||
}
|
||||
@ -92,7 +93,7 @@ TEST(StreamParams, CreateLegacy) {
|
||||
|
||||
TEST(StreamParams, HasSsrcGroup) {
|
||||
cricket::StreamParams sp =
|
||||
CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, ARRAY_SIZE(kSsrcs2));
|
||||
CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2));
|
||||
EXPECT_EQ(2U, sp.ssrcs.size());
|
||||
EXPECT_EQ(kSsrcs2[0], sp.first_ssrc());
|
||||
EXPECT_TRUE(sp.has_ssrcs());
|
||||
@ -107,7 +108,7 @@ TEST(StreamParams, HasSsrcGroup) {
|
||||
|
||||
TEST(StreamParams, GetSsrcGroup) {
|
||||
cricket::StreamParams sp =
|
||||
CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, ARRAY_SIZE(kSsrcs2));
|
||||
CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2));
|
||||
EXPECT_EQ(NULL, sp.get_ssrc_group("xyz"));
|
||||
EXPECT_EQ(&sp.ssrc_groups[0], sp.get_ssrc_group("XYZ"));
|
||||
}
|
||||
@ -116,17 +117,17 @@ TEST(StreamParams, EqualNotEqual) {
|
||||
cricket::StreamParams l1 = cricket::StreamParams::CreateLegacy(1);
|
||||
cricket::StreamParams l2 = cricket::StreamParams::CreateLegacy(2);
|
||||
cricket::StreamParams sg1 =
|
||||
CreateStreamParamsWithSsrcGroup("ABC", kSsrcs1, ARRAY_SIZE(kSsrcs1));
|
||||
CreateStreamParamsWithSsrcGroup("ABC", kSsrcs1, arraysize(kSsrcs1));
|
||||
cricket::StreamParams sg2 =
|
||||
CreateStreamParamsWithSsrcGroup("ABC", kSsrcs2, ARRAY_SIZE(kSsrcs2));
|
||||
CreateStreamParamsWithSsrcGroup("ABC", kSsrcs2, arraysize(kSsrcs2));
|
||||
cricket::StreamParams sg3 =
|
||||
CreateStreamParamsWithSsrcGroup("Abc", kSsrcs2, ARRAY_SIZE(kSsrcs2));
|
||||
CreateStreamParamsWithSsrcGroup("Abc", kSsrcs2, arraysize(kSsrcs2));
|
||||
cricket::StreamParams sg4 =
|
||||
CreateStreamParamsWithSsrcGroup("abc", kSsrcs2, ARRAY_SIZE(kSsrcs2));
|
||||
CreateStreamParamsWithSsrcGroup("abc", kSsrcs2, arraysize(kSsrcs2));
|
||||
cricket::StreamParams sps[] = {l1, l2, sg1, sg2, sg3, sg4};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(sps); ++i) {
|
||||
for (size_t j = 0; j < ARRAY_SIZE(sps); ++j) {
|
||||
for (size_t i = 0; i < arraysize(sps); ++i) {
|
||||
for (size_t j = 0; j < arraysize(sps); ++j) {
|
||||
EXPECT_EQ((sps[i] == sps[j]), (i == j));
|
||||
EXPECT_EQ((sps[i] != sps[j]), (i != j));
|
||||
}
|
||||
@ -195,7 +196,7 @@ TEST(StreamParams, GetPrimaryAndFidSsrcs) {
|
||||
|
||||
TEST(StreamParams, ToString) {
|
||||
cricket::StreamParams sp =
|
||||
CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, ARRAY_SIZE(kSsrcs2));
|
||||
CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2));
|
||||
EXPECT_STREQ("{ssrcs:[1,2];ssrc_groups:{semantics:XYZ;ssrcs:[1,2]};}",
|
||||
sp.ToString().c_str());
|
||||
}
|
||||
|
||||
@ -132,8 +132,8 @@ const RawRtcpPacket RtpTestUtility::kTestRawRtcpPackets[] = {
|
||||
};
|
||||
|
||||
size_t RtpTestUtility::GetTestPacketCount() {
|
||||
return std::min(ARRAY_SIZE(kTestRawRtpPackets),
|
||||
ARRAY_SIZE(kTestRawRtcpPackets));
|
||||
return std::min(arraysize(kTestRawRtpPackets),
|
||||
arraysize(kTestRawRtcpPackets));
|
||||
}
|
||||
|
||||
bool RtpTestUtility::WriteTestPackets(size_t count,
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include "talk/media/base/mediachannel.h"
|
||||
#include "talk/media/base/videocapturer.h"
|
||||
#include "talk/media/base/videocommon.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/sigslot.h"
|
||||
#include "webrtc/base/window.h"
|
||||
@ -54,7 +55,7 @@ namespace cricket {
|
||||
template <class T> inline std::vector<T> MakeVector(const T a[], size_t s) {
|
||||
return std::vector<T>(a, a + s);
|
||||
}
|
||||
#define MAKE_VECTOR(a) cricket::MakeVector(a, ARRAY_SIZE(a))
|
||||
#define MAKE_VECTOR(a) cricket::MakeVector(a, arraysize(a))
|
||||
|
||||
struct RtpDumpPacket;
|
||||
class RtpDumpWriter;
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include <math.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
|
||||
namespace cricket {
|
||||
@ -58,7 +59,7 @@ static const FourCCAliasEntry kFourCCAliases[] = {
|
||||
};
|
||||
|
||||
uint32_t CanonicalFourCC(uint32_t fourcc) {
|
||||
for (int i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) {
|
||||
for (int i = 0; i < arraysize(kFourCCAliases); ++i) {
|
||||
if (kFourCCAliases[i].alias == fourcc) {
|
||||
return kFourCCAliases[i].canonical;
|
||||
}
|
||||
@ -75,7 +76,7 @@ static float kScaleFactors[] = {
|
||||
1.f / 16.f // 1/16 scale.
|
||||
};
|
||||
|
||||
static const int kNumScaleFactors = ARRAY_SIZE(kScaleFactors);
|
||||
static const int kNumScaleFactors = arraysize(kScaleFactors);
|
||||
|
||||
// Finds the scale factor that, when applied to width and height, produces
|
||||
// fewer than num_pixels.
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
#include "libyuv/planar_functions.h"
|
||||
#include "libyuv/scale.h"
|
||||
#include "talk/media/base/videocommon.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
@ -318,7 +319,7 @@ bool VideoFrame::Validate(uint32_t fourcc,
|
||||
}
|
||||
// TODO(fbarchard): Make function to dump information about frames.
|
||||
uint8_t four_samples[4] = {0, 0, 0, 0};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(four_samples) && i < sample_size; ++i) {
|
||||
for (size_t i = 0; i < arraysize(four_samples) && i < sample_size; ++i) {
|
||||
four_samples[i] = sample[i];
|
||||
}
|
||||
if (sample_size < expected_size) {
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
#include "talk/media/base/videocapturerfactory.h"
|
||||
#include "talk/media/devices/filevideocapturer.h"
|
||||
#include "talk/media/devices/v4llookup.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -269,19 +270,19 @@ TEST(DeviceManagerTest, VerifyFilterDevices) {
|
||||
"device5",
|
||||
};
|
||||
std::vector<Device> devices;
|
||||
for (int i = 0; i < ARRAY_SIZE(kTotalDevicesName); ++i) {
|
||||
for (int i = 0; i < arraysize(kTotalDevicesName); ++i) {
|
||||
devices.push_back(Device(kTotalDevicesName[i], i));
|
||||
}
|
||||
EXPECT_TRUE(CompareDeviceList(devices, kTotalDevicesName,
|
||||
ARRAY_SIZE(kTotalDevicesName)));
|
||||
arraysize(kTotalDevicesName)));
|
||||
// Return false if given NULL as the exclusion list.
|
||||
EXPECT_TRUE(DeviceManager::FilterDevices(&devices, NULL));
|
||||
// The devices should not change.
|
||||
EXPECT_TRUE(CompareDeviceList(devices, kTotalDevicesName,
|
||||
ARRAY_SIZE(kTotalDevicesName)));
|
||||
arraysize(kTotalDevicesName)));
|
||||
EXPECT_TRUE(DeviceManager::FilterDevices(&devices, kFilteredDevicesName));
|
||||
EXPECT_TRUE(CompareDeviceList(devices, kDevicesName,
|
||||
ARRAY_SIZE(kDevicesName)));
|
||||
arraysize(kDevicesName)));
|
||||
}
|
||||
|
||||
#ifdef LINUX
|
||||
|
||||
@ -48,6 +48,7 @@ EXTERN_C const PROPERTYKEY PKEY_AudioEndpoint_GUID = { {
|
||||
} }, 4
|
||||
};
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
@ -148,7 +149,7 @@ bool Win32DeviceManager::GetDefaultVideoCaptureDevice(Device* device) {
|
||||
*device = devices[0];
|
||||
for (size_t i = 0; i < devices.size(); ++i) {
|
||||
if (strnicmp(devices[i].id.c_str(), kUsbDevicePathPrefix,
|
||||
ARRAY_SIZE(kUsbDevicePathPrefix) - 1) == 0) {
|
||||
arraysize(kUsbDevicePathPrefix) - 1) == 0) {
|
||||
*device = devices[i];
|
||||
break;
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "talk/media/base/constants.h"
|
||||
#include "talk/media/base/streamparams.h"
|
||||
#include "usrsctplib/usrsctp.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/buffer.h"
|
||||
#include "webrtc/base/helpers.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -76,7 +77,7 @@ std::string ListFlags(int flags) {
|
||||
MAKEFLAG(SCTP_STREAM_CHANGE_DENIED)
|
||||
};
|
||||
#undef MAKEFLAG
|
||||
for (int i = 0; i < ARRAY_SIZE(flaginfo); ++i) {
|
||||
for (int i = 0; i < arraysize(flaginfo); ++i) {
|
||||
if (flags & flaginfo[i].value) {
|
||||
if (!first) result << " | ";
|
||||
result << flaginfo[i].name;
|
||||
@ -473,7 +474,7 @@ bool SctpDataMediaChannel::OpenSctpSocket() {
|
||||
struct sctp_event event = {0};
|
||||
event.se_assoc_id = SCTP_ALL_ASSOC;
|
||||
event.se_on = 1;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(event_types); i++) {
|
||||
for (size_t i = 0; i < arraysize(event_types); i++) {
|
||||
event.se_type = event_types[i];
|
||||
if (usrsctp_setsockopt(sock_, IPPROTO_SCTP, SCTP_EVENT, &event,
|
||||
sizeof(event)) < 0) {
|
||||
|
||||
@ -29,9 +29,11 @@
|
||||
|
||||
#include "talk/media/base/streamparams.h"
|
||||
#include "talk/media/webrtc/simulcast.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
struct SimulcastFormat {
|
||||
@ -93,7 +95,7 @@ void MaybeExchangeWidthHeight(int* width, int* height) {
|
||||
int FindSimulcastFormatIndex(int width, int height) {
|
||||
MaybeExchangeWidthHeight(&width, &height);
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(kSimulcastFormats); ++i) {
|
||||
for (int i = 0; i < arraysize(kSimulcastFormats); ++i) {
|
||||
if (width >= kSimulcastFormats[i].width &&
|
||||
height >= kSimulcastFormats[i].height) {
|
||||
return i;
|
||||
@ -105,7 +107,7 @@ int FindSimulcastFormatIndex(int width, int height) {
|
||||
int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
|
||||
MaybeExchangeWidthHeight(&width, &height);
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(kSimulcastFormats); ++i) {
|
||||
for (int i = 0; i < arraysize(kSimulcastFormats); ++i) {
|
||||
if (width >= kSimulcastFormats[i].width &&
|
||||
height >= kSimulcastFormats[i].height &&
|
||||
max_layers == kSimulcastFormats[i].max_layers) {
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "talk/media/webrtc/webrtcmediaengine.h"
|
||||
#include "talk/media/webrtc/webrtcvideoengine2.h"
|
||||
#include "talk/media/webrtc/webrtcvoiceengine.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
@ -72,8 +73,7 @@ const char* kBweExtensionPriorities[] = {
|
||||
kRtpTransportSequenceNumberHeaderExtension,
|
||||
kRtpAbsoluteSenderTimeHeaderExtension, kRtpTimestampOffsetHeaderExtension};
|
||||
|
||||
const size_t kBweExtensionPrioritiesLength =
|
||||
ARRAY_SIZE(kBweExtensionPriorities);
|
||||
const size_t kBweExtensionPrioritiesLength = arraysize(kBweExtensionPriorities);
|
||||
|
||||
int GetPriority(const RtpHeaderExtension& extension,
|
||||
const char* extension_prios[],
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#ifdef HAVE_WEBRTC_VIDEO
|
||||
#include "talk/media/webrtc/webrtcvideoframe.h"
|
||||
#include "talk/media/webrtc/webrtcvideoframefactory.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/bind.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
@ -83,7 +84,7 @@ class WebRtcVcmFactory : public WebRtcVcmFactoryInterface {
|
||||
static bool CapabilityToFormat(const webrtc::VideoCaptureCapability& cap,
|
||||
VideoFormat* format) {
|
||||
uint32_t fourcc = 0;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) {
|
||||
for (size_t i = 0; i < arraysize(kSupportedFourCCs); ++i) {
|
||||
if (kSupportedFourCCs[i].webrtc_type == cap.rawType) {
|
||||
fourcc = kSupportedFourCCs[i].fourcc;
|
||||
break;
|
||||
@ -103,7 +104,7 @@ static bool CapabilityToFormat(const webrtc::VideoCaptureCapability& cap,
|
||||
static bool FormatToCapability(const VideoFormat& format,
|
||||
webrtc::VideoCaptureCapability* cap) {
|
||||
webrtc::RawVideoType webrtc_type = webrtc::kVideoUnknown;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) {
|
||||
for (size_t i = 0; i < arraysize(kSupportedFourCCs); ++i) {
|
||||
if (kSupportedFourCCs[i].fourcc == format.fourcc) {
|
||||
webrtc_type = kSupportedFourCCs[i].webrtc_type;
|
||||
break;
|
||||
@ -171,8 +172,8 @@ bool WebRtcVideoCapturer::Init(const Device& device) {
|
||||
bool found = false;
|
||||
for (int index = 0; index < num_cams; ++index) {
|
||||
char vcm_name[256];
|
||||
if (info->GetDeviceName(index, vcm_name, ARRAY_SIZE(vcm_name),
|
||||
vcm_id, ARRAY_SIZE(vcm_id)) != -1) {
|
||||
if (info->GetDeviceName(index, vcm_name, arraysize(vcm_name), vcm_id,
|
||||
arraysize(vcm_id)) != -1) {
|
||||
if (device.name == reinterpret_cast<char*>(vcm_name)) {
|
||||
found = true;
|
||||
break;
|
||||
@ -361,7 +362,7 @@ bool WebRtcVideoCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) {
|
||||
}
|
||||
|
||||
fourccs->clear();
|
||||
for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) {
|
||||
for (size_t i = 0; i < arraysize(kSupportedFourCCs); ++i) {
|
||||
fourccs->push_back(kSupportedFourCCs[i].fourcc);
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include "talk/media/base/constants.h"
|
||||
#include "talk/media/base/streamparams.h"
|
||||
#include "talk/media/webrtc/webrtcvoe.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/base64.h"
|
||||
#include "webrtc/base/byteorder.h"
|
||||
#include "webrtc/base/common.h"
|
||||
@ -212,7 +213,7 @@ bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) {
|
||||
}
|
||||
|
||||
bool IsCodecMultiRate(const webrtc::CodecInst& codec) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(kCodecPrefs); ++i) {
|
||||
for (size_t i = 0; i < arraysize(kCodecPrefs); ++i) {
|
||||
if (IsCodec(codec, kCodecPrefs[i].name) &&
|
||||
kCodecPrefs[i].clockrate == codec.plfreq) {
|
||||
return kCodecPrefs[i].is_multi_rate;
|
||||
@ -455,7 +456,7 @@ void WebRtcVoiceEngine::ConstructCodecs() {
|
||||
}
|
||||
|
||||
const CodecPref* pref = NULL;
|
||||
for (size_t j = 0; j < ARRAY_SIZE(kCodecPrefs); ++j) {
|
||||
for (size_t j = 0; j < arraysize(kCodecPrefs); ++j) {
|
||||
if (IsCodec(voe_codec, kCodecPrefs[j].name) &&
|
||||
kCodecPrefs[j].clockrate == voe_codec.plfreq &&
|
||||
kCodecPrefs[j].channels == voe_codec.channels) {
|
||||
@ -467,9 +468,10 @@ void WebRtcVoiceEngine::ConstructCodecs() {
|
||||
if (pref) {
|
||||
// Use the payload type that we've configured in our pref table;
|
||||
// use the offset in our pref table to determine the sort order.
|
||||
AudioCodec codec(pref->payload_type, voe_codec.plname, voe_codec.plfreq,
|
||||
voe_codec.rate, voe_codec.channels,
|
||||
ARRAY_SIZE(kCodecPrefs) - (pref - kCodecPrefs));
|
||||
AudioCodec codec(
|
||||
pref->payload_type, voe_codec.plname, voe_codec.plfreq,
|
||||
voe_codec.rate, voe_codec.channels,
|
||||
static_cast<int>(arraysize(kCodecPrefs)) - (pref - kCodecPrefs));
|
||||
LOG(LS_INFO) << ToString(codec);
|
||||
if (IsCodec(codec, kIsacCodecName)) {
|
||||
// Indicate auto-bitrate in signaling.
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/byteorder.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/call.h"
|
||||
@ -91,7 +92,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test {
|
||||
public:
|
||||
WebRtcVoiceEngineTestFake()
|
||||
: call_(webrtc::Call::Config()),
|
||||
voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)),
|
||||
voe_(kAudioCodecs, arraysize(kAudioCodecs)),
|
||||
trace_wrapper_(new FakeVoETraceWrapper()),
|
||||
engine_(new FakeVoEWrapper(&voe_), trace_wrapper_),
|
||||
channel_(nullptr) {
|
||||
@ -493,14 +494,13 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) {
|
||||
cricket::StreamParams::CreateLegacy(kSsrc1)));
|
||||
int channel_num = voe_.GetLastChannel();
|
||||
webrtc::CodecInst gcodec;
|
||||
rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
|
||||
rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
|
||||
gcodec.plfreq = 16000;
|
||||
gcodec.channels = 1;
|
||||
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
|
||||
EXPECT_EQ(106, gcodec.pltype);
|
||||
EXPECT_STREQ("ISAC", gcodec.plname);
|
||||
rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname),
|
||||
"telephone-event");
|
||||
rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event");
|
||||
gcodec.plfreq = 8000;
|
||||
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
|
||||
EXPECT_EQ(126, gcodec.pltype);
|
||||
@ -607,14 +607,13 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) {
|
||||
cricket::StreamParams::CreateLegacy(kSsrc1)));
|
||||
int channel_num2 = voe_.GetLastChannel();
|
||||
webrtc::CodecInst gcodec;
|
||||
rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
|
||||
rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
|
||||
gcodec.plfreq = 16000;
|
||||
gcodec.channels = 1;
|
||||
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
|
||||
EXPECT_EQ(106, gcodec.pltype);
|
||||
EXPECT_STREQ("ISAC", gcodec.plname);
|
||||
rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname),
|
||||
"telephone-event");
|
||||
rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event");
|
||||
gcodec.plfreq = 8000;
|
||||
gcodec.channels = 1;
|
||||
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
|
||||
@ -631,7 +630,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) {
|
||||
|
||||
int channel_num2 = voe_.GetLastChannel();
|
||||
webrtc::CodecInst gcodec;
|
||||
rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
|
||||
rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
|
||||
gcodec.plfreq = 16000;
|
||||
gcodec.channels = 1;
|
||||
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
|
||||
@ -1983,7 +1982,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) {
|
||||
int channel_num = voe_.GetChannelFromLocalSsrc(ssrc);
|
||||
EXPECT_TRUE(voe_.GetSend(channel_num));
|
||||
}
|
||||
EXPECT_EQ(ARRAY_SIZE(kSsrcs4), call_.GetAudioSendStreams().size());
|
||||
EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size());
|
||||
|
||||
// Delete the send streams.
|
||||
for (uint32_t ssrc : kSsrcs4) {
|
||||
@ -2088,7 +2087,7 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) {
|
||||
EXPECT_EQ(true, channel_->GetStats(&info));
|
||||
|
||||
// We have added 4 send streams. We should see empty stats for all.
|
||||
EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size());
|
||||
EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
|
||||
for (const auto& sender : info.senders) {
|
||||
VerifyVoiceSenderInfo(sender, false);
|
||||
}
|
||||
@ -2103,7 +2102,7 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) {
|
||||
cricket::VoiceMediaInfo info;
|
||||
EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2));
|
||||
EXPECT_EQ(true, channel_->GetStats(&info));
|
||||
EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size());
|
||||
EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
|
||||
EXPECT_EQ(0u, info.receivers.size());
|
||||
}
|
||||
|
||||
@ -2114,7 +2113,7 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) {
|
||||
DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
|
||||
SetAudioReceiveStreamStats();
|
||||
EXPECT_EQ(true, channel_->GetStats(&info));
|
||||
EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size());
|
||||
EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
|
||||
EXPECT_EQ(1u, info.receivers.size());
|
||||
VerifyVoiceReceiverInfo(info.receivers[0]);
|
||||
}
|
||||
@ -2442,7 +2441,7 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) {
|
||||
int channel_num3 = voe_.GetLastChannel();
|
||||
// Create packets with the right SSRCs.
|
||||
char packets[4][sizeof(kPcmuFrame)];
|
||||
for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) {
|
||||
for (size_t i = 0; i < arraysize(packets); ++i) {
|
||||
memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame));
|
||||
rtc::SetBE32(packets[i] + 8, static_cast<uint32_t>(i));
|
||||
}
|
||||
@ -2507,7 +2506,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) {
|
||||
cricket::StreamParams::CreateLegacy(kSsrc1)));
|
||||
int channel_num2 = voe_.GetLastChannel();
|
||||
webrtc::CodecInst gcodec;
|
||||
rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus");
|
||||
rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "opus");
|
||||
gcodec.plfreq = 48000;
|
||||
gcodec.channels = 2;
|
||||
EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec));
|
||||
@ -3046,12 +3045,12 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
|
||||
EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
|
||||
|
||||
static const uint32_t kSsrcs[] = {1, 2, 3, 4};
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) {
|
||||
for (unsigned int i = 0; i < arraysize(kSsrcs); ++i) {
|
||||
EXPECT_TRUE(media_channel->AddRecvStream(
|
||||
cricket::StreamParams::CreateLegacy(kSsrcs[i])));
|
||||
EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i]));
|
||||
}
|
||||
EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size());
|
||||
EXPECT_EQ(arraysize(kSsrcs), call_.GetAudioReceiveStreams().size());
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
|
||||
@ -3296,7 +3295,7 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) {
|
||||
|
||||
cricket::VoiceMediaChannel* channels[32];
|
||||
int num_channels = 0;
|
||||
while (num_channels < ARRAY_SIZE(channels)) {
|
||||
while (num_channels < arraysize(channels)) {
|
||||
cricket::VoiceMediaChannel* channel =
|
||||
engine.CreateChannel(call.get(), cricket::AudioOptions());
|
||||
if (!channel)
|
||||
@ -3304,7 +3303,7 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) {
|
||||
channels[num_channels++] = channel;
|
||||
}
|
||||
|
||||
int expected = ARRAY_SIZE(channels);
|
||||
int expected = arraysize(channels);
|
||||
EXPECT_EQ(expected, num_channels);
|
||||
|
||||
while (num_channels > 0) {
|
||||
|
||||
@ -33,8 +33,9 @@
|
||||
#include "talk/media/base/rtpdump.h"
|
||||
#include "talk/media/base/screencastid.h"
|
||||
#include "talk/media/base/testutils.h"
|
||||
#include "webrtc/p2p/base/faketransportcontroller.h"
|
||||
#include "talk/session/media/channel.h"
|
||||
#include "webrtc/p2p/base/faketransportcontroller.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/helpers.h"
|
||||
@ -2253,21 +2254,19 @@ TEST_F(VoiceChannelTest, TestScaleVolumeMultiwayCall) {
|
||||
}
|
||||
|
||||
TEST_F(VoiceChannelTest, SendBundleToBundle) {
|
||||
Base::SendBundleToBundle(kAudioPts, ARRAY_SIZE(kAudioPts), false, false);
|
||||
Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
|
||||
}
|
||||
|
||||
TEST_F(VoiceChannelTest, SendBundleToBundleSecure) {
|
||||
Base::SendBundleToBundle(kAudioPts, ARRAY_SIZE(kAudioPts), false, true);
|
||||
Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
|
||||
}
|
||||
|
||||
TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) {
|
||||
Base::SendBundleToBundle(
|
||||
kAudioPts, ARRAY_SIZE(kAudioPts), true, false);
|
||||
Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
|
||||
}
|
||||
|
||||
TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) {
|
||||
Base::SendBundleToBundle(
|
||||
kAudioPts, ARRAY_SIZE(kAudioPts), true, true);
|
||||
Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
|
||||
}
|
||||
|
||||
// VideoChannelTest
|
||||
@ -2501,21 +2500,19 @@ TEST_F(VideoChannelTest, TestFlushRtcp) {
|
||||
}
|
||||
|
||||
TEST_F(VideoChannelTest, SendBundleToBundle) {
|
||||
Base::SendBundleToBundle(kVideoPts, ARRAY_SIZE(kVideoPts), false, false);
|
||||
Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
|
||||
}
|
||||
|
||||
TEST_F(VideoChannelTest, SendBundleToBundleSecure) {
|
||||
Base::SendBundleToBundle(kVideoPts, ARRAY_SIZE(kVideoPts), false, true);
|
||||
Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
|
||||
}
|
||||
|
||||
TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMux) {
|
||||
Base::SendBundleToBundle(
|
||||
kVideoPts, ARRAY_SIZE(kVideoPts), true, false);
|
||||
Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
|
||||
}
|
||||
|
||||
TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMuxSecure) {
|
||||
Base::SendBundleToBundle(
|
||||
kVideoPts, ARRAY_SIZE(kVideoPts), true, true);
|
||||
Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
|
||||
}
|
||||
|
||||
TEST_F(VideoChannelTest, TestSrtpError) {
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/bitbuffer.h"
|
||||
#include "webrtc/base/bytebuffer.h"
|
||||
#include "webrtc/base/common.h"
|
||||
@ -301,11 +302,11 @@ TEST(BitBufferWriterTest, SymmetricGolomb) {
|
||||
char test_string[] = "my precious";
|
||||
uint8_t bytes[64] = {0};
|
||||
BitBufferWriter buffer(bytes, 64);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(test_string); ++i) {
|
||||
for (size_t i = 0; i < arraysize(test_string); ++i) {
|
||||
EXPECT_TRUE(buffer.WriteExponentialGolomb(test_string[i]));
|
||||
}
|
||||
buffer.Seek(0, 0);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(test_string); ++i) {
|
||||
for (size_t i = 0; i < arraysize(test_string); ++i) {
|
||||
uint32_t val;
|
||||
EXPECT_TRUE(buffer.ReadExponentialGolomb(&val));
|
||||
EXPECT_LE(val, std::numeric_limits<uint8_t>::max());
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/bytebuffer.h"
|
||||
#include "webrtc/base/byteorder.h"
|
||||
#include "webrtc/base/common.h"
|
||||
@ -114,7 +115,7 @@ TEST(ByteBufferTest, TestGetSetReadPosition) {
|
||||
TEST(ByteBufferTest, TestReadWriteBuffer) {
|
||||
ByteBuffer::ByteOrder orders[2] = { ByteBuffer::ORDER_HOST,
|
||||
ByteBuffer::ORDER_NETWORK };
|
||||
for (size_t i = 0; i < ARRAY_SIZE(orders); i++) {
|
||||
for (size_t i = 0; i < arraysize(orders); i++) {
|
||||
ByteBuffer buffer(orders[i]);
|
||||
EXPECT_EQ(orders[i], buffer.Order());
|
||||
uint8_t ru8;
|
||||
|
||||
@ -54,8 +54,6 @@ inline void RtcUnused(const void*) {}
|
||||
|
||||
#endif // !defined(WEBRTC_WIN)
|
||||
|
||||
#define ARRAY_SIZE(x) (static_cast<int>(sizeof(x) / sizeof(x[0])))
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Assertions
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/base/crc32.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/basicdefs.h"
|
||||
|
||||
namespace rtc {
|
||||
@ -22,9 +23,9 @@ static const uint32_t kCrc32Polynomial = 0xEDB88320;
|
||||
static uint32_t kCrc32Table[256] = {0};
|
||||
|
||||
static void EnsureCrc32TableInited() {
|
||||
if (kCrc32Table[ARRAY_SIZE(kCrc32Table) - 1])
|
||||
if (kCrc32Table[arraysize(kCrc32Table) - 1])
|
||||
return; // already inited
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(kCrc32Table); ++i) {
|
||||
for (uint32_t i = 0; i < arraysize(kCrc32Table); ++i) {
|
||||
uint32_t c = i;
|
||||
for (size_t j = 0; j < 8; ++j) {
|
||||
if (c & 1) {
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/diskcache.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
@ -263,7 +264,7 @@ std::string DiskCache::IdToFilename(const std::string& id, size_t index) const {
|
||||
#endif // !TRANSPARENT_CACHE_NAMES
|
||||
|
||||
char extension[32];
|
||||
sprintfn(extension, ARRAY_SIZE(extension), ".%u", index);
|
||||
sprintfn(extension, arraysize(extension), ".%u", index);
|
||||
|
||||
Pathname pathname;
|
||||
pathname.SetFolder(folder_);
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/pathutils.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
@ -273,8 +274,8 @@ bool CreateUniqueFile(Pathname& path, bool create_empty) {
|
||||
}
|
||||
version += 1;
|
||||
char version_base[MAX_PATH];
|
||||
sprintfn(version_base, ARRAY_SIZE(version_base), "%s-%u",
|
||||
basename.c_str(), version);
|
||||
sprintfn(version_base, arraysize(version_base), "%s-%u", basename.c_str(),
|
||||
version);
|
||||
path.SetBasename(version_base);
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#ifndef WEBRTC_BASE_HTTPCOMMON_INL_H__
|
||||
#define WEBRTC_BASE_HTTPCOMMON_INL_H__
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/httpcommon.h"
|
||||
|
||||
@ -80,7 +81,7 @@ void Url<CTYPE>::do_set_full_path(const CTYPE* val, size_t len) {
|
||||
template<class CTYPE>
|
||||
void Url<CTYPE>::do_get_url(string* val) const {
|
||||
CTYPE protocol[9];
|
||||
asccpyn(protocol, ARRAY_SIZE(protocol), secure_ ? "https://" : "http://");
|
||||
asccpyn(protocol, arraysize(protocol), secure_ ? "https://" : "http://");
|
||||
val->append(protocol);
|
||||
do_get_address(val);
|
||||
do_get_full_path(val);
|
||||
@ -91,8 +92,8 @@ void Url<CTYPE>::do_get_address(string* val) const {
|
||||
val->append(host_);
|
||||
if (port_ != HttpDefaultPort(secure_)) {
|
||||
CTYPE format[5], port[32];
|
||||
asccpyn(format, ARRAY_SIZE(format), ":%hu");
|
||||
sprintfn(port, ARRAY_SIZE(port), format, port_);
|
||||
asccpyn(format, arraysize(format), ":%hu");
|
||||
sprintfn(port, arraysize(port), format, port_);
|
||||
val->append(port);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/base64.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/cryptstring.h"
|
||||
@ -377,7 +378,7 @@ bool HttpDateToSeconds(const std::string& date, time_t* seconds) {
|
||||
gmt = non_gmt + ((zone[0] == '+') ? offset : -offset);
|
||||
} else {
|
||||
size_t zindex;
|
||||
if (!find_string(zindex, zone, kTimeZones, ARRAY_SIZE(kTimeZones))) {
|
||||
if (!find_string(zindex, zone, kTimeZones, arraysize(kTimeZones))) {
|
||||
return false;
|
||||
}
|
||||
gmt = non_gmt + kTimeZoneOffsets[zindex] * 60 * 60;
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/base/natsocketfactory.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/natserver.h"
|
||||
#include "webrtc/base/virtualsocketserver.h"
|
||||
@ -270,7 +271,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> {
|
||||
// Sends the destination address to the server to tell it to connect.
|
||||
void SendConnectRequest() {
|
||||
char buf[kNATEncodedIPv6AddressSize];
|
||||
size_t length = PackAddressForNAT(buf, ARRAY_SIZE(buf), remote_addr_);
|
||||
size_t length = PackAddressForNAT(buf, arraysize(buf), remote_addr_);
|
||||
socket_->Send(buf, length);
|
||||
}
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/openssl.h"
|
||||
@ -915,7 +916,7 @@ OpenSSLAdapter::SSLVerifyCallback(int ok, X509_STORE_CTX* store) {
|
||||
bool OpenSSLAdapter::ConfigureTrustedRootCertificates(SSL_CTX* ctx) {
|
||||
// Add the root cert that we care about to the SSL context
|
||||
int count_of_added_certs = 0;
|
||||
for (int i = 0; i < ARRAY_SIZE(kSSLCertCertificateList); i++) {
|
||||
for (size_t i = 0; i < arraysize(kSSLCertCertificateList); i++) {
|
||||
const unsigned char* cert_buffer = kSSLCertCertificateList[i];
|
||||
size_t cert_buffer_len = kSSLCertCertificateSizeList[i];
|
||||
X509* cert = d2i_X509(NULL, &cert_buffer,
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/byteorder.h"
|
||||
#include "webrtc/base/common.h"
|
||||
@ -628,8 +629,8 @@ class PosixSignalHandler {
|
||||
|
||||
// Returns true if the given signal number is set.
|
||||
bool IsSignalSet(int signum) const {
|
||||
ASSERT(signum < ARRAY_SIZE(received_signal_));
|
||||
if (signum < ARRAY_SIZE(received_signal_)) {
|
||||
ASSERT(signum < static_cast<int>(arraysize(received_signal_)));
|
||||
if (signum < static_cast<int>(arraysize(received_signal_))) {
|
||||
return received_signal_[signum];
|
||||
} else {
|
||||
return false;
|
||||
@ -638,8 +639,8 @@ class PosixSignalHandler {
|
||||
|
||||
// Clears the given signal number.
|
||||
void ClearSignal(int signum) {
|
||||
ASSERT(signum < ARRAY_SIZE(received_signal_));
|
||||
if (signum < ARRAY_SIZE(received_signal_)) {
|
||||
ASSERT(signum < static_cast<int>(arraysize(received_signal_)));
|
||||
if (signum < static_cast<int>(arraysize(received_signal_))) {
|
||||
received_signal_[signum] = false;
|
||||
}
|
||||
}
|
||||
@ -654,7 +655,7 @@ class PosixSignalHandler {
|
||||
// user-level state of the process, since the handler could be executed at any
|
||||
// time on any thread.
|
||||
void OnPosixSignalReceived(int signum) {
|
||||
if (signum >= ARRAY_SIZE(received_signal_)) {
|
||||
if (signum >= static_cast<int>(arraysize(received_signal_))) {
|
||||
// We don't have space in our array for this.
|
||||
return;
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
#include "webrtc/base/httpcommon.h"
|
||||
#include "webrtc/base/httpcommon-inl.h"
|
||||
@ -398,7 +399,7 @@ bool GetFirefoxProfilePath(Pathname* path) {
|
||||
}
|
||||
char buffer[NAME_MAX + 1];
|
||||
if (0 != FSRefMakePath(&fr, reinterpret_cast<uint8_t*>(buffer),
|
||||
ARRAY_SIZE(buffer))) {
|
||||
arraysize(buffer))) {
|
||||
LOG(LS_ERROR) << "FSRefMakePath failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/base/socket_unittest.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/asyncudpsocket.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/nethelpers.h"
|
||||
@ -827,7 +828,7 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) {
|
||||
// Fill the socket buffer.
|
||||
char buf[1024 * 16] = {0};
|
||||
int sends = 0;
|
||||
while (++sends && accepted->Send(&buf, ARRAY_SIZE(buf)) != -1) {}
|
||||
while (++sends && accepted->Send(&buf, arraysize(buf)) != -1) {}
|
||||
EXPECT_TRUE(accepted->IsBlocking());
|
||||
|
||||
// Wait until data is available.
|
||||
@ -835,7 +836,7 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) {
|
||||
|
||||
// Pull data.
|
||||
for (int i = 0; i < sends; ++i) {
|
||||
client->Recv(buf, ARRAY_SIZE(buf));
|
||||
client->Recv(buf, arraysize(buf));
|
||||
}
|
||||
|
||||
// Expect at least one additional writable callback.
|
||||
@ -845,7 +846,7 @@ void SocketTest::SingleFlowControlCallbackInternal(const IPAddress& loopback) {
|
||||
// callbacks.
|
||||
int extras = 0;
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
accepted->Send(&buf, ARRAY_SIZE(buf));
|
||||
accepted->Send(&buf, arraysize(buf));
|
||||
rtc::Thread::Current()->ProcessMessages(1);
|
||||
if (sink.Check(accepted.get(), testing::SSE_WRITE)) {
|
||||
extras++;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
@ -48,7 +49,7 @@ TEST(Utf8EncodeTest, EncodeDecode) {
|
||||
}
|
||||
|
||||
char buffer[5];
|
||||
memset(buffer, 0x01, ARRAY_SIZE(buffer));
|
||||
memset(buffer, 0x01, arraysize(buffer));
|
||||
ASSERT_EQ(kTests[i].enclen, utf8_encode(buffer,
|
||||
kTests[i].encsize,
|
||||
kTests[i].decoded));
|
||||
@ -56,7 +57,7 @@ TEST(Utf8EncodeTest, EncodeDecode) {
|
||||
// Make sure remainder of buffer is unchanged
|
||||
ASSERT_TRUE(memory_check(buffer + kTests[i].enclen,
|
||||
0x1,
|
||||
ARRAY_SIZE(buffer) - kTests[i].enclen));
|
||||
arraysize(buffer) - kTests[i].enclen));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "webrtc/base/win32.h"
|
||||
#endif // WEBRTC_WIN
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -408,7 +409,7 @@ TEST(start_task_test, AbortShouldWake) {
|
||||
class TimeoutChangeTest : public sigslot::has_slots<> {
|
||||
public:
|
||||
TimeoutChangeTest()
|
||||
: task_count_(ARRAY_SIZE(stuck_tasks_)) {}
|
||||
: task_count_(arraysize(stuck_tasks_)) {}
|
||||
|
||||
// no need to delete any tasks; the task runner owns them
|
||||
~TimeoutChangeTest() {}
|
||||
@ -463,7 +464,7 @@ class TimeoutChangeTest : public sigslot::has_slots<> {
|
||||
|
||||
private:
|
||||
void OnTimeoutId(const int id) {
|
||||
for (int i = 0; i < ARRAY_SIZE(stuck_tasks_); ++i) {
|
||||
for (size_t i = 0; i < arraysize(stuck_tasks_); ++i) {
|
||||
if (stuck_tasks_[i] && stuck_tasks_[i]->unique_id() == id) {
|
||||
task_count_--;
|
||||
stuck_tasks_[i] = NULL;
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/asyncsocket.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
@ -357,7 +358,7 @@ private:
|
||||
}
|
||||
void OnReadEvent(AsyncSocket* socket) {
|
||||
char data[64 * 1024];
|
||||
int result = socket_->Recv(data, ARRAY_SIZE(data));
|
||||
int result = socket_->Recv(data, arraysize(data));
|
||||
if (result > 0) {
|
||||
recv_buffer_.insert(recv_buffer_.end(), data, data + result);
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
#include <sys/syslimits.h>
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
#include "webrtc/base/pathutils.h"
|
||||
#include "webrtc/base/stream.h"
|
||||
@ -176,7 +177,7 @@ bool UnixFilesystem::GetTemporaryFolder(Pathname &pathname, bool create,
|
||||
kCreateFolder, &fr))
|
||||
return false;
|
||||
unsigned char buffer[NAME_MAX+1];
|
||||
if (0 != FSRefMakePath(&fr, buffer, ARRAY_SIZE(buffer)))
|
||||
if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer)))
|
||||
return false;
|
||||
pathname.SetPathname(reinterpret_cast<char*>(buffer), "");
|
||||
#elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
||||
@ -303,7 +304,7 @@ bool UnixFilesystem::IsTemporaryPath(const Pathname& pathname) {
|
||||
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
||||
#endif // WEBRTC_ANDROID || WEBRTC_IOS
|
||||
};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(kTempPrefixes); ++i) {
|
||||
for (size_t i = 0; i < arraysize(kTempPrefixes); ++i) {
|
||||
if (0 == strncmp(pathname.pathname().c_str(), kTempPrefixes[i],
|
||||
strlen(kTempPrefixes[i])))
|
||||
return true;
|
||||
@ -377,7 +378,7 @@ bool UnixFilesystem::GetAppPathname(Pathname* path) {
|
||||
return true;
|
||||
#else // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
||||
char buffer[PATH_MAX + 2];
|
||||
ssize_t len = readlink("/proc/self/exe", buffer, ARRAY_SIZE(buffer) - 1);
|
||||
ssize_t len = readlink("/proc/self/exe", buffer, arraysize(buffer) - 1);
|
||||
if ((len <= 0) || (len == PATH_MAX + 1))
|
||||
return false;
|
||||
buffer[len] = '\0';
|
||||
@ -399,7 +400,7 @@ bool UnixFilesystem::GetAppDataFolder(Pathname* path, bool per_user) {
|
||||
kCreateFolder, &fr))
|
||||
return false;
|
||||
unsigned char buffer[NAME_MAX+1];
|
||||
if (0 != FSRefMakePath(&fr, buffer, ARRAY_SIZE(buffer)))
|
||||
if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer)))
|
||||
return false;
|
||||
path->SetPathname(reinterpret_cast<char*>(buffer), "");
|
||||
} else {
|
||||
@ -487,7 +488,7 @@ bool UnixFilesystem::GetAppTempFolder(Pathname* path) {
|
||||
|
||||
// Create a random directory as /tmp/<appname>-<pid>-<timestamp>
|
||||
char buffer[128];
|
||||
sprintfn(buffer, ARRAY_SIZE(buffer), "-%d-%d",
|
||||
sprintfn(buffer, arraysize(buffer), "-%d-%d",
|
||||
static_cast<int>(getpid()),
|
||||
static_cast<int>(time(0)));
|
||||
std::string folder(application_name_);
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
@ -19,7 +20,7 @@ TEST(Urlencode, SourceTooLong) {
|
||||
char source[] = "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
|
||||
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
|
||||
char dest[1];
|
||||
ASSERT_EQ(0, UrlEncode(source, dest, ARRAY_SIZE(dest)));
|
||||
ASSERT_EQ(0, UrlEncode(source, dest, arraysize(dest)));
|
||||
ASSERT_EQ('\0', dest[0]);
|
||||
|
||||
dest[0] = 'a';
|
||||
@ -30,7 +31,7 @@ TEST(Urlencode, SourceTooLong) {
|
||||
TEST(Urlencode, OneCharacterConversion) {
|
||||
char source[] = "^";
|
||||
char dest[4];
|
||||
ASSERT_EQ(3, UrlEncode(source, dest, ARRAY_SIZE(dest)));
|
||||
ASSERT_EQ(3, UrlEncode(source, dest, arraysize(dest)));
|
||||
ASSERT_STREQ("%5E", dest);
|
||||
}
|
||||
|
||||
@ -40,7 +41,7 @@ TEST(Urlencode, ShortDestinationNoEncoding) {
|
||||
// hold the text given.
|
||||
char source[] = "aa";
|
||||
char dest[3];
|
||||
ASSERT_EQ(2, UrlEncode(source, dest, ARRAY_SIZE(dest)));
|
||||
ASSERT_EQ(2, UrlEncode(source, dest, arraysize(dest)));
|
||||
ASSERT_STREQ("aa", dest);
|
||||
}
|
||||
|
||||
@ -49,14 +50,14 @@ TEST(Urlencode, ShortDestinationEncoding) {
|
||||
// big enough to hold the encoding.
|
||||
char source[] = "&";
|
||||
char dest[3];
|
||||
ASSERT_EQ(0, UrlEncode(source, dest, ARRAY_SIZE(dest)));
|
||||
ASSERT_EQ(0, UrlEncode(source, dest, arraysize(dest)));
|
||||
ASSERT_EQ('\0', dest[0]);
|
||||
}
|
||||
|
||||
TEST(Urlencode, Encoding1) {
|
||||
char source[] = "A^ ";
|
||||
char dest[8];
|
||||
ASSERT_EQ(5, UrlEncode(source, dest, ARRAY_SIZE(dest)));
|
||||
ASSERT_EQ(5, UrlEncode(source, dest, arraysize(dest)));
|
||||
ASSERT_STREQ("A%5E+", dest);
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@ TEST(Urlencode, Encoding2) {
|
||||
char source[] = "A^ ";
|
||||
char dest[8];
|
||||
ASSERT_EQ(7, rtc::UrlEncodeWithoutEncodingSpaceAsPlus(source, dest,
|
||||
ARRAY_SIZE(dest)));
|
||||
arraysize(dest)));
|
||||
ASSERT_STREQ("A%5E%20", dest);
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/testclient.h"
|
||||
@ -1022,9 +1023,9 @@ TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) {
|
||||
const double kTestDev[] = { 0.25, 0.1, 0.01 };
|
||||
// TODO: The current code only works for 1000 data points or more.
|
||||
const uint32_t kTestSamples[] = {/*10, 100,*/ 1000};
|
||||
for (size_t midx = 0; midx < ARRAY_SIZE(kTestMean); ++midx) {
|
||||
for (size_t didx = 0; didx < ARRAY_SIZE(kTestDev); ++didx) {
|
||||
for (size_t sidx = 0; sidx < ARRAY_SIZE(kTestSamples); ++sidx) {
|
||||
for (size_t midx = 0; midx < arraysize(kTestMean); ++midx) {
|
||||
for (size_t didx = 0; didx < arraysize(kTestDev); ++didx) {
|
||||
for (size_t sidx = 0; sidx < arraysize(kTestSamples); ++sidx) {
|
||||
ASSERT_LT(0u, kTestSamples[sidx]);
|
||||
const uint32_t kStdDev =
|
||||
static_cast<uint32_t>(kTestDev[didx] * kTestMean[midx]);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <ws2tcpip.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/byteorder.h"
|
||||
#include "webrtc/base/common.h"
|
||||
@ -87,7 +88,7 @@ const char* inet_ntop_v6(const void* src, char* dst, socklen_t size) {
|
||||
int current = 1;
|
||||
int max = 0;
|
||||
int maxpos = -1;
|
||||
int run_array_size = ARRAY_SIZE(runpos);
|
||||
int run_array_size = arraysize(runpos);
|
||||
// Run over the address marking runs of 0s.
|
||||
for (int i = 0; i < run_array_size; ++i) {
|
||||
if (as_shorts[i] == 0) {
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <shlobj.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/fileutils.h"
|
||||
#include "webrtc/base/pathutils.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
@ -197,16 +198,16 @@ bool Win32Filesystem::DeleteEmptyFolder(const Pathname &folder) {
|
||||
bool Win32Filesystem::GetTemporaryFolder(Pathname &pathname, bool create,
|
||||
const std::string *append) {
|
||||
wchar_t buffer[MAX_PATH + 1];
|
||||
if (!::GetTempPath(ARRAY_SIZE(buffer), buffer))
|
||||
if (!::GetTempPath(arraysize(buffer), buffer))
|
||||
return false;
|
||||
if (!IsCurrentProcessLowIntegrity() &&
|
||||
!::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
|
||||
!::GetLongPathName(buffer, buffer, arraysize(buffer)))
|
||||
return false;
|
||||
size_t len = strlen(buffer);
|
||||
if ((len > 0) && (buffer[len-1] != '\\')) {
|
||||
len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, L"\\");
|
||||
len += strcpyn(buffer + len, arraysize(buffer) - len, L"\\");
|
||||
}
|
||||
if (len >= ARRAY_SIZE(buffer) - 1)
|
||||
if (len >= arraysize(buffer) - 1)
|
||||
return false;
|
||||
pathname.clear();
|
||||
pathname.SetFolder(ToUtf8(buffer));
|
||||
@ -295,10 +296,10 @@ bool Win32Filesystem::CopyFile(const Pathname &old_path,
|
||||
|
||||
bool Win32Filesystem::IsTemporaryPath(const Pathname& pathname) {
|
||||
TCHAR buffer[MAX_PATH + 1];
|
||||
if (!::GetTempPath(ARRAY_SIZE(buffer), buffer))
|
||||
if (!::GetTempPath(arraysize(buffer), buffer))
|
||||
return false;
|
||||
if (!IsCurrentProcessLowIntegrity() &&
|
||||
!::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
|
||||
!::GetLongPathName(buffer, buffer, arraysize(buffer)))
|
||||
return false;
|
||||
return (::strnicmp(ToUtf16(pathname.pathname()).c_str(),
|
||||
buffer, strlen(buffer)) == 0);
|
||||
@ -337,7 +338,7 @@ bool Win32Filesystem::GetFileTime(const Pathname& path, FileTimeType which,
|
||||
|
||||
bool Win32Filesystem::GetAppPathname(Pathname* path) {
|
||||
TCHAR buffer[MAX_PATH + 1];
|
||||
if (0 == ::GetModuleFileName(NULL, buffer, ARRAY_SIZE(buffer)))
|
||||
if (0 == ::GetModuleFileName(NULL, buffer, arraysize(buffer)))
|
||||
return false;
|
||||
path->SetPathname(ToUtf8(buffer));
|
||||
return true;
|
||||
@ -351,20 +352,20 @@ bool Win32Filesystem::GetAppDataFolder(Pathname* path, bool per_user) {
|
||||
if (!::SHGetSpecialFolderPath(NULL, buffer, csidl, TRUE))
|
||||
return false;
|
||||
if (!IsCurrentProcessLowIntegrity() &&
|
||||
!::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
|
||||
!::GetLongPathName(buffer, buffer, arraysize(buffer)))
|
||||
return false;
|
||||
size_t len = strcatn(buffer, ARRAY_SIZE(buffer), __T("\\"));
|
||||
len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len,
|
||||
size_t len = strcatn(buffer, arraysize(buffer), __T("\\"));
|
||||
len += strcpyn(buffer + len, arraysize(buffer) - len,
|
||||
ToUtf16(organization_name_).c_str());
|
||||
if ((len > 0) && (buffer[len-1] != __T('\\'))) {
|
||||
len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, __T("\\"));
|
||||
len += strcpyn(buffer + len, arraysize(buffer) - len, __T("\\"));
|
||||
}
|
||||
len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len,
|
||||
len += strcpyn(buffer + len, arraysize(buffer) - len,
|
||||
ToUtf16(application_name_).c_str());
|
||||
if ((len > 0) && (buffer[len-1] != __T('\\'))) {
|
||||
len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, __T("\\"));
|
||||
len += strcpyn(buffer + len, arraysize(buffer) - len, __T("\\"));
|
||||
}
|
||||
if (len >= ARRAY_SIZE(buffer) - 1)
|
||||
if (len >= arraysize(buffer) - 1)
|
||||
return false;
|
||||
path->clear();
|
||||
path->SetFolder(ToUtf8(buffer));
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
// Unittest for registry access API
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/win32regkey.h"
|
||||
@ -564,8 +565,8 @@ void RegKeyStaticFunctionsTest() {
|
||||
#ifdef IS_PRIVATE_BUILD
|
||||
// get a temp file name
|
||||
wchar_t temp_path[MAX_PATH] = {0};
|
||||
EXPECT_LT(::GetTempPath(ARRAY_SIZE(temp_path), temp_path),
|
||||
static_cast<DWORD>(ARRAY_SIZE(temp_path)));
|
||||
EXPECT_LT(::GetTempPath(arraysize(temp_path), temp_path),
|
||||
static_cast<DWORD>(arraysize(temp_path)));
|
||||
wchar_t temp_file[MAX_PATH] = {0};
|
||||
EXPECT_NE(::GetTempFileName(temp_path, L"rkut_",
|
||||
::GetTickCount(), temp_file), 0);
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
@ -58,7 +59,7 @@ BOOL CALLBACK Win32WindowPicker::EnumProc(HWND hwnd, LPARAM l_param) {
|
||||
}
|
||||
|
||||
TCHAR window_title[500];
|
||||
GetWindowText(hwnd, window_title, ARRAY_SIZE(window_title));
|
||||
GetWindowText(hwnd, window_title, arraysize(window_title));
|
||||
std::string title = ToUtf8(window_title);
|
||||
|
||||
WindowId id(hwnd);
|
||||
|
||||
@ -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 "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -71,7 +72,7 @@ TEST(Win32WindowPickerTest, TestGetWindowList) {
|
||||
EXPECT_EQ(window_picker.visible_window()->handle(), desc.id().id());
|
||||
TCHAR window_title[500];
|
||||
GetWindowText(window_picker.visible_window()->handle(), window_title,
|
||||
ARRAY_SIZE(window_title));
|
||||
arraysize(window_title));
|
||||
EXPECT_EQ(0, wcscmp(window_title, kVisibleWindowTitle));
|
||||
}
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
|
||||
const char kAudioLabel[] = "audio_label";
|
||||
@ -49,7 +50,7 @@ std::string GetDefaultServerName() {
|
||||
|
||||
std::string GetPeerName() {
|
||||
char computer_name[256];
|
||||
if (gethostname(computer_name, ARRAY_SIZE(computer_name)) != 0)
|
||||
if (gethostname(computer_name, arraysize(computer_name)) != 0)
|
||||
strcpy(computer_name, "host");
|
||||
std::string ret(GetEnvVarOrDefault("USERNAME", "user"));
|
||||
ret += '@';
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "webrtc/examples/peerconnection/client/defaults.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
@ -241,7 +242,7 @@ void MainWnd::OnPaint() {
|
||||
|
||||
// Set the map mode so that the ratio will be maintained for us.
|
||||
HDC all_dc[] = { ps.hdc, dc_mem };
|
||||
for (int i = 0; i < ARRAY_SIZE(all_dc); ++i) {
|
||||
for (int i = 0; i < arraysize(all_dc); ++i) {
|
||||
SetMapMode(all_dc[i], MM_ISOTROPIC);
|
||||
SetWindowExtEx(all_dc[i], width, height, NULL);
|
||||
SetViewportExtEx(all_dc[i], rc.right, rc.bottom, NULL);
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include "webrtc/libjingle/xmpp/chatroommodule.h"
|
||||
#include "webrtc/libjingle/xmpp/constants.h"
|
||||
#include "webrtc/libjingle/xmpp/moduleimpl.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
|
||||
namespace buzz {
|
||||
@ -535,7 +536,7 @@ XmppChatroomModuleImpl::ChangePresence(XmppChatroomState new_state,
|
||||
|
||||
// find the right transition description
|
||||
StateTransitionDescription* transition_desc = NULL;
|
||||
for (int i=0; i < ARRAY_SIZE(Transitions); i++) {
|
||||
for (size_t i = 0; i < arraysize(Transitions); i++) {
|
||||
if (Transitions[i].old_state == old_state &&
|
||||
Transitions[i].new_state == new_state) {
|
||||
transition_desc = &Transitions[i];
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include "webrtc/libjingle/xmpp/constants.h"
|
||||
#include "webrtc/libjingle/xmpp/presenceouttask.h"
|
||||
#include "webrtc/libjingle/xmpp/xmppclient.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
|
||||
namespace buzz {
|
||||
@ -128,7 +129,7 @@ PresenceOutTask::TranslateStatus(const PresenceStatus & s) {
|
||||
time(¤t_time_seconds);
|
||||
struct tm* current_time = gmtime(¤t_time_seconds);
|
||||
char output[256];
|
||||
strftime(output, ARRAY_SIZE(output), "%Y%m%dT%H:%M:%S", current_time);
|
||||
strftime(output, arraysize(output), "%Y%m%dT%H:%M:%S", current_time);
|
||||
result->AddAttr(kQnStamp, output, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
@ -662,7 +663,7 @@ void BweTest::RunSelfFairness(BandwidthEstimatorType bwe_type) {
|
||||
void BweTest::RunRoundTripTimeFairness(BandwidthEstimatorType bwe_type) {
|
||||
const int kAllFlowIds[] = {0, 1, 2, 3, 4}; // Five RMCAT flows.
|
||||
const int64_t kAllOneWayDelayMs[] = {10, 25, 50, 100, 150};
|
||||
const size_t kNumFlows = ARRAY_SIZE(kAllFlowIds);
|
||||
const size_t kNumFlows = arraysize(kAllFlowIds);
|
||||
rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumFlows];
|
||||
rtc::scoped_ptr<VideoSender> senders[kNumFlows];
|
||||
rtc::scoped_ptr<MetricRecorder> metric_recorders[kNumFlows];
|
||||
@ -774,10 +775,10 @@ void BweTest::RunMultipleShortTcpFairness(
|
||||
const int kAllTcpFlowIds[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
|
||||
|
||||
assert(tcp_starting_times_ms.size() == tcp_file_sizes_bytes.size() &&
|
||||
tcp_starting_times_ms.size() == ARRAY_SIZE(kAllTcpFlowIds));
|
||||
tcp_starting_times_ms.size() == arraysize(kAllTcpFlowIds));
|
||||
|
||||
const size_t kNumRmcatFlows = ARRAY_SIZE(kAllRmcatFlowIds);
|
||||
const size_t kNumTotalFlows = kNumRmcatFlows + ARRAY_SIZE(kAllTcpFlowIds);
|
||||
const size_t kNumRmcatFlows = arraysize(kAllRmcatFlowIds);
|
||||
const size_t kNumTotalFlows = kNumRmcatFlows + arraysize(kAllTcpFlowIds);
|
||||
|
||||
rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumRmcatFlows];
|
||||
rtc::scoped_ptr<PacketSender> senders[kNumTotalFlows];
|
||||
@ -869,7 +870,7 @@ void BweTest::RunMultipleShortTcpFairness(
|
||||
// During the test, one of the flows is paused and later resumed.
|
||||
void BweTest::RunPauseResumeFlows(BandwidthEstimatorType bwe_type) {
|
||||
const int kAllFlowIds[] = {0, 1, 2}; // Three RMCAT flows.
|
||||
const size_t kNumFlows = ARRAY_SIZE(kAllFlowIds);
|
||||
const size_t kNumFlows = arraysize(kAllFlowIds);
|
||||
|
||||
rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumFlows];
|
||||
rtc::scoped_ptr<VideoSender> senders[kNumFlows];
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace testing {
|
||||
@ -241,7 +242,7 @@ TEST_F(BweReceiverTest, PacketLossDuplicatedPackets) {
|
||||
|
||||
// Missing the element 5.
|
||||
const uint16_t kSequenceNumbers[] = {1, 2, 3, 4, 6, 7, 8};
|
||||
const int kNumPackets = ARRAY_SIZE(kSequenceNumbers);
|
||||
const int kNumPackets = arraysize(kSequenceNumbers);
|
||||
|
||||
// Insert each sequence number twice.
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h"
|
||||
@ -63,7 +64,7 @@ void NadaBweReceiver::ReceivePacket(int64_t arrival_time_ms,
|
||||
}
|
||||
|
||||
delay_signal_ms_ = delay_ms - baseline_delay_ms_; // Refered as d_n.
|
||||
const int kMedian = ARRAY_SIZE(last_delays_ms_);
|
||||
const int kMedian = arraysize(last_delays_ms_);
|
||||
last_delays_ms_[(last_delays_index_++) % kMedian] = delay_signal_ms_;
|
||||
int size = std::min(last_delays_index_, kMedian);
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h"
|
||||
@ -357,7 +358,7 @@ TEST_F(NadaReceiverSideTest, FeedbackIncreasingDelay) {
|
||||
// Baseline delay will be 50 ms.
|
||||
// Delay signals should be: [0 10 20 30 40 50 60 70] ms.
|
||||
const int64_t kMedianFilteredDelaysMs[] = {0, 5, 10, 15, 20, 30, 40, 50};
|
||||
const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs);
|
||||
const int kNumPackets = arraysize(kMedianFilteredDelaysMs);
|
||||
const float kAlpha = 0.1f; // Used for exponential smoothing.
|
||||
|
||||
int64_t exp_smoothed_delays_ms[kNumPackets];
|
||||
@ -426,7 +427,7 @@ TEST_F(NadaReceiverSideTest, FeedbackWarpedDelay) {
|
||||
// Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms.
|
||||
const int64_t kMedianFilteredDelaysMs[] = {
|
||||
0, 100, 200, 300, 400, 600, 800, 1000};
|
||||
const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs);
|
||||
const int kNumPackets = arraysize(kMedianFilteredDelaysMs);
|
||||
const float kAlpha = 0.1f; // Used for exponential smoothing.
|
||||
|
||||
int64_t exp_smoothed_delays_ms[kNumPackets];
|
||||
@ -480,7 +481,7 @@ TEST_F(FilterTest, ExponentialSmoothingConstantArray) {
|
||||
|
||||
TEST_F(FilterTest, ExponentialSmoothingInitialPertubation) {
|
||||
const int64_t kSignal[] = {90000, 0, 0, 0, 0, 0};
|
||||
const int kNumElements = ARRAY_SIZE(kSignal);
|
||||
const int kNumElements = arraysize(kSignal);
|
||||
int64_t exp_smoothed[kNumElements];
|
||||
ExponentialSmoothingFilter(kSignal, kNumElements, exp_smoothed);
|
||||
for (int i = 1; i < kNumElements; ++i) {
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/bitbuffer.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -121,7 +122,7 @@ TEST(H264SpsParserTest, TestSampleSPSHdLandscape) {
|
||||
const uint8_t buffer[] = {0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05,
|
||||
0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00,
|
||||
0x00, 0x2A, 0xE0, 0xF1, 0x83, 0x19, 0x60};
|
||||
H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
|
||||
H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
|
||||
EXPECT_TRUE(parser.Parse());
|
||||
EXPECT_EQ(1280u, parser.width());
|
||||
EXPECT_EQ(720u, parser.height());
|
||||
@ -133,7 +134,7 @@ TEST(H264SpsParserTest, TestSampleSPSVgaLandscape) {
|
||||
const uint8_t buffer[] = {0x7A, 0x00, 0x1E, 0xBC, 0xD9, 0x40, 0xA0, 0x2F,
|
||||
0xF8, 0x98, 0x40, 0x00, 0x00, 0x03, 0x01, 0x80,
|
||||
0x00, 0x00, 0x56, 0x83, 0xC5, 0x8B, 0x65, 0x80};
|
||||
H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
|
||||
H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
|
||||
EXPECT_TRUE(parser.Parse());
|
||||
EXPECT_EQ(640u, parser.width());
|
||||
EXPECT_EQ(360u, parser.height());
|
||||
@ -145,7 +146,7 @@ TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) {
|
||||
const uint8_t buffer[] = {0x7A, 0x00, 0x0D, 0xBC, 0xD9, 0x43, 0x43, 0x3E,
|
||||
0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00,
|
||||
0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60};
|
||||
H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
|
||||
H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
|
||||
EXPECT_TRUE(parser.Parse());
|
||||
EXPECT_EQ(200u, parser.width());
|
||||
EXPECT_EQ(400u, parser.height());
|
||||
@ -154,7 +155,7 @@ TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) {
|
||||
TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) {
|
||||
uint8_t buffer[kSpsBufferMaxSize] = {0};
|
||||
GenerateFakeSps(320u, 180u, buffer);
|
||||
H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
|
||||
H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
|
||||
EXPECT_TRUE(parser.Parse());
|
||||
EXPECT_EQ(320u, parser.width());
|
||||
EXPECT_EQ(180u, parser.height());
|
||||
@ -163,7 +164,7 @@ TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) {
|
||||
TEST(H264SpsParserTest, TestSyntheticSPSWeirdResolution) {
|
||||
uint8_t buffer[kSpsBufferMaxSize] = {0};
|
||||
GenerateFakeSps(156u, 122u, buffer);
|
||||
H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
|
||||
H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
|
||||
EXPECT_TRUE(parser.Parse());
|
||||
EXPECT_EQ(156u, parser.width());
|
||||
EXPECT_EQ(122u, parser.height());
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include "webrtc/p2p/base/testturnserver.h"
|
||||
#include "webrtc/p2p/base/transport.h"
|
||||
#include "webrtc/p2p/base/turnport.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/crc32.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/helpers.h"
|
||||
@ -2223,7 +2224,7 @@ TEST_F(PortTest, TestWritableState) {
|
||||
|
||||
// Data should be unsendable until the connection is accepted.
|
||||
char data[] = "abcd";
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int data_size = arraysize(data);
|
||||
rtc::PacketOptions options;
|
||||
EXPECT_EQ(SOCKET_ERROR, ch1.conn()->Send(data, data_size, options));
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/bytebuffer.h"
|
||||
#include "webrtc/base/byteorder.h"
|
||||
@ -187,7 +188,7 @@ void ReportStats() {
|
||||
char buffer[256];
|
||||
size_t len = 0;
|
||||
for (int i = 0; i < S_NUM_STATS; ++i) {
|
||||
len += rtc::sprintfn(buffer, ARRAY_SIZE(buffer), "%s%s:%d",
|
||||
len += rtc::sprintfn(buffer, arraysize(buffer), "%s%s:%d",
|
||||
(i == 0) ? "" : ",", STAT_NAMES[i], g_stats[i]);
|
||||
g_stats[i] = 0;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/p2p/base/stun.h"
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/bytebuffer.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
@ -515,11 +516,11 @@ TEST_F(StunTest, MessageTypes) {
|
||||
STUN_BINDING_REQUEST, STUN_BINDING_INDICATION,
|
||||
STUN_BINDING_RESPONSE, STUN_BINDING_ERROR_RESPONSE
|
||||
};
|
||||
for (int i = 0; i < ARRAY_SIZE(types); ++i) {
|
||||
EXPECT_EQ(i == 0, IsStunRequestType(types[i]));
|
||||
EXPECT_EQ(i == 1, IsStunIndicationType(types[i]));
|
||||
EXPECT_EQ(i == 2, IsStunSuccessResponseType(types[i]));
|
||||
EXPECT_EQ(i == 3, IsStunErrorResponseType(types[i]));
|
||||
for (size_t i = 0; i < arraysize(types); ++i) {
|
||||
EXPECT_EQ(i == 0U, IsStunRequestType(types[i]));
|
||||
EXPECT_EQ(i == 1U, IsStunIndicationType(types[i]));
|
||||
EXPECT_EQ(i == 2U, IsStunSuccessResponseType(types[i]));
|
||||
EXPECT_EQ(i == 3U, IsStunErrorResponseType(types[i]));
|
||||
EXPECT_EQ(1, types[i] & 0xFEEF);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/p2p/base/transportdescription.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/basicdefs.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/p2p/base/constants.h"
|
||||
@ -24,7 +25,7 @@ bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role) {
|
||||
CONNECTIONROLE_HOLDCONN_STR
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(roles); ++i) {
|
||||
for (size_t i = 0; i < arraysize(roles); ++i) {
|
||||
if (_stricmp(roles[i], role_str.c_str()) == 0) {
|
||||
*role = static_cast<ConnectionRole>(CONNECTIONROLE_ACTIVE + i);
|
||||
return true;
|
||||
|
||||
@ -11,15 +11,17 @@
|
||||
#include "webrtc/sound/alsasoundsystem.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/sound/sounddevicelocator.h"
|
||||
#include "webrtc/sound/soundinputstreaminterface.h"
|
||||
#include "webrtc/sound/soundoutputstreaminterface.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/stringutils.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/base/worker.h"
|
||||
#include "webrtc/sound/sounddevicelocator.h"
|
||||
#include "webrtc/sound/soundinputstreaminterface.h"
|
||||
#include "webrtc/sound/soundoutputstreaminterface.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -606,8 +608,6 @@ bool AlsaSoundSystem::GetDefaultDevice(SoundDeviceLocator **device) {
|
||||
}
|
||||
|
||||
inline size_t AlsaSoundSystem::FrameSize(const OpenParams ¶ms) {
|
||||
ASSERT(static_cast<int>(params.format) <
|
||||
ARRAY_SIZE(kCricketFormatToSampleSizeTable));
|
||||
return kCricketFormatToSampleSizeTable[params.format] * params.channels;
|
||||
}
|
||||
|
||||
@ -662,8 +662,7 @@ StreamInterface *AlsaSoundSystem::OpenDevice(
|
||||
latency = std::max(latency, kMinimumLatencyUsecs);
|
||||
}
|
||||
|
||||
ASSERT(static_cast<int>(params.format) <
|
||||
ARRAY_SIZE(kCricketFormatToAlsaFormatTable));
|
||||
ASSERT(params.format < arraysize(kCricketFormatToAlsaFormatTable));
|
||||
|
||||
err = symbol_table_.snd_pcm_set_params()(
|
||||
handle,
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
*/
|
||||
|
||||
#include "webrtc/sound/automaticallychosensoundsystem.h"
|
||||
#include "webrtc/sound/nullsoundsystem.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/sound/nullsoundsystem.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -112,7 +114,7 @@ extern const SoundSystemCreator kSingleSystemFailingCreators[] = {
|
||||
TEST(AutomaticallyChosenSoundSystem, SingleSystemFailing) {
|
||||
AutomaticallyChosenSoundSystem<
|
||||
kSingleSystemFailingCreators,
|
||||
ARRAY_SIZE(kSingleSystemFailingCreators)> sound_system;
|
||||
arraysize(kSingleSystemFailingCreators)> sound_system;
|
||||
EXPECT_FALSE(sound_system.Init());
|
||||
}
|
||||
|
||||
@ -123,7 +125,7 @@ extern const SoundSystemCreator kSingleSystemSucceedingCreators[] = {
|
||||
TEST(AutomaticallyChosenSoundSystem, SingleSystemSucceeding) {
|
||||
AutomaticallyChosenSoundSystem<
|
||||
kSingleSystemSucceedingCreators,
|
||||
ARRAY_SIZE(kSingleSystemSucceedingCreators)> sound_system;
|
||||
arraysize(kSingleSystemSucceedingCreators)> sound_system;
|
||||
EXPECT_TRUE(sound_system.Init());
|
||||
}
|
||||
|
||||
@ -136,7 +138,7 @@ extern const SoundSystemCreator
|
||||
TEST(AutomaticallyChosenSoundSystem, FailedFirstSystemResultsInUsingSecond) {
|
||||
AutomaticallyChosenSoundSystem<
|
||||
kFailedFirstSystemResultsInUsingSecondCreators,
|
||||
ARRAY_SIZE(kFailedFirstSystemResultsInUsingSecondCreators)> sound_system;
|
||||
arraysize(kFailedFirstSystemResultsInUsingSecondCreators)> sound_system;
|
||||
EXPECT_TRUE(sound_system.Init());
|
||||
}
|
||||
|
||||
@ -148,7 +150,7 @@ extern const SoundSystemCreator kEarlierEntriesHavePriorityCreators[] = {
|
||||
TEST(AutomaticallyChosenSoundSystem, EarlierEntriesHavePriority) {
|
||||
AutomaticallyChosenSoundSystem<
|
||||
kEarlierEntriesHavePriorityCreators,
|
||||
ARRAY_SIZE(kEarlierEntriesHavePriorityCreators)> sound_system;
|
||||
arraysize(kEarlierEntriesHavePriorityCreators)> sound_system;
|
||||
InitCheckingSoundSystem1::created_ = false;
|
||||
InitCheckingSoundSystem2::created_ = false;
|
||||
EXPECT_TRUE(sound_system.Init());
|
||||
@ -169,7 +171,7 @@ extern const SoundSystemCreator kManySoundSystemsCreators[] = {
|
||||
TEST(AutomaticallyChosenSoundSystem, ManySoundSystems) {
|
||||
AutomaticallyChosenSoundSystem<
|
||||
kManySoundSystemsCreators,
|
||||
ARRAY_SIZE(kManySoundSystemsCreators)> sound_system;
|
||||
arraysize(kManySoundSystemsCreators)> sound_system;
|
||||
EXPECT_TRUE(sound_system.Init());
|
||||
}
|
||||
|
||||
@ -182,7 +184,7 @@ extern const SoundSystemCreator kDeletesAllCreatedSoundSystemsCreators[] = {
|
||||
TEST(AutomaticallyChosenSoundSystem, DeletesAllCreatedSoundSystems) {
|
||||
typedef AutomaticallyChosenSoundSystem<
|
||||
kDeletesAllCreatedSoundSystemsCreators,
|
||||
ARRAY_SIZE(kDeletesAllCreatedSoundSystemsCreators)> TestSoundSystem;
|
||||
arraysize(kDeletesAllCreatedSoundSystemsCreators)> TestSoundSystem;
|
||||
TestSoundSystem *sound_system = new TestSoundSystem();
|
||||
DeletionCheckingSoundSystem1::deleted_ = false;
|
||||
DeletionCheckingSoundSystem2::deleted_ = false;
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#ifndef WEBRTC_SOUND_LINUXSOUNDSYSTEM_H_
|
||||
#define WEBRTC_SOUND_LINUXSOUNDSYSTEM_H_
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/sound/automaticallychosensoundsystem.h"
|
||||
|
||||
namespace rtc {
|
||||
@ -34,7 +35,7 @@ extern const SoundSystemCreator kLinuxSoundSystemCreators[
|
||||
// initializes then we choose that. Otherwise we choose ALSA.
|
||||
typedef AutomaticallyChosenSoundSystem<
|
||||
kLinuxSoundSystemCreators,
|
||||
ARRAY_SIZE(kLinuxSoundSystemCreators)> LinuxSoundSystem;
|
||||
arraysize(kLinuxSoundSystemCreators)> LinuxSoundSystem;
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
|
||||
@ -13,14 +13,16 @@
|
||||
#ifdef HAVE_LIBPULSE
|
||||
|
||||
#include <algorithm>
|
||||
#include "webrtc/sound/sounddevicelocator.h"
|
||||
#include "webrtc/sound/soundinputstreaminterface.h"
|
||||
#include "webrtc/sound/soundoutputstreaminterface.h"
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/fileutils.h" // for GetApplicationName()
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/base/worker.h"
|
||||
#include "webrtc/sound/sounddevicelocator.h"
|
||||
#include "webrtc/sound/soundinputstreaminterface.h"
|
||||
#include "webrtc/sound/soundoutputstreaminterface.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -1373,7 +1375,7 @@ StreamInterface *PulseAudioSoundSystem::OpenDevice(
|
||||
|
||||
StreamInterface *stream_interface = NULL;
|
||||
|
||||
ASSERT(params.format < ARRAY_SIZE(kCricketFormatToPulseFormatTable));
|
||||
ASSERT(params.format < arraysize(kCricketFormatToPulseFormatTable));
|
||||
|
||||
pa_sample_spec spec;
|
||||
spec.format = kCricketFormatToPulseFormatTable[params.format];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user