Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
0d7a5016
Unverified
提交
0d7a5016
authored
5月 19, 2021
作者:
Nazar Mokrynskyi
提交者:
GitHub
5月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid duplicated basenames so that libmediasoup-worker is compilable on macOS (#557)
上级
19f3f63b
隐藏空白字符变更
内嵌
并排
正在显示
65 个修改的文件
包含
668 行增加
和
656 行删除
+668
-656
Makefile
worker/Makefile
+1
-1
compile_commands_template.json
worker/compile_commands_template.json
+24
-24
ChannelNotifier.hpp
worker/include/Channel/ChannelNotifier.hpp
+4
-4
ChannelRequest.hpp
worker/include/Channel/ChannelRequest.hpp
+5
-5
ChannelSocket.hpp
worker/include/Channel/ChannelSocket.hpp
+7
-6
Logger.hpp
worker/include/Logger.hpp
+3
-3
PayloadChannelNotifier.hpp
worker/include/PayloadChannel/PayloadChannelNotifier.hpp
+4
-4
PayloadChannelRequest.hpp
worker/include/PayloadChannel/PayloadChannelRequest.hpp
+5
-5
PayloadChannelSocket.hpp
worker/include/PayloadChannel/PayloadChannelSocket.hpp
+9
-8
Consumer.hpp
worker/include/RTC/Consumer.hpp
+2
-2
DataConsumer.hpp
worker/include/RTC/DataConsumer.hpp
+4
-4
DataProducer.hpp
worker/include/RTC/DataProducer.hpp
+2
-2
DirectTransport.hpp
worker/include/RTC/DirectTransport.hpp
+1
-1
PipeConsumer.hpp
worker/include/RTC/PipeConsumer.hpp
+1
-1
PipeTransport.hpp
worker/include/RTC/PipeTransport.hpp
+1
-1
PlainTransport.hpp
worker/include/RTC/PlainTransport.hpp
+1
-1
Producer.hpp
worker/include/RTC/Producer.hpp
+2
-2
Router.hpp
worker/include/RTC/Router.hpp
+4
-4
SimpleConsumer.hpp
worker/include/RTC/SimpleConsumer.hpp
+1
-1
SimulcastConsumer.hpp
worker/include/RTC/SimulcastConsumer.hpp
+1
-1
SvcConsumer.hpp
worker/include/RTC/SvcConsumer.hpp
+1
-1
TcpConnection.hpp
worker/include/RTC/TcpConnection.hpp
+4
-4
TcpServer.hpp
worker/include/RTC/TcpServer.hpp
+5
-5
Transport.hpp
worker/include/RTC/Transport.hpp
+4
-4
UdpSocket.hpp
worker/include/RTC/UdpSocket.hpp
+3
-3
WebRtcTransport.hpp
worker/include/RTC/WebRtcTransport.hpp
+1
-1
Settings.hpp
worker/include/Settings.hpp
+2
-2
Worker.hpp
worker/include/Worker.hpp
+15
-14
TcpConnectionHandler.hpp
worker/include/handles/TcpConnectionHandler.hpp
+9
-9
TcpServerHandler.hpp
worker/include/handles/TcpServerHandler.hpp
+10
-10
UdpSocketHandler.hpp
worker/include/handles/UdpSocketHandler.hpp
+9
-8
mediasoup-worker.gyp
worker/mediasoup-worker.gyp
+18
-18
ChannelNotifier.cpp
worker/src/Channel/ChannelNotifier.cpp
+10
-10
ChannelRequest.cpp
worker/src/Channel/ChannelRequest.cpp
+194
-0
ChannelSocket.cpp
worker/src/Channel/ChannelSocket.cpp
+11
-12
Request.cpp
worker/src/Channel/Request.cpp
+0
-193
Logger.cpp
worker/src/Logger.cpp
+2
-2
PayloadChannelNotifier.cpp
worker/src/PayloadChannel/PayloadChannelNotifier.cpp
+10
-10
PayloadChannelRequest.cpp
worker/src/PayloadChannel/PayloadChannelRequest.cpp
+17
-15
PayloadChannelSocket.cpp
worker/src/PayloadChannel/PayloadChannelSocket.cpp
+13
-13
AudioLevelObserver.cpp
worker/src/RTC/AudioLevelObserver.cpp
+4
-4
Consumer.cpp
worker/src/RTC/Consumer.cpp
+16
-16
DataConsumer.cpp
worker/src/RTC/DataConsumer.cpp
+10
-10
DataProducer.cpp
worker/src/RTC/DataProducer.cpp
+3
-3
DirectTransport.cpp
worker/src/RTC/DirectTransport.cpp
+6
-6
PipeConsumer.cpp
worker/src/RTC/PipeConsumer.cpp
+3
-3
PipeTransport.cpp
worker/src/RTC/PipeTransport.cpp
+2
-2
PlainTransport.cpp
worker/src/RTC/PlainTransport.cpp
+7
-7
Producer.cpp
worker/src/RTC/Producer.cpp
+14
-14
Router.cpp
worker/src/RTC/Router.cpp
+14
-14
SctpAssociation.cpp
worker/src/RTC/SctpAssociation.cpp
+2
-2
SimpleConsumer.cpp
worker/src/RTC/SimpleConsumer.cpp
+5
-5
SimulcastConsumer.cpp
worker/src/RTC/SimulcastConsumer.cpp
+6
-6
SvcConsumer.cpp
worker/src/RTC/SvcConsumer.cpp
+6
-6
TcpConnection.cpp
worker/src/RTC/TcpConnection.cpp
+3
-3
TcpServer.cpp
worker/src/RTC/TcpServer.cpp
+2
-2
Transport.cpp
worker/src/RTC/Transport.cpp
+42
-42
UdpSocket.cpp
worker/src/RTC/UdpSocket.cpp
+1
-1
WebRtcTransport.cpp
worker/src/RTC/WebRtcTransport.cpp
+12
-12
Settings.cpp
worker/src/Settings.cpp
+2
-2
Worker.cpp
worker/src/Worker.cpp
+15
-14
TcpConnectionHandler.cpp
worker/src/handles/TcpConnectionHandler.cpp
+28
-23
TcpServerHandler.cpp
worker/src/handles/TcpServerHandler.cpp
+16
-16
UdpSocketHandler.cpp
worker/src/handles/UdpSocketHandler.cpp
+19
-19
lib.cpp
worker/src/lib.cpp
+10
-10
没有找到文件。
worker/Makefile
浏览文件 @
0d7a5016
...
...
@@ -110,5 +110,5 @@ docker-run:
mediasoup/docker:latest
libmediasoup-worker
:
$(PYTHON)
./scripts/configure.py
-
-no-duplicate-basename-check
-
R
libmediasoup-worker
$(PYTHON)
./scripts/configure.py
-R
libmediasoup-worker
$(MAKE)
-j
$(CORES)
BUILDTYPE
=
$(MEDIASOUP_BUILDTYPE)
-C
$(MEDIASOUP_OUT_DIR)
worker/compile_commands_template.json
浏览文件 @
0d7a5016
...
...
@@ -337,11 +337,11 @@
"-std=c++11"
,
"-I/usr/local/opt/openssl/include"
,
"-o"
,
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/Request.o"
,
"../src/Channel/Request.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/
Channel
Request.o"
,
"../src/Channel/
Channel
Request.cpp"
],
"directory"
:
"PATH/out"
,
"file"
:
"../src/Channel/Request.cpp"
"file"
:
"../src/Channel/
Channel
Request.cpp"
},
{
"arguments"
:
[
...
...
@@ -466,11 +466,11 @@
"-std=c++11"
,
"-I/usr/local/opt/openssl/include"
,
"-o"
,
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/UdpSocket.o"
,
"../src/handles/UdpSocket.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/UdpSocket
Handler
.o"
,
"../src/handles/UdpSocket
Handler
.cpp"
],
"directory"
:
"PATH/out"
,
"file"
:
"../src/handles/UdpSocket.cpp"
"file"
:
"../src/handles/UdpSocket
Handler
.cpp"
},
{
"arguments"
:
[
...
...
@@ -1670,11 +1670,11 @@
"-std=c++11"
,
"-I/usr/local/opt/openssl/include"
,
"-o"
,
"PATH/out/Release/obj.target/mediasoup-worker/src/PayloadChannel/
UnixStream
Socket.o"
,
"../src/PayloadChannel/
UnixStream
Socket.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/PayloadChannel/
PayloadChannel
Socket.o"
,
"../src/PayloadChannel/
PayloadChannel
Socket.cpp"
],
"directory"
:
"PATH/out"
,
"file"
:
"../src/PayloadChannel/
UnixStream
Socket.cpp"
"file"
:
"../src/PayloadChannel/
PayloadChannel
Socket.cpp"
},
{
"arguments"
:
[
...
...
@@ -1842,11 +1842,11 @@
"-std=c++11"
,
"-I/usr/local/opt/openssl/include"
,
"-o"
,
"PATH/out/Release/obj.target/mediasoup-worker/src/PayloadChannel/Notifier.o"
,
"../src/PayloadChannel/Notifier.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/PayloadChannel/
PayloadChannel
Notifier.o"
,
"../src/PayloadChannel/
PayloadChannel
Notifier.cpp"
],
"directory"
:
"PATH/out"
,
"file"
:
"../src/PayloadChannel/Notifier.cpp"
"file"
:
"../src/PayloadChannel/
PayloadChannel
Notifier.cpp"
},
{
"arguments"
:
[
...
...
@@ -1885,11 +1885,11 @@
"-std=c++11"
,
"-I/usr/local/opt/openssl/include"
,
"-o"
,
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/TcpConnection.o"
,
"../src/handles/TcpConnection.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/TcpConnection
Handler
.o"
,
"../src/handles/TcpConnection
Handler
.cpp"
],
"directory"
:
"PATH/out"
,
"file"
:
"../src/handles/TcpConnection.cpp"
"file"
:
"../src/handles/TcpConnection
Handler
.cpp"
},
{
"arguments"
:
[
...
...
@@ -2444,11 +2444,11 @@
"-std=c++11"
,
"-I/usr/local/opt/openssl/include"
,
"-o"
,
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/TcpServer.o"
,
"../src/handles/TcpServer.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/TcpServer
Handler
.o"
,
"../src/handles/TcpServer
Handler
.cpp"
],
"directory"
:
"PATH/out"
,
"file"
:
"../src/handles/TcpServer.cpp"
"file"
:
"../src/handles/TcpServer
Handler
.cpp"
},
{
"arguments"
:
[
...
...
@@ -2702,11 +2702,11 @@
"-std=c++11"
,
"-I/usr/local/opt/openssl/include"
,
"-o"
,
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/
UnixStream
Socket.o"
,
"../src/Channel/
UnixStream
Socket.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/
Channel
Socket.o"
,
"../src/Channel/
Channel
Socket.cpp"
],
"directory"
:
"PATH/out"
,
"file"
:
"../src/Channel/
UnixStream
Socket.cpp"
"file"
:
"../src/Channel/
Channel
Socket.cpp"
},
{
"arguments"
:
[
...
...
@@ -3691,11 +3691,11 @@
"-std=c++11"
,
"-I/usr/local/opt/openssl/include"
,
"-o"
,
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/Notifier.o"
,
"../src/Channel/Notifier.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/
Channel
Notifier.o"
,
"../src/Channel/
Channel
Notifier.cpp"
],
"directory"
:
"PATH/out"
,
"file"
:
"../src/Channel/Notifier.cpp"
"file"
:
"../src/Channel/
Channel
Notifier.cpp"
},
{
"arguments"
:
[
...
...
worker/include/Channel/Notifier.hpp
→
worker/include/Channel/
Channel
Notifier.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,22 +2,22 @@
#define MS_CHANNEL_NOTIFIER_HPP
#include "common.hpp"
#include "Channel/
UnixStream
Socket.hpp"
#include "Channel/
Channel
Socket.hpp"
#include <json.hpp>
#include <string>
namespace
Channel
{
class
Notifier
class
Channel
Notifier
{
public
:
static
void
ClassInit
(
Channel
::
UnixStream
Socket
*
channel
);
static
void
ClassInit
(
Channel
::
Channel
Socket
*
channel
);
static
void
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
);
static
void
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
,
json
&
data
);
public
:
// Passed by argument.
thread_local
static
Channel
::
UnixStream
Socket
*
channel
;
thread_local
static
Channel
::
Channel
Socket
*
channel
;
};
}
// namespace Channel
...
...
worker/include/Channel/Request.hpp
→
worker/include/Channel/
Channel
Request.hpp
浏览文件 @
0d7a5016
...
...
@@ -12,9 +12,9 @@ namespace Channel
{
// Avoid cyclic #include problem by declaring classes instead of including
// the corresponding header files.
class
UnixStream
Socket
;
class
Channel
Socket
;
class
Request
class
Channel
Request
{
public
:
enum
class
MethodId
...
...
@@ -76,8 +76,8 @@ namespace Channel
static
std
::
unordered_map
<
std
::
string
,
MethodId
>
string2MethodId
;
public
:
Request
(
Channel
::
UnixStream
Socket
*
channel
,
json
&
jsonRequest
);
virtual
~
Request
();
ChannelRequest
(
Channel
::
Channel
Socket
*
channel
,
json
&
jsonRequest
);
virtual
~
Channel
Request
();
void
Accept
();
void
Accept
(
json
&
data
);
...
...
@@ -86,7 +86,7 @@ namespace Channel
public
:
// Passed by argument.
Channel
::
UnixStream
Socket
*
channel
{
nullptr
};
Channel
::
Channel
Socket
*
channel
{
nullptr
};
uint32_t
id
{
0u
};
std
::
string
method
;
MethodId
methodId
;
...
...
worker/include/Channel/
UnixStream
Socket.hpp
→
worker/include/Channel/
Channel
Socket.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,7 +2,7 @@
#define MS_CHANNEL_UNIX_STREAM_SOCKET_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/
Channel
Request.hpp"
#include "handles/UnixStreamSocket.hpp"
#include <json.hpp>
...
...
@@ -47,19 +47,20 @@ namespace Channel
}
};
class
UnixStream
Socket
:
public
ConsumerSocket
::
Listener
class
Channel
Socket
:
public
ConsumerSocket
::
Listener
{
public
:
class
Listener
{
public
:
virtual
void
OnChannelRequest
(
Channel
::
UnixStreamSocket
*
channel
,
Channel
::
Request
*
request
)
=
0
;
virtual
void
OnChannelClosed
(
Channel
::
UnixStreamSocket
*
channel
)
=
0
;
virtual
void
OnChannelRequest
(
Channel
::
ChannelSocket
*
channel
,
Channel
::
ChannelRequest
*
request
)
=
0
;
virtual
void
OnChannelClosed
(
Channel
::
ChannelSocket
*
channel
)
=
0
;
};
public
:
explicit
UnixStream
Socket
(
int
consumerFd
,
int
producerFd
);
virtual
~
UnixStream
Socket
();
explicit
Channel
Socket
(
int
consumerFd
,
int
producerFd
);
virtual
~
Channel
Socket
();
public
:
void
SetListener
(
Listener
*
listener
);
...
...
worker/include/Logger.hpp
浏览文件 @
0d7a5016
...
...
@@ -89,7 +89,7 @@
#include "common.hpp"
#include "LogLevel.hpp"
#include "Settings.hpp"
#include "Channel/
UnixStream
Socket.hpp"
#include "Channel/
Channel
Socket.hpp"
#include <cstdio> // std::snprintf(), std::fprintf(), stdout, stderr
#include <cstdlib> // std::abort()
#include <cstring>
...
...
@@ -129,11 +129,11 @@
class
Logger
{
public
:
static
void
ClassInit
(
Channel
::
UnixStream
Socket
*
channel
);
static
void
ClassInit
(
Channel
::
Channel
Socket
*
channel
);
public
:
static
const
int64_t
pid
;
thread_local
static
Channel
::
UnixStream
Socket
*
channel
;
thread_local
static
Channel
::
Channel
Socket
*
channel
;
static
const
size_t
bufferSize
{
50000
};
static
char
buffer
[];
};
...
...
worker/include/PayloadChannel/Notifier.hpp
→
worker/include/PayloadChannel/
PayloadChannel
Notifier.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,16 +2,16 @@
#define MS_PAYLOAD_CHANNEL_NOTIFIER_HPP
#include "common.hpp"
#include "PayloadChannel/
UnixStream
Socket.hpp"
#include "PayloadChannel/
PayloadChannel
Socket.hpp"
#include <json.hpp>
#include <string>
namespace
PayloadChannel
{
class
Notifier
class
PayloadChannel
Notifier
{
public
:
static
void
ClassInit
(
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
);
static
void
ClassInit
(
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
);
static
void
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
,
const
uint8_t
*
payload
,
size_t
payloadLen
);
static
void
Emit
(
...
...
@@ -23,7 +23,7 @@ namespace PayloadChannel
public
:
// Passed by argument.
thread_local
static
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
;
thread_local
static
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
;
};
}
// namespace PayloadChannel
...
...
worker/include/PayloadChannel/Request.hpp
→
worker/include/PayloadChannel/
PayloadChannel
Request.hpp
浏览文件 @
0d7a5016
...
...
@@ -12,9 +12,9 @@ namespace PayloadChannel
{
// Avoid cyclic #include problem by declaring classes instead of including
// the corresponding header files.
class
UnixStream
Socket
;
class
PayloadChannel
Socket
;
class
Request
class
PayloadChannel
Request
{
public
:
enum
class
MethodId
...
...
@@ -29,8 +29,8 @@ namespace PayloadChannel
static
std
::
unordered_map
<
std
::
string
,
MethodId
>
string2MethodId
;
public
:
Request
(
PayloadChannel
::
UnixStream
Socket
*
channel
,
json
&
jsonRequest
);
virtual
~
Request
();
PayloadChannelRequest
(
PayloadChannel
::
PayloadChannel
Socket
*
channel
,
json
&
jsonRequest
);
virtual
~
PayloadChannel
Request
();
public
:
void
Accept
();
...
...
@@ -41,7 +41,7 @@ namespace PayloadChannel
public
:
// Passed by argument.
PayloadChannel
::
UnixStream
Socket
*
channel
{
nullptr
};
PayloadChannel
::
PayloadChannel
Socket
*
channel
{
nullptr
};
uint32_t
id
{
0u
};
std
::
string
method
;
MethodId
methodId
;
...
...
worker/include/PayloadChannel/
UnixStream
Socket.hpp
→
worker/include/PayloadChannel/
PayloadChannel
Socket.hpp
浏览文件 @
0d7a5016
...
...
@@ -3,7 +3,7 @@
#include "common.hpp"
#include "PayloadChannel/Notification.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/
PayloadChannel
Request.hpp"
#include "handles/UnixStreamSocket.hpp"
#include <json.hpp>
...
...
@@ -49,23 +49,24 @@ namespace PayloadChannel
}
};
class
UnixStream
Socket
:
public
ConsumerSocket
::
Listener
class
PayloadChannel
Socket
:
public
ConsumerSocket
::
Listener
{
public
:
class
Listener
{
public
:
virtual
void
OnPayloadChannelNotification
(
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
,
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
,
PayloadChannel
::
Notification
*
notification
)
=
0
;
virtual
void
OnPayloadChannelRequest
(
PayloadChannel
::
UnixStreamSocket
*
payloadChannel
,
PayloadChannel
::
Request
*
request
)
=
0
;
virtual
void
OnPayloadChannelClosed
(
PayloadChannel
::
UnixStreamSocket
*
payloadChannel
)
=
0
;
PayloadChannel
::
PayloadChannelSocket
*
payloadChannel
,
PayloadChannel
::
PayloadChannelRequest
*
request
)
=
0
;
virtual
void
OnPayloadChannelClosed
(
PayloadChannel
::
PayloadChannelSocket
*
payloadChannel
)
=
0
;
};
public
:
explicit
UnixStream
Socket
(
int
consumerFd
,
int
producerFd
);
virtual
~
UnixStream
Socket
();
explicit
PayloadChannel
Socket
(
int
consumerFd
,
int
producerFd
);
virtual
~
PayloadChannel
Socket
();
public
:
void
SetListener
(
Listener
*
listener
);
...
...
@@ -87,7 +88,7 @@ namespace PayloadChannel
ConsumerSocket
consumerSocket
;
ProducerSocket
producerSocket
;
PayloadChannel
::
Notification
*
ongoingNotification
{
nullptr
};
PayloadChannel
::
Request
*
ongoingRequest
{
nullptr
};
PayloadChannel
::
PayloadChannel
Request
*
ongoingRequest
{
nullptr
};
uint8_t
*
WriteBuffer
;
};
}
// namespace PayloadChannel
...
...
worker/include/RTC/Consumer.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,7 +2,7 @@
#define MS_RTC_CONSUMER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/
Channel
Request.hpp"
#include "RTC/RTCP/CompoundPacket.hpp"
#include "RTC/RTCP/FeedbackPs.hpp"
#include "RTC/RTCP/FeedbackPsFir.hpp"
...
...
@@ -67,7 +67,7 @@ namespace RTC
virtual
void
FillJson
(
json
&
jsonObject
)
const
;
virtual
void
FillJsonStats
(
json
&
jsonArray
)
const
=
0
;
virtual
void
FillJsonScore
(
json
&
jsonObject
)
const
=
0
;
virtual
void
HandleRequest
(
Channel
::
Request
*
request
);
virtual
void
HandleRequest
(
Channel
::
Channel
Request
*
request
);
RTC
::
Media
::
Kind
GetKind
()
const
{
return
this
->
kind
;
...
...
worker/include/RTC/DataConsumer.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,8 +2,8 @@
#define MS_RTC_DATA_CONSUMER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "PayloadChannel/Request.hpp"
#include "Channel/
Channel
Request.hpp"
#include "PayloadChannel/
PayloadChannel
Request.hpp"
#include "RTC/SctpDictionaries.hpp"
#include <json.hpp>
#include <string>
...
...
@@ -47,8 +47,8 @@ namespace RTC
public
:
void
FillJson
(
json
&
jsonObject
)
const
;
void
FillJsonStats
(
json
&
jsonArray
)
const
;
void
HandleRequest
(
Channel
::
Request
*
request
);
void
HandleRequest
(
PayloadChannel
::
Request
*
request
);
void
HandleRequest
(
Channel
::
Channel
Request
*
request
);
void
HandleRequest
(
PayloadChannel
::
PayloadChannel
Request
*
request
);
Type
GetType
()
const
{
return
this
->
type
;
...
...
worker/include/RTC/DataProducer.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,7 +2,7 @@
#define MS_RTC_DATA_PRODUCER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/
Channel
Request.hpp"
#include "RTC/SctpDictionaries.hpp"
#include <json.hpp>
#include <string>
...
...
@@ -33,7 +33,7 @@ namespace RTC
public
:
void
FillJson
(
json
&
jsonObject
)
const
;
void
FillJsonStats
(
json
&
jsonArray
)
const
;
void
HandleRequest
(
Channel
::
Request
*
request
)
const
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
const
;
Type
GetType
()
const
{
return
this
->
type
;
...
...
worker/include/RTC/DirectTransport.hpp
浏览文件 @
0d7a5016
...
...
@@ -14,7 +14,7 @@ namespace RTC
public
:
void
FillJson
(
json
&
jsonObject
)
const
override
;
void
FillJsonStats
(
json
&
jsonArray
)
override
;
void
HandleRequest
(
Channel
::
Request
*
request
)
override
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
override
;
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
override
;
private
:
...
...
worker/include/RTC/PipeConsumer.hpp
浏览文件 @
0d7a5016
...
...
@@ -21,7 +21,7 @@ namespace RTC
void
FillJson
(
json
&
jsonObject
)
const
override
;
void
FillJsonStats
(
json
&
jsonArray
)
const
override
;
void
FillJsonScore
(
json
&
jsonObject
)
const
override
;
void
HandleRequest
(
Channel
::
Request
*
request
)
override
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
override
;
void
ProducerRtpStream
(
RTC
::
RtpStream
*
rtpStream
,
uint32_t
mappedSsrc
)
override
;
void
ProducerNewRtpStream
(
RTC
::
RtpStream
*
rtpStream
,
uint32_t
mappedSsrc
)
override
;
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
override
;
...
...
worker/include/RTC/PipeTransport.hpp
浏览文件 @
0d7a5016
...
...
@@ -29,7 +29,7 @@ namespace RTC
public
:
void
FillJson
(
json
&
jsonObject
)
const
override
;
void
FillJsonStats
(
json
&
jsonArray
)
override
;
void
HandleRequest
(
Channel
::
Request
*
request
)
override
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
override
;
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
override
;
private
:
...
...
worker/include/RTC/PlainTransport.hpp
浏览文件 @
0d7a5016
...
...
@@ -30,7 +30,7 @@ namespace RTC
public
:
void
FillJson
(
json
&
jsonObject
)
const
override
;
void
FillJsonStats
(
json
&
jsonArray
)
override
;
void
HandleRequest
(
Channel
::
Request
*
request
)
override
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
override
;
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
override
;
private
:
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,7 +2,7 @@
#define MS_RTC_PRODUCER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/
Channel
Request.hpp"
#include "RTC/KeyFrameRequestManager.hpp"
#include "RTC/RTCP/CompoundPacket.hpp"
#include "RTC/RTCP/Packet.hpp"
...
...
@@ -89,7 +89,7 @@ namespace RTC
public
:
void
FillJson
(
json
&
jsonObject
)
const
;
void
FillJsonStats
(
json
&
jsonArray
)
const
;
void
HandleRequest
(
Channel
::
Request
*
request
);
void
HandleRequest
(
Channel
::
Channel
Request
*
request
);
RTC
::
Media
::
Kind
GetKind
()
const
{
return
this
->
kind
;
...
...
worker/include/RTC/Router.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,9 +2,9 @@
#define MS_RTC_ROUTER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/
Channel
Request.hpp"
#include "PayloadChannel/Notification.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/
PayloadChannel
Request.hpp"
#include "RTC/Consumer.hpp"
#include "RTC/DataConsumer.hpp"
#include "RTC/DataProducer.hpp"
...
...
@@ -30,8 +30,8 @@ namespace RTC
public
:
void
FillJson
(
json
&
jsonObject
)
const
;
void
HandleRequest
(
Channel
::
Request
*
request
);
void
HandleRequest
(
PayloadChannel
::
Request
*
request
);
void
HandleRequest
(
Channel
::
Channel
Request
*
request
);
void
HandleRequest
(
PayloadChannel
::
PayloadChannel
Request
*
request
);
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
);
private
:
...
...
worker/include/RTC/SimpleConsumer.hpp
浏览文件 @
0d7a5016
...
...
@@ -21,7 +21,7 @@ namespace RTC
void
FillJson
(
json
&
jsonObject
)
const
override
;
void
FillJsonStats
(
json
&
jsonArray
)
const
override
;
void
FillJsonScore
(
json
&
jsonObject
)
const
override
;
void
HandleRequest
(
Channel
::
Request
*
request
)
override
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
override
;
bool
IsActive
()
const
override
{
// clang-format off
...
...
worker/include/RTC/SimulcastConsumer.hpp
浏览文件 @
0d7a5016
...
...
@@ -22,7 +22,7 @@ namespace RTC
void
FillJson
(
json
&
jsonObject
)
const
override
;
void
FillJsonStats
(
json
&
jsonArray
)
const
override
;
void
FillJsonScore
(
json
&
jsonObject
)
const
override
;
void
HandleRequest
(
Channel
::
Request
*
request
)
override
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
override
;
RTC
::
Consumer
::
Layers
GetPreferredLayers
()
const
override
{
RTC
::
Consumer
::
Layers
layers
;
...
...
worker/include/RTC/SvcConsumer.hpp
浏览文件 @
0d7a5016
...
...
@@ -23,7 +23,7 @@ namespace RTC
void
FillJson
(
json
&
jsonObject
)
const
override
;
void
FillJsonStats
(
json
&
jsonArray
)
const
override
;
void
FillJsonScore
(
json
&
jsonObject
)
const
override
;
void
HandleRequest
(
Channel
::
Request
*
request
)
override
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
override
;
RTC
::
Consumer
::
Layers
GetPreferredLayers
()
const
override
{
RTC
::
Consumer
::
Layers
layers
;
...
...
worker/include/RTC/TcpConnection.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,11 +2,11 @@
#define MS_RTC_TCP_CONNECTION_HPP
#include "common.hpp"
#include "handles/TcpConnection.hpp"
#include "handles/TcpConnection
Handler
.hpp"
namespace
RTC
{
class
TcpConnection
:
public
::
TcpConnection
class
TcpConnection
:
public
::
TcpConnection
Handler
{
public
:
class
Listener
...
...
@@ -21,9 +21,9 @@ namespace RTC
~
TcpConnection
()
override
;
public
:
void
Send
(
const
uint8_t
*
data
,
size_t
len
,
::
TcpConnection
::
onSendCallback
*
cb
);
void
Send
(
const
uint8_t
*
data
,
size_t
len
,
::
TcpConnection
Handler
::
onSendCallback
*
cb
);
/* Pure virtual methods inherited from ::TcpConnection. */
/* Pure virtual methods inherited from ::TcpConnection
Handler
. */
public
:
void
UserOnTcpConnectionRead
()
override
;
...
...
worker/include/RTC/TcpServer.hpp
浏览文件 @
0d7a5016
...
...
@@ -3,13 +3,13 @@
#include "common.hpp"
#include "RTC/TcpConnection.hpp"
#include "handles/TcpConnection.hpp"
#include "handles/TcpServer.hpp"
#include "handles/TcpConnection
Handler
.hpp"
#include "handles/TcpServer
Handler
.hpp"
#include <string>
namespace
RTC
{
class
TcpServer
:
public
::
TcpServer
class
TcpServer
:
public
::
TcpServer
Handler
{
public
:
class
Listener
...
...
@@ -23,10 +23,10 @@ namespace RTC
TcpServer
(
Listener
*
listener
,
RTC
::
TcpConnection
::
Listener
*
connListener
,
std
::
string
&
ip
);
~
TcpServer
()
override
;
/* Pure virtual methods inherited from ::TcpServer. */
/* Pure virtual methods inherited from ::TcpServer
Handler
. */
public
:
void
UserOnTcpConnectionAlloc
()
override
;
void
UserOnTcpConnectionClosed
(
::
TcpConnection
*
connection
)
override
;
void
UserOnTcpConnectionClosed
(
::
TcpConnection
Handler
*
connection
)
override
;
private
:
// Passed by argument.
...
...
worker/include/RTC/Transport.hpp
浏览文件 @
0d7a5016
...
...
@@ -4,9 +4,9 @@
#include "common.hpp"
#include "DepLibUV.hpp"
#include "Channel/Request.hpp"
#include "Channel/
Channel
Request.hpp"
#include "PayloadChannel/Notification.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/
PayloadChannel
Request.hpp"
#include "RTC/Consumer.hpp"
#include "RTC/DataConsumer.hpp"
#include "RTC/DataProducer.hpp"
...
...
@@ -121,8 +121,8 @@ namespace RTC
virtual
void
FillJsonStats
(
json
&
jsonArray
);
// Subclasses must implement these methods and call the parent's ones to
// handle common requests.
virtual
void
HandleRequest
(
Channel
::
Request
*
request
);
virtual
void
HandleRequest
(
PayloadChannel
::
Request
*
request
);
virtual
void
HandleRequest
(
Channel
::
Channel
Request
*
request
);
virtual
void
HandleRequest
(
PayloadChannel
::
PayloadChannel
Request
*
request
);
virtual
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
);
protected
:
...
...
worker/include/RTC/UdpSocket.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,12 +2,12 @@
#define MS_RTC_UDP_SOCKET_HPP
#include "common.hpp"
#include "handles/UdpSocket.hpp"
#include "handles/UdpSocket
Handler
.hpp"
#include <string>
namespace
RTC
{
class
UdpSocket
:
public
::
UdpSocket
class
UdpSocket
:
public
::
UdpSocket
Handler
{
public
:
class
Listener
...
...
@@ -21,7 +21,7 @@ namespace RTC
UdpSocket
(
Listener
*
listener
,
std
::
string
&
ip
);
~
UdpSocket
()
override
;
/* Pure virtual methods inherited from ::UdpSocket. */
/* Pure virtual methods inherited from ::UdpSocket
Handler
. */
public
:
void
UserOnUdpDatagramReceived
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
override
;
...
...
worker/include/RTC/WebRtcTransport.hpp
浏览文件 @
0d7a5016
...
...
@@ -36,7 +36,7 @@ namespace RTC
public
:
void
FillJson
(
json
&
jsonObject
)
const
override
;
void
FillJsonStats
(
json
&
jsonArray
)
override
;
void
HandleRequest
(
Channel
::
Request
*
request
)
override
;
void
HandleRequest
(
Channel
::
Channel
Request
*
request
)
override
;
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
override
;
private
:
...
...
worker/include/Settings.hpp
浏览文件 @
0d7a5016
...
...
@@ -3,7 +3,7 @@
#include "common.hpp"
#include "LogLevel.hpp"
#include "Channel/Request.hpp"
#include "Channel/
Channel
Request.hpp"
#include <map>
#include <string>
#include <vector>
...
...
@@ -43,7 +43,7 @@ public:
public
:
static
void
SetConfiguration
(
int
argc
,
char
*
argv
[]);
static
void
PrintConfiguration
();
static
void
HandleRequest
(
Channel
::
Request
*
request
);
static
void
HandleRequest
(
Channel
::
Channel
Request
*
request
);
private
:
static
void
SetLogLevel
(
std
::
string
&
level
);
...
...
worker/include/Worker.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,11 +2,11 @@
#define MS_WORKER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/
UnixStream
Socket.hpp"
#include "Channel/
Channel
Request.hpp"
#include "Channel/
Channel
Socket.hpp"
#include "PayloadChannel/Notification.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/
UnixStream
Socket.hpp"
#include "PayloadChannel/
PayloadChannel
Request.hpp"
#include "PayloadChannel/
PayloadChannel
Socket.hpp"
#include "RTC/Router.hpp"
#include "handles/SignalsHandler.hpp"
#include <json.hpp>
...
...
@@ -15,12 +15,12 @@
using
json
=
nlohmann
::
json
;
class
Worker
:
public
Channel
::
UnixStream
Socket
::
Listener
,
public
PayloadChannel
::
UnixStream
Socket
::
Listener
,
class
Worker
:
public
Channel
::
Channel
Socket
::
Listener
,
public
PayloadChannel
::
PayloadChannel
Socket
::
Listener
,
public
SignalsHandler
::
Listener
{
public
:
explicit
Worker
(
Channel
::
UnixStreamSocket
*
channel
,
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
);
explicit
Worker
(
Channel
::
ChannelSocket
*
channel
,
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
);
~
Worker
();
private
:
...
...
@@ -32,17 +32,18 @@ private:
/* Methods inherited from Channel::lUnixStreamSocket::Listener. */
public
:
void
OnChannelRequest
(
Channel
::
UnixStreamSocket
*
channel
,
Channel
::
Request
*
request
)
override
;
void
OnChannelClosed
(
Channel
::
UnixStream
Socket
*
channel
)
override
;
void
OnChannelRequest
(
Channel
::
ChannelSocket
*
channel
,
Channel
::
Channel
Request
*
request
)
override
;
void
OnChannelClosed
(
Channel
::
Channel
Socket
*
channel
)
override
;
/* Methods inherited from PayloadChannel::lUnixStreamSocket::Listener. */
public
:
void
OnPayloadChannelNotification
(
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
,
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
,
PayloadChannel
::
Notification
*
notification
)
override
;
void
OnPayloadChannelRequest
(
PayloadChannel
::
UnixStreamSocket
*
payloadChannel
,
PayloadChannel
::
Request
*
request
)
override
;
void
OnPayloadChannelClosed
(
PayloadChannel
::
UnixStreamSocket
*
payloadChannel
)
override
;
PayloadChannel
::
PayloadChannelSocket
*
payloadChannel
,
PayloadChannel
::
PayloadChannelRequest
*
request
)
override
;
void
OnPayloadChannelClosed
(
PayloadChannel
::
PayloadChannelSocket
*
payloadChannel
)
override
;
/* Methods inherited from SignalsHandler::Listener. */
public
:
...
...
@@ -50,8 +51,8 @@ public:
private
:
// Passed by argument.
Channel
::
UnixStream
Socket
*
channel
{
nullptr
};
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
{
nullptr
};
Channel
::
Channel
Socket
*
channel
{
nullptr
};
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
{
nullptr
};
// Allocated by this.
SignalsHandler
*
signalsHandler
{
nullptr
};
std
::
unordered_map
<
std
::
string
,
RTC
::
Router
*>
mapRouters
;
...
...
worker/include/handles/TcpConnection.hpp
→
worker/include/handles/TcpConnection
Handler
.hpp
浏览文件 @
0d7a5016
...
...
@@ -5,7 +5,7 @@
#include <uv.h>
#include <string>
class
TcpConnection
class
TcpConnection
Handler
{
protected
:
using
onSendCallback
=
const
std
::
function
<
void
(
bool
sent
)
>
;
...
...
@@ -17,7 +17,7 @@ public:
virtual
~
Listener
()
=
default
;
public
:
virtual
void
OnTcpConnectionClosed
(
TcpConnection
*
connection
)
=
0
;
virtual
void
OnTcpConnectionClosed
(
TcpConnection
Handler
*
connection
)
=
0
;
};
public
:
...
...
@@ -40,14 +40,14 @@ public:
uv_write_t
req
;
uint8_t
*
store
{
nullptr
};
TcpConnection
::
onSendCallback
*
cb
{
nullptr
};
TcpConnection
Handler
::
onSendCallback
*
cb
{
nullptr
};
};
public
:
explicit
TcpConnection
(
size_t
bufferSize
);
TcpConnection
&
operator
=
(
const
TcpConnection
&
)
=
delete
;
TcpConnection
(
const
TcpConnection
&
)
=
delete
;
virtual
~
TcpConnection
();
explicit
TcpConnection
Handler
(
size_t
bufferSize
);
TcpConnection
Handler
&
operator
=
(
const
TcpConnectionHandler
&
)
=
delete
;
TcpConnection
Handler
(
const
TcpConnectionHandler
&
)
=
delete
;
virtual
~
TcpConnection
Handler
();
public
:
void
Close
();
...
...
@@ -66,13 +66,13 @@ public:
return
this
->
uvHandle
;
}
void
Start
();
void
Write
(
const
uint8_t
*
data
,
size_t
len
,
TcpConnection
::
onSendCallback
*
cb
);
void
Write
(
const
uint8_t
*
data
,
size_t
len
,
TcpConnection
Handler
::
onSendCallback
*
cb
);
void
Write
(
const
uint8_t
*
data1
,
size_t
len1
,
const
uint8_t
*
data2
,
size_t
len2
,
TcpConnection
::
onSendCallback
*
cb
);
TcpConnection
Handler
::
onSendCallback
*
cb
);
void
ErrorReceiving
();
const
struct
sockaddr
*
GetLocalAddress
()
const
{
...
...
worker/include/handles/TcpServer.hpp
→
worker/include/handles/TcpServer
Handler
.hpp
浏览文件 @
0d7a5016
...
...
@@ -2,19 +2,19 @@
#define MS_TCP_SERVER_HPP
#include "common.hpp"
#include "handles/TcpConnection.hpp"
#include "handles/TcpConnection
Handler
.hpp"
#include <uv.h>
#include <string>
#include <unordered_set>
class
TcpServer
:
public
TcpConnection
::
Listener
class
TcpServer
Handler
:
public
TcpConnectionHandler
::
Listener
{
public
:
/**
* uvHandle must be an already initialized and binded uv_tcp_t pointer.
*/
TcpServer
(
uv_tcp_t
*
uvHandle
,
int
backlog
);
virtual
~
TcpServer
()
override
;
TcpServer
Handler
(
uv_tcp_t
*
uvHandle
,
int
backlog
);
virtual
~
TcpServer
Handler
()
override
;
public
:
void
Close
();
...
...
@@ -41,23 +41,23 @@ public:
}
protected
:
void
AcceptTcpConnection
(
TcpConnection
*
connection
);
void
AcceptTcpConnection
(
TcpConnection
Handler
*
connection
);
private
:
bool
SetLocalAddress
();
/* Pure virtual methods that must be implemented by the subclass. */
protected
:
virtual
void
UserOnTcpConnectionAlloc
()
=
0
;
virtual
void
UserOnTcpConnectionClosed
(
TcpConnection
*
connection
)
=
0
;
virtual
void
UserOnTcpConnectionAlloc
()
=
0
;
virtual
void
UserOnTcpConnectionClosed
(
TcpConnection
Handler
*
connection
)
=
0
;
/* Callbacks fired by UV events. */
public
:
void
OnUvConnection
(
int
status
);
/* Methods inherited from TcpConnection::Listener. */
/* Methods inherited from TcpConnection
Handler
::Listener. */
public
:
void
OnTcpConnectionClosed
(
TcpConnection
*
connection
)
override
;
void
OnTcpConnectionClosed
(
TcpConnection
Handler
*
connection
)
override
;
protected
:
struct
sockaddr_storage
localAddr
;
...
...
@@ -68,7 +68,7 @@ private:
// Allocated by this (may be passed by argument).
uv_tcp_t
*
uvHandle
{
nullptr
};
// Others.
std
::
unordered_set
<
TcpConnection
*>
connections
;
std
::
unordered_set
<
TcpConnection
Handler
*>
connections
;
bool
closed
{
false
};
};
...
...
worker/include/handles/UdpSocket.hpp
→
worker/include/handles/UdpSocket
Handler
.hpp
浏览文件 @
0d7a5016
...
...
@@ -5,7 +5,7 @@
#include <uv.h>
#include <string>
class
UdpSocket
class
UdpSocket
Handler
{
protected
:
using
onSendCallback
=
const
std
::
function
<
void
(
bool
sent
)
>
;
...
...
@@ -30,22 +30,23 @@ public:
uv_udp_send_t
req
;
uint8_t
*
store
{
nullptr
};
UdpSocket
::
onSendCallback
*
cb
{
nullptr
};
UdpSocket
Handler
::
onSendCallback
*
cb
{
nullptr
};
};
public
:
/**
* uvHandle must be an already initialized and binded uv_udp_t pointer.
*/
explicit
UdpSocket
(
uv_udp_t
*
uvHandle
);
UdpSocket
&
operator
=
(
const
UdpSocket
&
)
=
delete
;
UdpSocket
(
const
UdpSocket
&
)
=
delete
;
virtual
~
UdpSocket
();
explicit
UdpSocket
Handler
(
uv_udp_t
*
uvHandle
);
UdpSocket
Handler
&
operator
=
(
const
UdpSocketHandler
&
)
=
delete
;
UdpSocket
Handler
(
const
UdpSocketHandler
&
)
=
delete
;
virtual
~
UdpSocket
Handler
();
public
:
void
Close
();
virtual
void
Dump
()
const
;
void
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
,
UdpSocket
::
onSendCallback
*
cb
);
void
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
,
UdpSocketHandler
::
onSendCallback
*
cb
);
const
struct
sockaddr
*
GetLocalAddress
()
const
{
return
reinterpret_cast
<
const
struct
sockaddr
*>
(
&
this
->
localAddr
);
...
...
@@ -78,7 +79,7 @@ private:
public
:
void
OnUvRecvAlloc
(
size_t
suggestedSize
,
uv_buf_t
*
buf
);
void
OnUvRecv
(
ssize_t
nread
,
const
uv_buf_t
*
buf
,
const
struct
sockaddr
*
addr
,
unsigned
int
flags
);
void
OnUvSend
(
int
status
,
UdpSocket
::
onSendCallback
*
cb
);
void
OnUvSend
(
int
status
,
UdpSocket
Handler
::
onSendCallback
*
cb
);
/* Pure virtual methods that must be implemented by the subclass. */
protected
:
...
...
worker/mediasoup-worker.gyp
浏览文件 @
0d7a5016
...
...
@@ -30,18 +30,18 @@
'src/Utils/IP.cpp',
'src/Utils/String.cpp',
'src/handles/SignalsHandler.cpp',
'src/handles/TcpConnection.cpp',
'src/handles/TcpServer.cpp',
'src/handles/TcpConnection
Handler
.cpp',
'src/handles/TcpServer
Handler
.cpp',
'src/handles/Timer.cpp',
'src/handles/UdpSocket.cpp',
'src/handles/UdpSocket
Handler
.cpp',
'src/handles/UnixStreamSocket.cpp',
'src/Channel/Notifier.cpp',
'src/Channel/Request.cpp',
'src/Channel/
UnixStream
Socket.cpp',
'src/Channel/
Channel
Notifier.cpp',
'src/Channel/
Channel
Request.cpp',
'src/Channel/
Channel
Socket.cpp',
'src/PayloadChannel/Notification.cpp',
'src/PayloadChannel/Notifier.cpp',
'src/PayloadChannel/Request.cpp',
'src/PayloadChannel/
UnixStream
Socket.cpp',
'src/PayloadChannel/
PayloadChannel
Notifier.cpp',
'src/PayloadChannel/
PayloadChannel
Request.cpp',
'src/PayloadChannel/
PayloadChannel
Socket.cpp',
'src/RTC/AudioLevelObserver.cpp',
'src/RTC/Consumer.cpp',
'src/RTC/DataConsumer.cpp',
...
...
@@ -142,18 +142,18 @@
'include/Worker.hpp',
'include/common.hpp',
'include/handles/SignalsHandler.hpp',
'include/handles/TcpConnection.hpp',
'include/handles/TcpServer.hpp',
'include/handles/TcpConnection
Handler
.hpp',
'include/handles/TcpServer
Handler
.hpp',
'include/handles/Timer.hpp',
'include/handles/UdpSocket.hpp',
'include/handles/UdpSocket
Handler
.hpp',
'include/handles/UnixStreamSocket.hpp',
'include/Channel/Notifier.hpp',
'include/Channel/Request.hpp',
'include/Channel/
UnixStream
Socket.hpp',
'include/Channel/
Channel
Notifier.hpp',
'include/Channel/
Channel
Request.hpp',
'include/Channel/
Channel
Socket.hpp',
'include/PayloadChannel/Notification.hpp',
'include/PayloadChannel/Notifier.hpp',
'include/PayloadChannel/Request.hpp',
'include/PayloadChannel/
UnixStream
Socket.hpp',
'include/PayloadChannel/
PayloadChannel
Notifier.hpp',
'include/PayloadChannel/
PayloadChannel
Request.hpp',
'include/PayloadChannel/
PayloadChannel
Socket.hpp',
'include/RTC/BweType.hpp',
'include/RTC/AudioLevelObserver.hpp',
'include/RTC/Consumer.hpp',
...
...
worker/src/Channel/Notifier.cpp
→
worker/src/Channel/
Channel
Notifier.cpp
浏览文件 @
0d7a5016
#define MS_CLASS "Channel::Notifier"
// #define MS_LOG_DEV_LEVEL 3
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include "Logger.hpp"
namespace
Channel
{
/* Class variables. */
thread_local
Channel
::
UnixStreamSocket
*
Notifier
::
channel
{
nullptr
};
thread_local
Channel
::
ChannelSocket
*
Channel
Notifier
::
channel
{
nullptr
};
/* Static methods. */
void
Notifier
::
ClassInit
(
Channel
::
UnixStream
Socket
*
channel
)
void
ChannelNotifier
::
ClassInit
(
Channel
::
Channel
Socket
*
channel
)
{
MS_TRACE
();
Notifier
::
channel
=
channel
;
Channel
Notifier
::
channel
=
channel
;
}
void
Notifier
::
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
)
void
Channel
Notifier
::
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
)
{
MS_TRACE
();
MS_ASSERT
(
Notifier
::
channel
,
"channel unset"
);
MS_ASSERT
(
Channel
Notifier
::
channel
,
"channel unset"
);
json
jsonNotification
=
json
::
object
();
jsonNotification
[
"targetId"
]
=
targetId
;
jsonNotification
[
"event"
]
=
event
;
Notifier
::
channel
->
Send
(
jsonNotification
);
Channel
Notifier
::
channel
->
Send
(
jsonNotification
);
}
void
Notifier
::
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
,
json
&
data
)
void
Channel
Notifier
::
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
,
json
&
data
)
{
MS_TRACE
();
MS_ASSERT
(
Notifier
::
channel
,
"channel unset"
);
MS_ASSERT
(
Channel
Notifier
::
channel
,
"channel unset"
);
json
jsonNotification
=
json
::
object
();
...
...
@@ -45,6 +45,6 @@ namespace Channel
jsonNotification
[
"event"
]
=
event
;
jsonNotification
[
"data"
]
=
data
;
Notifier
::
channel
->
Send
(
jsonNotification
);
Channel
Notifier
::
channel
->
Send
(
jsonNotification
);
}
}
// namespace Channel
worker/src/Channel/ChannelRequest.cpp
0 → 100644
浏览文件 @
0d7a5016
#define MS_CLASS "Channel::ChannelRequest"
// #define MS_LOG_DEV_LEVEL 3
#include "Channel/ChannelRequest.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
namespace
Channel
{
/* Class variables. */
// clang-format off
std
::
unordered_map
<
std
::
string
,
ChannelRequest
::
MethodId
>
ChannelRequest
::
string2MethodId
=
{
{
"worker.close"
,
ChannelRequest
::
MethodId
::
WORKER_CLOSE
},
{
"worker.dump"
,
ChannelRequest
::
MethodId
::
WORKER_DUMP
},
{
"worker.getResourceUsage"
,
ChannelRequest
::
MethodId
::
WORKER_GET_RESOURCE_USAGE
},
{
"worker.updateSettings"
,
ChannelRequest
::
MethodId
::
WORKER_UPDATE_SETTINGS
},
{
"worker.createRouter"
,
ChannelRequest
::
MethodId
::
WORKER_CREATE_ROUTER
},
{
"router.close"
,
ChannelRequest
::
MethodId
::
ROUTER_CLOSE
},
{
"router.dump"
,
ChannelRequest
::
MethodId
::
ROUTER_DUMP
},
{
"router.createWebRtcTransport"
,
ChannelRequest
::
MethodId
::
ROUTER_CREATE_WEBRTC_TRANSPORT
},
{
"router.createPlainTransport"
,
ChannelRequest
::
MethodId
::
ROUTER_CREATE_PLAIN_TRANSPORT
},
{
"router.createPipeTransport"
,
ChannelRequest
::
MethodId
::
ROUTER_CREATE_PIPE_TRANSPORT
},
{
"router.createDirectTransport"
,
ChannelRequest
::
MethodId
::
ROUTER_CREATE_DIRECT_TRANSPORT
},
{
"router.createAudioLevelObserver"
,
ChannelRequest
::
MethodId
::
ROUTER_CREATE_AUDIO_LEVEL_OBSERVER
},
{
"transport.close"
,
ChannelRequest
::
MethodId
::
TRANSPORT_CLOSE
},
{
"transport.dump"
,
ChannelRequest
::
MethodId
::
TRANSPORT_DUMP
},
{
"transport.getStats"
,
ChannelRequest
::
MethodId
::
TRANSPORT_GET_STATS
},
{
"transport.connect"
,
ChannelRequest
::
MethodId
::
TRANSPORT_CONNECT
},
{
"transport.setMaxIncomingBitrate"
,
ChannelRequest
::
MethodId
::
TRANSPORT_SET_MAX_INCOMING_BITRATE
},
{
"transport.restartIce"
,
ChannelRequest
::
MethodId
::
TRANSPORT_RESTART_ICE
},
{
"transport.produce"
,
ChannelRequest
::
MethodId
::
TRANSPORT_PRODUCE
},
{
"transport.consume"
,
ChannelRequest
::
MethodId
::
TRANSPORT_CONSUME
},
{
"transport.produceData"
,
ChannelRequest
::
MethodId
::
TRANSPORT_PRODUCE_DATA
},
{
"transport.consumeData"
,
ChannelRequest
::
MethodId
::
TRANSPORT_CONSUME_DATA
},
{
"transport.enableTraceEvent"
,
ChannelRequest
::
MethodId
::
TRANSPORT_ENABLE_TRACE_EVENT
},
{
"producer.close"
,
ChannelRequest
::
MethodId
::
PRODUCER_CLOSE
},
{
"producer.dump"
,
ChannelRequest
::
MethodId
::
PRODUCER_DUMP
},
{
"producer.getStats"
,
ChannelRequest
::
MethodId
::
PRODUCER_GET_STATS
},
{
"producer.pause"
,
ChannelRequest
::
MethodId
::
PRODUCER_PAUSE
},
{
"producer.resume"
,
ChannelRequest
::
MethodId
::
PRODUCER_RESUME
},
{
"producer.enableTraceEvent"
,
ChannelRequest
::
MethodId
::
PRODUCER_ENABLE_TRACE_EVENT
},
{
"consumer.close"
,
ChannelRequest
::
MethodId
::
CONSUMER_CLOSE
},
{
"consumer.dump"
,
ChannelRequest
::
MethodId
::
CONSUMER_DUMP
},
{
"consumer.getStats"
,
ChannelRequest
::
MethodId
::
CONSUMER_GET_STATS
},
{
"consumer.pause"
,
ChannelRequest
::
MethodId
::
CONSUMER_PAUSE
},
{
"consumer.resume"
,
ChannelRequest
::
MethodId
::
CONSUMER_RESUME
},
{
"consumer.setPreferredLayers"
,
ChannelRequest
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
},
{
"consumer.setPriority"
,
ChannelRequest
::
MethodId
::
CONSUMER_SET_PRIORITY
},
{
"consumer.requestKeyFrame"
,
ChannelRequest
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
},
{
"consumer.enableTraceEvent"
,
ChannelRequest
::
MethodId
::
CONSUMER_ENABLE_TRACE_EVENT
},
{
"dataProducer.close"
,
ChannelRequest
::
MethodId
::
DATA_PRODUCER_CLOSE
},
{
"dataProducer.dump"
,
ChannelRequest
::
MethodId
::
DATA_PRODUCER_DUMP
},
{
"dataProducer.getStats"
,
ChannelRequest
::
MethodId
::
DATA_PRODUCER_GET_STATS
},
{
"dataConsumer.close"
,
ChannelRequest
::
MethodId
::
DATA_CONSUMER_CLOSE
},
{
"dataConsumer.dump"
,
ChannelRequest
::
MethodId
::
DATA_CONSUMER_DUMP
},
{
"dataConsumer.getStats"
,
ChannelRequest
::
MethodId
::
DATA_CONSUMER_GET_STATS
},
{
"dataConsumer.getBufferedAmount"
,
ChannelRequest
::
MethodId
::
DATA_CONSUMER_GET_BUFFERED_AMOUNT
},
{
"dataConsumer.setBufferedAmountLowThreshold"
,
ChannelRequest
::
MethodId
::
DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD
},
{
"rtpObserver.close"
,
ChannelRequest
::
MethodId
::
RTP_OBSERVER_CLOSE
},
{
"rtpObserver.pause"
,
ChannelRequest
::
MethodId
::
RTP_OBSERVER_PAUSE
},
{
"rtpObserver.resume"
,
ChannelRequest
::
MethodId
::
RTP_OBSERVER_RESUME
},
{
"rtpObserver.addProducer"
,
ChannelRequest
::
MethodId
::
RTP_OBSERVER_ADD_PRODUCER
},
{
"rtpObserver.removeProducer"
,
ChannelRequest
::
MethodId
::
RTP_OBSERVER_REMOVE_PRODUCER
}
};
// clang-format on
/* Instance methods. */
ChannelRequest
::
ChannelRequest
(
Channel
::
ChannelSocket
*
channel
,
json
&
jsonRequest
)
:
channel
(
channel
)
{
MS_TRACE
();
auto
jsonIdIt
=
jsonRequest
.
find
(
"id"
);
if
(
jsonIdIt
==
jsonRequest
.
end
()
||
!
Utils
::
Json
::
IsPositiveInteger
(
*
jsonIdIt
))
MS_THROW_ERROR
(
"missing id"
);
this
->
id
=
jsonIdIt
->
get
<
uint32_t
>
();
auto
jsonMethodIt
=
jsonRequest
.
find
(
"method"
);
if
(
jsonMethodIt
==
jsonRequest
.
end
()
||
!
jsonMethodIt
->
is_string
())
MS_THROW_ERROR
(
"missing method"
);
this
->
method
=
jsonMethodIt
->
get
<
std
::
string
>
();
auto
methodIdIt
=
ChannelRequest
::
string2MethodId
.
find
(
this
->
method
);
if
(
methodIdIt
==
ChannelRequest
::
string2MethodId
.
end
())
{
Error
(
"unknown method"
);
MS_THROW_ERROR
(
"unknown method '%s'"
,
this
->
method
.
c_str
());
}
this
->
methodId
=
methodIdIt
->
second
;
auto
jsonInternalIt
=
jsonRequest
.
find
(
"internal"
);
if
(
jsonInternalIt
!=
jsonRequest
.
end
()
&&
jsonInternalIt
->
is_object
())
this
->
internal
=
*
jsonInternalIt
;
else
this
->
internal
=
json
::
object
();
auto
jsonDataIt
=
jsonRequest
.
find
(
"data"
);
if
(
jsonDataIt
!=
jsonRequest
.
end
()
&&
jsonDataIt
->
is_object
())
this
->
data
=
*
jsonDataIt
;
else
this
->
data
=
json
::
object
();
}
ChannelRequest
::~
ChannelRequest
()
{
MS_TRACE
();
}
void
ChannelRequest
::
Accept
()
{
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"request already replied"
);
this
->
replied
=
true
;
json
jsonResponse
=
json
::
object
();
jsonResponse
[
"id"
]
=
this
->
id
;
jsonResponse
[
"accepted"
]
=
true
;
this
->
channel
->
Send
(
jsonResponse
);
}
void
ChannelRequest
::
Accept
(
json
&
data
)
{
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"request already replied"
);
this
->
replied
=
true
;
json
jsonResponse
=
json
::
object
();
jsonResponse
[
"id"
]
=
this
->
id
;
jsonResponse
[
"accepted"
]
=
true
;
if
(
data
.
is_structured
())
jsonResponse
[
"data"
]
=
data
;
this
->
channel
->
Send
(
jsonResponse
);
}
void
ChannelRequest
::
Error
(
const
char
*
reason
)
{
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"request already replied"
);
this
->
replied
=
true
;
json
jsonResponse
=
json
::
object
();
jsonResponse
[
"id"
]
=
this
->
id
;
jsonResponse
[
"error"
]
=
"Error"
;
if
(
reason
!=
nullptr
)
jsonResponse
[
"reason"
]
=
reason
;
this
->
channel
->
Send
(
jsonResponse
);
}
void
ChannelRequest
::
TypeError
(
const
char
*
reason
)
{
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"request already replied"
);
this
->
replied
=
true
;
json
jsonResponse
=
json
::
object
();
jsonResponse
[
"id"
]
=
this
->
id
;
jsonResponse
[
"error"
]
=
"TypeError"
;
if
(
reason
!=
nullptr
)
jsonResponse
[
"reason"
]
=
reason
;
this
->
channel
->
Send
(
jsonResponse
);
}
}
// namespace Channel
worker/src/Channel/
UnixStream
Socket.cpp
→
worker/src/Channel/
Channel
Socket.cpp
浏览文件 @
0d7a5016
#define MS_CLASS "Channel::
UnixStream
Socket"
#define MS_CLASS "Channel::
Channel
Socket"
// #define MS_LOG_DEV_LEVEL 3
#include "Channel/
UnixStream
Socket.hpp"
#include "Channel/
Channel
Socket.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include <cmath> // std::ceil()
...
...
@@ -21,7 +21,7 @@ namespace Channel
static
constexpr
size_t
NsPayloadMaxLen
{
4194304
};
/* Instance methods. */
UnixStreamSocket
::
UnixStream
Socket
(
int
consumerFd
,
int
producerFd
)
ChannelSocket
::
Channel
Socket
(
int
consumerFd
,
int
producerFd
)
:
consumerSocket
(
consumerFd
,
NsMessageMaxLen
,
this
),
producerSocket
(
producerFd
,
NsMessageMaxLen
)
{
MS_TRACE_STD
();
...
...
@@ -29,21 +29,21 @@ namespace Channel
this
->
WriteBuffer
=
static_cast
<
uint8_t
*>
(
std
::
malloc
(
NsMessageMaxLen
));
}
UnixStreamSocket
::~
UnixStream
Socket
()
ChannelSocket
::~
Channel
Socket
()
{
MS_TRACE_STD
();
std
::
free
(
this
->
WriteBuffer
);
}
void
UnixStream
Socket
::
SetListener
(
Listener
*
listener
)
void
Channel
Socket
::
SetListener
(
Listener
*
listener
)
{
MS_TRACE_STD
();
this
->
listener
=
listener
;
}
void
UnixStream
Socket
::
Send
(
json
&
jsonMessage
)
void
Channel
Socket
::
Send
(
json
&
jsonMessage
)
{
MS_TRACE_STD
();
...
...
@@ -62,7 +62,7 @@ namespace Channel
SendImpl
(
message
.
c_str
(),
message
.
length
());
}
void
UnixStream
Socket
::
SendLog
(
char
*
message
,
size_t
messageLen
)
void
Channel
Socket
::
SendLog
(
char
*
message
,
size_t
messageLen
)
{
MS_TRACE_STD
();
...
...
@@ -79,7 +79,7 @@ namespace Channel
SendImpl
(
message
,
messageLen
);
}
inline
void
UnixStream
Socket
::
SendImpl
(
const
void
*
nsPayload
,
size_t
nsPayloadLen
)
inline
void
Channel
Socket
::
SendImpl
(
const
void
*
nsPayload
,
size_t
nsPayloadLen
)
{
MS_TRACE_STD
();
...
...
@@ -105,15 +105,14 @@ namespace Channel
this
->
producerSocket
.
Write
(
this
->
WriteBuffer
,
nsLen
);
}
void
UnixStreamSocket
::
OnConsumerSocketMessage
(
ConsumerSocket
*
/*consumerSocket*/
,
char
*
msg
,
size_t
msgLen
)
void
ChannelSocket
::
OnConsumerSocketMessage
(
ConsumerSocket
*
/*consumerSocket*/
,
char
*
msg
,
size_t
msgLen
)
{
MS_TRACE_STD
();
try
{
json
jsonMessage
=
json
::
parse
(
msg
,
msg
+
msgLen
);
auto
*
request
=
new
Channel
::
Request
(
this
,
jsonMessage
);
auto
*
request
=
new
Channel
::
Channel
Request
(
this
,
jsonMessage
);
// Notify the listener.
try
...
...
@@ -142,7 +141,7 @@ namespace Channel
}
}
void
UnixStream
Socket
::
OnConsumerSocketClosed
(
ConsumerSocket
*
/*consumerSocket*/
)
void
Channel
Socket
::
OnConsumerSocketClosed
(
ConsumerSocket
*
/*consumerSocket*/
)
{
MS_TRACE_STD
();
...
...
worker/src/Channel/Request.cpp
deleted
100644 → 0
浏览文件 @
19f3f63b
#define MS_CLASS "Channel::Request"
// #define MS_LOG_DEV_LEVEL 3
#include "Channel/Request.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
namespace
Channel
{
/* Class variables. */
// clang-format off
std
::
unordered_map
<
std
::
string
,
Request
::
MethodId
>
Request
::
string2MethodId
=
{
{
"worker.close"
,
Request
::
MethodId
::
WORKER_CLOSE
},
{
"worker.dump"
,
Request
::
MethodId
::
WORKER_DUMP
},
{
"worker.getResourceUsage"
,
Request
::
MethodId
::
WORKER_GET_RESOURCE_USAGE
},
{
"worker.updateSettings"
,
Request
::
MethodId
::
WORKER_UPDATE_SETTINGS
},
{
"worker.createRouter"
,
Request
::
MethodId
::
WORKER_CREATE_ROUTER
},
{
"router.close"
,
Request
::
MethodId
::
ROUTER_CLOSE
},
{
"router.dump"
,
Request
::
MethodId
::
ROUTER_DUMP
},
{
"router.createWebRtcTransport"
,
Request
::
MethodId
::
ROUTER_CREATE_WEBRTC_TRANSPORT
},
{
"router.createPlainTransport"
,
Request
::
MethodId
::
ROUTER_CREATE_PLAIN_TRANSPORT
},
{
"router.createPipeTransport"
,
Request
::
MethodId
::
ROUTER_CREATE_PIPE_TRANSPORT
},
{
"router.createDirectTransport"
,
Request
::
MethodId
::
ROUTER_CREATE_DIRECT_TRANSPORT
},
{
"router.createAudioLevelObserver"
,
Request
::
MethodId
::
ROUTER_CREATE_AUDIO_LEVEL_OBSERVER
},
{
"transport.close"
,
Request
::
MethodId
::
TRANSPORT_CLOSE
},
{
"transport.dump"
,
Request
::
MethodId
::
TRANSPORT_DUMP
},
{
"transport.getStats"
,
Request
::
MethodId
::
TRANSPORT_GET_STATS
},
{
"transport.connect"
,
Request
::
MethodId
::
TRANSPORT_CONNECT
},
{
"transport.setMaxIncomingBitrate"
,
Request
::
MethodId
::
TRANSPORT_SET_MAX_INCOMING_BITRATE
},
{
"transport.restartIce"
,
Request
::
MethodId
::
TRANSPORT_RESTART_ICE
},
{
"transport.produce"
,
Request
::
MethodId
::
TRANSPORT_PRODUCE
},
{
"transport.consume"
,
Request
::
MethodId
::
TRANSPORT_CONSUME
},
{
"transport.produceData"
,
Request
::
MethodId
::
TRANSPORT_PRODUCE_DATA
},
{
"transport.consumeData"
,
Request
::
MethodId
::
TRANSPORT_CONSUME_DATA
},
{
"transport.enableTraceEvent"
,
Request
::
MethodId
::
TRANSPORT_ENABLE_TRACE_EVENT
},
{
"producer.close"
,
Request
::
MethodId
::
PRODUCER_CLOSE
},
{
"producer.dump"
,
Request
::
MethodId
::
PRODUCER_DUMP
},
{
"producer.getStats"
,
Request
::
MethodId
::
PRODUCER_GET_STATS
},
{
"producer.pause"
,
Request
::
MethodId
::
PRODUCER_PAUSE
},
{
"producer.resume"
,
Request
::
MethodId
::
PRODUCER_RESUME
},
{
"producer.enableTraceEvent"
,
Request
::
MethodId
::
PRODUCER_ENABLE_TRACE_EVENT
},
{
"consumer.close"
,
Request
::
MethodId
::
CONSUMER_CLOSE
},
{
"consumer.dump"
,
Request
::
MethodId
::
CONSUMER_DUMP
},
{
"consumer.getStats"
,
Request
::
MethodId
::
CONSUMER_GET_STATS
},
{
"consumer.pause"
,
Request
::
MethodId
::
CONSUMER_PAUSE
},
{
"consumer.resume"
,
Request
::
MethodId
::
CONSUMER_RESUME
},
{
"consumer.setPreferredLayers"
,
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
},
{
"consumer.setPriority"
,
Request
::
MethodId
::
CONSUMER_SET_PRIORITY
},
{
"consumer.requestKeyFrame"
,
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
},
{
"consumer.enableTraceEvent"
,
Request
::
MethodId
::
CONSUMER_ENABLE_TRACE_EVENT
},
{
"dataProducer.close"
,
Request
::
MethodId
::
DATA_PRODUCER_CLOSE
},
{
"dataProducer.dump"
,
Request
::
MethodId
::
DATA_PRODUCER_DUMP
},
{
"dataProducer.getStats"
,
Request
::
MethodId
::
DATA_PRODUCER_GET_STATS
},
{
"dataConsumer.close"
,
Request
::
MethodId
::
DATA_CONSUMER_CLOSE
},
{
"dataConsumer.dump"
,
Request
::
MethodId
::
DATA_CONSUMER_DUMP
},
{
"dataConsumer.getStats"
,
Request
::
MethodId
::
DATA_CONSUMER_GET_STATS
},
{
"dataConsumer.getBufferedAmount"
,
Request
::
MethodId
::
DATA_CONSUMER_GET_BUFFERED_AMOUNT
},
{
"dataConsumer.setBufferedAmountLowThreshold"
,
Request
::
MethodId
::
DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD
},
{
"rtpObserver.close"
,
Request
::
MethodId
::
RTP_OBSERVER_CLOSE
},
{
"rtpObserver.pause"
,
Request
::
MethodId
::
RTP_OBSERVER_PAUSE
},
{
"rtpObserver.resume"
,
Request
::
MethodId
::
RTP_OBSERVER_RESUME
},
{
"rtpObserver.addProducer"
,
Request
::
MethodId
::
RTP_OBSERVER_ADD_PRODUCER
},
{
"rtpObserver.removeProducer"
,
Request
::
MethodId
::
RTP_OBSERVER_REMOVE_PRODUCER
}
};
// clang-format on
/* Instance methods. */
Request
::
Request
(
Channel
::
UnixStreamSocket
*
channel
,
json
&
jsonRequest
)
:
channel
(
channel
)
{
MS_TRACE
();
auto
jsonIdIt
=
jsonRequest
.
find
(
"id"
);
if
(
jsonIdIt
==
jsonRequest
.
end
()
||
!
Utils
::
Json
::
IsPositiveInteger
(
*
jsonIdIt
))
MS_THROW_ERROR
(
"missing id"
);
this
->
id
=
jsonIdIt
->
get
<
uint32_t
>
();
auto
jsonMethodIt
=
jsonRequest
.
find
(
"method"
);
if
(
jsonMethodIt
==
jsonRequest
.
end
()
||
!
jsonMethodIt
->
is_string
())
MS_THROW_ERROR
(
"missing method"
);
this
->
method
=
jsonMethodIt
->
get
<
std
::
string
>
();
auto
methodIdIt
=
Request
::
string2MethodId
.
find
(
this
->
method
);
if
(
methodIdIt
==
Request
::
string2MethodId
.
end
())
{
Error
(
"unknown method"
);
MS_THROW_ERROR
(
"unknown method '%s'"
,
this
->
method
.
c_str
());
}
this
->
methodId
=
methodIdIt
->
second
;
auto
jsonInternalIt
=
jsonRequest
.
find
(
"internal"
);
if
(
jsonInternalIt
!=
jsonRequest
.
end
()
&&
jsonInternalIt
->
is_object
())
this
->
internal
=
*
jsonInternalIt
;
else
this
->
internal
=
json
::
object
();
auto
jsonDataIt
=
jsonRequest
.
find
(
"data"
);
if
(
jsonDataIt
!=
jsonRequest
.
end
()
&&
jsonDataIt
->
is_object
())
this
->
data
=
*
jsonDataIt
;
else
this
->
data
=
json
::
object
();
}
Request
::~
Request
()
{
MS_TRACE
();
}
void
Request
::
Accept
()
{
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"request already replied"
);
this
->
replied
=
true
;
json
jsonResponse
=
json
::
object
();
jsonResponse
[
"id"
]
=
this
->
id
;
jsonResponse
[
"accepted"
]
=
true
;
this
->
channel
->
Send
(
jsonResponse
);
}
void
Request
::
Accept
(
json
&
data
)
{
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"request already replied"
);
this
->
replied
=
true
;
json
jsonResponse
=
json
::
object
();
jsonResponse
[
"id"
]
=
this
->
id
;
jsonResponse
[
"accepted"
]
=
true
;
if
(
data
.
is_structured
())
jsonResponse
[
"data"
]
=
data
;
this
->
channel
->
Send
(
jsonResponse
);
}
void
Request
::
Error
(
const
char
*
reason
)
{
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"request already replied"
);
this
->
replied
=
true
;
json
jsonResponse
=
json
::
object
();
jsonResponse
[
"id"
]
=
this
->
id
;
jsonResponse
[
"error"
]
=
"Error"
;
if
(
reason
!=
nullptr
)
jsonResponse
[
"reason"
]
=
reason
;
this
->
channel
->
Send
(
jsonResponse
);
}
void
Request
::
TypeError
(
const
char
*
reason
)
{
MS_TRACE
();
MS_ASSERT
(
!
this
->
replied
,
"request already replied"
);
this
->
replied
=
true
;
json
jsonResponse
=
json
::
object
();
jsonResponse
[
"id"
]
=
this
->
id
;
jsonResponse
[
"error"
]
=
"TypeError"
;
if
(
reason
!=
nullptr
)
jsonResponse
[
"reason"
]
=
reason
;
this
->
channel
->
Send
(
jsonResponse
);
}
}
// namespace Channel
worker/src/Logger.cpp
浏览文件 @
0d7a5016
...
...
@@ -7,12 +7,12 @@
/* Class variables. */
const
int64_t
Logger
::
pid
{
static_cast
<
int64_t
>
(
uv_os_getpid
())
};
thread_local
Channel
::
UnixStream
Socket
*
Logger
::
channel
{
nullptr
};
thread_local
Channel
::
Channel
Socket
*
Logger
::
channel
{
nullptr
};
char
Logger
::
buffer
[
Logger
::
bufferSize
];
/* Class methods. */
void
Logger
::
ClassInit
(
Channel
::
UnixStream
Socket
*
channel
)
void
Logger
::
ClassInit
(
Channel
::
Channel
Socket
*
channel
)
{
Logger
::
channel
=
channel
;
...
...
worker/src/PayloadChannel/Notifier.cpp
→
worker/src/PayloadChannel/
PayloadChannel
Notifier.cpp
浏览文件 @
0d7a5016
#define MS_CLASS "PayloadChannel::Notifier"
// #define MS_LOG_DEV_LEVEL 3
#include "PayloadChannel/Notifier.hpp"
#include "PayloadChannel/
PayloadChannel
Notifier.hpp"
#include "Logger.hpp"
namespace
PayloadChannel
{
/* Class variables. */
thread_local
PayloadChannel
::
UnixStreamSocket
*
Notifier
::
payloadChannel
{
nullptr
};
thread_local
PayloadChannel
::
PayloadChannelSocket
*
PayloadChannel
Notifier
::
payloadChannel
{
nullptr
};
/* Static methods. */
void
Notifier
::
ClassInit
(
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
)
void
PayloadChannelNotifier
::
ClassInit
(
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
)
{
MS_TRACE
();
Notifier
::
payloadChannel
=
payloadChannel
;
PayloadChannel
Notifier
::
payloadChannel
=
payloadChannel
;
}
void
Notifier
::
Emit
(
void
PayloadChannel
Notifier
::
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
,
const
uint8_t
*
payload
,
size_t
payloadLen
)
{
MS_TRACE
();
MS_ASSERT
(
Notifier
::
payloadChannel
,
"payloadChannel unset"
);
MS_ASSERT
(
PayloadChannel
Notifier
::
payloadChannel
,
"payloadChannel unset"
);
json
jsonNotification
=
json
::
object
();
jsonNotification
[
"targetId"
]
=
targetId
;
jsonNotification
[
"event"
]
=
event
;
Notifier
::
payloadChannel
->
Send
(
jsonNotification
,
payload
,
payloadLen
);
PayloadChannel
Notifier
::
payloadChannel
->
Send
(
jsonNotification
,
payload
,
payloadLen
);
}
void
Notifier
::
Emit
(
void
PayloadChannel
Notifier
::
Emit
(
const
std
::
string
&
targetId
,
const
char
*
event
,
json
&
data
,
const
uint8_t
*
payload
,
size_t
payloadLen
)
{
MS_TRACE
();
MS_ASSERT
(
Notifier
::
payloadChannel
,
"payloadChannel unset"
);
MS_ASSERT
(
PayloadChannel
Notifier
::
payloadChannel
,
"payloadChannel unset"
);
json
jsonNotification
=
json
::
object
();
...
...
@@ -47,6 +47,6 @@ namespace PayloadChannel
jsonNotification
[
"event"
]
=
event
;
jsonNotification
[
"data"
]
=
data
;
Notifier
::
payloadChannel
->
Send
(
jsonNotification
,
payload
,
payloadLen
);
PayloadChannel
Notifier
::
payloadChannel
->
Send
(
jsonNotification
,
payload
,
payloadLen
);
}
}
// namespace PayloadChannel
worker/src/PayloadChannel/Request.cpp
→
worker/src/PayloadChannel/
PayloadChannel
Request.cpp
浏览文件 @
0d7a5016
#define MS_CLASS "PayloadChannel::Request"
#define MS_CLASS "PayloadChannel::
PayloadChannel
Request"
// #define MS_LOG_DEV_LEVEL 3
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/
PayloadChannel
Request.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "PayloadChannel/
UnixStream
Socket.hpp"
#include "PayloadChannel/
PayloadChannel
Socket.hpp"
namespace
PayloadChannel
{
/* Class variables. */
// clang-format off
std
::
unordered_map
<
std
::
string
,
Request
::
MethodId
>
Request
::
string2MethodId
=
std
::
unordered_map
<
std
::
string
,
PayloadChannelRequest
::
MethodId
>
PayloadChannel
Request
::
string2MethodId
=
{
{
"dataConsumer.send"
,
Request
::
MethodId
::
DATA_CONSUMER_SEND
},
{
"dataConsumer.send"
,
PayloadChannel
Request
::
MethodId
::
DATA_CONSUMER_SEND
},
};
// clang-format on
/* Class methods. */
bool
Request
::
IsRequest
(
json
&
jsonRequest
)
bool
PayloadChannel
Request
::
IsRequest
(
json
&
jsonRequest
)
{
MS_TRACE
();
...
...
@@ -38,7 +38,9 @@ namespace PayloadChannel
/* Instance methods. */
Request
::
Request
(
PayloadChannel
::
UnixStreamSocket
*
channel
,
json
&
jsonRequest
)
:
channel
(
channel
)
PayloadChannelRequest
::
PayloadChannelRequest
(
PayloadChannel
::
PayloadChannelSocket
*
channel
,
json
&
jsonRequest
)
:
channel
(
channel
)
{
MS_TRACE
();
...
...
@@ -56,9 +58,9 @@ namespace PayloadChannel
this
->
method
=
jsonMethodIt
->
get
<
std
::
string
>
();
auto
methodIdIt
=
Request
::
string2MethodId
.
find
(
this
->
method
);
auto
methodIdIt
=
PayloadChannel
Request
::
string2MethodId
.
find
(
this
->
method
);
if
(
methodIdIt
==
Request
::
string2MethodId
.
end
())
if
(
methodIdIt
==
PayloadChannel
Request
::
string2MethodId
.
end
())
{
Error
(
"unknown method"
);
...
...
@@ -82,12 +84,12 @@ namespace PayloadChannel
this
->
data
=
json
::
object
();
}
Request
::~
Request
()
PayloadChannelRequest
::~
PayloadChannel
Request
()
{
MS_TRACE
();
}
void
Request
::
Accept
()
void
PayloadChannel
Request
::
Accept
()
{
MS_TRACE
();
...
...
@@ -103,7 +105,7 @@ namespace PayloadChannel
this
->
channel
->
Send
(
jsonResponse
);
}
void
Request
::
Accept
(
json
&
data
)
void
PayloadChannel
Request
::
Accept
(
json
&
data
)
{
MS_TRACE
();
...
...
@@ -122,7 +124,7 @@ namespace PayloadChannel
this
->
channel
->
Send
(
jsonResponse
);
}
void
Request
::
Error
(
const
char
*
reason
)
void
PayloadChannel
Request
::
Error
(
const
char
*
reason
)
{
MS_TRACE
();
...
...
@@ -141,7 +143,7 @@ namespace PayloadChannel
this
->
channel
->
Send
(
jsonResponse
);
}
void
Request
::
TypeError
(
const
char
*
reason
)
void
PayloadChannel
Request
::
TypeError
(
const
char
*
reason
)
{
MS_TRACE
();
...
...
@@ -160,7 +162,7 @@ namespace PayloadChannel
this
->
channel
->
Send
(
jsonResponse
);
}
void
Request
::
SetPayload
(
const
uint8_t
*
payload
,
size_t
payloadLen
)
void
PayloadChannel
Request
::
SetPayload
(
const
uint8_t
*
payload
,
size_t
payloadLen
)
{
MS_TRACE
();
...
...
worker/src/PayloadChannel/
UnixStream
Socket.cpp
→
worker/src/PayloadChannel/
PayloadChannel
Socket.cpp
浏览文件 @
0d7a5016
#define MS_CLASS "PayloadChannel::
UnixStream
Socket"
#define MS_CLASS "PayloadChannel::
PayloadChannel
Socket"
// #define MS_LOG_DEV_LEVEL 3
#include "PayloadChannel/
UnixStream
Socket.hpp"
#include "PayloadChannel/
PayloadChannel
Socket.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/
PayloadChannel
Request.hpp"
#include <cmath> // std::ceil()
#include <cstdio> // sprintf()
#include <cstring> // std::memcpy(), std::memmove()
...
...
@@ -22,7 +22,7 @@ namespace PayloadChannel
static
constexpr
size_t
NsPayloadMaxLen
{
4194304
};
/* Instance methods. */
UnixStreamSocket
::
UnixStream
Socket
(
int
consumerFd
,
int
producerFd
)
PayloadChannelSocket
::
PayloadChannel
Socket
(
int
consumerFd
,
int
producerFd
)
:
consumerSocket
(
consumerFd
,
NsMessageMaxLen
,
this
),
producerSocket
(
producerFd
,
NsMessageMaxLen
)
{
MS_TRACE
();
...
...
@@ -30,7 +30,7 @@ namespace PayloadChannel
this
->
WriteBuffer
=
(
uint8_t
*
)
std
::
malloc
(
NsMessageMaxLen
);
}
UnixStreamSocket
::~
UnixStream
Socket
()
PayloadChannelSocket
::~
PayloadChannel
Socket
()
{
MS_TRACE
();
...
...
@@ -38,14 +38,14 @@ namespace PayloadChannel
delete
this
->
ongoingNotification
;
}
void
UnixStream
Socket
::
SetListener
(
Listener
*
listener
)
void
PayloadChannel
Socket
::
SetListener
(
Listener
*
listener
)
{
MS_TRACE
();
this
->
listener
=
listener
;
}
void
UnixStream
Socket
::
Send
(
json
&
jsonMessage
,
const
uint8_t
*
payload
,
size_t
payloadLen
)
void
PayloadChannel
Socket
::
Send
(
json
&
jsonMessage
,
const
uint8_t
*
payload
,
size_t
payloadLen
)
{
MS_TRACE
();
...
...
@@ -71,7 +71,7 @@ namespace PayloadChannel
SendImpl
(
payload
,
payloadLen
);
}
void
UnixStream
Socket
::
Send
(
json
&
jsonMessage
)
void
PayloadChannel
Socket
::
Send
(
json
&
jsonMessage
)
{
MS_TRACE_STD
();
...
...
@@ -90,7 +90,7 @@ namespace PayloadChannel
SendImpl
(
message
.
c_str
(),
message
.
length
());
}
inline
void
UnixStream
Socket
::
SendImpl
(
const
void
*
nsPayload
,
size_t
nsPayloadLen
)
inline
void
PayloadChannel
Socket
::
SendImpl
(
const
void
*
nsPayload
,
size_t
nsPayloadLen
)
{
MS_TRACE
();
...
...
@@ -116,7 +116,7 @@ namespace PayloadChannel
this
->
producerSocket
.
Write
(
this
->
WriteBuffer
,
nsLen
);
}
void
UnixStream
Socket
::
OnConsumerSocketMessage
(
void
PayloadChannel
Socket
::
OnConsumerSocketMessage
(
ConsumerSocket
*
/*consumerSocket*/
,
char
*
msg
,
size_t
msgLen
)
{
MS_TRACE
();
...
...
@@ -124,12 +124,12 @@ namespace PayloadChannel
if
(
!
this
->
ongoingNotification
&&
!
this
->
ongoingRequest
)
{
json
jsonData
=
json
::
parse
(
msg
,
msg
+
msgLen
);
if
(
Request
::
IsRequest
(
jsonData
))
if
(
PayloadChannel
Request
::
IsRequest
(
jsonData
))
{
try
{
json
jsonMessage
=
json
::
parse
(
msg
,
msg
+
msgLen
);
this
->
ongoingRequest
=
new
PayloadChannel
::
Request
(
this
,
jsonMessage
);
this
->
ongoingRequest
=
new
PayloadChannel
::
PayloadChannel
Request
(
this
,
jsonMessage
);
}
catch
(
const
json
::
parse_error
&
error
)
{
...
...
@@ -205,7 +205,7 @@ namespace PayloadChannel
}
}
void
UnixStream
Socket
::
OnConsumerSocketClosed
(
ConsumerSocket
*
/*consumerSocket*/
)
void
PayloadChannel
Socket
::
OnConsumerSocketClosed
(
ConsumerSocket
*
/*consumerSocket*/
)
{
MS_TRACE
();
...
...
worker/src/RTC/AudioLevelObserver.cpp
浏览文件 @
0d7a5016
...
...
@@ -5,7 +5,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include "RTC/RtpDictionaries.hpp"
#include <cmath> // std::lround()
#include <map>
...
...
@@ -131,7 +131,7 @@ namespace RTC
{
this
->
silence
=
true
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"silence"
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"silence"
);
}
}
...
...
@@ -183,13 +183,13 @@ namespace RTC
jsonEntry
[
"volume"
]
=
rit
->
first
;
}
Channel
::
Notifier
::
Emit
(
this
->
id
,
"volumes"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"volumes"
,
data
);
}
else
if
(
!
this
->
silence
)
{
this
->
silence
=
true
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"silence"
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"silence"
);
}
}
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
0d7a5016
...
...
@@ -5,7 +5,7 @@
#include "DepLibUV.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include <iterator> // std::ostream_iterator
#include <sstream> // std::ostringstream
...
...
@@ -230,13 +230,13 @@ namespace RTC
jsonObject
[
"traceEventTypes"
]
=
traceEventTypesStream
.
str
();
}
void
Consumer
::
HandleRequest
(
Channel
::
Request
*
request
)
void
Consumer
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_DUMP
:
{
json
data
=
json
::
object
();
...
...
@@ -247,7 +247,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_GET_STATS
:
{
json
data
=
json
::
array
();
...
...
@@ -258,7 +258,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_PAUSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_PAUSE
:
{
if
(
this
->
paused
)
{
...
...
@@ -281,7 +281,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_RESUME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_RESUME
:
{
if
(
!
this
->
paused
)
{
...
...
@@ -302,7 +302,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_SET_PRIORITY
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_SET_PRIORITY
:
{
auto
jsonPriorityIt
=
request
->
data
.
find
(
"priority"
);
...
...
@@ -325,7 +325,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_ENABLE_TRACE_EVENT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_ENABLE_TRACE_EVENT
:
{
auto
jsonTypesIt
=
request
->
data
.
find
(
"types"
);
...
...
@@ -407,7 +407,7 @@ namespace RTC
if
(
wasActive
)
UserOnPaused
();
Channel
::
Notifier
::
Emit
(
this
->
id
,
"producerpause"
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"producerpause"
);
}
void
Consumer
::
ProducerResumed
()
...
...
@@ -424,7 +424,7 @@ namespace RTC
if
(
IsActive
())
UserOnResumed
();
Channel
::
Notifier
::
Emit
(
this
->
id
,
"producerresume"
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"producerresume"
);
}
void
Consumer
::
ProducerRtpStreamScores
(
const
std
::
vector
<
uint8_t
>*
scores
)
...
...
@@ -445,7 +445,7 @@ namespace RTC
MS_DEBUG_DEV
(
"Producer closed [consumerId:%s]"
,
this
->
id
.
c_str
());
Channel
::
Notifier
::
Emit
(
this
->
id
,
"producerclose"
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"producerclose"
);
this
->
listener
->
OnConsumerProducerClosed
(
this
);
}
...
...
@@ -467,7 +467,7 @@ namespace RTC
if
(
isRtx
)
data
[
"info"
][
"isRtx"
]
=
true
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
else
if
(
this
->
traceEventTypes
.
rtp
)
{
...
...
@@ -482,7 +482,7 @@ namespace RTC
if
(
isRtx
)
data
[
"info"
][
"isRtx"
]
=
true
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
}
...
...
@@ -500,7 +500,7 @@ namespace RTC
data
[
"direction"
]
=
"in"
;
data
[
"info"
][
"ssrc"
]
=
ssrc
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
void
Consumer
::
EmitTraceEventFirType
(
uint32_t
ssrc
)
const
...
...
@@ -517,7 +517,7 @@ namespace RTC
data
[
"direction"
]
=
"in"
;
data
[
"info"
][
"ssrc"
]
=
ssrc
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
void
Consumer
::
EmitTraceEventNackType
()
const
...
...
@@ -534,6 +534,6 @@ namespace RTC
data
[
"direction"
]
=
"in"
;
data
[
"info"
]
=
json
::
object
();
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
}
// namespace RTC
worker/src/RTC/DataConsumer.cpp
浏览文件 @
0d7a5016
...
...
@@ -6,7 +6,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
namespace
RTC
{
...
...
@@ -125,13 +125,13 @@ namespace RTC
jsonObject
[
"bufferedAmount"
]
=
this
->
bufferedAmount
;
}
void
DataConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
void
DataConsumer
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
DATA_CONSUMER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_CONSUMER_DUMP
:
{
json
data
=
json
::
object
();
...
...
@@ -142,7 +142,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_CONSUMER_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_CONSUMER_GET_STATS
:
{
json
data
=
json
::
array
();
...
...
@@ -153,7 +153,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD
:
{
auto
jsonThresholdIt
=
request
->
data
.
find
(
"threshold"
);
...
...
@@ -173,7 +173,7 @@ namespace RTC
data
[
"bufferedAmount"
]
=
this
->
bufferedAmount
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"bufferedamountlow"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"bufferedamountlow"
,
data
);
}
// Force the trigger of 'bufferedamountlow' once there is less or same
// buffered data than the given threshold.
...
...
@@ -192,13 +192,13 @@ namespace RTC
}
}
void
DataConsumer
::
HandleRequest
(
PayloadChannel
::
Request
*
request
)
void
DataConsumer
::
HandleRequest
(
PayloadChannel
::
PayloadChannel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
PayloadChannel
:
:
Request
::
MethodId
::
DATA_CONSUMER_SEND
:
case
PayloadChannel
:
:
PayloadChannel
Request
::
MethodId
::
DATA_CONSUMER_SEND
:
{
auto
jsonPpidIt
=
request
->
data
.
find
(
"ppid"
);
...
...
@@ -299,7 +299,7 @@ namespace RTC
data
[
"bufferedAmount"
]
=
this
->
bufferedAmount
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"bufferedamountlow"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"bufferedamountlow"
,
data
);
}
}
...
...
@@ -313,7 +313,7 @@ namespace RTC
MS_DEBUG_DEV
(
"DataProducer closed [dataConsumerId:%s]"
,
this
->
id
.
c_str
());
Channel
::
Notifier
::
Emit
(
this
->
id
,
"dataproducerclose"
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"dataproducerclose"
);
this
->
listener
->
OnDataConsumerDataProducerClosed
(
this
);
}
...
...
worker/src/RTC/DataProducer.cpp
浏览文件 @
0d7a5016
...
...
@@ -110,13 +110,13 @@ namespace RTC
jsonObject
[
"bytesReceived"
]
=
this
->
bytesReceived
;
}
void
DataProducer
::
HandleRequest
(
Channel
::
Request
*
request
)
const
void
DataProducer
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
const
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
DATA_PRODUCER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_PRODUCER_DUMP
:
{
json
data
=
json
::
object
();
...
...
@@ -127,7 +127,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_PRODUCER_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_PRODUCER_GET_STATS
:
{
json
data
=
json
::
array
();
...
...
worker/src/RTC/DirectTransport.cpp
浏览文件 @
0d7a5016
...
...
@@ -4,7 +4,7 @@
#include "RTC/DirectTransport.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "PayloadChannel/Notifier.hpp"
#include "PayloadChannel/
PayloadChannel
Notifier.hpp"
namespace
RTC
{
...
...
@@ -43,7 +43,7 @@ namespace RTC
jsonObject
[
"type"
]
=
"direct-transport"
;
}
void
DirectTransport
::
HandleRequest
(
Channel
::
Request
*
request
)
void
DirectTransport
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
...
...
@@ -181,7 +181,7 @@ namespace RTC
size_t
len
=
packet
->
GetSize
();
// Notify the Node DirectTransport.
PayloadChannel
::
Notifier
::
Emit
(
consumer
->
id
,
"rtp"
,
data
,
len
);
PayloadChannel
::
PayloadChannel
Notifier
::
Emit
(
consumer
->
id
,
"rtp"
,
data
,
len
);
if
(
cb
)
{
...
...
@@ -201,7 +201,7 @@ namespace RTC
size_t
len
=
packet
->
GetSize
();
// Notify the Node DirectTransport.
PayloadChannel
::
Notifier
::
Emit
(
this
->
id
,
"rtcp"
,
data
,
len
);
PayloadChannel
::
PayloadChannel
Notifier
::
Emit
(
this
->
id
,
"rtcp"
,
data
,
len
);
// Increase send transmission.
RTC
::
Transport
::
DataSent
(
len
);
...
...
@@ -215,7 +215,7 @@ namespace RTC
size_t
len
=
packet
->
GetSize
();
// Notify the Node DirectTransport.
PayloadChannel
::
Notifier
::
Emit
(
this
->
id
,
"rtcp"
,
data
,
len
);
PayloadChannel
::
PayloadChannel
Notifier
::
Emit
(
this
->
id
,
"rtcp"
,
data
,
len
);
// Increase send transmission.
RTC
::
Transport
::
DataSent
(
len
);
...
...
@@ -231,7 +231,7 @@ namespace RTC
data
[
"ppid"
]
=
ppid
;
PayloadChannel
::
Notifier
::
Emit
(
dataConsumer
->
id
,
"message"
,
data
,
msg
,
len
);
PayloadChannel
::
PayloadChannel
Notifier
::
Emit
(
dataConsumer
->
id
,
"message"
,
data
,
msg
,
len
);
// Increase send transmission.
RTC
::
Transport
::
DataSent
(
len
);
...
...
worker/src/RTC/PipeConsumer.cpp
浏览文件 @
0d7a5016
...
...
@@ -91,13 +91,13 @@ namespace RTC
jsonObject
[
"producerScores"
]
=
*
this
->
producerRtpStreamScores
;
}
void
PipeConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
void
PipeConsumer
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
{
if
(
IsActive
())
RequestKeyFrame
();
...
...
@@ -107,7 +107,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
{
// Do nothing.
...
...
worker/src/RTC/PipeTransport.cpp
浏览文件 @
0d7a5016
...
...
@@ -179,13 +179,13 @@ namespace RTC
}
}
void
PipeTransport
::
HandleRequest
(
Channel
::
Request
*
request
)
void
PipeTransport
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_CONNECT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_CONNECT
:
{
// Ensure this method is not called twice.
if
(
this
->
tuple
)
...
...
worker/src/RTC/PlainTransport.cpp
浏览文件 @
0d7a5016
...
...
@@ -5,7 +5,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
namespace
RTC
{
...
...
@@ -267,13 +267,13 @@ namespace RTC
this
->
rtcpTuple
->
FillJson
(
jsonObject
[
"rtcpTuple"
]);
}
void
PlainTransport
::
HandleRequest
(
Channel
::
Request
*
request
)
void
PlainTransport
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_CONNECT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_CONNECT
:
{
// Ensure this method is not called twice.
if
(
this
->
connectCalled
)
...
...
@@ -824,7 +824,7 @@ namespace RTC
this
->
tuple
->
FillJson
(
data
[
"tuple"
]);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"tuple"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"tuple"
,
data
);
RTC
::
Transport
::
Connected
();
}
...
...
@@ -889,7 +889,7 @@ namespace RTC
this
->
tuple
->
FillJson
(
data
[
"tuple"
]);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"tuple"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"tuple"
,
data
);
RTC
::
Transport
::
Connected
();
}
...
...
@@ -917,7 +917,7 @@ namespace RTC
this
->
rtcpTuple
->
FillJson
(
data
[
"rtcpTuple"
]);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"rtcptuple"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"rtcptuple"
,
data
);
}
// If RTCP-mux verify that the packet's tuple matches our RTP tuple.
else
if
(
this
->
rtcpMux
&&
!
this
->
tuple
->
Compare
(
tuple
))
...
...
@@ -979,7 +979,7 @@ namespace RTC
this
->
tuple
->
FillJson
(
data
[
"tuple"
]);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"tuple"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"tuple"
,
data
);
RTC
::
Transport
::
Connected
();
}
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
0d7a5016
...
...
@@ -6,7 +6,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include "RTC/Codecs/Tools.hpp"
#include "RTC/RTCP/FeedbackPs.hpp"
#include "RTC/RTCP/FeedbackRtp.hpp"
...
...
@@ -454,13 +454,13 @@ namespace RTC
}
}
void
Producer
::
HandleRequest
(
Channel
::
Request
*
request
)
void
Producer
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_DUMP
:
{
json
data
=
json
::
object
();
...
...
@@ -471,7 +471,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_GET_STATS
:
{
json
data
=
json
::
array
();
...
...
@@ -482,7 +482,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_PAUSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_PAUSE
:
{
if
(
this
->
paused
)
{
...
...
@@ -510,7 +510,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_RESUME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_RESUME
:
{
if
(
!
this
->
paused
)
{
...
...
@@ -551,7 +551,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_ENABLE_TRACE_EVENT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_ENABLE_TRACE_EVENT
:
{
auto
jsonTypesIt
=
request
->
data
.
find
(
"types"
);
...
...
@@ -1398,7 +1398,7 @@ namespace RTC
data
[
"flip"
]
=
this
->
videoOrientation
.
flip
;
data
[
"rotation"
]
=
this
->
videoOrientation
.
rotation
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"videoorientationchange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"videoorientationchange"
,
data
);
}
}
}
...
...
@@ -1428,7 +1428,7 @@ namespace RTC
jsonEntry
[
"score"
]
=
rtpStream
->
GetScore
();
}
Channel
::
Notifier
::
Emit
(
this
->
id
,
"score"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"score"
,
data
);
}
inline
void
Producer
::
EmitTraceEventRtpAndKeyFrameTypes
(
RTC
::
RtpPacket
*
packet
,
bool
isRtx
)
const
...
...
@@ -1448,7 +1448,7 @@ namespace RTC
if
(
isRtx
)
data
[
"info"
][
"isRtx"
]
=
true
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
else
if
(
this
->
traceEventTypes
.
rtp
)
{
...
...
@@ -1463,7 +1463,7 @@ namespace RTC
if
(
isRtx
)
data
[
"info"
][
"isRtx"
]
=
true
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
}
...
...
@@ -1481,7 +1481,7 @@ namespace RTC
data
[
"direction"
]
=
"out"
;
data
[
"info"
][
"ssrc"
]
=
ssrc
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
inline
void
Producer
::
EmitTraceEventFirType
(
uint32_t
ssrc
)
const
...
...
@@ -1498,7 +1498,7 @@ namespace RTC
data
[
"direction"
]
=
"out"
;
data
[
"info"
][
"ssrc"
]
=
ssrc
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
inline
void
Producer
::
EmitTraceEventNackType
()
const
...
...
@@ -1515,7 +1515,7 @@ namespace RTC
data
[
"direction"
]
=
"out"
;
data
[
"info"
]
=
json
::
object
();
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
inline
void
Producer
::
OnRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
...
...
worker/src/RTC/Router.cpp
浏览文件 @
0d7a5016
...
...
@@ -160,13 +160,13 @@ namespace RTC
}
}
void
Router
::
HandleRequest
(
Channel
::
Request
*
request
)
void
Router
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
ROUTER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
ROUTER_DUMP
:
{
json
data
=
json
::
object
();
...
...
@@ -177,7 +177,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
ROUTER_CREATE_WEBRTC_TRANSPORT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
ROUTER_CREATE_WEBRTC_TRANSPORT
:
{
std
::
string
transportId
;
...
...
@@ -201,7 +201,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
ROUTER_CREATE_PLAIN_TRANSPORT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
ROUTER_CREATE_PLAIN_TRANSPORT
:
{
std
::
string
transportId
;
...
...
@@ -224,7 +224,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
ROUTER_CREATE_PIPE_TRANSPORT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
ROUTER_CREATE_PIPE_TRANSPORT
:
{
std
::
string
transportId
;
...
...
@@ -247,7 +247,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
ROUTER_CREATE_DIRECT_TRANSPORT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
ROUTER_CREATE_DIRECT_TRANSPORT
:
{
std
::
string
transportId
;
...
...
@@ -270,7 +270,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
ROUTER_CREATE_AUDIO_LEVEL_OBSERVER
:
case
Channel
:
:
Channel
Request
::
MethodId
::
ROUTER_CREATE_AUDIO_LEVEL_OBSERVER
:
{
std
::
string
rtpObserverId
;
...
...
@@ -289,7 +289,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_CLOSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_CLOSE
:
{
// This may throw.
RTC
::
Transport
*
transport
=
GetTransportFromInternal
(
request
->
internal
);
...
...
@@ -311,7 +311,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
RTP_OBSERVER_CLOSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
RTP_OBSERVER_CLOSE
:
{
// This may throw.
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
...
...
@@ -337,7 +337,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
RTP_OBSERVER_PAUSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
RTP_OBSERVER_PAUSE
:
{
// This may throw.
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
...
...
@@ -349,7 +349,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
RTP_OBSERVER_RESUME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
RTP_OBSERVER_RESUME
:
{
// This may throw.
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
...
...
@@ -361,7 +361,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
RTP_OBSERVER_ADD_PRODUCER
:
case
Channel
:
:
Channel
Request
::
MethodId
::
RTP_OBSERVER_ADD_PRODUCER
:
{
// This may throw.
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
...
...
@@ -377,7 +377,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
RTP_OBSERVER_REMOVE_PRODUCER
:
case
Channel
:
:
Channel
Request
::
MethodId
::
RTP_OBSERVER_REMOVE_PRODUCER
:
{
// This may throw.
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
...
...
@@ -406,7 +406,7 @@ namespace RTC
}
}
void
Router
::
HandleRequest
(
PayloadChannel
::
Request
*
request
)
void
Router
::
HandleRequest
(
PayloadChannel
::
PayloadChannel
Request
*
request
)
{
MS_TRACE
();
...
...
worker/src/RTC/SctpAssociation.cpp
浏览文件 @
0d7a5016
...
...
@@ -5,7 +5,7 @@
#include "DepUsrSCTP.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include <cstdlib> // std::malloc(), std::free()
#include <cstring> // std::memset(), std::memcpy()
#include <string>
...
...
@@ -470,7 +470,7 @@ namespace RTC
if
(
sctpSendBufferFull
)
{
Channel
::
Notifier
::
Emit
(
dataConsumer
->
id
,
"sctpsendbufferfull"
);
Channel
::
Channel
Notifier
::
Emit
(
dataConsumer
->
id
,
"sctpsendbufferfull"
);
}
}
else
if
(
cb
)
...
...
worker/src/RTC/SimpleConsumer.cpp
浏览文件 @
0d7a5016
...
...
@@ -5,7 +5,7 @@
#include "DepLibUV.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include "RTC/Codecs/Tools.hpp"
namespace
RTC
...
...
@@ -81,13 +81,13 @@ namespace RTC
jsonObject
[
"producerScores"
]
=
*
this
->
producerRtpStreamScores
;
}
void
SimpleConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
void
SimpleConsumer
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
{
if
(
IsActive
())
RequestKeyFrame
();
...
...
@@ -97,7 +97,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
{
// Do nothing.
...
...
@@ -561,7 +561,7 @@ namespace RTC
FillJsonScore
(
data
);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"score"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"score"
,
data
);
}
inline
void
SimpleConsumer
::
OnRtpStreamScore
(
...
...
worker/src/RTC/SimulcastConsumer.cpp
浏览文件 @
0d7a5016
...
...
@@ -6,7 +6,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include "RTC/Codecs/Tools.hpp"
namespace
RTC
...
...
@@ -193,13 +193,13 @@ namespace RTC
jsonObject
[
"producerScores"
]
=
*
this
->
producerRtpStreamScores
;
}
void
SimulcastConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
void
SimulcastConsumer
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
{
if
(
IsActive
())
RequestKeyFrames
();
...
...
@@ -209,7 +209,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
{
auto
previousPreferredSpatialLayer
=
this
->
preferredSpatialLayer
;
auto
previousPreferredTemporalLayer
=
this
->
preferredTemporalLayer
;
...
...
@@ -1413,7 +1413,7 @@ namespace RTC
FillJsonScore
(
data
);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"score"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"score"
,
data
);
}
inline
void
SimulcastConsumer
::
EmitLayersChange
()
const
...
...
@@ -1438,7 +1438,7 @@ namespace RTC
data
=
nullptr
;
}
Channel
::
Notifier
::
Emit
(
this
->
id
,
"layerschange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"layerschange"
,
data
);
}
inline
RTC
::
RtpStream
*
SimulcastConsumer
::
GetProducerCurrentRtpStream
()
const
...
...
worker/src/RTC/SvcConsumer.cpp
浏览文件 @
0d7a5016
...
...
@@ -6,7 +6,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include "RTC/Codecs/Tools.hpp"
namespace
RTC
...
...
@@ -172,13 +172,13 @@ namespace RTC
jsonObject
[
"producerScores"
]
=
*
this
->
producerRtpStreamScores
;
}
void
SvcConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
void
SvcConsumer
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
{
if
(
IsActive
())
RequestKeyFrame
();
...
...
@@ -188,7 +188,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
{
auto
previousPreferredSpatialLayer
=
this
->
preferredSpatialLayer
;
auto
previousPreferredTemporalLayer
=
this
->
preferredTemporalLayer
;
...
...
@@ -1044,7 +1044,7 @@ namespace RTC
FillJsonScore
(
data
);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"score"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"score"
,
data
);
}
inline
void
SvcConsumer
::
EmitLayersChange
()
const
...
...
@@ -1069,7 +1069,7 @@ namespace RTC
data
=
nullptr
;
}
Channel
::
Notifier
::
Emit
(
this
->
id
,
"layerschange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"layerschange"
,
data
);
}
inline
void
SvcConsumer
::
OnRtpStreamScore
(
...
...
worker/src/RTC/TcpConnection.cpp
浏览文件 @
0d7a5016
...
...
@@ -16,7 +16,7 @@ namespace RTC
/* Instance methods. */
TcpConnection
::
TcpConnection
(
Listener
*
listener
,
size_t
bufferSize
)
:
::
TcpConnection
::
TcpConnection
(
bufferSize
),
listener
(
listener
)
:
::
TcpConnection
Handler
::
TcpConnectionHandler
(
bufferSize
),
listener
(
listener
)
{
MS_TRACE
();
}
...
...
@@ -154,7 +154,7 @@ namespace RTC
}
}
void
TcpConnection
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
::
TcpConnection
::
onSendCallback
*
cb
)
void
TcpConnection
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
::
TcpConnection
Handler
::
onSendCallback
*
cb
)
{
MS_TRACE
();
...
...
@@ -163,6 +163,6 @@ namespace RTC
uint8_t
frameLen
[
2
];
Utils
::
Byte
::
Set2Bytes
(
frameLen
,
0
,
len
);
::
TcpConnection
::
Write
(
frameLen
,
2
,
data
,
len
,
cb
);
::
TcpConnection
Handler
::
Write
(
frameLen
,
2
,
data
,
len
,
cb
);
}
}
// namespace RTC
worker/src/RTC/TcpServer.cpp
浏览文件 @
0d7a5016
...
...
@@ -16,7 +16,7 @@ namespace RTC
TcpServer
::
TcpServer
(
Listener
*
listener
,
RTC
::
TcpConnection
::
Listener
*
connListener
,
std
::
string
&
ip
)
:
// This may throw.
::
TcpServer
::
TcpServ
er
(
RTC
::
PortManager
::
BindTcp
(
ip
),
256
),
listener
(
listener
),
::
TcpServer
Handler
::
TcpServerHandl
er
(
RTC
::
PortManager
::
BindTcp
(
ip
),
256
),
listener
(
listener
),
connListener
(
connListener
)
{
MS_TRACE
();
...
...
@@ -48,7 +48,7 @@ namespace RTC
AcceptTcpConnection
(
connection
);
}
void
TcpServer
::
UserOnTcpConnectionClosed
(
::
TcpConnection
*
connection
)
void
TcpServer
::
UserOnTcpConnectionClosed
(
::
TcpConnection
Handler
*
connection
)
{
MS_TRACE
();
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
0d7a5016
...
...
@@ -5,8 +5,8 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "PayloadChannel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include "PayloadChannel/
PayloadChannel
Notifier.hpp"
#include "RTC/BweType.hpp"
#include "RTC/PipeConsumer.hpp"
#include "RTC/RTCP/FeedbackPs.hpp"
...
...
@@ -554,13 +554,13 @@ namespace RTC
jsonObject
[
"maxIncomingBitrate"
]
=
this
->
maxIncomingBitrate
;
}
void
Transport
::
HandleRequest
(
Channel
::
Request
*
request
)
void
Transport
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_DUMP
:
{
json
data
=
json
::
object
();
...
...
@@ -571,7 +571,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_GET_STATS
:
{
json
data
=
json
::
array
();
...
...
@@ -582,7 +582,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_SET_MAX_INCOMING_BITRATE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_SET_MAX_INCOMING_BITRATE
:
{
auto
jsonBitrateIt
=
request
->
data
.
find
(
"bitrate"
);
...
...
@@ -608,7 +608,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_PRODUCE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_PRODUCE
:
{
std
::
string
producerId
;
...
...
@@ -765,7 +765,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_CONSUME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_CONSUME
:
{
auto
jsonProducerIdIt
=
request
->
internal
.
find
(
"producerId"
);
...
...
@@ -1017,7 +1017,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_PRODUCE_DATA
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_PRODUCE_DATA
:
{
// Early check. The Transport must support SCTP or be direct.
if
(
!
this
->
sctpAssociation
&&
!
this
->
direct
)
...
...
@@ -1113,7 +1113,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_CONSUME_DATA
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_CONSUME_DATA
:
{
// Early check. The Transport must support SCTP or be direct.
if
(
!
this
->
sctpAssociation
&&
!
this
->
direct
)
...
...
@@ -1214,7 +1214,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_ENABLE_TRACE_EVENT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_ENABLE_TRACE_EVENT
:
{
auto
jsonTypesIt
=
request
->
data
.
find
(
"types"
);
...
...
@@ -1245,7 +1245,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_CLOSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_CLOSE
:
{
// This may throw.
RTC
::
Producer
*
producer
=
GetProducerFromInternal
(
request
->
internal
);
...
...
@@ -1280,7 +1280,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_CLOSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_CLOSE
:
{
// This may throw.
RTC
::
Consumer
*
consumer
=
GetConsumerFromInternal
(
request
->
internal
);
...
...
@@ -1321,11 +1321,11 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_DUMP
:
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_GET_STATS
:
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_PAUSE
:
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_RESUME
:
case
Channel
:
:
Request
::
MethodId
::
PRODUCER_ENABLE_TRACE_EVENT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_PAUSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_RESUME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
PRODUCER_ENABLE_TRACE_EVENT
:
{
// This may throw.
RTC
::
Producer
*
producer
=
GetProducerFromInternal
(
request
->
internal
);
...
...
@@ -1335,14 +1335,14 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_DUMP
:
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_GET_STATS
:
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_PAUSE
:
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_RESUME
:
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_SET_PRIORITY
:
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
case
Channel
:
:
Request
::
MethodId
::
CONSUMER_ENABLE_TRACE_EVENT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_PAUSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_RESUME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_SET_PREFERRED_LAYERS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_SET_PRIORITY
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_REQUEST_KEY_FRAME
:
case
Channel
:
:
Channel
Request
::
MethodId
::
CONSUMER_ENABLE_TRACE_EVENT
:
{
// This may throw.
RTC
::
Consumer
*
consumer
=
GetConsumerFromInternal
(
request
->
internal
);
...
...
@@ -1352,7 +1352,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_PRODUCER_CLOSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_PRODUCER_CLOSE
:
{
// This may throw.
RTC
::
DataProducer
*
dataProducer
=
GetDataProducerFromInternal
(
request
->
internal
);
...
...
@@ -1385,7 +1385,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_CONSUMER_CLOSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_CONSUMER_CLOSE
:
{
// This may throw.
RTC
::
DataConsumer
*
dataConsumer
=
GetDataConsumerFromInternal
(
request
->
internal
);
...
...
@@ -1412,8 +1412,8 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_PRODUCER_DUMP
:
case
Channel
:
:
Request
::
MethodId
::
DATA_PRODUCER_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_PRODUCER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_PRODUCER_GET_STATS
:
{
// This may throw.
RTC
::
DataProducer
*
dataProducer
=
GetDataProducerFromInternal
(
request
->
internal
);
...
...
@@ -1423,8 +1423,8 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_CONSUMER_DUMP
:
case
Channel
:
:
Request
::
MethodId
::
DATA_CONSUMER_GET_STATS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_CONSUMER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_CONSUMER_GET_STATS
:
{
// This may throw.
RTC
::
DataConsumer
*
dataConsumer
=
GetDataConsumerFromInternal
(
request
->
internal
);
...
...
@@ -1434,7 +1434,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_CONSUMER_GET_BUFFERED_AMOUNT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_CONSUMER_GET_BUFFERED_AMOUNT
:
{
// This may throw.
RTC
::
DataConsumer
*
dataConsumer
=
GetDataConsumerFromInternal
(
request
->
internal
);
...
...
@@ -1459,7 +1459,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD
:
case
Channel
:
:
Channel
Request
::
MethodId
::
DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD
:
{
// This may throw.
RTC
::
DataConsumer
*
dataConsumer
=
GetDataConsumerFromInternal
(
request
->
internal
);
...
...
@@ -1481,13 +1481,13 @@ namespace RTC
}
}
void
Transport
::
HandleRequest
(
PayloadChannel
::
Request
*
request
)
void
Transport
::
HandleRequest
(
PayloadChannel
::
PayloadChannel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
PayloadChannel
:
:
Request
::
MethodId
::
DATA_CONSUMER_SEND
:
case
PayloadChannel
:
:
PayloadChannel
Request
::
MethodId
::
DATA_CONSUMER_SEND
:
{
// This may throw.
RTC
::
DataConsumer
*
dataConsumer
=
GetDataConsumerFromInternal
(
request
->
internal
);
...
...
@@ -2411,7 +2411,7 @@ namespace RTC
packet
->
FillJson
(
data
[
"info"
]);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
inline
void
Transport
::
EmitTraceEventBweType
(
...
...
@@ -2445,7 +2445,7 @@ namespace RTC
break
;
}
Channel
::
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"trace"
,
data
);
}
inline
void
Transport
::
OnProducerPaused
(
RTC
::
Producer
*
producer
)
...
...
@@ -2760,7 +2760,7 @@ namespace RTC
data
[
"sctpState"
]
=
"connecting"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"sctpstatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"sctpstatechange"
,
data
);
}
inline
void
Transport
::
OnSctpAssociationConnected
(
RTC
::
SctpAssociation
*
/*sctpAssociation*/
)
...
...
@@ -2783,7 +2783,7 @@ namespace RTC
data
[
"sctpState"
]
=
"connected"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"sctpstatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"sctpstatechange"
,
data
);
}
inline
void
Transport
::
OnSctpAssociationFailed
(
RTC
::
SctpAssociation
*
/*sctpAssociation*/
)
...
...
@@ -2806,7 +2806,7 @@ namespace RTC
data
[
"sctpState"
]
=
"failed"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"sctpstatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"sctpstatechange"
,
data
);
}
inline
void
Transport
::
OnSctpAssociationClosed
(
RTC
::
SctpAssociation
*
/*sctpAssociation*/
)
...
...
@@ -2829,7 +2829,7 @@ namespace RTC
data
[
"sctpState"
]
=
"closed"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"sctpstatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"sctpstatechange"
,
data
);
}
inline
void
Transport
::
OnSctpAssociationSendData
(
...
...
worker/src/RTC/UdpSocket.cpp
浏览文件 @
0d7a5016
...
...
@@ -12,7 +12,7 @@ namespace RTC
UdpSocket
::
UdpSocket
(
Listener
*
listener
,
std
::
string
&
ip
)
:
// This may throw.
::
UdpSocket
::
UdpSocket
(
PortManager
::
BindUdp
(
ip
)),
listener
(
listener
)
::
UdpSocket
Handler
::
UdpSocketHandler
(
PortManager
::
BindUdp
(
ip
)),
listener
(
listener
)
{
MS_TRACE
();
}
...
...
worker/src/RTC/WebRtcTransport.cpp
浏览文件 @
0d7a5016
...
...
@@ -5,7 +5,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include <cmath> // std::pow()
namespace
RTC
...
...
@@ -425,13 +425,13 @@ namespace RTC
}
}
void
WebRtcTransport
::
HandleRequest
(
Channel
::
Request
*
request
)
void
WebRtcTransport
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_CONNECT
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_CONNECT
:
{
// Ensure this method is not called twice.
if
(
this
->
connectCalled
)
...
...
@@ -561,7 +561,7 @@ namespace RTC
break
;
}
case
Channel
:
:
Request
::
MethodId
::
TRANSPORT_RESTART_ICE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
TRANSPORT_RESTART_ICE
:
{
std
::
string
usernameFragment
=
Utils
::
Crypto
::
GetRandomString
(
16
);
std
::
string
password
=
Utils
::
Crypto
::
GetRandomString
(
32
);
...
...
@@ -1111,7 +1111,7 @@ namespace RTC
this
->
iceServer
->
GetSelectedTuple
()
->
FillJson
(
data
[
"iceSelectedTuple"
]);
Channel
::
Notifier
::
Emit
(
this
->
id
,
"iceselectedtuplechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"iceselectedtuplechange"
,
data
);
}
inline
void
WebRtcTransport
::
OnIceServerConnected
(
const
RTC
::
IceServer
*
/*iceServer*/
)
...
...
@@ -1125,7 +1125,7 @@ namespace RTC
data
[
"iceState"
]
=
"connected"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"icestatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"icestatechange"
,
data
);
// If ready, run the DTLS handler.
MayRunDtlsTransport
();
...
...
@@ -1148,7 +1148,7 @@ namespace RTC
data
[
"iceState"
]
=
"completed"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"icestatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"icestatechange"
,
data
);
// If ready, run the DTLS handler.
MayRunDtlsTransport
();
...
...
@@ -1171,7 +1171,7 @@ namespace RTC
data
[
"iceState"
]
=
"disconnected"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"icestatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"icestatechange"
,
data
);
// If DTLS was already connected, notify the parent class.
if
(
this
->
dtlsTransport
->
GetState
()
==
RTC
::
DtlsTransport
::
DtlsState
::
CONNECTED
)
...
...
@@ -1191,7 +1191,7 @@ namespace RTC
data
[
"dtlsState"
]
=
"connecting"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"dtlsstatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"dtlsstatechange"
,
data
);
}
inline
void
WebRtcTransport
::
OnDtlsTransportConnected
(
...
...
@@ -1235,7 +1235,7 @@ namespace RTC
data
[
"dtlsState"
]
=
"connected"
;
data
[
"dtlsRemoteCert"
]
=
remoteCert
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"dtlsstatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"dtlsstatechange"
,
data
);
// Tell the parent class.
RTC
::
Transport
::
Connected
();
...
...
@@ -1260,7 +1260,7 @@ namespace RTC
data
[
"dtlsState"
]
=
"failed"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"dtlsstatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"dtlsstatechange"
,
data
);
}
inline
void
WebRtcTransport
::
OnDtlsTransportClosed
(
const
RTC
::
DtlsTransport
*
/*dtlsTransport*/
)
...
...
@@ -1274,7 +1274,7 @@ namespace RTC
data
[
"dtlsState"
]
=
"closed"
;
Channel
::
Notifier
::
Emit
(
this
->
id
,
"dtlsstatechange"
,
data
);
Channel
::
Channel
Notifier
::
Emit
(
this
->
id
,
"dtlsstatechange"
,
data
);
// Tell the parent class.
RTC
::
Transport
::
Disconnected
();
...
...
worker/src/Settings.cpp
浏览文件 @
0d7a5016
...
...
@@ -237,13 +237,13 @@ void Settings::PrintConfiguration()
MS_DEBUG_TAG
(
info
,
"</configuration>"
);
}
void
Settings
::
HandleRequest
(
Channel
::
Request
*
request
)
void
Settings
::
HandleRequest
(
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
WORKER_UPDATE_SETTINGS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
WORKER_UPDATE_SETTINGS
:
{
auto
jsonLogLevelIt
=
request
->
data
.
find
(
"logLevel"
);
auto
jsonLogTagsIt
=
request
->
data
.
find
(
"logTags"
);
...
...
worker/src/Worker.cpp
浏览文件 @
0d7a5016
...
...
@@ -6,11 +6,11 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Settings.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
Channel
Notifier.hpp"
/* Instance methods. */
Worker
::
Worker
(
::
Channel
::
UnixStreamSocket
*
channel
,
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
)
Worker
::
Worker
(
::
Channel
::
ChannelSocket
*
channel
,
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
)
:
channel
(
channel
),
payloadChannel
(
payloadChannel
)
{
MS_TRACE
();
...
...
@@ -33,7 +33,7 @@ Worker::Worker(::Channel::UnixStreamSocket* channel, PayloadChannel::UnixStreamS
#endif
// Tell the Node process that we are running.
Channel
::
Notifier
::
Emit
(
std
::
to_string
(
Logger
::
pid
),
"running"
);
Channel
::
Channel
Notifier
::
Emit
(
std
::
to_string
(
Logger
::
pid
),
"running"
);
MS_DEBUG_DEV
(
"starting libuv loop"
);
DepLibUV
::
RunLoop
();
...
...
@@ -192,7 +192,7 @@ RTC::Router* Worker::GetRouterFromInternal(json& internal) const
return
router
;
}
inline
void
Worker
::
OnChannelRequest
(
Channel
::
UnixStreamSocket
*
/*channel*/
,
Channel
::
Request
*
request
)
inline
void
Worker
::
OnChannelRequest
(
Channel
::
ChannelSocket
*
/*channel*/
,
Channel
::
Channel
Request
*
request
)
{
MS_TRACE
();
...
...
@@ -201,7 +201,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
switch
(
request
->
methodId
)
{
case
Channel
:
:
Request
::
MethodId
::
WORKER_CLOSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
WORKER_CLOSE
:
{
if
(
this
->
closed
)
return
;
...
...
@@ -213,7 +213,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
break
;
}
case
Channel
:
:
Request
::
MethodId
::
WORKER_DUMP
:
case
Channel
:
:
Channel
Request
::
MethodId
::
WORKER_DUMP
:
{
json
data
=
json
::
object
();
...
...
@@ -224,7 +224,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
break
;
}
case
Channel
:
:
Request
::
MethodId
::
WORKER_GET_RESOURCE_USAGE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
WORKER_GET_RESOURCE_USAGE
:
{
json
data
=
json
::
object
();
...
...
@@ -235,14 +235,14 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
break
;
}
case
Channel
:
:
Request
::
MethodId
::
WORKER_UPDATE_SETTINGS
:
case
Channel
:
:
Channel
Request
::
MethodId
::
WORKER_UPDATE_SETTINGS
:
{
Settings
::
HandleRequest
(
request
);
break
;
}
case
Channel
:
:
Request
::
MethodId
::
WORKER_CREATE_ROUTER
:
case
Channel
:
:
Channel
Request
::
MethodId
::
WORKER_CREATE_ROUTER
:
{
std
::
string
routerId
;
...
...
@@ -260,7 +260,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
break
;
}
case
Channel
:
:
Request
::
MethodId
::
ROUTER_CLOSE
:
case
Channel
:
:
Channel
Request
::
MethodId
::
ROUTER_CLOSE
:
{
// This may throw.
RTC
::
Router
*
router
=
GetRouterFromInternal
(
request
->
internal
);
...
...
@@ -289,7 +289,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
}
}
inline
void
Worker
::
OnChannelClosed
(
Channel
::
UnixStream
Socket
*
/*socket*/
)
inline
void
Worker
::
OnChannelClosed
(
Channel
::
Channel
Socket
*
/*socket*/
)
{
MS_TRACE_STD
();
...
...
@@ -304,7 +304,7 @@ inline void Worker::OnChannelClosed(Channel::UnixStreamSocket* /*socket*/)
}
inline
void
Worker
::
OnPayloadChannelNotification
(
PayloadChannel
::
UnixStream
Socket
*
/*payloadChannel*/
,
PayloadChannel
::
Notification
*
notification
)
PayloadChannel
::
PayloadChannel
Socket
*
/*payloadChannel*/
,
PayloadChannel
::
Notification
*
notification
)
{
MS_TRACE
();
...
...
@@ -317,7 +317,8 @@ inline void Worker::OnPayloadChannelNotification(
}
inline
void
Worker
::
OnPayloadChannelRequest
(
PayloadChannel
::
UnixStreamSocket
*
/*payloadChannel*/
,
PayloadChannel
::
Request
*
request
)
PayloadChannel
::
PayloadChannelSocket
*
/*payloadChannel*/
,
PayloadChannel
::
PayloadChannelRequest
*
request
)
{
MS_TRACE
();
...
...
@@ -332,7 +333,7 @@ inline void Worker::OnPayloadChannelRequest(
router
->
HandleRequest
(
request
);
}
inline
void
Worker
::
OnPayloadChannelClosed
(
PayloadChannel
::
UnixStream
Socket
*
/*payloadChannel*/
)
inline
void
Worker
::
OnPayloadChannelClosed
(
PayloadChannel
::
PayloadChannel
Socket
*
/*payloadChannel*/
)
{
MS_TRACE
();
...
...
worker/src/handles/TcpConnection.cpp
→
worker/src/handles/TcpConnection
Handler
.cpp
浏览文件 @
0d7a5016
#define MS_CLASS "TcpConnection"
#define MS_CLASS "TcpConnection
Handler
"
// #define MS_LOG_DEV_LEVEL 3
#include "handles/TcpConnection.hpp"
#include "handles/TcpConnection
Handler
.hpp"
#include "DepLibUV.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
...
...
@@ -12,7 +12,7 @@
inline
static
void
onAlloc
(
uv_handle_t
*
handle
,
size_t
suggestedSize
,
uv_buf_t
*
buf
)
{
auto
*
connection
=
static_cast
<
TcpConnection
*>
(
handle
->
data
);
auto
*
connection
=
static_cast
<
TcpConnection
Handler
*>
(
handle
->
data
);
if
(
connection
)
connection
->
OnUvReadAlloc
(
suggestedSize
,
buf
);
...
...
@@ -20,7 +20,7 @@ inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t*
inline
static
void
onRead
(
uv_stream_t
*
handle
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
auto
*
connection
=
static_cast
<
TcpConnection
*>
(
handle
->
data
);
auto
*
connection
=
static_cast
<
TcpConnection
Handler
*>
(
handle
->
data
);
if
(
connection
)
connection
->
OnUvRead
(
nread
,
buf
);
...
...
@@ -28,9 +28,9 @@ inline static void onRead(uv_stream_t* handle, ssize_t nread, const uv_buf_t* bu
inline
static
void
onWrite
(
uv_write_t
*
req
,
int
status
)
{
auto
*
writeData
=
static_cast
<
TcpConnection
::
UvWriteData
*>
(
req
->
data
);
auto
*
writeData
=
static_cast
<
TcpConnection
Handler
::
UvWriteData
*>
(
req
->
data
);
auto
*
handle
=
req
->
handle
;
auto
*
connection
=
static_cast
<
TcpConnection
*>
(
handle
->
data
);
auto
*
connection
=
static_cast
<
TcpConnection
Handler
*>
(
handle
->
data
);
auto
*
cb
=
writeData
->
cb
;
if
(
connection
)
...
...
@@ -58,7 +58,7 @@ inline static void onShutdown(uv_shutdown_t* req, int /*status*/)
/* Instance methods. */
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
TcpConnection
::
TcpConnection
(
size_t
bufferSize
)
:
bufferSize
(
bufferSize
)
TcpConnection
Handler
::
TcpConnectionHandler
(
size_t
bufferSize
)
:
bufferSize
(
bufferSize
)
{
MS_TRACE
();
...
...
@@ -68,7 +68,7 @@ TcpConnection::TcpConnection(size_t bufferSize) : bufferSize(bufferSize)
// NOTE: Don't allocate the buffer here. Instead wait for the first uv_alloc_cb().
}
TcpConnection
::~
TcpConnection
()
TcpConnection
Handler
::~
TcpConnectionHandler
()
{
MS_TRACE
();
...
...
@@ -78,7 +78,7 @@ TcpConnection::~TcpConnection()
delete
[]
this
->
buffer
;
}
void
TcpConnection
::
Close
()
void
TcpConnection
Handler
::
Close
()
{
MS_TRACE
();
...
...
@@ -89,7 +89,7 @@ void TcpConnection::Close()
this
->
closed
=
true
;
// Tell the UV handle that the TcpConnection has been closed.
// Tell the UV handle that the TcpConnection
Handler
has been closed.
this
->
uvHandle
->
data
=
nullptr
;
// Don't read more.
...
...
@@ -118,18 +118,18 @@ void TcpConnection::Close()
}
}
void
TcpConnection
::
Dump
()
const
void
TcpConnection
Handler
::
Dump
()
const
{
MS_DUMP
(
"<TcpConnection>"
);
MS_DUMP
(
"<TcpConnection
Handler
>"
);
MS_DUMP
(
" localIp : %s"
,
this
->
localIp
.
c_str
());
MS_DUMP
(
" localPort : %"
PRIu16
,
static_cast
<
uint16_t
>
(
this
->
localPort
));
MS_DUMP
(
" remoteIp : %s"
,
this
->
peerIp
.
c_str
());
MS_DUMP
(
" remotePort : %"
PRIu16
,
static_cast
<
uint16_t
>
(
this
->
peerPort
));
MS_DUMP
(
" closed : %s"
,
!
this
->
closed
?
"open"
:
"closed"
);
MS_DUMP
(
"</TcpConnection>"
);
MS_DUMP
(
"</TcpConnection
Handler
>"
);
}
void
TcpConnection
::
Setup
(
void
TcpConnection
Handler
::
Setup
(
Listener
*
listener
,
struct
sockaddr_storage
*
localAddr
,
const
std
::
string
&
localIp
,
uint16_t
localPort
)
{
MS_TRACE
();
...
...
@@ -154,7 +154,7 @@ void TcpConnection::Setup(
this
->
localPort
=
localPort
;
}
void
TcpConnection
::
Start
()
void
TcpConnection
Handler
::
Start
()
{
MS_TRACE
();
...
...
@@ -174,7 +174,8 @@ void TcpConnection::Start()
MS_THROW_ERROR
(
"error setting peer IP and port"
);
}
void
TcpConnection
::
Write
(
const
uint8_t
*
data
,
size_t
len
,
TcpConnection
::
onSendCallback
*
cb
)
void
TcpConnectionHandler
::
Write
(
const
uint8_t
*
data
,
size_t
len
,
TcpConnectionHandler
::
onSendCallback
*
cb
)
{
MS_TRACE
();
...
...
@@ -268,8 +269,12 @@ void TcpConnection::Write(const uint8_t* data, size_t len, TcpConnection::onSend
}
}
void
TcpConnection
::
Write
(
const
uint8_t
*
data1
,
size_t
len1
,
const
uint8_t
*
data2
,
size_t
len2
,
TcpConnection
::
onSendCallback
*
cb
)
void
TcpConnectionHandler
::
Write
(
const
uint8_t
*
data1
,
size_t
len1
,
const
uint8_t
*
data2
,
size_t
len2
,
TcpConnectionHandler
::
onSendCallback
*
cb
)
{
MS_TRACE
();
...
...
@@ -385,7 +390,7 @@ void TcpConnection::Write(
}
}
void
TcpConnection
::
ErrorReceiving
()
void
TcpConnection
Handler
::
ErrorReceiving
()
{
MS_TRACE
();
...
...
@@ -394,7 +399,7 @@ void TcpConnection::ErrorReceiving()
this
->
listener
->
OnTcpConnectionClosed
(
this
);
}
bool
TcpConnection
::
SetPeerAddress
()
bool
TcpConnection
Handler
::
SetPeerAddress
()
{
MS_TRACE
();
...
...
@@ -418,7 +423,7 @@ bool TcpConnection::SetPeerAddress()
return
true
;
}
inline
void
TcpConnection
::
OnUvReadAlloc
(
size_t
/*suggestedSize*/
,
uv_buf_t
*
buf
)
inline
void
TcpConnection
Handler
::
OnUvReadAlloc
(
size_t
/*suggestedSize*/
,
uv_buf_t
*
buf
)
{
MS_TRACE
();
...
...
@@ -442,7 +447,7 @@ inline void TcpConnection::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* buf
}
}
inline
void
TcpConnection
::
OnUvRead
(
ssize_t
nread
,
const
uv_buf_t
*
/*buf*/
)
inline
void
TcpConnection
Handler
::
OnUvRead
(
ssize_t
nread
,
const
uv_buf_t
*
/*buf*/
)
{
MS_TRACE
();
...
...
@@ -489,7 +494,7 @@ inline void TcpConnection::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/)
}
}
inline
void
TcpConnection
::
OnUvWrite
(
int
status
,
TcpConnection
::
onSendCallback
*
cb
)
inline
void
TcpConnection
Handler
::
OnUvWrite
(
int
status
,
TcpConnectionHandler
::
onSendCallback
*
cb
)
{
MS_TRACE
();
...
...
worker/src/handles/TcpServer.cpp
→
worker/src/handles/TcpServer
Handler
.cpp
浏览文件 @
0d7a5016
#define MS_CLASS "TcpServer"
#define MS_CLASS "TcpServer
Handler
"
// #define MS_LOG_DEV_LEVEL 3
#include "handles/TcpServer.hpp"
#include "handles/TcpServer
Handler
.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
...
...
@@ -10,7 +10,7 @@
inline
static
void
onConnection
(
uv_stream_t
*
handle
,
int
status
)
{
auto
*
server
=
static_cast
<
TcpServer
*>
(
handle
->
data
);
auto
*
server
=
static_cast
<
TcpServer
Handler
*>
(
handle
->
data
);
if
(
server
)
server
->
OnUvConnection
(
status
);
...
...
@@ -24,7 +24,7 @@ inline static void onClose(uv_handle_t* handle)
/* Instance methods. */
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
TcpServer
::
TcpServ
er
(
uv_tcp_t
*
uvHandle
,
int
backlog
)
:
uvHandle
(
uvHandle
)
TcpServer
Handler
::
TcpServerHandl
er
(
uv_tcp_t
*
uvHandle
,
int
backlog
)
:
uvHandle
(
uvHandle
)
{
MS_TRACE
();
...
...
@@ -53,7 +53,7 @@ TcpServer::TcpServer(uv_tcp_t* uvHandle, int backlog) : uvHandle(uvHandle)
}
}
TcpServer
::~
TcpServ
er
()
TcpServer
Handler
::~
TcpServerHandl
er
()
{
MS_TRACE
();
...
...
@@ -61,7 +61,7 @@ TcpServer::~TcpServer()
Close
();
}
void
TcpServer
::
Close
()
void
TcpServer
Handler
::
Close
()
{
MS_TRACE
();
...
...
@@ -70,7 +70,7 @@ void TcpServer::Close()
this
->
closed
=
true
;
// Tell the UV handle that the TcpServer has been closed.
// Tell the UV handle that the TcpServer
Handler
has been closed.
this
->
uvHandle
->
data
=
nullptr
;
MS_DEBUG_DEV
(
"closing %zu active connections"
,
this
->
connections
.
size
());
...
...
@@ -83,23 +83,23 @@ void TcpServer::Close()
uv_close
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
static_cast
<
uv_close_cb
>
(
onClose
));
}
void
TcpServer
::
Dump
()
const
void
TcpServer
Handler
::
Dump
()
const
{
MS_DUMP
(
"<TcpServer>"
);
MS_DUMP
(
"<TcpServer
Handler
>"
);
MS_DUMP
(
" [TCP, local:%s :%"
PRIu16
", status:%s, connections:%zu]"
,
this
->
localIp
.
c_str
(),
static_cast
<
uint16_t
>
(
this
->
localPort
),
(
!
this
->
closed
)
?
"open"
:
"closed"
,
this
->
connections
.
size
());
MS_DUMP
(
"</TcpServer>"
);
MS_DUMP
(
"</TcpServer
Handler
>"
);
}
void
TcpServer
::
AcceptTcpConnection
(
TcpConnection
*
connection
)
void
TcpServer
Handler
::
AcceptTcpConnection
(
TcpConnectionHandler
*
connection
)
{
MS_TRACE
();
MS_ASSERT
(
connection
!=
nullptr
,
"TcpConnection pointer was not allocated by the user"
);
MS_ASSERT
(
connection
!=
nullptr
,
"TcpConnection
Handler
pointer was not allocated by the user"
);
try
{
...
...
@@ -137,7 +137,7 @@ void TcpServer::AcceptTcpConnection(TcpConnection* connection)
this
->
connections
.
insert
(
connection
);
}
bool
TcpServer
::
SetLocalAddress
()
bool
TcpServer
Handler
::
SetLocalAddress
()
{
MS_TRACE
();
...
...
@@ -162,7 +162,7 @@ bool TcpServer::SetLocalAddress()
return
true
;
}
inline
void
TcpServer
::
OnUvConnection
(
int
status
)
inline
void
TcpServer
Handler
::
OnUvConnection
(
int
status
)
{
MS_TRACE
();
...
...
@@ -180,13 +180,13 @@ inline void TcpServer::OnUvConnection(int status)
UserOnTcpConnectionAlloc
();
}
inline
void
TcpServer
::
OnTcpConnectionClosed
(
TcpConnection
*
connection
)
inline
void
TcpServer
Handler
::
OnTcpConnectionClosed
(
TcpConnectionHandler
*
connection
)
{
MS_TRACE
();
MS_DEBUG_DEV
(
"TCP connection closed"
);
// Remove the TcpConnection from the set.
// Remove the TcpConnection
Handler
from the set.
this
->
connections
.
erase
(
connection
);
// Notify the subclass.
...
...
worker/src/handles/UdpSocket.cpp
→
worker/src/handles/UdpSocket
Handler
.cpp
浏览文件 @
0d7a5016
#define MS_CLASS "UdpSocket"
#define MS_CLASS "UdpSocket
Handler
"
// #define MS_LOG_DEV_LEVEL 3
#include "handles/UdpSocket.hpp"
#include "handles/UdpSocket
Handler
.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
...
...
@@ -16,7 +16,7 @@ thread_local static uint8_t ReadBuffer[ReadBufferSize];
inline
static
void
onAlloc
(
uv_handle_t
*
handle
,
size_t
suggestedSize
,
uv_buf_t
*
buf
)
{
auto
*
socket
=
static_cast
<
UdpSocket
*>
(
handle
->
data
);
auto
*
socket
=
static_cast
<
UdpSocket
Handler
*>
(
handle
->
data
);
if
(
socket
)
socket
->
OnUvRecvAlloc
(
suggestedSize
,
buf
);
...
...
@@ -25,7 +25,7 @@ inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t*
inline
static
void
onRecv
(
uv_udp_t
*
handle
,
ssize_t
nread
,
const
uv_buf_t
*
buf
,
const
struct
sockaddr
*
addr
,
unsigned
int
flags
)
{
auto
*
socket
=
static_cast
<
UdpSocket
*>
(
handle
->
data
);
auto
*
socket
=
static_cast
<
UdpSocket
Handler
*>
(
handle
->
data
);
if
(
socket
)
socket
->
OnUvRecv
(
nread
,
buf
,
addr
,
flags
);
...
...
@@ -33,9 +33,9 @@ inline static void onRecv(
inline
static
void
onSend
(
uv_udp_send_t
*
req
,
int
status
)
{
auto
*
sendData
=
static_cast
<
UdpSocket
::
UvSendData
*>
(
req
->
data
);
auto
*
sendData
=
static_cast
<
UdpSocket
Handler
::
UvSendData
*>
(
req
->
data
);
auto
*
handle
=
req
->
handle
;
auto
*
socket
=
static_cast
<
UdpSocket
*>
(
handle
->
data
);
auto
*
socket
=
static_cast
<
UdpSocket
Handler
*>
(
handle
->
data
);
auto
*
cb
=
sendData
->
cb
;
if
(
socket
)
...
...
@@ -53,7 +53,7 @@ inline static void onClose(uv_handle_t* handle)
/* Instance methods. */
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
UdpSocket
::
UdpSocket
(
uv_udp_t
*
uvHandle
)
:
uvHandle
(
uvHandle
)
UdpSocket
Handler
::
UdpSocketHandler
(
uv_udp_t
*
uvHandle
)
:
uvHandle
(
uvHandle
)
{
MS_TRACE
();
...
...
@@ -80,7 +80,7 @@ UdpSocket::UdpSocket(uv_udp_t* uvHandle) : uvHandle(uvHandle)
}
}
UdpSocket
::~
UdpSocket
()
UdpSocket
Handler
::~
UdpSocketHandler
()
{
MS_TRACE
();
...
...
@@ -88,7 +88,7 @@ UdpSocket::~UdpSocket()
Close
();
}
void
UdpSocket
::
Close
()
void
UdpSocket
Handler
::
Close
()
{
MS_TRACE
();
...
...
@@ -97,7 +97,7 @@ void UdpSocket::Close()
this
->
closed
=
true
;
// Tell the UV handle that the UdpSocket has been closed.
// Tell the UV handle that the UdpSocket
Handler
has been closed.
this
->
uvHandle
->
data
=
nullptr
;
// Don't read more.
...
...
@@ -109,17 +109,17 @@ void UdpSocket::Close()
uv_close
(
reinterpret_cast
<
uv_handle_t
*>
(
this
->
uvHandle
),
static_cast
<
uv_close_cb
>
(
onClose
));
}
void
UdpSocket
::
Dump
()
const
void
UdpSocket
Handler
::
Dump
()
const
{
MS_DUMP
(
"<UdpSocket>"
);
MS_DUMP
(
"<UdpSocket
Handler
>"
);
MS_DUMP
(
" localIp : %s"
,
this
->
localIp
.
c_str
());
MS_DUMP
(
" localPort : %"
PRIu16
,
static_cast
<
uint16_t
>
(
this
->
localPort
));
MS_DUMP
(
" closed : %s"
,
!
this
->
closed
?
"open"
:
"closed"
);
MS_DUMP
(
"</UdpSocket>"
);
MS_DUMP
(
"</UdpSocket
Handler
>"
);
}
void
UdpSocket
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
,
UdpSocket
::
onSendCallback
*
cb
)
void
UdpSocket
Handler
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
,
UdpSocket
Handler
::
onSendCallback
*
cb
)
{
MS_TRACE
();
...
...
@@ -216,7 +216,7 @@ void UdpSocket::Send(
}
}
bool
UdpSocket
::
SetLocalAddress
()
bool
UdpSocket
Handler
::
SetLocalAddress
()
{
MS_TRACE
();
...
...
@@ -241,7 +241,7 @@ bool UdpSocket::SetLocalAddress()
return
true
;
}
inline
void
UdpSocket
::
OnUvRecvAlloc
(
size_t
/*suggestedSize*/
,
uv_buf_t
*
buf
)
inline
void
UdpSocket
Handler
::
OnUvRecvAlloc
(
size_t
/*suggestedSize*/
,
uv_buf_t
*
buf
)
{
MS_TRACE
();
...
...
@@ -251,7 +251,7 @@ inline void UdpSocket::OnUvRecvAlloc(size_t /*suggestedSize*/, uv_buf_t* buf)
buf
->
len
=
ReadBufferSize
;
}
inline
void
UdpSocket
::
OnUvRecv
(
inline
void
UdpSocket
Handler
::
OnUvRecv
(
ssize_t
nread
,
const
uv_buf_t
*
buf
,
const
struct
sockaddr
*
addr
,
unsigned
int
flags
)
{
MS_TRACE
();
...
...
@@ -284,7 +284,7 @@ inline void UdpSocket::OnUvRecv(
}
}
inline
void
UdpSocket
::
OnUvSend
(
int
status
,
UdpSocket
::
onSendCallback
*
cb
)
inline
void
UdpSocket
Handler
::
OnUvSend
(
int
status
,
UdpSocketHandler
::
onSendCallback
*
cb
)
{
MS_TRACE
();
...
...
worker/src/lib.cpp
浏览文件 @
0d7a5016
...
...
@@ -12,10 +12,10 @@
#include "Settings.hpp"
#include "Utils.hpp"
#include "Worker.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/
UnixStream
Socket.hpp"
#include "PayloadChannel/Notifier.hpp"
#include "PayloadChannel/
UnixStream
Socket.hpp"
#include "Channel/
Channel
Notifier.hpp"
#include "Channel/
Channel
Socket.hpp"
#include "PayloadChannel/
PayloadChannel
Notifier.hpp"
#include "PayloadChannel/
PayloadChannel
Socket.hpp"
#include "RTC/DtlsTransport.hpp"
#include "RTC/SrtpSession.hpp"
#include <uv.h>
...
...
@@ -41,14 +41,14 @@ extern "C" int run_worker(
DepLibUV
::
ClassInit
();
// Channel socket (it will be handled and deleted by the Worker).
Channel
::
UnixStream
Socket
*
channel
{
nullptr
};
Channel
::
Channel
Socket
*
channel
{
nullptr
};
// PayloadChannel socket (it will be handled and deleted by the Worker).
PayloadChannel
::
UnixStream
Socket
*
payloadChannel
{
nullptr
};
PayloadChannel
::
PayloadChannel
Socket
*
payloadChannel
{
nullptr
};
try
{
channel
=
new
Channel
::
UnixStream
Socket
(
consumerChannelFd
,
producerChannelFd
);
channel
=
new
Channel
::
Channel
Socket
(
consumerChannelFd
,
producerChannelFd
);
}
catch
(
const
MediaSoupError
&
error
)
{
...
...
@@ -60,7 +60,7 @@ extern "C" int run_worker(
try
{
payloadChannel
=
new
PayloadChannel
::
UnixStream
Socket
(
payloadConsumeChannelFd
,
payloadProduceChannelFd
);
new
PayloadChannel
::
PayloadChannel
Socket
(
payloadConsumeChannelFd
,
payloadProduceChannelFd
);
}
catch
(
const
MediaSoupError
&
error
)
{
...
...
@@ -121,8 +121,8 @@ extern "C" int run_worker(
Utils
::
Crypto
::
ClassInit
();
RTC
::
DtlsTransport
::
ClassInit
();
RTC
::
SrtpSession
::
ClassInit
();
Channel
::
Notifier
::
ClassInit
(
channel
);
PayloadChannel
::
Notifier
::
ClassInit
(
payloadChannel
);
Channel
::
Channel
Notifier
::
ClassInit
(
channel
);
PayloadChannel
::
PayloadChannel
Notifier
::
ClassInit
(
payloadChannel
);
#ifdef MS_EXECUTABLE
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论