Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
555e433d
提交
555e433d
authored
7月 24, 2022
作者:
Nazar Mokrynskyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move `Producer` notification handling from `DirectTransport` to `Producer` itself
上级
23e26f80
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
73 行增加
和
37 行删除
+73
-37
DirectTransport.hpp
worker/include/RTC/DirectTransport.hpp
+0
-4
Producer.hpp
worker/include/RTC/Producer.hpp
+10
-1
Transport.hpp
worker/include/RTC/Transport.hpp
+8
-0
DirectTransport.cpp
worker/src/RTC/DirectTransport.cpp
+3
-32
Producer.cpp
worker/src/RTC/Producer.cpp
+52
-0
没有找到文件。
worker/include/RTC/DirectTransport.hpp
浏览文件 @
555e433d
...
@@ -40,10 +40,6 @@ namespace RTC
...
@@ -40,10 +40,6 @@ namespace RTC
/* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */
/* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */
public
:
public
:
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
override
;
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
override
;
private
:
// Allocated by this.
uint8_t
*
buffer
{
nullptr
};
};
};
}
// namespace RTC
}
// namespace RTC
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
555e433d
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include "common.hpp"
#include "common.hpp"
#include "Channel/ChannelRequest.hpp"
#include "Channel/ChannelRequest.hpp"
#include "Channel/ChannelSocket.hpp"
#include "Channel/ChannelSocket.hpp"
#include "PayloadChannel/PayloadChannelSocket.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"
...
@@ -23,7 +24,8 @@ namespace RTC
...
@@ -23,7 +24,8 @@ namespace RTC
{
{
class
Producer
:
public
RTC
::
RtpStreamRecv
::
Listener
,
class
Producer
:
public
RTC
::
RtpStreamRecv
::
Listener
,
public
RTC
::
KeyFrameRequestManager
::
Listener
,
public
RTC
::
KeyFrameRequestManager
::
Listener
,
public
Channel
::
ChannelSocket
::
RequestHandler
public
Channel
::
ChannelSocket
::
RequestHandler
,
public
PayloadChannel
::
PayloadChannelSocket
::
NotificationHandler
{
{
public
:
public
:
class
Listener
class
Listener
...
@@ -32,6 +34,8 @@ namespace RTC
...
@@ -32,6 +34,8 @@ namespace RTC
virtual
~
Listener
()
=
default
;
virtual
~
Listener
()
=
default
;
public
:
public
:
virtual
void
OnProducerReceiveData
(
RTC
::
Producer
*
producer
,
size_t
len
)
=
0
;
virtual
void
OnProducerReceiveRtpPacket
(
RTC
::
Producer
*
producer
,
RTC
::
RtpPacket
*
packet
)
=
0
;
virtual
void
OnProducerPaused
(
RTC
::
Producer
*
producer
)
=
0
;
virtual
void
OnProducerPaused
(
RTC
::
Producer
*
producer
)
=
0
;
virtual
void
OnProducerResumed
(
RTC
::
Producer
*
producer
)
=
0
;
virtual
void
OnProducerResumed
(
RTC
::
Producer
*
producer
)
=
0
;
virtual
void
OnProducerNewRtpStream
(
virtual
void
OnProducerNewRtpStream
(
...
@@ -132,6 +136,10 @@ namespace RTC
...
@@ -132,6 +136,10 @@ namespace RTC
public
:
public
:
void
HandleRequest
(
Channel
::
ChannelRequest
*
request
)
override
;
void
HandleRequest
(
Channel
::
ChannelRequest
*
request
)
override
;
/* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */
public
:
void
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
override
;
private
:
private
:
RTC
::
RtpStreamRecv
*
GetRtpStream
(
RTC
::
RtpPacket
*
packet
);
RTC
::
RtpStreamRecv
*
GetRtpStream
(
RTC
::
RtpPacket
*
packet
);
RTC
::
RtpStreamRecv
*
CreateRtpStream
(
RTC
::
RtpStreamRecv
*
CreateRtpStream
(
...
@@ -188,6 +196,7 @@ namespace RTC
...
@@ -188,6 +196,7 @@ namespace RTC
bool
videoOrientationDetected
{
false
};
bool
videoOrientationDetected
{
false
};
struct
VideoOrientation
videoOrientation
;
struct
VideoOrientation
videoOrientation
;
struct
TraceEventTypes
traceEventTypes
;
struct
TraceEventTypes
traceEventTypes
;
uint8_t
*
buffer
{
nullptr
};
};
};
}
// namespace RTC
}
// namespace RTC
...
...
worker/include/RTC/Transport.hpp
浏览文件 @
555e433d
...
@@ -191,6 +191,14 @@ namespace RTC
...
@@ -191,6 +191,14 @@ namespace RTC
/* Pure virtual methods inherited from RTC::Producer::Listener. */
/* Pure virtual methods inherited from RTC::Producer::Listener. */
public
:
public
:
void
OnProducerReceiveData
(
RTC
::
Producer
*
/*producer*/
,
size_t
len
)
override
{
this
->
DataReceived
(
len
);
}
void
OnProducerReceiveRtpPacket
(
RTC
::
Producer
*
/*producer*/
,
RTC
::
RtpPacket
*
packet
)
override
{
this
->
ReceiveRtpPacket
(
packet
);
}
void
OnProducerPaused
(
RTC
::
Producer
*
producer
)
override
;
void
OnProducerPaused
(
RTC
::
Producer
*
producer
)
override
;
void
OnProducerResumed
(
RTC
::
Producer
*
producer
)
override
;
void
OnProducerResumed
(
RTC
::
Producer
*
producer
)
override
;
void
OnProducerNewRtpStream
(
void
OnProducerNewRtpStream
(
...
...
worker/src/RTC/DirectTransport.cpp
浏览文件 @
555e433d
...
@@ -20,8 +20,6 @@ namespace RTC
...
@@ -20,8 +20,6 @@ namespace RTC
DirectTransport
::~
DirectTransport
()
DirectTransport
::~
DirectTransport
()
{
{
MS_TRACE
();
MS_TRACE
();
delete
[]
this
->
buffer
;
}
}
void
DirectTransport
::
FillJson
(
json
&
jsonObject
)
const
void
DirectTransport
::
FillJson
(
json
&
jsonObject
)
const
...
@@ -91,37 +89,10 @@ namespace RTC
...
@@ -91,37 +89,10 @@ namespace RTC
case
PayloadChannel
:
:
Notification
::
EventId
::
PRODUCER_SEND
:
case
PayloadChannel
:
:
Notification
::
EventId
::
PRODUCER_SEND
:
{
{
const
auto
*
data
=
notification
->
payload
;
// This may throw.
auto
len
=
notification
->
payloadLen
;
RTC
::
Producer
*
producer
=
GetProducerFromInternal
(
notification
->
internal
);
// Increase receive transmission.
RTC
::
Transport
::
DataReceived
(
len
);
if
(
len
>
RTC
::
MtuSize
+
100
)
{
MS_WARN_TAG
(
rtp
,
"given RTP packet exceeds maximum size [len:%zu]"
,
len
);
return
;
}
// If this is the first time to reveive a RTP packet then allocate the receiving buffer now.
if
(
!
this
->
buffer
)
this
->
buffer
=
new
uint8_t
[
RTC
::
MtuSize
+
100
];
// Copy the received packet into this buffer so it can be expanded later.
std
::
memcpy
(
this
->
buffer
,
data
,
static_cast
<
size_t
>
(
len
));
RTC
::
RtpPacket
*
packet
=
RTC
::
RtpPacket
::
Parse
(
this
->
buffer
,
len
);
if
(
!
packet
)
{
MS_WARN_TAG
(
rtp
,
"received data is not a valid RTP packet"
);
return
;
}
// Pass the packet to the parent transport.
producer
->
HandleNotification
(
notification
);
RTC
::
Transport
::
ReceiveRtpPacket
(
packet
);
break
;
break
;
}
}
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
555e433d
...
@@ -332,6 +332,8 @@ namespace RTC
...
@@ -332,6 +332,8 @@ namespace RTC
// Delete the KeyFrameRequestManager.
// Delete the KeyFrameRequestManager.
delete
this
->
keyFrameRequestManager
;
delete
this
->
keyFrameRequestManager
;
delete
[]
this
->
buffer
;
}
}
void
Producer
::
FillJson
(
json
&
jsonObject
)
const
void
Producer
::
FillJson
(
json
&
jsonObject
)
const
...
@@ -605,6 +607,56 @@ namespace RTC
...
@@ -605,6 +607,56 @@ namespace RTC
}
}
}
}
void
Producer
::
HandleNotification
(
PayloadChannel
::
Notification
*
notification
)
{
MS_TRACE
();
switch
(
notification
->
eventId
)
{
case
PayloadChannel
:
:
Notification
::
EventId
::
PRODUCER_SEND
:
{
const
auto
*
data
=
notification
->
payload
;
auto
len
=
notification
->
payloadLen
;
// Increase receive transmission.
this
->
listener
->
OnProducerReceiveData
(
this
,
len
);
if
(
len
>
RTC
::
MtuSize
+
100
)
{
MS_WARN_TAG
(
rtp
,
"given RTP packet exceeds maximum size [len:%zu]"
,
len
);
break
;
}
// If this is the first time to receive a RTP packet then allocate the receiving buffer now.
if
(
!
this
->
buffer
)
this
->
buffer
=
new
uint8_t
[
RTC
::
MtuSize
+
100
];
// Copy the received packet into this buffer so it can be expanded later.
std
::
memcpy
(
this
->
buffer
,
data
,
static_cast
<
size_t
>
(
len
));
RTC
::
RtpPacket
*
packet
=
RTC
::
RtpPacket
::
Parse
(
this
->
buffer
,
len
);
if
(
!
packet
)
{
MS_WARN_TAG
(
rtp
,
"received data is not a valid RTP packet"
);
break
;
}
// Pass the packet to the parent transport.
this
->
listener
->
OnProducerReceiveRtpPacket
(
this
,
packet
);
break
;
}
default
:
{
MS_ERROR
(
"unknown event '%s'"
,
notification
->
event
.
c_str
());
}
}
}
Producer
::
ReceiveRtpPacketResult
Producer
::
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
)
Producer
::
ReceiveRtpPacketResult
Producer
::
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
)
{
{
MS_TRACE
();
MS_TRACE
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论