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