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 个修改的文件
包含
117 行增加
和
85 行删除
+117
-85
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
+89
-53
Router.cpp
worker/src/RTC/Router.cpp
+1
-1
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+1
-6
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
cbb4daf0
...
@@ -66,7 +66,9 @@ namespace RTC
...
@@ -66,7 +66,9 @@ namespace RTC
/* Pure virtual methods inherited from RTC::RtpStream::Listener. */
/* Pure virtual methods inherited from RTC::RtpStream::Listener. */
public
:
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
:
public
:
// Passed by argument.
// Passed by argument.
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
cbb4daf0
...
@@ -70,7 +70,7 @@ namespace RTC
...
@@ -70,7 +70,7 @@ namespace RTC
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
const
;
void
RequestKeyFrame
(
bool
force
=
false
);
void
RequestKeyFrame
(
bool
force
=
false
);
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
Get
Profiles
()
const
;
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
&
GetHealthy
Profiles
()
const
;
private
:
private
:
void
FillHeaderExtensionIds
();
void
FillHeaderExtensionIds
();
...
@@ -80,13 +80,17 @@ namespace RTC
...
@@ -80,13 +80,17 @@ namespace RTC
void
ClearRtpStreams
();
void
ClearRtpStreams
();
void
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
;
void
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
;
RTC
::
RtpEncodingParameters
::
Profile
GetProfile
(
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
);
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. */
/* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */
public
:
public
:
void
OnRtpStreamRecvNackRequired
(
void
OnRtpStreamRecvNackRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
override
;
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
override
;
void
OnRtpStreamRecvPliRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
)
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. */
/* Pure virtual methods inherited from Timer::Listener. */
public
:
public
:
...
@@ -107,7 +111,8 @@ namespace RTC
...
@@ -107,7 +111,8 @@ namespace RTC
// Allocated by this.
// Allocated by this.
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
rtpStreams
;
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
rtpStreams
;
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
mapRtxStreams
;
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
};
Timer
*
keyFrameRequestBlockTimer
{
nullptr
};
// Others.
// Others.
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
...
@@ -159,24 +164,9 @@ namespace RTC
...
@@ -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
;
return
this
->
healthyProfiles
;
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
;
}
}
}
// namespace RTC
}
// namespace RTC
...
...
worker/include/RTC/RtpStream.hpp
浏览文件 @
cbb4daf0
...
@@ -16,7 +16,9 @@ namespace RTC
...
@@ -16,7 +16,9 @@ namespace RTC
class
Listener
class
Listener
{
{
public
:
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
:
public
:
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
cbb4daf0
...
@@ -544,12 +544,19 @@ namespace RTC
...
@@ -544,12 +544,19 @@ namespace RTC
}
}
}
}
void
Consumer
::
OnRtpStream
HealthReport
(
RtpStream
*
stream
,
bool
healthy
)
void
Consumer
::
OnRtpStream
Died
(
RtpStream
*
/*stream*/
)
{
{
MS_TRACE
();
MS_TRACE
();
}
if
(
!
IsEnabled
())
void
Consumer
::
OnRtpStreamHealthy
(
RtpStream
*
/*stream*/
)
return
;
{
MS_TRACE
();
}
void
Consumer
::
OnRtpStreamUnhealthy
(
RtpStream
*
/*stream*/
)
{
MS_TRACE
();
}
}
void
Consumer
::
FillSupportedCodecPayloadTypes
()
void
Consumer
::
FillSupportedCodecPayloadTypes
()
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
cbb4daf0
...
@@ -50,7 +50,7 @@ namespace RTC
...
@@ -50,7 +50,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
this
->
p
rofiles
.
clear
();
this
->
mapRtpStreamP
rofiles
.
clear
();
ClearRtpStreams
();
ClearRtpStreams
();
}
}
...
@@ -507,20 +507,14 @@ namespace RTC
...
@@ -507,20 +507,14 @@ namespace RTC
this
->
mapRtxStreams
[
encoding
.
rtx
.
ssrc
]
=
rtpStream
;
this
->
mapRtxStreams
[
encoding
.
rtx
.
ssrc
]
=
rtpStream
;
}
}
// Enter the stream into the profiles map.
// TODO: For SVC, the dependencyEncodingIds must be checked and their respective profiles must be also added into mapRtpStreamProfiles.
// NOTE: This is specific to simulcast with no temporal layers.
auto
profile
=
encoding
.
profile
;
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.
// Add new profile/s into healthyProfiles and notify the listener.
if
(
profile
!=
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
AddHealthyProfiles
(
rtpStream
);
{
for
(
auto
&
listener
:
this
->
listeners
)
{
listener
->
OnProducerProfileEnabled
(
this
,
profile
);
}
}
// Request a key frame since we may have lost the first packets of this stream.
// Request a key frame since we may have lost the first packets of this stream.
RequestKeyFrame
(
true
);
RequestKeyFrame
(
true
);
...
@@ -530,20 +524,8 @@ namespace RTC
...
@@ -530,20 +524,8 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
auto
&
profiles
=
this
->
profiles
[
rtpStream
];
// Remove the profiles related to this stream from healthyProfiles and notify the listener.
RemoveHealthyProfiles
(
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
);
}
}
this
->
rtpStreams
.
erase
(
rtpStream
->
GetSsrc
());
this
->
rtpStreams
.
erase
(
rtpStream
->
GetSsrc
());
...
@@ -560,7 +542,7 @@ namespace RTC
...
@@ -560,7 +542,7 @@ namespace RTC
}
}
}
}
this
->
p
rofiles
.
erase
(
rtpStream
);
this
->
mapRtpStreamP
rofiles
.
erase
(
rtpStream
);
delete
rtpStream
;
delete
rtpStream
;
}
}
...
@@ -577,7 +559,7 @@ namespace RTC
...
@@ -577,7 +559,7 @@ namespace RTC
}
}
// Notify about all profiles being disabled.
// Notify about all profiles being disabled.
for
(
auto
&
kv
:
this
->
p
rofiles
)
for
(
auto
&
kv
:
this
->
mapRtpStreamP
rofiles
)
{
{
auto
&
profiles
=
kv
.
second
;
auto
&
profiles
=
kv
.
second
;
...
@@ -596,7 +578,8 @@ namespace RTC
...
@@ -596,7 +578,8 @@ namespace RTC
this
->
rtpStreams
.
clear
();
this
->
rtpStreams
.
clear
();
this
->
mapRtxStreams
.
clear
();
this
->
mapRtxStreams
.
clear
();
this
->
profiles
.
clear
();
this
->
mapRtpStreamProfiles
.
clear
();
this
->
healthyProfiles
.
clear
();
}
}
void
Producer
::
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
void
Producer
::
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
...
@@ -638,9 +621,9 @@ namespace RTC
...
@@ -638,9 +621,9 @@ namespace RTC
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
)
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
)
{
{
// The stream is already mapped to a profile.
// 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
;
auto
profile
=
*
it
;
return
profile
;
return
profile
;
...
@@ -649,6 +632,52 @@ namespace RTC
...
@@ -649,6 +632,52 @@ namespace RTC
MS_THROW_ERROR
(
"unknown RTP packet received [ssrc:%"
PRIu32
"]"
,
packet
->
GetSsrc
());
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
(
void
Producer
::
OnRtpStreamRecvNackRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
{
{
...
@@ -713,45 +742,52 @@ namespace RTC
...
@@ -713,45 +742,52 @@ namespace RTC
this
->
transport
->
SendRtcpPacket
(
&
packet
);
this
->
transport
->
SendRtcpPacket
(
&
packet
);
}
}
void
Producer
::
OnRtpStream
HealthReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
healthy
)
void
Producer
::
OnRtpStream
Died
(
RTC
::
RtpStream
*
rtpStream
)
{
{
MS_TRACE
();
MS_TRACE
();
auto
rtpStreamRecv
=
static_cast
<
RtpStreamRecv
*>
(
rtpStream
);
auto
rtpStreamRecv
=
static_cast
<
RtpStreamRecv
*>
(
rtpStream
);
MS_ASSERT
(
MS_ASSERT
(
this
->
profiles
.
find
(
rtpStreamRecv
)
!=
this
->
p
rofiles
.
end
(),
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamP
rofiles
.
end
(),
"stream not present in
profiles map
"
);
"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.
// Completely destroy the stream.
ClearRtpStream
(
rtpStreamRecv
);
ClearRtpStream
(
rtpStreamRecv
);
}
}
// The stream has transitioned to healthy.
void
Producer
::
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
if
(
!
rtpStream
->
IsHealthy
()
&&
healthy
)
{
{
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 healthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
MS_DEBUG_TAG
(
rtp
,
"stream is now healthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
// Notify about the profiles being disabled.
// Add the profiles related to this stream into healthyProfiles and notify the listener.
for
(
auto
&
profile
:
profiles
)
AddHealthyProfiles
(
rtpStreamRecv
);
{
}
// Don't announce default profile, but just those for simulcast/SVC.
if
(
profile
==
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
break
;
for
(
auto
&
listener
:
this
->
listeners
)
void
Producer
::
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
{
{
listener
->
OnProducerProfileEnabled
(
this
,
profile
);
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
)
inline
void
Producer
::
OnTimer
(
Timer
*
timer
)
...
...
worker/src/RTC/Router.cpp
浏览文件 @
cbb4daf0
...
@@ -454,7 +454,7 @@ namespace RTC
...
@@ -454,7 +454,7 @@ namespace RTC
// Add us as listener.
// Add us as listener.
consumer
->
AddListener
(
this
);
consumer
->
AddListener
(
this
);
auto
profiles
=
producer
->
GetProfiles
();
auto
profiles
=
producer
->
Get
Healthy
Profiles
();
std
::
set
<
RtpEncodingParameters
::
Profile
>::
reverse_iterator
it
;
std
::
set
<
RtpEncodingParameters
::
Profile
>::
reverse_iterator
it
;
for
(
it
=
profiles
.
rbegin
();
it
!=
profiles
.
rend
();
++
it
)
for
(
it
=
profiles
.
rbegin
();
it
!=
profiles
.
rend
();
++
it
)
...
...
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
cbb4daf0
...
@@ -211,14 +211,9 @@ namespace RTC
...
@@ -211,14 +211,9 @@ namespace RTC
void
RtpStreamRecv
::
CheckHealth
()
void
RtpStreamRecv
::
CheckHealth
()
{
{
auto
now
=
DepLibUV
::
GetTime
();
auto
now
=
DepLibUV
::
GetTime
();
bool
healthy
=
true
;
if
(
this
->
counter
.
GetRate
(
now
)
==
0
)
if
(
this
->
counter
.
GetRate
(
now
)
==
0
)
healthy
=
false
;
this
->
listener
->
OnRtpStreamDied
(
this
);
// NOTE: Update the 'healthy' value after notification.
this
->
listener
->
OnRtpStreamHealthReport
(
this
,
healthy
);
this
->
healthy
=
healthy
;
}
}
void
RtpStreamRecv
::
OnNackGeneratorNackRequired
(
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
void
RtpStreamRecv
::
OnNackGeneratorNackRequired
(
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论