Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
1e3bdac0
Unverified
提交
1e3bdac0
authored
5月 28, 2021
作者:
Nazar Mokrynskyi
提交者:
GitHub
5月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Thread and memory safety fixes (#562)
上级
f2f8a5fc
隐藏空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
66 行增加
和
44 行删除
+66
-44
ChannelSocket.hpp
worker/include/Channel/ChannelSocket.hpp
+1
-0
Logger.hpp
worker/include/Logger.hpp
+1
-1
MediaSoupErrors.hpp
worker/include/MediaSoupErrors.hpp
+12
-20
PayloadChannelSocket.hpp
worker/include/PayloadChannel/PayloadChannelSocket.hpp
+1
-0
PortManager.hpp
worker/include/RTC/PortManager.hpp
+2
-2
Utils.hpp
worker/include/Utils.hpp
+1
-1
mediasoup-worker.gyp
worker/mediasoup-worker.gyp
+1
-0
ChannelSocket.cpp
worker/src/Channel/ChannelSocket.cpp
+8
-0
Logger.cpp
worker/src/Logger.cpp
+1
-1
MediaSoupErrors.cpp
worker/src/MediaSoupErrors.cpp
+5
-0
PayloadChannelSocket.cpp
worker/src/PayloadChannel/PayloadChannelSocket.cpp
+8
-0
PortManager.cpp
worker/src/RTC/PortManager.cpp
+2
-2
Producer.cpp
worker/src/RTC/Producer.cpp
+2
-2
RtpProbationGenerator.cpp
worker/src/RTC/RtpProbationGenerator.cpp
+1
-1
SctpAssociation.cpp
worker/src/RTC/SctpAssociation.cpp
+4
-4
StunPacket.cpp
worker/src/RTC/StunPacket.cpp
+2
-2
IP.cpp
worker/src/Utils/IP.cpp
+1
-1
String.cpp
worker/src/Utils/String.cpp
+1
-1
Worker.cpp
worker/src/Worker.cpp
+8
-2
UnixStreamSocket.cpp
worker/src/handles/UnixStreamSocket.cpp
+2
-2
lib.cpp
worker/src/lib.cpp
+2
-2
没有找到文件。
worker/include/Channel/ChannelSocket.hpp
浏览文件 @
1e3bdac0
...
...
@@ -63,6 +63,7 @@ namespace Channel
virtual
~
ChannelSocket
();
public
:
void
Close
();
void
SetListener
(
Listener
*
listener
);
void
Send
(
json
&
jsonMessage
);
void
SendLog
(
char
*
message
,
size_t
messageLen
);
...
...
worker/include/Logger.hpp
浏览文件 @
1e3bdac0
...
...
@@ -135,7 +135,7 @@ public:
static
const
int64_t
pid
;
thread_local
static
Channel
::
ChannelSocket
*
channel
;
static
const
size_t
bufferSize
{
50000
};
static
char
buffer
[];
thread_local
static
char
buffer
[];
};
/* Logging macros. */
...
...
worker/include/MediaSoupErrors.hpp
浏览文件 @
1e3bdac0
...
...
@@ -11,6 +11,10 @@ public:
explicit
MediaSoupError
(
const
char
*
description
)
:
std
::
runtime_error
(
description
)
{
}
public
:
static
const
size_t
bufferSize
{
2000
};
thread_local
static
char
buffer
[];
};
class
MediaSoupTypeError
:
public
MediaSoupError
...
...
@@ -26,44 +30,32 @@ public:
do \
{ \
MS_ERROR("throwing MediaSoupError: " desc, ##__VA_ARGS__); \
\
static char buffer[2000]; \
\
std::snprintf(buffer, 2000, desc, ##__VA_ARGS__); \
throw MediaSoupError(buffer); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::bufferSize, desc, ##__VA_ARGS__); \
throw MediaSoupError(MediaSoupError::buffer); \
} while (false)
#define MS_THROW_ERROR_STD(desc, ...) \
do \
{ \
MS_ERROR_STD("throwing MediaSoupError: " desc, ##__VA_ARGS__); \
\
static char buffer[2000]; \
\
std::snprintf(buffer, 2000, desc, ##__VA_ARGS__); \
throw MediaSoupError(buffer); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::bufferSize, desc, ##__VA_ARGS__); \
throw MediaSoupError(MediaSoupError::buffer); \
} while (false)
#define MS_THROW_TYPE_ERROR(desc, ...) \
do \
{ \
MS_ERROR("throwing MediaSoupTypeError: " desc, ##__VA_ARGS__); \
\
static char buffer[2000]; \
\
std::snprintf(buffer, 2000, desc, ##__VA_ARGS__); \
throw MediaSoupTypeError(buffer); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::bufferSize, desc, ##__VA_ARGS__); \
throw MediaSoupTypeError(MediaSoupError::buffer); \
} while (false)
#define MS_THROW_TYPE_ERROR_STD(desc, ...) \
do \
{ \
MS_ERROR_STD("throwing MediaSoupTypeError: " desc, ##__VA_ARGS__); \
\
static char buffer[2000]; \
\
std::snprintf(buffer, 2000, desc, ##__VA_ARGS__); \
throw MediaSoupTypeError(buffer); \
std::snprintf(MediaSoupError::buffer, MediaSoupError::bufferSize, desc, ##__VA_ARGS__); \
throw MediaSoupTypeError(MediaSoupError::buffer); \
} while (false)
// clang-format on
...
...
worker/include/PayloadChannel/PayloadChannelSocket.hpp
浏览文件 @
1e3bdac0
...
...
@@ -69,6 +69,7 @@ namespace PayloadChannel
virtual
~
PayloadChannelSocket
();
public
:
void
Close
();
void
SetListener
(
Listener
*
listener
);
void
Send
(
json
&
jsonMessage
,
const
uint8_t
*
payload
,
size_t
payloadLen
);
void
Send
(
json
&
jsonMessage
);
...
...
worker/include/RTC/PortManager.hpp
浏览文件 @
1e3bdac0
...
...
@@ -45,8 +45,8 @@ namespace RTC
static
std
::
vector
<
bool
>&
GetPorts
(
Transport
transport
,
const
std
::
string
&
ip
);
private
:
static
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
bool
>>
mapUdpIpPorts
;
static
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
bool
>>
mapTcpIpPorts
;
thread_local
static
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
bool
>>
mapUdpIpPorts
;
thread_local
static
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
bool
>>
mapTcpIpPorts
;
};
}
// namespace RTC
...
...
worker/include/Utils.hpp
浏览文件 @
1e3bdac0
...
...
@@ -222,7 +222,7 @@ namespace Utils
static
const
std
::
string
GetRandomString
(
size_t
len
)
{
static
char
buffer
[
64
];
char
buffer
[
64
];
static
const
char
chars
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
};
...
...
worker/mediasoup-worker.gyp
浏览文件 @
1e3bdac0
...
...
@@ -23,6 +23,7 @@
'src/DepOpenSSL.cpp',
'src/DepUsrSCTP.cpp',
'src/Logger.cpp',
'src/MediaSoupErrors.cpp',
'src/Settings.cpp',
'src/Worker.cpp',
'src/Utils/Crypto.cpp',
...
...
worker/src/Channel/ChannelSocket.cpp
浏览文件 @
1e3bdac0
...
...
@@ -36,6 +36,14 @@ namespace Channel
std
::
free
(
this
->
writeBuffer
);
}
void
ChannelSocket
::
Close
()
{
MS_TRACE_STD
();
this
->
consumerSocket
.
Close
();
this
->
producerSocket
.
Close
();
}
void
ChannelSocket
::
SetListener
(
Listener
*
listener
)
{
MS_TRACE_STD
();
...
...
worker/src/Logger.cpp
浏览文件 @
1e3bdac0
...
...
@@ -8,7 +8,7 @@
const
int64_t
Logger
::
pid
{
static_cast
<
int64_t
>
(
uv_os_getpid
())
};
thread_local
Channel
::
ChannelSocket
*
Logger
::
channel
{
nullptr
};
char
Logger
::
buffer
[
Logger
::
bufferSize
];
thread_local
char
Logger
::
buffer
[
Logger
::
bufferSize
];
/* Class methods. */
...
...
worker/src/MediaSoupErrors.cpp
0 → 100644
浏览文件 @
1e3bdac0
#define MS_CLASS "MediaSoupError"
#include "MediaSoupErrors.hpp"
thread_local
char
MediaSoupError
::
buffer
[
MediaSoupError
::
bufferSize
];
worker/src/PayloadChannel/PayloadChannelSocket.cpp
浏览文件 @
1e3bdac0
...
...
@@ -38,6 +38,14 @@ namespace PayloadChannel
delete
this
->
ongoingNotification
;
}
void
PayloadChannelSocket
::
Close
()
{
MS_TRACE_STD
();
this
->
consumerSocket
.
Close
();
this
->
producerSocket
.
Close
();
}
void
PayloadChannelSocket
::
SetListener
(
Listener
*
listener
)
{
MS_TRACE
();
...
...
worker/src/RTC/PortManager.cpp
浏览文件 @
1e3bdac0
...
...
@@ -26,8 +26,8 @@ namespace RTC
{
/* Class variables. */
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
bool
>>
PortManager
::
mapUdpIpPorts
;
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
bool
>>
PortManager
::
mapTcpIpPorts
;
thread_local
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
bool
>>
PortManager
::
mapUdpIpPorts
;
thread_local
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
bool
>>
PortManager
::
mapTcpIpPorts
;
/* Class methods. */
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
1e3bdac0
...
...
@@ -1206,8 +1206,8 @@ namespace RTC
// Mangle RTP header extensions.
{
static
uint8_t
buffer
[
4096
];
static
std
::
vector
<
RTC
::
RtpPacket
::
GenericExtension
>
extensions
;
thread_local
static
uint8_t
buffer
[
4096
];
thread_local
static
std
::
vector
<
RTC
::
RtpPacket
::
GenericExtension
>
extensions
;
// This happens just once.
if
(
extensions
.
capacity
()
!=
24
)
...
...
worker/src/RTC/RtpProbationGenerator.cpp
浏览文件 @
1e3bdac0
...
...
@@ -62,7 +62,7 @@ namespace RTC
this
->
probationPacket
->
SetTimestamp
(
Utils
::
Crypto
::
GetRandomUInt
(
0
,
4294967295
));
// Add BWE related RTP header extensions.
static
uint8_t
buffer
[
4096
];
thread_local
static
uint8_t
buffer
[
4096
];
std
::
vector
<
RTC
::
RtpPacket
::
GenericExtension
>
extensions
;
uint8_t
extenLen
;
...
...
worker/src/RTC/SctpAssociation.cpp
浏览文件 @
1e3bdac0
...
...
@@ -770,7 +770,7 @@ namespace RTC
if
(
notification
->
sn_header
.
sn_length
>
0
)
{
static
const
size_t
BufferSize
{
1024
};
static
char
buffer
[
BufferSize
];
thread_local
static
char
buffer
[
BufferSize
];
uint32_t
len
=
notification
->
sn_header
.
sn_length
;
...
...
@@ -838,7 +838,7 @@ namespace RTC
if
(
notification
->
sn_header
.
sn_length
>
0
)
{
static
const
size_t
BufferSize
{
1024
};
static
char
buffer
[
BufferSize
];
thread_local
static
char
buffer
[
BufferSize
];
uint32_t
len
=
notification
->
sn_header
.
sn_length
;
...
...
@@ -879,7 +879,7 @@ namespace RTC
case
SCTP_REMOTE_ERROR
:
{
static
const
size_t
BufferSize
{
1024
};
static
char
buffer
[
BufferSize
];
thread_local
static
char
buffer
[
BufferSize
];
uint32_t
len
=
notification
->
sn_remote_error
.
sre_length
-
sizeof
(
struct
sctp_remote_error
);
...
...
@@ -915,7 +915,7 @@ namespace RTC
case
SCTP_SEND_FAILED_EVENT
:
{
static
const
size_t
BufferSize
{
1024
};
static
char
buffer
[
BufferSize
];
thread_local
static
char
buffer
[
BufferSize
];
uint32_t
len
=
notification
->
sn_send_failed_event
.
ssfe_length
-
sizeof
(
struct
sctp_send_failed_event
);
...
...
worker/src/RTC/StunPacket.cpp
浏览文件 @
1e3bdac0
...
...
@@ -353,7 +353,7 @@ namespace RTC
}
MS_DUMP
(
" size: %zu bytes"
,
this
->
size
);
static
char
transactionId
[
25
];
char
transactionId
[
25
];
for
(
int
i
{
0
};
i
<
12
;
++
i
)
{
...
...
@@ -385,7 +385,7 @@ namespace RTC
}
if
(
this
->
messageIntegrity
!=
nullptr
)
{
static
char
messageIntegrity
[
41
];
char
messageIntegrity
[
41
];
for
(
int
i
{
0
};
i
<
20
;
++
i
)
{
...
...
worker/src/Utils/IP.cpp
浏览文件 @
1e3bdac0
...
...
@@ -83,7 +83,7 @@ namespace Utils
{
MS_TRACE
();
s
tatic
s
ockaddr_storage
addrStorage
;
sockaddr_storage
addrStorage
;
char
ipBuffer
[
INET6_ADDRSTRLEN
]
=
{
0
};
int
err
;
...
...
worker/src/Utils/String.cpp
浏览文件 @
1e3bdac0
...
...
@@ -19,7 +19,7 @@
/* Static. */
static
constexpr
size_t
BufferOutSize
{
65536
};
static
uint8_t
BufferOut
[
BufferOutSize
];
thread_local
static
uint8_t
BufferOut
[
BufferOutSize
];
static
const
uint8_t
Base64Table
[
65
]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
...
...
worker/src/Worker.cpp
浏览文件 @
1e3bdac0
...
...
@@ -44,6 +44,12 @@ Worker::~Worker()
{
MS_TRACE
();
// Delete the Channel.
delete
this
->
channel
;
// Delete the PayloadChannel.
delete
this
->
payloadChannel
;
if
(
!
this
->
closed
)
Close
();
}
...
...
@@ -70,10 +76,10 @@ void Worker::Close()
this
->
mapRouters
.
clear
();
// Close the Channel.
delete
this
->
channel
;
this
->
channel
->
Close
()
;
// Close the PayloadChannel.
delete
this
->
payloadChannel
;
this
->
payloadChannel
->
Close
()
;
}
void
Worker
::
FillJson
(
json
&
jsonObject
)
const
...
...
worker/src/handles/UnixStreamSocket.cpp
浏览文件 @
1e3bdac0
...
...
@@ -113,10 +113,10 @@ UnixStreamSocket::~UnixStreamSocket()
{
MS_TRACE_STD
();
delete
[]
this
->
buffer
;
if
(
!
this
->
closed
)
Close
();
delete
[]
this
->
buffer
;
}
void
UnixStreamSocket
::
Close
()
...
...
worker/src/lib.cpp
浏览文件 @
1e3bdac0
...
...
@@ -135,14 +135,14 @@ extern "C" int run_worker(
Worker
worker
(
channel
,
payloadChannel
);
// Free static stuff.
DepLibUV
::
ClassDestroy
();
DepLibSRTP
::
ClassDestroy
();
Utils
::
Crypto
::
ClassDestroy
();
DepLibWebRTC
::
ClassDestroy
();
RTC
::
DtlsTransport
::
ClassDestroy
();
DepUsrSCTP
::
ClassDestroy
();
DepLibUV
::
ClassDestroy
();
// Wait a bit so peding messages to stdout/Channel arrive to the Node
// Wait a bit so pe
n
ding messages to stdout/Channel arrive to the Node
// process.
uv_sleep
(
200
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论