Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
369857f5
提交
369857f5
authored
9月 11, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Propagate profile activation/deactivation events.
上级
3ff70302
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
212 行增加
和
31 行删除
+212
-31
Consumer.hpp
worker/include/RTC/Consumer.hpp
+7
-2
Producer.hpp
worker/include/RTC/Producer.hpp
+19
-1
ProducerListener.hpp
worker/include/RTC/ProducerListener.hpp
+2
-0
Router.hpp
worker/include/RTC/Router.hpp
+6
-0
RtpDictionaries.hpp
worker/include/RTC/RtpDictionaries.hpp
+2
-2
Transport.hpp
worker/include/RTC/Transport.hpp
+6
-0
Consumer.cpp
worker/src/RTC/Consumer.cpp
+68
-10
Producer.cpp
worker/src/RTC/Producer.cpp
+34
-4
Router.cpp
worker/src/RTC/Router.cpp
+43
-0
RtpEncodingParameters.cpp
worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp
+8
-8
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+5
-4
Transport.cpp
worker/src/RTC/Transport.cpp
+12
-0
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
369857f5
...
...
@@ -16,6 +16,7 @@
#include "RTC/Transport.hpp"
#include <json/json.h>
#include <unordered_set>
#include <set>
namespace
RTC
{
...
...
@@ -42,6 +43,8 @@ namespace RTC
void
Resume
();
void
SourcePause
();
void
SourceResume
();
void
AddProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
RemoveProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
SourceRtpParametersUpdated
();
void
SetPreferredProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
);
void
Disable
();
...
...
@@ -59,6 +62,7 @@ namespace RTC
void
FillSupportedCodecPayloadTypes
();
void
CreateRtpStream
(
RTC
::
RtpEncodingParameters
&
encoding
);
void
RetransmitRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
RecalculateEffectiveProfile
();
/* Pure virtual methods inherited from RTC::RtpStream::Listener. */
public
:
...
...
@@ -95,8 +99,9 @@ namespace RTC
uint32_t
lastRecvRtpTimestamp
{
0
};
bool
syncRequired
{
true
};
// RTP profiles.
RTC
::
RtpEncodingParameters
::
Profile
preferredProfile
{
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
};
RTC
::
RtpEncodingParameters
::
Profile
effectiveProfile
{
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
};
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
profiles
;
RTC
::
RtpEncodingParameters
::
Profile
preferredProfile
{
RTC
::
RtpEncodingParameters
::
Profile
::
NONE
};
RTC
::
RtpEncodingParameters
::
Profile
effectiveProfile
{
RTC
::
RtpEncodingParameters
::
Profile
::
NONE
};
};
/* Inline methods. */
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
369857f5
...
...
@@ -84,13 +84,14 @@ namespace RTC
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackPsPacket
*
packet
)
const
;
void
ReceiveRtcpFeedback
(
RTC
::
RTCP
::
FeedbackRtpPacket
*
packet
)
const
;
void
RequestFullFrame
(
bool
force
=
false
);
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
GetProfiles
()
const
;
private
:
void
FillHeaderExtensionIds
();
void
CreateRtpStream
(
RTC
::
RtpEncodingParameters
&
encoding
);
void
ClearRtpStreams
();
void
ApplyRtpMapping
(
RTC
::
RtpPacket
*
packet
)
const
;
RTC
::
RtpEncodingParameters
::
Profile
Get
Rtp
Profile
(
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
);
RTC
::
RtpEncodingParameters
::
Profile
GetProfile
(
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
);
/* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */
public
:
...
...
@@ -165,6 +166,23 @@ namespace RTC
rtpStream
->
ReceiveRtcpSenderReport
(
report
);
}
}
inline
const
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
Producer
::
GetProfiles
()
const
{
std
::
set
<
RTC
::
RtpEncodingParameters
::
Profile
>
profiles
;
for
(
const
auto
&
it
:
this
->
rtpProfiles
)
{
for
(
const
auto
&
it2
:
it
.
second
)
{
auto
profile
=
it2
;
profiles
.
insert
(
profile
);
}
}
return
profiles
;
}
}
// namespace RTC
#endif
worker/include/RTC/ProducerListener.hpp
浏览文件 @
369857f5
...
...
@@ -18,6 +18,8 @@ namespace RTC
virtual
void
OnProducerResumed
(
RTC
::
Producer
*
producer
)
=
0
;
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
;
virtual
void
OnProducerProfileDisabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
=
0
;
};
}
// namespace RTC
...
...
worker/include/RTC/Router.hpp
浏览文件 @
369857f5
...
...
@@ -71,6 +71,12 @@ namespace RTC
RTC
::
Producer
*
producer
,
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
void
OnProducerProfileEnabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
void
OnProducerProfileDisabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
/* Pure virtual methods inherited from RTC::ConsumerListener. */
public
:
...
...
worker/include/RTC/RtpDictionaries.hpp
浏览文件 @
369857f5
...
...
@@ -209,7 +209,7 @@ namespace RTC
public
:
enum
class
Profile
:
uint8_t
{
DEFAULT
=
0
,
NONE
=
0
,
LOW
,
MEDIUM
,
HIGH
...
...
@@ -239,7 +239,7 @@ namespace RTC
bool
active
{
true
};
std
::
string
encodingId
;
std
::
vector
<
std
::
string
>
dependencyEncodingIds
;
Profile
profile
{
Profile
::
DEFAULT
};
Profile
profile
{
Profile
::
NONE
};
};
class
RtpHeaderExtensionParameters
...
...
worker/include/RTC/Transport.hpp
浏览文件 @
369857f5
...
...
@@ -157,6 +157,12 @@ namespace RTC
RTC
::
Producer
*
producer
,
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
void
OnProducerProfileEnabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
void
OnProducerProfileDisabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
override
;
/* Pure virtual methods inherited from RTC::ConsumerListener. */
public
:
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
369857f5
...
...
@@ -224,6 +224,31 @@ namespace RTC
this
->
rtpStream
->
ClearRetransmissionBuffer
();
}
void
Consumer
::
AddProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
)
{
// If this is the first enabled profile, remove the NONE entry from the set.
if
(
this
->
profiles
.
size
()
==
1
&&
(
*
(
this
->
profiles
.
begin
())
==
RTC
::
RtpEncodingParameters
::
Profile
::
NONE
))
this
->
profiles
.
clear
();
// Insert profile.
this
->
profiles
.
insert
(
profile
);
MS_DEBUG_TAG
(
rtp
,
"profile added: %s"
,
RTC
::
RtpEncodingParameters
::
profile2String
[
profile
].
c_str
());;
RecalculateEffectiveProfile
();
}
void
Consumer
::
RemoveProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
)
{
// Remove profile.
this
->
profiles
.
erase
(
profile
);
MS_DEBUG_TAG
(
rtp
,
"profile removed: %s"
,
RTC
::
RtpEncodingParameters
::
profile2String
[
this
->
effectiveProfile
].
c_str
());;
RecalculateEffectiveProfile
();
}
void
Consumer
::
SetPreferredProfile
(
const
RTC
::
RtpEncodingParameters
::
Profile
profile
)
{
MS_TRACE
();
...
...
@@ -233,16 +258,7 @@ namespace RTC
this
->
preferredProfile
=
profile
;
// TODO: Set it dynamically.
this
->
effectiveProfile
=
profile
;
if
(
IsEnabled
()
&&
!
IsPaused
())
{
this
->
syncRequired
=
true
;
this
->
rtpStream
->
ClearRetransmissionBuffer
();
RequestFullFrame
();
}
RecalculateEffectiveProfile
();
}
/**
...
...
@@ -567,4 +583,46 @@ namespace RTC
if
(
rtxPacket
!=
packet
)
delete
rtxPacket
;
}
void
Consumer
::
RecalculateEffectiveProfile
()
{
static
const
Json
::
StaticString
JsonStringProfile
{
"profile"
};
Json
::
Value
eventData
(
Json
::
objectValue
);
RTC
::
RtpEncodingParameters
::
Profile
newProfile
;
// If there is no preferred profile, take the best one available.
if
(
this
->
preferredProfile
==
RTC
::
RtpEncodingParameters
::
Profile
::
NONE
)
{
auto
it
=
this
->
profiles
.
crbegin
();
newProfile
=
*
it
;
}
// Otherwise take the highest available profile equal or lower than the preferred.
else
{
auto
it
=
this
->
profiles
.
lower_bound
(
this
->
preferredProfile
);
newProfile
=
*
it
;
}
if
(
newProfile
==
this
->
effectiveProfile
)
return
;
this
->
effectiveProfile
=
newProfile
;
MS_DEBUG_TAG
(
rtp
,
"new effective profile: %s"
,
RTC
::
RtpEncodingParameters
::
profile2String
[
this
->
effectiveProfile
].
c_str
());;
// Notify.
eventData
[
JsonStringProfile
]
=
RTC
::
RtpEncodingParameters
::
profile2String
[
this
->
effectiveProfile
];
this
->
notifier
->
Emit
(
this
->
consumerId
,
"effectiveprofilechange"
,
eventData
);
if
(
IsEnabled
()
&&
!
IsPaused
())
{
this
->
rtpStream
->
ClearRetransmissionBuffer
();
RequestFullFrame
();
}
this
->
syncRequired
=
true
;
}
}
// namespace RTC
worker/src/RTC/Producer.cpp
浏览文件 @
369857f5
...
...
@@ -315,7 +315,7 @@ namespace RTC
try
{
profile
=
Get
Rtp
Profile
(
rtpStream
,
packet
);
profile
=
GetProfile
(
rtpStream
,
packet
);
}
catch
(
const
MediaSoupError
&
error
)
{
...
...
@@ -612,7 +612,7 @@ namespace RTC
}
}
RTC
::
RtpEncodingParameters
::
Profile
Producer
::
Get
Rtp
Profile
(
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
)
RTC
::
RtpEncodingParameters
::
Profile
Producer
::
GetProfile
(
RTC
::
RtpStreamRecv
*
rtpStream
,
RTC
::
RtpPacket
*
packet
)
{
auto
ssrc
=
packet
->
GetSsrc
();
...
...
@@ -632,6 +632,11 @@ namespace RTC
{
this
->
rtpProfiles
[
rtpStream
].
insert
(
encoding
.
profile
);
for
(
auto
&
listener
:
this
->
listeners
)
{
listener
->
OnProducerProfileEnabled
(
this
,
encoding
.
profile
);
}
return
encoding
.
profile
;
}
}
...
...
@@ -707,8 +712,33 @@ namespace RTC
{
MS_TRACE
();
if
(
!
healthy
)
MS_DEBUG_TAG
(
rtp
,
"stream is not healthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
auto
rtpStreamRecv
=
static_cast
<
RtpStreamRecv
*>
(
rtpStream
);
auto
&
profiles
=
this
->
rtpProfiles
[
rtpStreamRecv
];
// The stream has transitioned to non healthy.
if
(
rtpStream
->
IsHealthy
()
&&
!
healthy
)
{
MS_DEBUG_TAG
(
rtp
,
"stream is now unhealthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
// Notify about the profiles being disabled.
for
(
auto
&
profile
:
profiles
)
{
for
(
auto
&
listener
:
this
->
listeners
)
listener
->
OnProducerProfileDisabled
(
this
,
profile
);
}
}
// The stream has transitioned to healthy.
if
(
!
rtpStream
->
IsHealthy
()
&&
healthy
)
{
MS_DEBUG_TAG
(
rtp
,
"stream is now healthy [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
// Notify about the profiles being disabled.
for
(
auto
&
profile
:
profiles
)
{
for
(
auto
&
listener
:
this
->
listeners
)
listener
->
OnProducerProfileDisabled
(
this
,
profile
);
}
}
}
inline
void
Producer
::
OnTimer
(
Timer
*
timer
)
...
...
worker/src/RTC/Router.cpp
浏览文件 @
369857f5
...
...
@@ -454,6 +454,16 @@ namespace RTC
// Add us as listener.
consumer
->
AddListener
(
this
);
auto
profiles
=
producer
->
GetProfiles
();
std
::
set
<
RtpEncodingParameters
::
Profile
>::
reverse_iterator
it
;
for
(
it
=
profiles
.
rbegin
();
it
!=
profiles
.
rend
();
++
it
)
{
auto
profile
=
*
it
;
consumer
->
AddProfile
(
profile
);
}
// Insert into the maps.
this
->
consumers
[
consumerId
]
=
consumer
;
this
->
mapProducerConsumers
[
producer
].
insert
(
consumer
);
...
...
@@ -1406,6 +1416,39 @@ namespace RTC
}
}
void
Router
::
OnProducerProfileEnabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
{
MS_TRACE
();
MS_ASSERT
(
this
->
mapProducerConsumers
.
find
(
producer
)
!=
this
->
mapProducerConsumers
.
end
(),
"Producer not present in mapProducerConsumers"
);
auto
&
consumers
=
this
->
mapProducerConsumers
[
producer
];
for
(
auto
*
consumer
:
consumers
)
{
consumer
->
AddProfile
(
profile
);
}
}
void
Router
::
OnProducerProfileDisabled
(
RTC
::
Producer
*
producer
,
RTC
::
RtpEncodingParameters
::
Profile
profile
)
{
MS_TRACE
();
MS_ASSERT
(
this
->
mapProducerConsumers
.
find
(
producer
)
!=
this
->
mapProducerConsumers
.
end
(),
"Producer not present in mapProducerConsumers"
);
auto
&
consumers
=
this
->
mapProducerConsumers
[
producer
];
for
(
auto
*
consumer
:
consumers
)
{
consumer
->
RemoveProfile
(
profile
);
}
}
void
Router
::
OnConsumerClosed
(
RTC
::
Consumer
*
consumer
)
{
MS_TRACE
();
...
...
worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp
浏览文件 @
369857f5
...
...
@@ -12,18 +12,18 @@ namespace RTC
// clang-format off
std
::
map
<
std
::
string
,
RTC
::
RtpEncodingParameters
::
Profile
>
RTC
::
RtpEncodingParameters
::
string2Profile
=
{
{
"
default"
,
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
},
{
"low"
,
RTC
::
RtpEncodingParameters
::
Profile
::
LOW
},
{
"medium"
,
RTC
::
RtpEncodingParameters
::
Profile
::
MEDIUM
},
{
"high"
,
RTC
::
RtpEncodingParameters
::
Profile
::
HIGH
}
{
"
none"
,
RTC
::
RtpEncodingParameters
::
Profile
::
NONE
},
{
"low"
,
RTC
::
RtpEncodingParameters
::
Profile
::
LOW
},
{
"medium"
,
RTC
::
RtpEncodingParameters
::
Profile
::
MEDIUM
},
{
"high"
,
RTC
::
RtpEncodingParameters
::
Profile
::
HIGH
}
};
std
::
map
<
RTC
::
RtpEncodingParameters
::
Profile
,
std
::
string
>
RTC
::
RtpEncodingParameters
::
profile2String
=
{
{
RTC
::
RtpEncodingParameters
::
Profile
::
DEFAULT
,
"default"
},
{
RTC
::
RtpEncodingParameters
::
Profile
::
LOW
,
"low"
},
{
RTC
::
RtpEncodingParameters
::
Profile
::
MEDIUM
,
"medium"
},
{
RTC
::
RtpEncodingParameters
::
Profile
::
HIGH
,
"high"
}
{
RTC
::
RtpEncodingParameters
::
Profile
::
NONE
,
"none"
},
{
RTC
::
RtpEncodingParameters
::
Profile
::
LOW
,
"low"
},
{
RTC
::
RtpEncodingParameters
::
Profile
::
MEDIUM
,
"medium"
},
{
RTC
::
RtpEncodingParameters
::
Profile
::
HIGH
,
"high"
}
};
// clang-format on
...
...
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
369857f5
...
...
@@ -250,13 +250,14 @@ namespace RTC
void
RtpStreamRecv
::
CheckHealth
()
{
auto
now
=
DepLibUV
::
GetTime
();
bool
healthy
=
true
;
if
(
this
->
receivedCounter
.
GetRate
(
now
)
==
0
)
this
->
healthy
=
false
;
else
this
->
healthy
=
true
;
healthy
=
false
;
this
->
listener
->
OnRtpStreamHealthReport
(
this
,
this
->
healthy
);
// NOTE: Update the 'healthy' value after notification.
this
->
listener
->
OnRtpStreamHealthReport
(
this
,
healthy
);
this
->
healthy
=
healthy
;
}
void
RtpStreamRecv
::
OnNackGeneratorNackRequired
(
const
std
::
vector
<
uint16_t
>&
seqNumbers
)
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
369857f5
...
...
@@ -1563,6 +1563,18 @@ namespace RTC
// Do nothing.
}
void
Transport
::
OnProducerProfileEnabled
(
RTC
::
Producer
*
/*producer*/
,
RTC
::
RtpEncodingParameters
::
Profile
/*profile*/
)
{
// Do nothing.
}
void
Transport
::
OnProducerProfileDisabled
(
RTC
::
Producer
*
/*producer*/
,
RTC
::
RtpEncodingParameters
::
Profile
/*profile*/
)
{
// Do nothing.
}
void
Transport
::
OnConsumerClosed
(
RTC
::
Consumer
*
consumer
)
{
MS_TRACE
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论