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