Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
8dd72196
提交
8dd72196
authored
12月 08, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consumer: make use of RTC::RtpMonitor
上级
30f9b95c
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
29 行增加
和
78 行删除
+29
-78
Consumer.hpp
worker/include/RTC/Consumer.hpp
+6
-4
RtpStreamSend.hpp
worker/include/RTC/RtpStreamSend.hpp
+3
-14
Consumer.cpp
worker/src/RTC/Consumer.cpp
+15
-17
RtpStreamSend.cpp
worker/src/RTC/RtpStreamSend.cpp
+2
-33
TestRtpMonitor.cpp
worker/test/RTC/TestRtpMonitor.cpp
+2
-2
TestRtpStreamSend.cpp
worker/test/RTC/TestRtpStreamSend.cpp
+1
-8
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
8dd72196
...
...
@@ -11,6 +11,7 @@
#include "RTC/RTCP/Sdes.hpp"
#include "RTC/RtpDataCounter.hpp"
#include "RTC/RtpDictionaries.hpp"
#include "RTC/RtpMonitor.hpp"
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpStreamSend.hpp"
#include "RTC/SeqManager.hpp"
...
...
@@ -21,7 +22,7 @@
namespace
RTC
{
class
Consumer
:
public
RTC
::
Rtp
StreamSend
::
Listener
class
Consumer
:
public
RTC
::
Rtp
Monitor
::
Listener
{
public
:
Consumer
(
...
...
@@ -72,10 +73,10 @@ namespace RTC
void
SetEffectiveProfile
(
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
MayRunProbation
();
/* Pure virtual methods inherited from RTC::Rtp
StreamSend
::Listener. */
/* Pure virtual methods inherited from RTC::Rtp
Monitor
::Listener. */
public
:
void
OnRtp
StreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtp
StreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtp
MonitorHealthy
(
)
override
;
void
OnRtp
MonitorUnhealthy
(
)
override
;
public
:
// Passed by argument.
...
...
@@ -91,6 +92,7 @@ namespace RTC
std
::
unordered_set
<
RTC
::
ConsumerListener
*>
listeners
;
// Allocated by this.
RTC
::
RtpStreamSend
*
rtpStream
{
nullptr
};
RtpMonitor
*
rtpMonitor
{
nullptr
};
// Others.
std
::
unordered_set
<
uint8_t
>
supportedCodecPayloadTypes
;
bool
paused
{
false
};
...
...
worker/include/RTC/RtpStreamSend.hpp
浏览文件 @
8dd72196
...
...
@@ -11,14 +11,6 @@ namespace RTC
{
class
RtpStreamSend
:
public
RtpStream
{
public
:
class
Listener
{
public
:
virtual
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
};
private
:
struct
StorageItem
{
...
...
@@ -34,7 +26,7 @@ namespace RTC
};
public
:
RtpStreamSend
(
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
);
RtpStreamSend
(
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
);
~
RtpStreamSend
()
override
;
Json
::
Value
GetStats
()
override
;
...
...
@@ -58,14 +50,11 @@ namespace RTC
private
:
// Passed by argument.
Listener
*
listener
{
nullptr
};
std
::
vector
<
StorageItem
>
storage
;
using
Buffer
=
std
::
list
<
BufferItem
>
;
Buffer
buffer
;
// Stats.
float
rtt
{
0
};
// Others.
bool
healthy
{
true
};
private
:
// Retransmittion related.
...
...
@@ -80,9 +69,9 @@ namespace RTC
return
this
->
hasRtx
;
}
inline
bool
RtpStreamSend
::
IsHealthy
()
const
inline
void
RtpStreamSend
::
CheckStatus
()
{
return
this
->
healthy
;
return
;
}
}
// namespace RTC
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
8dd72196
...
...
@@ -32,6 +32,8 @@ namespace RTC
this
->
maxRtcpInterval
=
RTC
::
RTCP
::
MaxAudioIntervalMs
;
else
this
->
maxRtcpInterval
=
RTC
::
RTCP
::
MaxVideoIntervalMs
;
this
->
rtpMonitor
=
new
RTC
::
RtpMonitor
(
this
);
}
Consumer
::~
Consumer
()
...
...
@@ -39,6 +41,7 @@ namespace RTC
MS_TRACE
();
delete
this
->
rtpStream
;
delete
this
->
rtpMonitor
;
}
void
Consumer
::
Destroy
()
...
...
@@ -186,7 +189,7 @@ namespace RTC
if
(
IsEnabled
()
&&
!
this
->
sourcePaused
)
{
this
->
rtp
Stream
->
StopStatusCheckTimer
();
this
->
rtp
Monitor
->
Reset
();
this
->
rtpStream
->
ClearRetransmissionBuffer
();
this
->
rtpPacketsBeforeProbation
=
RtpPacketsBeforeProbation
;
...
...
@@ -211,8 +214,6 @@ namespace RTC
if
(
IsEnabled
()
&&
!
this
->
sourcePaused
)
{
this
->
rtpStream
->
RestartStatusCheckTimer
();
// We need to sync and wait for a key frame. Otherwise the receiver will
// request lot of NACKs due to unknown RTP packets.
this
->
syncRequired
=
true
;
...
...
@@ -236,7 +237,7 @@ namespace RTC
if
(
IsEnabled
()
&&
!
this
->
paused
)
{
this
->
rtp
Stream
->
StopStatusCheckTimer
();
this
->
rtp
Monitor
->
Reset
();
this
->
rtpStream
->
ClearRetransmissionBuffer
();
this
->
rtpPacketsBeforeProbation
=
RtpPacketsBeforeProbation
;
...
...
@@ -263,8 +264,6 @@ namespace RTC
if
(
IsEnabled
()
&&
!
this
->
paused
)
{
this
->
rtpStream
->
RestartStatusCheckTimer
();
// We need to sync. However we don't need to request a key frame since the source
// (Producer) already requested it.
this
->
syncRequired
=
true
;
...
...
@@ -331,9 +330,8 @@ namespace RTC
this
->
isProbing
=
false
;
this
->
probingProfile
=
RtpEncodingParameters
::
Profile
::
NONE
;
// Restart the health check timer so this probation doesn't affect the effective
// profile.
this
->
rtpStream
->
RestartStatusCheckTimer
();
// Reset the RTP monitor so this probation doesn't affect the current profile.
this
->
rtpMonitor
->
Reset
();
return
;
}
...
...
@@ -703,6 +701,7 @@ namespace RTC
return
;
this
->
rtpStream
->
ReceiveRtcpReceiverReport
(
report
);
this
->
rtpMonitor
->
ReceiveRtcpReceiverReport
(
report
);
}
float
Consumer
::
GetLossPercentage
()
const
...
...
@@ -743,7 +742,7 @@ namespace RTC
}
}
void
Consumer
::
OnRtp
StreamHealthy
(
RtpStream
*
rtpStream
)
void
Consumer
::
OnRtp
MonitorHealthy
(
)
{
MS_TRACE
();
...
...
@@ -773,7 +772,7 @@ namespace RTC
RTC
::
RtpEncodingParameters
::
profile2String
[
this
->
targetProfile
].
c_str
());
}
void
Consumer
::
OnRtp
StreamUnhealthy
(
RtpStream
*
rtpStream
)
void
Consumer
::
OnRtp
MonitorUnhealthy
(
)
{
MS_TRACE
();
...
...
@@ -815,8 +814,8 @@ namespace RTC
if
(
IsEnabled
()
&&
!
IsPaused
())
RequestKeyFrame
();
//
We want to be notified about this new profile's health
.
this
->
rtp
Stream
->
RestartStatusCheckTimer
();
//
Reset the RTP monitor to have clear data about the new profile
.
this
->
rtp
Monitor
->
Reset
();
MS_DEBUG_TAG
(
rtp
,
...
...
@@ -840,7 +839,7 @@ namespace RTC
return
;
// Current health status is not good.
if
(
!
this
->
rtp
Stream
->
IsHealthy
())
if
(
!
this
->
rtp
Monitor
->
IsHealthy
())
return
;
RecalculateTargetProfile
();
...
...
@@ -894,9 +893,9 @@ namespace RTC
// Create a RtpStreamSend for sending a single media stream.
if
(
useNack
)
this
->
rtpStream
=
new
RTC
::
RtpStreamSend
(
this
,
params
,
1500
);
this
->
rtpStream
=
new
RTC
::
RtpStreamSend
(
params
,
1500
);
else
this
->
rtpStream
=
new
RTC
::
RtpStreamSend
(
this
,
params
,
0
);
this
->
rtpStream
=
new
RTC
::
RtpStreamSend
(
params
,
0
);
if
(
encoding
.
hasRtx
&&
encoding
.
rtx
.
ssrc
!=
0u
)
{
...
...
@@ -1027,7 +1026,6 @@ namespace RTC
{
this
->
isProbing
=
true
;
this
->
probingProfile
=
newTargetProfile
;
this
->
rtpStream
->
RestartStatusCheckTimer
();
MS_DEBUG_TAG
(
rtp
,
...
...
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
8dd72196
...
...
@@ -14,18 +14,13 @@ namespace RTC
// Don't retransmit packets older than this (ms).
static
constexpr
uint32_t
MaxRetransmissionDelay
{
2000
};
static
constexpr
uint32_t
DefaultRtt
{
100
};
static
constexpr
uint8_t
MaxHealthLossPercentage
{
20
};
static
constexpr
uint16_t
StatusCheckPeriod
{
1000
};
/* Instance methods. */
RtpStreamSend
::
RtpStreamSend
(
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
)
:
RtpStream
::
RtpStream
(
params
),
listener
(
listener
),
storage
(
bufferSize
)
RtpStreamSend
::
RtpStreamSend
(
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
)
:
RtpStream
::
RtpStream
(
params
),
storage
(
bufferSize
)
{
MS_TRACE
();
// Run the timer.
this
->
statusCheckTimer
->
Start
(
StatusCheckPeriod
,
StatusCheckPeriod
);
}
RtpStreamSend
::~
RtpStreamSend
()
...
...
@@ -399,32 +394,6 @@ namespace RTC
(
*
newBufferIt
).
packet
=
packet
->
Clone
(
store
);
}
void
RtpStreamSend
::
CheckStatus
()
{
MS_TRACE
();
auto
lossPercentage
=
GetLossPercentage
();
if
(
lossPercentage
>=
MaxHealthLossPercentage
)
{
if
(
this
->
notifyStatus
||
this
->
healthy
)
{
MS_DEBUG_TAG
(
rtp
,
"rtp stream packet loss [ssrc:%"
PRIu32
", %.2f%%]"
,
GetSsrc
(),
lossPercentage
);
this
->
healthy
=
false
;
this
->
listener
->
OnRtpStreamUnhealthy
(
this
);
}
}
else
if
(
this
->
notifyStatus
||
!
this
->
healthy
)
{
this
->
healthy
=
true
;
this
->
listener
->
OnRtpStreamHealthy
(
this
);
}
this
->
notifyStatus
=
false
;
}
void
RtpStreamSend
::
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
)
{
MS_TRACE
();
...
...
worker/test/RTC/TestRtpMonitor.cpp
浏览文件 @
8dd72196
...
...
@@ -11,14 +11,14 @@ SCENARIO("RTP Monitor", "[rtp][monitor]")
class
TestRtpMonitorListener
:
public
RtpMonitor
::
Listener
{
public
:
virtual
void
On
Healthy
(
RTC
::
RtpMonitor
*
/*rtpMonitor*/
)
override
virtual
void
On
RtpMonitorHealthy
(
)
override
{
INFO
(
"OnHealthy"
);
this
->
healthyTriggered
=
true
;
}
virtual
void
On
Unhealthy
(
RTC
::
RtpMonitor
*
/*rtpMonitor*/
)
override
virtual
void
On
RtpMonitorUnhealthy
(
)
override
{
INFO
(
"OnUnhealthy"
);
...
...
worker/test/RTC/TestRtpStreamSend.cpp
浏览文件 @
8dd72196
...
...
@@ -11,13 +11,6 @@ using namespace RTC;
// Can retransmit up to 17 RTP packets.
static
std
::
vector
<
RtpPacket
*>
rtpRetransmissionContainer
(
18
);
class
RtpStreamSendListener
:
public
RtpStreamSend
::
Listener
{
public
:
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
/*rtpStream*/
){};
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
/*rtpStream*/
){};
}
rtpStreamSendListener
;
SCENARIO
(
"NACK and RTP packets retransmission"
,
"[rtp][rtcp]"
)
{
SECTION
(
"receive NACK and get retransmitted packets"
)
...
...
@@ -86,7 +79,7 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp]")
params
.
useNack
=
true
;
// Create a RtpStreamSend.
RtpStreamSend
*
stream
=
new
RtpStreamSend
(
&
rtpStreamSendListener
,
params
,
200
);
RtpStreamSend
*
stream
=
new
RtpStreamSend
(
params
,
200
);
// Receive all the packets in order into the stream.
stream
->
ReceivePacket
(
packet1
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论