提交 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
......
......@@ -16,13 +16,13 @@ namespace Channel
void Emit(uint32_t targetId, const std::string& event);
void Emit(uint32_t targetId, const std::string& event, Json::Value& data);
void EmitWithBinary(
uint32_t targetId, const std::string& event, const uint8_t* binaryData, size_t binaryLen);
uint32_t targetId, const std::string& event, const uint8_t* binaryData, size_t binaryLen);
void EmitWithBinary(
uint32_t targetId,
const std::string& event,
const uint8_t* binaryData,
size_t binaryLen,
Json::Value& data);
uint32_t targetId,
const std::string& event,
const uint8_t* binaryData,
size_t binaryLen,
Json::Value& data);
public:
// Passed by argument.
......
......@@ -23,10 +23,10 @@ namespace RTC
{
public:
Consumer(
Channel::Notifier* notifier,
uint32_t consumerId,
RTC::Media::Kind kind,
uint32_t sourceProducerId);
Channel::Notifier* notifier,
uint32_t consumerId,
RTC::Media::Kind kind,
uint32_t sourceProducerId);
private:
virtual ~Consumer();
......
......@@ -72,13 +72,13 @@ namespace RTC
// and remote fingerprint verification). Outgoing media can now flow through.
// NOTE: The caller MUST NOT call any method during this callback.
virtual void OnDtlsConnected(
const RTC::DtlsTransport* dtlsTransport,
RTC::SrtpSession::Profile srtpProfile,
uint8_t* srtpLocalKey,
size_t srtpLocalKeyLen,
uint8_t* srtpRemoteKey,
size_t srtpRemoteKeyLen,
std::string& remoteCert) = 0;
const RTC::DtlsTransport* dtlsTransport,
RTC::SrtpSession::Profile srtpProfile,
uint8_t* srtpLocalKey,
size_t srtpLocalKeyLen,
uint8_t* srtpRemoteKey,
size_t srtpRemoteKeyLen,
std::string& remoteCert) = 0;
// The DTLS connection has been closed as the result of an error (such as a
// DTLS alert or a failure to validate the remote fingerprint).
// NOTE: The caller MUST NOT call Destroy() during this callback.
......@@ -89,11 +89,11 @@ namespace RTC
// Need to send DTLS data to the peer.
// NOTE: The caller MUST NOT call Destroy() during this callback.
virtual void OnOutgoingDtlsData(
const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) = 0;
const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) = 0;
// DTLS application data received.
// NOTE: The caller MUST NOT call Destroy() during this callback.
virtual void OnDtlsApplicationData(
const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) = 0;
const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) = 0;
};
public:
......@@ -190,7 +190,7 @@ namespace RTC
}
inline DtlsTransport::FingerprintAlgorithm DtlsTransport::GetFingerprintAlgorithm(
const std::string& fingerprint)
const std::string& fingerprint)
{
auto it = DtlsTransport::string2FingerprintAlgorithm.find(fingerprint);
......@@ -203,10 +203,10 @@ namespace RTC
inline bool DtlsTransport::IsDtls(const uint8_t* data, size_t len)
{
return (
// Minimum DTLS record length is 13 bytes.
(len >= 13) &&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(data[0] > 19 && data[0] < 64));
// Minimum DTLS record length is 13 bytes.
(len >= 13) &&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(data[0] > 19 && data[0] < 64));
}
/* Inline instance methods. */
......
......@@ -32,7 +32,7 @@ namespace RTC
* returns, so the given pointers are still usable.
*/
virtual void OnOutgoingStunMessage(
const RTC::IceServer* iceServer, const RTC::StunMessage* msg, RTC::TransportTuple* tuple) = 0;
const RTC::IceServer* iceServer, const RTC::StunMessage* msg, RTC::TransportTuple* tuple) = 0;
virtual void OnIceSelectedTuple(const RTC::IceServer* iceServer, RTC::TransportTuple* tuple) = 0;
virtual void OnIceConnected(const RTC::IceServer* iceServer) = 0;
virtual void OnIceCompleted(const RTC::IceServer* iceServer) = 0;
......
......@@ -67,7 +67,7 @@ namespace RTC
// Inline instance methods.
inline NackGenerator::NackInfo::NackInfo(uint32_t seq32, uint32_t sendAtSeqNum)
: seq32(seq32), sendAtSeqNum(sendAtSeqNum)
: seq32(seq32), sendAtSeqNum(sendAtSeqNum)
{
}
} // namespace RTC
......
......@@ -44,7 +44,7 @@ namespace RTC
}
explicit Value(std::vector<int32_t>& arrayOfIntegers)
: type(Type::ARRAY_OF_INTEGERS), arrayOfIntegers(arrayOfIntegers)
: type(Type::ARRAY_OF_INTEGERS), arrayOfIntegers(arrayOfIntegers)
{
}
......
......@@ -35,17 +35,17 @@ namespace RTC
virtual void OnPeerProducerPaused(const RTC::Peer* peer, const RTC::Producer* producer) = 0;
virtual void OnPeerProducerResumed(const RTC::Peer* peer, const RTC::Producer* producer) = 0;
virtual void OnPeerProducerRtpPacket(
const RTC::Peer* peer, RTC::Producer* producer, RTC::RtpPacket* packet) = 0;
const RTC::Peer* peer, RTC::Producer* producer, RTC::RtpPacket* packet) = 0;
virtual void OnPeerProducerRtcpSenderReport(
const RTC::Peer* peer, RTC::Producer* producer, RTC::RTCP::SenderReport* report) = 0;
virtual void OnPeerConsumerClosed(const RTC::Peer* peer, RTC::Consumer* consumer) = 0;
const RTC::Peer* peer, RTC::Producer* producer, RTC::RTCP::SenderReport* report) = 0;
virtual void OnPeerConsumerClosed(const RTC::Peer* peer, RTC::Consumer* consumer) = 0;
virtual void OnPeerConsumerRtcpReceiverReport(
const RTC::Peer* peer, RTC::Consumer* consumer, RTC::RTCP::ReceiverReport* report) = 0;
const RTC::Peer* peer, RTC::Consumer* consumer, RTC::RTCP::ReceiverReport* report) = 0;
virtual void OnPeerConsumerRtcpFeedback(
const RTC::Peer* peer, RTC::Consumer* consumer, RTC::RTCP::FeedbackPsPacket* packet) = 0;
const RTC::Peer* peer, RTC::Consumer* consumer, RTC::RTCP::FeedbackPsPacket* packet) = 0;
virtual void OnPeerConsumerRtcpFeedback(
const RTC::Peer* peer, RTC::Consumer* consumer, RTC::RTCP::FeedbackRtpPacket* packet) = 0;
virtual void OnPeerConsumerFullFrameRequired(RTC::Peer* peer, RTC::Consumer* consumer) = 0;
const RTC::Peer* peer, RTC::Consumer* consumer, RTC::RTCP::FeedbackRtpPacket* packet) = 0;
virtual void OnPeerConsumerFullFrameRequired(RTC::Peer* peer, RTC::Consumer* consumer) = 0;
};
public:
......@@ -67,13 +67,13 @@ namespace RTC
* @param peerName - Name of the receiver Peer.
*/
void AddConsumer(
RTC::Consumer* consumer, RTC::RtpParameters* rtpParameters, uint32_t associatedProducerId);
RTC::Consumer* consumer, RTC::RtpParameters* rtpParameters, uint32_t associatedProducerId);
RTC::Consumer* GetConsumer(uint32_t ssrc) const;
void SendRtcp(uint64_t now);
private:
RTC::Transport* GetTransportFromRequest(
Channel::Request* request, uint32_t* transportId = nullptr) const;
Channel::Request* request, uint32_t* transportId = nullptr) const;
RTC::Producer* GetProducerFromRequest(Channel::Request* request, uint32_t* producerId = nullptr) const;
RTC::Consumer* GetConsumerFromRequest(Channel::Request* request, uint32_t* consumerId = nullptr) const;
......
......@@ -38,13 +38,13 @@ namespace RTC
public:
Producer(
Channel::Notifier* notifier,
uint32_t producerId,
RTC::Media::Kind kind,
RTC::Transport* transport,
RTC::RtpParameters& rtpParameters,
struct RtpMapping& rtpMapping,
bool paused);
Channel::Notifier* notifier,
uint32_t producerId,
RTC::Media::Kind kind,
RTC::Transport* transport,
RTC::RtpParameters& rtpParameters,
struct RtpMapping& rtpMapping,
bool paused);
public:
// Must be public because Router needs to call it.
......
......@@ -42,13 +42,13 @@ namespace RTC
template<typename Item>
inline FeedbackPsItemsPacket<Item>::FeedbackPsItemsPacket(CommonHeader* commonHeader)
: FeedbackPsPacket(commonHeader)
: FeedbackPsPacket(commonHeader)
{
}
template<typename Item>
inline FeedbackPsItemsPacket<Item>::FeedbackPsItemsPacket(uint32_t senderSsrc, uint32_t mediaSsrc)
: FeedbackPsPacket(Item::messageType, senderSsrc, mediaSsrc)
: FeedbackPsPacket(Item::messageType, senderSsrc, mediaSsrc)
{
}
......
......@@ -23,9 +23,9 @@ namespace RTC
public:
// Parsed Report. Points to an external data.
explicit FeedbackPsAfbPacket(
CommonHeader* commonHeader, Application application = Application::UNKNOWN);
CommonHeader* commonHeader, Application application = Application::UNKNOWN);
FeedbackPsAfbPacket(
uint32_t senderSsrc, uint32_t mediaSsrc, Application application = Application::UNKNOWN);
uint32_t senderSsrc, uint32_t mediaSsrc, Application application = Application::UNKNOWN);
~FeedbackPsAfbPacket() override = default;
Application GetApplication() const;
......@@ -45,7 +45,7 @@ namespace RTC
/* Inline instance methods. */
inline FeedbackPsAfbPacket::FeedbackPsAfbPacket(CommonHeader* commonHeader, Application application)
: FeedbackPsPacket(commonHeader)
: FeedbackPsPacket(commonHeader)
{
this->size = ((static_cast<size_t>(ntohs(commonHeader->length)) + 1) * 4) -
(sizeof(CommonHeader) + sizeof(FeedbackPacket::Header));
......@@ -56,8 +56,8 @@ namespace RTC
}
inline FeedbackPsAfbPacket::FeedbackPsAfbPacket(
uint32_t senderSsrc, uint32_t mediaSsrc, Application application)
: FeedbackPsPacket(FeedbackPs::MessageType::AFB, senderSsrc, mediaSsrc)
uint32_t senderSsrc, uint32_t mediaSsrc, Application application)
: FeedbackPsPacket(FeedbackPs::MessageType::AFB, senderSsrc, mediaSsrc)
{
this->application = application;
}
......
......@@ -26,12 +26,12 @@ namespace RTC
/* Inline instance methods. */
inline FeedbackPsPliPacket::FeedbackPsPliPacket(CommonHeader* commonHeader)
: FeedbackPsPacket(commonHeader)
: FeedbackPsPacket(commonHeader)
{
}
inline FeedbackPsPliPacket::FeedbackPsPliPacket(uint32_t senderSsrc, uint32_t mediaSsrc)
: FeedbackPsPacket(FeedbackPs::MessageType::PLI, senderSsrc, mediaSsrc)
: FeedbackPsPacket(FeedbackPs::MessageType::PLI, senderSsrc, mediaSsrc)
{
}
} // namespace RTCP
......
......@@ -66,7 +66,7 @@ namespace RTC
/* Inline instance methods. */
inline FeedbackPsRembPacket::FeedbackPsRembPacket(uint32_t senderSsrc, uint32_t mediaSsrc)
: FeedbackPsAfbPacket(senderSsrc, mediaSsrc, FeedbackPsAfbPacket::Application::REMB)
: FeedbackPsAfbPacket(senderSsrc, mediaSsrc, FeedbackPsAfbPacket::Application::REMB)
{
}
......
......@@ -46,7 +46,7 @@ namespace RTC
explicit FeedbackPsVbcmItem(Header* header);
explicit FeedbackPsVbcmItem(FeedbackPsVbcmItem* item);
FeedbackPsVbcmItem(
uint32_t ssrc, uint8_t sequenceNumber, uint8_t payloadType, uint16_t length, uint8_t* value);
uint32_t ssrc, uint8_t sequenceNumber, uint8_t payloadType, uint16_t length, uint8_t* value);
~FeedbackPsVbcmItem() override = default;
uint32_t GetSsrc() const;
......
......@@ -42,13 +42,13 @@ namespace RTC
template<typename Item>
inline FeedbackRtpItemsPacket<Item>::FeedbackRtpItemsPacket(CommonHeader* commonHeader)
: FeedbackRtpPacket(commonHeader)
: FeedbackRtpPacket(commonHeader)
{
}
template<typename Item>
inline FeedbackRtpItemsPacket<Item>::FeedbackRtpItemsPacket(uint32_t senderSsrc, uint32_t mediaSsrc)
: FeedbackRtpPacket(Item::messageType, senderSsrc, mediaSsrc)
: FeedbackRtpPacket(Item::messageType, senderSsrc, mediaSsrc)
{
}
......
......@@ -61,7 +61,7 @@ namespace RTC
}
inline FeedbackRtpNackItem::FeedbackRtpNackItem(FeedbackRtpNackItem* item)
: header(item->header)
: header(item->header)
{
}
......
......@@ -25,12 +25,12 @@ namespace RTC
/* Inline instance methods. */
inline FeedbackRtpSrReqPacket::FeedbackRtpSrReqPacket(CommonHeader* commonHeader)
: FeedbackRtpPacket(commonHeader)
: FeedbackRtpPacket(commonHeader)
{
}
inline FeedbackRtpSrReqPacket::FeedbackRtpSrReqPacket(uint32_t senderSsrc, uint32_t mediaSsrc)
: FeedbackRtpPacket(FeedbackRtp::MessageType::SR_REQ, senderSsrc, mediaSsrc)
: FeedbackRtpPacket(FeedbackRtp::MessageType::SR_REQ, senderSsrc, mediaSsrc)
{
}
} // namespace RTCP
......
......@@ -61,7 +61,7 @@ namespace RTC
}
inline FeedbackRtpTlleiItem::FeedbackRtpTlleiItem(FeedbackRtpTlleiItem* item)
: header(item->header)
: header(item->header)
{
}
......
......@@ -87,15 +87,15 @@ namespace RTC
auto header = const_cast<CommonHeader*>(reinterpret_cast<const CommonHeader*>(data));
return (
(len >= sizeof(CommonHeader)) &&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(data[0] > 127 && data[0] < 192) &&
// RTP Version must be 2.
(header->version == 2) &&
// RTCP packet types defined by IANA:
// http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-4
// RFC 5761 (RTCP-mux) states this range for secure RTCP/RTP detection.
(header->packetType >= 192 && header->packetType <= 223));
(len >= sizeof(CommonHeader)) &&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(data[0] > 127 && data[0] < 192) &&
// RTP Version must be 2.
(header->version == 2) &&
// RTCP packet types defined by IANA:
// http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-4
// RFC 5761 (RTCP-mux) states this range for secure RTCP/RTP detection.
(header->packetType >= 192 && header->packetType <= 223));
}
/* Inline instance methods. */
......
......@@ -136,7 +136,7 @@ namespace RTC
inline uint32_t AimdRateControl::UpdateBandwidthEstimate(int64_t nowMs)
{
this->currentBitrateBps =
ChangeBitrate(this->currentBitrateBps, this->currentInput.incomingBitrate, nowMs);
ChangeBitrate(this->currentBitrateBps, this->currentInput.incomingBitrate, nowMs);
return this->currentBitrateBps;
}
......
......@@ -40,13 +40,13 @@ namespace RTC
// |arrivalTimeDeltaMs| (output) is the computed arrival-time delta.
// |packetSizeDelta| (output) is the computed size delta.
bool ComputeDeltas(
uint32_t timestamp,
int64_t arrivalTimeMs,
int64_t systemTimeMs,
size_t packetSize,
uint32_t* timestampDelta,
int64_t* arrivalTimeDeltaMs,
int* packetSizeDelta);
uint32_t timestamp,
int64_t arrivalTimeMs,
int64_t systemTimeMs,
size_t packetSize,
uint32_t* timestampDelta,
int64_t* arrivalTimeDeltaMs,
int* packetSizeDelta);
private:
struct TimestampGroup
......@@ -80,7 +80,7 @@ namespace RTC
/* Inline methods. */
inline InterArrival::TimestampGroup::TimestampGroup()
: size(0), firstTimestamp(0), timestamp(0), completeTimeMs(-1)
: size(0), firstTimestamp(0), timestamp(0), completeTimeMs(-1)
{
}
......@@ -90,10 +90,10 @@ namespace RTC
}
inline InterArrival::InterArrival(
uint32_t timestampGroupLengthTicks, double timestampToMsCoeff, bool enableBurstGrouping)
: timestampGroupLengthTicks(timestampGroupLengthTicks), currentTimestampGroup(),
prevTimestampGroup(), timestampToMsCoeff(timestampToMsCoeff),
burstGrouping(enableBurstGrouping), numConsecutiveReorderedPackets(0)
uint32_t timestampGroupLengthTicks, double timestampToMsCoeff, bool enableBurstGrouping)
: timestampGroupLengthTicks(timestampGroupLengthTicks), currentTimestampGroup(),
prevTimestampGroup(), timestampToMsCoeff(timestampToMsCoeff),
burstGrouping(enableBurstGrouping), numConsecutiveReorderedPackets(0)
{
}
} // namespace RTC
......
......@@ -46,7 +46,7 @@ namespace RTC
// |currentHypothesis| should be the hypothesis of the over-use detector at
// this time.
void Update(
int64_t tDelta, double tsDelta, int sizeDelta, BandwidthUsage currentHypothesis, int64_t nowMs);
int64_t tDelta, double tsDelta, int sizeDelta, BandwidthUsage currentHypothesis, int64_t nowMs);
// Returns the estimated noise/jitter variance in ms^2.
double GetVarNoise() const;
// Returns the estimated inter-arrival time delta offset in ms.
......@@ -76,8 +76,8 @@ namespace RTC
/* Inline methods. */
inline OverUseDetectorOptions::OverUseDetectorOptions()
: initialSlope(8.0 / 512.0), initialOffset(0), initialE(), initialProcessNoise(),
initialAvgNoise(0.0), initialVarNoise(50)
: initialSlope(8.0 / 512.0), initialOffset(0), initialE(), initialProcessNoise(),
initialAvgNoise(0.0), initialVarNoise(50)
{
initialE[0][0] = 100;
initialE[1][1] = 1e-1;
......@@ -87,10 +87,10 @@ namespace RTC
}
inline OveruseEstimator::OveruseEstimator(OverUseDetectorOptions options)
: options(std::move(options)), numOfDeltas(0), slope(this->options.initialSlope),
offset(this->options.initialOffset), prevOffset(this->options.initialOffset), e(),
processNoise(), avgNoise(this->options.initialAvgNoise),
varNoise(this->options.initialVarNoise), tsDeltaHist()
: options(std::move(options)), numOfDeltas(0), slope(this->options.initialSlope),
offset(this->options.initialOffset), prevOffset(this->options.initialOffset), e(),
processNoise(), avgNoise(this->options.initialAvgNoise),
varNoise(this->options.initialVarNoise), tsDeltaHist()
{
std::memcpy(this->e, this->options.initialE, sizeof(this->e));
std::memcpy(this->processNoise, this->options.initialProcessNoise, sizeof(this->processNoise));
......
......@@ -20,8 +20,8 @@ namespace RTC
/* Inline methods. */
inline RateControlInput::RateControlInput(
BandwidthUsage bwState, const uint32_t incomingBitrate, double noiseVar)
: bwState(bwState), incomingBitrate(incomingBitrate), noiseVar(noiseVar)
BandwidthUsage bwState, const uint32_t incomingBitrate, double noiseVar)
: bwState(bwState), incomingBitrate(incomingBitrate), noiseVar(noiseVar)
{
}
} // namespace RTC
......
......@@ -57,7 +57,7 @@ namespace RTC
// packet size excluding headers.
// Note that |arrivalTimeMs| can be of an arbitrary time base.
virtual void IncomingPacket(
int64_t arrivalTimeMs, size_t payloadSize, const RtpPacket& packet, uint32_t absSendTime) = 0;
int64_t arrivalTimeMs, size_t payloadSize, const RtpPacket& packet, uint32_t absSendTime) = 0;
// Removes all data for |ssrc|.
virtual void RemoveStream(uint32_t ssrc) = 0;
......
......@@ -59,7 +59,7 @@ namespace RTC
~RemoteBitrateEstimatorAbsSendTime() override = default;
void IncomingPacket(
int64_t arrivalTimeMs, size_t payloadSize, const RtpPacket& packet, uint32_t absSendTime) override;
int64_t arrivalTimeMs, size_t payloadSize, const RtpPacket& packet, uint32_t absSendTime) override;
// This class relies on Process() being called periodically (at least once
// every other second) for streams to be timed out properly.
void Process() override;
......@@ -80,7 +80,7 @@ namespace RTC
private:
void IncomingPacketInfo(
int64_t arrivalTimeMs, uint32_t sendTime24bits, size_t payloadSize, uint32_t ssrc);
int64_t arrivalTimeMs, uint32_t sendTime24bits, size_t payloadSize, uint32_t ssrc);
void ComputeClusters(std::list<Cluster>* clusters) const;
std::list<Cluster>::const_iterator FindBestProbe(const std::list<Cluster>& clusters) const;
......@@ -110,7 +110,7 @@ namespace RTC
/* Inline Methods. */
inline Probe::Probe(int64_t sendTimeMs, int64_t recvTimeMs, size_t payloadSize)
: sendTimeMs(sendTimeMs), recvTimeMs(recvTimeMs), payloadSize(payloadSize)
: sendTimeMs(sendTimeMs), recvTimeMs(recvTimeMs), payloadSize(payloadSize)
{
}
......@@ -129,7 +129,7 @@ namespace RTC
}
inline RemoteBitrateEstimatorAbsSendTime::RemoteBitrateEstimatorAbsSendTime(Listener* observer)
: observer(observer), interArrival(), estimator(), detector(), incomingBitrate()
: observer(observer), interArrival(), estimator(), detector(), incomingBitrate()
{
}
......
......@@ -34,10 +34,10 @@ namespace RTC
~RemoteBitrateEstimatorSingleStream() override;
void IncomingPacket(
int64_t arrivalTimeMs,
size_t payloadSize,
const RtpPacket& packet,
uint32_t transmissionTimeOffset) override;
int64_t arrivalTimeMs,
size_t payloadSize,
const RtpPacket& packet,
uint32_t transmissionTimeOffset) override;
void Process() override;
int64_t TimeUntilNextProcess() override;
void OnRttUpdate(int64_t avgRttMs, int64_t maxRttMs) override;
......@@ -53,7 +53,7 @@ namespace RTC
TIMESTAMP_GROUP_LENGTH_MS = 5
};
explicit Detector(
int64_t lastPacketTimeMs, const OverUseDetectorOptions& options, bool enableBurstGrouping);
int64_t lastPacketTimeMs, const OverUseDetectorOptions& options, bool enableBurstGrouping);
int64_t lastPacketTimeMs;
InterArrival interArrival;
......@@ -87,16 +87,16 @@ namespace RTC
/* Inline Methods. */
inline RemoteBitrateEstimatorSingleStream::Detector::Detector(
int64_t lastPacketTimeMs, const OverUseDetectorOptions& options, bool enableBurstGrouping)
: lastPacketTimeMs(lastPacketTimeMs),
interArrival(90 * TIMESTAMP_GROUP_LENGTH_MS, TimestampToMs, enableBurstGrouping),
estimator(options), detector()
int64_t lastPacketTimeMs, const OverUseDetectorOptions& options, bool enableBurstGrouping)
: lastPacketTimeMs(lastPacketTimeMs),
interArrival(90 * TIMESTAMP_GROUP_LENGTH_MS, TimestampToMs, enableBurstGrouping),
estimator(options), detector()
{
}
inline RemoteBitrateEstimatorSingleStream::RemoteBitrateEstimatorSingleStream(Listener* observer)
: incomingBitrate(), remoteRate(new AimdRateControl()), observer(observer),
processIntervalMs(RemoteBitrateEstimator::processIntervalMs)
: incomingBitrate(), remoteRate(new AimdRateControl()), observer(observer),
processIntervalMs(RemoteBitrateEstimator::processIntervalMs)
{
// assert(this->observer);
}
......
......@@ -54,7 +54,7 @@ namespace RTC
private:
RTC::Transport* GetTransportFromRequest(
Channel::Request* request, uint32_t* transportId = nullptr) const;
Channel::Request* request, uint32_t* transportId = nullptr) const;
RTC::Producer* GetProducerFromRequest(Channel::Request* request, uint32_t* producerId = nullptr) const;
RTC::Consumer* GetConsumerFromRequest(Channel::Request* request, uint32_t* consumerId = nullptr) const;
......
......@@ -65,7 +65,7 @@ namespace RTC
/* Inline instance methods. */
inline RateCalculator::RateCalculator(size_t windowSize, float scale)
: windowSize(windowSize), scale(scale)
: windowSize(windowSize), scale(scale)
{
uint64_t now = DepLibUV::GetTime();
......
......@@ -27,10 +27,10 @@ namespace RTC
private:
void RollbackProducer(
RTC::Producer* producer,
std::vector<uint32_t>& previousSsrcs,
std::string& previousMuxId,
std::vector<uint8_t>& previousPayloadTypes);
RTC::Producer* producer,
std::vector<uint32_t>& previousSsrcs,
std::string& previousMuxId,
std::vector<uint8_t>& previousPayloadTypes);
public:
// Table of SSRC / Producer pairs.
......
......@@ -80,12 +80,12 @@ namespace RTC
public:
RtpPacket(
Header* header,
ExtensionHeader* extensionHeader,
const uint8_t* payload,
size_t payloadLength,
uint8_t payloadPadding,
size_t size);
Header* header,
ExtensionHeader* extensionHeader,
const uint8_t* payload,
size_t payloadLength,
uint8_t payloadPadding,
size_t size);
~RtpPacket();
void Dump() const;
......@@ -148,11 +148,11 @@ namespace RTC
auto header = const_cast<Header*>(reinterpret_cast<const Header*>(data));
return (
(len >= sizeof(Header)) &&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(data[0] > 127 && data[0] < 192) &&
// RTP Version must be 2.
(header->version == 2));
(len >= sizeof(Header)) &&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(data[0] > 127 && data[0] < 192) &&
// RTP Version must be 2.
(header->version == 2));
}
/* Inline instance methods. */
......
......@@ -15,8 +15,8 @@ namespace RTC
{
public:
virtual void OnNackRequired(
RTC::RtpStreamRecv* rtpStream, const std::vector<uint16_t>& seqNumbers) = 0;
virtual void OnPliRequired(RTC::RtpStreamRecv* rtpStream) = 0;
RTC::RtpStreamRecv* rtpStream, const std::vector<uint16_t>& seqNumbers) = 0;
virtual void OnPliRequired(RTC::RtpStreamRecv* rtpStream) = 0;
};
public:
......
......@@ -33,7 +33,7 @@ namespace RTC
bool ReceivePacket(RTC::RtpPacket* packet) override;
void ReceiveRtcpReceiverReport(RTC::RTCP::ReceiverReport* report);
void RequestRtpRetransmission(
uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container);
uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container);
RTC::RTCP::SenderReport* GetRtcpSenderReport(uint64_t now);
uint32_t GetRtt() const;
void SetRtx(uint8_t payloadType, uint32_t ssrc);
......
......@@ -61,7 +61,7 @@ namespace RTC
public:
StunMessage(
Class klass, Method method, const uint8_t* transactionId, const uint8_t* data, size_t size);
Class klass, Method method, const uint8_t* transactionId, const uint8_t* data, size_t size);
~StunMessage();
void Dump() const;
......@@ -87,7 +87,7 @@ namespace RTC
bool HasMessageIntegrity() const;
bool HasFingerprint() const;
Authentication CheckAuthentication(
const std::string& localUsername, const std::string& localPassword);
const std::string& localUsername, const std::string& localPassword);
StunMessage* CreateSuccessResponse();
StunMessage* CreateErrorResponse(uint16_t errorCode);
void Authenticate(const std::string& password);
......@@ -118,13 +118,13 @@ namespace RTC
inline bool StunMessage::IsStun(const uint8_t* data, size_t len)
{
return (
// STUN headers are 20 bytes.
(len >= 20) &&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(data[0] < 3) &&
// Magic cookie must match.
(data[4] == StunMessage::magicCookie[0]) && (data[5] == StunMessage::magicCookie[1]) &&
(data[6] == StunMessage::magicCookie[2]) && (data[7] == StunMessage::magicCookie[3]));
// STUN headers are 20 bytes.
(len >= 20) &&
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(data[0] < 3) &&
// Magic cookie must match.
(data[4] == StunMessage::magicCookie[0]) && (data[5] == StunMessage::magicCookie[1]) &&
(data[6] == StunMessage::magicCookie[2]) && (data[7] == StunMessage::magicCookie[3]));
}
/* Inline instance methods. */
......
......@@ -20,7 +20,7 @@ namespace RTC
public:
virtual void OnRtcTcpConnectionClosed(
RTC::TcpServer* tcpServer, RTC::TcpConnection* connection, bool isClosedByPeer) = 0;
RTC::TcpServer* tcpServer, RTC::TcpConnection* connection, bool isClosedByPeer) = 0;
};
public:
......
......@@ -84,15 +84,12 @@ 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:
void OnRtcTcpConnectionClosed(
RTC::TcpServer* tcpServer, RTC::TcpConnection* connection, bool isClosedByPeer) override;
RTC::TcpServer* tcpServer, RTC::TcpConnection* connection, bool isClosedByPeer) override;
/* Pure virtual methods inherited from RTC::TcpConnection::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;
......@@ -113,19 +108,19 @@ namespace RTC
public:
void OnDtlsConnecting(const RTC::DtlsTransport* dtlsTransport) override;
void OnDtlsConnected(
const RTC::DtlsTransport* dtlsTransport,
RTC::SrtpSession::Profile srtpProfile,
uint8_t* srtpLocalKey,
size_t srtpLocalKeyLen,
uint8_t* srtpRemoteKey,
size_t srtpRemoteKeyLen,
std::string& remoteCert) override;
const RTC::DtlsTransport* dtlsTransport,
RTC::SrtpSession::Profile srtpProfile,
uint8_t* srtpLocalKey,
size_t srtpLocalKeyLen,
uint8_t* srtpRemoteKey,
size_t srtpRemoteKeyLen,
std::string& remoteCert) override;
void OnDtlsFailed(const RTC::DtlsTransport* dtlsTransport) override;
void OnDtlsClosed(const RTC::DtlsTransport* dtlsTransport) override;
void OnOutgoingDtlsData(
const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) override;
const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) override;
void OnDtlsApplicationData(
const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) override;
const RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) override;
/* Pure virtual methods inherited from RTC::RemoteBitrateEstimator::Listener. */
public:
......@@ -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()
......
......@@ -44,12 +44,12 @@ namespace RTC
/* Inline methods. */
inline TransportTuple::TransportTuple(RTC::UdpSocket* udpSocket, const struct sockaddr* udpRemoteAddr)
: udpSocket(udpSocket), udpRemoteAddr((struct sockaddr*)udpRemoteAddr), protocol(Protocol::UDP)
: udpSocket(udpSocket), udpRemoteAddr((struct sockaddr*)udpRemoteAddr), protocol(Protocol::UDP)
{
}
inline TransportTuple::TransportTuple(RTC::TcpConnection* tcpConnection)
: tcpConnection(tcpConnection), protocol(Protocol::TCP)
: tcpConnection(tcpConnection), protocol(Protocol::TCP)
{
}
......@@ -71,8 +71,8 @@ namespace RTC
if (this->protocol == Protocol::UDP && tuple->GetProtocol() == Protocol::UDP)
{
return (
this->udpSocket == tuple->udpSocket &&
Utils::IP::CompareAddresses(this->udpRemoteAddr, tuple->GetRemoteAddress()));
this->udpSocket == tuple->udpSocket &&
Utils::IP::CompareAddresses(this->udpRemoteAddr, tuple->GetRemoteAddress()));
}
else if (this->protocol == Protocol::TCP && tuple->GetProtocol() == Protocol::TCP)
{
......
......@@ -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;
}
......@@ -290,7 +284,7 @@ namespace Utils
ntp.seconds = tv.tv_sec + UnixNtpOffset;
ntp.fractions =
static_cast<uint32_t>(static_cast<double>(tv.tv_usec) * NtpFractionalUnit * 1.0e-6);
static_cast<uint32_t>(static_cast<double>(tv.tv_usec) * NtpFractionalUnit * 1.0e-6);
}
inline bool Time::IsNewerTimestamp(uint32_t timestamp, uint32_t prevTimestamp)
......
......@@ -45,10 +45,10 @@ public:
void Destroy();
virtual void Dump() const;
void Setup(
Listener* listener,
struct sockaddr_storage* localAddr,
const std::string& localIP,
uint16_t localPort);
Listener* listener,
struct sockaddr_storage* localAddr,
const std::string& localIP,
uint16_t localPort);
bool IsClosing() const;
uv_tcp_t* GetUvHandle() const;
void Start();
......
......@@ -46,7 +46,7 @@ namespace Channel
}
void Notifier::EmitWithBinary(
uint32_t targetId, const std::string& event, const uint8_t* binaryData, size_t binaryLen)
uint32_t targetId, const std::string& event, const uint8_t* binaryData, size_t binaryLen)
{
MS_TRACE();
......@@ -65,11 +65,11 @@ namespace Channel
}
void Notifier::EmitWithBinary(
uint32_t targetId,
const std::string& event,
const uint8_t* binaryData,
size_t binaryLen,
Json::Value& data)
uint32_t targetId,
const std::string& event,
const uint8_t* binaryData,
size_t binaryLen,
Json::Value& data)
{
MS_TRACE();
......
......@@ -201,7 +201,7 @@ namespace Channel
char* jsonStart = nullptr;
size_t jsonLen;
int nsRet = netstring_read(
reinterpret_cast<char*>(this->buffer + this->msgStart), readLen, &jsonStart, &jsonLen);
reinterpret_cast<char*>(this->buffer + this->msgStart), readLen, &jsonStart, &jsonLen);
if (nsRet != 0)
{
......@@ -224,8 +224,8 @@ namespace Channel
else
{
MS_ERROR_STD(
"no more space in the buffer for the unfinished message being parsed, "
"discarding it");
"no more space in the buffer for the unfinished message being parsed, "
"discarding it");
this->msgStart = 0;
this->bufferDataLen = 0;
......@@ -266,14 +266,14 @@ 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;
if (this->jsonReader->parse(
(const char*)jsonStart, (const char*)jsonStart + jsonLen, &json, &jsonParseError))
(const char*)jsonStart, (const char*)jsonStart + jsonLen, &json, &jsonParseError))
{
Channel::Request* request = nullptr;
......
......@@ -18,8 +18,8 @@ namespace RTC
/* Instance methods. */
Consumer::Consumer(
Channel::Notifier* notifier, uint32_t consumerId, RTC::Media::Kind kind, uint32_t sourceProducerId)
: consumerId(consumerId), kind(kind), sourceProducerId(sourceProducerId), notifier(notifier)
Channel::Notifier* notifier, uint32_t consumerId, RTC::Media::Kind kind, uint32_t sourceProducerId)
: consumerId(consumerId), kind(kind), sourceProducerId(sourceProducerId), notifier(notifier)
{
MS_TRACE();
......@@ -252,7 +252,7 @@ namespace RTC
// Build SDES chunk for this sender.
auto sdesChunk = new RTC::RTCP::SdesChunk(ssrc);
auto sdesItem =
new RTC::RTCP::SdesItem(RTC::RTCP::SdesItem::Type::CNAME, cname.size(), cname.c_str());
new RTC::RTCP::SdesItem(RTC::RTCP::SdesItem::Type::CNAME, cname.size(), cname.c_str());
sdesChunk->AddItem(sdesItem);
packet->AddSdesChunk(sdesChunk);
......@@ -271,7 +271,7 @@ namespace RTC
RTC::RTCP::FeedbackRtpNackItem* item = *it;
this->rtpStream->RequestRtpRetransmission(
item->GetPacketId(), item->GetLostPacketBitmask(), RtpRetransmissionContainer);
item->GetPacketId(), item->GetLostPacketBitmask(), RtpRetransmissionContainer);
auto it2 = RtpRetransmissionContainer.begin();
for (; it2 != RtpRetransmissionContainer.end(); ++it2)
......@@ -386,22 +386,22 @@ namespace RTC
this->rtpStream->RtxEncode(rtxPacket);
MS_DEBUG_TAG(
rtx,
"sending rtx packet [ssrc: %" PRIu32 " seqnr: %" PRIu16
"] recovering original [ssrc: %" PRIu32 " seqnr: %" PRIu16 "]",
rtxPacket->GetSsrc(),
rtxPacket->GetSequenceNumber(),
packet->GetSsrc(),
packet->GetSequenceNumber());
rtx,
"sending rtx packet [ssrc: %" PRIu32 " seqnr: %" PRIu16
"] recovering original [ssrc: %" PRIu32 " seqnr: %" PRIu16 "]",
rtxPacket->GetSsrc(),
rtxPacket->GetSequenceNumber(),
packet->GetSsrc(),
packet->GetSequenceNumber());
}
else
{
rtxPacket = packet;
MS_DEBUG_TAG(
rtx,
"retransmitting packet [ssrc: %" PRIu32 " seqnr: %" PRIu16 "]",
rtxPacket->GetSsrc(),
rtxPacket->GetSequenceNumber());
rtx,
"retransmitting packet [ssrc: %" PRIu32 " seqnr: %" PRIu16 "]",
rtxPacket->GetSsrc(),
rtxPacket->GetSequenceNumber());
}
// Update retransmitted RTP data counter.
......
......@@ -95,8 +95,9 @@ namespace RTC
MS_TRACE();
// Generate a X509 certificate and private key (unless PEM files are provided).
if (Settings::configuration.dtlsCertificateFile.empty() ||
Settings::configuration.dtlsPrivateKeyFile.empty())
if (
Settings::configuration.dtlsCertificateFile.empty() ||
Settings::configuration.dtlsPrivateKeyFile.empty())
{
GenerateCertificateAndPrivateKey();
}
......@@ -195,8 +196,8 @@ namespace RTC
// Set serial number (avoid default 0).
ASN1_INTEGER_set(
X509_get_serialNumber(DtlsTransport::certificate),
static_cast<uint64_t>(Utils::Crypto::GetRandomUInt(1000000, 9999999)));
X509_get_serialNumber(DtlsTransport::certificate),
static_cast<uint64_t>(Utils::Crypto::GetRandomUInt(1000000, 9999999)));
// Set valid period.
X509_gmtime_adj(X509_get_notBefore(DtlsTransport::certificate), -315360000); // -10 years.
......@@ -218,9 +219,9 @@ namespace RTC
goto error;
}
X509_NAME_add_entry_by_txt(
certName, "O", MBSTRING_ASC, reinterpret_cast<const uint8_t*>("mediasoup"), -1, -1, 0);
certName, "O", MBSTRING_ASC, reinterpret_cast<const uint8_t*>("mediasoup"), -1, -1, 0);
X509_NAME_add_entry_by_txt(
certName, "CN", MBSTRING_ASC, reinterpret_cast<const uint8_t*>("mediasoup"), -1, -1, 0);
certName, "CN", MBSTRING_ASC, reinterpret_cast<const uint8_t*>("mediasoup"), -1, -1, 0);
// It is self-signed so set the issuer name to be the same as the subject.
ret = X509_set_issuer_name(DtlsTransport::certificate, certName);
......@@ -349,8 +350,8 @@ namespace RTC
// Set options.
SSL_CTX_set_options(
DtlsTransport::sslCtx,
SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_NO_TICKET | SSL_OP_SINGLE_ECDH_USE);
DtlsTransport::sslCtx,
SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_NO_TICKET | SSL_OP_SINGLE_ECDH_USE);
// Don't use sessions cache.
SSL_CTX_set_session_cache_mode(DtlsTransport::sslCtx, SSL_SESS_CACHE_OFF);
......@@ -364,16 +365,14 @@ 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);
// Set ciphers.
ret = SSL_CTX_set_cipher_list(
DtlsTransport::sslCtx, "ALL:!ADH:!LOW:!EXP:!MD5:!aNULL:!eNULL:@STRENGTH");
DtlsTransport::sslCtx, "ALL:!ADH:!LOW:!EXP:!MD5:!aNULL:!eNULL:@STRENGTH");
if (ret == 0)
{
LOG_OPENSSL_ERROR("SSL_CTX_set_cipher_list() failed");
......@@ -600,12 +599,12 @@ namespace RTC
MS_DUMP("<DtlsTransport>");
MS_DUMP(
" [role:%s, running:%s, handshake done:%s, connected:%s]",
(this->localRole == Role::SERVER ? "server"
: (this->localRole == Role::CLIENT ? "client" : "none")),
IsRunning() ? "yes" : "no",
this->handshakeDone ? "yes" : "no",
this->state == DtlsState::CONNECTED ? "yes" : "no");
" [role:%s, running:%s, handshake done:%s, connected:%s]",
(this->localRole == Role::SERVER ? "server"
: (this->localRole == Role::CLIENT ? "client" : "none")),
IsRunning() ? "yes" : "no",
this->handshakeDone ? "yes" : "no",
this->state == DtlsState::CONNECTED ? "yes" : "no");
MS_DUMP("</DtlsTransport>");
}
......@@ -614,8 +613,8 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
localRole == Role::CLIENT || localRole == Role::SERVER,
"local DTLS role must be 'client' or 'server'");
localRole == Role::CLIENT || localRole == Role::SERVER,
"local DTLS role must be 'client' or 'server'");
Role previousLocalRole = this->localRole;
......@@ -669,7 +668,7 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
fingerprint.algorithm != FingerprintAlgorithm::NONE, "no fingerprint algorithm provided");
fingerprint.algorithm != FingerprintAlgorithm::NONE, "no fingerprint algorithm provided");
this->remoteFingerprint = fingerprint;
......@@ -702,10 +701,10 @@ namespace RTC
if (written != static_cast<int>(len))
{
MS_WARN_TAG(
dtls,
"OpenSSL BIO_write() wrote less (%zu bytes) than given data (%zu bytes)",
static_cast<size_t>(written),
len);
dtls,
"OpenSSL BIO_write() wrote less (%zu bytes) than given data (%zu bytes)",
static_cast<size_t>(written),
len);
}
// Must call SSL_read() to process received DTLS data.
......@@ -735,7 +734,7 @@ namespace RTC
// Notify the listener.
this->listener->OnDtlsApplicationData(
this, (uint8_t*)DtlsTransport::sslReadBuffer, static_cast<size_t>(read));
this, (uint8_t*)DtlsTransport::sslReadBuffer, static_cast<size_t>(read));
}
}
......@@ -770,7 +769,7 @@ namespace RTC
else if (written != static_cast<int>(len))
{
MS_WARN_TAG(
dtls, "OpenSSL SSL_write() wrote less (%d bytes) than given data (%zu bytes)", written, len);
dtls, "OpenSSL SSL_write() wrote less (%d bytes) than given data (%zu bytes)", written, len);
}
// Send data.
......@@ -909,7 +908,7 @@ namespace RTC
// Notify the listener.
this->listener->OnOutgoingDtlsData(
this, reinterpret_cast<uint8_t*>(data), static_cast<size_t>(read));
this, reinterpret_cast<uint8_t*>(data), static_cast<size_t>(read));
// Clear the BIO buffer.
// NOTE: the (void) avoids the -Wunused-value warning.
......@@ -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];
......@@ -1073,10 +1071,10 @@ namespace RTC
if (this->remoteFingerprint.value != hexFingerprint)
{
MS_WARN_TAG(
dtls,
"fingerprint in the remote certificate (%s) does not match the announced one (%s)",
hexFingerprint,
this->remoteFingerprint.value.c_str());
dtls,
"fingerprint in the remote certificate (%s) does not match the announced one (%s)",
hexFingerprint,
this->remoteFingerprint.value.c_str());
X509_free(certificate);
......@@ -1140,7 +1138,7 @@ namespace RTC
int ret;
ret = SSL_export_keying_material(
this->ssl, srtpMaterial, SrtpMasterLength * 2, "EXTRACTOR-dtls_srtp", 19, nullptr, 0, 0);
this->ssl, srtpMaterial, SrtpMasterLength * 2, "EXTRACTOR-dtls_srtp", 19, nullptr, 0, 0);
MS_ASSERT(ret != 0, "SSL_export_keying_material() failed");
......@@ -1173,13 +1171,13 @@ namespace RTC
// Set state and notify the listener.
this->state = DtlsState::CONNECTED;
this->listener->OnDtlsConnected(
this,
srtpProfile,
srtpLocalMasterKey,
SrtpMasterLength,
srtpRemoteMasterKey,
SrtpMasterLength,
this->remoteCert);
this,
srtpProfile,
srtpLocalMasterKey,
SrtpMasterLength,
srtpRemoteMasterKey,
SrtpMasterLength,
this->remoteCert);
}
inline RTC::SrtpSession::Profile DtlsTransport::GetNegotiatedSrtpProfile()
......@@ -1210,8 +1208,8 @@ namespace RTC
}
MS_ASSERT(
negotiatedSrtpProfile != RTC::SrtpSession::Profile::NONE,
"chosen SRTP profile is not an available one");
negotiatedSrtpProfile != RTC::SrtpSession::Profile::NONE,
"chosen SRTP profile is not an available one");
return negotiatedSrtpProfile;
}
......
......@@ -9,8 +9,8 @@ namespace RTC
/* Instance methods. */
IceCandidate::IceCandidate(RTC::UdpSocket* udpSocket, uint32_t priority)
: foundation("udpcandidate"), priority(priority), family(udpSocket->GetLocalFamily()),
protocol(Protocol::UDP), port(udpSocket->GetLocalPort()), type(CandidateType::HOST)
: foundation("udpcandidate"), priority(priority), family(udpSocket->GetLocalFamily()),
protocol(Protocol::UDP), port(udpSocket->GetLocalPort()), type(CandidateType::HOST)
{
switch (this->family)
{
......@@ -37,8 +37,8 @@ namespace RTC
}
IceCandidate::IceCandidate(RTC::TcpServer* tcpServer, uint32_t priority)
: foundation("tcpcandidate"), priority(priority), family(tcpServer->GetLocalFamily()),
protocol(Protocol::TCP), port(tcpServer->GetLocalPort()), type(CandidateType::HOST)
: foundation("tcpcandidate"), priority(priority), family(tcpServer->GetLocalFamily()),
protocol(Protocol::TCP), port(tcpServer->GetLocalPort()), type(CandidateType::HOST)
{
switch (this->family)
{
......
......@@ -16,16 +16,16 @@ namespace RTC
/* Instance methods. */
IceServer::IceServer(Listener* listener, std::string usernameFragment, std::string password)
: listener(listener), usernameFragment(std::move(usernameFragment)),
password(std::move(password))
: listener(listener), usernameFragment(std::move(usernameFragment)),
password(std::move(password))
{
MS_TRACE();
MS_DEBUG_TAG(
ice,
"[usernameFragment:%s, password:%s]",
this->usernameFragment.c_str(),
this->password.c_str());
ice,
"[usernameFragment:%s, password:%s]",
this->usernameFragment.c_str(),
this->password.c_str());
}
void IceServer::Destroy()
......@@ -45,7 +45,7 @@ namespace RTC
if (msg->GetClass() == RTC::StunMessage::Class::REQUEST)
{
MS_WARN_TAG(
ice, "unknown method %#.3x in STUN Request => 400", (unsigned int)msg->GetMethod());
ice, "unknown method %#.3x in STUN Request => 400", (unsigned int)msg->GetMethod());
// Reply 400.
RTC::StunMessage* response = msg->CreateErrorResponse(400);
......@@ -57,9 +57,9 @@ namespace RTC
else
{
MS_WARN_TAG(
ice,
"ignoring STUN Indication or Response with unknown method %#.3x",
(unsigned int)msg->GetMethod());
ice,
"ignoring STUN Indication or Response with unknown method %#.3x",
(unsigned int)msg->GetMethod());
}
return;
......@@ -159,9 +159,9 @@ namespace RTC
// }
MS_DEBUG_DEV(
"processing STUN Binding Request [Priority:%" PRIu32 ", UseCandidate:%s]",
static_cast<uint32_t>(msg->GetPriority()),
msg->HasUseCandidate() ? "true" : "false");
"processing STUN Binding Request [Priority:%" PRIu32 ", UseCandidate:%s]",
static_cast<uint32_t>(msg->GetPriority()),
msg->HasUseCandidate() ? "true" : "false");
// Create a success response.
RTC::StunMessage* response = msg->CreateSuccessResponse();
......@@ -266,14 +266,14 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->selectedTuple != nullptr,
"cannot force the selected tuple if there was not a selected tuple");
this->selectedTuple != nullptr,
"cannot force the selected tuple if there was not a selected tuple");
auto storedTuple = HasTuple(tuple);
MS_ASSERT(
storedTuple,
"cannot force the selected tuple if the given tuple was not already a valid tuple");
storedTuple,
"cannot force the selected tuple if the given tuple was not already a valid tuple");
// Mark it as selected tuple.
SetSelectedTuple(storedTuple);
......@@ -289,7 +289,7 @@ namespace RTC
{
// There should be no tuples.
MS_ASSERT(
this->tuples.empty(), "state is 'new' but there are %zu tuples", this->tuples.size());
this->tuples.empty(), "state is 'new' but there are %zu tuples", this->tuples.size());
// There shouldn't be a selected tuple.
MS_ASSERT(this->selectedTuple == nullptr, "state is 'new' but there is selected tuple");
......@@ -330,13 +330,13 @@ namespace RTC
{
// There should be no tuples.
MS_ASSERT(
this->tuples.empty(),
"state is 'disconnected' but there are %zu tuples",
this->tuples.size());
this->tuples.empty(),
"state is 'disconnected' but there are %zu tuples",
this->tuples.size());
// There shouldn't be a selected tuple.
MS_ASSERT(
this->selectedTuple == nullptr, "state is 'disconnected' but there is selected tuple");
this->selectedTuple == nullptr, "state is 'disconnected' but there is selected tuple");
if (!hasUseCandidate)
{
......@@ -377,7 +377,7 @@ namespace RTC
// There should be a selected tuple.
MS_ASSERT(
this->selectedTuple != nullptr, "state is 'connected' but there is not selected tuple");
this->selectedTuple != nullptr, "state is 'connected' but there is not selected tuple");
if (!hasUseCandidate)
{
......@@ -413,7 +413,7 @@ namespace RTC
// There should be a selected tuple.
MS_ASSERT(
this->selectedTuple != nullptr, "state is 'completed' but there is not selected tuple");
this->selectedTuple != nullptr, "state is 'completed' but there is not selected tuple");
if (!hasUseCandidate)
{
......
......@@ -68,10 +68,10 @@ namespace RTC
if (it != this->nackList.end())
{
MS_DEBUG_TAG(
rtx,
"nacked packet received [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
rtx,
"nacked packet received [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
this->nackList.erase(it);
}
......@@ -79,10 +79,10 @@ namespace RTC
else
{
MS_DEBUG_TAG(
rtx,
"out of order packet received [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
rtx,
"out of order packet received [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
}
return;
......@@ -133,7 +133,7 @@ namespace RTC
NackInfo nackInfo(seq32, sendAtSeqNum);
MS_ASSERT(
this->nackList.find(seq32) == this->nackList.end(), "packet already in the NACK list");
this->nackList.find(seq32) == this->nackList.end(), "packet already in the NACK list");
this->nackList[seq32] = nackInfo;
}
......@@ -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;
......@@ -159,9 +158,9 @@ namespace RTC
if (nackInfo.retries >= MaxNackRetries)
{
MS_WARN_TAG(
rtx,
"sequence number removed from the NACK list due to max retries [seq:%" PRIu16 "]",
seq);
rtx,
"sequence number removed from the NACK list due to max retries [seq:%" PRIu16 "]",
seq);
it = this->nackList.erase(it);
}
......@@ -182,9 +181,9 @@ namespace RTC
if (nackInfo.retries >= MaxNackRetries)
{
MS_WARN_TAG(
rtx,
"sequence number removed from the NACK list due to max retries [seq:%" PRIu16 "]",
seq);
rtx,
"sequence number removed from the NACK list due to max retries [seq:%" PRIu16 "]",
seq);
it = this->nackList.erase(it);
}
......
......@@ -16,7 +16,7 @@ namespace RTC
/* Instance methods. */
Peer::Peer(Listener* listener, Channel::Notifier* notifier, uint32_t peerId, std::string& peerName)
: peerId(peerId), peerName(peerName), listener(listener), notifier(notifier)
: peerId(peerId), peerName(peerName), listener(listener), notifier(notifier)
{
MS_TRACE();
......@@ -380,7 +380,7 @@ namespace RTC
}
void Peer::AddConsumer(
RTC::Consumer* consumer, RTC::RtpParameters* rtpParameters, uint32_t associatedProducerId)
RTC::Consumer* consumer, RTC::RtpParameters* rtpParameters, uint32_t associatedProducerId)
{
MS_TRACE();
......@@ -391,8 +391,8 @@ namespace RTC
static const Json::StaticString JsonStringAssociatedProducerId{ "associatedProducerId" };
MS_ASSERT(
this->consumers.find(consumer->consumerId) == this->consumers.end(),
"given Consumer already exists in this Peer");
this->consumers.find(consumer->consumerId) == this->consumers.end(),
"given Consumer already exists in this Peer");
// Provide the Consumer with the received RTP parameters.
consumer->Send(rtpParameters);
......@@ -658,9 +658,9 @@ namespace RTC
else
{
MS_WARN_TAG(
rtcp,
"no Consumer found for received Receiver Report [ssrc:%" PRIu32 "]",
report->GetSsrc());
rtcp,
"no Consumer found for received Receiver Report [ssrc:%" PRIu32 "]",
report->GetSsrc());
}
}
......@@ -705,12 +705,12 @@ namespace RTC
else
{
MS_WARN_TAG(
rtcp,
"no Consumer found for received %s Feedback packet "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
RTCP::FeedbackPsPacket::MessageType2String(feedback->GetMessageType()).c_str(),
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
rtcp,
"no Consumer found for received %s Feedback packet "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
RTCP::FeedbackPsPacket::MessageType2String(feedback->GetMessageType()).c_str(),
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
}
break;
......@@ -725,12 +725,12 @@ namespace RTC
default:
{
MS_WARN_TAG(
rtcp,
"ignoring unsupported %s Feedback packet "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
RTCP::FeedbackPsPacket::MessageType2String(feedback->GetMessageType()).c_str(),
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
rtcp,
"ignoring unsupported %s Feedback packet "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
RTCP::FeedbackPsPacket::MessageType2String(feedback->GetMessageType()).c_str(),
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
break;
}
......@@ -758,11 +758,11 @@ namespace RTC
else
{
MS_WARN_TAG(
rtcp,
"no Consumer found for received NACK Feedback packet "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
rtcp,
"no Consumer found for received NACK Feedback packet "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
}
break;
......@@ -779,12 +779,12 @@ namespace RTC
default:
{
MS_WARN_TAG(
rtcp,
"ignoring unsupported %s Feedback packet "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
RTCP::FeedbackRtpPacket::MessageType2String(feedback->GetMessageType()).c_str(),
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
rtcp,
"ignoring unsupported %s Feedback packet "
"[sender ssrc:%" PRIu32 ", media ssrc:%" PRIu32 "]",
RTCP::FeedbackRtpPacket::MessageType2String(feedback->GetMessageType()).c_str(),
feedback->GetMediaSsrc(),
feedback->GetMediaSsrc());
break;
}
......@@ -815,9 +815,9 @@ namespace RTC
else
{
MS_WARN_TAG(
rtcp,
"no Producer found for received Sender Report [ssrc:%" PRIu32 "]",
report->GetSsrc());
rtcp,
"no Producer found for received Sender Report [ssrc:%" PRIu32 "]",
report->GetSsrc());
}
}
......@@ -838,7 +838,7 @@ namespace RTC
if (producer == nullptr)
{
MS_WARN_TAG(
rtcp, "no Producer for received SDES chunk [ssrc:%" PRIu32 "]", chunk->GetSsrc());
rtcp, "no Producer for received SDES chunk [ssrc:%" PRIu32 "]", chunk->GetSsrc());
}
}
......@@ -855,9 +855,9 @@ namespace RTC
default:
{
MS_WARN_TAG(
rtcp,
"unhandled RTCP type received [type:%" PRIu8 "]",
static_cast<uint8_t>(packet->GetType()));
rtcp,
"unhandled RTCP type received [type:%" PRIu8 "]",
static_cast<uint8_t>(packet->GetType()));
}
}
......
......@@ -18,15 +18,15 @@ namespace RTC
/* Instance methods. */
Producer::Producer(
Channel::Notifier* notifier,
uint32_t producerId,
RTC::Media::Kind kind,
RTC::Transport* transport,
RTC::RtpParameters& rtpParameters,
struct RtpMapping& rtpMapping,
bool paused)
: producerId(producerId), kind(kind), notifier(notifier), transport(transport),
rtpParameters(rtpParameters), paused(paused)
Channel::Notifier* notifier,
uint32_t producerId,
RTC::Media::Kind kind,
RTC::Transport* transport,
RTC::RtpParameters& rtpParameters,
struct RtpMapping& rtpMapping,
bool paused)
: producerId(producerId), kind(kind), notifier(notifier), transport(transport),
rtpParameters(rtpParameters), paused(paused)
{
MS_TRACE();
......@@ -298,7 +298,7 @@ namespace RTC
eventData[JsonStringObject] = jsonObject;
this->notifier->EmitWithBinary(
this->producerId, "rtpobject", packet->GetPayload(), packet->GetPayloadLength(), eventData);
this->producerId, "rtpobject", packet->GetPayload(), packet->GetPayloadLength(), eventData);
}
// Apply the Producer RTP mapping before dispatching the packet to the Router.
......@@ -407,8 +407,9 @@ namespace RTC
for (auto& exten : this->rtpParameters.headerExtensions)
{
if (this->kind == RTC::Media::Kind::AUDIO && (ssrcAudioLevelId == 0u) &&
exten.type == RTC::RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL)
if (
this->kind == RTC::Media::Kind::AUDIO && (ssrcAudioLevelId == 0u) &&
exten.type == RTC::RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL)
{
if (idMapping.find(exten.id) != idMapping.end())
ssrcAudioLevelId = idMapping[exten.id];
......@@ -528,14 +529,13 @@ 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)
{
packet->AddExtensionMapping(
RtpHeaderExtensionUri::Type::ABS_SEND_TIME, this->knownHeaderExtensions.absSendTimeId);
RtpHeaderExtensionUri::Type::ABS_SEND_TIME, this->knownHeaderExtensions.absSendTimeId);
}
}
......
......@@ -52,9 +52,9 @@ namespace RTC
{
// Fix header length field.
size_t length =
((sizeof(SenderReport::Header) +
(sizeof(ReceiverReport::Header) * this->receiverReportPacket.GetCount())) /
4);
((sizeof(SenderReport::Header) +
(sizeof(ReceiverReport::Header) * this->receiverReportPacket.GetCount())) /
4);
header->length = uint16_t{ htons(length) };
......
......@@ -42,17 +42,17 @@ namespace RTC
template<typename T>
FeedbackPacket<T>::FeedbackPacket(CommonHeader* commonHeader)
: Packet(RTCP::Type(commonHeader->packetType)),
messageType(typename T::MessageType(commonHeader->count))
: Packet(RTCP::Type(commonHeader->packetType)),
messageType(typename T::MessageType(commonHeader->count))
{
this->header =
reinterpret_cast<Header*>(reinterpret_cast<uint8_t*>(commonHeader) + sizeof(CommonHeader));
reinterpret_cast<Header*>(reinterpret_cast<uint8_t*>(commonHeader) + sizeof(CommonHeader));
}
template<typename T>
FeedbackPacket<T>::FeedbackPacket(
typename T::MessageType messageType, uint32_t senderSsrc, uint32_t mediaSsrc)
: Packet(rtcpType), messageType(messageType)
typename T::MessageType messageType, uint32_t senderSsrc, uint32_t mediaSsrc)
: Packet(rtcpType), messageType(messageType)
{
this->raw = new uint8_t[sizeof(Header)];
this->header = reinterpret_cast<Header*>(this->raw);
......@@ -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;
......@@ -260,9 +258,9 @@ namespace RTC
default:
MS_WARN_TAG(
rtcp,
"unknown RTCP RTP Feedback message type [packetType:%" PRIu8 "]",
commonHeader->count);
rtcp,
"unknown RTCP RTP Feedback message type [packetType:%" PRIu8 "]",
commonHeader->count);
}
return packet;
......
......@@ -31,7 +31,7 @@ namespace RTC
auto* commonHeader = const_cast<CommonHeader*>(reinterpret_cast<const CommonHeader*>(data));
std::unique_ptr<FeedbackPsItemsPacket<Item>> packet(
new FeedbackPsItemsPacket<Item>(commonHeader));
new FeedbackPsItemsPacket<Item>(commonHeader));
size_t offset = sizeof(CommonHeader) + sizeof(FeedbackPacket::Header);
......
......@@ -38,7 +38,7 @@ namespace RTC
}
FeedbackPsRembPacket::FeedbackPsRembPacket(CommonHeader* commonHeader)
: FeedbackPsAfbPacket(commonHeader, FeedbackPsAfbPacket::Application::REMB)
: FeedbackPsAfbPacket(commonHeader, FeedbackPsAfbPacket::Application::REMB)
{
auto* data = reinterpret_cast<uint8_t*>(commonHeader + 1);
......@@ -53,7 +53,7 @@ namespace RTC
size_t numSsrcs = data[12];
uint8_t exponent = data[13] >> 2;
uint64_t mantissa =
(static_cast<uint32_t>(data[13] & 0x03) << 16) | Utils::Byte::Get2Bytes(data, 14);
(static_cast<uint32_t>(data[13] & 0x03) << 16) | Utils::Byte::Get2Bytes(data, 14);
this->bitrate = (mantissa << exponent);
if ((this->bitrate >> exponent) != mantissa)
......@@ -67,11 +67,10 @@ 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);
rtcp, "invalid payload size (%zu bytes) for the given number of ssrcs (%zu)", len, numSsrcs);
this->isCorrect = false;
return;
......
......@@ -67,8 +67,8 @@ namespace RTC
MS_ASSERT(payloadType <= 0x7f, "rpsi payload type exceeds the maximum value");
MS_ASSERT(
length <= FeedbackPsRpsiItem::maxBitStringSize,
"rpsi bit string length exceeds the maximum value");
length <= FeedbackPsRpsiItem::maxBitStringSize,
"rpsi bit string length exceeds the maximum value");
this->raw = new uint8_t[sizeof(Header)];
this->header = reinterpret_cast<Header*>(this->raw);
......
......@@ -71,13 +71,13 @@ namespace RTC
template<>
const FeedbackPs::MessageType FeedbackPsTstItem<Tstr>::messageType =
FeedbackPs::MessageType::TSTR;
FeedbackPs::MessageType::TSTR;
/* Specialization for Tstn class. */
template<>
const FeedbackPs::MessageType FeedbackPsTstItem<Tstn>::messageType =
FeedbackPs::MessageType::TSTN;
FeedbackPs::MessageType::TSTN;
// Explicit instantiation to have all definitions in this file.
template class FeedbackPsTstItem<Tstr>;
......
......@@ -30,7 +30,7 @@ namespace RTC
/* Instance methods. */
FeedbackPsVbcmItem::FeedbackPsVbcmItem(
uint32_t ssrc, uint8_t sequenceNumber, uint8_t payloadType, uint16_t length, uint8_t* value)
uint32_t ssrc, uint8_t sequenceNumber, uint8_t payloadType, uint16_t length, uint8_t* value)
{
this->raw = new uint8_t[8 + length];
this->header = reinterpret_cast<Header*>(this->raw);
......
......@@ -29,7 +29,7 @@ namespace RTC
auto* commonHeader = const_cast<CommonHeader*>(reinterpret_cast<const CommonHeader*>(data));
std::unique_ptr<FeedbackRtpItemsPacket<Item>> packet(
new FeedbackRtpItemsPacket<Item>(commonHeader));
new FeedbackRtpItemsPacket<Item>(commonHeader));
size_t offset = sizeof(CommonHeader) + sizeof(FeedbackPacket::Header);
......
......@@ -95,13 +95,13 @@ namespace RTC
template<>
const FeedbackRtp::MessageType FeedbackRtpTmmbItem<FeedbackRtpTmmbr>::messageType =
FeedbackRtp::MessageType::TMMBR;
FeedbackRtp::MessageType::TMMBR;
/* Specialization for Tmmbn class. */
template<>
const FeedbackRtp::MessageType FeedbackRtpTmmbItem<FeedbackRtpTmmbn>::messageType =
FeedbackRtp::MessageType::TMMBN;
FeedbackRtp::MessageType::TMMBN;
// Explicit instantiation to have all FeedbackRtpTmmbItem definitions in this file.
template class FeedbackRtpTmmbItem<FeedbackRtpTmmbr>;
......
......@@ -60,11 +60,11 @@ namespace RTC
if (len < packetLlen)
{
MS_WARN_TAG(
rtcp,
"packet length exceeds remaining data [len:%zu, "
"packet len:%zu]",
len,
packetLlen);
rtcp,
"packet length exceeds remaining data [len:%zu, "
"packet len:%zu]",
len,
packetLlen);
return first;
}
......@@ -142,12 +142,12 @@ namespace RTC
if (Type(header->packetType) == Type::PSFB)
{
packetType +=
" " + FeedbackPsPacket::MessageType2String(FeedbackPs::MessageType(header->count));
" " + FeedbackPsPacket::MessageType2String(FeedbackPs::MessageType(header->count));
}
else if (Type(header->packetType) == Type::RTPFB)
{
packetType +=
" " + FeedbackRtpPacket::MessageType2String(FeedbackRtp::MessageType(header->count));
" " + FeedbackRtpPacket::MessageType2String(FeedbackRtp::MessageType(header->count));
}
MS_WARN_TAG(rtcp, "error parsing %s Packet", packetType.c_str());
......
......@@ -74,7 +74,7 @@ namespace RTC
std::unique_ptr<ReceiverReportPacket> packet(new ReceiverReportPacket());
packet->SetSsrc(
Utils::Byte::Get4Bytes(reinterpret_cast<uint8_t*>(header), sizeof(CommonHeader)));
Utils::Byte::Get4Bytes(reinterpret_cast<uint8_t*>(header), sizeof(CommonHeader)));
if (offset == 0)
offset = sizeof(Packet::CommonHeader) + sizeof(uint32_t) /* ssrc */;
......
......@@ -31,7 +31,7 @@ namespace RTC
const int64_t minFeedbackIntervalMs{ 200 };
auto interval =
int64_t{ std::lround((RtcpSize * 8.0 * 1000.0) / (0.05 * this->currentBitrateBps) + 0.5) };
int64_t{ std::lround((RtcpSize * 8.0 * 1000.0) / (0.05 * this->currentBitrateBps) + 0.5) };
return std::min(std::max(interval, minFeedbackIntervalMs), MaxFeedbackIntervalMs);
}
......@@ -115,7 +115,7 @@ namespace RTC
}
uint32_t AimdRateControl::ChangeBitrate(
uint32_t newBitrateBps, uint32_t incomingBitrateBps, int64_t nowMs)
uint32_t newBitrateBps, uint32_t incomingBitrateBps, int64_t nowMs)
{
MS_TRACE();
......@@ -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;
......@@ -158,7 +157,7 @@ namespace RTC
else
{
uint32_t multiplicativeIncreaseBps =
MultiplicativeRateIncrease(nowMs, this->timeLastBitrateChange, newBitrateBps);
MultiplicativeRateIncrease(nowMs, this->timeLastBitrateChange, newBitrateBps);
newBitrateBps += multiplicativeIncreaseBps;
}
......@@ -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);
......@@ -223,7 +222,7 @@ namespace RTC
}
uint32_t AimdRateControl::MultiplicativeRateIncrease(
int64_t nowMs, int64_t lastMs, uint32_t currentBitrateBps) const
int64_t nowMs, int64_t lastMs, uint32_t currentBitrateBps) const
{
MS_TRACE();
......@@ -262,7 +261,7 @@ namespace RTC
this->varMaxBitrateKbps = (1 - alpha) * this->varMaxBitrateKbps +
alpha * (this->avgMaxBitrateKbps - incomingBitrateKbps) *
(this->avgMaxBitrateKbps - incomingBitrateKbps) / norm;
(this->avgMaxBitrateKbps - incomingBitrateKbps) / norm;
// 0.4 ~= 14 kbit/s at 500 kbit/s
if (this->varMaxBitrateKbps < 0.4f)
......
......@@ -22,13 +22,13 @@ namespace RTC
static const int BurstDeltaThresholdMs{ 5 };
bool InterArrival::ComputeDeltas(
uint32_t timestamp,
int64_t arrivalTimeMs,
int64_t systemTimeMs,
size_t packetSize,
uint32_t* timestampDelta,
int64_t* arrivalTimeDeltaMs,
int* packetSizeDelta)
uint32_t timestamp,
int64_t arrivalTimeMs,
int64_t systemTimeMs,
size_t packetSize,
uint32_t* timestampDelta,
int64_t* arrivalTimeDeltaMs,
int* packetSizeDelta)
{
MS_TRACE();
......@@ -56,20 +56,20 @@ namespace RTC
{
*timestampDelta = this->currentTimestampGroup.timestamp - this->prevTimestampGroup.timestamp;
*arrivalTimeDeltaMs =
this->currentTimestampGroup.completeTimeMs - this->prevTimestampGroup.completeTimeMs;
this->currentTimestampGroup.completeTimeMs - this->prevTimestampGroup.completeTimeMs;
// Check system time differences to see if we have an unproportional jump
// in arrival time. In that case reset the inter-arrival computations.
int64_t systemTimeDeltaMs =
this->currentTimestampGroup.lastSystemTimeMs - this->prevTimestampGroup.lastSystemTimeMs;
this->currentTimestampGroup.lastSystemTimeMs - this->prevTimestampGroup.lastSystemTimeMs;
if (*arrivalTimeDeltaMs - systemTimeDeltaMs >= ArrivalTimeOffsetThresholdMs)
{
MS_WARN_TAG(
rbe,
"the arrival time clock offset has changed, resetting"
"[diff:%" PRId64 "ms]",
*arrivalTimeDeltaMs - systemTimeDeltaMs);
rbe,
"the arrival time clock offset has changed, resetting"
"[diff:%" PRId64 "ms]",
*arrivalTimeDeltaMs - systemTimeDeltaMs);
Reset();
......@@ -84,10 +84,10 @@ namespace RTC
if (this->numConsecutiveReorderedPackets >= ReorderedResetThreshold)
{
MS_WARN_TAG(
rbe,
"packets are being reordered on the path from the "
"socket to the bandwidth estimator, ignoring this "
"packet for bandwidth estimation, resetting");
rbe,
"packets are being reordered on the path from the "
"socket to the bandwidth estimator, ignoring this "
"packet for bandwidth estimation, resetting");
Reset();
}
......@@ -112,7 +112,7 @@ namespace RTC
else
{
this->currentTimestampGroup.timestamp =
Utils::Time::LatestTimestamp(this->currentTimestampGroup.timestamp, timestamp);
Utils::Time::LatestTimestamp(this->currentTimestampGroup.timestamp, timestamp);
}
// Accumulate the frame size.
......@@ -167,7 +167,7 @@ namespace RTC
int64_t arrivalTimeDeltaMs = arrivalTimeMs - this->currentTimestampGroup.completeTimeMs;
uint32_t timestampDiff = timestamp - this->currentTimestampGroup.timestamp;
auto tsDeltaMs =
static_cast<int64_t>(std::lround(this->timestampToMsCoeff * timestampDiff + 0.5));
static_cast<int64_t>(std::lround(this->timestampToMsCoeff * timestampDiff + 0.5));
if (tsDeltaMs == 0)
return true;
......
......@@ -24,7 +24,7 @@ namespace RTC
constexpr uint16_t DeltaCounterMax{ 1000 };
void OveruseEstimator::Update(
int64_t tDelta, double tsDelta, int sizeDelta, BandwidthUsage currentHypothesis, int64_t nowMs)
int64_t tDelta, double tsDelta, int sizeDelta, BandwidthUsage currentHypothesis, int64_t nowMs)
{
MS_TRACE();
......@@ -42,8 +42,9 @@ namespace RTC
this->e[0][0] += this->processNoise[0];
this->e[1][1] += this->processNoise[1];
if ((currentHypothesis == BW_OVERUSING && this->offset < this->prevOffset) ||
(currentHypothesis == BW_UNDERUSING && 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;
}
......
......@@ -51,14 +51,14 @@ namespace RTC
uint32_t convertMsTo24Bits(int64_t timeMs)
{
uint32_t time24Bits =
static_cast<uint32_t>(((static_cast<uint64_t>(timeMs) << AbsSendTimeFraction) + 500) / 1000) &
0x00FFFFFF;
static_cast<uint32_t>(((static_cast<uint64_t>(timeMs) << AbsSendTimeFraction) + 500) / 1000) &
0x00FFFFFF;
return time24Bits;
}
bool RemoteBitrateEstimatorAbsSendTime::IsWithinClusterBounds(
int sendDeltaMs, const Cluster& clusterAggregate)
int sendDeltaMs, const Cluster& clusterAggregate)
{
MS_TRACE();
......@@ -123,7 +123,7 @@ namespace RTC
}
std::list<Cluster>::const_iterator RemoteBitrateEstimatorAbsSendTime::FindBestProbe(
const std::list<Cluster>& clusters) const
const std::list<Cluster>& clusters) const
{
MS_TRACE();
......@@ -136,8 +136,9 @@ namespace RTC
if (it->sendMeanMs == 0 || it->recvMeanMs == 0)
continue;
if (it->numAboveMinDelta > it->count / 2 &&
(it->recvMeanMs - it->sendMeanMs <= 2.0f && it->sendMeanMs - it->recvMeanMs <= 5.0f))
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());
......@@ -153,14 +154,14 @@ namespace RTC
int recvBitrateBps = it->meanSize * 8 * 1000 / it->recvMeanMs;
MS_DEBUG_TAG(
rbe,
"probe failed, sent at %d bps, received at %d bps [mean "
"send delta:%fms, mean recv delta:%fms, num probes:%d]",
sendBitrateBps,
recvBitrateBps,
it->sendMeanMs,
it->recvMeanMs,
it->count);
rbe,
"probe failed, sent at %d bps, received at %d bps [mean "
"send delta:%fms, mean recv delta:%fms, num probes:%d]",
sendBitrateBps,
recvBitrateBps,
it->sendMeanMs,
it->recvMeanMs,
it->count);
break;
}
......@@ -170,7 +171,7 @@ namespace RTC
}
RemoteBitrateEstimatorAbsSendTime::ProbeResult RemoteBitrateEstimatorAbsSendTime::ProcessClusters(
int64_t nowMs)
int64_t nowMs)
{
MS_TRACE();
......@@ -197,15 +198,15 @@ namespace RTC
if (IsBitrateImproving(probeBitrateBps))
{
MS_DEBUG_TAG(
rbe,
"probe successful, sent at %d bps, received at %d bps "
"[mean send delta:%fms, mean recv delta: %f ms, "
"num probes:%d",
bestIt->GetSendBitrateBps(),
bestIt->GetRecvBitrateBps(),
bestIt->sendMeanMs,
bestIt->recvMeanMs,
bestIt->count);
rbe,
"probe successful, sent at %d bps, received at %d bps "
"[mean send delta:%fms, mean recv delta: %f ms, "
"num probes:%d",
bestIt->GetSendBitrateBps(),
bestIt->GetRecvBitrateBps(),
bestIt->sendMeanMs,
bestIt->recvMeanMs,
bestIt->count);
this->remoteRate.SetEstimate(probeBitrateBps, nowMs);
......@@ -233,7 +234,7 @@ namespace RTC
}
void RemoteBitrateEstimatorAbsSendTime::IncomingPacket(
int64_t arrivalTimeMs, size_t payloadSize, const RtpPacket& packet, const uint32_t absSendTime)
int64_t arrivalTimeMs, size_t payloadSize, const RtpPacket& packet, const uint32_t absSendTime)
{
MS_TRACE();
......@@ -241,7 +242,7 @@ namespace RTC
}
void RemoteBitrateEstimatorAbsSendTime::IncomingPacketInfo(
int64_t arrivalTimeMs, uint32_t sendTime24bits, size_t payloadSize, uint32_t ssrc)
int64_t arrivalTimeMs, uint32_t sendTime24bits, size_t payloadSize, uint32_t ssrc)
{
MS_TRACE();
......@@ -298,9 +299,10 @@ namespace RTC
// the sender.
const size_t minProbePacketSize{ 200 };
if (payloadSize > minProbePacketSize &&
(!this->remoteRate.ValidEstimate() ||
nowMs - this->firstPacketTimeMs < InitialProbingIntervalMs))
if (
payloadSize > minProbePacketSize &&
(!this->remoteRate.ValidEstimate() ||
nowMs - this->firstPacketTimeMs < InitialProbingIntervalMs))
{
// TODO(holmer): Use a map instead to get correct order?
if (this->totalProbesReceived < MaxProbePackets)
......@@ -315,14 +317,14 @@ namespace RTC
}
MS_DEBUG_TAG(
rbe,
"probe packet received [send time:%" PRId64
"ms, recv "
"time:%" PRId64 "ms, send delta:%dms, recv delta:%d ms]",
sendTimeMs,
arrivalTimeMs,
sendDeltaMs,
recvDeltaMs);
rbe,
"probe packet received [send time:%" PRId64
"ms, recv "
"time:%" PRId64 "ms, send delta:%dms, recv delta:%d ms]",
sendTimeMs,
arrivalTimeMs,
sendDeltaMs,
recvDeltaMs);
}
this->probes.emplace_back(sendTimeMs, arrivalTimeMs, payloadSize);
......@@ -335,21 +337,20 @@ namespace RTC
}
if (this->interArrival->ComputeDeltas(
timestamp, arrivalTimeMs, nowMs, payloadSize, &tsDelta, &tDelta, &sizeDelta))
timestamp, arrivalTimeMs, nowMs, payloadSize, &tsDelta, &tDelta, &sizeDelta))
{
double tsDeltaMs = (1000.0 * tsDelta) / (1 << InterArrivalShift);
this->estimator->Update(tDelta, tsDeltaMs, sizeDelta, this->detector.State(), arrivalTimeMs);
this->detector.Detect(
this->estimator->GetOffset(), tsDeltaMs, this->estimator->GetNumOfDeltas(), arrivalTimeMs);
this->estimator->GetOffset(), tsDeltaMs, this->estimator->GetNumOfDeltas(), arrivalTimeMs);
}
if (!updateEstimate)
{
// 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;
}
......@@ -368,9 +369,9 @@ namespace RTC
// We also have to update the estimate immediately if we are overusing
// and the target bitrate is too high compared to what we are receiving.
const RateControlInput input(
this->detector.State(),
this->incomingBitrate.GetRate(arrivalTimeMs),
this->estimator->GetVarNoise());
this->detector.State(),
this->incomingBitrate.GetRate(arrivalTimeMs),
this->estimator->GetVarNoise());
this->remoteRate.Update(&input, nowMs);
targetBitrateBps = this->remoteRate.UpdateBandwidthEstimate(nowMs);
......@@ -402,7 +403,7 @@ namespace RTC
{
// We can't update the estimate if we don't have any active streams.
this->interArrival.reset(new InterArrival(
(TimestampGroupLengthMs << InterArrivalShift) / 1000, TimestampToMs, true));
(TimestampGroupLengthMs << InterArrivalShift) / 1000, TimestampToMs, true));
this->estimator.reset(new OveruseEstimator(OverUseDetectorOptions()));
// We deliberately don't reset the this->firstPacketTimeMs here for now since
// we only probe for bandwidth in the beginning of a call right now.
......@@ -410,7 +411,7 @@ namespace RTC
}
bool RemoteBitrateEstimatorAbsSendTime::LatestEstimate(
std::vector<uint32_t>* ssrcs, uint32_t* bitrateBps) const
std::vector<uint32_t>* ssrcs, uint32_t* bitrateBps) const
{
MS_TRACE();
......
......@@ -23,10 +23,10 @@
namespace RTC
{
void RemoteBitrateEstimatorSingleStream::IncomingPacket(
int64_t arrivalTimeMs,
size_t payloadSize,
const RtpPacket& packet,
const uint32_t transmissionTimeOffset)
int64_t arrivalTimeMs,
size_t payloadSize,
const RtpPacket& packet,
const uint32_t transmissionTimeOffset)
{
MS_TRACE();
......@@ -47,7 +47,7 @@ namespace RTC
// automatically cleaned up when we have one RemoteBitrateEstimator per REMB
// group.
std::pair<SsrcOveruseEstimatorMap::iterator, bool> insertResult = this->overuseDetectors.insert(
std::make_pair(ssrc, new Detector(nowMs, OverUseDetectorOptions(), true)));
std::make_pair(ssrc, new Detector(nowMs, OverUseDetectorOptions(), true)));
it = insertResult.first;
}
......@@ -78,27 +78,28 @@ namespace RTC
int sizeDelta{ 0 };
if (estimator->interArrival.ComputeDeltas(
rtpTimestamp, arrivalTimeMs, nowMs, payloadSize, &timestampDelta, &timeDelta, &sizeDelta))
rtpTimestamp, arrivalTimeMs, nowMs, payloadSize, &timestampDelta, &timeDelta, &sizeDelta))
{
double timestampDeltaMs = timestampDelta * TimestampToMs;
estimator->estimator.Update(
timeDelta, timestampDeltaMs, sizeDelta, estimator->detector.State(), nowMs);
timeDelta, timestampDeltaMs, sizeDelta, estimator->detector.State(), nowMs);
estimator->detector.Detect(
estimator->estimator.GetOffset(),
timestampDeltaMs,
estimator->estimator.GetNumOfDeltas(),
nowMs);
estimator->estimator.GetOffset(),
timestampDeltaMs,
estimator->estimator.GetNumOfDeltas(),
nowMs);
}
if (estimator->detector.State() == BW_OVERUSING)
{
uint32_t incomingBitrateBps = this->incomingBitrate.GetRate(nowMs);
if ((incomingBitrateBps != 0u) &&
(priorState != BW_OVERUSING ||
GetRemoteRate()->TimeToReduceFurther(nowMs, incomingBitrateBps)))
if (
(incomingBitrateBps != 0u) &&
(priorState != BW_OVERUSING ||
GetRemoteRate()->TimeToReduceFurther(nowMs, incomingBitrateBps)))
{
// The first overuse should immediately trigger a new estimate.
// We also have to update the estimate immediately if we are overusing
......@@ -175,7 +176,7 @@ namespace RTC
}
bool RemoteBitrateEstimatorSingleStream::LatestEstimate(
std::vector<uint32_t>* ssrcs, uint32_t* bitrateBps) const
std::vector<uint32_t>* ssrcs, uint32_t* bitrateBps) const
{
MS_TRACE();
......
......@@ -19,7 +19,7 @@ namespace RTC
/* Instance methods. */
Router::Router(Listener* listener, Channel::Notifier* notifier, uint32_t routerId)
: routerId(routerId), listener(listener), notifier(notifier)
: routerId(routerId), listener(listener), notifier(notifier)
{
MS_TRACE();
......@@ -147,7 +147,7 @@ namespace RTC
auto* producer = kv.second;
jsonMapConsumerProducer[std::to_string(consumer->consumerId)] =
std::to_string(producer->producerId);
std::to_string(producer->producerId);
}
json[JsonStringMapConsumerProducer] = jsonMapConsumerProducer;
......@@ -353,7 +353,7 @@ namespace RTC
// Create a Producer instance.
producer = new RTC::Producer(
this->notifier, producerId, kind, transport, rtpParameters, rtpMapping, paused);
this->notifier, producerId, kind, transport, rtpParameters, rtpMapping, paused);
// Add us as listener.
producer->AddListener(this);
......@@ -885,8 +885,8 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end(),
"Producer not present in mapProducerConsumers");
this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end(),
"Producer not present in mapProducerConsumers");
auto& consumers = this->mapProducerConsumers[producer];
......@@ -901,8 +901,8 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end(),
"Producer not present in mapProducerConsumers");
this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end(),
"Producer not present in mapProducerConsumers");
auto& consumers = this->mapProducerConsumers[producer];
......@@ -917,8 +917,8 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end(),
"Producer not present in mapProducerConsumers");
this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end(),
"Producer not present in mapProducerConsumers");
auto& consumers = this->mapProducerConsumers[producer];
......@@ -969,8 +969,8 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapConsumerProducer.find(consumer) != this->mapConsumerProducer.end(),
"Consumer not present in mapConsumerProducer");
this->mapConsumerProducer.find(consumer) != this->mapConsumerProducer.end(),
"Consumer not present in mapConsumerProducer");
auto* producer = this->mapConsumerProducer[consumer];
......
......@@ -151,9 +151,9 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
return this->mapKeyValues[key].booleanValue;
}
......@@ -163,9 +163,9 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
return this->mapKeyValues[key].integerValue;
}
......@@ -175,9 +175,9 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
return this->mapKeyValues[key].doubleValue;
}
......@@ -187,9 +187,9 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
return this->mapKeyValues[key].stringValue;
}
......@@ -199,9 +199,9 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
this->mapKeyValues.find(key) != this->mapKeyValues.end(),
"key does not exist [key:%s]",
key.c_str());
return this->mapKeyValues[key].arrayOfIntegers;
}
......
......@@ -91,9 +91,9 @@ namespace RTC
}
RtpParameters::RtpParameters(const RtpParameters* rtpParameters)
: muxId(rtpParameters->muxId), codecs(rtpParameters->codecs),
encodings(rtpParameters->encodings), headerExtensions(rtpParameters->headerExtensions),
rtcp(rtpParameters->rtcp), hasRtcp(rtpParameters->hasRtcp)
: muxId(rtpParameters->muxId), codecs(rtpParameters->codecs),
encodings(rtpParameters->encodings), headerExtensions(rtpParameters->headerExtensions),
rtcp(rtpParameters->rtcp), hasRtcp(rtpParameters->hasRtcp)
{
MS_TRACE();
}
......@@ -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,8 +198,9 @@ namespace RTC
{
auto& encoding = *it;
if ((encoding.ssrc == 0u) || (encoding.hasRtx && (encoding.rtx.ssrc == 0u)) ||
(encoding.hasFec && (encoding.fec.ssrc == 0u)))
if (
(encoding.ssrc == 0u) || (encoding.hasRtx && (encoding.rtx.ssrc == 0u)) ||
(encoding.hasFec && (encoding.fec.ssrc == 0u)))
{
break;
}
......@@ -221,7 +222,7 @@ namespace RTC
RollbackProducer(producer, previousSsrcs, previousMuxId, previousPayloadTypes);
MS_THROW_ERROR(
"payloadType already exists in RTP listener [payloadType:%" PRIu8 "]", payloadType);
"payloadType already exists in RTP listener [payloadType:%" PRIu8 "]", payloadType);
}
}
}
......@@ -329,10 +330,10 @@ namespace RTC
}
void RtpListener::RollbackProducer(
RTC::Producer* producer,
std::vector<uint32_t>& previousSsrcs,
std::string& previousMuxId,
std::vector<uint8_t>& previousPayloadTypes)
RTC::Producer* producer,
std::vector<uint32_t>& previousSsrcs,
std::string& previousMuxId,
std::vector<uint8_t>& previousPayloadTypes)
{
MS_TRACE();
......
......@@ -69,7 +69,7 @@ namespace RTC
if (len < (ptr - data) + 4 + extensionValueSize)
{
MS_WARN_TAG(
rtp, "not enough space for the announced header extension value, packet discarded");
rtp, "not enough space for the announced header extension value, packet discarded");
return nullptr;
}
......@@ -105,9 +105,9 @@ namespace RTC
if (payloadLength < static_cast<size_t>(payloadPadding))
{
MS_WARN_TAG(
rtp,
"number of padding octets is greater than available space for payload, packet "
"discarded");
rtp,
"number of padding octets is greater than available space for payload, packet "
"discarded");
return nullptr;
}
......@@ -115,9 +115,9 @@ namespace RTC
}
MS_ASSERT(
len == sizeof(Header) + csrcListSize + (extensionHeader ? 4 + extensionValueSize : 0) +
payloadLength + static_cast<size_t>(payloadPadding),
"packet's computed size does not match received size");
len == sizeof(Header) + csrcListSize + (extensionHeader ? 4 + extensionValueSize : 0) +
payloadLength + static_cast<size_t>(payloadPadding),
"packet's computed size does not match received size");
auto packet = new RtpPacket(header, extensionHeader, payload, payloadLength, payloadPadding, len);
......@@ -130,14 +130,14 @@ namespace RTC
/* Instance methods. */
RtpPacket::RtpPacket(
Header* header,
ExtensionHeader* extensionHeader,
const uint8_t* payload,
size_t payloadLength,
uint8_t payloadPadding,
size_t size)
: header(header), extensionHeader(extensionHeader), payload(const_cast<uint8_t*>(payload)),
payloadLength(payloadLength), payloadPadding(payloadPadding), size(size)
Header* header,
ExtensionHeader* extensionHeader,
const uint8_t* payload,
size_t payloadLength,
uint8_t payloadPadding,
size_t size)
: header(header), extensionHeader(extensionHeader), payload(const_cast<uint8_t*>(payload)),
payloadLength(payloadLength), payloadPadding(payloadPadding), size(size)
{
MS_TRACE();
......@@ -187,7 +187,7 @@ namespace RTC
}
std::copy(
extIds.begin(), extIds.end() - 1, std::ostream_iterator<std::string>(extIdsStream, ","));
extIds.begin(), extIds.end() - 1, std::ostream_iterator<std::string>(extIdsStream, ","));
extIdsStream << extIds.back();
MS_DUMP(" RFC5285 ext ids : %s", extIdsStream.str().c_str());
......@@ -362,7 +362,7 @@ namespace RTC
// Create the new RtpPacket instance and return it.
auto packet = new RtpPacket(
header, extensionHeader, payload, this->payloadLength, this->payloadPadding, this->size);
header, extensionHeader, payload, this->payloadLength, this->payloadPadding, this->size);
// Parse RFC 5285 extension header.
packet->ParseExtensions();
......@@ -457,7 +457,7 @@ namespace RTC
if (ptr + 1 + len > extensionEnd)
{
MS_WARN_TAG(
rtp, "not enough space for the announced One-Byte header extension element value");
rtp, "not enough space for the announced One-Byte header extension element value");
break;
}
......@@ -490,7 +490,7 @@ namespace RTC
if (ptr + len > extensionEnd)
{
MS_WARN_TAG(
rtp, "not enough space for the announced Two-Bytes header extension element value");
rtp, "not enough space for the announced Two-Bytes header extension element value");
break;
}
......
......@@ -48,10 +48,10 @@ namespace RTC
if (this->probation == 0u)
{
MS_WARN_TAG(
rtp,
"invalid packet [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
rtp,
"invalid packet [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
}
return false;
......@@ -59,7 +59,7 @@ namespace RTC
// Set the extended sequence number into the packet.
packet->SetExtendedSequenceNumber(
this->cycles + static_cast<uint32_t>(packet->GetSequenceNumber()));
this->cycles + static_cast<uint32_t>(packet->GetSequenceNumber()));
// Update highest seen RTP timestamp.
if (packet->GetTimestamp() > this->maxTimestamp)
......@@ -143,20 +143,20 @@ namespace RTC
* (i.e., pretend this was the first packet).
*/
MS_WARN_TAG(
rtp,
"too bad sequence number, re-syncing RTP [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
rtp,
"too bad sequence number, re-syncing RTP [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
InitSeq(seq);
}
else
{
MS_WARN_TAG(
rtp,
"bad sequence number, ignoring packet [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
rtp,
"bad sequence number, ignoring packet [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
this->badSeq = (seq + 1) & (RtpSeqMod - 1);
......
......@@ -10,7 +10,7 @@ namespace RTC
/* Instance methods. */
RtpStreamRecv::RtpStreamRecv(Listener* listener, RTC::RtpStream::Params& params)
: RtpStream::RtpStream(params), listener(listener)
: RtpStream::RtpStream(params), listener(listener)
{
MS_TRACE();
}
......@@ -69,12 +69,12 @@ namespace RTC
if (packet->GetPayloadType() != this->rtxPayloadType)
{
MS_WARN_TAG(
rtx,
"ignoring RTX packet with invalid payload type [ssrc: %" PRIu32 " seq: %" PRIu16
" payload type: %" PRIu8 "]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetPayloadType());
rtx,
"ignoring RTX packet with invalid payload type [ssrc: %" PRIu32 " seq: %" PRIu16
" payload type: %" PRIu8 "]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetPayloadType());
return false;
}
......@@ -89,39 +89,38 @@ namespace RTC
if (packet->GetPayloadLength() < 2)
{
MS_DEBUG_TAG(
rtx,
"ignoring empty RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16
" payload type: %" PRIu8 "]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetPayloadType());
rtx,
"ignoring empty RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16 " payload type: %" PRIu8 "]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetPayloadType());
return false;
}
MS_WARN_TAG(
rtx,
"ignoring malformed RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16
" payload type: %" PRIu8 "]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetPayloadType());
rtx,
"ignoring malformed RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16 " payload type: %" PRIu8
"]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetPayloadType());
return false;
}
MS_DEBUG_TAG(
rtx,
"received RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16
"] recovering original [ssrc: %" PRIu32 " seq: %" PRIu16 "]",
this->rtxSsrc,
rtxSeq,
packet->GetSsrc(),
packet->GetSequenceNumber());
rtx,
"received RTX packet [ssrc: %" PRIu32 " seq: %" PRIu16 "] recovering original [ssrc: %" PRIu32
" seq: %" PRIu16 "]",
this->rtxSsrc,
rtxSeq,
packet->GetSsrc(),
packet->GetSequenceNumber());
// Set the extended sequence number into the packet.
packet->SetExtendedSequenceNumber(
this->cycles + static_cast<uint32_t>(packet->GetSequenceNumber()));
this->cycles + static_cast<uint32_t>(packet->GetSequenceNumber()));
// Pass the packet to the NackGenerator.
if (this->params.useNack && this->nackGenerator)
......@@ -216,7 +215,7 @@ namespace RTC
return;
auto transit =
static_cast<int>(DepLibUV::GetTime() - (rtpTimestamp * 1000 / this->params.clockRate));
static_cast<int>(DepLibUV::GetTime() - (rtpTimestamp * 1000 / this->params.clockRate));
int d = transit - this->transit;
this->transit = transit;
......@@ -249,11 +248,11 @@ namespace RTC
MS_ASSERT(this->params.useNack, "NACK required but not supported");
MS_WARN_TAG(
rtx,
"triggering NACK [ssrc:%" PRIu32 ", first seq:%" PRIu16 ", num packets:%zu]",
this->params.ssrc,
seqNumbers[0],
seqNumbers.size());
rtx,
"triggering NACK [ssrc:%" PRIu32 ", first seq:%" PRIu16 ", num packets:%zu]",
this->params.ssrc,
seqNumbers[0],
seqNumbers.size());
this->listener->OnNackRequired(this, seqNumbers);
}
......
......@@ -18,7 +18,7 @@ namespace RTC
/* Instance methods. */
RtpStreamSend::RtpStreamSend(RTC::RtpStream::Params& params, size_t bufferSize)
: RtpStream::RtpStream(params), storage(bufferSize)
: RtpStream::RtpStream(params), storage(bufferSize)
{
MS_TRACE();
}
......@@ -100,7 +100,7 @@ namespace RTC
// This method looks for the requested RTP packets and inserts them into the
// given container (and set to null the next container position).
void RtpStreamSend::RequestRtpRetransmission(
uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container)
uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container)
{
MS_TRACE();
......@@ -190,7 +190,7 @@ namespace RTC
{
auto currentPacket = (*bufferIt).packet;
uint32_t diff =
(this->maxTimestamp - currentPacket->GetTimestamp()) * 1000 / this->params.clockRate;
(this->maxTimestamp - currentPacket->GetTimestamp()) * 1000 / this->params.clockRate;
// Just provide the packet if no older than MaxRetransmissionAge ms.
if (diff > MaxRetransmissionAge)
......@@ -198,12 +198,12 @@ namespace RTC
if (!tooOldPacketFound)
{
MS_WARN_TAG(
rtx,
"ignoring retransmission for too old packet "
"[seq:%" PRIu16 ", max age:%" PRIu32 "ms, packet age:%" PRIu32 "ms]",
currentPacket->GetSequenceNumber(),
MaxRetransmissionAge,
diff);
rtx,
"ignoring retransmission for too old packet "
"[seq:%" PRIu16 ", max age:%" PRIu32 "ms, packet age:%" PRIu32 "ms]",
currentPacket->GetSequenceNumber(),
MaxRetransmissionAge,
diff);
tooOldPacketFound = true;
}
......@@ -217,11 +217,11 @@ namespace RTC
if ((resentAtTime != 0u) && now - resentAtTime < static_cast<uint64_t>(rtt))
{
MS_WARN_TAG(
rtx,
"ignoring retransmission for a packet already resent in the last RTT ms "
"[seq:%" PRIu16 ", rtt:%" PRIu32 "]",
currentPacket->GetSequenceNumber(),
rtt);
rtx,
"ignoring retransmission for a packet already resent in the last RTT ms "
"[seq:%" PRIu16 ", rtt:%" PRIu32 "]",
currentPacket->GetSequenceNumber(),
rtt);
break;
}
......@@ -263,22 +263,22 @@ namespace RTC
if (!firstPacketSent || origBitmask != sentBitmask)
{
MS_DEBUG_TAG(
rtx,
"could not resend all packets [seq:%" PRIu16
", first:%s, "
"bitmask:" MS_UINT16_TO_BINARY_PATTERN ", sent bitmask:" MS_UINT16_TO_BINARY_PATTERN "]",
seq,
firstPacketSent ? "yes" : "no",
MS_UINT16_TO_BINARY(origBitmask),
MS_UINT16_TO_BINARY(sentBitmask));
rtx,
"could not resend all packets [seq:%" PRIu16
", first:%s, "
"bitmask:" MS_UINT16_TO_BINARY_PATTERN ", sent bitmask:" MS_UINT16_TO_BINARY_PATTERN "]",
seq,
firstPacketSent ? "yes" : "no",
MS_UINT16_TO_BINARY(origBitmask),
MS_UINT16_TO_BINARY(sentBitmask));
}
else
{
MS_DEBUG_TAG(
rtx,
"all packets resent [seq:%" PRIu16 ", bitmask:" MS_UINT16_TO_BINARY_PATTERN "]",
seq,
MS_UINT16_TO_BINARY(origBitmask));
rtx,
"all packets resent [seq:%" PRIu16 ", bitmask:" MS_UINT16_TO_BINARY_PATTERN "]",
seq,
MS_UINT16_TO_BINARY(origBitmask));
}
// Set the next container element to null.
......@@ -350,11 +350,11 @@ namespace RTC
if (packet->GetSize() > RTC::MtuSize)
{
MS_WARN_TAG(
rtp,
"packet too big [ssrc:%" PRIu32 ", seq:%" PRIu16 ", size:%zu]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetSize());
rtp,
"packet too big [ssrc:%" PRIu32 ", seq:%" PRIu16 ", size:%zu]",
packet->GetSsrc(),
packet->GetSequenceNumber(),
packet->GetSize());
return;
}
......@@ -404,10 +404,10 @@ namespace RTC
if (bufferItReverse == this->buffer.rend())
{
MS_WARN_TAG(
rtp,
"ignoring packet older than anything in the buffer [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
rtp,
"ignoring packet older than anything in the buffer [ssrc:%" PRIu32 ", seq:%" PRIu16 "]",
packet->GetSsrc(),
packet->GetSequenceNumber());
return;
}
......
......@@ -75,8 +75,8 @@ namespace RTC
}
MS_ASSERT(
(int)keyLen == policy.rtp.cipher_key_len,
"given keyLen does not match policy.rtp.cipher_keyLen");
(int)keyLen == policy.rtp.cipher_key_len,
"given keyLen does not match policy.rtp.cipher_keyLen");
switch (type)
{
......
......@@ -51,9 +51,9 @@ namespace RTC
if ((static_cast<size_t>(msgLength) != len - 20) || ((msgLength & 0x03) != 0))
{
MS_WARN_TAG(
ice,
"length field + 20 does not match total size (or it is not multiple of 4 bytes), "
"message discarded");
ice,
"length field + 20 does not match total size (or it is not multiple of 4 bytes), "
"message discarded");
return nullptr;
}
......@@ -66,7 +66,7 @@ namespace RTC
// Create a new StunMessage (data + 8 points to the received TransactionID field).
auto msg = new StunMessage(
static_cast<Class>(msgClass), static_cast<Method>(msgMethod), data + 8, data, len);
static_cast<Class>(msgClass), static_cast<Method>(msgMethod), data + 8, data, len);
/*
STUN Attributes
......@@ -125,9 +125,9 @@ namespace RTC
if (hasMessageIntegrity && attrType != Attribute::FINGERPRINT)
{
MS_WARN_TAG(
ice,
"attribute after MESSAGE_INTEGRITY other than FINGERPRINT is not allowed, "
"message discarded");
ice,
"attribute after MESSAGE_INTEGRITY other than FINGERPRINT is not allowed, "
"message discarded");
delete msg;
return nullptr;
......@@ -140,7 +140,7 @@ namespace RTC
case Attribute::USERNAME:
{
msg->SetUsername(
reinterpret_cast<const char*>(attrValuePos), static_cast<size_t>(attrLength));
reinterpret_cast<const char*>(attrValuePos), static_cast<size_t>(attrLength));
break;
}
......@@ -199,7 +199,7 @@ namespace RTC
// Set next attribute position.
pos =
static_cast<size_t>(Utils::Byte::PadTo4Bytes(static_cast<uint16_t>(pos + 4 + attrLength)));
static_cast<size_t>(Utils::Byte::PadTo4Bytes(static_cast<uint16_t>(pos + 4 + attrLength)));
}
// Ensure current position matches the total length.
......@@ -222,9 +222,9 @@ namespace RTC
if (fingerprint != computedFingerprint)
{
MS_WARN_TAG(
ice,
"computed FINGERPRINT value does not match the value in the message, "
"message discarded");
ice,
"computed FINGERPRINT value does not match the value in the message, "
"message discarded");
delete msg;
return nullptr;
......@@ -237,9 +237,9 @@ namespace RTC
/* Instance methods. */
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)
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)
{
MS_TRACE();
}
......@@ -330,7 +330,7 @@ namespace RTC
}
StunMessage::Authentication StunMessage::CheckAuthentication(
const std::string& localUsername, const std::string& localPassword)
const std::string& localUsername, const std::string& localPassword)
{
MS_TRACE();
......@@ -346,9 +346,9 @@ 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) != ':' ||
(this->username.compare(0, localUsernameLen, localUsername) != 0))
if (
this->username.length() <= localUsernameLen || this->username.at(localUsernameLen) != ':' ||
(this->username.compare(0, localUsernameLen, localUsername) != 0))
return Authentication::UNAUTHORIZED;
break;
......@@ -372,7 +372,7 @@ namespace RTC
// Calculate the HMAC-SHA1 of the message according to MESSAGE-INTEGRITY rules.
const uint8_t* computedMessageIntegrity = Utils::Crypto::GetHmacShA1(
localPassword, this->data, (this->messageIntegrity - 4) - this->data);
localPassword, this->data, (this->messageIntegrity - 4) - this->data);
Authentication result;
......@@ -394,8 +394,8 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->klass == Class::REQUEST,
"attempt to create a success response for a non Request STUN message");
this->klass == Class::REQUEST,
"attempt to create a success response for a non Request STUN message");
return new StunMessage(Class::SUCCESS_RESPONSE, this->method, this->transactionId, nullptr, 0);
}
......@@ -405,11 +405,11 @@ namespace RTC
MS_TRACE();
MS_ASSERT(
this->klass == Class::REQUEST,
"attempt to create an error response for a non Request STUN message");
this->klass == Class::REQUEST,
"attempt to create an error response for a non Request STUN message");
auto response =
new StunMessage(Class::ERROR_RESPONSE, this->method, this->transactionId, nullptr, 0);
new StunMessage(Class::ERROR_RESPONSE, this->method, this->transactionId, nullptr, 0);
response->SetErrorCode(errorCode);
......@@ -437,8 +437,8 @@ namespace RTC
uint16_t usernamePaddedLen{ 0 };
uint16_t xorMappedAddressPaddedLen{ 0 };
bool addXorMappedAddress =
((this->xorMappedAddress != nullptr) && this->method == StunMessage::Method::BINDING &&
this->klass == Class::SUCCESS_RESPONSE);
((this->xorMappedAddress != nullptr) && this->method == StunMessage::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());
bool addFingerprint{ true }; // Do always.
......@@ -591,16 +591,16 @@ namespace RTC
attrValue[1] = 0x01;
// Set port and XOR it.
std::memcpy(
attrValue + 2,
&(reinterpret_cast<const sockaddr_in*>(this->xorMappedAddress))->sin_port,
2);
attrValue + 2,
&(reinterpret_cast<const sockaddr_in*>(this->xorMappedAddress))->sin_port,
2);
attrValue[2] ^= StunMessage::magicCookie[0];
attrValue[3] ^= StunMessage::magicCookie[1];
// Set address and XOR it.
std::memcpy(
attrValue + 4,
&(reinterpret_cast<const sockaddr_in*>(this->xorMappedAddress))->sin_addr.s_addr,
4);
attrValue + 4,
&(reinterpret_cast<const sockaddr_in*>(this->xorMappedAddress))->sin_addr.s_addr,
4);
attrValue[4] ^= StunMessage::magicCookie[0];
attrValue[5] ^= StunMessage::magicCookie[1];
attrValue[6] ^= StunMessage::magicCookie[2];
......@@ -618,16 +618,16 @@ namespace RTC
attrValue[1] = 0x02;
// Set port and XOR it.
std::memcpy(
attrValue + 2,
&(reinterpret_cast<const sockaddr_in6*>(this->xorMappedAddress))->sin6_port,
2);
attrValue + 2,
&(reinterpret_cast<const sockaddr_in6*>(this->xorMappedAddress))->sin6_port,
2);
attrValue[2] ^= StunMessage::magicCookie[0];
attrValue[3] ^= StunMessage::magicCookie[1];
// Set address and XOR it.
std::memcpy(
attrValue + 4,
&(reinterpret_cast<const sockaddr_in6*>(this->xorMappedAddress))->sin6_addr.s6_addr,
16);
attrValue + 4,
&(reinterpret_cast<const sockaddr_in6*>(this->xorMappedAddress))->sin6_addr.s6_addr,
16);
attrValue[4] ^= StunMessage::magicCookie[0];
attrValue[5] ^= StunMessage::magicCookie[1];
attrValue[6] ^= StunMessage::magicCookie[2];
......@@ -676,7 +676,7 @@ namespace RTC
// Calculate the HMAC-SHA1 of the message according to MESSAGE-INTEGRITY rules.
const uint8_t* computedMessageIntegrity =
Utils::Crypto::GetHmacShA1(this->password, buffer, pos);
Utils::Crypto::GetHmacShA1(this->password, buffer, pos);
Utils::Byte::Set2Bytes(buffer, pos, static_cast<uint16_t>(Attribute::MESSAGE_INTEGRITY));
Utils::Byte::Set2Bytes(buffer, pos + 2, 20);
......
......@@ -11,7 +11,7 @@ namespace RTC
/* Instance methods. */
TcpConnection::TcpConnection(Listener* listener, size_t bufferSize)
: ::TcpConnection::TcpConnection(bufferSize), listener(listener)
: ::TcpConnection::TcpConnection(bufferSize), listener(listener)
{
MS_TRACE();
}
......@@ -21,11 +21,11 @@ namespace RTC
MS_TRACE();
MS_DEBUG_DEV(
"data received [local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
GetLocalIP().c_str(),
GetLocalPort(),
GetPeerIP().c_str(),
GetPeerPort());
"data received [local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
GetLocalIP().c_str(),
GetLocalPort(),
GetPeerIP().c_str(),
GetPeerPort());
/*
* Framing RFC 4571
......@@ -105,11 +105,11 @@ namespace RTC
if (this->frameStart != 0)
{
MS_DEBUG_DEV(
"no more space in the buffer, moving parsed bytes to the beginning of "
"the buffer and wait for more data");
"no more space in the buffer, moving parsed bytes to the beginning of "
"the buffer and wait for more data");
std::memmove(
this->buffer, this->buffer + this->frameStart, this->bufferSize - this->frameStart);
this->buffer, this->buffer + this->frameStart, this->bufferSize - this->frameStart);
this->bufferDataLen = this->bufferSize - this->frameStart;
this->frameStart = 0;
}
......@@ -118,8 +118,8 @@ namespace RTC
else
{
MS_WARN_DEV(
"no more space in the buffer for the unfinished frame being parsed, closing the "
"connection");
"no more space in the buffer for the unfinished frame being parsed, closing the "
"connection");
// Close the socket.
Destroy();
......
......@@ -43,9 +43,9 @@ namespace RTC
if (!Settings::configuration.rtcIPv4.empty())
{
err = uv_ip4_addr(
Settings::configuration.rtcIPv4.c_str(),
0,
reinterpret_cast<struct sockaddr_in*>(&RTC::TcpServer::sockaddrStorageIPv4));
Settings::configuration.rtcIPv4.c_str(),
0,
reinterpret_cast<struct sockaddr_in*>(&RTC::TcpServer::sockaddrStorageIPv4));
if (err != 0)
MS_THROW_ERROR("uv_ipv4_addr() failed: %s", uv_strerror(err));
......@@ -54,9 +54,9 @@ namespace RTC
if (!Settings::configuration.rtcIPv6.empty())
{
err = uv_ip6_addr(
Settings::configuration.rtcIPv6.c_str(),
0,
reinterpret_cast<struct sockaddr_in6*>(&RTC::TcpServer::sockaddrStorageIPv6));
Settings::configuration.rtcIPv6.c_str(),
0,
reinterpret_cast<struct sockaddr_in6*>(&RTC::TcpServer::sockaddrStorageIPv6));
if (err != 0)
MS_THROW_ERROR("uv_ipv6_addr() failed: %s", uv_strerror(err));
......@@ -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)
......@@ -181,10 +178,10 @@ namespace RTC
if (err != 0)
{
MS_WARN_DEV(
"uv_tcp_bind() failed [port:%" PRIu16 ", attempt:%" PRIu16 "]: %s",
attempt,
iteratingPort,
uv_strerror(err));
"uv_tcp_bind() failed [port:%" PRIu16 ", attempt:%" PRIu16 "]: %s",
attempt,
iteratingPort,
uv_strerror(err));
uv_close(reinterpret_cast<uv_handle_t*>(uvHandle), static_cast<uv_close_cb>(onErrorClose));
......@@ -195,7 +192,7 @@ namespace RTC
// If bind() fails for more that MaxBindAttempts then raise an error.
if (bindAttempt > MaxBindAttempts)
MS_THROW_ERROR(
"uv_tcp_bind() fails more than %" PRIu16 " times for IP '%s'", MaxBindAttempts, listenIp);
"uv_tcp_bind() fails more than %" PRIu16 " times for IP '%s'", MaxBindAttempts, listenIp);
// 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;
};
......@@ -220,11 +214,11 @@ namespace RTC
/* Instance methods. */
TcpServer::TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, int addressFamily)
: // Provide the parent class constructor with a UDP uv handle.
// NOTE: This may throw a MediaSoupError exception if the address family is not available
// or there are no available ports.
::TcpServer::TcpServer(GetRandomPort(addressFamily), 256), listener(listener),
connListener(connListener)
: // Provide the parent class constructor with a UDP uv handle.
// NOTE: This may throw a MediaSoupError exception if the address family is not available
// or there are no available ports.
::TcpServer::TcpServer(GetRandomPort(addressFamily), 256), listener(listener),
connListener(connListener)
{
MS_TRACE();
}
......@@ -256,7 +250,7 @@ namespace RTC
if (!IsClosing())
{
this->listener->OnRtcTcpConnectionClosed(
this, dynamic_cast<RTC::TcpConnection*>(connection), isClosedByPeer);
this, dynamic_cast<RTC::TcpConnection*>(connection), isClosedByPeer);
}
}
......
......@@ -58,11 +58,11 @@ namespace RTC
MS_DUMP("<TransportTuple>");
MS_DUMP(
" [UDP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
this->udpSocket->GetLocalIP().c_str(),
this->udpSocket->GetLocalPort(),
remoteIp.c_str(),
remotePort);
" [UDP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
this->udpSocket->GetLocalIP().c_str(),
this->udpSocket->GetLocalPort(),
remoteIp.c_str(),
remotePort);
MS_DUMP("</TransportTuple>");
break;
}
......@@ -71,11 +71,11 @@ namespace RTC
{
MS_DUMP("<TransportTuple>");
MS_DUMP(
" [TCP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
this->tcpConnection->GetLocalIP().c_str(),
this->tcpConnection->GetLocalPort(),
this->tcpConnection->GetPeerIP().c_str(),
this->tcpConnection->GetPeerPort());
" [TCP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 "]",
this->tcpConnection->GetLocalIP().c_str(),
this->tcpConnection->GetLocalPort(),
this->tcpConnection->GetPeerIP().c_str(),
this->tcpConnection->GetPeerPort());
MS_DUMP("</TransportTuple>");
break;
}
......
......@@ -42,9 +42,9 @@ namespace RTC
if (Settings::configuration.hasIPv4)
{
err = uv_ip4_addr(
Settings::configuration.rtcIPv4.c_str(),
0,
reinterpret_cast<struct sockaddr_in*>(&RTC::UdpSocket::sockaddrStorageIPv4));
Settings::configuration.rtcIPv4.c_str(),
0,
reinterpret_cast<struct sockaddr_in*>(&RTC::UdpSocket::sockaddrStorageIPv4));
if (err != 0)
MS_THROW_ERROR("uv_ipv4_addr() failed: %s", uv_strerror(err));
......@@ -53,9 +53,9 @@ namespace RTC
if (Settings::configuration.hasIPv6)
{
err = uv_ip6_addr(
Settings::configuration.rtcIPv6.c_str(),
0,
reinterpret_cast<struct sockaddr_in6*>(&RTC::UdpSocket::sockaddrStorageIPv6));
Settings::configuration.rtcIPv6.c_str(),
0,
reinterpret_cast<struct sockaddr_in6*>(&RTC::UdpSocket::sockaddrStorageIPv6));
if (err != 0)
MS_THROW_ERROR("uv_ipv6_addr() failed: %s", uv_strerror(err));
......@@ -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)
......@@ -180,10 +177,10 @@ namespace RTC
if (err != 0)
{
MS_WARN_DEV(
"uv_udp_bind() failed [port:%" PRIu16 ", attempt:%" PRIu16 "]: %s",
attempt,
iteratingPort,
uv_strerror(err));
"uv_udp_bind() failed [port:%" PRIu16 ", attempt:%" PRIu16 "]: %s",
attempt,
iteratingPort,
uv_strerror(err));
uv_close(reinterpret_cast<uv_handle_t*>(uvHandle), static_cast<uv_close_cb>(onErrorClose));
......@@ -194,7 +191,7 @@ namespace RTC
// If bind() fails for more that MaxBindAttempts then raise an error.
if (bindAttempt > MaxBindAttempts)
MS_THROW_ERROR(
"uv_udp_bind() fails more than %" PRIu16 " times for IP '%s'", MaxBindAttempts, listenIp);
"uv_udp_bind() fails more than %" PRIu16 " times for IP '%s'", MaxBindAttempts, listenIp);
// 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;
};
......@@ -219,10 +213,10 @@ namespace RTC
/* Instance methods. */
UdpSocket::UdpSocket(Listener* listener, int addressFamily)
: // Provide the parent class constructor with a UDP uv handle.
// NOTE: This may throw a MediaSoupError exception if the address family is not available
// or there are no available ports.
::UdpSocket::UdpSocket(GetRandomPort(addressFamily)), listener(listener)
: // Provide the parent class constructor with a UDP uv handle.
// NOTE: This may throw a MediaSoupError exception if the address family is not available
// or there are no available ports.
::UdpSocket::UdpSocket(GetRandomPort(addressFamily)), listener(listener)
{
MS_TRACE();
}
......
......@@ -204,16 +204,16 @@ void Settings::PrintConfiguration()
if (!logTags.empty())
{
std::copy(
logTags.begin(), logTags.end() - 1, std::ostream_iterator<std::string>(logTagsStream, ","));
logTags.begin(), logTags.end() - 1, std::ostream_iterator<std::string>(logTagsStream, ","));
logTagsStream << logTags.back();
}
MS_DEBUG_TAG(info, "<configuration>");
MS_DEBUG_TAG(
info,
" logLevel : \"%s\"",
Settings::logLevel2String[Settings::configuration.logLevel].c_str());
info,
" logLevel : \"%s\"",
Settings::logLevel2String[Settings::configuration.logLevel].c_str());
MS_DEBUG_TAG(info, " logTags : \"%s\"", logTagsStream.str().c_str());
if (Settings::configuration.hasIPv4)
{
......@@ -234,7 +234,7 @@ void Settings::PrintConfiguration()
if (Settings::configuration.hasAnnouncedIPv4)
{
MS_DEBUG_TAG(
info, " rtcAnnouncedIPv4 : \"%s\"", Settings::configuration.rtcAnnouncedIPv4.c_str());
info, " rtcAnnouncedIPv4 : \"%s\"", Settings::configuration.rtcAnnouncedIPv4.c_str());
}
else
{
......@@ -243,7 +243,7 @@ void Settings::PrintConfiguration()
if (Settings::configuration.hasAnnouncedIPv6)
{
MS_DEBUG_TAG(
info, " rtcAnnouncedIPv6 : \"%s\"", Settings::configuration.rtcAnnouncedIPv6.c_str());
info, " rtcAnnouncedIPv6 : \"%s\"", Settings::configuration.rtcAnnouncedIPv6.c_str());
}
else
{
......@@ -254,9 +254,9 @@ void Settings::PrintConfiguration()
if (!Settings::configuration.dtlsCertificateFile.empty())
{
MS_DEBUG_TAG(
info, " dtlsCertificateFile : \"%s\"", Settings::configuration.dtlsCertificateFile.c_str());
info, " dtlsCertificateFile : \"%s\"", Settings::configuration.dtlsCertificateFile.c_str());
MS_DEBUG_TAG(
info, " dtlsPrivateKeyFile : \"%s\"", Settings::configuration.dtlsPrivateKeyFile.c_str());
info, " dtlsPrivateKeyFile : \"%s\"", Settings::configuration.dtlsPrivateKeyFile.c_str());
}
MS_DEBUG_TAG(info, "</configuration>");
......@@ -344,7 +344,7 @@ void Settings::SetDefaultRtcIP(int requestedFamily)
std::string ip;
Utils::IP::GetAddressInfo(
reinterpret_cast<struct sockaddr*>(&address.address.address4), &family, ip, &port);
reinterpret_cast<struct sockaddr*>(&address.address.address4), &family, ip, &port);
if (family != requestedFamily)
continue;
......@@ -506,8 +506,9 @@ void Settings::SetDtlsCertificateAndPrivateKeyFiles()
{
MS_TRACE();
if (Settings::configuration.dtlsCertificateFile.empty() ||
Settings::configuration.dtlsPrivateKeyFile.empty())
if (
Settings::configuration.dtlsCertificateFile.empty() ||
Settings::configuration.dtlsPrivateKeyFile.empty())
{
Settings::configuration.dtlsCertificateFile = "";
Settings::configuration.dtlsPrivateKeyFile = "";
......@@ -610,7 +611,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_in));
bindSocket, reinterpret_cast<const struct sockaddr*>(&bindAddr), sizeof(struct sockaddr_in));
break;
case AF_INET6:
......@@ -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:
......
......@@ -13,7 +13,7 @@ namespace Utils
HMAC_CTX Crypto::hmacSha1Ctx;
uint8_t Crypto::hmacSha1Buffer[20]; // SHA-1 result is 20 bytes long.
const uint32_t Crypto::crc32Table[] =
// clang-format off
// clang-format off
{
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
......@@ -84,20 +84,17 @@ namespace Utils
ret = HMAC_Update(&Crypto::hmacSha1Ctx, data, static_cast<int>(len));
MS_ASSERT(
ret == 1,
"OpenSSL HMAC_Update() failed with key '%s' and data length %zu bytes",
key.c_str(),
len);
ret == 1,
"OpenSSL HMAC_Update() failed with key '%s' and data length %zu bytes",
key.c_str(),
len);
uint32_t resultLen;
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;
......
......@@ -65,7 +65,7 @@ TcpConnection::~TcpConnection()
}
void TcpConnection::Setup(
Listener* listener, struct sockaddr_storage* localAddr, const std::string& localIP, uint16_t localPort)
Listener* listener, struct sockaddr_storage* localAddr, const std::string& localIP, uint16_t localPort)
{
MS_TRACE();
......@@ -114,7 +114,7 @@ void TcpConnection::Destroy()
auto req = new uv_shutdown_t;
req->data = (void*)this;
err = uv_shutdown(
req, reinterpret_cast<uv_stream_t*>(this->uvHandle), static_cast<uv_shutdown_cb>(onShutdown));
req, reinterpret_cast<uv_stream_t*>(this->uvHandle), static_cast<uv_shutdown_cb>(onShutdown));
if (err != 0)
MS_ABORT("uv_shutdown() failed: %s", uv_strerror(err));
}
......@@ -129,12 +129,12 @@ void TcpConnection::Dump() const
{
MS_DUMP("<TcpConnection>");
MS_DUMP(
" [TCP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 ", status:%s]",
this->localIP.c_str(),
static_cast<uint16_t>(this->localPort),
this->peerIP.c_str(),
static_cast<uint16_t>(this->peerPort),
(!this->isClosing) ? "open" : "closed");
" [TCP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 ", status:%s]",
this->localIP.c_str(),
static_cast<uint16_t>(this->localPort),
this->peerIP.c_str(),
static_cast<uint16_t>(this->peerPort),
(!this->isClosing) ? "open" : "closed");
MS_DUMP("</TcpConnection>");
}
......@@ -148,9 +148,9 @@ void TcpConnection::Start()
int err;
err = uv_read_start(
reinterpret_cast<uv_stream_t*>(this->uvHandle),
static_cast<uv_alloc_cb>(onAlloc),
static_cast<uv_read_cb>(onRead));
reinterpret_cast<uv_stream_t*>(this->uvHandle),
static_cast<uv_alloc_cb>(onAlloc),
static_cast<uv_read_cb>(onRead));
if (err != 0)
MS_THROW_ERROR("uv_read_start() failed: %s", uv_strerror(err));
......@@ -215,11 +215,11 @@ void TcpConnection::Write(const uint8_t* data, size_t len)
buffer = uv_buf_init(reinterpret_cast<char*>(writeData->store), pendingLen);
err = uv_write(
&writeData->req,
reinterpret_cast<uv_stream_t*>(this->uvHandle),
&buffer,
1,
static_cast<uv_write_cb>(onWrite));
&writeData->req,
reinterpret_cast<uv_stream_t*>(this->uvHandle),
&buffer,
1,
static_cast<uv_write_cb>(onWrite));
if (err != 0)
MS_ABORT("uv_write() failed: %s", uv_strerror(err));
}
......@@ -280,27 +280,27 @@ void TcpConnection::Write(const uint8_t* data1, size_t len1, const uint8_t* data
if (static_cast<size_t>(written) < len1)
{
std::memcpy(
writeData->store, data1 + static_cast<size_t>(written), len1 - static_cast<size_t>(written));
writeData->store, data1 + static_cast<size_t>(written), len1 - static_cast<size_t>(written));
std::memcpy(writeData->store + (len1 - static_cast<size_t>(written)), data2, len2);
}
// Otherwise just take the pending data in the second buffer.
else
{
std::memcpy(
writeData->store,
data2 + (static_cast<size_t>(written) - len1),
len2 - (static_cast<size_t>(written) - len1));
writeData->store,
data2 + (static_cast<size_t>(written) - len1),
len2 - (static_cast<size_t>(written) - len1));
}
writeData->req.data = (void*)writeData;
uv_buf_t buffer = uv_buf_init(reinterpret_cast<char*>(writeData->store), pendingLen);
err = uv_write(
&writeData->req,
reinterpret_cast<uv_stream_t*>(this->uvHandle),
&buffer,
1,
static_cast<uv_write_cb>(onWrite));
&writeData->req,
reinterpret_cast<uv_stream_t*>(this->uvHandle),
&buffer,
1,
static_cast<uv_write_cb>(onWrite));
if (err != 0)
MS_ABORT("uv_write() failed: %s", uv_strerror(err));
}
......@@ -322,7 +322,7 @@ bool TcpConnection::SetPeerAddress()
int family;
Utils::IP::GetAddressInfo(
reinterpret_cast<const struct sockaddr*>(&this->peerAddr), &family, this->peerIP, &this->peerPort);
reinterpret_cast<const struct sockaddr*>(&this->peerAddr), &family, this->peerIP, &this->peerPort);
return true;
}
......
......@@ -53,14 +53,14 @@ TcpServer::TcpServer(const std::string& ip, uint16_t port, int backlog)
{
case AF_INET:
err = uv_ip4_addr(
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in*>(&bindAddr));
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in*>(&bindAddr));
if (err != 0)
MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err));
break;
case AF_INET6:
err = uv_ip6_addr(
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in6*>(&bindAddr));
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in6*>(&bindAddr));
if (err != 0)
MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err));
// Don't also bind into IPv4 when listening in IPv6.
......@@ -81,9 +81,9 @@ TcpServer::TcpServer(const std::string& ip, uint16_t port, int backlog)
}
err = uv_listen(
reinterpret_cast<uv_stream_t*>(this->uvHandle),
backlog,
static_cast<uv_connection_cb>(onConnection));
reinterpret_cast<uv_stream_t*>(this->uvHandle),
backlog,
static_cast<uv_connection_cb>(onConnection));
if (err != 0)
{
uv_close(reinterpret_cast<uv_handle_t*>(this->uvHandle), static_cast<uv_close_cb>(onErrorClose));
......@@ -107,9 +107,9 @@ TcpServer::TcpServer(uv_tcp_t* uvHandle, int backlog) : uvHandle(uvHandle)
this->uvHandle->data = (void*)this;
err = uv_listen(
reinterpret_cast<uv_stream_t*>(this->uvHandle),
backlog,
static_cast<uv_connection_cb>(onConnection));
reinterpret_cast<uv_stream_t*>(this->uvHandle),
backlog,
static_cast<uv_connection_cb>(onConnection));
if (err != 0)
{
uv_close(reinterpret_cast<uv_handle_t*>(this->uvHandle), static_cast<uv_close_cb>(onErrorClose));
......@@ -161,11 +161,11 @@ void TcpServer::Dump() const
{
MS_DUMP("<TcpServer>");
MS_DUMP(
" [TCP, local:%s :%" PRIu16 ", status:%s, connections:%zu]",
this->localIP.c_str(),
static_cast<uint16_t>(this->localPort),
(!this->isClosing) ? "open" : "closed",
this->connections.size());
" [TCP, local:%s :%" PRIu16 ", status:%s, connections:%zu]",
this->localIP.c_str(),
static_cast<uint16_t>(this->localPort),
(!this->isClosing) ? "open" : "closed",
this->connections.size());
MS_DUMP("</TcpServer>");
}
......@@ -177,7 +177,7 @@ bool TcpServer::SetLocalAddress()
int len = sizeof(this->localAddr);
err =
uv_tcp_getsockname(this->uvHandle, reinterpret_cast<struct sockaddr*>(&this->localAddr), &len);
uv_tcp_getsockname(this->uvHandle, reinterpret_cast<struct sockaddr*>(&this->localAddr), &len);
if (err != 0)
{
MS_ERROR("uv_tcp_getsockname() failed: %s", uv_strerror(err));
......@@ -187,10 +187,10 @@ bool TcpServer::SetLocalAddress()
int family;
Utils::IP::GetAddressInfo(
reinterpret_cast<const struct sockaddr*>(&this->localAddr),
&family,
this->localIP,
&this->localPort);
reinterpret_cast<const struct sockaddr*>(&this->localAddr),
&family,
this->localIP,
&this->localPort);
return true;
}
......@@ -230,8 +230,8 @@ inline void TcpServer::OnUvConnection(int status)
// Accept the connection.
err = uv_accept(
reinterpret_cast<uv_stream_t*>(this->uvHandle),
reinterpret_cast<uv_stream_t*>(connection->GetUvHandle()));
reinterpret_cast<uv_stream_t*>(this->uvHandle),
reinterpret_cast<uv_stream_t*>(connection->GetUvHandle()));
if (err != 0)
MS_ABORT("uv_accept() failed: %s", uv_strerror(err));
......
......@@ -20,7 +20,7 @@ inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t*
}
inline static void onRecv(
uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags)
uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags)
{
static_cast<UdpSocket*>(handle->data)->OnUvRecv(nread, buf, addr, flags);
}
......@@ -77,14 +77,14 @@ UdpSocket::UdpSocket(const std::string& ip, uint16_t port)
{
case AF_INET:
err = uv_ip4_addr(
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in*>(&bindAddr));
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in*>(&bindAddr));
if (err != 0)
MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err));
break;
case AF_INET6:
err = uv_ip6_addr(
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in6*>(&bindAddr));
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in6*>(&bindAddr));
if (err != 0)
MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err));
// Don't also bind into IPv4 when listening in IPv6.
......@@ -105,7 +105,7 @@ UdpSocket::UdpSocket(const std::string& ip, uint16_t port)
}
err = uv_udp_recv_start(
this->uvHandle, static_cast<uv_alloc_cb>(onAlloc), static_cast<uv_udp_recv_cb>(onRecv));
this->uvHandle, static_cast<uv_alloc_cb>(onAlloc), static_cast<uv_udp_recv_cb>(onRecv));
if (err != 0)
{
uv_close(reinterpret_cast<uv_handle_t*>(this->uvHandle), static_cast<uv_close_cb>(onErrorClose));
......@@ -129,7 +129,7 @@ UdpSocket::UdpSocket(uv_udp_t* uvHandle) : uvHandle(uvHandle)
this->uvHandle->data = (void*)this;
err = uv_udp_recv_start(
this->uvHandle, static_cast<uv_alloc_cb>(onAlloc), static_cast<uv_udp_recv_cb>(onRecv));
this->uvHandle, static_cast<uv_alloc_cb>(onAlloc), static_cast<uv_udp_recv_cb>(onRecv));
if (err != 0)
{
uv_close(reinterpret_cast<uv_handle_t*>(this->uvHandle), static_cast<uv_close_cb>(onErrorClose));
......@@ -174,10 +174,10 @@ void UdpSocket::Dump() const
{
MS_DUMP("<UdpSocket>");
MS_DUMP(
" [UDP, local:%s :%" PRIu16 ", status:%s]",
this->localIP.c_str(),
static_cast<uint16_t>(this->localPort),
(!this->isClosing) ? "open" : "closed");
" [UDP, local:%s :%" PRIu16 ", status:%s]",
this->localIP.c_str(),
static_cast<uint16_t>(this->localPort),
(!this->isClosing) ? "open" : "closed");
MS_DUMP("</UdpSocket>");
}
......@@ -233,7 +233,7 @@ void UdpSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* add
buffer = uv_buf_init(reinterpret_cast<char*>(sendData->store), len);
err = uv_udp_send(
&sendData->req, this->uvHandle, &buffer, 1, addr, static_cast<uv_udp_send_cb>(onSend));
&sendData->req, this->uvHandle, &buffer, 1, addr, static_cast<uv_udp_send_cb>(onSend));
if (err != 0)
{
// NOTE: uv_udp_send() returns error if a wrong INET family is given
......@@ -265,14 +265,14 @@ void UdpSocket::Send(const uint8_t* data, size_t len, const std::string& ip, uin
{
case AF_INET:
err = uv_ip4_addr(
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in*>(&addr));
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in*>(&addr));
if (err != 0)
MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err));
break;
case AF_INET6:
err = uv_ip6_addr(
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in6*>(&addr));
ip.c_str(), static_cast<int>(port), reinterpret_cast<struct sockaddr_in6*>(&addr));
if (err != 0)
MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err));
break;
......@@ -294,7 +294,7 @@ bool UdpSocket::SetLocalAddress()
int len = sizeof(this->localAddr);
err =
uv_udp_getsockname(this->uvHandle, reinterpret_cast<struct sockaddr*>(&this->localAddr), &len);
uv_udp_getsockname(this->uvHandle, reinterpret_cast<struct sockaddr*>(&this->localAddr), &len);
if (err != 0)
{
MS_ERROR("uv_udp_getsockname() failed: %s", uv_strerror(err));
......@@ -304,10 +304,10 @@ bool UdpSocket::SetLocalAddress()
int family;
Utils::IP::GetAddressInfo(
reinterpret_cast<const struct sockaddr*>(&this->localAddr),
&family,
this->localIP,
&this->localPort);
reinterpret_cast<const struct sockaddr*>(&this->localAddr),
&family,
this->localIP,
&this->localPort);
return true;
}
......@@ -323,7 +323,7 @@ inline void UdpSocket::OnUvRecvAlloc(size_t /*suggestedSize*/, uv_buf_t* buf)
}
inline void UdpSocket::OnUvRecv(
ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags)
ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags)
{
MS_TRACE();
......
......@@ -83,9 +83,9 @@ UnixStreamSocket::UnixStreamSocket(int fd, size_t bufferSize) : bufferSize(buffe
// Start reading.
err = uv_read_start(
reinterpret_cast<uv_stream_t*>(this->uvHandle),
static_cast<uv_alloc_cb>(onAlloc),
static_cast<uv_read_cb>(onRead));
reinterpret_cast<uv_stream_t*>(this->uvHandle),
static_cast<uv_alloc_cb>(onAlloc),
static_cast<uv_read_cb>(onRead));
if (err != 0)
{
uv_close(reinterpret_cast<uv_handle_t*>(this->uvHandle), static_cast<uv_close_cb>(onErrorClose));
......@@ -127,7 +127,7 @@ void UnixStreamSocket::Destroy()
auto req = new uv_shutdown_t;
req->data = (void*)this;
err = uv_shutdown(
req, reinterpret_cast<uv_stream_t*>(this->uvHandle), static_cast<uv_shutdown_cb>(onShutdown));
req, reinterpret_cast<uv_stream_t*>(this->uvHandle), static_cast<uv_shutdown_cb>(onShutdown));
if (err != 0)
MS_ABORT("uv_shutdown() failed: %s", uv_strerror(err));
}
......@@ -189,11 +189,11 @@ void UnixStreamSocket::Write(const uint8_t* data, size_t len)
buffer = uv_buf_init(reinterpret_cast<char*>(writeData->store), pendingLen);
err = uv_write(
&writeData->req,
reinterpret_cast<uv_stream_t*>(this->uvHandle),
&buffer,
1,
static_cast<uv_write_cb>(onWrite));
&writeData->req,
reinterpret_cast<uv_stream_t*>(this->uvHandle),
&buffer,
1,
static_cast<uv_write_cb>(onWrite));
if (err != 0)
MS_ABORT("uv_write() failed: %s", uv_strerror(err));
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论