Unverified 提交 3bdad193 authored 作者: José Luis Millán's avatar José Luis Millán 提交者: GitHub

Worker: More const correctness and qualified auto enhancements (#1006)

上级 f02edc62
---
Checks: '*,-llvmlibc-*,-boost-use-to-string,-cert-*,-clang-analyzer-osx.*,-clang-analyzer-optin.osx.*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-special-member-functions,-google-readability-*,-llvm-include-order,-readability-else-after-return,-readability-implicit-bool-cast,-modernize-pass-by-value,-cppcoreguidelines-no-malloc,-modernize-make-unique,-google-default-arguments,-hicpp-uppercase-literal-suffix,-readability-uppercase-literal-suffix,-hicpp-braces-around-statements,-hicpp-vararg,-hicpp-no-array-decay,-cppcoreguidelines-avoid-c-arrays,-hicpp-avoid-c-arrays,-modernize-avoid-c-arrays,-fuchsia-default-arguments-calls,-readability-implicit-bool-conversion,-modernize-use-trailing-return-type,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-init-variables,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-cppcoreguidelines-owning-memory,-hicpp-special-member-functions,-google-runtime-references,-fuchsia-default-arguments-declarations,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-hicpp-signed-bitwise,-readability-function-cognitive-complexity,-altera*'
Checks: '*,-llvmlibc-*,-boost-use-to-string,-cert-*,-clang-analyzer-osx.*,-clang-analyzer-optin.osx.*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-special-member-functions,-google-readability-*,-llvm-include-order,-readability-else-after-return,-readability-implicit-bool-cast,-modernize-pass-by-value,-cppcoreguidelines-no-malloc,-modernize-make-unique,-google-default-arguments,-hicpp-uppercase-literal-suffix,-readability-uppercase-literal-suffix,-hicpp-braces-around-statements,-hicpp-vararg,-hicpp-no-array-decay,-cppcoreguidelines-avoid-c-arrays,-hicpp-avoid-c-arrays,-modernize-avoid-c-arrays,-fuchsia-default-arguments-calls,-readability-implicit-bool-conversion,-modernize-use-trailing-return-type,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-init-variables,-readability-magic-numbers,-cppcoreguidelines-avoid-goto,-hicpp-avoid-goto,-cppcoreguidelines-owning-memory,-hicpp-special-member-functions,-google-runtime-references,-fuchsia-default-arguments-declarations,-cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,-hicpp-signed-bitwise,-readability-function-cognitive-complexity,-altera*,-readability-identifier-length'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
......
......@@ -347,7 +347,7 @@ namespace RTC
if (!type.is_string())
MS_THROW_TYPE_ERROR("wrong type (not a string)");
std::string typeStr = type.get<std::string>();
const std::string typeStr = type.get<std::string>();
if (typeStr == "rtp")
newTraceEventTypes.rtp = true;
......
......@@ -122,7 +122,7 @@ namespace RTC
}
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
const size_t len = packet->GetSize();
// Notify the Node DirectTransport.
this->shared->payloadChannelNotifier->Emit(consumer->id, "rtp", data, len);
......@@ -142,7 +142,7 @@ namespace RTC
MS_TRACE();
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
const size_t len = packet->GetSize();
// Notify the Node DirectTransport.
this->shared->payloadChannelNotifier->Emit(this->id, "rtcp", data, len);
......@@ -158,7 +158,7 @@ namespace RTC
packet->Serialize(RTC::RTCP::Buffer);
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
const size_t len = packet->GetSize();
// Notify the Node DirectTransport.
this->shared->payloadChannelNotifier->Emit(this->id, "rtcp", data, len);
......
......@@ -25,8 +25,8 @@ namespace RTC
if (this->rtpParameters.encodings.size() != this->consumableRtpEncodings.size())
MS_THROW_TYPE_ERROR("number of rtpParameters.encodings and consumableRtpEncodings do not match");
auto& encoding = this->rtpParameters.encodings[0];
auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
auto& encoding = this->rtpParameters.encodings[0];
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
this->keyFrameSupported = RTC::Codecs::Tools::CanBeKeyFrame(mediaCodec->mimeType);
......@@ -226,7 +226,7 @@ namespace RTC
return;
// Whether this is the first packet after re-sync.
bool isSyncPacket = syncRequired;
const bool isSyncPacket = syncRequired;
// Sync sequence number and timestamp if required.
if (isSyncPacket)
......
......@@ -39,13 +39,13 @@ namespace RTC
Utils::IP::NormalizeIp(ip);
int err;
int family = Utils::IP::GetFamily(ip);
const int family = Utils::IP::GetFamily(ip);
struct sockaddr_storage bindAddr; // NOLINT(cppcoreguidelines-pro-type-member-init)
size_t portIdx;
int flags{ 0 };
std::vector<bool>& ports = PortManager::GetPorts(transport, ip);
size_t attempt{ 0u };
size_t numAttempts = ports.size();
const size_t numAttempts = ports.size();
uv_handle_t* uvHandle{ nullptr };
uint16_t port;
std::string transportStr;
......@@ -322,7 +322,7 @@ namespace RTC
Utils::IP::NormalizeIp(ip);
int err;
int family = Utils::IP::GetFamily(ip);
const int family = Utils::IP::GetFamily(ip);
struct sockaddr_storage bindAddr; // NOLINT(cppcoreguidelines-pro-type-member-init)
int flags{ 0 };
uv_handle_t* uvHandle{ nullptr };
......
......@@ -66,8 +66,8 @@ namespace RTC
this->rtpStreamByEncodingIdx.resize(this->rtpParameters.encodings.size(), nullptr);
this->rtpStreamScores.resize(this->rtpParameters.encodings.size(), 0u);
auto& encoding = this->rtpParameters.encodings[0];
auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
auto& encoding = this->rtpParameters.encodings[0];
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
if (!RTC::Codecs::Tools::IsValidTypeForCodec(this->type, mediaCodec->mimeType))
{
......@@ -373,7 +373,7 @@ namespace RTC
auto jsonCodecsIt = jsonRtpMappingIt->find("codecs");
size_t idx{ 0 };
for (auto& kv : this->rtpMapping.codecs)
for (const auto& kv : this->rtpMapping.codecs)
{
jsonCodecsIt->emplace_back(json::value_t::object);
......@@ -590,7 +590,7 @@ namespace RTC
if (!type.is_string())
MS_THROW_TYPE_ERROR("wrong type (not a string)");
std::string typeStr = type.get<std::string>();
const std::string typeStr = type.get<std::string>();
if (typeStr == "rtp")
newTraceEventTypes.rtp = true;
......@@ -781,8 +781,8 @@ namespace RTC
if (it != this->mapSsrcRtpStream.end())
{
auto* rtpStream = it->second;
bool first = rtpStream->GetSenderReportNtpMs() == 0;
auto* rtpStream = it->second;
const bool first = rtpStream->GetSenderReportNtpMs() == 0;
rtpStream->ReceiveRtcpSenderReport(report);
......@@ -882,7 +882,7 @@ namespace RTC
return;
}
uint32_t ssrc = it->second;
const uint32_t ssrc = it->second;
// If the current RTP packet is a key frame for the given mapped SSRC do
// nothing since we are gonna provide Consumers with the requested key frame
......@@ -909,8 +909,8 @@ namespace RTC
{
MS_TRACE();
uint32_t ssrc = packet->GetSsrc();
uint8_t payloadType = packet->GetPayloadType();
const uint32_t ssrc = packet->GetSsrc();
const uint8_t payloadType = packet->GetPayloadType();
// If stream found in media ssrcs map, return it.
{
......@@ -941,11 +941,11 @@ namespace RTC
// First, look for an encoding with matching media or RTX ssrc value.
for (size_t i{ 0 }; i < this->rtpParameters.encodings.size(); ++i)
{
auto& encoding = this->rtpParameters.encodings[i];
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
const auto* rtxCodec = this->rtpParameters.GetRtxCodecForEncoding(encoding);
bool isMediaPacket = (mediaCodec->payloadType == payloadType);
bool isRtxPacket = (rtxCodec && rtxCodec->payloadType == payloadType);
auto& encoding = this->rtpParameters.encodings[i];
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
const auto* rtxCodec = this->rtpParameters.GetRtxCodecForEncoding(encoding);
const bool isMediaPacket = (mediaCodec->payloadType == payloadType);
const bool isRtxPacket = (rtxCodec && rtxCodec->payloadType == payloadType);
if (isMediaPacket && encoding.ssrc == ssrc)
{
......@@ -997,10 +997,10 @@ namespace RTC
if (encoding.rid != rid)
continue;
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
const auto* rtxCodec = this->rtpParameters.GetRtxCodecForEncoding(encoding);
bool isMediaPacket = (mediaCodec->payloadType == payloadType);
bool isRtxPacket = (rtxCodec && rtxCodec->payloadType == payloadType);
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
const auto* rtxCodec = this->rtpParameters.GetRtxCodecForEncoding(encoding);
const bool isMediaPacket = (mediaCodec->payloadType == payloadType);
const bool isRtxPacket = (rtxCodec && rtxCodec->payloadType == payloadType);
if (isMediaPacket)
{
......@@ -1071,11 +1071,11 @@ namespace RTC
)
// clang-format on
{
auto& encoding = this->rtpParameters.encodings[0];
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
const auto* rtxCodec = this->rtpParameters.GetRtxCodecForEncoding(encoding);
bool isMediaPacket = (mediaCodec->payloadType == payloadType);
bool isRtxPacket = (rtxCodec && rtxCodec->payloadType == payloadType);
auto& encoding = this->rtpParameters.encodings[0];
const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding);
const auto* rtxCodec = this->rtpParameters.GetRtxCodecForEncoding(encoding);
const bool isMediaPacket = (mediaCodec->payloadType == payloadType);
const bool isRtxPacket = (rtxCodec && rtxCodec->payloadType == payloadType);
if (isMediaPacket)
{
......@@ -1134,7 +1134,7 @@ namespace RTC
{
MS_TRACE();
uint32_t ssrc = packet->GetSsrc();
const uint32_t ssrc = packet->GetSsrc();
MS_ASSERT(
this->mapSsrcRtpStream.find(ssrc) == this->mapSsrcRtpStream.end(),
......@@ -1263,8 +1263,8 @@ namespace RTC
// Mangle the payload type.
{
uint8_t payloadType = packet->GetPayloadType();
auto it = this->rtpMapping.codecs.find(payloadType);
const uint8_t payloadType = packet->GetPayloadType();
auto it = this->rtpMapping.codecs.find(payloadType);
if (it == this->rtpMapping.codecs.end())
{
......@@ -1273,14 +1273,14 @@ namespace RTC
return false;
}
uint8_t mappedPayloadType = it->second;
const uint8_t mappedPayloadType = it->second;
packet->SetPayloadType(mappedPayloadType);
}
// Mangle the SSRC.
{
uint32_t mappedSsrc = this->mapRtpStreamMappedSsrc.at(rtpStream);
const uint32_t mappedSsrc = this->mapRtpStreamMappedSsrc.at(rtpStream);
packet->SetSsrc(mappedSsrc);
}
......
......@@ -116,7 +116,7 @@ namespace RTC
void RtpDataCounter::Update(RTC::RtpPacket* packet)
{
uint64_t nowMs = DepLibUV::GetTimeMs();
const uint64_t nowMs = DepLibUV::GetTimeMs();
this->packets++;
this->rate.Update(packet->GetSize(), nowMs);
......
......@@ -789,8 +789,8 @@ namespace RTC
// Get all streams in the Producer and provide the Consumer with them.
for (const auto& kv : producer->GetRtpStreams())
{
auto* rtpStream = kv.first;
uint32_t mappedSsrc = kv.second;
auto* rtpStream = kv.first;
const uint32_t mappedSsrc = kv.second;
consumer->ProducerRtpStream(rtpStream, mappedSsrc);
}
......
......@@ -23,7 +23,7 @@ namespace RTC
auto jsonRidTableIt = jsonObject.find("ridTable");
// Add ssrcTable.
for (auto& kv : this->ssrcTable)
for (const auto& kv : this->ssrcTable)
{
auto ssrc = kv.first;
auto* producer = kv.second;
......@@ -32,19 +32,19 @@ namespace RTC
}
// Add midTable.
for (auto& kv : this->midTable)
for (const auto& kv : this->midTable)
{
auto& mid = kv.first;
auto* producer = kv.second;
const auto& mid = kv.first;
auto* producer = kv.second;
(*jsonMidTableIt)[mid] = producer->id;
}
// Add ridTable.
for (auto& kv : this->ridTable)
for (const auto& kv : this->ridTable)
{
auto& rid = kv.first;
auto* producer = kv.second;
const auto& rid = kv.first;
auto* producer = kv.second;
(*jsonRidTableIt)[rid] = producer->id;
}
......@@ -57,7 +57,7 @@ namespace RTC
const auto& rtpParameters = producer->GetRtpParameters();
// Add entries into the ssrcTable.
for (auto& encoding : rtpParameters.encodings)
for (const auto& encoding : rtpParameters.encodings)
{
uint32_t ssrc;
......@@ -99,7 +99,7 @@ namespace RTC
// Add entries into midTable.
if (!rtpParameters.mid.empty())
{
auto& mid = rtpParameters.mid;
const auto& mid = rtpParameters.mid;
if (this->midTable.find(mid) == this->midTable.end())
{
......@@ -114,9 +114,9 @@ namespace RTC
}
// Add entries into ridTable.
for (auto& encoding : rtpParameters.encodings)
for (const auto& encoding : rtpParameters.encodings)
{
auto& rid = encoding.rid;
const auto& rid = encoding.rid;
if (rid.empty())
continue;
......
......@@ -543,7 +543,7 @@ namespace RTC
if (!extenValue)
return;
size_t midLen = mid.length();
const size_t midLen = mid.length();
// Here we assume that there is MidMaxLength available bytes, even if now
// they are padding bytes.
......
......@@ -17,7 +17,7 @@ namespace RTC
// Probation RTP header.
// Caution: This must have an exact size for the RTP extensions to be added
// and must align extensions to 4 bytes.
static uint8_t ProbationPacketHeader[] =
static const uint8_t ProbationPacketHeader[] =
{
0b10010000, 0b01111111, 0, 0, // PayloadType: 127, Sequence Number: 0
0, 0, 0, 0, // Timestamp: 0
......
......@@ -440,11 +440,12 @@ namespace RTC
this->packetsLost = 0u;
// Calculate Fraction Lost.
uint32_t expectedInterval = expected - this->expectedPrior;
const uint32_t expectedInterval = expected - this->expectedPrior;
this->expectedPrior = expected;
uint32_t receivedInterval = this->mediaTransmissionCounter.GetPacketCount() - this->receivedPrior;
const uint32_t receivedInterval =
this->mediaTransmissionCounter.GetPacketCount() - this->receivedPrior;
this->receivedPrior = this->mediaTransmissionCounter.GetPacketCount();
......@@ -669,14 +670,14 @@ namespace RTC
MS_TRACE();
// Calculate number of packets expected in this interval.
auto totalExpected = GetExpectedPackets();
uint32_t expected = totalExpected - this->expectedPriorScore;
const auto totalExpected = GetExpectedPackets();
const uint32_t expected = totalExpected - this->expectedPriorScore;
this->expectedPriorScore = totalExpected;
// Calculate number of packets received in this interval.
auto totalReceived = this->mediaTransmissionCounter.GetPacketCount();
uint32_t received = totalReceived - this->receivedPriorScore;
const auto totalReceived = this->mediaTransmissionCounter.GetPacketCount();
const uint32_t received = totalReceived - this->receivedPriorScore;
this->receivedPriorScore = totalReceived;
......@@ -689,14 +690,14 @@ namespace RTC
lost = expected - received;
// Calculate number of packets repaired in this interval.
auto totalRepaired = this->packetsRepaired;
uint32_t repaired = totalRepaired - this->repairedPriorScore;
const auto totalRepaired = this->packetsRepaired;
uint32_t repaired = totalRepaired - this->repairedPriorScore;
this->repairedPriorScore = totalRepaired;
// Calculate number of packets retransmitted in this interval.
auto totatRetransmitted = this->packetsRetransmitted;
uint32_t retransmitted = totatRetransmitted - this->retransmittedPriorScore;
const auto totatRetransmitted = this->packetsRetransmitted;
uint32_t retransmitted = totatRetransmitted - this->retransmittedPriorScore;
this->retransmittedPriorScore = totatRetransmitted;
......
......@@ -180,7 +180,7 @@ namespace RTC
{
MS_TRACE();
uint64_t nowMs = DepLibUV::GetTimeMs();
const uint64_t nowMs = DepLibUV::GetTimeMs();
RTC::RtpStream::FillJsonStats(jsonObject);
......@@ -465,7 +465,7 @@ namespace RTC
// Processing RTP packet is older than first one.
if (RTC::SeqManager<uint32_t>::IsSeqLowerThan(packet->GetTimestamp(), storageItem->timestamp))
{
uint32_t diffTs{ storageItem->timestamp - packet->GetTimestamp() };
const uint32_t diffTs{ storageItem->timestamp - packet->GetTimestamp() };
// RTP packet is older than the retransmission buffer size.
if (static_cast<uint32_t>(diffTs * 1000 / this->params.clockRate) >= this->retransmissionBufferSize)
......@@ -523,7 +523,7 @@ namespace RTC
for (size_t i{ 0 }; i < bufferSize && this->storageItemBuffer.GetBufferSize() != 0; ++i)
{
auto* storageItem = this->storageItemBuffer.GetFirst();
uint32_t diffTs{ packet->GetTimestamp() - storageItem->timestamp };
const uint32_t diffTs{ packet->GetTimestamp() - storageItem->timestamp };
// Processing RTP packet is older than first one.
if (RTC::SeqManager<uint32_t>::IsSeqLowerThan(packet->GetTimestamp(), storageItem->timestamp))
......@@ -605,7 +605,7 @@ namespace RTC
if (!this->mid.empty())
packet->UpdateMid(mid);
uint32_t diffTs = this->maxPacketTs - packet->GetTimestamp();
const uint32_t diffTs = this->maxPacketTs - packet->GetTimestamp();
diffMs = diffTs * 1000 / this->params.clockRate;
}
......
......@@ -11,12 +11,12 @@
#include <string>
// Free send buffer threshold (in bytes) upon which send_cb will be executed.
static uint32_t SendBufferThreshold{ 256u };
static const uint32_t SendBufferThreshold{ 256u };
/* SCTP events to which we are subscribing. */
/* clang-format off */
uint16_t EventTypes[] =
const uint16_t EventTypes[] =
{
SCTP_ADAPTATION_INDICATION,
SCTP_ASSOC_CHANGE,
......@@ -59,7 +59,7 @@ inline static int onRecvSctpData(
else
{
const uint16_t streamId = rcv.rcv_sid;
uint32_t ppid = ntohl(rcv.rcv_ppid);
const uint32_t ppid = ntohl(rcv.rcv_ppid);
const uint16_t ssn = rcv.rcv_ssn;
MS_DEBUG_TAG(
......
......@@ -95,8 +95,8 @@ namespace RTC
if (!result.received)
continue;
uint16_t wideSeq = result.sequenceNumber;
auto it = this->sentInfos.find(wideSeq);
const uint16_t wideSeq = result.sequenceNumber;
auto it = this->sentInfos.find(wideSeq);
if (it == this->sentInfos.end())
{
......
......@@ -85,9 +85,9 @@ namespace RTC
if (!this->dropped.empty())
{
// Delete dropped inputs older than input - MaxValue/2.
size_t droppedCount = this->dropped.size();
size_t threshold = (input - MaxValue / 2) & MaxValue;
auto it = this->dropped.lower_bound(threshold);
size_t droppedCount = this->dropped.size();
const size_t threshold = (input - MaxValue / 2) & MaxValue;
auto it = this->dropped.lower_bound(threshold);
this->dropped.erase(this->dropped.begin(), it);
this->base = (this->base - (droppedCount - this->dropped.size())) & MaxValue;
......
......@@ -309,7 +309,7 @@ namespace RTC
MS_ASSERT(it != this->mapMappedSsrcSpatialLayer.end(), "unknown mappedSsrc");
int16_t spatialLayer = it->second;
const int16_t spatialLayer = it->second;
this->producerRtpStreams[spatialLayer] = rtpStream;
}
......@@ -322,7 +322,7 @@ namespace RTC
MS_ASSERT(it != this->mapMappedSsrcSpatialLayer.end(), "unknown mappedSsrc");
int16_t spatialLayer = it->second;
const int16_t spatialLayer = it->second;
this->producerRtpStreams[spatialLayer] = rtpStream;
......@@ -750,7 +750,7 @@ namespace RTC
else
diffMs = -1 * (ntpMs1 - ntpMs2);
int64_t diffTs = diffMs * this->rtpStream->GetClockRate() / 1000;
const int64_t diffTs = diffMs * this->rtpStream->GetClockRate() / 1000;
const uint32_t newTs2 = ts2 - diffTs;
// Apply offset. This is the difference that later must be removed from the
......@@ -778,8 +778,8 @@ namespace RTC
// Apply an expected offset for a new frame in a 30fps stream.
static const uint8_t MsOffset{ 33u }; // (1 / 30 * 1000).
int64_t maxTsExtraOffset = MaxExtraOffsetMs * this->rtpStream->GetClockRate() / 1000;
uint32_t tsExtraOffset = this->rtpStream->GetMaxPacketTs() - packet->GetTimestamp() +
const int64_t maxTsExtraOffset = MaxExtraOffsetMs * this->rtpStream->GetClockRate() / 1000;
uint32_t tsExtraOffset = this->rtpStream->GetMaxPacketTs() - packet->GetTimestamp() +
tsOffset + MsOffset * this->rtpStream->GetClockRate() / 1000;
// NOTE: Don't ask for a key frame if already done.
......
......@@ -434,7 +434,7 @@ namespace RTC
return Authentication::BAD_REQUEST;
// Check that USERNAME attribute begins with our local username plus ":".
size_t localUsernameLen = localUsername.length();
const size_t localUsernameLen = localUsername.length();
if (
this->username.length() <= localUsernameLen || this->username.at(localUsernameLen) != ':' ||
......@@ -531,8 +531,9 @@ namespace RTC
bool addXorMappedAddress =
((this->xorMappedAddress != nullptr) && this->method == StunPacket::Method::BINDING &&
this->klass == Class::SUCCESS_RESPONSE);
bool addErrorCode = ((this->errorCode != 0u) && this->klass == Class::ERROR_RESPONSE);
bool addMessageIntegrity = (this->klass != Class::ERROR_RESPONSE && !this->password.empty());
const bool addErrorCode = ((this->errorCode != 0u) && this->klass == Class::ERROR_RESPONSE);
const bool addMessageIntegrity =
(this->klass != Class::ERROR_RESPONSE && !this->password.empty());
const bool addFingerprint{ true }; // Do always.
// Update data pointer.
......@@ -748,8 +749,8 @@ namespace RTC
Utils::Byte::Set2Bytes(buffer, pos, static_cast<uint16_t>(Attribute::ERROR_CODE));
Utils::Byte::Set2Bytes(buffer, pos + 2, 4);
auto codeClass = static_cast<uint8_t>(this->errorCode / 100);
uint8_t codeNumber = static_cast<uint8_t>(this->errorCode) - (codeClass * 100);
auto codeClass = static_cast<uint8_t>(this->errorCode / 100);
const uint8_t codeNumber = static_cast<uint8_t>(this->errorCode) - (codeClass * 100);
Utils::Byte::Set2Bytes(buffer, pos + 4, 0);
Utils::Byte::Set1Byte(buffer, pos + 6, codeClass);
......
......@@ -25,8 +25,8 @@
namespace RTC
{
static size_t DefaultSctpSendBufferSize{ 262144 }; // 2^18.
static size_t MaxSctpSendBufferSize{ 268435456 }; // 2^28.
static const size_t DefaultSctpSendBufferSize{ 262144 }; // 2^18.
static const size_t MaxSctpSendBufferSize{ 268435456 }; // 2^28.
/* Instance methods. */
......@@ -622,7 +622,7 @@ namespace RTC
MS_THROW_TYPE_ERROR("missing bitrate");
}
uint32_t bitrate = jsonBitrateIt->get<uint32_t>();
const uint32_t bitrate = jsonBitrateIt->get<uint32_t>();
if (bitrate < RTC::TransportCongestionControlMinOutgoingBitrate)
{
......@@ -1287,7 +1287,7 @@ namespace RTC
if (!type.is_string())
MS_THROW_TYPE_ERROR("wrong type (not a string)");
std::string typeStr = type.get<std::string>();
const std::string typeStr = type.get<std::string>();
if (typeStr == "probation")
newTraceEventTypes.probation = true;
......@@ -2324,7 +2324,7 @@ namespace RTC
for (uint8_t i{ 1u }; i <= (baseAllocation ? 1u : priority); ++i)
{
uint32_t usedBitrate{ 0u };
bool considerLoss = (bweType == RTC::BweType::REMB);
const bool considerLoss = (bweType == RTC::BweType::REMB);
usedBitrate = consumer->IncreaseLayer(availableBitrate, considerLoss);
......@@ -2525,7 +2525,7 @@ namespace RTC
// invoked *after* the WebRtcTransport has been closed (freed). To avoid
// invalid memory access we need to use weak_ptr. Same applies in other
// send callbacks.
std::weak_ptr<RTC::TransportCongestionControlClient> tccClientWeakPtr(this->tccClient);
const std::weak_ptr<RTC::TransportCongestionControlClient> tccClientWeakPtr(this->tccClient);
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
std::weak_ptr<RTC::SenderBandwidthEstimator> senderBweWeakPtr(this->senderBwe);
......@@ -2614,7 +2614,7 @@ namespace RTC
// Indicate the pacer (and prober) that a packet is to be sent.
this->tccClient->InsertPacket(packetInfo);
std::weak_ptr<RTC::TransportCongestionControlClient> tccClientWeakPtr(this->tccClient);
const std::weak_ptr<RTC::TransportCongestionControlClient> tccClientWeakPtr(this->tccClient);
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
std::weak_ptr<RTC::SenderBandwidthEstimator> senderBweWeakPtr = this->senderBwe;
......@@ -2970,7 +2970,7 @@ namespace RTC
// Indicate the pacer (and prober) that a packet is to be sent.
this->tccClient->InsertPacket(packetInfo);
std::weak_ptr<RTC::TransportCongestionControlClient> tccClientWeakPtr(this->tccClient);
const std::weak_ptr<RTC::TransportCongestionControlClient> tccClientWeakPtr(this->tccClient);
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
std::weak_ptr<RTC::SenderBandwidthEstimator> senderBweWeakPtr = this->senderBwe;
......
......@@ -232,8 +232,8 @@ namespace RTC
this, this->transportCcFeedbackPacket.get());
// Update packet loss history.
size_t expected_packets = this->transportCcFeedbackPacket->GetPacketStatusCount();
size_t lost_packets = 0;
const size_t expected_packets = this->transportCcFeedbackPacket->GetPacketStatusCount();
size_t lost_packets = 0;
for (const auto& result : this->transportCcFeedbackPacket->GetPacketResults())
{
if (!result.received)
......
......@@ -34,7 +34,7 @@ namespace RTC
// Otherwise decrease current value.
else
{
uint64_t elapsedMs = nowMs - this->highestValueUpdatedAtMs;
const uint64_t elapsedMs = nowMs - this->highestValueUpdatedAtMs;
auto subtraction =
static_cast<uint32_t>(this->highestValue * this->decreaseFactor * (elapsedMs / 1000.0));
......
......@@ -359,8 +359,8 @@ namespace RTC
// local usernameFragment) which is the first value in the attribute value
// before the ":" symbol.
auto& username = packet->GetUsername();
size_t colonPos = username.find(':');
const auto& username = packet->GetUsername();
const size_t colonPos = username.find(':');
// If no colon is found just return the whole USERNAME attribute anyway.
if (colonPos == std::string::npos)
......
......@@ -365,8 +365,8 @@ namespace RTC
{
jsonIceCandidatesIt->emplace_back(json::value_t::object);
auto& jsonEntry = (*jsonIceCandidatesIt)[i];
auto& iceCandidate = this->iceCandidates[i];
auto& jsonEntry = (*jsonIceCandidatesIt)[i];
const auto& iceCandidate = this->iceCandidates[i];
iceCandidate.FillJson(jsonEntry);
}
......@@ -648,8 +648,8 @@ namespace RTC
case Channel::ChannelRequest::MethodId::TRANSPORT_RESTART_ICE:
{
std::string usernameFragment = Utils::Crypto::GetRandomString(32);
std::string password = Utils::Crypto::GetRandomString(32);
const std::string usernameFragment = Utils::Crypto::GetRandomString(32);
const std::string password = Utils::Crypto::GetRandomString(32);
this->iceServer->RestartIce(usernameFragment, password);
......
......@@ -328,7 +328,7 @@ void Settings::SetLogTags(const std::vector<std::string>& tags)
// Reset logTags.
struct LogTags newLogTags;
for (auto& tag : tags)
for (const auto& tag : tags)
{
if (tag == "info")
newLogTags.info = true;
......
......@@ -114,20 +114,20 @@ void Worker::FillJson(json& jsonObject) const
jsonObject["webRtcServerIds"] = json::array();
auto jsonWebRtcServerIdsIt = jsonObject.find("webRtcServerIds");
for (auto& kv : this->mapWebRtcServers)
for (const auto& kv : this->mapWebRtcServers)
{
auto& WebRtcServerId = kv.first;
const auto& webRtcServerId = kv.first;
jsonWebRtcServerIdsIt->emplace_back(WebRtcServerId);
jsonWebRtcServerIdsIt->emplace_back(webRtcServerId);
}
// Add routerIds.
jsonObject["routerIds"] = json::array();
auto jsonRouterIdsIt = jsonObject.find("routerIds");
for (auto& kv : this->mapRouters)
for (const auto& kv : this->mapRouters)
{
auto& routerId = kv.first;
const auto& routerId = kv.first;
jsonRouterIdsIt->emplace_back(routerId);
}
......
......@@ -56,7 +56,7 @@ void SignalsHandler::AddSignal(int signum, const std::string& name)
MS_THROW_ERROR("closed");
int err;
auto uvHandle = new uv_signal_t;
auto* uvHandle = new uv_signal_t;
uvHandle->data = static_cast<void*>(this);
......
......@@ -103,7 +103,7 @@ void TcpConnectionHandler::Close()
{
// Use uv_shutdown() so pending data to be written will be sent to the peer
// before closing.
auto req = new uv_shutdown_t;
auto* req = new uv_shutdown_t;
req->data = static_cast<void*>(this);
err = uv_shutdown(
req, reinterpret_cast<uv_stream_t*>(this->uvHandle), static_cast<uv_shutdown_cb>(onShutdown));
......
......@@ -146,7 +146,7 @@ void UnixStreamSocket::Close()
if (this->role == UnixStreamSocket::Role::PRODUCER && !this->hasError && !this->isClosedByPeer)
{
// Use uv_shutdown() so pending data to be written will be sent to the peer before closing.
auto req = new uv_shutdown_t;
auto* req = new uv_shutdown_t;
req->data = static_cast<void*>(this);
err = uv_shutdown(
req, reinterpret_cast<uv_stream_t*>(this->uvHandle), static_cast<uv_shutdown_cb>(onShutdown));
......
......@@ -21,7 +21,7 @@ int main(int argc, char* argv[])
std::_Exit(EXIT_FAILURE);
}
std::string version = std::getenv("MEDIASOUP_VERSION");
const std::string version = std::getenv("MEDIASOUP_VERSION");
auto statusCode = mediasoup_worker_run(
argc,
......
......@@ -338,7 +338,7 @@ SCENARIO("parse RTP packets", "[parser][rtp]")
REQUIRE(packet->HasOneByteExtensions() == false);
REQUIRE(packet->HasTwoBytesExtensions());
auto rtxPacket = packet->Clone();
auto* rtxPacket = packet->Clone();
delete packet;
......
......@@ -78,15 +78,15 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
SECTION("receive NACK and get retransmitted packets")
{
// packet1 [pt:123, seq:21006, timestamp:1533790901]
auto packet1 = CreateRtpPacket(rtpBuffer1, 21006, 1533790901);
auto* packet1 = CreateRtpPacket(rtpBuffer1, 21006, 1533790901);
// packet2 [pt:123, seq:21007, timestamp:1533790901]
auto packet2 = CreateRtpPacket(rtpBuffer2, 21007, 1533790901);
auto* packet2 = CreateRtpPacket(rtpBuffer2, 21007, 1533790901);
// packet3 [pt:123, seq:21008, timestamp:1533793871]
auto packet3 = CreateRtpPacket(rtpBuffer3, 21008, 1533793871);
auto* packet3 = CreateRtpPacket(rtpBuffer3, 21008, 1533793871);
// packet4 [pt:123, seq:21009, timestamp:1533793871]
auto packet4 = CreateRtpPacket(rtpBuffer4, 21009, 1533793871);
auto* packet4 = CreateRtpPacket(rtpBuffer4, 21009, 1533793871);
// packet5 [pt:123, seq:21010, timestamp:1533796931]
auto packet5 = CreateRtpPacket(rtpBuffer5, 21010, 1533796931);
auto* packet5 = CreateRtpPacket(rtpBuffer5, 21010, 1533796931);
// Create a RtpStreamSend instance.
TestRtpStreamListener testRtpStreamListener;
......@@ -143,15 +143,15 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
SECTION("receive NACK and get zero retransmitted packets if useNack is not set")
{
// packet1 [pt:123, seq:21006, timestamp:1533790901]
auto packet1 = CreateRtpPacket(rtpBuffer1, 21006, 1533790901);
auto* packet1 = CreateRtpPacket(rtpBuffer1, 21006, 1533790901);
// packet2 [pt:123, seq:21007, timestamp:1533790901]
auto packet2 = CreateRtpPacket(rtpBuffer2, 21007, 1533790901);
auto* packet2 = CreateRtpPacket(rtpBuffer2, 21007, 1533790901);
// packet3 [pt:123, seq:21008, timestamp:1533793871]
auto packet3 = CreateRtpPacket(rtpBuffer3, 21008, 1533793871);
auto* packet3 = CreateRtpPacket(rtpBuffer3, 21008, 1533793871);
// packet4 [pt:123, seq:21009, timestamp:1533793871]
auto packet4 = CreateRtpPacket(rtpBuffer4, 21009, 1533793871);
auto* packet4 = CreateRtpPacket(rtpBuffer4, 21009, 1533793871);
// packet5 [pt:123, seq:21010, timestamp:1533796931]
auto packet5 = CreateRtpPacket(rtpBuffer5, 21010, 1533796931);
auto* packet5 = CreateRtpPacket(rtpBuffer5, 21010, 1533796931);
// Create a RtpStreamSend instance.
TestRtpStreamListener testRtpStreamListener;
......@@ -196,15 +196,15 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
SECTION("receive NACK and get zero retransmitted packets for audio")
{
// packet1 [pt:123, seq:21006, timestamp:1533790901]
auto packet1 = CreateRtpPacket(rtpBuffer1, 21006, 1533790901);
auto* packet1 = CreateRtpPacket(rtpBuffer1, 21006, 1533790901);
// packet2 [pt:123, seq:21007, timestamp:1533790901]
auto packet2 = CreateRtpPacket(rtpBuffer2, 21007, 1533790901);
auto* packet2 = CreateRtpPacket(rtpBuffer2, 21007, 1533790901);
// packet3 [pt:123, seq:21008, timestamp:1533793871]
auto packet3 = CreateRtpPacket(rtpBuffer3, 21008, 1533793871);
auto* packet3 = CreateRtpPacket(rtpBuffer3, 21008, 1533793871);
// packet4 [pt:123, seq:21009, timestamp:1533793871]
auto packet4 = CreateRtpPacket(rtpBuffer4, 21009, 1533793871);
auto* packet4 = CreateRtpPacket(rtpBuffer4, 21009, 1533793871);
// packet5 [pt:123, seq:21010, timestamp:1533796931]
auto packet5 = CreateRtpPacket(rtpBuffer5, 21010, 1533796931);
auto* packet5 = CreateRtpPacket(rtpBuffer5, 21010, 1533796931);
// Create a RtpStreamSend instance.
TestRtpStreamListener testRtpStreamListener;
......@@ -249,9 +249,9 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
SECTION("receive NACK in different RtpStreamSend instances and get retransmitted packets")
{
// packet1 [pt:123, seq:21006, timestamp:1533790901]
auto packet1 = CreateRtpPacket(rtpBuffer1, 21006, 1533790901);
auto* packet1 = CreateRtpPacket(rtpBuffer1, 21006, 1533790901);
// packet2 [pt:123, seq:21007, timestamp:1533790901]
auto packet2 = CreateRtpPacket(rtpBuffer2, 21007, 1533790901);
auto* packet2 = CreateRtpPacket(rtpBuffer2, 21007, 1533790901);
// Create two RtpStreamSend instances.
TestRtpStreamListener testRtpStreamListener1;
......@@ -326,8 +326,8 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
uint32_t diffTs = RtpStreamSend::MaxRetransmissionDelay * clockRate / 1000;
uint32_t secondTs = firstTs + diffTs;
auto packet1 = CreateRtpPacket(rtpBuffer1, 21006, firstTs);
auto packet2 = CreateRtpPacket(rtpBuffer2, 21007, secondTs - 1);
auto* packet1 = CreateRtpPacket(rtpBuffer1, 21006, firstTs);
auto* packet2 = CreateRtpPacket(rtpBuffer2, 21007, secondTs - 1);
// Create a RtpStreamSend instance.
TestRtpStreamListener testRtpStreamListener1;
......@@ -378,8 +378,8 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp][nack]")
uint32_t diffTs = RtpStreamSend::MaxRetransmissionDelay * clockRate / 1000;
uint32_t secondTs = firstTs + diffTs;
auto packet1 = CreateRtpPacket(rtpBuffer1, 21006, firstTs);
auto packet2 = CreateRtpPacket(rtpBuffer2, 21007, secondTs);
auto* packet1 = CreateRtpPacket(rtpBuffer1, 21006, firstTs);
auto* packet2 = CreateRtpPacket(rtpBuffer2, 21007, secondTs);
// Create a RtpStreamSend instance.
TestRtpStreamListener testRtpStreamListener1;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论