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 个修改的文件
包含
115 行增加
和
123 行删除
+115
-123
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
+38
-43
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 @@
...
@@ -21,7 +21,7 @@
namespace
RTC
namespace
RTC
{
{
class
Consumer
:
public
RTC
::
RtpStream
::
Listener
class
Consumer
:
public
RTC
::
RtpStream
Send
::
Listener
{
{
public
:
public
:
Consumer
(
Consumer
(
...
@@ -71,9 +71,8 @@ namespace RTC
...
@@ -71,9 +71,8 @@ namespace RTC
void
SetEffectiveProfile
(
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
SetEffectiveProfile
(
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
MayRunProbation
();
void
MayRunProbation
();
/* Pure virtual methods inherited from RTC::RtpStream::Listener. */
/* Pure virtual methods inherited from RTC::RtpStream
Send
::Listener. */
public
:
public
:
void
OnRtpStreamInactivity
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
27f060bf
...
@@ -72,7 +72,7 @@ namespace RTC
...
@@ -72,7 +72,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
::
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
:
private
:
void
FillHeaderExtensionIds
();
void
FillHeaderExtensionIds
();
...
@@ -82,17 +82,16 @@ namespace RTC
...
@@ -82,17 +82,16 @@ 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
Add
Healthy
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
);
void
Add
Active
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
);
void
Remove
Healthy
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
);
void
Remove
Active
Profiles
(
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
OnRtpStreamInactivity
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamInactive
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
override
;
void
OnRtpStreamActive
(
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
:
...
@@ -114,7 +113,7 @@ namespace RTC
...
@@ -114,7 +113,7 @@ namespace RTC
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
>>
mapRtpStreamProfiles
;
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
};
Timer
*
keyFrameRequestBlockTimer
{
nullptr
};
// Others.
// Others.
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
...
@@ -179,9 +178,9 @@ namespace RTC
...
@@ -179,9 +178,9 @@ namespace RTC
}
}
inline
const
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStream
*>&
Producer
::
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
}
// namespace RTC
...
...
worker/include/RTC/RtpStream.hpp
浏览文件 @
27f060bf
...
@@ -12,15 +12,6 @@ namespace RTC
...
@@ -12,15 +12,6 @@ namespace RTC
{
{
class
RtpStream
:
public
Timer
::
Listener
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
:
public
:
struct
Params
struct
Params
{
{
...
@@ -35,7 +26,7 @@ namespace RTC
...
@@ -35,7 +26,7 @@ namespace RTC
};
};
public
:
public
:
static
constexpr
uint16_t
Health
CheckPeriod
{
1000
};
static
constexpr
uint16_t
Status
CheckPeriod
{
1000
};
public
:
public
:
explicit
RtpStream
(
RTC
::
RtpStream
::
Params
&
params
);
explicit
RtpStream
(
RTC
::
RtpStream
::
Params
&
params
);
...
@@ -49,9 +40,7 @@ namespace RTC
...
@@ -49,9 +40,7 @@ namespace RTC
uint8_t
GetPayloadType
()
const
;
uint8_t
GetPayloadType
()
const
;
const
RTC
::
RtpCodecMimeType
&
GetMimeType
()
const
;
const
RTC
::
RtpCodecMimeType
&
GetMimeType
()
const
;
float
GetLossPercentage
()
const
;
float
GetLossPercentage
()
const
;
bool
IsHealthy
()
const
;
void
ResetStatusCheckTimer
(
uint16_t
timeout
=
StatusCheckPeriod
);
void
SetUnhealthy
();
void
ResetHealthCheckTimer
(
uint16_t
timeout
=
HealthCheckPeriod
);
protected
:
protected
:
bool
UpdateSeq
(
RTC
::
RtpPacket
*
packet
);
bool
UpdateSeq
(
RTC
::
RtpPacket
*
packet
);
...
@@ -61,7 +50,7 @@ namespace RTC
...
@@ -61,7 +50,7 @@ namespace RTC
/* Pure virtual methods that must be implemented by the subclass. */
/* Pure virtual methods that must be implemented by the subclass. */
protected
:
protected
:
virtual
void
Check
Health
()
=
0
;
virtual
void
Check
Status
()
=
0
;
/* Pure virtual methods inherited from Timer::Listener. */
/* Pure virtual methods inherited from Timer::Listener. */
public
:
public
:
...
@@ -95,9 +84,8 @@ namespace RTC
...
@@ -95,9 +84,8 @@ namespace RTC
// Others.
// Others.
uint32_t
maxPacketTs
{
0
};
// Highest timestamp seen.
uint32_t
maxPacketTs
{
0
};
// Highest timestamp seen.
uint64_t
maxPacketMs
{
0
};
// When the packet with highest timestammp was seen.
uint64_t
maxPacketMs
{
0
};
// When the packet with highest timestammp was seen.
Timer
*
healthCheckTimer
{
nullptr
};
Timer
*
statusCheckTimer
{
nullptr
};
bool
healthy
{
true
};
bool
notifyStatus
{
true
};
bool
notifyHealth
{
true
};
private
:
private
:
std
::
string
rtpStreamId
{};
std
::
string
rtpStreamId
{};
...
@@ -124,16 +112,6 @@ namespace RTC
...
@@ -124,16 +112,6 @@ namespace RTC
{
{
return
static_cast
<
float
>
(
this
->
fractionLost
)
*
100
/
256
;
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
}
// namespace RTC
#endif
#endif
worker/include/RTC/RtpStreamRecv.hpp
浏览文件 @
27f060bf
...
@@ -11,12 +11,14 @@ namespace RTC
...
@@ -11,12 +11,14 @@ namespace RTC
class
RtpStreamRecv
:
public
RtpStream
,
public
RTC
::
NackGenerator
::
Listener
class
RtpStreamRecv
:
public
RtpStream
,
public
RTC
::
NackGenerator
::
Listener
{
{
public
:
public
:
class
Listener
:
public
RtpStream
::
Listener
class
Listener
{
{
public
:
public
:
virtual
void
OnRtpStreamRecvNackRequired
(
virtual
void
OnRtpStreamRecvNackRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
=
0
;
RTC
::
RtpStreamRecv
*
rtpStream
,
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
=
0
;
virtual
void
OnRtpStreamRecvPliRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamRecvPliRequired
(
RTC
::
RtpStreamRecv
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamInactive
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamActive
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
};
};
public
:
public
:
...
@@ -30,13 +32,14 @@ namespace RTC
...
@@ -30,13 +32,14 @@ namespace RTC
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
void
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
);
void
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
);
void
RequestKeyFrame
();
void
RequestKeyFrame
();
bool
IsActive
()
const
;
private
:
private
:
void
CalculateJitter
(
uint32_t
rtpTimestamp
);
void
CalculateJitter
(
uint32_t
rtpTimestamp
);
/* Pure virtual methods inherited from RtpStream. */
/* Pure virtual methods inherited from RtpStream. */
protected
:
protected
:
virtual
void
Check
Health
()
override
;
virtual
void
Check
Status
()
override
;
/* Pure virtual methods inherited from RTC::NackGenerator. */
/* Pure virtual methods inherited from RTC::NackGenerator. */
protected
:
protected
:
...
@@ -61,7 +64,14 @@ namespace RTC
...
@@ -61,7 +64,14 @@ namespace RTC
uint32_t
rtxSsrc
{
0
};
uint32_t
rtxSsrc
{
0
};
// Stats.
// Stats.
uint32_t
jitter
{
0
};
uint32_t
jitter
{
0
};
// Others.
bool
active
{
true
};
};
};
inline
bool
RtpStreamRecv
::
IsActive
()
const
{
return
this
->
active
;
}
}
// namespace RTC
}
// namespace RTC
#endif
#endif
worker/include/RTC/RtpStreamSend.hpp
浏览文件 @
27f060bf
...
@@ -11,6 +11,14 @@ namespace RTC
...
@@ -11,6 +11,14 @@ namespace RTC
{
{
class
RtpStreamSend
:
public
RtpStream
class
RtpStreamSend
:
public
RtpStream
{
{
public
:
class
Listener
{
public
:
virtual
void
OnRtpStreamHealthy
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
virtual
void
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
=
0
;
};
private
:
private
:
struct
StorageItem
struct
StorageItem
{
{
...
@@ -26,7 +34,7 @@ namespace RTC
...
@@ -26,7 +34,7 @@ namespace RTC
};
};
public
:
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
;
~
RtpStreamSend
()
override
;
Json
::
Value
GetStats
()
override
;
Json
::
Value
GetStats
()
override
;
...
@@ -39,22 +47,25 @@ namespace RTC
...
@@ -39,22 +47,25 @@ namespace RTC
bool
HasRtx
()
const
;
bool
HasRtx
()
const
;
void
RtxEncode
(
RtpPacket
*
packet
);
void
RtxEncode
(
RtpPacket
*
packet
);
void
ClearRetransmissionBuffer
();
void
ClearRetransmissionBuffer
();
bool
IsHealthy
()
const
;
private
:
private
:
void
StorePacket
(
RTC
::
RtpPacket
*
packet
);
void
StorePacket
(
RTC
::
RtpPacket
*
packet
);
/* Pure virtual methods inherited from RtpStream. */
/* Pure virtual methods inherited from RtpStream. */
protected
:
protected
:
void
Check
Health
()
override
;
void
Check
Status
()
override
;
private
:
private
:
// Passed by argument.
// Passed by argument.
RTC
::
RtpStream
::
Listener
*
listener
{
nullptr
};
Listener
*
listener
{
nullptr
};
std
::
vector
<
StorageItem
>
storage
;
std
::
vector
<
StorageItem
>
storage
;
using
Buffer
=
std
::
list
<
BufferItem
>
;
using
Buffer
=
std
::
list
<
BufferItem
>
;
Buffer
buffer
;
Buffer
buffer
;
// Stats.
// Stats.
uint32_t
rtt
{
0
};
uint32_t
rtt
{
0
};
// Others.
bool
healthy
{
true
};
private
:
private
:
// Retransmittion related.
// Retransmittion related.
...
@@ -68,6 +79,11 @@ namespace RTC
...
@@ -68,6 +79,11 @@ namespace RTC
{
{
return
this
->
hasRtx
;
return
this
->
hasRtx
;
}
}
inline
bool
RtpStreamSend
::
IsHealthy
()
const
{
return
this
->
healthy
;
}
}
// namespace RTC
}
// namespace RTC
#endif
#endif
worker/src/RTC/Consumer.cpp
浏览文件 @
27f060bf
...
@@ -307,7 +307,7 @@ namespace RTC
...
@@ -307,7 +307,7 @@ namespace RTC
this
->
probingProfile
=
RtpEncodingParameters
::
Profile
::
NONE
;
this
->
probingProfile
=
RtpEncodingParameters
::
Profile
::
NONE
;
// Reset the health check timer so this probation doesn't affect the effective profile.
// 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
;
return
;
}
}
...
@@ -699,13 +699,6 @@ namespace RTC
...
@@ -699,13 +699,6 @@ namespace RTC
}
}
}
}
void
Consumer
::
OnRtpStreamInactivity
(
RtpStream
*
rtpStream
)
{
MS_TRACE
();
OnRtpStreamUnhealthy
(
rtpStream
);
}
void
Consumer
::
OnRtpStreamHealthy
(
RtpStream
*
rtpStream
)
void
Consumer
::
OnRtpStreamHealthy
(
RtpStream
*
rtpStream
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -789,7 +782,7 @@ namespace RTC
...
@@ -789,7 +782,7 @@ namespace RTC
RequestKeyFrame
();
RequestKeyFrame
();
// We want to be notified about this new profile's health.
// We want to be notified about this new profile's health.
this
->
rtpStream
->
Reset
Health
CheckTimer
();
this
->
rtpStream
->
Reset
Status
CheckTimer
();
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rtp
,
rtp
,
...
@@ -1011,7 +1004,7 @@ namespace RTC
...
@@ -1011,7 +1004,7 @@ namespace RTC
{
{
this
->
isProbing
=
true
;
this
->
isProbing
=
true
;
this
->
probingProfile
=
newTargetProfile
;
this
->
probingProfile
=
newTargetProfile
;
this
->
rtpStream
->
Reset
Health
CheckTimer
();
this
->
rtpStream
->
Reset
Status
CheckTimer
();
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rtp
,
rtp
,
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
27f060bf
...
@@ -543,8 +543,8 @@ namespace RTC
...
@@ -543,8 +543,8 @@ namespace RTC
// Add the stream to the profiles map.
// Add the stream to the profiles map.
this
->
mapRtpStreamProfiles
[
rtpStream
].
insert
(
profile
);
this
->
mapRtpStreamProfiles
[
rtpStream
].
insert
(
profile
);
// Add new profile/s into
healthy
Profiles and notify the listener.
// Add new profile/s into
active
Profiles and notify the listener.
Add
Healthy
Profiles
(
rtpStream
);
Add
Active
Profiles
(
rtpStream
);
// 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
);
...
@@ -554,8 +554,8 @@ namespace RTC
...
@@ -554,8 +554,8 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// Remove the profiles related to this stream from
healthy
Profiles and notify the listener.
// Remove the profiles related to this stream from
active
Profiles and notify the listener.
Remove
Healthy
Profiles
(
rtpStream
);
Remove
Active
Profiles
(
rtpStream
);
this
->
rtpStreams
.
erase
(
rtpStream
->
GetSsrc
());
this
->
rtpStreams
.
erase
(
rtpStream
->
GetSsrc
());
...
@@ -609,7 +609,7 @@ namespace RTC
...
@@ -609,7 +609,7 @@ namespace RTC
this
->
rtpStreams
.
clear
();
this
->
rtpStreams
.
clear
();
this
->
mapRtxStreams
.
clear
();
this
->
mapRtxStreams
.
clear
();
this
->
mapRtpStreamProfiles
.
clear
();
this
->
mapRtpStreamProfiles
.
clear
();
this
->
healthy
Profiles
.
clear
();
this
->
active
Profiles
.
clear
();
}
}
void
Producer
::
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
void
Producer
::
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
...
@@ -662,7 +662,7 @@ namespace RTC
...
@@ -662,7 +662,7 @@ 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
::
Add
Healthy
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
)
void
Producer
::
Add
Active
Profiles
(
RTC
::
RtpStreamRecv
*
rtpStream
)
{
{
auto
&
profiles
=
this
->
mapRtpStreamProfiles
[
rtpStream
];
auto
&
profiles
=
this
->
mapRtpStreamProfiles
[
rtpStream
];
...
@@ -670,11 +670,11 @@ namespace RTC
...
@@ -670,11 +670,11 @@ namespace RTC
for
(
auto
&
profile
:
profiles
)
for
(
auto
&
profile
:
profiles
)
{
{
MS_ASSERT
(
MS_ASSERT
(
this
->
healthyProfiles
.
find
(
profile
)
==
this
->
healthy
Profiles
.
end
(),
this
->
activeProfiles
.
find
(
profile
)
==
this
->
active
Profiles
.
end
(),
"profile already in headltyProfiles set"
);
"profile already in headltyProfiles set"
);
// Add the profile to the
healthy profiles set
.
// Add the profile to the
active profiles map
.
this
->
healthy
Profiles
[
profile
]
=
rtpStream
;
this
->
active
Profiles
[
profile
]
=
rtpStream
;
for
(
auto
&
listener
:
this
->
listeners
)
for
(
auto
&
listener
:
this
->
listeners
)
{
{
...
@@ -683,7 +683,7 @@ namespace RTC
...
@@ -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
];
auto
&
profiles
=
this
->
mapRtpStreamProfiles
[
rtpStream
];
...
@@ -691,11 +691,11 @@ namespace RTC
...
@@ -691,11 +691,11 @@ namespace RTC
for
(
auto
&
profile
:
profiles
)
for
(
auto
&
profile
:
profiles
)
{
{
MS_ASSERT
(
MS_ASSERT
(
this
->
healthyProfiles
.
find
(
profile
)
!=
this
->
healthy
Profiles
.
end
(),
this
->
activeProfiles
.
find
(
profile
)
!=
this
->
active
Profiles
.
end
(),
"profile not in headltyProfiles"
);
"profile not in headltyProfiles"
);
// Remove the profile from the
healthy profiles set
.
// Remove the profile from the
active profiles map
.
this
->
healthy
Profiles
.
erase
(
profile
);
this
->
active
Profiles
.
erase
(
profile
);
for
(
auto
&
listener
:
this
->
listeners
)
for
(
auto
&
listener
:
this
->
listeners
)
{
{
...
@@ -772,7 +772,7 @@ namespace RTC
...
@@ -772,7 +772,7 @@ namespace RTC
rtpStream
->
pliCount
++
;
rtpStream
->
pliCount
++
;
}
}
void
Producer
::
OnRtpStreamInactiv
ity
(
RTC
::
RtpStream
*
rtpStream
)
void
Producer
::
OnRtpStreamInactiv
e
(
RTC
::
RtpStream
*
rtpStream
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -782,18 +782,18 @@ namespace RTC
...
@@ -782,18 +782,18 @@ namespace RTC
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamProfiles
.
end
(),
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamProfiles
.
end
(),
"stream not present in mapRtpStreamProfiles"
);
"stream not present in mapRtpStreamProfiles"
);
// Single
healthy
profile present. Ignore.
// Single
active
profile present. Ignore.
if
(
this
->
healthy
Profiles
.
size
()
==
1
)
if
(
this
->
active
Profiles
.
size
()
==
1
)
return
;
return
;
// Simulcast. Check whether any RTP is being received at all.
// Simulcast. Check whether any RTP is being received at all.
uint32_t
totalBitrate
=
0
;
uint32_t
totalBitrate
=
0
;
uint64_t
now
=
DepLibUV
::
GetTime
();
uint64_t
now
=
DepLibUV
::
GetTime
();
for
(
auto
it
:
this
->
healthy
Profiles
)
for
(
auto
it
:
this
->
active
Profiles
)
{
{
auto
healthy
RtpStream
=
it
.
second
;
auto
active
RtpStream
=
it
.
second
;
auto
ssrc
=
healthy
RtpStream
->
GetSsrc
();
auto
ssrc
=
active
RtpStream
->
GetSsrc
();
totalBitrate
+=
this
->
rtpStreams
[
ssrc
]
->
GetRate
(
now
);
totalBitrate
+=
this
->
rtpStreams
[
ssrc
]
->
GetRate
(
now
);
}
}
...
@@ -802,23 +802,22 @@ namespace RTC
...
@@ -802,23 +802,22 @@ namespace RTC
if
(
totalBitrate
==
0
)
if
(
totalBitrate
==
0
)
return
;
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
());
MS_DEBUG_TAG
(
rtp
,
"rtp inactivity detected [ssrc:%"
PRIu32
,
rtpStream
->
GetSsrc
());
rtpStream
->
SetUnhealthy
();
RemoveActiveProfiles
(
rtpStreamRecv
);
RemoveHealthyProfiles
(
rtpStreamRecv
);
// Reset
health check timer on every healthy
stream.
// Reset
stream check timer on every active
stream.
for
(
auto
it
:
this
->
healthy
Profiles
)
for
(
auto
it
:
this
->
active
Profiles
)
{
{
auto
healthy
RtpStream
=
it
.
second
;
auto
active
RtpStream
=
it
.
second
;
auto
ssrc
=
healthy
RtpStream
->
GetSsrc
();
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
();
MS_TRACE
();
...
@@ -828,26 +827,22 @@ namespace RTC
...
@@ -828,26 +827,22 @@ namespace RTC
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamProfiles
.
end
(),
this
->
mapRtpStreamProfiles
.
find
(
rtpStreamRecv
)
!=
this
->
mapRtpStreamProfiles
.
end
(),
"stream not present in mapRtpStreamProfiles"
);
"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.
// Check whether the stream is active.
AddHealthyProfiles
(
rtpStreamRecv
);
const
RtpStream
*
activeRtpStream
=
nullptr
;
}
void
Producer
::
OnRtpStreamUnhealthy
(
RTC
::
RtpStream
*
rtpStream
)
for
(
auto
it
:
this
->
activeProfiles
)
{
{
MS_TRACE
();
activeRtpStream
=
it
.
second
;
auto
rtpStreamRecv
=
dynamic_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
());
if
(
activeRtpStream
!=
nullptr
)
break
;
}
// Remove the profiles related to this stream from healthyProfiles and notify the listener.
// Add the profiles related to this stream into activeProfiles and notify the listener.
RemoveHealthyProfiles
(
rtpStreamRecv
);
if
(
!
activeRtpStream
)
AddActiveProfiles
(
rtpStreamRecv
);
}
}
inline
void
Producer
::
OnTimer
(
Timer
*
timer
)
inline
void
Producer
::
OnTimer
(
Timer
*
timer
)
...
...
worker/src/RTC/Router.cpp
浏览文件 @
27f060bf
...
@@ -514,10 +514,10 @@ namespace RTC
...
@@ -514,10 +514,10 @@ namespace RTC
// Add us as listener.
// Add us as listener.
consumer
->
AddListener
(
this
);
consumer
->
AddListener
(
this
);
auto
healthyProfiles
=
producer
->
GetHealthy
Profiles
();
auto
activeProfiles
=
producer
->
GetActive
Profiles
();
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStream
*>::
reverse_iterator
it
;
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
profile
=
it
->
first
;
auto
stats
=
it
->
second
;
auto
stats
=
it
->
second
;
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
27f060bf
...
@@ -24,19 +24,19 @@ namespace RTC
...
@@ -24,19 +24,19 @@ namespace RTC
// Generate a random rtpStreamId.
// Generate a random rtpStreamId.
this
->
rtpStreamId
=
Utils
::
Crypto
::
GetRandomString
(
16
);
this
->
rtpStreamId
=
Utils
::
Crypto
::
GetRandomString
(
16
);
// Set the
health
check timer.
// Set the
status
check timer.
this
->
health
CheckTimer
=
new
Timer
(
this
);
this
->
status
CheckTimer
=
new
Timer
(
this
);
// Run the timer.
// Run the timer.
this
->
healthCheckTimer
->
Start
(
HealthCheckPeriod
,
Health
CheckPeriod
);
this
->
statusCheckTimer
->
Start
(
StatusCheckPeriod
,
Status
CheckPeriod
);
}
}
RtpStream
::~
RtpStream
()
RtpStream
::~
RtpStream
()
{
{
MS_TRACE
();
MS_TRACE
();
// Close the
health
check timer.
// Close the
status
check timer.
this
->
health
CheckTimer
->
Destroy
();
this
->
status
CheckTimer
->
Destroy
();
}
}
Json
::
Value
RtpStream
::
ToJson
()
Json
::
Value
RtpStream
::
ToJson
()
...
@@ -61,7 +61,6 @@ namespace RTC
...
@@ -61,7 +61,6 @@ namespace RTC
static
const
Json
::
StaticString
JsonStringSsrc
{
"ssrc"
};
static
const
Json
::
StaticString
JsonStringSsrc
{
"ssrc"
};
static
const
Json
::
StaticString
JsonStringMediaType
{
"mediaType"
};
static
const
Json
::
StaticString
JsonStringMediaType
{
"mediaType"
};
static
const
Json
::
StaticString
JsonStringMimeType
{
"mimeType"
};
static
const
Json
::
StaticString
JsonStringMimeType
{
"mimeType"
};
static
const
Json
::
StaticString
JsonStringHealthy
{
"healthy"
};
static
const
Json
::
StaticString
JsonStringPacketCount
{
"packetCount"
};
static
const
Json
::
StaticString
JsonStringPacketCount
{
"packetCount"
};
static
const
Json
::
StaticString
JsonStringByteCount
{
"byteCount"
};
static
const
Json
::
StaticString
JsonStringByteCount
{
"byteCount"
};
static
const
Json
::
StaticString
JsonStringBitRate
{
"bitrate"
};
static
const
Json
::
StaticString
JsonStringBitRate
{
"bitrate"
};
...
@@ -82,7 +81,6 @@ namespace RTC
...
@@ -82,7 +81,6 @@ namespace RTC
json
[
JsonStringSsrc
]
=
Json
::
UInt
{
this
->
params
.
ssrc
};
json
[
JsonStringSsrc
]
=
Json
::
UInt
{
this
->
params
.
ssrc
};
json
[
JsonStringMediaType
]
=
RtpCodecMimeType
::
type2String
[
this
->
params
.
mimeType
.
type
];
json
[
JsonStringMediaType
]
=
RtpCodecMimeType
::
type2String
[
this
->
params
.
mimeType
.
type
];
json
[
JsonStringMimeType
]
=
this
->
params
.
mimeType
.
ToString
();
json
[
JsonStringMimeType
]
=
this
->
params
.
mimeType
.
ToString
();
json
[
JsonStringHealthy
]
=
this
->
healthy
?
"true"
:
"false"
;
json
[
JsonStringPacketCount
]
=
static_cast
<
Json
::
UInt
>
(
this
->
transmissionCounter
.
GetPacketCount
());
json
[
JsonStringPacketCount
]
=
static_cast
<
Json
::
UInt
>
(
this
->
transmissionCounter
.
GetPacketCount
());
json
[
JsonStringByteCount
]
=
static_cast
<
Json
::
UInt
>
(
this
->
transmissionCounter
.
GetBytes
());
json
[
JsonStringByteCount
]
=
static_cast
<
Json
::
UInt
>
(
this
->
transmissionCounter
.
GetBytes
());
json
[
JsonStringBitRate
]
=
Json
::
UInt
{
this
->
transmissionCounter
.
GetRate
(
now
)
};
json
[
JsonStringBitRate
]
=
Json
::
UInt
{
this
->
transmissionCounter
.
GetRate
(
now
)
};
...
@@ -143,11 +141,11 @@ namespace RTC
...
@@ -143,11 +141,11 @@ namespace RTC
return
this
->
transmissionCounter
.
GetRate
(
now
);
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
.
// Notify about
status on next check
.
this
->
notify
Health
=
true
;
this
->
notify
Status
=
true
;
this
->
healthCheckTimer
->
Start
(
timeout
,
Health
CheckPeriod
);
this
->
statusCheckTimer
->
Start
(
timeout
,
Status
CheckPeriod
);
}
}
void
RtpStream
::
InitSeq
(
uint16_t
seq
)
void
RtpStream
::
InitSeq
(
uint16_t
seq
)
...
@@ -253,9 +251,9 @@ namespace RTC
...
@@ -253,9 +251,9 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
if
(
timer
==
this
->
health
CheckTimer
)
if
(
timer
==
this
->
status
CheckTimer
)
{
{
this
->
Check
Health
();
this
->
Check
Status
();
}
}
}
}
}
// namespace RTC
}
// namespace RTC
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
27f060bf
...
@@ -227,20 +227,24 @@ namespace RTC
...
@@ -227,20 +227,24 @@ namespace RTC
this
->
jitter
+=
(
1.
/
16.
)
*
(
static_cast
<
double
>
(
d
)
-
this
->
jitter
);
this
->
jitter
+=
(
1.
/
16.
)
*
(
static_cast
<
double
>
(
d
)
-
this
->
jitter
);
}
}
void
RtpStreamRecv
::
Check
Health
()
void
RtpStreamRecv
::
Check
Status
()
{
{
MS_TRACE
();
MS_TRACE
();
auto
now
=
DepLibUV
::
GetTime
();
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
->
active
=
true
;
this
->
listener
->
OnRtpStream
Healthy
(
this
);
this
->
listener
->
OnRtpStream
Active
(
this
);
}
}
}
}
...
...
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
27f060bf
...
@@ -20,7 +20,7 @@ namespace RTC
...
@@ -20,7 +20,7 @@ namespace RTC
/* Instance methods. */
/* Instance methods. */
RtpStreamSend
::
RtpStreamSend
(
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
)
:
RtpStream
::
RtpStream
(
params
),
listener
(
listener
),
storage
(
bufferSize
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -398,7 +398,7 @@ namespace RTC
...
@@ -398,7 +398,7 @@ namespace RTC
(
*
newBufferIt
).
packet
=
packet
->
Clone
(
store
);
(
*
newBufferIt
).
packet
=
packet
->
Clone
(
store
);
}
}
void
RtpStreamSend
::
Check
Health
()
void
RtpStreamSend
::
Check
Status
()
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -408,19 +408,19 @@ namespace RTC
...
@@ -408,19 +408,19 @@ namespace RTC
{
{
MS_DEBUG_TAG
(
rtp
,
"last period loss percentage: %.2f"
,
lossPercentage
);
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
->
healthy
=
false
;
this
->
listener
->
OnRtpStreamUnhealthy
(
this
);
this
->
listener
->
OnRtpStreamUnhealthy
(
this
);
}
}
}
}
else
if
(
this
->
notify
Health
||
!
this
->
healthy
)
else
if
(
this
->
notify
Status
||
!
this
->
healthy
)
{
{
this
->
healthy
=
true
;
this
->
healthy
=
true
;
this
->
listener
->
OnRtpStreamHealthy
(
this
);
this
->
listener
->
OnRtpStreamHealthy
(
this
);
}
}
this
->
notify
Health
=
false
;
this
->
notify
Status
=
false
;
}
}
void
RtpStreamSend
::
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
)
void
RtpStreamSend
::
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论