Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
0c45b732
提交
0c45b732
authored
9月 18, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consumer: add probation
上级
af04dc66
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
96 行增加
和
32 行删除
+96
-32
Consumer.hpp
worker/include/RTC/Consumer.hpp
+9
-3
Producer.hpp
worker/include/RTC/Producer.hpp
+5
-3
ProducerListener.hpp
worker/include/RTC/ProducerListener.hpp
+4
-1
Router.hpp
worker/include/RTC/Router.hpp
+3
-1
RtpStream.hpp
worker/include/RTC/RtpStream.hpp
+14
-5
RtpStreamSend.hpp
worker/include/RTC/RtpStreamSend.hpp
+3
-1
Transport.hpp
worker/include/RTC/Transport.hpp
+3
-1
Consumer.cpp
worker/src/RTC/Consumer.cpp
+0
-0
Producer.cpp
worker/src/RTC/Producer.cpp
+11
-7
Router.cpp
worker/src/RTC/Router.cpp
+9
-7
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+9
-0
RtpStreamSend.cpp
worker/src/RTC/RtpStreamSend.cpp
+23
-2
Transport.cpp
worker/src/RTC/Transport.cpp
+3
-1
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
0c45b732
...
...
@@ -21,7 +21,7 @@
namespace
RTC
{
class
Consumer
:
public
RtpStream
::
Listener
class
Consumer
:
public
R
TC
::
R
tpStream
::
Listener
{
public
:
Consumer
(
...
...
@@ -43,7 +43,7 @@ namespace RTC
void
Resume
();
void
SourcePause
();
void
SourceResume
();
void
AddProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
AddProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
,
const
RTC
::
RtpStreamInfo
*
info
);
void
RemoveProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
SourceRtpParametersUpdated
();
void
SetPreferredProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
);
...
...
@@ -62,8 +62,9 @@ namespace RTC
void
FillSupportedCodecPayloadTypes
();
void
CreateRtpStream
(
RTC
::
RtpEncodingParameters
&
encoding
);
void
RetransmitRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
RecalculateTargetProfile
();
void
RecalculateTargetProfile
(
bool
forcePreferred
=
false
);
void
SetEffectiveProfile
(
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
MayRunProbation
();
/* Pure virtual methods inherited from RTC::RtpStream::Listener. */
public
:
...
...
@@ -103,9 +104,14 @@ namespace RTC
// RTP profiles.
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
profiles
;
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStreamInfo
*>
mapProfileRtpStreamInfo
;
RTC
::
RtpEncodingParameters
::
Profile
preferredProfile
{
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
};
RTC
::
RtpEncodingParameters
::
Profile
targetProfile
{
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
};
RTC
::
RtpEncodingParameters
::
Profile
effectiveProfile
{
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
};
RTC
::
RtpEncodingParameters
::
Profile
probingProfile
{
RTC
::
RtpEncodingParameters
::
Profile
::
NONE
};
// RTP probation
bool
isProbing
{
false
};
uint16_t
rtpPacketsBeforeProbation
{
0
};
};
/* Inline methods. */
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
0c45b732
...
...
@@ -69,7 +69,8 @@ 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
>&
GetHealthyProfiles
()
const
;
const
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStreamInfo
*>&
GetHealthyProfiles
()
const
;
private
:
void
FillHeaderExtensionIds
();
...
...
@@ -111,7 +112,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
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
healthyProfiles
;
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStreamInfo
*
>
healthyProfiles
;
Timer
*
keyFrameRequestBlockTimer
{
nullptr
};
// Others.
std
::
vector
<
RtpEncodingParameters
>
outputEncodings
;
...
...
@@ -163,7 +164,8 @@ namespace RTC
}
}
inline
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>&
Producer
::
GetHealthyProfiles
()
const
inline
const
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStreamInfo
*>&
Producer
::
GetHealthyProfiles
()
const
{
return
this
->
healthyProfiles
;
}
...
...
worker/include/RTC/ProducerListener.hpp
浏览文件 @
0c45b732
...
...
@@ -2,6 +2,7 @@
#define MS_RTC_PRODUCER_LISTENER_HPP
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpStream.hpp"
namespace
RTC
{
...
...
@@ -19,7 +20,9 @@ namespace RTC
virtual
void
OnProducerRtpPacket
(
RTC
::
Producer
*
producer
,
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
=
0
;
virtual
void
OnProducerProfileEnabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
=
0
;
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
,
const
RTC
::
RtpStreamInfo
*
info
)
=
0
;
virtual
void
OnProducerProfileDisabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
=
0
;
};
...
...
worker/include/RTC/Router.hpp
浏览文件 @
0c45b732
...
...
@@ -72,7 +72,9 @@ namespace RTC
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
void
OnProducerProfileEnabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
,
const
RTC
::
RtpStreamInfo
*
info
)
override
;
void
OnProducerProfileDisabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
...
...
worker/include/RTC/RtpStream.hpp
浏览文件 @
0c45b732
...
...
@@ -10,7 +10,18 @@
namespace
RTC
{
class
RtpStream
:
public
Timer
::
Listener
class
RtpStreamInfo
{
public
:
uint32_t
totalLost
{
0
};
uint8_t
fractionLost
{
0
};
uint32_t
jitter
{
0
};
uint32_t
rtt
{
0
};
size_t
numPlis
{
0
};
size_t
numNacks
{
0
};
};
class
RtpStream
:
public
Timer
::
Listener
,
public
RtpStreamInfo
{
public
:
class
Listener
...
...
@@ -45,6 +56,7 @@ namespace RTC
uint8_t
GetPayloadType
();
const
RTC
::
RtpCodecMimeType
&
GetMimeType
()
const
;
bool
IsHealthy
();
void
ResetHealthCheckTimer
();
protected
:
bool
UpdateSeq
(
RTC
::
RtpPacket
*
packet
);
...
...
@@ -76,10 +88,7 @@ namespace RTC
uint64_t
maxPacketMs
{
0
};
// When the packet with highest timestammp was seen.
Timer
*
healthCheckTimer
{
nullptr
};
bool
healthy
{
true
};
uint32_t
totalLost
{
0
};
uint8_t
fractionLost
{
0
};
uint32_t
jitter
{
0
};
uint32_t
rtt
{
0
};
bool
notifyHealth
{
true
};
// RTP counters.
RTC
::
RtpDataCounter
counter
;
};
...
...
worker/include/RTC/RtpStreamSend.hpp
浏览文件 @
0c45b732
...
...
@@ -26,7 +26,7 @@ namespace RTC
};
public
:
RtpStreamSend
(
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
);
RtpStreamSend
(
RTC
::
RtpStream
::
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
);
~
RtpStreamSend
()
override
;
bool
ReceivePacket
(
RTC
::
RtpPacket
*
packet
)
override
;
...
...
@@ -47,6 +47,8 @@ namespace RTC
void
CheckHealth
()
override
;
private
:
// Passed by argument.
RTC
::
RtpStream
::
Listener
*
listener
{
nullptr
};
std
::
vector
<
StorageItem
>
storage
;
using
Buffer
=
std
::
list
<
BufferItem
>
;
Buffer
buffer
;
...
...
worker/include/RTC/Transport.hpp
浏览文件 @
0c45b732
...
...
@@ -96,7 +96,9 @@ namespace RTC
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
void
OnProducerProfileEnabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
,
const
RTC
::
RtpStreamInfo
*
info
)
override
;
void
OnProducerProfileDisabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
0c45b732
差异被折叠。
点击展开。
worker/src/RTC/Producer.cpp
浏览文件 @
0c45b732
...
...
@@ -636,14 +636,16 @@ namespace RTC
if
(
profile
==
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
break
;
MS_ASSERT
(
this
->
healthyProfiles
.
find
(
profile
)
==
this
->
healthyProfiles
.
end
(),
"profile already in headltyProfiles set"
);
// 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"
);
this
->
healthyProfiles
[
profile
]
=
rtpStream
;
for
(
auto
&
listener
:
this
->
listeners
)
{
listener
->
OnProducerProfileEnabled
(
this
,
profile
);
listener
->
OnProducerProfileEnabled
(
this
,
profile
,
rtpStream
);
}
}
}
...
...
@@ -659,10 +661,12 @@ namespace RTC
if
(
profile
==
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
)
break
;
MS_ASSERT
(
this
->
healthyProfiles
.
find
(
profile
)
!=
this
->
healthyProfiles
.
end
(),
"profile already in headltyProfiles set"
);
// 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"
);
this
->
healthyProfiles
.
erase
(
profile
);
for
(
auto
&
listener
:
this
->
listeners
)
{
...
...
worker/src/RTC/Router.cpp
浏览文件 @
0c45b732
...
...
@@ -9,6 +9,7 @@
#include "RTC/RtpDictionaries.hpp"
#include "RTC/WebRtcTransport.hpp"
#include <cmath> // std::lround()
#include <map>
#include <set>
#include <string>
...
...
@@ -511,14 +512,15 @@ namespace RTC
// Add us as listener.
consumer
->
AddListener
(
this
);
auto
p
rofiles
=
producer
->
GetHealthyProfiles
();
std
::
set
<
RtpEncodingParameters
::
Profile
>::
reverse_iterator
it
;
auto
healthyP
rofiles
=
producer
->
GetHealthyProfiles
();
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
const
RTC
::
RtpStreamInfo
*
>::
reverse_iterator
it
;
for
(
it
=
profiles
.
rbegin
();
it
!=
p
rofiles
.
rend
();
++
it
)
for
(
it
=
healthyProfiles
.
rbegin
();
it
!=
healthyP
rofiles
.
rend
();
++
it
)
{
auto
profile
=
*
it
;
auto
profile
=
it
->
first
;
auto
info
=
it
->
second
;
consumer
->
AddProfile
(
profile
);
consumer
->
AddProfile
(
profile
,
info
);
}
// Insert into the maps.
...
...
@@ -1530,7 +1532,7 @@ namespace RTC
}
void
Router
::
OnProducerProfileEnabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
,
const
RTC
::
RtpStreamInfo
*
info
)
{
MS_TRACE
();
...
...
@@ -1542,7 +1544,7 @@ namespace RTC
for
(
auto
*
consumer
:
consumers
)
{
consumer
->
AddProfile
(
profile
);
consumer
->
AddProfile
(
profile
,
info
);
}
}
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
0c45b732
...
...
@@ -49,6 +49,7 @@ namespace RTC
static
const
Json
::
StaticString
JsonStringRtt
{
"rtt"
};
static
const
Json
::
StaticString
JsonStringFractionLost
{
"fractionLost"
};
static
const
Json
::
StaticString
JsonStringTotalLost
{
"totalLost"
};
static
const
Json
::
StaticString
JsonStringHealthy
{
"healthy"
};
Json
::
Value
json
(
Json
::
objectValue
);
...
...
@@ -62,6 +63,7 @@ namespace RTC
json
[
JsonStringRtt
]
=
Json
::
UInt
{
this
->
rtt
};
json
[
JsonStringFractionLost
]
=
Json
::
UInt
{
this
->
fractionLost
};
json
[
JsonStringTotalLost
]
=
Json
::
UInt
{
this
->
totalLost
};
json
[
JsonStringHealthy
]
=
this
->
healthy
?
"true"
:
"false"
;
return
json
;
}
...
...
@@ -115,6 +117,13 @@ namespace RTC
return
this
->
counter
.
GetRate
(
now
);
}
void
RtpStream
::
ResetHealthCheckTimer
()
{
// Notify about next health status.
this
->
notifyHealth
=
true
;
this
->
healthCheckTimer
->
Start
(
HealthCheckPeriod
,
HealthCheckPeriod
);
}
void
RtpStream
::
InitSeq
(
uint16_t
seq
)
{
MS_TRACE
();
...
...
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
0c45b732
...
...
@@ -15,11 +15,13 @@ namespace RTC
// TODO: This must be tunned.
static
constexpr
uint32_t
MaxRetransmissionDelay
{
1000
};
static
constexpr
uint32_t
DefaultRtt
{
100
};
static
constexpr
uint8_t
MaxHealthLossPercentage
{
20
};
/* Instance methods. */
RtpStreamSend
::
RtpStreamSend
(
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
)
:
RtpStream
::
RtpStream
(
params
),
storage
(
bufferSize
)
RtpStreamSend
::
RtpStreamSend
(
RTC
::
RtpStream
::
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
,
size_t
bufferSize
)
:
RtpStream
::
RtpStream
(
params
),
listener
(
listener
),
storage
(
bufferSize
)
{
MS_TRACE
();
}
...
...
@@ -416,6 +418,25 @@ namespace RTC
void
RtpStreamSend
::
CheckHealth
()
{
MS_TRACE
();
uint16_t
currentLossPercentage
=
this
->
fractionLost
*
100
/
256
;
if
(
currentLossPercentage
>=
MaxHealthLossPercentage
)
{
MS_DEBUG_TAG
(
rtp
,
"last period loss percentage: %"
PRIu16
,
currentLossPercentage
);
if
(
this
->
notifyHealth
||
this
->
healthy
)
{
this
->
healthy
=
false
;
this
->
listener
->
OnRtpStreamUnhealthy
(
this
);
}
}
else
if
(
this
->
notifyHealth
||
!
this
->
healthy
)
{
this
->
healthy
=
true
;
this
->
listener
->
OnRtpStreamHealthy
(
this
);
}
this
->
notifyHealth
=
false
;
}
void
RtpStreamSend
::
SetRtx
(
uint8_t
payloadType
,
uint32_t
ssrc
)
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
0c45b732
...
...
@@ -542,7 +542,9 @@ namespace RTC
}
void
Transport
::
OnProducerProfileEnabled
(
RTC
::
Producer
*
/*producer*/
,
RTC
::
RtpEncodingParameters
::
Profile
/*profile*/
)
RTC
::
Producer
*
/*producer*/
,
RTC
::
RtpEncodingParameters
::
Profile
/*profile*/
,
const
RTC
::
RtpStreamInfo
*
/*info*/
)
{
// Do nothing.
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论