Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
3f08055c
提交
3f08055c
authored
7月 24, 2022
作者:
Nazar Mokrynskyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move `DataProducer` notification handling from `DirectTransport` to `DataProducer` itself
上级
555e433d
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
67 行增加
和
31 行删除
+67
-31
DataProducer.hpp
worker/include/RTC/DataProducer.hpp
+12
-2
Transport.hpp
worker/include/RTC/Transport.hpp
+4
-0
DataProducer.cpp
worker/src/RTC/DataProducer.cpp
+48
-2
DirectTransport.cpp
worker/src/RTC/DirectTransport.cpp
+1
-26
Transport.cpp
worker/src/RTC/Transport.cpp
+2
-1
没有找到文件。
worker/include/RTC/DataProducer.hpp
浏览文件 @
3f08055c
...
...
@@ -4,13 +4,16 @@
#include "common.hpp"
#include "Channel/ChannelRequest.hpp"
#include "Channel/ChannelSocket.hpp"
#include "PayloadChannel/PayloadChannelSocket.hpp"
#include "RTC/RTCP/Packet.hpp"
#include "RTC/SctpDictionaries.hpp"
#include <nlohmann/json.hpp>
#include <string>
namespace
RTC
{
class
DataProducer
:
public
Channel
::
ChannelSocket
::
RequestHandler
class
DataProducer
:
public
Channel
::
ChannelSocket
::
RequestHandler
,
public
PayloadChannel
::
PayloadChannelSocket
::
NotificationHandler
{
public
:
class
Listener
...
...
@@ -19,6 +22,7 @@ namespace RTC
virtual
~
Listener
()
=
default
;
public
:
virtual
void
OnDataProducerReceiveData
(
RTC
::
DataProducer
*
producer
,
size_t
len
)
=
0
;
virtual
void
OnDataProducerMessageReceived
(
RTC
::
DataProducer
*
dataProducer
,
uint32_t
ppid
,
const
uint8_t
*
msg
,
size_t
len
)
=
0
;
};
...
...
@@ -31,7 +35,8 @@ namespace RTC
};
public
:
DataProducer
(
const
std
::
string
&
id
,
RTC
::
DataProducer
::
Listener
*
listener
,
json
&
data
);
DataProducer
(
const
std
::
string
&
id
,
size_t
maxMessageSize
,
RTC
::
DataProducer
::
Listener
*
listener
,
json
&
data
);
virtual
~
DataProducer
();
public
:
...
...
@@ -51,12 +56,17 @@ namespace RTC
public
:
void
HandleRequest
(
Channel
::
ChannelRequest
*
request
)
override
;
/* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */
public
:
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
override
;
public
:
// Passed by argument.
const
std
::
string
id
;
private
:
// Passed by argument.
size_t
maxMessageSize
{
0u
};
RTC
::
DataProducer
::
Listener
*
listener
{
nullptr
};
// Others.
Type
type
;
...
...
worker/include/RTC/Transport.hpp
浏览文件 @
3f08055c
...
...
@@ -223,6 +223,10 @@ namespace RTC
/* Pure virtual methods inherited from RTC::DataProducer::Listener. */
public
:
void
OnDataProducerReceiveData
(
RTC
::
DataProducer
*
/*dataProducer*/
,
size_t
len
)
override
{
this
->
DataReceived
(
len
);
}
void
OnDataProducerMessageReceived
(
RTC
::
DataProducer
*
dataProducer
,
uint32_t
ppid
,
const
uint8_t
*
msg
,
size_t
len
)
override
;
...
...
worker/src/RTC/DataProducer.cpp
浏览文件 @
3f08055c
...
...
@@ -11,8 +11,9 @@ namespace RTC
{
/* Instance methods. */
DataProducer
::
DataProducer
(
const
std
::
string
&
id
,
RTC
::
DataProducer
::
Listener
*
listener
,
json
&
data
)
:
id
(
id
),
listener
(
listener
)
DataProducer
::
DataProducer
(
const
std
::
string
&
id
,
size_t
maxMessageSize
,
RTC
::
DataProducer
::
Listener
*
listener
,
json
&
data
)
:
id
(
id
),
maxMessageSize
(
maxMessageSize
),
listener
(
listener
)
{
MS_TRACE
();
...
...
@@ -145,6 +146,51 @@ namespace RTC
}
}
void
DataProducer
::
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
{
MS_TRACE
();
switch
(
notification
->
eventId
)
{
case
PayloadChannel
:
:
Notification
::
EventId
::
DATA_PRODUCER_SEND
:
{
auto
jsonPpidIt
=
notification
->
data
.
find
(
"ppid"
);
if
(
jsonPpidIt
==
notification
->
data
.
end
()
||
!
Utils
::
Json
::
IsPositiveInteger
(
*
jsonPpidIt
))
{
MS_THROW_TYPE_ERROR
(
"invalid ppid"
);
}
auto
ppid
=
jsonPpidIt
->
get
<
uint32_t
>
();
const
auto
*
msg
=
notification
->
payload
;
auto
len
=
notification
->
payloadLen
;
if
(
len
>
this
->
maxMessageSize
)
{
MS_WARN_TAG
(
message
,
"given message exceeds maxMessageSize value [maxMessageSize:%zu, len:%zu]"
,
len
,
this
->
maxMessageSize
);
break
;
}
this
->
ReceiveMessage
(
ppid
,
msg
,
len
);
// Increase receive transmission.
this
->
listener
->
OnDataProducerReceiveData
(
this
,
len
);
break
;
}
default
:
{
MS_ERROR
(
"unknown event '%s'"
,
notification
->
event
.
c_str
());
}
}
}
void
DataProducer
::
ReceiveMessage
(
uint32_t
ppid
,
const
uint8_t
*
msg
,
size_t
len
)
{
MS_TRACE
();
...
...
worker/src/RTC/DirectTransport.cpp
浏览文件 @
3f08055c
...
...
@@ -102,32 +102,7 @@ namespace RTC
// This may throw.
RTC
::
DataProducer
*
dataProducer
=
GetDataProducerFromInternal
(
notification
->
internal
);
auto
jsonPpidIt
=
notification
->
data
.
find
(
"ppid"
);
if
(
jsonPpidIt
==
notification
->
data
.
end
()
||
!
Utils
::
Json
::
IsPositiveInteger
(
*
jsonPpidIt
))
{
MS_THROW_TYPE_ERROR
(
"invalid ppid"
);
}
auto
ppid
=
jsonPpidIt
->
get
<
uint32_t
>
();
const
auto
*
msg
=
notification
->
payload
;
auto
len
=
notification
->
payloadLen
;
if
(
len
>
this
->
maxMessageSize
)
{
MS_WARN_TAG
(
message
,
"given message exceeds maxMessageSize value [maxMessageSize:%zu, len:%zu]"
,
len
,
this
->
maxMessageSize
);
return
;
}
dataProducer
->
ReceiveMessage
(
ppid
,
msg
,
len
);
// Increase receive transmission.
RTC
::
Transport
::
DataReceived
(
len
);
dataProducer
->
HandleNotification
(
notification
);
break
;
}
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
3f08055c
...
...
@@ -1092,7 +1092,8 @@ namespace RTC
SetNewDataProducerIdFromInternal
(
request
->
internal
,
dataProducerId
);
// This may throw.
auto
*
dataProducer
=
new
RTC
::
DataProducer
(
dataProducerId
,
this
,
request
->
data
);
auto
*
dataProducer
=
new
RTC
::
DataProducer
(
dataProducerId
,
this
->
maxMessageSize
,
this
,
request
->
data
);
// Verify the type of the DataProducer.
switch
(
dataProducer
->
GetType
())
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论