提交 22900858 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

clang-format: Use 2 spaces for indentation instead of 4

上级 7fc6a08a
......@@ -37,8 +37,8 @@ BreakStringLiterals: false
ColumnLimit: 100
CommentPragmas: 'NOLINT'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
......
......@@ -84,10 +84,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::UdpSocket::Listener. */
public:
void OnPacketRecv(
RTC::UdpSocket* socket,
const uint8_t* data,
size_t len,
const struct sockaddr* remoteAddr) override;
RTC::UdpSocket* socket, const uint8_t* data, size_t len, const struct sockaddr* remoteAddr) override;
/* Pure virtual methods inherited from RTC::TcpServer::Listener. */
public:
......@@ -101,9 +98,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::IceServer::Listener. */
public:
void OnOutgoingStunMessage(
const RTC::IceServer* iceServer,
const RTC::StunMessage* msg,
RTC::TransportTuple* tuple) override;
const RTC::IceServer* iceServer, const RTC::StunMessage* msg, RTC::TransportTuple* tuple) override;
void OnIceSelectedTuple(const RTC::IceServer* iceServer, RTC::TransportTuple* tuple) override;
void OnIceConnected(const RTC::IceServer* iceServer) override;
void OnIceCompleted(const RTC::IceServer* iceServer) override;
......@@ -182,7 +177,9 @@ namespace RTC
inline bool Transport::IsConnected() const
{
return this->dtlsTransport->GetState() == RTC::DtlsTransport::DtlsState::CONNECTED;
return (
this->selectedTuple != nullptr &&
this->dtlsTransport->GetState() == RTC::DtlsTransport::DtlsState::CONNECTED);
}
inline void Transport::EnableRemb()
......
......@@ -18,10 +18,7 @@ namespace RTC
public:
virtual void OnPacketRecv(
RTC::UdpSocket* socket,
const uint8_t* data,
size_t len,
const struct sockaddr* remoteAddr) = 0;
RTC::UdpSocket* socket, const uint8_t* data, size_t len, const struct sockaddr* remoteAddr) = 0;
};
public:
......
......@@ -29,8 +29,7 @@ namespace Utils
inline bool IP::CompareAddresses(const struct sockaddr* addr1, const struct sockaddr* addr2)
{
// Compare family.
if (addr1->sa_family != addr2->sa_family ||
(addr1->sa_family != AF_INET && addr1->sa_family != AF_INET6))
if (addr1->sa_family != addr2->sa_family || (addr1->sa_family != AF_INET && addr1->sa_family != AF_INET6))
{
return false;
}
......@@ -43,18 +42,13 @@ namespace Utils
switch (addr1->sa_family)
{
case AF_INET:
if (std::memcmp(
&((struct sockaddr_in*)addr1)->sin_addr, &((struct sockaddr_in*)addr2)->sin_addr, 4) ==
0)
if (std::memcmp(&((struct sockaddr_in*)addr1)->sin_addr, &((struct sockaddr_in*)addr2)->sin_addr, 4) == 0)
{
return true;
}
break;
case AF_INET6:
if (std::memcmp(
&((struct sockaddr_in6*)addr1)->sin6_addr,
&((struct sockaddr_in6*)addr2)->sin6_addr,
16) == 0)
if (std::memcmp(&((struct sockaddr_in6*)addr1)->sin6_addr, &((struct sockaddr_in6*)addr2)->sin6_addr, 16) == 0)
{
return true;
}
......
......@@ -266,8 +266,8 @@ namespace Channel
// If here it means that jsonStart points to the beginning of a JSON string
// with jsonLen bytes length, so recalculate readLen.
readLen = reinterpret_cast<const uint8_t*>(jsonStart) - (this->buffer + this->msgStart) +
jsonLen + 1;
readLen =
reinterpret_cast<const uint8_t*>(jsonStart) - (this->buffer + this->msgStart) + jsonLen + 1;
Json::Value json;
std::string jsonParseError;
......
......@@ -95,7 +95,8 @@ namespace RTC
MS_TRACE();
// Generate a X509 certificate and private key (unless PEM files are provided).
if (Settings::configuration.dtlsCertificateFile.empty() ||
if (
Settings::configuration.dtlsCertificateFile.empty() ||
Settings::configuration.dtlsPrivateKeyFile.empty())
{
GenerateCertificateAndPrivateKey();
......@@ -364,9 +365,7 @@ namespace RTC
// Require certificate from peer.
SSL_CTX_set_verify(
DtlsTransport::sslCtx,
SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
onSslCertificateVerify);
DtlsTransport::sslCtx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, onSslCertificateVerify);
// Set SSL info callback.
SSL_CTX_set_info_callback(DtlsTransport::sslCtx, onSslInfo);
......@@ -1013,8 +1012,7 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->remoteFingerprint.algorithm != FingerprintAlgorithm::NONE,
"remote fingerprint not set");
this->remoteFingerprint.algorithm != FingerprintAlgorithm::NONE, "remote fingerprint not set");
X509* certificate;
uint8_t binaryFingerprint[EVP_MAX_MD_SIZE];
......
......@@ -150,8 +150,7 @@ namespace RTC
NackInfo& nackInfo = it->second;
uint16_t seq = nackInfo.seq32 % (1 << 16);
if (filter == NackFilter::SEQ && nackInfo.sentAtTime == 0 &&
this->lastSeq32 >= nackInfo.sendAtSeqNum)
if (filter == NackFilter::SEQ && nackInfo.sentAtTime == 0 && this->lastSeq32 >= nackInfo.sendAtSeqNum)
{
nackInfo.retries++;
nackInfo.sentAtTime = now;
......
......@@ -407,7 +407,8 @@ namespace RTC
for (auto& exten : this->rtpParameters.headerExtensions)
{
if (this->kind == RTC::Media::Kind::AUDIO && (ssrcAudioLevelId == 0u) &&
if (
this->kind == RTC::Media::Kind::AUDIO && (ssrcAudioLevelId == 0u) &&
exten.type == RTC::RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL)
{
if (idMapping.find(exten.id) != idMapping.end())
......@@ -528,8 +529,7 @@ namespace RTC
if (this->knownHeaderExtensions.ssrcAudioLevelId)
{
packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL,
this->knownHeaderExtensions.ssrcAudioLevelId);
RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL, this->knownHeaderExtensions.ssrcAudioLevelId);
}
if (this->knownHeaderExtensions.absSendTimeId)
......
......@@ -177,9 +177,7 @@ namespace RTC
default:
MS_WARN_TAG(
rtcp,
"unknown RTCP PS Feedback message type [packetType:%" PRIu8 "]",
commonHeader->count);
rtcp, "unknown RTCP PS Feedback message type [packetType:%" PRIu8 "]", commonHeader->count);
}
return packet;
......
......@@ -67,8 +67,7 @@ namespace RTC
// Check length.
size_t len = static_cast<size_t>(ntohs(commonHeader->length) + 1) * 4;
if (len != sizeof(CommonHeader) + sizeof(FeedbackPacket::Header) + sizeof(Header) +
(numSsrcs * sizeof(uint32_t)))
if (len != sizeof(CommonHeader) + sizeof(FeedbackPacket::Header) + sizeof(Header) + (numSsrcs * sizeof(uint32_t)))
{
MS_WARN_TAG(
rtcp, "invalid payload size (%zu bytes) for the given number of ssrcs (%zu)", len, numSsrcs);
......
......@@ -143,8 +143,7 @@ namespace RTC
break;
case RC_INCREASE:
if (this->avgMaxBitrateKbps >= 0 &&
incomingBitrateKbps > this->avgMaxBitrateKbps + 3 * stdMaxBitRate)
if (this->avgMaxBitrateKbps >= 0 && incomingBitrateKbps > this->avgMaxBitrateKbps + 3 * stdMaxBitRate)
{
ChangeRegion(RC_MAX_UNKNOWN);
this->avgMaxBitrateKbps = -1.0;
......@@ -177,8 +176,8 @@ namespace RTC
// Avoid increasing the rate when over-using.
if (this->rateControlRegion != RC_MAX_UNKNOWN)
{
newBitrateBps = static_cast<uint32_t>(
std::lround(this->beta * this->avgMaxBitrateKbps * 1000 + 0.5f));
newBitrateBps =
static_cast<uint32_t>(std::lround(this->beta * this->avgMaxBitrateKbps * 1000 + 0.5f));
}
newBitrateBps = std::min(newBitrateBps, this->currentBitrateBps);
......
......@@ -42,7 +42,8 @@ namespace RTC
this->e[0][0] += this->processNoise[0];
this->e[1][1] += this->processNoise[1];
if ((currentHypothesis == BW_OVERUSING && this->offset < this->prevOffset) ||
if (
(currentHypothesis == BW_OVERUSING && this->offset < this->prevOffset) ||
(currentHypothesis == BW_UNDERUSING && this->offset > this->prevOffset))
{
this->e[1][1] += 10 * this->processNoise[1];
......@@ -135,8 +136,8 @@ namespace RTC
const double beta = pow(1 - alpha, tsDelta * 30.0 / 1000.0);
this->avgNoise = beta * this->avgNoise + (1 - beta) * residual;
this->varNoise = beta * this->varNoise +
(1 - beta) * (this->avgNoise - residual) * (this->avgNoise - residual);
this->varNoise =
beta * this->varNoise + (1 - beta) * (this->avgNoise - residual) * (this->avgNoise - residual);
if (this->varNoise < 1)
this->varNoise = 1;
}
......
......@@ -136,7 +136,8 @@ namespace RTC
if (it->sendMeanMs == 0 || it->recvMeanMs == 0)
continue;
if (it->numAboveMinDelta > it->count / 2 &&
if (
it->numAboveMinDelta > it->count / 2 &&
(it->recvMeanMs - it->sendMeanMs <= 2.0f && it->sendMeanMs - it->recvMeanMs <= 5.0f))
{
int probeBitrateBps = std::min(it->GetSendBitrateBps(), it->GetRecvBitrateBps());
......@@ -298,7 +299,8 @@ namespace RTC
// the sender.
const size_t minProbePacketSize{ 200 };
if (payloadSize > minProbePacketSize &&
if (
payloadSize > minProbePacketSize &&
(!this->remoteRate.ValidEstimate() ||
nowMs - this->firstPacketTimeMs < InitialProbingIntervalMs))
{
......@@ -348,8 +350,7 @@ namespace RTC
{
// Check if it's time for a periodic update or if we should update because
// of an over-use.
if (this->lastUpdateMs == -1 ||
nowMs - this->lastUpdateMs > this->remoteRate.GetFeedbackInterval())
if (this->lastUpdateMs == -1 || nowMs - this->lastUpdateMs > this->remoteRate.GetFeedbackInterval())
{
updateEstimate = true;
}
......
......@@ -96,7 +96,8 @@ namespace RTC
{
uint32_t incomingBitrateBps = this->incomingBitrate.GetRate(nowMs);
if ((incomingBitrateBps != 0u) &&
if (
(incomingBitrateBps != 0u) &&
(priorState != BW_OVERUSING ||
GetRemoteRate()->TimeToReduceFurther(nowMs, incomingBitrateBps)))
{
......
......@@ -184,8 +184,7 @@ namespace RTC
{
auto& codec = *it;
if (codec.mime.IsFeatureCodec() &&
codec.parameters.GetInteger(associatedPayloadType) == payloadType)
if (codec.mime.IsFeatureCodec() && codec.parameters.GetInteger(associatedPayloadType) == payloadType)
{
return codec;
}
......
......@@ -198,7 +198,8 @@ namespace RTC
{
auto& encoding = *it;
if ((encoding.ssrc == 0u) || (encoding.hasRtx && (encoding.rtx.ssrc == 0u)) ||
if (
(encoding.ssrc == 0u) || (encoding.hasRtx && (encoding.rtx.ssrc == 0u)) ||
(encoding.hasFec && (encoding.fec.ssrc == 0u)))
{
break;
......
......@@ -90,8 +90,7 @@ namespace RTC
{
MS_DEBUG_TAG(
rtx,
"ignoring empty RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16
" payload type: %" PRIu8 "]",
"ignoring empty RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16 " payload type: %" PRIu8 "]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetPayloadType());
......@@ -101,8 +100,8 @@ namespace RTC
MS_WARN_TAG(
rtx,
"ignoring malformed RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16
" payload type: %" PRIu8 "]",
"ignoring malformed RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16 " payload type: %" PRIu8
"]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetPayloadType());
......@@ -112,8 +111,8 @@ namespace RTC
MS_DEBUG_TAG(
rtx,
"received RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16
"] recovering original [ssrc: %" PRIu32 " seq: %" PRIu16 "]",
"received RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16 "] recovering original [ssrc: %" PRIu32
" seq: %" PRIu16 "]",
this->rtxSsrc,
rtxSeq,
packet->GetSsrc(),
......
......@@ -238,8 +238,8 @@ namespace RTC
StunMessage::StunMessage(
Class klass, Method method, const uint8_t* transactionId, const uint8_t* data, size_t size)
: klass(klass), method(method), transactionId(transactionId),
data(const_cast<uint8_t*>(data)), size(size)
: klass(klass), method(method), transactionId(transactionId), data(const_cast<uint8_t*>(data)),
size(size)
{
MS_TRACE();
}
......@@ -346,8 +346,8 @@ namespace RTC
// Check that USERNAME attribute begins with our local username plus ":".
size_t localUsernameLen = localUsername.length();
if (this->username.length() <= localUsernameLen ||
this->username.at(localUsernameLen) != ':' ||
if (
this->username.length() <= localUsernameLen || this->username.at(localUsernameLen) != ':' ||
(this->username.compare(0, localUsernameLen, localUsername) != 0))
return Authentication::UNAUTHORIZED;
......
......@@ -119,8 +119,7 @@ namespace RTC
// Choose a random first port to start from.
initialPort = static_cast<uint16_t>(Utils::Crypto::GetRandomUInt(
static_cast<uint32_t>(RTC::TcpServer::minPort),
static_cast<uint32_t>(RTC::TcpServer::maxPort)));
static_cast<uint32_t>(RTC::TcpServer::minPort), static_cast<uint32_t>(RTC::TcpServer::maxPort)));
iteratingPort = initialPort;
......@@ -140,9 +139,7 @@ namespace RTC
if (!(*availablePorts)[iteratingPort])
{
MS_DEBUG_DEV(
"port in use, trying again [port:%" PRIu16 ", attempt:%" PRIu16 "]",
iteratingPort,
attempt);
"port in use, trying again [port:%" PRIu16 ", attempt:%" PRIu16 "]", iteratingPort, attempt);
// If we have tried all the ports in the range raise an error.
if (iteratingPort == initialPort)
......@@ -208,10 +205,7 @@ namespace RTC
(*availablePorts)[iteratingPort] = false;
MS_DEBUG_DEV(
"bind success [ip:%s, port:%" PRIu16 ", attempt:%" PRIu16 "]",
listenIp,
iteratingPort,
attempt);
"bind success [ip:%s, port:%" PRIu16 ", attempt:%" PRIu16 "]", listenIp, iteratingPort, attempt);
return uvHandle;
};
......
......@@ -623,9 +623,7 @@ namespace RTC
{
if (consumer->kind == RTC::Media::Kind::VIDEO)
{
MS_DEBUG_TAG(
rtx,
"requesting fullframe for new Consumer since Transport already connected");
MS_DEBUG_TAG(rtx, "requesting fullframe for new Consumer since Transport already connected");
}
consumer->RequestFullFrame();
......@@ -636,8 +634,7 @@ namespace RTC
{
MS_TRACE();
// If there is no selected tuple do nothing.
if (this->selectedTuple == nullptr)
if (!IsConnected())
return;
// Ensure there is sending SRTP session.
......@@ -661,8 +658,7 @@ namespace RTC
{
MS_TRACE();
// If there is no selected tuple do nothing.
if (this->selectedTuple == nullptr)
if (!IsConnected())
return;
// Ensure there is sending SRTP session.
......@@ -686,8 +682,7 @@ namespace RTC
{
MS_TRACE();
// If there is no selected tuple do nothing.
if (this->selectedTuple == nullptr)
if (!IsConnected())
return;
// Ensure there is sending SRTP session.
......@@ -722,7 +717,8 @@ namespace RTC
// If still 'auto' then transition to 'server' if ICE is 'connected' or
// 'completed'.
case RTC::DtlsTransport::Role::AUTO:
if (this->iceServer->GetState() == RTC::IceServer::IceState::CONNECTED ||
if (
this->iceServer->GetState() == RTC::IceServer::IceState::CONNECTED ||
this->iceServer->GetState() == RTC::IceServer::IceState::COMPLETED)
{
MS_DEBUG_TAG(
......@@ -748,7 +744,8 @@ namespace RTC
// If 'server' then run the DTLS transport if ICE is 'connected' (not yet
// USE-CANDIDATE) or 'completed'.
case RTC::DtlsTransport::Role::SERVER:
if (this->iceServer->GetState() == RTC::IceServer::IceState::CONNECTED ||
if (
this->iceServer->GetState() == RTC::IceServer::IceState::CONNECTED ||
this->iceServer->GetState() == RTC::IceServer::IceState::COMPLETED)
{
MS_DEBUG_TAG(dtls, "running DTLS transport in local role 'server'");
......@@ -898,7 +895,8 @@ namespace RTC
this->iceServer->ForceSelectedTuple(tuple);
// Check that DTLS status is 'connecting' or 'connected'.
if (this->dtlsTransport->GetState() == DtlsTransport::DtlsState::CONNECTING ||
if (
this->dtlsTransport->GetState() == DtlsTransport::DtlsState::CONNECTING ||
this->dtlsTransport->GetState() == DtlsTransport::DtlsState::CONNECTED)
{
MS_DEBUG_DEV("DTLS data received, passing it to the DTLS transport");
......@@ -1335,6 +1333,8 @@ namespace RTC
MS_TRACE();
MS_DEBUG_TAG(dtls, "DTLS application data received [size:%zu]", len);
// NOTE: No DataChannel support, si just ignore it.
}
void Transport::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs, uint32_t bitrate)
......@@ -1379,7 +1379,8 @@ namespace RTC
// has decreased abruptly.
if (now - this->lastEffectiveMaxBitrateAt > EffectiveMaxBitrateCheckInterval)
{
if ((bitrate != 0u) && (this->effectiveMaxBitrate != 0u) &&
if (
(bitrate != 0u) && (this->effectiveMaxBitrate != 0u) &&
static_cast<double>(effectiveBitrate) / static_cast<double>(this->effectiveMaxBitrate) <
EffectiveMaxBitrateThresholdBeforeFullFrame)
{
......
......@@ -118,8 +118,7 @@ namespace RTC
// Choose a random port to start from.
initialPort = static_cast<uint16_t>(Utils::Crypto::GetRandomUInt(
static_cast<uint32_t>(RTC::UdpSocket::minPort),
static_cast<uint32_t>(RTC::UdpSocket::maxPort)));
static_cast<uint32_t>(RTC::UdpSocket::minPort), static_cast<uint32_t>(RTC::UdpSocket::maxPort)));
iteratingPort = initialPort;
......@@ -139,9 +138,7 @@ namespace RTC
if (!(*availablePorts)[iteratingPort])
{
MS_DEBUG_DEV(
"port in use, trying again [port:%" PRIu16 ", attempt:%" PRIu16 "]",
iteratingPort,
attempt);
"port in use, trying again [port:%" PRIu16 ", attempt:%" PRIu16 "]", iteratingPort, attempt);
// If we have tried all the ports in the range raise an error.
if (iteratingPort == initialPort)
......@@ -207,10 +204,7 @@ namespace RTC
(*availablePorts)[iteratingPort] = false;
MS_DEBUG_DEV(
"bind success [ip:%s, port:%" PRIu16 ", attempt:%" PRIu16 "]",
listenIp,
iteratingPort,
attempt);
"bind success [ip:%s, port:%" PRIu16 ", attempt:%" PRIu16 "]", listenIp, iteratingPort, attempt);
return uvHandle;
};
......
......@@ -506,7 +506,8 @@ void Settings::SetDtlsCertificateAndPrivateKeyFiles()
{
MS_TRACE();
if (Settings::configuration.dtlsCertificateFile.empty() ||
if (
Settings::configuration.dtlsCertificateFile.empty() ||
Settings::configuration.dtlsPrivateKeyFile.empty())
{
Settings::configuration.dtlsCertificateFile = "";
......@@ -622,9 +623,7 @@ bool isBindableIp(const std::string& ip, int family, int* bindErrno)
MS_ABORT("socket() failed: %s", std::strerror(errno));
err = bind(
bindSocket,
reinterpret_cast<const struct sockaddr*>(&bindAddr),
sizeof(struct sockaddr_in6));
bindSocket, reinterpret_cast<const struct sockaddr*>(&bindAddr), sizeof(struct sockaddr_in6));
break;
default:
......
......@@ -94,10 +94,7 @@ namespace Utils
ret = HMAC_Final(&Crypto::hmacSha1Ctx, (uint8_t*)Crypto::hmacSha1Buffer, &resultLen);
MS_ASSERT(
ret == 1,
"OpenSSL HMAC_Final() failed with key '%s' and data length %zu bytes",
key.c_str(),
len);
ret == 1, "OpenSSL HMAC_Final() failed with key '%s' and data length %zu bytes", key.c_str(), len);
MS_ASSERT(resultLen == 20, "OpenSSL HMAC_Final() resultLen is %u instead of 20", resultLen);
return Crypto::hmacSha1Buffer;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论