Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
cbb4daf0
提交
cbb4daf0
authored
9月 18, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RtpStream: multiple health status callbacks: 'died', 'healthy', 'unhealthy'
上级
4584fad8
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
123 行增加
和
91 行删除
+123
-91
Consumer.hpp
worker/include/RTC/Consumer.hpp
+3
-1
Producer.hpp
worker/include/RTC/Producer.hpp
+10
-20
RtpStream.hpp
worker/include/RTC/RtpStream.hpp
+3
-1
Consumer.cpp
worker/src/RTC/Consumer.cpp
+10
-3
Producer.cpp
worker/src/RTC/Producer.cpp
+94
-58
Router.cpp
worker/src/RTC/Router.cpp
+1
-1
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+2
-7
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
cbb4daf0
...
...
@@ -66,7 +66,9 @@ namespace RTC
/* Pure virtual methods inherited from RTC::RtpStream::Listener. */
public
:
void
OnRtpStreamHealthReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
healthy
)
override
;
void
OnRtpStreamDied
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
public
:
// Passed by argument.
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
cbb4daf0
...
...
@@ -70,7 +70,7 @@ namespace RTC
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
const
;
void
RequestKeyFrame
(
bool
force
=
false
);
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
Get
Profiles
()
const
;
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
&
GetHealthy
Profiles
()
const
;
private
:
void
FillHeaderExtensionIds
();
...
...
@@ -80,13 +80,17 @@ namespace RTC
void
ClearRtpStreams
();
void
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
;
RTC
::
RtpEncodingParameters
::
Profile
GetProfile
(
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
);
void
AddHealthyProfiles
(
RTC
::
RtpStreamRecv
*
rtpStream
);
void
RemoveHealthyProfiles
(
RTC
::
RtpStreamRecv
*
rtpStream
);
/* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */
public
:
void
OnRtpStreamRecvNackRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
override
;
void
OnRtpStreamRecvPliRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
)
override
;
void
OnRtpStreamHealthReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
healthy
)
override
;
void
OnRtpStreamDied
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
/* Pure virtual methods inherited from Timer::Listener. */
public
:
...
...
@@ -107,7 +111,8 @@ namespace RTC
// Allocated by this.
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
rtpStreams
;
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
mapRtxStreams
;
std
::
map
<
RTC
::
RtpStreamRecv
*
,
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>>
profiles
;
std
::
map
<
RTC
::
RtpStreamRecv
*
,
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>>
mapRtpStreamProfiles
;
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
healthyProfiles
;
Timer
*
keyFrameRequestBlockTimer
{
nullptr
};
// Others.
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
...
...
@@ -159,24 +164,9 @@ namespace RTC
}
}
inline
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
Producer
::
Get
Profiles
()
const
inline
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
&
Producer
::
GetHealthy
Profiles
()
const
{
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
profiles
;
for
(
const
auto
&
it
:
this
->
profiles
)
{
for
(
const
auto
&
it2
:
it
.
second
)
{
auto
profile
=
it2
;
if
(
profile
==
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
break
;
profiles
.
insert
(
profile
);
}
}
return
profiles
;
return
this
->
healthyProfiles
;
}
}
// namespace RTC
...
...
worker/include/RTC/RtpStream.hpp
浏览文件 @
cbb4daf0
...
...
@@ -16,7 +16,9 @@ namespace RTC
class
Listener
{
public
:
virtual
void
OnRtpStreamHealthReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
healthy
)
=
0
;
virtual
void
OnRtpStreamDied
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
};
public
:
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
cbb4daf0
...
...
@@ -544,12 +544,19 @@ namespace RTC
}
}
void
Consumer
::
OnRtpStream
HealthReport
(
RtpStream
*
stream
,
bool
healthy
)
void
Consumer
::
OnRtpStream
Died
(
RtpStream
*
/*stream*/
)
{
MS_TRACE
();
}
if
(
!
IsEnabled
())
return
;
void
Consumer
::
OnRtpStreamHealthy
(
RtpStream
*
/*stream*/
)
{
MS_TRACE
();
}
void
Consumer
::
OnRtpStreamUnhealthy
(
RtpStream
*
/*stream*/
)
{
MS_TRACE
();
}
void
Consumer
::
FillSupportedCodecPayloadTypes
()
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
cbb4daf0
...
...
@@ -50,7 +50,7 @@ namespace RTC
{
MS_TRACE
();
this
->
p
rofiles
.
clear
();
this
->
mapRtpStreamP
rofiles
.
clear
();
ClearRtpStreams
();
}
...
...
@@ -507,20 +507,14 @@ namespace RTC
this
->
mapRtxStreams
[
encoding
.
rtx
.
ssrc
]
=
rtpStream
;
}
// Enter the stream into the profiles map.
// NOTE: This is specific to simulcast with no temporal layers.
// TODO: For SVC, the dependencyEncodingIds must be checked and their respective profiles must be also added into mapRtpStreamProfiles.
auto
profile
=
encoding
.
profile
;
this
->
profiles
[
rtpStream
].
insert
(
profile
);
// Add the stream to the profiles map.
this
->
mapRtpStreamProfiles
[
rtpStream
].
insert
(
profile
);
// Don't announce default profile, but just those for simulcast/SVC.
if
(
profile
!=
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
{
for
(
auto
&
listener
:
this
->
listeners
)
{
listener
->
OnProducerProfileEnabled
(
this
,
profile
);
}
}
// Add new profile/s into healthyProfiles and notify the listener.
AddHealthyProfiles
(
rtpStream
);
// Request a key frame since we may have lost the first packets of this stream.
RequestKeyFrame
(
true
);
...
...
@@ -530,20 +524,8 @@ namespace RTC
{
MS_TRACE
();
auto
&
profiles
=
this
->
profiles
[
rtpStream
];
// Notify about the profiles being disabled.
for
(
auto
&
profile
:
profiles
)
{
// Don't announce default profile, but just those for simulcast/SVC.
if
(
profile
==
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
break
;
for
(
auto
&
listener
:
this
->
listeners
)
{
listener
->
OnProducerProfileDisabled
(
this
,
profile
);
}
}
// Remove the profiles related to this stream from healthyProfiles and notify the listener.
RemoveHealthyProfiles
(
rtpStream
);
this
->
rtpStreams
.
erase
(
rtpStream
->
GetSsrc
());
...
...
@@ -560,7 +542,7 @@ namespace RTC
}
}
this
->
p
rofiles
.
erase
(
rtpStream
);
this
->
mapRtpStreamP
rofiles
.
erase
(
rtpStream
);
delete
rtpStream
;
}
...
...
@@ -577,7 +559,7 @@ namespace RTC
}
// Notify about all profiles being disabled.
for
(
auto
&
kv
:
this
->
p
rofiles
)
for
(
auto
&
kv
:
this
->
mapRtpStreamP
rofiles
)
{
auto
&
profiles
=
kv
.
second
;
...
...
@@ -596,7 +578,8 @@ namespace RTC
this
->
rtpStreams
.
clear
();
this
->
mapRtxStreams
.
clear
();
this
->
profiles
.
clear
();
this
->
mapRtpStreamProfiles
.
clear
();
this
->
healthyProfiles
.
clear
();
}
void
Producer
::
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
...
...
@@ -638,9 +621,9 @@ namespace RTC
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
)
{
// The stream is already mapped to a profile.
if
(
this
->
profiles
.
find
(
rtpStream
)
!=
this
->
p
rofiles
.
end
())
if
(
this
->
mapRtpStreamProfiles
.
find
(
rtpStream
)
!=
this
->
mapRtpStreamP
rofiles
.
end
())
{
auto
it
=
this
->
p
rofiles
[
rtpStream
].
begin
();
auto
it
=
this
->
mapRtpStreamP
rofiles
[
rtpStream
].
begin
();
auto
profile
=
*
it
;
return
profile
;
...
...
@@ -649,6 +632,52 @@ namespace RTC
MS_THROW_ERROR
(
"unknown RTP packet received [ssrc:%"
PRIu32
"]"
,
packet
->
GetSsrc
());
}
void
Producer
::
AddHealthyProfiles
(
RTC
::
RtpStreamRecv
*
rtpStream
)
{
auto
&
profiles
=
this
->
mapRtpStreamProfiles
[
rtpStream
];
// Notify about the profiles being enabled.
for
(
auto
&
profile
:
profiles
)
{
// Don't announce default profile, but just those for simulcast/SVC.
if
(
profile
==
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
break
;
// Add the profile to the healthy profiles set.
const
auto
&
result
=
this
->
healthyProfiles
.
insert
(
profile
);
bool
profileExisted
=
!
result
.
second
;
MS_ASSERT
(
!
profileExisted
,
"profile already in headltyProfiles set"
);
for
(
auto
&
listener
:
this
->
listeners
)
{
listener
->
OnProducerProfileEnabled
(
this
,
profile
);
}
}
}
void
Producer
::
RemoveHealthyProfiles
(
RTC
::
RtpStreamRecv
*
rtpStream
)
{
auto
&
profiles
=
this
->
mapRtpStreamProfiles
[
rtpStream
];
// Notify about the profiles being disabled.
for
(
auto
&
profile
:
profiles
)
{
// Don't announce default profile, but just those for simulcast/SVC.
if
(
profile
==
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
break
;
// Remove the profile from the healthy profiles set.
auto
result
=
this
->
healthyProfiles
.
erase
(
profile
);
bool
profileExisted
=
(
result
==
1
);
MS_ASSERT
(
profileExisted
,
"profile not present in headltyProfiles set"
);
for
(
auto
&
listener
:
this
->
listeners
)
{
listener
->
OnProducerProfileDisabled
(
this
,
profile
);
}
}
}
void
Producer
::
OnRtpStreamRecvNackRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
{
...
...
@@ -713,45 +742,52 @@ namespace RTC
this
->
transport
->
SendRtcpPacket
(
&
packet
);
}
void
Producer
::
OnRtpStream
HealthReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
healthy
)
void
Producer
::
OnRtpStream
Died
(
RTC
::
RtpStream
*
rtpStream
)
{
MS_TRACE
();
auto
rtpStreamRecv
=
static_cast
<
RtpStreamRecv
*>
(
rtpStream
);
MS_ASSERT
(
this
->
profiles
.
find
(
rtpStreamRecv
)
!=
this
->
p
rofiles
.
end
(),
"stream not present in
profiles map
"
);
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamP
rofiles
.
end
(),
"stream not present in
mapRtpStreamProfiles
"
);
auto
&
profiles
=
this
->
profiles
[
rtpStreamRecv
]
;
MS_DEBUG_TAG
(
rtp
,
"stream is dead [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
())
;
// The stream has transitioned to non healthy.
if
(
rtpStream
->
IsHealthy
()
&&
!
healthy
)
{
MS_DEBUG_TAG
(
rtp
,
"stream is now unhealthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
// Completely destroy the stream.
ClearRtpStream
(
rtpStreamRecv
);
}
// Completely destroy the stream.
ClearRtpStream
(
rtpStreamRecv
);
}
void
Producer
::
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
{
MS_TRACE
();
// The stream has transitioned to healthy.
if
(
!
rtpStream
->
IsHealthy
()
&&
healthy
)
{
MS_DEBUG_TAG
(
rtp
,
"stream is now healthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
auto
rtpStreamRecv
=
static_cast
<
RtpStreamRecv
*>
(
rtpStream
);
// Notify about the profiles being disabled.
for
(
auto
&
profile
:
profiles
)
{
// Don't announce default profile, but just those for simulcast/SVC.
if
(
profile
==
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
break
;
MS_ASSERT
(
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamProfiles
.
end
(),
"stream not present in mapRtpStreamProfiles"
);
for
(
auto
&
listener
:
this
->
listeners
)
{
listener
->
OnProducerProfileEnabled
(
this
,
profile
);
}
}
}
MS_DEBUG_TAG
(
rtp
,
"stream is now healthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
// Add the profiles related to this stream into healthyProfiles and notify the listener.
AddHealthyProfiles
(
rtpStreamRecv
);
}
void
Producer
::
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
{
MS_TRACE
();
auto
rtpStreamRecv
=
static_cast
<
RtpStreamRecv
*>
(
rtpStream
);
MS_ASSERT
(
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamProfiles
.
end
(),
"stream not present in mapRtpStreamProfiles"
);
MS_DEBUG_TAG
(
rtp
,
"stream is now unhealthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
// Remove the profiles related to this stream from healthyProfiles and notify the listener.
RemoveHealthyProfiles
(
rtpStreamRecv
);
}
inline
void
Producer
::
OnTimer
(
Timer
*
timer
)
...
...
worker/src/RTC/Router.cpp
浏览文件 @
cbb4daf0
...
...
@@ -454,7 +454,7 @@ namespace RTC
// Add us as listener.
consumer
->
AddListener
(
this
);
auto
profiles
=
producer
->
GetProfiles
();
auto
profiles
=
producer
->
Get
Healthy
Profiles
();
std
::
set
<
RtpEncodingParameters
::
Profile
>::
reverse_iterator
it
;
for
(
it
=
profiles
.
rbegin
();
it
!=
profiles
.
rend
();
++
it
)
...
...
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
cbb4daf0
...
...
@@ -210,15 +210,10 @@ namespace RTC
void
RtpStreamRecv
::
CheckHealth
()
{
auto
now
=
DepLibUV
::
GetTime
();
bool
healthy
=
true
;
auto
now
=
DepLibUV
::
GetTime
();
if
(
this
->
counter
.
GetRate
(
now
)
==
0
)
healthy
=
false
;
// NOTE: Update the 'healthy' value after notification.
this
->
listener
->
OnRtpStreamHealthReport
(
this
,
healthy
);
this
->
healthy
=
healthy
;
this
->
listener
->
OnRtpStreamDied
(
this
);
}
void
RtpStreamRecv
::
OnNackGeneratorNackRequired
(
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论