Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
6a573c26
Unverified
提交
6a573c26
authored
1月 08, 2024
作者:
José Luis Millán
提交者:
GitHub
1月 08, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
C++: tidy up (#1304)
C++: tidy up
上级
bca9b0d7
隐藏空白字符变更
内嵌
并排
正在显示
70 个修改的文件
包含
420 行增加
和
397 行删除
+420
-397
.clang-tidy
worker/.clang-tidy
+15
-9
ChannelSocket.hpp
worker/include/Channel/ChannelSocket.hpp
+5
-5
Logger.hpp
worker/include/Logger.hpp
+20
-16
MediaSoupErrors.hpp
worker/include/MediaSoupErrors.hpp
+5
-5
ActiveSpeakerObserver.hpp
worker/include/RTC/ActiveSpeakerObserver.hpp
+2
-2
Consumer.hpp
worker/include/RTC/Consumer.hpp
+2
-2
DataConsumer.hpp
worker/include/RTC/DataConsumer.hpp
+2
-2
DataProducer.hpp
worker/include/RTC/DataProducer.hpp
+1
-1
DtlsTransport.hpp
worker/include/RTC/DtlsTransport.hpp
+4
-4
IceCandidate.hpp
worker/include/RTC/IceCandidate.hpp
+6
-6
KeyFrameRequestManager.hpp
worker/include/RTC/KeyFrameRequestManager.hpp
+3
-3
PipeTransport.hpp
worker/include/RTC/PipeTransport.hpp
+3
-1
PlainTransport.hpp
worker/include/RTC/PlainTransport.hpp
+6
-2
Producer.hpp
worker/include/RTC/Producer.hpp
+1
-1
FeedbackRtpTransport.hpp
worker/include/RTC/RTCP/FeedbackRtpTransport.hpp
+3
-3
RateCalculator.hpp
worker/include/RTC/RateCalculator.hpp
+1
-1
Router.hpp
worker/include/RTC/Router.hpp
+2
-2
RtcLogger.hpp
worker/include/RTC/RtcLogger.hpp
+6
-6
RtpObserver.hpp
worker/include/RTC/RtpObserver.hpp
+1
-1
RtpPacket.hpp
worker/include/RTC/RtpPacket.hpp
+12
-17
RtpRetransmissionBuffer.hpp
worker/include/RTC/RtpRetransmissionBuffer.hpp
+4
-2
RtpStreamRecv.hpp
worker/include/RTC/RtpStreamRecv.hpp
+1
-1
SctpAssociation.hpp
worker/include/RTC/SctpAssociation.hpp
+2
-2
StunPacket.hpp
worker/include/RTC/StunPacket.hpp
+4
-4
Transport.hpp
worker/include/RTC/Transport.hpp
+2
-2
TransportCongestionControlClient.hpp
worker/include/RTC/TransportCongestionControlClient.hpp
+1
-1
TransportCongestionControlServer.hpp
worker/include/RTC/TransportCongestionControlServer.hpp
+1
-1
TransportTuple.hpp
worker/include/RTC/TransportTuple.hpp
+3
-1
TrendCalculator.hpp
worker/include/RTC/TrendCalculator.hpp
+1
-1
WebRtcServer.hpp
worker/include/RTC/WebRtcServer.hpp
+5
-3
TcpConnectionHandle.hpp
worker/include/handles/TcpConnectionHandle.hpp
+5
-4
TcpServerHandle.hpp
worker/include/handles/TcpServerHandle.hpp
+5
-3
UdpSocketHandle.hpp
worker/include/handles/UdpSocketHandle.hpp
+5
-4
UnixStreamSocketHandle.hpp
worker/include/handles/UnixStreamSocketHandle.hpp
+2
-3
ChannelSocket.cpp
worker/src/Channel/ChannelSocket.cpp
+10
-10
DepLibSRTP.cpp
worker/src/DepLibSRTP.cpp
+8
-8
DepLibWebRTC.cpp
worker/src/DepLibWebRTC.cpp
+2
-2
DepOpenSSL.cpp
worker/src/DepOpenSSL.cpp
+2
-2
DepUsrSCTP.cpp
worker/src/DepUsrSCTP.cpp
+7
-9
Logger.cpp
worker/src/Logger.cpp
+2
-2
MediaSoupErrors.cpp
worker/src/MediaSoupErrors.cpp
+1
-1
ActiveSpeakerObserver.cpp
worker/src/RTC/ActiveSpeakerObserver.cpp
+15
-18
Consumer.cpp
worker/src/RTC/Consumer.cpp
+2
-3
DataConsumer.cpp
worker/src/RTC/DataConsumer.cpp
+4
-4
DataProducer.cpp
worker/src/RTC/DataProducer.cpp
+1
-1
DirectTransport.cpp
worker/src/RTC/DirectTransport.cpp
+5
-1
DtlsTransport.cpp
worker/src/RTC/DtlsTransport.cpp
+7
-11
KeyFrameRequestManager.cpp
worker/src/RTC/KeyFrameRequestManager.cpp
+2
-4
NackGenerator.cpp
worker/src/RTC/NackGenerator.cpp
+7
-16
PortManager.cpp
worker/src/RTC/PortManager.cpp
+8
-4
Producer.cpp
worker/src/RTC/Producer.cpp
+1
-4
RtpPacket.cpp
worker/src/RTC/RtpPacket.cpp
+2
-12
RtpRetransmissionBuffer.cpp
worker/src/RTC/RtpRetransmissionBuffer.cpp
+38
-36
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+3
-3
SctpAssociation.cpp
worker/src/RTC/SctpAssociation.cpp
+35
-19
SimulcastConsumer.cpp
worker/src/RTC/SimulcastConsumer.cpp
+1
-1
StunPacket.cpp
worker/src/RTC/StunPacket.cpp
+14
-14
Transport.cpp
worker/src/RTC/Transport.cpp
+4
-4
WebRtcServer.cpp
worker/src/RTC/WebRtcServer.cpp
+30
-28
WebRtcTransport.cpp
worker/src/RTC/WebRtcTransport.cpp
+3
-3
Settings.cpp
worker/src/Settings.cpp
+2
-2
File.cpp
worker/src/Utils/File.cpp
+3
-1
IP.cpp
worker/src/Utils/IP.cpp
+1
-1
Worker.cpp
worker/src/Worker.cpp
+2
-2
TcpConnectionHandle.cpp
worker/src/handles/TcpConnectionHandle.cpp
+2
-2
TcpServerHandle.cpp
worker/src/handles/TcpServerHandle.cpp
+14
-12
TimerHandle.cpp
worker/src/handles/TimerHandle.cpp
+1
-2
UdpSocketHandle.cpp
worker/src/handles/UdpSocketHandle.cpp
+15
-13
UnixStreamSocketHandle.cpp
worker/src/handles/UnixStreamSocketHandle.cpp
+15
-14
lib.cpp
worker/src/lib.cpp
+10
-7
没有找到文件。
worker/.clang-tidy
浏览文件 @
6a573c26
...
...
@@ -3,6 +3,8 @@ Checks: "*,\
-altera*,\
-boost-use-to-string,\
-bugprone-easily-swappable-parameters,\
-bugprone-lambda-function-name,\
-bugprone-macro-parentheses,\
-cert-*,\
-clang-analyzer-optin.osx.*,\
-clang-analyzer-osx.*,\
...
...
@@ -37,11 +39,15 @@ Checks: "*,\
-hicpp-uppercase-literal-suffix,\
-hicpp-vararg,\
-llvm-include-order,\
-llvm-header-guard,\
-llvm-else-after-return,\
-llvmlibc-*,\
-misc-non-private-member-variables-in-classes,\
-modernize-avoid-c-arrays,\
-modernize-concat-nested-namespaces,\
-modernize-make-unique,\
-modernize-pass-by-value,\
-modernize-use-nodiscard, \
-modernize-use-trailing-return-type,\
-readability-else-after-return,\
-readability-function-cognitive-complexity,\
...
...
@@ -49,22 +55,22 @@ Checks: "*,\
-readability-implicit-bool-cast,\
-readability-implicit-bool-conversion,\
-readability-magic-numbers,\
-readability-redundant-access-specifiers, \
-readability-uppercase-literal-suffix,\
"
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
User: mediasoup
# Old clang-tidy does not support this option which indicates to take the
# format options from .clang-format when applying fixes.
#FormatStyle: file
FormatStyle: file
CheckOptions:
- key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
value: ''
- key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle
value: '0'
- key: cppcoreguidelines-macro-usage.AllowedRegexp
value: ^MS_*
- key: misc-assert-side-effect.AssertMacros
value: assert
- key: misc-assert-side-effect.CheckFunctionCalls
...
...
@@ -98,7 +104,7 @@ CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.ClassConstantCase
value:
camelBack
value:
CamelCase
- key: readability-identifier-naming.ClassConstantPrefix
value: ''
- key: readability-identifier-naming.ClassConstantSuffix
...
...
@@ -156,9 +162,9 @@ CheckOptions:
- key: readability-identifier-naming.ConstexprVariableSuffix
value: ''
- key: readability-identifier-naming.EnumCase
value: aNy_Cas
e
value: aNy_Cas
E
- key: readability-identifier-naming.EnumConstantCase
value: aNy_Cas
e
value: aNy_Cas
E
- key: readability-identifier-naming.EnumConstantPrefix
value: ''
- key: readability-identifier-naming.EnumConstantSuffix
...
...
@@ -194,7 +200,7 @@ CheckOptions:
- key: readability-identifier-naming.IgnoreFailedSplit
value: '0'
- key: readability-identifier-naming.InlineNamespaceCase
value: aNy_Cas
e
value: aNy_Cas
E
- key: readability-identifier-naming.InlineNamespacePrefix
value: ''
- key: readability-identifier-naming.InlineNamespaceSuffix
...
...
@@ -224,7 +230,7 @@ CheckOptions:
- key: readability-identifier-naming.MethodSuffix
value: ''
- key: readability-identifier-naming.NamespaceCase
value: aNy_Cas
e
value: aNy_Cas
E
- key: readability-identifier-naming.NamespacePrefix
value: ''
- key: readability-identifier-naming.NamespaceSuffix
...
...
worker/include/Channel/ChannelSocket.hpp
浏览文件 @
6a573c26
...
...
@@ -24,7 +24,7 @@ namespace Channel
public
:
ConsumerSocket
(
int
fd
,
size_t
bufferSize
,
Listener
*
listener
);
~
ConsumerSocket
();
~
ConsumerSocket
()
override
;
/* Pure virtual methods inherited from ::UnixStreamSocketHandle. */
public
:
...
...
@@ -75,7 +75,7 @@ namespace Channel
class
Listener
:
public
RequestHandler
,
public
NotificationHandler
{
public
:
virtual
~
Listener
()
=
default
;
~
Listener
()
override
=
default
;
public
:
virtual
void
OnChannelClosed
(
Channel
::
ChannelSocket
*
channel
)
=
0
;
...
...
@@ -88,13 +88,13 @@ namespace Channel
ChannelReadCtx
channelReadCtx
,
ChannelWriteFn
channelWriteFn
,
ChannelWriteCtx
channelWriteCtx
);
virtual
~
ChannelSocket
()
;
~
ChannelSocket
()
override
;
public
:
void
Close
();
void
SetListener
(
Listener
*
listener
);
void
Send
(
const
uint8_t
*
message
,
uint32_t
message
Len
);
void
SendLog
(
const
char
*
message
,
uint32_t
message
Len
);
void
Send
(
const
uint8_t
*
data
,
uint32_t
data
Len
);
void
SendLog
(
const
char
*
data
,
uint32_t
data
Len
);
bool
CallbackRead
();
private
:
...
...
worker/include/Logger.hpp
浏览文件 @
6a573c26
...
...
@@ -96,8 +96,10 @@
// clang-format off
// NOLINTBEGIN
#define _MS_TAG_ENABLED(tag) Settings::configuration.logTags.tag
#define _MS_TAG_ENABLED_2(tag1, tag2) (Settings::configuration.logTags.tag1 || Settings::configuration.logTags.tag2)
// NOLINTEND
#if !defined(MS_LOG_DEV_LEVEL)
#define MS_LOG_DEV_LEVEL 0
...
...
@@ -145,14 +147,15 @@ public:
static
void
ClassInit
(
Channel
::
ChannelSocket
*
channel
);
public
:
static
const
uint64_t
p
id
;
static
const
uint64_t
P
id
;
thread_local
static
Channel
::
ChannelSocket
*
channel
;
static
const
size_t
b
ufferSize
{
50000
};
static
const
size_t
B
ufferSize
{
50000
};
thread_local
static
char
buffer
[];
};
/* Logging macros. */
// NOLINTBEGIN
#define _MS_LOG_SEPARATOR_CHAR_STD "\n"
#ifdef MS_LOG_FILE_LINE
...
...
@@ -165,6 +168,7 @@ public:
#define _MS_LOG_STR_DESC _MS_LOG_STR " | "
#define _MS_LOG_ARG MS_CLASS, __FUNCTION__
#endif
// NOLINTEND
#ifdef MS_LOG_TRACE
#define MS_TRACE() \
...
...
@@ -172,7 +176,7 @@ public:
{ \
if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG) \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "D(trace) " _MS_LOG_STR, _MS_LOG_ARG); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "D(trace) " _MS_LOG_STR, _MS_LOG_ARG); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
} \
...
...
@@ -204,7 +208,7 @@ public:
{ \
if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && _MS_TAG_ENABLED(tag)) \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
} \
...
...
@@ -226,7 +230,7 @@ public:
{ \
if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && _MS_TAG_ENABLED(tag)) \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
} \
...
...
@@ -248,7 +252,7 @@ public:
{ \
if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && _MS_TAG_ENABLED_2(tag1, tag2)) \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
} \
...
...
@@ -270,7 +274,7 @@ public:
{ \
if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && _MS_TAG_ENABLED_2(tag1, tag2)) \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
} \
...
...
@@ -291,7 +295,7 @@ public:
#define MS_DEBUG_DEV(desc, ...) \
do \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
while (false)
...
...
@@ -313,7 +317,7 @@ public:
#define MS_WARN_DEV(desc, ...) \
do \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
while (false)
...
...
@@ -333,7 +337,7 @@ public:
#define MS_DUMP(desc, ...) \
do \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "X" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "X" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
while (false)
...
...
@@ -349,7 +353,7 @@ public:
#define MS_DUMP_DATA(data, len) \
do \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "X(data) " _MS_LOG_STR, _MS_LOG_ARG); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "X(data) " _MS_LOG_STR, _MS_LOG_ARG); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
size_t bufferDataLen{ 0 }; \
for (size_t i{0}; i < len; ++i) \
...
...
@@ -361,10 +365,10 @@ public:
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(bufferDataLen)); \
bufferDataLen = 0; \
} \
const int loggerWritten = std::snprintf(Logger::buffer + bufferDataLen, Logger::
b
ufferSize, "X%06X ", static_cast<unsigned int>(i)); \
const int loggerWritten = std::snprintf(Logger::buffer + bufferDataLen, Logger::
B
ufferSize, "X%06X ", static_cast<unsigned int>(i)); \
bufferDataLen += loggerWritten; \
} \
const int loggerWritten = std::snprintf(Logger::buffer + bufferDataLen, Logger::
b
ufferSize, "%02X ", static_cast<unsigned char>(data[i])); \
const int loggerWritten = std::snprintf(Logger::buffer + bufferDataLen, Logger::
B
ufferSize, "%02X ", static_cast<unsigned char>(data[i])); \
bufferDataLen += loggerWritten; \
} \
if (bufferDataLen != 0) \
...
...
@@ -389,10 +393,10 @@ public:
std::fprintf(stdout, "%s", Logger::buffer); \
bufferDataLen = 0; \
} \
const int loggerWritten = std::snprintf(Logger::buffer + bufferDataLen, Logger::
b
ufferSize, "\n%06X ", static_cast<unsigned int>(i)); \
const int loggerWritten = std::snprintf(Logger::buffer + bufferDataLen, Logger::
B
ufferSize, "\n%06X ", static_cast<unsigned int>(i)); \
bufferDataLen += loggerWritten; \
} \
const int loggerWritten = std::snprintf(Logger::buffer + bufferDataLen, Logger::
b
ufferSize, "%02X ", static_cast<unsigned char>(data[i])); \
const int loggerWritten = std::snprintf(Logger::buffer + bufferDataLen, Logger::
B
ufferSize, "%02X ", static_cast<unsigned char>(data[i])); \
bufferDataLen += loggerWritten; \
} \
if (bufferDataLen != 0) \
...
...
@@ -409,7 +413,7 @@ public:
{ \
if (Settings::configuration.logLevel >= LogLevel::LOG_ERROR || MS_LOG_DEV_LEVEL >= 1) \
{ \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
b
ufferSize, "E" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
const int loggerWritten = std::snprintf(Logger::buffer, Logger::
B
ufferSize, "E" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, static_cast<uint32_t>(loggerWritten)); \
} \
} \
...
...
worker/include/MediaSoupErrors.hpp
浏览文件 @
6a573c26
...
...
@@ -13,7 +13,7 @@ public:
}
public
:
static
const
size_t
b
ufferSize
{
2000
};
static
const
size_t
B
ufferSize
{
2000
};
thread_local
static
char
buffer
[];
};
...
...
@@ -30,7 +30,7 @@ public:
do \
{ \
MS_ERROR("throwing MediaSoupError: " desc, ##__VA_ARGS__); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::
b
ufferSize, desc, ##__VA_ARGS__); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::
B
ufferSize, desc, ##__VA_ARGS__); \
throw MediaSoupError(MediaSoupError::buffer); \
} while (false)
...
...
@@ -38,7 +38,7 @@ public:
do \
{ \
MS_ERROR_STD("throwing MediaSoupError: " desc, ##__VA_ARGS__); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::
b
ufferSize, desc, ##__VA_ARGS__); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::
B
ufferSize, desc, ##__VA_ARGS__); \
throw MediaSoupError(MediaSoupError::buffer); \
} while (false)
...
...
@@ -46,7 +46,7 @@ public:
do \
{ \
MS_ERROR("throwing MediaSoupTypeError: " desc, ##__VA_ARGS__); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::
b
ufferSize, desc, ##__VA_ARGS__); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::
B
ufferSize, desc, ##__VA_ARGS__); \
throw MediaSoupTypeError(MediaSoupError::buffer); \
} while (false)
...
...
@@ -54,7 +54,7 @@ public:
do \
{ \
MS_ERROR_STD("throwing MediaSoupTypeError: " desc, ##__VA_ARGS__); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::
b
ufferSize, desc, ##__VA_ARGS__); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::
B
ufferSize, desc, ##__VA_ARGS__); \
throw MediaSoupTypeError(MediaSoupError::buffer); \
} while (false)
// clang-format on
...
...
worker/include/RTC/ActiveSpeakerObserver.hpp
浏览文件 @
6a573c26
...
...
@@ -23,7 +23,7 @@ namespace RTC
public
:
Speaker
();
void
EvalActivityScores
();
double
GetActivityScore
(
uint8_t
interval
);
double
GetActivityScore
(
uint8_t
interval
)
const
;
void
LevelChanged
(
uint32_t
level
,
uint64_t
now
);
void
LevelTimedOut
(
uint64_t
now
);
...
...
@@ -95,7 +95,7 @@ namespace RTC
void
OnTimer
(
TimerHandle
*
timer
)
override
;
private
:
double
relativeSpeachActivities
[
RelativeSpeachActivitiesLen
];
double
relativeSpeachActivities
[
RelativeSpeachActivitiesLen
]
{}
;
std
::
string
dominantId
;
TimerHandle
*
periodicTimer
{
nullptr
};
uint16_t
interval
{
300u
};
...
...
worker/include/RTC/Consumer.hpp
浏览文件 @
6a573c26
...
...
@@ -66,7 +66,7 @@ namespace RTC
RTC
::
Consumer
::
Listener
*
listener
,
const
FBS
::
Transport
::
ConsumeRequest
*
data
,
RTC
::
RtpParameters
::
Type
type
);
virtual
~
Consumer
()
;
~
Consumer
()
override
;
public
:
flatbuffers
::
Offset
<
FBS
::
Consumer
::
BaseConsumerDump
>
FillBuffer
(
...
...
@@ -74,7 +74,7 @@ namespace RTC
virtual
flatbuffers
::
Offset
<
FBS
::
Consumer
::
GetStatsResponse
>
FillBufferStats
(
flatbuffers
::
FlatBufferBuilder
&
builder
)
=
0
;
virtual
flatbuffers
::
Offset
<
FBS
::
Consumer
::
ConsumerScore
>
FillBufferScore
(
flatbuffers
::
FlatBufferBuilder
&
builder
)
const
flatbuffers
::
FlatBufferBuilder
&
/*builder*/
)
const
{
return
0
;
};
...
...
worker/include/RTC/DataConsumer.hpp
浏览文件 @
6a573c26
...
...
@@ -52,7 +52,7 @@ namespace RTC
RTC
::
DataConsumer
::
Listener
*
listener
,
const
FBS
::
Transport
::
ConsumeDataRequest
*
data
,
size_t
maxMessageSize
);
virtual
~
DataConsumer
()
;
~
DataConsumer
()
override
;
public
:
flatbuffers
::
Offset
<
FBS
::
DataConsumer
::
DumpResponse
>
FillBuffer
(
...
...
@@ -104,7 +104,7 @@ namespace RTC
uint32_t
ppid
,
std
::
vector
<
uint16_t
>&
subchannels
,
std
::
optional
<
uint16_t
>
requiredSubchannel
,
onQueuedCallback
*
=
nullptr
);
onQueuedCallback
*
cb
=
nullptr
);
/* Methods inherited from Channel::ChannelSocket::RequestHandler. */
public
:
...
...
worker/include/RTC/DataProducer.hpp
浏览文件 @
6a573c26
...
...
@@ -48,7 +48,7 @@ namespace RTC
size_t
maxMessageSize
,
RTC
::
DataProducer
::
Listener
*
listener
,
const
FBS
::
Transport
::
ProduceDataRequest
*
data
);
virtual
~
DataProducer
()
;
~
DataProducer
()
override
;
public
:
flatbuffers
::
Offset
<
FBS
::
DataProducer
::
DumpResponse
>
FillBuffer
(
...
...
worker/include/RTC/DtlsTransport.hpp
浏览文件 @
6a573c26
...
...
@@ -112,6 +112,10 @@ namespace RTC
);
// clang-format on
}
static
std
::
vector
<
Fingerprint
>&
GetLocalFingerprints
()
{
return
DtlsTransport
::
localFingerprints
;
}
private
:
static
void
GenerateCertificateAndPrivateKey
();
...
...
@@ -137,10 +141,6 @@ namespace RTC
public
:
void
Dump
()
const
;
void
Run
(
Role
localRole
);
std
::
vector
<
Fingerprint
>&
GetLocalFingerprints
()
const
{
return
DtlsTransport
::
localFingerprints
;
}
bool
SetRemoteFingerprint
(
const
Fingerprint
&
fingerprint
);
void
ProcessDtlsData
(
const
uint8_t
*
data
,
size_t
len
);
DtlsState
GetState
()
const
...
...
worker/include/RTC/IceCandidate.hpp
浏览文件 @
6a573c26
...
...
@@ -36,27 +36,27 @@ namespace RTC
public
:
IceCandidate
(
RTC
::
UdpSocket
*
udpSocket
,
uint32_t
priority
)
:
foundation
(
"udpcandidate"
),
priority
(
priority
),
ip
(
udpSocket
->
GetLocalIp
()),
protocol
(
Protocol
::
UDP
),
port
(
udpSocket
->
GetLocalPort
())
,
type
(
CandidateType
::
HOST
)
protocol
(
Protocol
::
UDP
),
port
(
udpSocket
->
GetLocalPort
())
{
}
IceCandidate
(
RTC
::
UdpSocket
*
udpSocket
,
uint32_t
priority
,
std
::
string
&
announcedIp
)
:
foundation
(
"udpcandidate"
),
priority
(
priority
),
ip
(
announcedIp
),
protocol
(
Protocol
::
UDP
),
port
(
udpSocket
->
GetLocalPort
())
,
type
(
CandidateType
::
HOST
)
port
(
udpSocket
->
GetLocalPort
())
{
}
IceCandidate
(
RTC
::
TcpServer
*
tcpServer
,
uint32_t
priority
)
:
foundation
(
"tcpcandidate"
),
priority
(
priority
),
ip
(
tcpServer
->
GetLocalIp
()),
protocol
(
Protocol
::
TCP
),
port
(
tcpServer
->
GetLocalPort
())
,
type
(
CandidateType
::
HOST
),
tcpType
(
TcpCandidateType
::
PASSIVE
)
protocol
(
Protocol
::
TCP
),
port
(
tcpServer
->
GetLocalPort
())
{
}
IceCandidate
(
RTC
::
TcpServer
*
tcpServer
,
uint32_t
priority
,
std
::
string
&
announcedIp
)
:
foundation
(
"tcpcandidate"
),
priority
(
priority
),
ip
(
announcedIp
),
protocol
(
Protocol
::
TCP
),
port
(
tcpServer
->
GetLocalPort
())
,
type
(
CandidateType
::
HOST
),
tcpType
(
TcpCandidateType
::
PASSIVE
)
port
(
tcpServer
->
GetLocalPort
())
{
}
...
...
worker/include/RTC/KeyFrameRequestManager.hpp
浏览文件 @
6a573c26
...
...
@@ -20,7 +20,7 @@ namespace RTC
public
:
PendingKeyFrameInfo
(
Listener
*
listener
,
uint32_t
ssrc
);
~
PendingKeyFrameInfo
();
~
PendingKeyFrameInfo
()
override
;
uint32_t
GetSsrc
()
const
{
...
...
@@ -64,7 +64,7 @@ namespace RTC
public
:
KeyFrameRequestDelayer
(
Listener
*
listener
,
uint32_t
ssrc
,
uint32_t
delay
);
~
KeyFrameRequestDelayer
();
~
KeyFrameRequestDelayer
()
override
;
uint32_t
GetSsrc
()
const
{
...
...
@@ -105,7 +105,7 @@ namespace RTC
public
:
explicit
KeyFrameRequestManager
(
Listener
*
listener
,
uint32_t
keyFrameRequestDelay
);
virtual
~
KeyFrameRequestManager
()
;
~
KeyFrameRequestManager
()
override
;
void
KeyFrameNeeded
(
uint32_t
ssrc
);
void
ForceKeyFrameNeeded
(
uint32_t
ssrc
);
...
...
worker/include/RTC/PipeTransport.hpp
浏览文件 @
6a573c26
...
...
@@ -75,7 +75,9 @@ namespace RTC
RTC
::
SrtpSession
*
srtpSendSession
{
nullptr
};
// Others.
ListenInfo
listenInfo
;
struct
sockaddr_storage
remoteAddrStorage
;
struct
sockaddr_storage
remoteAddrStorage
{
};
bool
rtx
{
false
};
std
::
string
srtpKey
;
std
::
string
srtpKeyBase64
;
...
...
worker/include/RTC/PlainTransport.hpp
浏览文件 @
6a573c26
...
...
@@ -76,8 +76,12 @@ namespace RTC
ListenInfo
rtcpListenInfo
;
bool
rtcpMux
{
true
};
bool
comedia
{
false
};
struct
sockaddr_storage
remoteAddrStorage
;
struct
sockaddr_storage
rtcpRemoteAddrStorage
;
struct
sockaddr_storage
remoteAddrStorage
{
};
struct
sockaddr_storage
rtcpRemoteAddrStorage
{
};
RTC
::
SrtpSession
::
CryptoSuite
srtpCryptoSuite
{
RTC
::
SrtpSession
::
CryptoSuite
::
AES_CM_128_HMAC_SHA1_80
};
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
6a573c26
...
...
@@ -98,7 +98,7 @@ namespace RTC
const
std
::
string
&
id
,
RTC
::
Producer
::
Listener
*
listener
,
const
FBS
::
Transport
::
ProduceRequest
*
data
);
virtual
~
Producer
()
;
~
Producer
()
override
;
public
:
flatbuffers
::
Offset
<
FBS
::
Producer
::
DumpResponse
>
FillBuffer
(
...
...
worker/include/RTC/RTCP/FeedbackRtpTransport.hpp
浏览文件 @
6a573c26
...
...
@@ -209,13 +209,13 @@ namespace RTC
{
}
FeedbackRtpTransportPacket
(
CommonHeader
*
commonHeader
,
size_t
availableLen
);
~
FeedbackRtpTransportPacket
();
~
FeedbackRtpTransportPacket
()
override
;
public
:
AddPacketResult
AddPacket
(
uint16_t
sequenceNumber
,
uint64_t
timestamp
,
size_t
maxRtcpPacketLen
);
// Just for locally generated packets.
void
Finish
();
bool
IsFull
()
bool
IsFull
()
const
{
// NOTE: Since AddPendingChunks() is called at the end, we cannot track
// the exact ongoing value of packetStatusCount. Hence, let's reserve 7
...
...
@@ -224,7 +224,7 @@ namespace RTC
}
bool
IsSerializable
()
const
{
return
this
->
deltas
.
size
()
>
0
;
return
!
this
->
deltas
.
empty
()
;
}
bool
IsCorrect
()
const
// Just for locally generated packets.
{
...
...
worker/include/RTC/RateCalculator.hpp
浏览文件 @
6a573c26
...
...
@@ -17,7 +17,7 @@ namespace RTC
static
constexpr
uint16_t
DefaultWindowItems
{
100u
};
public
:
RateCalculator
(
explicit
RateCalculator
(
size_t
windowSizeMs
=
DefaultWindowSize
,
float
scale
=
DefaultBpsScale
,
uint16_t
windowItems
=
DefaultWindowItems
)
...
...
worker/include/RTC/Router.hpp
浏览文件 @
6a573c26
...
...
@@ -38,7 +38,7 @@ namespace RTC
public
:
explicit
Router
(
RTC
::
Shared
*
shared
,
const
std
::
string
&
id
,
Listener
*
listener
);
virtual
~
Router
()
;
~
Router
()
override
;
public
:
flatbuffers
::
Offset
<
FBS
::
Router
::
DumpResponse
>
FillBuffer
(
...
...
@@ -111,7 +111,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::RtpObserver::Listener. */
public
:
RTC
::
Producer
*
RtpObserverGetProducer
(
RTC
::
RtpObserver
*
,
const
std
::
string
&
id
)
override
;
RTC
::
Producer
*
RtpObserverGetProducer
(
RTC
::
RtpObserver
*
rtpObserver
,
const
std
::
string
&
id
)
override
;
void
OnRtpObserverAddProducer
(
RTC
::
RtpObserver
*
rtpObserver
,
RTC
::
Producer
*
producer
)
override
;
void
OnRtpObserverRemoveProducer
(
RTC
::
RtpObserver
*
rtpObserver
,
RTC
::
Producer
*
producer
)
override
;
...
...
worker/include/RTC/RtcLogger.hpp
浏览文件 @
6a573c26
...
...
@@ -40,17 +40,17 @@ namespace RTC
void
Clear
();
public
:
uint64_t
timestamp
;
uint64_t
timestamp
{}
;
std
::
string
recvTransportId
{};
std
::
string
sendTransportId
{};
std
::
string
routerId
{};
std
::
string
producerId
{};
std
::
string
consumerId
{};
uint32_t
recvRtpTimestamp
;
uint32_t
sendRtpTimestamp
;
uint16_t
recvSeqNumber
;
uint16_t
sendSeqNumber
;
bool
dropped
;
uint32_t
recvRtpTimestamp
{}
;
uint32_t
sendRtpTimestamp
{}
;
uint16_t
recvSeqNumber
{}
;
uint16_t
sendSeqNumber
{}
;
bool
dropped
{}
;
DropReason
dropReason
{
DropReason
::
NONE
};
};
};
// namespace RtcLogger
...
...
worker/include/RTC/RtpObserver.hpp
浏览文件 @
6a573c26
...
...
@@ -27,7 +27,7 @@ namespace RTC
public
:
RtpObserver
(
RTC
::
Shared
*
shared
,
const
std
::
string
&
id
,
RTC
::
RtpObserver
::
Listener
*
listener
);
virtual
~
RtpObserver
()
;
~
RtpObserver
()
override
;
public
:
void
Pause
();
...
...
worker/include/RTC/RtpPacket.hpp
浏览文件 @
6a573c26
...
...
@@ -217,7 +217,7 @@ namespace RTC
bool
HasHeaderExtension
()
const
{
return
(
this
->
headerExtension
?
true
:
false
);
return
(
this
->
headerExtension
!=
nullptr
);
}
// After calling this method, all the extension ids are reset to 0.
...
...
@@ -366,7 +366,7 @@ namespace RTC
return
true
;
}
bool
UpdateAbsSendTime
(
uint64_t
ms
)
bool
UpdateAbsSendTime
(
uint64_t
ms
)
const
{
uint8_t
extenLen
;
uint8_t
*
extenValue
=
GetExtension
(
this
->
absSendTimeExtensionId
,
extenLen
);
...
...
@@ -398,7 +398,7 @@ namespace RTC
return
true
;
}
bool
UpdateTransportWideCc01
(
uint16_t
wideSeqNumber
)
bool
UpdateTransportWideCc01
(
uint16_t
wideSeqNumber
)
const
{
uint8_t
extenLen
;
uint8_t
*
extenValue
=
GetExtension
(
this
->
transportWideCc01ExtensionId
,
extenLen
);
...
...
@@ -446,7 +446,7 @@ namespace RTC
}
volume
=
Utils
::
Byte
::
Get1Byte
(
extenValue
,
0
);
voice
=
(
volume
&
(
1
<<
7
))
?
true
:
false
;
voice
=
(
volume
&
(
1
<<
7
))
!=
0
;
volume
&=
~
(
1
<<
7
);
return
true
;
...
...
@@ -462,13 +462,13 @@ namespace RTC
return
false
;
}
uint8_t
cvoByte
=
Utils
::
Byte
::
Get1Byte
(
extenValue
,
0
);
uint8_t
cameraValue
=
((
cvoByte
&
0
b00001000
)
>>
3
);
uint8_t
flipValue
=
((
cvoByte
&
0
b00000100
)
>>
2
);
uint8_t
rotationValue
=
(
cvoByte
&
0
b00000011
);
const
uint8_t
cvoByte
=
Utils
::
Byte
::
Get1Byte
(
extenValue
,
0
);
const
uint8_t
cameraValue
=
((
cvoByte
&
0
b00001000
)
>>
3
);
const
uint8_t
flipValue
=
((
cvoByte
&
0
b00000100
)
>>
2
);
const
uint8_t
rotationValue
=
(
cvoByte
&
0
b00000011
);
camera
=
cameraValue
?
true
:
false
;
flip
=
flipValue
?
true
:
false
;
camera
=
cameraValue
!=
0
;
flip
=
flipValue
!=
0
;
// Using counter clockwise values.
switch
(
rotationValue
)
...
...
@@ -517,12 +517,7 @@ namespace RTC
auto
*
extension
=
it
->
second
;
// In Two-Byte extensions value length may be zero. If so, return false.
if
(
extension
->
len
==
0u
)
{
return
false
;
}
return
true
;
return
extension
->
len
!=
0u
;
}
else
{
...
...
@@ -666,7 +661,7 @@ namespace RTC
HeaderExtension
*
headerExtension
{
nullptr
};
// There might be up to 14 one-byte header extensions
// (https://datatracker.ietf.org/doc/html/rfc5285#section-4.2), use std::array.
std
::
array
<
OneByteExtension
*
,
14
>
oneByteExtensions
;
std
::
array
<
OneByteExtension
*
,
14
>
oneByteExtensions
{}
;
absl
::
flat_hash_map
<
uint8_t
,
TwoBytesExtension
*>
mapTwoBytesExtensions
;
uint8_t
midExtensionId
{
0u
};
uint8_t
ridExtensionId
{
0u
};
...
...
worker/include/RTC/RtpRetransmissionBuffer.hpp
浏览文件 @
6a573c26
...
...
@@ -32,6 +32,10 @@ namespace RTC
uint8_t
sentTimes
{
0u
};
};
private
:
static
Item
*
FillItem
(
Item
*
item
,
RTC
::
RtpPacket
*
packet
,
std
::
shared_ptr
<
RTC
::
RtpPacket
>&
sharedPacket
);
public
:
RtpRetransmissionBuffer
(
uint16_t
maxItems
,
uint32_t
maxRetransmissionDelayMs
,
uint32_t
clockRate
);
~
RtpRetransmissionBuffer
();
...
...
@@ -48,8 +52,6 @@ namespace RTC
void
RemoveOldest
(
uint16_t
numItems
);
bool
ClearTooOldByTimestamp
(
uint32_t
newestTimestamp
);
bool
IsTooOldTimestamp
(
uint32_t
timestamp
,
uint32_t
newestTimestamp
)
const
;
Item
*
FillItem
(
Item
*
item
,
RTC
::
RtpPacket
*
packet
,
std
::
shared_ptr
<
RTC
::
RtpPacket
>&
sharedPacket
)
const
;
protected
:
// Make buffer protected for testing purposes.
...
...
worker/include/RTC/RtpStreamRecv.hpp
浏览文件 @
6a573c26
...
...
@@ -47,7 +47,7 @@ namespace RTC
RTC
::
RtpStream
::
Params
&
params
,
unsigned
int
sendNackDelayMs
,
bool
useRtpInactivityCheck
);
~
RtpStreamRecv
();
~
RtpStreamRecv
()
override
;
flatbuffers
::
Offset
<
FBS
::
RtpStream
::
Stats
>
FillBufferStats
(
flatbuffers
::
FlatBufferBuilder
&
builder
)
override
;
...
...
worker/include/RTC/SctpAssociation.hpp
浏览文件 @
6a573c26
...
...
@@ -89,7 +89,7 @@ namespace RTC
{
return
this
->
sctpBufferedAmount
;
}
void
ProcessSctpData
(
const
uint8_t
*
data
,
size_t
len
);
void
ProcessSctpData
(
const
uint8_t
*
data
,
size_t
len
)
const
;
void
SendSctpMessage
(
RTC
::
DataConsumer
*
dataConsumer
,
const
uint8_t
*
msg
,
...
...
@@ -101,7 +101,7 @@ namespace RTC
void
DataConsumerClosed
(
RTC
::
DataConsumer
*
dataConsumer
);
private
:
void
ResetSctpStream
(
uint16_t
streamId
,
StreamDirection
);
void
ResetSctpStream
(
uint16_t
streamId
,
StreamDirection
direction
);
void
AddOutgoingStreams
(
bool
force
=
false
);
/* Callbacks fired by usrsctp events. */
...
...
worker/include/RTC/StunPacket.hpp
浏览文件 @
6a573c26
...
...
@@ -63,15 +63,15 @@ namespace RTC
// DOC: https://tools.ietf.org/html/draft-ietf-avtcore-rfc5764-mux-fixes
(
data
[
0
]
<
3
)
&&
// Magic cookie must match.
(
data
[
4
]
==
StunPacket
::
magicCookie
[
0
])
&&
(
data
[
5
]
==
StunPacket
::
m
agicCookie
[
1
])
&&
(
data
[
6
]
==
StunPacket
::
magicCookie
[
2
])
&&
(
data
[
7
]
==
StunPacket
::
m
agicCookie
[
3
])
(
data
[
4
]
==
StunPacket
::
MagicCookie
[
0
])
&&
(
data
[
5
]
==
StunPacket
::
M
agicCookie
[
1
])
&&
(
data
[
6
]
==
StunPacket
::
MagicCookie
[
2
])
&&
(
data
[
7
]
==
StunPacket
::
M
agicCookie
[
3
])
);
// clang-format on
}
static
StunPacket
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
private
:
static
const
uint8_t
m
agicCookie
[];
static
const
uint8_t
M
agicCookie
[];
public
:
StunPacket
(
...
...
@@ -173,7 +173,7 @@ namespace RTC
}
bool
HasMessageIntegrity
()
const
{
return
(
this
->
messageIntegrity
?
true
:
false
);
return
(
this
->
messageIntegrity
!=
nullptr
);
}
bool
HasFingerprint
()
const
{
...
...
worker/include/RTC/Transport.hpp
浏览文件 @
6a573c26
...
...
@@ -148,7 +148,7 @@ namespace RTC
const
std
::
string
&
id
,
RTC
::
Transport
::
Listener
*
listener
,
const
FBS
::
Transport
::
Options
*
options
);
virtual
~
Transport
()
;
~
Transport
()
override
;
public
:
void
CloseProducersAndConsumers
();
...
...
@@ -271,7 +271,7 @@ namespace RTC
const
uint8_t
*
msg
,
size_t
len
,
uint32_t
ppid
,
onQueuedCallback
*
=
nullptr
)
override
;
onQueuedCallback
*
cb
=
nullptr
)
override
;
void
OnDataConsumerDataProducerClosed
(
RTC
::
DataConsumer
*
dataConsumer
)
override
;
/* Pure virtual methods inherited from RTC::SctpAssociation::Listener. */
...
...
worker/include/RTC/TransportCongestionControlClient.hpp
浏览文件 @
6a573c26
...
...
@@ -58,7 +58,7 @@ namespace RTC
uint32_t
initialAvailableBitrate
,
uint32_t
maxOutgoingBitrate
,
uint32_t
minOutgoingBitrate
);
virtual
~
TransportCongestionControlClient
()
;
~
TransportCongestionControlClient
()
override
;
public
:
RTC
::
BweType
GetBweType
()
const
...
...
worker/include/RTC/TransportCongestionControlServer.hpp
浏览文件 @
6a573c26
...
...
@@ -31,7 +31,7 @@ namespace RTC
RTC
::
TransportCongestionControlServer
::
Listener
*
listener
,
RTC
::
BweType
bweType
,
size_t
maxRtcpPacketLen
);
virtual
~
TransportCongestionControlServer
()
;
~
TransportCongestionControlServer
()
override
;
public
:
RTC
::
BweType
GetBweType
()
const
...
...
worker/include/RTC/TransportTuple.hpp
浏览文件 @
6a573c26
...
...
@@ -245,7 +245,9 @@ namespace RTC
RTC
::
TcpConnection
*
tcpConnection
{
nullptr
};
std
::
string
localAnnouncedIp
;
// Others.
struct
sockaddr_storage
udpRemoteAddrStorage
;
struct
sockaddr_storage
udpRemoteAddrStorage
{
};
Protocol
protocol
;
};
}
// namespace RTC
...
...
worker/include/RTC/TrendCalculator.hpp
浏览文件 @
6a573c26
...
...
@@ -11,7 +11,7 @@ namespace RTC
static
constexpr
float
DecreaseFactor
{
0.05
f
};
// per second.
public
:
TrendCalculator
(
float
decreaseFactor
=
DecreaseFactor
);
explicit
TrendCalculator
(
float
decreaseFactor
=
DecreaseFactor
);
public
:
uint32_t
GetValue
()
const
...
...
worker/include/RTC/WebRtcServer.hpp
浏览文件 @
6a573c26
...
...
@@ -38,17 +38,20 @@ namespace RTC
std
::
string
announcedIp
;
};
private
:
static
std
::
string
GetLocalIceUsernameFragmentFromReceivedStunPacket
(
RTC
::
StunPacket
*
packet
);
public
:
WebRtcServer
(
RTC
::
Shared
*
shared
,
const
std
::
string
&
id
,
const
flatbuffers
::
Vector
<
flatbuffers
::
Offset
<
FBS
::
Transport
::
ListenInfo
>>*
listenInfos
);
~
WebRtcServer
();
~
WebRtcServer
()
override
;
public
:
flatbuffers
::
Offset
<
FBS
::
WebRtcServer
::
DumpResponse
>
FillBuffer
(
flatbuffers
::
FlatBufferBuilder
&
builder
)
const
;
const
std
::
vector
<
RTC
::
IceCandidate
>
GetIceCandidates
(
std
::
vector
<
RTC
::
IceCandidate
>
GetIceCandidates
(
bool
enableUdp
,
bool
enableTcp
,
bool
preferUdp
,
bool
preferTcp
)
const
;
/* Methods inherited from Channel::ChannelSocket::RequestHandler. */
...
...
@@ -56,7 +59,6 @@ namespace RTC
void
HandleRequest
(
Channel
::
ChannelRequest
*
request
)
override
;
private
:
std
::
string
GetLocalIceUsernameFragmentFromReceivedStunPacket
(
RTC
::
StunPacket
*
packet
)
const
;
void
OnPacketReceived
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
OnStunDataReceived
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
OnNonStunDataReceived
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
...
...
worker/include/handles/TcpConnectionHandle.hpp
浏览文件 @
6a573c26
...
...
@@ -24,9 +24,8 @@ public:
/* Struct for the data field of uv_req_t when writing into the connection. */
struct
UvWriteData
{
explicit
UvWriteData
(
size_t
storeSize
)
explicit
UvWriteData
(
size_t
storeSize
)
:
store
(
new
uint8_t
[
storeSize
])
{
this
->
store
=
new
uint8_t
[
storeSize
];
}
// Disable copy constructor because of the dynamically allocated data (store).
...
...
@@ -38,7 +37,7 @@ public:
delete
this
->
cb
;
}
uv_write_t
req
;
uv_write_t
req
{}
;
uint8_t
*
store
{
nullptr
};
TcpConnectionHandle
::
onSendCallback
*
cb
{
nullptr
};
};
...
...
@@ -132,7 +131,9 @@ protected:
size_t
bufferDataLen
{
0u
};
std
::
string
localIp
;
uint16_t
localPort
{
0u
};
struct
sockaddr_storage
peerAddr
;
struct
sockaddr_storage
peerAddr
{
};
std
::
string
peerIp
;
uint16_t
peerPort
{
0u
};
...
...
worker/include/handles/TcpServerHandle.hpp
浏览文件 @
6a573c26
...
...
@@ -13,8 +13,8 @@ public:
/**
* uvHandle must be an already initialized and binded uv_tcp_t pointer.
*/
TcpServerHandle
(
uv_tcp_t
*
uvHandle
);
virtual
~
TcpServerHandle
()
override
;
explicit
TcpServerHandle
(
uv_tcp_t
*
uvHandle
);
~
TcpServerHandle
()
override
;
public
:
void
Close
();
...
...
@@ -64,7 +64,9 @@ public:
void
OnTcpConnectionClosed
(
TcpConnectionHandle
*
connection
)
override
;
protected
:
struct
sockaddr_storage
localAddr
;
struct
sockaddr_storage
localAddr
{
};
std
::
string
localIp
;
uint16_t
localPort
{
0u
};
...
...
worker/include/handles/UdpSocketHandle.hpp
浏览文件 @
6a573c26
...
...
@@ -14,9 +14,8 @@ public:
/* Struct for the data field of uv_req_t when sending a datagram. */
struct
UvSendData
{
explicit
UvSendData
(
size_t
storeSize
)
explicit
UvSendData
(
size_t
storeSize
)
:
store
(
new
uint8_t
[
storeSize
])
{
this
->
store
=
new
uint8_t
[
storeSize
];
}
// Disable copy constructor because of the dynamically allocated data (store).
...
...
@@ -28,7 +27,7 @@ public:
delete
this
->
cb
;
}
uv_udp_send_t
req
;
uv_udp_send_t
req
{}
;
uint8_t
*
store
{
nullptr
};
UdpSocketHandle
::
onSendCallback
*
cb
{
nullptr
};
};
...
...
@@ -95,7 +94,9 @@ protected:
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
=
0
;
protected
:
struct
sockaddr_storage
localAddr
;
struct
sockaddr_storage
localAddr
{
};
std
::
string
localIp
;
uint16_t
localPort
{
0u
};
...
...
worker/include/handles/UnixStreamSocketHandle.hpp
浏览文件 @
6a573c26
...
...
@@ -11,9 +11,8 @@ public:
/* Struct for the data field of uv_req_t when writing data. */
struct
UvWriteData
{
explicit
UvWriteData
(
size_t
storeSize
)
explicit
UvWriteData
(
size_t
storeSize
)
:
store
(
new
uint8_t
[
storeSize
])
{
this
->
store
=
new
uint8_t
[
storeSize
];
}
// Disable copy constructor because of the dynamically allocated data (store).
...
...
@@ -24,7 +23,7 @@ public:
delete
[]
this
->
store
;
}
uv_write_t
req
;
uv_write_t
req
{}
;
uint8_t
*
store
{
nullptr
};
};
...
...
worker/src/Channel/ChannelSocket.cpp
浏览文件 @
6a573c26
...
...
@@ -43,13 +43,12 @@ namespace Channel
ChannelWriteFn
channelWriteFn
,
ChannelWriteCtx
channelWriteCtx
)
:
channelReadFn
(
channelReadFn
),
channelReadCtx
(
channelReadCtx
),
channelWriteFn
(
channelWriteFn
),
channelWriteCtx
(
channelWriteCtx
)
channelWriteCtx
(
channelWriteCtx
)
,
uvReadHandle
(
new
uv_async_t
)
{
MS_TRACE_STD
();
int
err
;
this
->
uvReadHandle
=
new
uv_async_t
;
this
->
uvReadHandle
->
data
=
static_cast
<
void
*>
(
this
);
err
=
...
...
@@ -122,7 +121,7 @@ namespace Channel
this
->
listener
=
listener
;
}
void
ChannelSocket
::
Send
(
const
uint8_t
*
message
,
uint32_t
message
Len
)
void
ChannelSocket
::
Send
(
const
uint8_t
*
data
,
uint32_t
data
Len
)
{
MS_TRACE_STD
();
...
...
@@ -131,17 +130,17 @@ namespace Channel
return
;
}
if
(
message
Len
>
PayloadMaxLen
)
if
(
data
Len
>
PayloadMaxLen
)
{
MS_ERROR_STD
(
"message too big"
);
return
;
}
SendImpl
(
reinterpret_cast
<
const
uint8_t
*>
(
message
),
message
Len
);
SendImpl
(
reinterpret_cast
<
const
uint8_t
*>
(
data
),
data
Len
);
}
void
ChannelSocket
::
SendLog
(
const
char
*
msg
,
uint32_t
message
Len
)
void
ChannelSocket
::
SendLog
(
const
char
*
data
,
uint32_t
data
Len
)
{
MS_TRACE_STD
();
...
...
@@ -150,14 +149,14 @@ namespace Channel
return
;
}
if
(
message
Len
>
PayloadMaxLen
)
if
(
data
Len
>
PayloadMaxLen
)
{
MS_ERROR_STD
(
"message too big"
);
return
;
}
auto
log
=
FBS
::
Log
::
CreateLogDirect
(
this
->
bufferBuilder
,
msg
);
auto
log
=
FBS
::
Log
::
CreateLogDirect
(
this
->
bufferBuilder
,
data
);
auto
message
=
FBS
::
Message
::
CreateMessage
(
this
->
bufferBuilder
,
FBS
::
Message
::
Body
::
Log
,
log
.
Union
());
...
...
@@ -263,7 +262,8 @@ namespace Channel
}
}
void
ChannelSocket
::
OnConsumerSocketMessage
(
ConsumerSocket
*
/*consumerSocket*/
,
char
*
msg
,
size_t
msgLen
)
void
ChannelSocket
::
OnConsumerSocketMessage
(
ConsumerSocket
*
/*consumerSocket*/
,
char
*
msg
,
size_t
/*msgLen*/
)
{
MS_TRACE
();
...
...
@@ -356,7 +356,7 @@ namespace Channel
return
;
}
size_t
readLen
=
this
->
bufferDataLen
-
msgStart
;
const
size_t
readLen
=
this
->
bufferDataLen
-
msgStart
;
if
(
readLen
<
sizeof
(
uint32_t
))
{
...
...
worker/src/DepLibSRTP.cpp
浏览文件 @
6a573c26
...
...
@@ -8,8 +8,8 @@
/* Static variables. */
static
std
::
mutex
g
lobalSyncMutex
;
static
size_t
g
lobalInstances
=
0
;
static
std
::
mutex
G
lobalSyncMutex
;
static
size_t
G
lobalInstances
=
0
;
// clang-format off
std
::
vector
<
const
char
*>
DepLibSRTP
::
errors
=
...
...
@@ -50,9 +50,9 @@ void DepLibSRTP::ClassInit()
MS_TRACE
();
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
g
lobalSyncMutex
);
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
G
lobalSyncMutex
);
if
(
g
lobalInstances
==
0
)
if
(
G
lobalInstances
==
0
)
{
MS_DEBUG_TAG
(
info
,
"libsrtp version:
\"
%s
\"
"
,
srtp_get_version_string
());
...
...
@@ -64,7 +64,7 @@ void DepLibSRTP::ClassInit()
}
}
++
g
lobalInstances
;
++
G
lobalInstances
;
}
}
...
...
@@ -73,10 +73,10 @@ void DepLibSRTP::ClassDestroy()
MS_TRACE
();
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
g
lobalSyncMutex
);
--
g
lobalInstances
;
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
G
lobalSyncMutex
);
--
G
lobalInstances
;
if
(
g
lobalInstances
==
0
)
if
(
G
lobalInstances
==
0
)
{
srtp_shutdown
();
}
...
...
worker/src/DepLibWebRTC.cpp
浏览文件 @
6a573c26
...
...
@@ -9,7 +9,7 @@
/* Static. */
static
std
::
once_flag
g
lobalInitOnce
;
static
std
::
once_flag
G
lobalInitOnce
;
/* Static methods. */
...
...
@@ -21,7 +21,7 @@ void DepLibWebRTC::ClassInit()
info
,
"libwebrtc field trials:
\"
%s
\"
"
,
Settings
::
configuration
.
libwebrtcFieldTrials
.
c_str
());
std
::
call_once
(
g
lobalInitOnce
,
G
lobalInitOnce
,
[]
{
webrtc
::
field_trial
::
InitFieldTrialsFromString
(
...
...
worker/src/DepOpenSSL.cpp
浏览文件 @
6a573c26
...
...
@@ -9,7 +9,7 @@
/* Static. */
static
std
::
once_flag
g
lobalInitOnce
;
static
std
::
once_flag
G
lobalInitOnce
;
/* Static methods. */
...
...
@@ -18,7 +18,7 @@ void DepOpenSSL::ClassInit()
MS_TRACE
();
std
::
call_once
(
g
lobalInitOnce
,
G
lobalInitOnce
,
[]
{
MS_DEBUG_TAG
(
info
,
"openssl version:
\"
%s
\"
"
,
OpenSSL_version
(
OPENSSL_VERSION
));
...
...
worker/src/DepUsrSCTP.cpp
浏览文件 @
6a573c26
...
...
@@ -69,7 +69,7 @@ void DepUsrSCTP::ClassInit()
MS_DEBUG_TAG
(
info
,
"usrsctp"
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
if
(
GlobalInstances
==
0
)
{
...
...
@@ -90,7 +90,7 @@ void DepUsrSCTP::ClassDestroy()
{
MS_TRACE
();
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
--
GlobalInstances
;
if
(
GlobalInstances
==
0
)
...
...
@@ -126,7 +126,7 @@ uintptr_t DepUsrSCTP::GetNextSctpAssociationId()
{
MS_TRACE
();
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
// NOTE: usrsctp_connect() fails with a value of 0.
if
(
DepUsrSCTP
::
nextSctpAssociationId
==
0u
)
...
...
@@ -154,7 +154,7 @@ void DepUsrSCTP::RegisterSctpAssociation(RTC::SctpAssociation* sctpAssociation)
{
MS_TRACE
();
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
MS_ASSERT
(
DepUsrSCTP
::
checker
!=
nullptr
,
"Checker not created"
);
...
...
@@ -176,7 +176,7 @@ void DepUsrSCTP::DeregisterSctpAssociation(RTC::SctpAssociation* sctpAssociation
{
MS_TRACE
();
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
MS_ASSERT
(
DepUsrSCTP
::
checker
!=
nullptr
,
"Checker not created"
);
...
...
@@ -195,7 +195,7 @@ RTC::SctpAssociation* DepUsrSCTP::RetrieveSctpAssociation(uintptr_t id)
{
MS_TRACE
();
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
GlobalSyncMutex
);
auto
it
=
DepUsrSCTP
::
mapIdSctpAssociation
.
find
(
id
);
...
...
@@ -209,11 +209,9 @@ RTC::SctpAssociation* DepUsrSCTP::RetrieveSctpAssociation(uintptr_t id)
/* DepUsrSCTP::Checker instance methods. */
DepUsrSCTP
::
Checker
::
Checker
()
DepUsrSCTP
::
Checker
::
Checker
()
:
timer
(
new
TimerHandle
(
this
))
{
MS_TRACE
();
this
->
timer
=
new
TimerHandle
(
this
);
}
DepUsrSCTP
::
Checker
::~
Checker
()
...
...
worker/src/Logger.cpp
浏览文件 @
6a573c26
...
...
@@ -6,9 +6,9 @@
/* Class variables. */
const
uint64_t
Logger
::
p
id
{
static_cast
<
uint64_t
>
(
uv_os_getpid
())
};
const
uint64_t
Logger
::
P
id
{
static_cast
<
uint64_t
>
(
uv_os_getpid
())
};
thread_local
Channel
::
ChannelSocket
*
Logger
::
channel
{
nullptr
};
thread_local
char
Logger
::
buffer
[
Logger
::
b
ufferSize
];
thread_local
char
Logger
::
buffer
[
Logger
::
B
ufferSize
];
/* Class methods. */
...
...
worker/src/MediaSoupErrors.cpp
浏览文件 @
6a573c26
...
...
@@ -2,4 +2,4 @@
#include "MediaSoupErrors.hpp"
thread_local
char
MediaSoupError
::
buffer
[
MediaSoupError
::
b
ufferSize
];
thread_local
char
MediaSoupError
::
buffer
[
MediaSoupError
::
B
ufferSize
];
worker/src/RTC/ActiveSpeakerObserver.cpp
浏览文件 @
6a573c26
...
...
@@ -67,8 +67,8 @@ namespace RTC
inline
bool
ComputeBigs
(
const
std
::
vector
<
uint8_t
>&
littles
,
std
::
vector
<
uint8_t
>&
bigs
,
uint8_t
threashold
)
{
uint32_t
littleLen
=
littles
.
size
();
uint32_t
bigLen
=
bigs
.
size
();
const
uint32_t
littleLen
=
littles
.
size
();
const
uint32_t
bigLen
=
bigs
.
size
();
const
uint32_t
littleLenPerBig
=
littleLen
/
bigLen
;
bool
changed
{
false
};
...
...
@@ -99,12 +99,10 @@ namespace RTC
const
std
::
string
&
id
,
RTC
::
RtpObserver
::
Listener
*
listener
,
const
FBS
::
ActiveSpeakerObserver
::
ActiveSpeakerObserverOptions
*
options
)
:
RTC
::
RtpObserver
(
shared
,
id
,
listener
)
:
RTC
::
RtpObserver
(
shared
,
id
,
listener
)
,
interval
(
options
->
interval
())
{
MS_TRACE
();
this
->
interval
=
options
->
interval
();
if
(
this
->
interval
<
100
)
{
this
->
interval
=
100
;
...
...
@@ -231,14 +229,14 @@ namespace RTC
return
;
}
uint8_t
volume
=
127
-
level
;
const
uint8_t
volume
=
127
-
level
;
auto
it
=
this
->
mapProducerSpeakers
.
find
(
producer
->
id
);
if
(
it
!=
this
->
mapProducerSpeakers
.
end
())
{
auto
*
producerSpeaker
=
it
->
second
;
uint64_t
now
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
now
=
DepLibUV
::
GetTimeMs
();
producerSpeaker
->
speaker
->
LevelChanged
(
volume
,
now
);
}
...
...
@@ -258,7 +256,7 @@ namespace RTC
this
->
periodicTimer
->
Restart
();
}
void
ActiveSpeakerObserver
::
OnTimer
(
TimerHandle
*
timer
)
void
ActiveSpeakerObserver
::
OnTimer
(
TimerHandle
*
/*timer*/
)
{
MS_TRACE
();
...
...
@@ -299,7 +297,7 @@ namespace RTC
MS_TRACE
();
std
::
string
newDominantId
;
int32_t
speakerCount
=
this
->
mapProducerSpeakers
.
size
();
const
int32_t
speakerCount
=
this
->
mapProducerSpeakers
.
size
();
if
(
speakerCount
==
0
)
{
...
...
@@ -352,9 +350,9 @@ namespace RTC
speaker
->
GetActivityScore
(
interval
)
/
dominantSpeaker
->
GetActivityScore
(
interval
));
}
double
c1
=
this
->
relativeSpeachActivities
[
0
];
double
c2
=
this
->
relativeSpeachActivities
[
1
];
double
c3
=
this
->
relativeSpeachActivities
[
2
];
const
double
c1
=
this
->
relativeSpeachActivities
[
0
];
const
double
c2
=
this
->
relativeSpeachActivities
[
1
];
const
double
c3
=
this
->
relativeSpeachActivities
[
2
];
if
((
c1
>
C1
)
&&
(
c2
>
C2
)
&&
(
c3
>
C3
)
&&
(
c2
>
newDominantC2
))
{
...
...
@@ -383,7 +381,7 @@ namespace RTC
auto
*
producerSpeaker
=
kv
.
second
;
auto
*
speaker
=
producerSpeaker
->
speaker
;
const
auto
&
id
=
producerSpeaker
->
producer
->
id
;
uint64_t
idle
=
now
-
speaker
->
lastLevelChangeTime
;
const
uint64_t
idle
=
now
-
speaker
->
lastLevelChangeTime
;
if
(
SpeakerIdleTimeout
<
idle
&&
(
this
->
dominantId
.
empty
()
||
id
!=
this
->
dominantId
))
{
...
...
@@ -397,11 +395,10 @@ namespace RTC
}
ActiveSpeakerObserver
::
ProducerSpeaker
::
ProducerSpeaker
(
RTC
::
Producer
*
producer
)
:
producer
(
producer
)
:
producer
(
producer
)
,
speaker
(
new
Speaker
())
{
MS_TRACE
();
this
->
speaker
=
new
Speaker
();
this
->
speaker
->
paused
=
producer
->
IsPaused
();
}
...
...
@@ -416,7 +413,7 @@ namespace RTC
:
immediateActivityScore
(
MinActivityScore
),
mediumActivityScore
(
MinActivityScore
),
longActivityScore
(
MinActivityScore
),
lastLevelChangeTime
(
DepLibUV
::
GetTimeMs
()),
minLevel
(
MinLevel
),
nextMinLevel
(
MinLevel
),
immediates
(
ImmediateBuffLen
,
0
),
mediums
(
MediumsBuffLen
,
0
),
longs
(
LongsBuffLen
,
0
),
levels
(
LevelsBuffLen
,
0
)
,
nextLevelIndex
(
0
)
mediums
(
MediumsBuffLen
,
0
),
longs
(
LongsBuffLen
,
0
),
levels
(
LevelsBuffLen
,
0
)
{
MS_TRACE
();
}
...
...
@@ -441,7 +438,7 @@ namespace RTC
}
}
double
ActiveSpeakerObserver
::
Speaker
::
GetActivityScore
(
uint8_t
interval
)
double
ActiveSpeakerObserver
::
Speaker
::
GetActivityScore
(
uint8_t
interval
)
const
{
MS_TRACE
();
...
...
@@ -486,7 +483,7 @@ namespace RTC
// The algorithm expect to have an update every 20 milliseconds. If the
// Producer is paused, using a different packetization time or using DTX
// we need to update more than one sample when receiving an audio packet.
uint32_t
intervalsUpdated
=
const
uint32_t
intervalsUpdated
=
std
::
min
(
std
::
max
(
static_cast
<
uint32_t
>
(
elapsed
/
20
),
1U
),
LevelsBuffLen
);
for
(
uint32_t
i
{
0u
};
i
<
intervalsUpdated
;
++
i
)
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
6a573c26
...
...
@@ -19,12 +19,11 @@ namespace RTC
Listener
*
listener
,
const
FBS
::
Transport
::
ConsumeRequest
*
data
,
RTC
::
RtpParameters
::
Type
type
)
:
id
(
id
),
producerId
(
producerId
),
shared
(
shared
),
listener
(
listener
),
type
(
type
)
:
id
(
id
),
producerId
(
producerId
),
shared
(
shared
),
listener
(
listener
),
kind
(
RTC
::
Media
::
Kind
(
data
->
kind
())),
type
(
type
)
{
MS_TRACE
();
this
->
kind
=
RTC
::
Media
::
Kind
(
data
->
kind
());
// This may throw.
this
->
rtpParameters
=
RTC
::
RtpParameters
(
data
->
rtpParameters
());
...
...
worker/src/RTC/DataConsumer.cpp
浏览文件 @
6a573c26
...
...
@@ -280,7 +280,7 @@ namespace RTC
const
auto
*
body
=
request
->
data
->
body_as
<
FBS
::
DataConsumer
::
SendRequest
>
();
const
uint8_t
*
data
=
body
->
data
()
->
Data
();
size_t
len
=
body
->
data
()
->
size
();
const
size_t
len
=
body
->
data
()
->
size
();
if
(
len
>
this
->
maxMessageSize
)
{
...
...
@@ -303,9 +303,9 @@ namespace RTC
}
});
static
std
::
vector
<
uint16_t
>
E
mptySubchannels
;
static
std
::
vector
<
uint16_t
>
e
mptySubchannels
;
SendMessage
(
data
,
len
,
body
->
ppid
(),
E
mptySubchannels
,
std
::
nullopt
,
cb
);
SendMessage
(
data
,
len
,
body
->
ppid
(),
e
mptySubchannels
,
std
::
nullopt
,
cb
);
break
;
}
...
...
@@ -543,7 +543,7 @@ namespace RTC
// If subchannels are given, verify that this data consumer is subscribed
// to at least one of them.
if
(
subchannels
.
size
()
>
0
)
if
(
!
subchannels
.
empty
()
)
{
bool
subchannelMatched
{
false
};
...
...
worker/src/RTC/DataProducer.cpp
浏览文件 @
6a573c26
...
...
@@ -202,7 +202,7 @@ namespace RTC
{
const
auto
*
body
=
notification
->
data
->
body_as
<
FBS
::
DataProducer
::
SendNotification
>
();
const
uint8_t
*
data
=
body
->
data
()
->
Data
();
size_t
len
=
body
->
data
()
->
size
();
const
size_t
len
=
body
->
data
()
->
size
();
if
(
len
>
this
->
maxMessageSize
)
{
...
...
worker/src/RTC/DirectTransport.cpp
浏览文件 @
6a573c26
...
...
@@ -213,7 +213,11 @@ namespace RTC
}
void
DirectTransport
::
SendMessage
(
RTC
::
DataConsumer
*
dataConsumer
,
const
uint8_t
*
msg
,
size_t
len
,
uint32_t
ppid
,
onQueuedCallback
*
cb
)
RTC
::
DataConsumer
*
dataConsumer
,
const
uint8_t
*
msg
,
size_t
len
,
uint32_t
ppid
,
onQueuedCallback
*
/*cb*/
)
{
MS_TRACE
();
...
...
worker/src/RTC/DtlsTransport.cpp
浏览文件 @
6a573c26
...
...
@@ -71,14 +71,13 @@ inline static long onSslBioOut(
int
ret
,
size_t
*
/*processed*/
)
{
long
resultOfcallback
=
(
operationType
==
BIO_CB_RETURN
)
?
static_cast
<
long
>
(
ret
)
:
1
;
const
long
resultOfcallback
=
(
operationType
==
BIO_CB_RETURN
)
?
static_cast
<
long
>
(
ret
)
:
1
;
if
(
operationType
==
BIO_CB_WRITE
&&
argp
&&
len
>
0
)
{
MS_DEBUG_DEV
(
"%zu bytes of DTLS data ready to be sent"
,
len
);
RTC
::
DtlsTransport
*
dtlsTransport
=
reinterpret_cast
<
RTC
::
DtlsTransport
*>
(
BIO_get_callback_arg
(
bio
));
auto
*
dtlsTransport
=
reinterpret_cast
<
RTC
::
DtlsTransport
*>
(
BIO_get_callback_arg
(
bio
));
dtlsTransport
->
SendDtlsData
(
reinterpret_cast
<
const
uint8_t
*>
(
argp
),
len
);
}
...
...
@@ -333,7 +332,7 @@ namespace RTC
int
ret
{
0
};
X509_NAME
*
certName
{
nullptr
};
std
::
string
subject
=
const
std
::
string
subject
=
std
::
string
(
"mediasoup"
)
+
std
::
to_string
(
Utils
::
Crypto
::
GetRandomUInt
(
100000
,
999999
));
// Create key with curve.
...
...
@@ -618,8 +617,8 @@ namespace RTC
for
(
auto
&
kv
:
DtlsTransport
::
string2FingerprintAlgorithm
)
{
const
std
::
string
&
algorithmString
=
kv
.
first
;
FingerprintAlgorithm
algorithm
=
kv
.
second
;
const
std
::
string
&
algorithmString
=
kv
.
first
;
const
FingerprintAlgorithm
algorithm
=
kv
.
second
;
uint8_t
binaryFingerprint
[
EVP_MAX_MD_SIZE
];
unsigned
int
size
{
0
};
char
hexFingerprint
[(
EVP_MAX_MD_SIZE
*
3
)
+
1
];
...
...
@@ -693,14 +692,11 @@ namespace RTC
/* Instance methods. */
DtlsTransport
::
DtlsTransport
(
Listener
*
listener
)
:
listener
(
listener
)
DtlsTransport
::
DtlsTransport
(
Listener
*
listener
)
:
listener
(
listener
),
ssl
(
SSL_new
(
DtlsTransport
::
sslCtx
))
{
MS_TRACE
();
/* Set SSL. */
this
->
ssl
=
SSL_new
(
DtlsTransport
::
sslCtx
);
if
(
!
this
->
ssl
)
{
LOG_OPENSSL_ERROR
(
"SSL_new() failed"
);
...
...
worker/src/RTC/KeyFrameRequestManager.cpp
浏览文件 @
6a573c26
...
...
@@ -9,11 +9,10 @@ static constexpr uint32_t KeyFrameRetransmissionWaitTime{ 1000 };
/* PendingKeyFrameInfo methods. */
RTC
::
PendingKeyFrameInfo
::
PendingKeyFrameInfo
(
PendingKeyFrameInfo
::
Listener
*
listener
,
uint32_t
ssrc
)
:
listener
(
listener
),
ssrc
(
ssrc
)
:
listener
(
listener
),
ssrc
(
ssrc
)
,
timer
(
new
TimerHandle
(
this
))
{
MS_TRACE
();
this
->
timer
=
new
TimerHandle
(
this
);
this
->
timer
->
Start
(
KeyFrameRetransmissionWaitTime
);
}
...
...
@@ -39,11 +38,10 @@ inline void RTC::PendingKeyFrameInfo::OnTimer(TimerHandle* timer)
RTC
::
KeyFrameRequestDelayer
::
KeyFrameRequestDelayer
(
KeyFrameRequestDelayer
::
Listener
*
listener
,
uint32_t
ssrc
,
uint32_t
delay
)
:
listener
(
listener
),
ssrc
(
ssrc
)
:
listener
(
listener
),
ssrc
(
ssrc
)
,
timer
(
new
TimerHandle
(
this
))
{
MS_TRACE
();
this
->
timer
=
new
TimerHandle
(
this
);
this
->
timer
->
Start
(
delay
);
}
...
...
worker/src/RTC/NackGenerator.cpp
浏览文件 @
6a573c26
...
...
@@ -21,12 +21,10 @@ namespace RTC
/* Instance methods. */
NackGenerator
::
NackGenerator
(
Listener
*
listener
,
unsigned
int
sendNackDelayMs
)
:
listener
(
listener
),
sendNackDelayMs
(
sendNackDelayMs
),
rtt
(
DefaultRtt
)
:
listener
(
listener
),
sendNackDelayMs
(
sendNackDelayMs
),
timer
(
new
TimerHandle
(
this
)),
rtt
(
DefaultRtt
)
{
MS_TRACE
();
// Set the timer.
this
->
timer
=
new
TimerHandle
(
this
);
}
NackGenerator
::~
NackGenerator
()
...
...
@@ -42,7 +40,7 @@ namespace RTC
{
MS_TRACE
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
const
uint16_t
seq
=
packet
->
GetSequenceNumber
();
const
bool
isKeyFrame
=
packet
->
IsKeyFrame
();
if
(
!
this
->
started
)
...
...
@@ -83,14 +81,7 @@ namespace RTC
this
->
nackList
.
erase
(
it
);
if
(
retries
!=
0
)
{
return
true
;
}
else
{
return
false
;
}
return
retries
!=
0
;
}
// Out of order packet or already handled NACKed packet.
...
...
@@ -145,7 +136,7 @@ namespace RTC
this
->
lastSeq
=
seq
;
// Check if there are any nacks that are waiting for this seq number.
std
::
vector
<
uint16_t
>
nackBatch
=
GetNackBatch
(
NackFilter
::
SEQ
);
const
std
::
vector
<
uint16_t
>
nackBatch
=
GetNackBatch
(
NackFilter
::
SEQ
);
if
(
!
nackBatch
.
empty
())
{
...
...
@@ -256,7 +247,7 @@ namespace RTC
while
(
it
!=
this
->
nackList
.
end
())
{
NackInfo
&
nackInfo
=
it
->
second
;
uint16_t
seq
=
nackInfo
.
seq
;
const
uint16_t
seq
=
nackInfo
.
seq
;
if
(
this
->
sendNackDelayMs
>
0
&&
nowMs
-
nackInfo
.
createdAtMs
<
this
->
sendNackDelayMs
)
{
...
...
@@ -376,7 +367,7 @@ namespace RTC
{
MS_TRACE
();
std
::
vector
<
uint16_t
>
nackBatch
=
GetNackBatch
(
NackFilter
::
TIME
);
const
std
::
vector
<
uint16_t
>
nackBatch
=
GetNackBatch
(
NackFilter
::
TIME
);
if
(
!
nackBatch
.
empty
())
{
...
...
worker/src/RTC/PortManager.cpp
浏览文件 @
6a573c26
...
...
@@ -47,7 +47,9 @@ namespace RTC
int
err
;
const
int
family
=
Utils
::
IP
::
GetFamily
(
ip
);
struct
sockaddr_storage
bindAddr
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sockaddr_storage
bindAddr
{
};
size_t
portIdx
;
std
::
vector
<
bool
>&
ports
=
PortManager
::
GetPorts
(
transport
,
ip
);
size_t
attempt
{
0u
};
...
...
@@ -55,7 +57,7 @@ namespace RTC
uv_handle_t
*
uvHandle
{
nullptr
};
uint16_t
port
;
std
::
string
transportStr
;
uint8_t
bitFlags
=
ConvertSocketFlags
(
flags
,
transport
,
family
);
const
uint8_t
bitFlags
=
ConvertSocketFlags
(
flags
,
transport
,
family
);
switch
(
transport
)
{
...
...
@@ -375,10 +377,12 @@ namespace RTC
int
err
;
const
int
family
=
Utils
::
IP
::
GetFamily
(
ip
);
struct
sockaddr_storage
bindAddr
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sockaddr_storage
bindAddr
{
};
uv_handle_t
*
uvHandle
{
nullptr
};
std
::
string
transportStr
;
uint8_t
bitFlags
=
ConvertSocketFlags
(
flags
,
transport
,
family
);
const
uint8_t
bitFlags
=
ConvertSocketFlags
(
flags
,
transport
,
family
);
switch
(
transport
)
{
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
6a573c26
...
...
@@ -32,13 +32,10 @@ namespace RTC
const
std
::
string
&
id
,
RTC
::
Producer
::
Listener
*
listener
,
const
FBS
::
Transport
::
ProduceRequest
*
data
)
:
id
(
id
),
shared
(
shared
),
listener
(
listener
)
:
id
(
id
),
shared
(
shared
),
listener
(
listener
)
,
kind
(
RTC
::
Media
::
Kind
(
data
->
kind
()))
{
MS_TRACE
();
// This may throw.
this
->
kind
=
RTC
::
Media
::
Kind
(
data
->
kind
());
// This may throw.
this
->
rtpParameters
=
RTC
::
RtpParameters
(
data
->
rtpParameters
());
...
...
worker/src/RTC/RtpPacket.cpp
浏览文件 @
6a573c26
...
...
@@ -158,10 +158,7 @@ namespace RTC
{
MS_TRACE
();
if
(
this
->
buffer
)
{
delete
[]
this
->
buffer
;
}
delete
[]
this
->
buffer
;
}
void
RtpPacket
::
Dump
()
const
...
...
@@ -840,14 +837,7 @@ namespace RTC
return
true
;
}
if
(
this
->
payloadDescriptorHandler
->
Process
(
context
,
this
->
payload
,
marker
))
{
return
true
;
}
else
{
return
false
;
}
return
this
->
payloadDescriptorHandler
->
Process
(
context
,
this
->
payload
,
marker
);
}
void
RtpPacket
::
RestorePayload
()
...
...
worker/src/RTC/RtpRetransmissionBuffer.cpp
浏览文件 @
6a573c26
...
...
@@ -7,6 +7,37 @@
namespace
RTC
{
/* Class methods. */
RtpRetransmissionBuffer
::
Item
*
RtpRetransmissionBuffer
::
FillItem
(
RtpRetransmissionBuffer
::
Item
*
item
,
RTC
::
RtpPacket
*
packet
,
std
::
shared_ptr
<
RTC
::
RtpPacket
>&
sharedPacket
)
{
MS_TRACE
();
// Store original packet into the item. Only clone once and only if
// necessary.
//
// NOTE: This must be done BEFORE assigning item->packet = sharedPacket,
// otherwise the value being copied in item->packet will remain nullptr.
// This is because we are copying an **empty** shared_ptr into another
// shared_ptr (item->packet), so future value assigned via reset() in the
// former doesn't update the value in the copy.
if
(
!
sharedPacket
)
{
sharedPacket
.
reset
(
packet
->
Clone
());
}
// Store original packet and some extra info into the item.
item
->
packet
=
sharedPacket
;
item
->
ssrc
=
packet
->
GetSsrc
();
item
->
sequenceNumber
=
packet
->
GetSequenceNumber
();
item
->
timestamp
=
packet
->
GetTimestamp
();
return
item
;
}
/* Instance methods. */
RtpRetransmissionBuffer
::
RtpRetransmissionBuffer
(
...
...
@@ -76,7 +107,7 @@ namespace RTC
auto
*
item
=
new
Item
();
this
->
buffer
.
push_back
(
FillItem
(
item
,
packet
,
sharedPacket
));
this
->
buffer
.
push_back
(
RtpRetransmissionBuffer
::
FillItem
(
item
,
packet
,
sharedPacket
));
return
;
}
...
...
@@ -102,7 +133,7 @@ namespace RTC
auto
*
item
=
new
Item
();
this
->
buffer
.
push_back
(
FillItem
(
item
,
packet
,
sharedPacket
));
this
->
buffer
.
push_back
(
RtpRetransmissionBuffer
::
FillItem
(
item
,
packet
,
sharedPacket
));
return
;
}
...
...
@@ -132,7 +163,7 @@ namespace RTC
auto
*
item
=
new
Item
();
this
->
buffer
.
push_back
(
FillItem
(
item
,
packet
,
sharedPacket
));
this
->
buffer
.
push_back
(
RtpRetransmissionBuffer
::
FillItem
(
item
,
packet
,
sharedPacket
));
return
;
}
...
...
@@ -215,7 +246,7 @@ namespace RTC
// Push the packet, which becomes the newest one in the buffer.
auto
*
item
=
new
Item
();
this
->
buffer
.
push_back
(
FillItem
(
item
,
packet
,
sharedPacket
));
this
->
buffer
.
push_back
(
RtpRetransmissionBuffer
::
FillItem
(
item
,
packet
,
sharedPacket
));
}
// Packet arrived out order and its seq is less than seq of the oldest
// stored packet, so will become the oldest one in the buffer.
...
...
@@ -281,7 +312,7 @@ namespace RTC
// Insert the packet, which becomes the oldest one in the buffer.
auto
*
item
=
new
Item
();
this
->
buffer
.
push_front
(
FillItem
(
item
,
packet
,
sharedPacket
));
this
->
buffer
.
push_front
(
RtpRetransmissionBuffer
::
FillItem
(
item
,
packet
,
sharedPacket
));
}
// Otherwise packet must be inserted between oldest and newest stored items
// so there is already an allocated slot for it.
...
...
@@ -375,7 +406,7 @@ namespace RTC
// Store the packet.
item
=
new
Item
();
this
->
buffer
[
idx
]
=
FillItem
(
item
,
packet
,
sharedPacket
);
this
->
buffer
[
idx
]
=
RtpRetransmissionBuffer
::
FillItem
(
item
,
packet
,
sharedPacket
);
}
MS_ASSERT
(
...
...
@@ -411,7 +442,7 @@ namespace RTC
MS_DUMP
(
"<RtpRetransmissionBuffer>"
);
MS_DUMP
(
" buffer [size:%zu, maxSize:%"
PRIu16
"]"
,
this
->
buffer
.
size
(),
this
->
maxItems
);
if
(
this
->
buffer
.
size
()
>
0
)
if
(
!
this
->
buffer
.
empty
()
)
{
const
auto
*
oldestItem
=
GetOldest
();
const
auto
*
newestItem
=
GetNewest
();
...
...
@@ -554,35 +585,6 @@ namespace RTC
return
static_cast
<
uint32_t
>
(
diffTs
*
1000
/
this
->
clockRate
)
>
this
->
maxRetransmissionDelayMs
;
}
RtpRetransmissionBuffer
::
Item
*
RtpRetransmissionBuffer
::
FillItem
(
RtpRetransmissionBuffer
::
Item
*
item
,
RTC
::
RtpPacket
*
packet
,
std
::
shared_ptr
<
RTC
::
RtpPacket
>&
sharedPacket
)
const
{
MS_TRACE
();
// Store original packet into the item. Only clone once and only if
// necessary.
//
// NOTE: This must be done BEFORE assigning item->packet = sharedPacket,
// otherwise the value being copied in item->packet will remain nullptr.
// This is because we are copying an **empty** shared_ptr into another
// shared_ptr (item->packet), so future value assigned via reset() in the
// former doesn't update the value in the copy.
if
(
!
sharedPacket
.
get
())
{
sharedPacket
.
reset
(
packet
->
Clone
());
}
// Store original packet and some extra info into the item.
item
->
packet
=
sharedPacket
;
item
->
ssrc
=
packet
->
GetSsrc
();
item
->
sequenceNumber
=
packet
->
GetSequenceNumber
();
item
->
timestamp
=
packet
->
GetTimestamp
();
return
item
;
}
void
RtpRetransmissionBuffer
::
Item
::
Reset
()
{
MS_TRACE
();
...
...
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
6a573c26
...
...
@@ -27,7 +27,7 @@ namespace RTC
{
for
(
uint8_t
tIdx
{
0u
};
tIdx
<
temporalLayers
;
++
tIdx
)
{
spatialLayerCounter
.
emplace_back
(
RTC
::
RtpDataCounter
(
windowSize
)
);
spatialLayerCounter
.
emplace_back
(
windowSize
);
}
}
}
...
...
@@ -561,7 +561,7 @@ namespace RTC
this
->
lastSrTimestamp
+=
report
->
GetNtpFrac
()
>>
16
;
// Update info about last Sender Report.
Utils
::
Time
::
Ntp
ntp
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
Utils
::
Time
::
Ntp
ntp
{}
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
ntp
.
seconds
=
report
->
GetNtpSec
();
ntp
.
fractions
=
report
->
GetNtpFrac
();
...
...
@@ -900,7 +900,7 @@ namespace RTC
while
(
it
!=
end
)
{
uint16_t
shift
=
*
it
-
seq
-
1
;
const
uint16_t
shift
=
*
it
-
seq
-
1
;
if
(
shift
>
15
)
{
...
...
worker/src/RTC/SctpAssociation.cpp
浏览文件 @
6a573c26
...
...
@@ -115,14 +115,12 @@ namespace RTC
size_t
maxSctpMessageSize
,
size_t
sctpSendBufferSize
,
bool
isDataChannel
)
:
listener
(
listener
),
os
(
os
),
mis
(
mis
),
maxSctpMessageSize
(
maxSctpMessageSize
),
sctpSendBufferSize
(
sctpSendBufferSize
),
isDataChannel
(
isDataChannel
)
:
id
(
DepUsrSCTP
::
GetNextSctpAssociationId
()),
listener
(
listener
),
os
(
os
),
mis
(
mis
),
maxSctpMessageSize
(
maxSctpMessageSize
),
sctpSendBufferSize
(
sctpSendBufferSize
),
isDataChannel
(
isDataChannel
)
{
MS_TRACE
();
// Get a id for this SctpAssociation.
this
->
id
=
DepUsrSCTP
::
GetNextSctpAssociationId
();
// Register ourselves in usrsctp.
// NOTE: This must be done before calling usrsctp_bind().
usrsctp_register_address
(
reinterpret_cast
<
void
*>
(
this
->
id
));
...
...
@@ -161,7 +159,9 @@ namespace RTC
// This ensures that the usrsctp close call deletes the association. This
// prevents usrsctp from calling the global send callback with references to
// this class as the address.
struct
linger
lingerOpt
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
linger
lingerOpt
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
lingerOpt
.
l_onoff
=
1
;
lingerOpt
.
l_linger
=
0
;
...
...
@@ -176,7 +176,9 @@ namespace RTC
}
// Set SCTP_ENABLE_STREAM_RESET.
struct
sctp_assoc_value
av
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sctp_assoc_value
av
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
av
.
assoc_value
=
SCTP_ENABLE_RESET_STREAM_REQ
|
SCTP_ENABLE_RESET_ASSOC_REQ
|
SCTP_ENABLE_CHANGE_ASSOC_REQ
;
...
...
@@ -203,7 +205,9 @@ namespace RTC
}
// Enable events.
struct
sctp_event
event
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sctp_event
event
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
std
::
memset
(
&
event
,
0
,
sizeof
(
event
));
event
.
se_on
=
1
;
...
...
@@ -223,7 +227,9 @@ namespace RTC
}
// Init message.
struct
sctp_initmsg
initmsg
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sctp_initmsg
initmsg
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
std
::
memset
(
&
initmsg
,
0
,
sizeof
(
initmsg
));
initmsg
.
sinit_num_ostreams
=
this
->
os
;
...
...
@@ -239,7 +245,9 @@ namespace RTC
}
// Server side.
struct
sockaddr_conn
sconn
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sockaddr_conn
sconn
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
std
::
memset
(
&
sconn
,
0
,
sizeof
(
sconn
));
sconn
.
sconn_family
=
AF_CONN
;
...
...
@@ -300,7 +308,9 @@ namespace RTC
try
{
int
ret
;
struct
sockaddr_conn
rconn
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sockaddr_conn
rconn
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
std
::
memset
(
&
rconn
,
0
,
sizeof
(
rconn
));
rconn
.
sconn_family
=
AF_CONN
;
...
...
@@ -318,7 +328,7 @@ namespace RTC
}
// Disable MTU discovery.
sctp_paddrparams
peerAddrParams
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
sctp_paddrparams
peerAddrParams
{}
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
std
::
memset
(
&
peerAddrParams
,
0
,
sizeof
(
peerAddrParams
));
std
::
memcpy
(
&
peerAddrParams
.
spp_address
,
&
rconn
,
sizeof
(
rconn
));
...
...
@@ -370,7 +380,7 @@ namespace RTC
this
->
isDataChannel
);
}
void
SctpAssociation
::
ProcessSctpData
(
const
uint8_t
*
data
,
size_t
len
)
void
SctpAssociation
::
ProcessSctpData
(
const
uint8_t
*
data
,
size_t
len
)
const
{
MS_TRACE
();
...
...
@@ -396,7 +406,9 @@ namespace RTC
const
auto
&
parameters
=
dataConsumer
->
GetSctpStreamParameters
();
// Fill sctp_sendv_spa.
struct
sctp_sendv_spa
spa
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sctp_sendv_spa
spa
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
std
::
memset
(
&
spa
,
0
,
sizeof
(
spa
));
spa
.
sendv_flags
=
SCTP_SEND_SNDINFO_VALID
;
...
...
@@ -436,12 +448,12 @@ namespace RTC
// via onSendSctpData.
this
->
listener
->
OnSctpAssociationBufferedAmount
(
this
,
this
->
sctpBufferedAmount
);
int
ret
=
usrsctp_sendv
(
const
int
ret
=
usrsctp_sendv
(
this
->
socket
,
msg
,
len
,
nullptr
,
0
,
&
spa
,
static_cast
<
socklen_t
>
(
sizeof
(
spa
)),
SCTP_SENDV_SPA
,
0
);
if
(
ret
<
0
)
{
bool
sctpSendBufferFull
=
errno
==
EWOULDBLOCK
||
errno
==
EAGAIN
;
const
bool
sctpSendBufferFull
=
errno
==
EWOULDBLOCK
||
errno
==
EAGAIN
;
// SCTP send buffer being full is legit, not an error.
if
(
sctpSendBufferFull
)
...
...
@@ -535,7 +547,9 @@ namespace RTC
}
int
ret
;
struct
sctp_assoc_value
av
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sctp_assoc_value
av
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
socklen_t
len
=
sizeof
(
av
);
ret
=
usrsctp_getsockopt
(
this
->
socket
,
IPPROTO_SCTP
,
SCTP_RECONFIG_SUPPORTED
,
&
av
,
&
len
);
...
...
@@ -633,7 +647,9 @@ namespace RTC
return
;
}
struct
sctp_add_streams
sas
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sctp_add_streams
sas
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
std
::
memset
(
&
sas
,
0
,
sizeof
(
sas
));
sas
.
sas_instrms
=
0
;
...
...
@@ -641,7 +657,7 @@ namespace RTC
MS_DEBUG_TAG
(
sctp
,
"adding %"
PRIu16
" outgoing streams"
,
additionalOs
);
int
ret
=
usrsctp_setsockopt
(
const
int
ret
=
usrsctp_setsockopt
(
this
->
socket
,
IPPROTO_SCTP
,
SCTP_ADD_STREAMS
,
&
sas
,
static_cast
<
socklen_t
>
(
sizeof
(
sas
)));
if
(
ret
<
0
)
...
...
worker/src/RTC/SimulcastConsumer.cpp
浏览文件 @
6a573c26
...
...
@@ -1713,7 +1713,7 @@ namespace RTC
}
inline
void
SimulcastConsumer
::
OnRtpStreamScore
(
RTC
::
RtpStream
*
/*rtpStream*/
,
uint8_t
score
,
uint8_t
/*previousScore*/
)
RTC
::
RtpStream
*
/*rtpStream*/
,
uint8_t
/*score*/
,
uint8_t
/*previousScore*/
)
{
MS_TRACE
();
...
...
worker/src/RTC/StunPacket.cpp
浏览文件 @
6a573c26
...
...
@@ -11,7 +11,7 @@ namespace RTC
{
/* Class variables. */
const
uint8_t
StunPacket
::
m
agicCookie
[]
=
{
0x21
,
0x12
,
0xA4
,
0x42
};
const
uint8_t
StunPacket
::
M
agicCookie
[]
=
{
0x21
,
0x12
,
0xA4
,
0x42
};
/* Class methods. */
...
...
@@ -651,7 +651,7 @@ namespace RTC
// Set length field.
Utils
::
Byte
::
Set2Bytes
(
buffer
,
2
,
static_cast
<
uint16_t
>
(
this
->
size
)
-
20
);
// Set magic cookie.
std
::
memcpy
(
buffer
+
4
,
StunPacket
::
m
agicCookie
,
4
);
std
::
memcpy
(
buffer
+
4
,
StunPacket
::
M
agicCookie
,
4
);
// Set TransactionId field.
std
::
memcpy
(
buffer
+
8
,
this
->
transactionId
,
12
);
// Update the transaction ID pointer.
...
...
@@ -724,17 +724,17 @@ namespace RTC
attrValue
+
2
,
&
(
reinterpret_cast
<
const
sockaddr_in
*>
(
this
->
xorMappedAddress
))
->
sin_port
,
2
);
attrValue
[
2
]
^=
StunPacket
::
m
agicCookie
[
0
];
attrValue
[
3
]
^=
StunPacket
::
m
agicCookie
[
1
];
attrValue
[
2
]
^=
StunPacket
::
M
agicCookie
[
0
];
attrValue
[
3
]
^=
StunPacket
::
M
agicCookie
[
1
];
// Set address and XOR it.
std
::
memcpy
(
attrValue
+
4
,
&
(
reinterpret_cast
<
const
sockaddr_in
*>
(
this
->
xorMappedAddress
))
->
sin_addr
.
s_addr
,
4
);
attrValue
[
4
]
^=
StunPacket
::
m
agicCookie
[
0
];
attrValue
[
5
]
^=
StunPacket
::
m
agicCookie
[
1
];
attrValue
[
6
]
^=
StunPacket
::
m
agicCookie
[
2
];
attrValue
[
7
]
^=
StunPacket
::
m
agicCookie
[
3
];
attrValue
[
4
]
^=
StunPacket
::
M
agicCookie
[
0
];
attrValue
[
5
]
^=
StunPacket
::
M
agicCookie
[
1
];
attrValue
[
6
]
^=
StunPacket
::
M
agicCookie
[
2
];
attrValue
[
7
]
^=
StunPacket
::
M
agicCookie
[
3
];
pos
+=
4
+
8
;
...
...
@@ -752,17 +752,17 @@ namespace RTC
attrValue
+
2
,
&
(
reinterpret_cast
<
const
sockaddr_in6
*>
(
this
->
xorMappedAddress
))
->
sin6_port
,
2
);
attrValue
[
2
]
^=
StunPacket
::
m
agicCookie
[
0
];
attrValue
[
3
]
^=
StunPacket
::
m
agicCookie
[
1
];
attrValue
[
2
]
^=
StunPacket
::
M
agicCookie
[
0
];
attrValue
[
3
]
^=
StunPacket
::
M
agicCookie
[
1
];
// Set address and XOR it.
std
::
memcpy
(
attrValue
+
4
,
&
(
reinterpret_cast
<
const
sockaddr_in6
*>
(
this
->
xorMappedAddress
))
->
sin6_addr
.
s6_addr
,
16
);
attrValue
[
4
]
^=
StunPacket
::
m
agicCookie
[
0
];
attrValue
[
5
]
^=
StunPacket
::
m
agicCookie
[
1
];
attrValue
[
6
]
^=
StunPacket
::
m
agicCookie
[
2
];
attrValue
[
7
]
^=
StunPacket
::
m
agicCookie
[
3
];
attrValue
[
4
]
^=
StunPacket
::
M
agicCookie
[
0
];
attrValue
[
5
]
^=
StunPacket
::
M
agicCookie
[
1
];
attrValue
[
6
]
^=
StunPacket
::
M
agicCookie
[
2
];
attrValue
[
7
]
^=
StunPacket
::
M
agicCookie
[
3
];
attrValue
[
8
]
^=
this
->
transactionId
[
0
];
attrValue
[
9
]
^=
this
->
transactionId
[
1
];
attrValue
[
10
]
^=
this
->
transactionId
[
2
];
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
6a573c26
...
...
@@ -2320,7 +2320,7 @@ namespace RTC
this
->
tccClient
->
SetDesiredBitrate
(
totalDesiredBitrate
,
forceBitrate
);
}
inline
void
Transport
::
EmitTraceEventProbationType
(
RTC
::
RtpPacket
*
packet
)
const
inline
void
Transport
::
EmitTraceEventProbationType
(
RTC
::
RtpPacket
*
/*packet*/
)
const
{
MS_TRACE
();
...
...
@@ -2893,10 +2893,10 @@ namespace RTC
// Pass the SCTP message to the corresponding DataProducer.
try
{
static
std
::
vector
<
uint16_t
>
E
mptySubchannels
;
static
std
::
vector
<
uint16_t
>
e
mptySubchannels
;
dataProducer
->
ReceiveMessage
(
msg
,
len
,
ppid
,
E
mptySubchannels
,
/*requiredSubchannel*/
std
::
nullopt
);
msg
,
len
,
ppid
,
e
mptySubchannels
,
/*requiredSubchannel*/
std
::
nullopt
);
}
catch
(
std
::
exception
&
error
)
{
...
...
@@ -2936,7 +2936,7 @@ namespace RTC
}
inline
void
Transport
::
OnTransportCongestionControlClientSendRtpPacket
(
RTC
::
TransportCongestionControlClient
*
tccClient
,
RTC
::
TransportCongestionControlClient
*
/*tccClient*/
,
RTC
::
RtpPacket
*
packet
,
const
webrtc
::
PacedPacketInfo
&
pacingInfo
)
{
...
...
worker/src/RTC/WebRtcServer.cpp
浏览文件 @
6a573c26
...
...
@@ -25,6 +25,30 @@ namespace RTC
std
::
pow
(
2
,
0
)
*
(
256
-
IceComponent
);
}
/* Class methods. */
inline
std
::
string
WebRtcServer
::
GetLocalIceUsernameFragmentFromReceivedStunPacket
(
RTC
::
StunPacket
*
packet
)
{
MS_TRACE
();
// Here we inspect the USERNAME attribute of a received STUN request and
// extract its remote usernameFragment (the one given to our IceServer as
// local usernameFragment) which is the first value in the attribute value
// before the ":" symbol.
const
auto
&
username
=
packet
->
GetUsername
();
const
size_t
colonPos
=
username
.
find
(
':'
);
// If no colon is found just return the whole USERNAME attribute anyway.
if
(
colonPos
==
std
::
string
::
npos
)
{
return
username
;
}
return
username
.
substr
(
0
,
colonPos
);
}
/* Instance methods. */
WebRtcServer
::
WebRtcServer
(
...
...
@@ -265,7 +289,7 @@ namespace RTC
}
}
const
std
::
vector
<
RTC
::
IceCandidate
>
WebRtcServer
::
GetIceCandidates
(
std
::
vector
<
RTC
::
IceCandidate
>
WebRtcServer
::
GetIceCandidates
(
bool
enableUdp
,
bool
enableTcp
,
bool
preferUdp
,
bool
preferTcp
)
const
{
MS_TRACE
();
...
...
@@ -284,7 +308,7 @@ namespace RTC
iceLocalPreference
+=
1000
;
}
uint32_t
icePriority
=
generateIceCandidatePriority
(
iceLocalPreference
);
const
uint32_t
icePriority
=
generateIceCandidatePriority
(
iceLocalPreference
);
if
(
item
.
announcedIp
.
empty
())
{
...
...
@@ -305,7 +329,7 @@ namespace RTC
iceLocalPreference
+=
1000
;
}
uint32_t
icePriority
=
generateIceCandidatePriority
(
iceLocalPreference
);
const
uint32_t
icePriority
=
generateIceCandidatePriority
(
iceLocalPreference
);
if
(
item
.
announcedIp
.
empty
())
{
...
...
@@ -325,28 +349,6 @@ namespace RTC
return
iceCandidates
;
}
inline
std
::
string
WebRtcServer
::
GetLocalIceUsernameFragmentFromReceivedStunPacket
(
RTC
::
StunPacket
*
packet
)
const
{
MS_TRACE
();
// Here we inspect the USERNAME attribute of a received STUN request and
// extract its remote usernameFragment (the one given to our IceServer as
// local usernameFragment) which is the first value in the attribute value
// before the ":" symbol.
const
auto
&
username
=
packet
->
GetUsername
();
const
size_t
colonPos
=
username
.
find
(
':'
);
// If no colon is found just return the whole USERNAME attribute anyway.
if
(
colonPos
==
std
::
string
::
npos
)
{
return
username
;
}
return
username
.
substr
(
0
,
colonPos
);
}
inline
void
WebRtcServer
::
OnPacketReceived
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
)
{
MS_TRACE
();
...
...
@@ -389,7 +391,7 @@ namespace RTC
}
// Otherwise try to match the local ICE username fragment.
auto
key
=
GetLocalIceUsernameFragmentFromReceivedStunPacket
(
packet
);
auto
key
=
WebRtcServer
::
GetLocalIceUsernameFragmentFromReceivedStunPacket
(
packet
);
auto
it2
=
this
->
mapLocalIceUsernameFragmentWebRtcTransport
.
find
(
key
);
if
(
it2
==
this
->
mapLocalIceUsernameFragmentWebRtcTransport
.
end
())
...
...
@@ -463,7 +465,7 @@ namespace RTC
}
inline
void
WebRtcServer
::
OnWebRtcTransportLocalIceUsernameFragmentRemoved
(
RTC
::
WebRtcTransport
*
webRtcTransport
,
const
std
::
string
&
usernameFragment
)
RTC
::
WebRtcTransport
*
/*webRtcTransport*/
,
const
std
::
string
&
usernameFragment
)
{
MS_TRACE
();
...
...
@@ -491,7 +493,7 @@ namespace RTC
}
inline
void
WebRtcServer
::
OnWebRtcTransportTransportTupleRemoved
(
RTC
::
WebRtcTransport
*
webRtcTransport
,
RTC
::
TransportTuple
*
tuple
)
RTC
::
WebRtcTransport
*
/*webRtcTransport*/
,
RTC
::
TransportTuple
*
tuple
)
{
MS_TRACE
();
...
...
worker/src/RTC/WebRtcTransport.cpp
浏览文件 @
6a573c26
...
...
@@ -86,7 +86,7 @@ namespace RTC
this
->
udpSockets
[
udpSocket
]
=
announcedIp
;
if
(
announcedIp
.
size
()
==
0
)
if
(
announcedIp
.
empty
()
)
{
this
->
iceCandidates
.
emplace_back
(
udpSocket
,
icePriority
);
}
...
...
@@ -128,7 +128,7 @@ namespace RTC
this
->
tcpServers
[
tcpServer
]
=
announcedIp
;
if
(
announcedIp
.
size
()
==
0
)
if
(
announcedIp
.
empty
()
)
{
this
->
iceCandidates
.
emplace_back
(
tcpServer
,
icePriority
);
}
...
...
@@ -341,7 +341,7 @@ namespace RTC
// Add dtlsParameters.fingerprints.
std
::
vector
<
flatbuffers
::
Offset
<
FBS
::
WebRtcTransport
::
Fingerprint
>>
fingerprints
;
for
(
const
auto
&
fingerprint
:
this
->
dtlsTransport
->
GetLocalFingerprints
())
for
(
const
auto
&
fingerprint
:
RTC
::
DtlsTransport
::
GetLocalFingerprints
())
{
auto
algorithm
=
DtlsTransport
::
AlgorithmToFbs
(
fingerprint
.
algorithm
);
const
auto
&
value
=
fingerprint
.
value
;
...
...
worker/src/Settings.cpp
浏览文件 @
6a573c26
...
...
@@ -18,7 +18,7 @@ extern "C"
/* Static. */
static
std
::
mutex
g
lobalSyncMutex
;
static
std
::
mutex
G
lobalSyncMutex
;
/* Class variables. */
...
...
@@ -69,7 +69,7 @@ void Settings::SetConfiguration(int argc, char* argv[])
/* Parse command line options. */
// getopt_long_only() is not thread-safe
std
::
lock_guard
<
std
::
mutex
>
lock
(
g
lobalSyncMutex
);
const
std
::
lock_guard
<
std
::
mutex
>
lock
(
G
lobalSyncMutex
);
optind
=
1
;
// Set explicitly, otherwise subsequent runs will fail.
opterr
=
0
;
// Don't allow getopt to print error messages.
...
...
worker/src/Utils/File.cpp
浏览文件 @
6a573c26
...
...
@@ -20,7 +20,9 @@ namespace Utils
{
MS_TRACE
();
struct
stat
fileStat
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
stat
fileStat
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
int
err
;
// Ensure the given file exists.
...
...
worker/src/Utils/IP.cpp
浏览文件 @
6a573c26
...
...
@@ -118,7 +118,7 @@ namespace Utils
{
MS_TRACE
();
sockaddr_storage
addrStorage
;
sockaddr_storage
addrStorage
{}
;
char
ipBuffer
[
INET6_ADDRSTRLEN
]
=
{
0
};
int
err
;
...
...
worker/src/Worker.cpp
浏览文件 @
6a573c26
...
...
@@ -50,7 +50,7 @@ Worker::Worker(::Channel::ChannelSocket* channel) : channel(channel)
// Tell the Node process that we are running.
this
->
shared
->
channelNotifier
->
Emit
(
std
::
to_string
(
Logger
::
p
id
),
FBS
::
Notification
::
Event
::
WORKER_RUNNING
);
std
::
to_string
(
Logger
::
P
id
),
FBS
::
Notification
::
Event
::
WORKER_RUNNING
);
MS_DEBUG_DEV
(
"starting libuv loop"
);
DepLibUV
::
RunLoop
();
...
...
@@ -143,7 +143,7 @@ flatbuffers::Offset<FBS::Worker::DumpResponse> Worker::FillBuffer(
return
FBS
::
Worker
::
CreateDumpResponseDirect
(
builder
,
Logger
::
p
id
,
Logger
::
P
id
,
&
webRtcServerIds
,
&
routerIds
,
channelMessageHandlers
...
...
worker/src/handles/TcpConnectionHandle.cpp
浏览文件 @
6a573c26
...
...
@@ -74,11 +74,11 @@ inline static void onShutdown(uv_shutdown_t* req, int /*status*/)
/* Instance methods. */
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
TcpConnectionHandle
::
TcpConnectionHandle
(
size_t
bufferSize
)
:
bufferSize
(
bufferSize
)
TcpConnectionHandle
::
TcpConnectionHandle
(
size_t
bufferSize
)
:
bufferSize
(
bufferSize
),
uvHandle
(
new
uv_tcp_t
)
{
MS_TRACE
();
this
->
uvHandle
=
new
uv_tcp_t
;
this
->
uvHandle
->
data
=
static_cast
<
void
*>
(
this
);
// NOTE: Don't allocate the buffer here. Instead wait for the first uv_alloc_cb().
...
...
worker/src/handles/TcpServerHandle.cpp
浏览文件 @
6a573c26
...
...
@@ -110,7 +110,8 @@ uint32_t TcpServerHandle::GetSendBufferSize() const
MS_TRACE
();
int
size
{
0
};
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
const
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
if
(
err
)
{
...
...
@@ -124,15 +125,15 @@ void TcpServerHandle::SetSendBufferSize(uint32_t size)
{
MS_TRACE
();
auto
size
_i
nt
=
static_cast
<
int
>
(
size
);
auto
size
I
nt
=
static_cast
<
int
>
(
size
);
if
(
size
_i
nt
<=
0
)
if
(
size
I
nt
<=
0
)
{
MS_THROW_TYPE_ERROR
(
"invalid size: %d"
,
size
_i
nt
);
MS_THROW_TYPE_ERROR
(
"invalid size: %d"
,
size
I
nt
);
}
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
_i
nt
));
const
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
I
nt
));
if
(
err
)
{
...
...
@@ -145,7 +146,8 @@ uint32_t TcpServerHandle::GetRecvBufferSize() const
MS_TRACE
();
int
size
{
0
};
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
const
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
if
(
err
)
{
...
...
@@ -159,15 +161,15 @@ void TcpServerHandle::SetRecvBufferSize(uint32_t size)
{
MS_TRACE
();
auto
size
_i
nt
=
static_cast
<
int
>
(
size
);
auto
size
I
nt
=
static_cast
<
int
>
(
size
);
if
(
size
_i
nt
<=
0
)
if
(
size
I
nt
<=
0
)
{
MS_THROW_TYPE_ERROR
(
"invalid size: %d"
,
size
_i
nt
);
MS_THROW_TYPE_ERROR
(
"invalid size: %d"
,
size
I
nt
);
}
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
_i
nt
));
const
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
I
nt
));
if
(
err
)
{
...
...
worker/src/handles/TimerHandle.cpp
浏览文件 @
6a573c26
...
...
@@ -20,11 +20,10 @@ inline static void onCloseTimer(uv_handle_t* handle)
/* Instance methods. */
TimerHandle
::
TimerHandle
(
Listener
*
listener
)
:
listener
(
listener
)
TimerHandle
::
TimerHandle
(
Listener
*
listener
)
:
listener
(
listener
)
,
uvHandle
(
new
uv_timer_t
)
{
MS_TRACE
();
this
->
uvHandle
=
new
uv_timer_t
;
this
->
uvHandle
->
data
=
static_cast
<
void
*>
(
this
);
const
int
err
=
uv_timer_init
(
DepLibUV
::
GetLoop
(),
this
->
uvHandle
);
...
...
worker/src/handles/UdpSocketHandle.cpp
浏览文件 @
6a573c26
...
...
@@ -243,7 +243,7 @@ send_libuv:
buffer
=
uv_buf_init
(
reinterpret_cast
<
char
*>
(
sendData
->
store
),
len
);
int
err
=
uv_udp_send
(
const
int
err
=
uv_udp_send
(
&
sendData
->
req
,
this
->
uvHandle
,
&
buffer
,
1
,
addr
,
static_cast
<
uv_udp_send_cb
>
(
onSend
));
if
(
err
!=
0
)
...
...
@@ -272,7 +272,8 @@ uint32_t UdpSocketHandle::GetSendBufferSize() const
MS_TRACE
();
int
size
{
0
};
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
const
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
if
(
err
)
{
...
...
@@ -286,15 +287,15 @@ void UdpSocketHandle::SetSendBufferSize(uint32_t size)
{
MS_TRACE
();
auto
size
_i
nt
=
static_cast
<
int
>
(
size
);
auto
size
I
nt
=
static_cast
<
int
>
(
size
);
if
(
size
_i
nt
<=
0
)
if
(
size
I
nt
<=
0
)
{
MS_THROW_TYPE_ERROR
(
"invalid size: %d"
,
size
_i
nt
);
MS_THROW_TYPE_ERROR
(
"invalid size: %d"
,
size
I
nt
);
}
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
_i
nt
));
const
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
I
nt
));
if
(
err
)
{
...
...
@@ -307,7 +308,8 @@ uint32_t UdpSocketHandle::GetRecvBufferSize() const
MS_TRACE
();
int
size
{
0
};
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
const
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
if
(
err
)
{
...
...
@@ -321,15 +323,15 @@ void UdpSocketHandle::SetRecvBufferSize(uint32_t size)
{
MS_TRACE
();
auto
size
_i
nt
=
static_cast
<
int
>
(
size
);
auto
size
I
nt
=
static_cast
<
int
>
(
size
);
if
(
size
_i
nt
<=
0
)
if
(
size
I
nt
<=
0
)
{
MS_THROW_TYPE_ERROR
(
"invalid size: %d"
,
size
_i
nt
);
MS_THROW_TYPE_ERROR
(
"invalid size: %d"
,
size
I
nt
);
}
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
_i
nt
));
const
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
I
nt
));
if
(
err
)
{
...
...
worker/src/handles/UnixStreamSocketHandle.cpp
浏览文件 @
6a573c26
...
...
@@ -76,13 +76,12 @@ inline static void onShutdown(uv_shutdown_t* req, int /*status*/)
UnixStreamSocketHandle
::
UnixStreamSocketHandle
(
int
fd
,
size_t
bufferSize
,
UnixStreamSocketHandle
::
Role
role
)
:
bufferSize
(
bufferSize
),
role
(
role
)
:
uvHandle
(
new
uv_pipe_t
),
bufferSize
(
bufferSize
),
role
(
role
)
{
MS_TRACE_STD
();
int
err
;
this
->
uvHandle
=
new
uv_pipe_t
;
this
->
uvHandle
->
data
=
static_cast
<
void
*>
(
this
);
err
=
uv_pipe_init
(
DepLibUV
::
GetLoop
(),
this
->
uvHandle
,
0
);
...
...
@@ -252,7 +251,8 @@ uint32_t UnixStreamSocketHandle::GetSendBufferSize() const
MS_TRACE
();
int
size
{
0
};
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
const
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
if
(
err
)
{
...
...
@@ -266,15 +266,15 @@ void UnixStreamSocketHandle::SetSendBufferSize(uint32_t size)
{
MS_TRACE
();
auto
size
_i
nt
=
static_cast
<
int
>
(
size
);
auto
size
I
nt
=
static_cast
<
int
>
(
size
);
if
(
size
_i
nt
<=
0
)
if
(
size
I
nt
<=
0
)
{
MS_THROW_TYPE_ERROR_STD
(
"invalid size: %d"
,
size
_i
nt
);
MS_THROW_TYPE_ERROR_STD
(
"invalid size: %d"
,
size
I
nt
);
}
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
_i
nt
));
const
int
err
=
uv_send_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
I
nt
));
if
(
err
)
{
...
...
@@ -287,7 +287,8 @@ uint32_t UnixStreamSocketHandle::GetRecvBufferSize() const
MS_TRACE
();
int
size
{
0
};
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
const
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
));
if
(
err
)
{
...
...
@@ -301,15 +302,15 @@ void UnixStreamSocketHandle::SetRecvBufferSize(uint32_t size)
{
MS_TRACE
();
auto
size
_i
nt
=
static_cast
<
int
>
(
size
);
auto
size
I
nt
=
static_cast
<
int
>
(
size
);
if
(
size
_i
nt
<=
0
)
if
(
size
I
nt
<=
0
)
{
MS_THROW_TYPE_ERROR_STD
(
"invalid size: %d"
,
size
_i
nt
);
MS_THROW_TYPE_ERROR_STD
(
"invalid size: %d"
,
size
I
nt
);
}
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
_i
nt
));
const
int
err
=
uv_recv_buffer_size
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
std
::
addressof
(
size
I
nt
));
if
(
err
)
{
...
...
worker/src/lib.cpp
浏览文件 @
6a573c26
...
...
@@ -26,14 +26,15 @@
void
IgnoreSignals
();
// NOLINTNEXTLINE
extern
"C"
int
mediasoup_worker_run
(
int
argc
,
char
*
argv
[],
const
char
*
version
,
int
consumerChannelFd
,
int
producerChannelFd
,
int
payloadConsumeChannelFd
,
int
payloadProduceChannelFd
,
int
/*payloadConsumeChannelFd*/
,
int
/*payloadProduceChannelFd*/
,
ChannelReadFn
channelReadFn
,
ChannelReadCtx
channelReadCtx
,
ChannelWriteFn
channelWriteFn
,
...
...
@@ -141,7 +142,7 @@ extern "C" int mediasoup_worker_run(
#endif
// Run the Worker.
Worker
worker
(
channel
.
get
());
const
Worker
worker
(
channel
.
get
());
// Free static stuff.
DepLibSRTP
::
ClassDestroy
();
...
...
@@ -177,10 +178,12 @@ void IgnoreSignals()
MS_TRACE
();
int
err
;
struct
sigaction
act
;
// NOLINT(cppcoreguidelines-pro-type-member-init)
struct
sigaction
act
{
};
// NOLINT(cppcoreguidelines-pro-type-member-init)
// clang-format off
absl
::
flat_hash_map
<
std
::
string
,
int
>
ignoredSignals
=
absl
::
flat_hash_map
<
std
::
string
,
int
>
const
ignoredSignals
=
{
{
"PIPE"
,
SIGPIPE
},
{
"HUP"
,
SIGHUP
},
...
...
@@ -199,10 +202,10 @@ void IgnoreSignals()
MS_THROW_ERROR
(
"sigfillset() failed: %s"
,
std
::
strerror
(
errno
));
}
for
(
auto
&
kv
:
ignoredSignals
)
for
(
const
auto
&
kv
:
ignoredSignals
)
{
const
auto
&
sigName
=
kv
.
first
;
int
sigId
=
kv
.
second
;
const
int
sigId
=
kv
.
second
;
err
=
sigaction
(
sigId
,
&
act
,
nullptr
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论