Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
27f060bf
提交
27f060bf
authored
10月 10, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix naming on RtpStreamSend and RtpStreamRecv check methods
上级
66063670
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
116 行增加
和
124 行删除
+116
-124
Consumer.hpp
worker/include/RTC/Consumer.hpp
+2
-3
Producer.hpp
worker/include/RTC/Producer.hpp
+8
-9
RtpStream.hpp
worker/include/RTC/RtpStream.hpp
+5
-27
RtpStreamRecv.hpp
worker/include/RTC/RtpStreamRecv.hpp
+12
-2
RtpStreamSend.hpp
worker/include/RTC/RtpStreamSend.hpp
+19
-3
Consumer.cpp
worker/src/RTC/Consumer.cpp
+3
-10
Producer.cpp
worker/src/RTC/Producer.cpp
+39
-44
Router.cpp
worker/src/RTC/Router.cpp
+2
-2
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+11
-13
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+10
-6
RtpStreamSend.cpp
worker/src/RTC/RtpStreamSend.cpp
+5
-5
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
27f060bf
...
...
@@ -21,7 +21,7 @@
namespace
RTC
{
class
Consumer
:
public
RTC
::
RtpStream
::
Listener
class
Consumer
:
public
RTC
::
RtpStream
Send
::
Listener
{
public
:
Consumer
(
...
...
@@ -71,9 +71,8 @@ namespace RTC
void
SetEffectiveProfile
(
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
MayRunProbation
();
/* Pure virtual methods inherited from RTC::RtpStream::Listener. */
/* Pure virtual methods inherited from RTC::RtpStream
Send
::Listener. */
public
:
void
OnRtpStreamInactivity
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
27f060bf
...
...
@@ -72,7 +72,7 @@ namespace RTC
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
const
;
void
RequestKeyFrame
(
bool
force
=
false
);
const
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStream
*>&
Get
Healthy
Profiles
()
const
;
const
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStream
*>&
Get
Active
Profiles
()
const
;
private
:
void
FillHeaderExtensionIds
();
...
...
@@ -82,17 +82,16 @@ namespace RTC
void
ClearRtpStreams
();
void
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
;
RTC
::
RtpEncodingParameters
::
Profile
GetProfile
(
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
);
void
Add
Healthy
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
);
void
Remove
Healthy
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
);
void
Add
Active
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
);
void
Remove
Active
Profiles
(
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
OnRtpStreamInactivity
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamInactive
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamActive
(
RTC
::
RtpStream
*
rtpStream
)
override
;
/* Pure virtual methods inherited from Timer::Listener. */
public
:
...
...
@@ -114,7 +113,7 @@ namespace RTC
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
rtpStreams
;
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
mapRtxStreams
;
std
::
map
<
RTC
::
RtpStreamRecv
*
,
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>>
mapRtpStreamProfiles
;
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStream
*>
healthy
Profiles
;
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStream
*>
active
Profiles
;
Timer
*
keyFrameRequestBlockTimer
{
nullptr
};
// Others.
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
...
...
@@ -179,9 +178,9 @@ namespace RTC
}
inline
const
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStream
*>&
Producer
::
Get
Healthy
Profiles
()
const
Get
Active
Profiles
()
const
{
return
this
->
healthy
Profiles
;
return
this
->
active
Profiles
;
}
}
// namespace RTC
...
...
worker/include/RTC/RtpStream.hpp
浏览文件 @
27f060bf
...
...
@@ -12,15 +12,6 @@ namespace RTC
{
class
RtpStream
:
public
Timer
::
Listener
{
public
:
class
Listener
{
public
:
virtual
void
OnRtpStreamInactivity
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
};
public
:
struct
Params
{
...
...
@@ -35,7 +26,7 @@ namespace RTC
};
public
:
static
constexpr
uint16_t
Health
CheckPeriod
{
1000
};
static
constexpr
uint16_t
Status
CheckPeriod
{
1000
};
public
:
explicit
RtpStream
(
RTC
::
RtpStream
::
Params
&
params
);
...
...
@@ -49,9 +40,7 @@ namespace RTC
uint8_t
GetPayloadType
()
const
;
const
RTC
::
RtpCodecMimeType
&
GetMimeType
()
const
;
float
GetLossPercentage
()
const
;
bool
IsHealthy
()
const
;
void
SetUnhealthy
();
void
ResetHealthCheckTimer
(
uint16_t
timeout
=
HealthCheckPeriod
);
void
ResetStatusCheckTimer
(
uint16_t
timeout
=
StatusCheckPeriod
);
protected
:
bool
UpdateSeq
(
RTC
::
RtpPacket
*
packet
);
...
...
@@ -61,7 +50,7 @@ namespace RTC
/* Pure virtual methods that must be implemented by the subclass. */
protected
:
virtual
void
Check
Health
()
=
0
;
virtual
void
Check
Status
()
=
0
;
/* Pure virtual methods inherited from Timer::Listener. */
public
:
...
...
@@ -95,9 +84,8 @@ namespace RTC
// Others.
uint32_t
maxPacketTs
{
0
};
// Highest timestamp seen.
uint64_t
maxPacketMs
{
0
};
// When the packet with highest timestammp was seen.
Timer
*
healthCheckTimer
{
nullptr
};
bool
healthy
{
true
};
bool
notifyHealth
{
true
};
Timer
*
statusCheckTimer
{
nullptr
};
bool
notifyStatus
{
true
};
private
:
std
::
string
rtpStreamId
{};
...
...
@@ -124,16 +112,6 @@ namespace RTC
{
return
static_cast
<
float
>
(
this
->
fractionLost
)
*
100
/
256
;
}
inline
bool
RtpStream
::
IsHealthy
()
const
{
return
this
->
healthy
;
}
inline
void
RtpStream
::
SetUnhealthy
()
{
this
->
healthy
=
false
;
}
}
// namespace RTC
#endif
worker/include/RTC/RtpStreamRecv.hpp
浏览文件 @
27f060bf
...
...
@@ -11,12 +11,14 @@ namespace RTC
class
RtpStreamRecv
:
public
RtpStream
,
public
RTC
::
NackGenerator
::
Listener
{
public
:
class
Listener
:
public
RtpStream
::
Listener
class
Listener
{
public
:
virtual
void
OnRtpStreamRecvNackRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
=
0
;
virtual
void
OnRtpStreamRecvPliRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamInactive
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamActive
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
};
public
:
...
...
@@ -30,13 +32,14 @@ namespace RTC
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
void
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
);
void
RequestKeyFrame
();
bool
IsActive
()
const
;
private
:
void
CalculateJitter
(
uint32_t
rtpTimestamp
);
/* Pure virtual methods inherited from RtpStream. */
protected
:
virtual
void
Check
Health
()
override
;
virtual
void
Check
Status
()
override
;
/* Pure virtual methods inherited from RTC::NackGenerator. */
protected
:
...
...
@@ -61,7 +64,14 @@ namespace RTC
uint32_t
rtxSsrc
{
0
};
// Stats.
uint32_t
jitter
{
0
};
// Others.
bool
active
{
true
};
};
inline
bool
RtpStreamRecv
::
IsActive
()
const
{
return
this
->
active
;
}
}
// namespace RTC
#endif
worker/include/RTC/RtpStreamSend.hpp
浏览文件 @
27f060bf
...
...
@@ -11,6 +11,14 @@ 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
{
...
...
@@ -26,7 +34,7 @@ namespace RTC
};
public
:
RtpStreamSend
(
RTC
::
RtpStream
::
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
);
RtpStreamSend
(
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
);
~
RtpStreamSend
()
override
;
Json
::
Value
GetStats
()
override
;
...
...
@@ -39,22 +47,25 @@ namespace RTC
bool
HasRtx
()
const
;
void
RtxEncode
(
RtpPacket
*
packet
);
void
ClearRetransmissionBuffer
();
bool
IsHealthy
()
const
;
private
:
void
StorePacket
(
RTC
::
RtpPacket
*
packet
);
/* Pure virtual methods inherited from RtpStream. */
protected
:
void
Check
Health
()
override
;
void
Check
Status
()
override
;
private
:
// Passed by argument.
RTC
::
RtpStream
::
Listener
*
listener
{
nullptr
};
Listener
*
listener
{
nullptr
};
std
::
vector
<
StorageItem
>
storage
;
using
Buffer
=
std
::
list
<
BufferItem
>
;
Buffer
buffer
;
// Stats.
uint32_t
rtt
{
0
};
// Others.
bool
healthy
{
true
};
private
:
// Retransmittion related.
...
...
@@ -68,6 +79,11 @@ namespace RTC
{
return
this
->
hasRtx
;
}
inline
bool
RtpStreamSend
::
IsHealthy
()
const
{
return
this
->
healthy
;
}
}
// namespace RTC
#endif
worker/src/RTC/Consumer.cpp
浏览文件 @
27f060bf
...
...
@@ -307,7 +307,7 @@ namespace RTC
this
->
probingProfile
=
RtpEncodingParameters
::
Profile
::
NONE
;
// Reset the health check timer so this probation doesn't affect the effective profile.
this
->
rtpStream
->
Reset
Health
CheckTimer
();
this
->
rtpStream
->
Reset
Status
CheckTimer
();
return
;
}
...
...
@@ -699,13 +699,6 @@ namespace RTC
}
}
void
Consumer
::
OnRtpStreamInactivity
(
RtpStream
*
rtpStream
)
{
MS_TRACE
();
OnRtpStreamUnhealthy
(
rtpStream
);
}
void
Consumer
::
OnRtpStreamHealthy
(
RtpStream
*
rtpStream
)
{
MS_TRACE
();
...
...
@@ -789,7 +782,7 @@ namespace RTC
RequestKeyFrame
();
// We want to be notified about this new profile's health.
this
->
rtpStream
->
Reset
Health
CheckTimer
();
this
->
rtpStream
->
Reset
Status
CheckTimer
();
MS_DEBUG_TAG
(
rtp
,
...
...
@@ -1011,7 +1004,7 @@ namespace RTC
{
this
->
isProbing
=
true
;
this
->
probingProfile
=
newTargetProfile
;
this
->
rtpStream
->
Reset
Health
CheckTimer
();
this
->
rtpStream
->
Reset
Status
CheckTimer
();
MS_DEBUG_TAG
(
rtp
,
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
27f060bf
...
...
@@ -543,8 +543,8 @@ namespace RTC
// Add the stream to the profiles map.
this
->
mapRtpStreamProfiles
[
rtpStream
].
insert
(
profile
);
// Add new profile/s into
healthy
Profiles and notify the listener.
Add
Healthy
Profiles
(
rtpStream
);
// Add new profile/s into
active
Profiles and notify the listener.
Add
Active
Profiles
(
rtpStream
);
// Request a key frame since we may have lost the first packets of this stream.
RequestKeyFrame
(
true
);
...
...
@@ -554,8 +554,8 @@ namespace RTC
{
MS_TRACE
();
// Remove the profiles related to this stream from
healthy
Profiles and notify the listener.
Remove
Healthy
Profiles
(
rtpStream
);
// Remove the profiles related to this stream from
active
Profiles and notify the listener.
Remove
Active
Profiles
(
rtpStream
);
this
->
rtpStreams
.
erase
(
rtpStream
->
GetSsrc
());
...
...
@@ -609,7 +609,7 @@ namespace RTC
this
->
rtpStreams
.
clear
();
this
->
mapRtxStreams
.
clear
();
this
->
mapRtpStreamProfiles
.
clear
();
this
->
healthy
Profiles
.
clear
();
this
->
active
Profiles
.
clear
();
}
void
Producer
::
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
...
...
@@ -662,7 +662,7 @@ namespace RTC
MS_THROW_ERROR
(
"unknown RTP packet received [ssrc:%"
PRIu32
"]"
,
packet
->
GetSsrc
());
}
void
Producer
::
Add
Healthy
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
)
void
Producer
::
Add
Active
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
)
{
auto
&
profiles
=
this
->
mapRtpStreamProfiles
[
rtpStream
];
...
...
@@ -670,11 +670,11 @@ namespace RTC
for
(
auto
&
profile
:
profiles
)
{
MS_ASSERT
(
this
->
healthyProfiles
.
find
(
profile
)
==
this
->
healthy
Profiles
.
end
(),
this
->
activeProfiles
.
find
(
profile
)
==
this
->
active
Profiles
.
end
(),
"profile already in headltyProfiles set"
);
// Add the profile to the
healthy profiles set
.
this
->
healthy
Profiles
[
profile
]
=
rtpStream
;
// Add the profile to the
active profiles map
.
this
->
active
Profiles
[
profile
]
=
rtpStream
;
for
(
auto
&
listener
:
this
->
listeners
)
{
...
...
@@ -683,7 +683,7 @@ namespace RTC
}
}
void
Producer
::
Remove
Healthy
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
)
void
Producer
::
Remove
Active
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
)
{
auto
&
profiles
=
this
->
mapRtpStreamProfiles
[
rtpStream
];
...
...
@@ -691,11 +691,11 @@ namespace RTC
for
(
auto
&
profile
:
profiles
)
{
MS_ASSERT
(
this
->
healthyProfiles
.
find
(
profile
)
!=
this
->
healthy
Profiles
.
end
(),
this
->
activeProfiles
.
find
(
profile
)
!=
this
->
active
Profiles
.
end
(),
"profile not in headltyProfiles"
);
// Remove the profile from the
healthy profiles set
.
this
->
healthy
Profiles
.
erase
(
profile
);
// Remove the profile from the
active profiles map
.
this
->
active
Profiles
.
erase
(
profile
);
for
(
auto
&
listener
:
this
->
listeners
)
{
...
...
@@ -772,7 +772,7 @@ namespace RTC
rtpStream
->
pliCount
++
;
}
void
Producer
::
OnRtpStreamInactiv
ity
(
RTC
::
RtpStream
*
rtpStream
)
void
Producer
::
OnRtpStreamInactiv
e
(
RTC
::
RtpStream
*
rtpStream
)
{
MS_TRACE
();
...
...
@@ -782,18 +782,18 @@ namespace RTC
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamProfiles
.
end
(),
"stream not present in mapRtpStreamProfiles"
);
// Single
healthy
profile present. Ignore.
if
(
this
->
healthy
Profiles
.
size
()
==
1
)
// Single
active
profile present. Ignore.
if
(
this
->
active
Profiles
.
size
()
==
1
)
return
;
// Simulcast. Check whether any RTP is being received at all.
uint32_t
totalBitrate
=
0
;
uint64_t
now
=
DepLibUV
::
GetTime
();
for
(
auto
it
:
this
->
healthy
Profiles
)
for
(
auto
it
:
this
->
active
Profiles
)
{
auto
healthy
RtpStream
=
it
.
second
;
auto
ssrc
=
healthy
RtpStream
->
GetSsrc
();
auto
active
RtpStream
=
it
.
second
;
auto
ssrc
=
active
RtpStream
->
GetSsrc
();
totalBitrate
+=
this
->
rtpStreams
[
ssrc
]
->
GetRate
(
now
);
}
...
...
@@ -802,23 +802,22 @@ namespace RTC
if
(
totalBitrate
==
0
)
return
;
// Simulcast. Remove the stream from
healthy
profiles.
// Simulcast. Remove the stream from
active
profiles.
MS_DEBUG_TAG
(
rtp
,
"rtp inactivity detected [ssrc:%"
PRIu32
,
rtpStream
->
GetSsrc
());
rtpStream
->
SetUnhealthy
();
RemoveHealthyProfiles
(
rtpStreamRecv
);
RemoveActiveProfiles
(
rtpStreamRecv
);
// Reset
health check timer on every healthy
stream.
for
(
auto
it
:
this
->
healthy
Profiles
)
// Reset
stream check timer on every active
stream.
for
(
auto
it
:
this
->
active
Profiles
)
{
auto
healthy
RtpStream
=
it
.
second
;
auto
ssrc
=
healthy
RtpStream
->
GetSsrc
();
auto
active
RtpStream
=
it
.
second
;
auto
ssrc
=
active
RtpStream
->
GetSsrc
();
this
->
rtpStreams
[
ssrc
]
->
Reset
HealthCheckTimer
(
RTC
::
RtpStream
::
Health
CheckPeriod
*
2
);
this
->
rtpStreams
[
ssrc
]
->
Reset
StatusCheckTimer
(
RTC
::
RtpStream
::
Status
CheckPeriod
*
2
);
}
}
void
Producer
::
OnRtpStream
Healthy
(
RTC
::
RtpStream
*
rtpStream
)
void
Producer
::
OnRtpStream
Active
(
RTC
::
RtpStream
*
rtpStream
)
{
MS_TRACE
();
...
...
@@ -828,26 +827,22 @@ namespace RTC
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
active
[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
=
dynamic_cast
<
RtpStreamRecv
*>
(
rtpStream
);
// Check whether the stream is active.
const
RtpStream
*
activeRtpStream
=
nullptr
;
MS_ASSERT
(
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamProfiles
.
end
(),
"stream not present in mapRtpStreamProfiles"
)
;
for
(
auto
it
:
this
->
activeProfiles
)
{
activeRtpStream
=
it
.
second
;
MS_DEBUG_TAG
(
rtp
,
"stream is now unhealthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
if
(
activeRtpStream
!=
nullptr
)
break
;
}
// Remove the profiles related to this stream from healthyProfiles and notify the listener.
RemoveHealthyProfiles
(
rtpStreamRecv
);
// Add the profiles related to this stream into activeProfiles and notify the listener.
if
(
!
activeRtpStream
)
AddActiveProfiles
(
rtpStreamRecv
);
}
inline
void
Producer
::
OnTimer
(
Timer
*
timer
)
...
...
worker/src/RTC/Router.cpp
浏览文件 @
27f060bf
...
...
@@ -514,10 +514,10 @@ namespace RTC
// Add us as listener.
consumer
->
AddListener
(
this
);
auto
healthyProfiles
=
producer
->
GetHealthy
Profiles
();
auto
activeProfiles
=
producer
->
GetActive
Profiles
();
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStream
*>::
reverse_iterator
it
;
for
(
it
=
healthyProfiles
.
rbegin
();
it
!=
healthy
Profiles
.
rend
();
++
it
)
for
(
it
=
activeProfiles
.
rbegin
();
it
!=
active
Profiles
.
rend
();
++
it
)
{
auto
profile
=
it
->
first
;
auto
stats
=
it
->
second
;
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
27f060bf
...
...
@@ -24,19 +24,19 @@ namespace RTC
// Generate a random rtpStreamId.
this
->
rtpStreamId
=
Utils
::
Crypto
::
GetRandomString
(
16
);
// Set the
health
check timer.
this
->
health
CheckTimer
=
new
Timer
(
this
);
// Set the
status
check timer.
this
->
status
CheckTimer
=
new
Timer
(
this
);
// Run the timer.
this
->
healthCheckTimer
->
Start
(
HealthCheckPeriod
,
Health
CheckPeriod
);
this
->
statusCheckTimer
->
Start
(
StatusCheckPeriod
,
Status
CheckPeriod
);
}
RtpStream
::~
RtpStream
()
{
MS_TRACE
();
// Close the
health
check timer.
this
->
health
CheckTimer
->
Destroy
();
// Close the
status
check timer.
this
->
status
CheckTimer
->
Destroy
();
}
Json
::
Value
RtpStream
::
ToJson
()
...
...
@@ -61,7 +61,6 @@ namespace RTC
static
const
Json
::
StaticString
JsonStringSsrc
{
"ssrc"
};
static
const
Json
::
StaticString
JsonStringMediaType
{
"mediaType"
};
static
const
Json
::
StaticString
JsonStringMimeType
{
"mimeType"
};
static
const
Json
::
StaticString
JsonStringHealthy
{
"healthy"
};
static
const
Json
::
StaticString
JsonStringPacketCount
{
"packetCount"
};
static
const
Json
::
StaticString
JsonStringByteCount
{
"byteCount"
};
static
const
Json
::
StaticString
JsonStringBitRate
{
"bitrate"
};
...
...
@@ -82,7 +81,6 @@ namespace RTC
json
[
JsonStringSsrc
]
=
Json
::
UInt
{
this
->
params
.
ssrc
};
json
[
JsonStringMediaType
]
=
RtpCodecMimeType
::
type2String
[
this
->
params
.
mimeType
.
type
];
json
[
JsonStringMimeType
]
=
this
->
params
.
mimeType
.
ToString
();
json
[
JsonStringHealthy
]
=
this
->
healthy
?
"true"
:
"false"
;
json
[
JsonStringPacketCount
]
=
static_cast
<
Json
::
UInt
>
(
this
->
transmissionCounter
.
GetPacketCount
());
json
[
JsonStringByteCount
]
=
static_cast
<
Json
::
UInt
>
(
this
->
transmissionCounter
.
GetBytes
());
json
[
JsonStringBitRate
]
=
Json
::
UInt
{
this
->
transmissionCounter
.
GetRate
(
now
)
};
...
...
@@ -143,11 +141,11 @@ namespace RTC
return
this
->
transmissionCounter
.
GetRate
(
now
);
}
void
RtpStream
::
Reset
Health
CheckTimer
(
uint16_t
timeout
)
void
RtpStream
::
Reset
Status
CheckTimer
(
uint16_t
timeout
)
{
// Notify about
next health status
.
this
->
notify
Health
=
true
;
this
->
healthCheckTimer
->
Start
(
timeout
,
Health
CheckPeriod
);
// Notify about
status on next check
.
this
->
notify
Status
=
true
;
this
->
statusCheckTimer
->
Start
(
timeout
,
Status
CheckPeriod
);
}
void
RtpStream
::
InitSeq
(
uint16_t
seq
)
...
...
@@ -253,9 +251,9 @@ namespace RTC
{
MS_TRACE
();
if
(
timer
==
this
->
health
CheckTimer
)
if
(
timer
==
this
->
status
CheckTimer
)
{
this
->
Check
Health
();
this
->
Check
Status
();
}
}
}
// namespace RTC
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
27f060bf
...
...
@@ -227,20 +227,24 @@ namespace RTC
this
->
jitter
+=
(
1.
/
16.
)
*
(
static_cast
<
double
>
(
d
)
-
this
->
jitter
);
}
void
RtpStreamRecv
::
Check
Health
()
void
RtpStreamRecv
::
Check
Status
()
{
MS_TRACE
();
auto
now
=
DepLibUV
::
GetTime
();
if
(
this
->
transmissionCounter
.
GetRate
(
now
)
==
0
&&
this
->
healthy
)
if
(
this
->
transmissionCounter
.
GetRate
(
now
)
==
0
)
{
this
->
listener
->
OnRtpStreamInactivity
(
this
);
if
(
this
->
active
)
{
this
->
active
=
false
;
this
->
listener
->
OnRtpStreamInactive
(
this
);
}
}
else
if
(
!
this
->
healthy
)
else
if
(
!
this
->
active
)
{
this
->
healthy
=
true
;
this
->
listener
->
OnRtpStream
Healthy
(
this
);
this
->
active
=
true
;
this
->
listener
->
OnRtpStream
Active
(
this
);
}
}
...
...
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
27f060bf
...
...
@@ -20,7 +20,7 @@ namespace RTC
/* Instance methods. */
RtpStreamSend
::
RtpStreamSend
(
RTC
::
RtpStream
::
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
)
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
)
:
RtpStream
::
RtpStream
(
params
),
listener
(
listener
),
storage
(
bufferSize
)
{
MS_TRACE
();
...
...
@@ -398,7 +398,7 @@ namespace RTC
(
*
newBufferIt
).
packet
=
packet
->
Clone
(
store
);
}
void
RtpStreamSend
::
Check
Health
()
void
RtpStreamSend
::
Check
Status
()
{
MS_TRACE
();
...
...
@@ -408,19 +408,19 @@ namespace RTC
{
MS_DEBUG_TAG
(
rtp
,
"last period loss percentage: %.2f"
,
lossPercentage
);
if
(
this
->
notify
Health
||
this
->
healthy
)
if
(
this
->
notify
Status
||
this
->
healthy
)
{
this
->
healthy
=
false
;
this
->
listener
->
OnRtpStreamUnhealthy
(
this
);
}
}
else
if
(
this
->
notify
Health
||
!
this
->
healthy
)
else
if
(
this
->
notify
Status
||
!
this
->
healthy
)
{
this
->
healthy
=
true
;
this
->
listener
->
OnRtpStreamHealthy
(
this
);
}
this
->
notify
Health
=
false
;
this
->
notify
Status
=
false
;
}
void
RtpStreamSend
::
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论