Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
feb7fd40
提交
feb7fd40
authored
4月 26, 2019
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Producer: avoid unneeded key frames
上级
f2939643
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
70 行增加
和
9 行删除
+70
-9
Producer.hpp
worker/include/RTC/Producer.hpp
+2
-0
Producer.cpp
worker/src/RTC/Producer.cpp
+68
-9
没有找到文件。
worker/include/RTC/Producer.hpp
浏览文件 @
feb7fd40
...
@@ -82,6 +82,7 @@ namespace RTC
...
@@ -82,6 +82,7 @@ namespace RTC
RTC
::
RtpStreamRecv
*
GetRtpStream
(
RTC
::
RtpPacket
*
packet
);
RTC
::
RtpStreamRecv
*
GetRtpStream
(
RTC
::
RtpPacket
*
packet
);
RTC
::
RtpStreamRecv
*
CreateRtpStream
(
RTC
::
RtpStreamRecv
*
CreateRtpStream
(
RTC
::
RtpPacket
*
packet
,
const
RTC
::
RtpCodecParameters
&
mediaCodec
,
size_t
encodingIdx
);
RTC
::
RtpPacket
*
packet
,
const
RTC
::
RtpCodecParameters
&
mediaCodec
,
size_t
encodingIdx
);
void
NotifyNewRtpStream
(
RTC
::
RtpStreamRecv
*
rtpStream
);
bool
MangleRtpPacket
(
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpStreamRecv
*
rtpStream
)
const
;
bool
MangleRtpPacket
(
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpStreamRecv
*
rtpStream
)
const
;
void
PostProcessRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
PostProcessRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
EmitScore
()
const
;
void
EmitScore
()
const
;
...
@@ -117,6 +118,7 @@ namespace RTC
...
@@ -117,6 +118,7 @@ namespace RTC
std
::
map
<
uint32_t
,
uint32_t
>
mapMappedSsrcSsrc
;
std
::
map
<
uint32_t
,
uint32_t
>
mapMappedSsrcSsrc
;
struct
RTC
::
RtpHeaderExtensionIds
rtpHeaderExtensionIds
;
struct
RTC
::
RtpHeaderExtensionIds
rtpHeaderExtensionIds
;
bool
paused
{
false
};
bool
paused
{
false
};
RTC
::
RtpPacket
*
currentRtpPacket
{
nullptr
};
// Timestamp when last RTCP was sent.
// Timestamp when last RTCP was sent.
uint64_t
lastRtcpSentTime
{
0
};
uint64_t
lastRtcpSentTime
{
0
};
uint16_t
maxRtcpInterval
{
0
};
uint16_t
maxRtcpInterval
{
0
};
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
feb7fd40
...
@@ -412,6 +412,12 @@ namespace RTC
...
@@ -412,6 +412,12 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// Reset current packet.
this
->
currentRtpPacket
=
nullptr
;
// Count number of RTP streams.
auto
numRtpStreamsBefore
=
this
->
mapSsrcRtpStream
.
size
();
auto
*
rtpStream
=
GetRtpStream
(
packet
);
auto
*
rtpStream
=
GetRtpStream
(
packet
);
if
(
rtpStream
==
nullptr
)
if
(
rtpStream
==
nullptr
)
...
@@ -426,7 +432,13 @@ namespace RTC
...
@@ -426,7 +432,13 @@ namespace RTC
{
{
// Process the packet.
// Process the packet.
if
(
!
rtpStream
->
ReceivePacket
(
packet
))
if
(
!
rtpStream
->
ReceivePacket
(
packet
))
{
// May have to announce a new RTP stream to the listener.
if
(
this
->
mapSsrcRtpStream
.
size
()
>
numRtpStreamsBefore
)
NotifyNewRtpStream
(
rtpStream
);
return
;
return
;
}
}
}
// RTX packet.
// RTX packet.
else
if
(
packet
->
GetSsrc
()
==
rtpStream
->
GetRtxSsrc
())
else
if
(
packet
->
GetSsrc
()
==
rtpStream
->
GetRtxSsrc
())
...
@@ -443,6 +455,12 @@ namespace RTC
...
@@ -443,6 +455,12 @@ namespace RTC
if
(
packet
->
IsKeyFrame
())
if
(
packet
->
IsKeyFrame
())
{
{
// TODO
MS_ERROR
(
"key frame received [ssrc:%"
PRIu32
", seq:%"
PRIu16
"]"
,
packet
->
GetSsrc
(),
packet
->
GetSequenceNumber
());
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
rtp
,
rtp
,
"key frame received [ssrc:%"
PRIu32
", seq:%"
PRIu16
"]"
,
"key frame received [ssrc:%"
PRIu32
", seq:%"
PRIu16
"]"
,
...
@@ -454,6 +472,23 @@ namespace RTC
...
@@ -454,6 +472,23 @@ namespace RTC
this
->
keyFrameRequestManager
->
KeyFrameReceived
(
packet
->
GetSsrc
());
this
->
keyFrameRequestManager
->
KeyFrameReceived
(
packet
->
GetSsrc
());
}
}
// May have to announce a new RTP stream to the listener.
if
(
this
->
mapSsrcRtpStream
.
size
()
>
numRtpStreamsBefore
)
{
// Request a key frame for this stream since we may have lost the first packets
// (do not do it if this is a key frame).
if
(
this
->
keyFrameRequestManager
&&
!
this
->
paused
&&
!
packet
->
IsKeyFrame
())
this
->
keyFrameRequestManager
->
ForceKeyFrameNeeded
(
packet
->
GetSsrc
());
// Update current packet.
this
->
currentRtpPacket
=
packet
;
NotifyNewRtpStream
(
rtpStream
);
// Reset current packet.
this
->
currentRtpPacket
=
nullptr
;
}
// If paused stop here.
// If paused stop here.
if
(
this
->
paused
)
if
(
this
->
paused
)
return
;
return
;
...
@@ -522,6 +557,26 @@ namespace RTC
...
@@ -522,6 +557,26 @@ namespace RTC
uint32_t
ssrc
=
it
->
second
;
uint32_t
ssrc
=
it
->
second
;
// If the current RTP packet is a key frame for the given mapped SSRC do
// nothing since we are gonna provide Consumers with the requested key frame
// right now.
//
// NOTE: We know that this may only happen before calling MangleRtpPacket()
// so the SSRC of the packet is still the original one and not the mapped one.
//
// clang-format off
if
(
this
->
currentRtpPacket
&&
this
->
currentRtpPacket
->
GetSsrc
()
==
ssrc
&&
this
->
currentRtpPacket
->
IsKeyFrame
()
)
// clang-format on
{
MS_ERROR
(
"----- IGNORING BECAUSE CURRENT PACKET IS KEY FRAME [ssrc:%"
PRIu32
"]"
,
ssrc
);
return
;
}
this
->
keyFrameRequestManager
->
KeyFrameNeeded
(
ssrc
);
this
->
keyFrameRequestManager
->
KeyFrameNeeded
(
ssrc
);
}
}
...
@@ -775,21 +830,23 @@ namespace RTC
...
@@ -775,21 +830,23 @@ namespace RTC
if
(
this
->
paused
)
if
(
this
->
paused
)
rtpStream
->
Pause
();
rtpStream
->
Pause
();
// Notify to the listener.
this
->
listener
->
OnProducerNewRtpStream
(
this
,
static_cast
<
RTC
::
RtpStream
*>
(
rtpStream
),
encodingMapping
.
mappedSsrc
);
// Request a key frame for this stream since we may have lost the first packets
// (do not do it if this is a key frame).
if
(
this
->
keyFrameRequestManager
&&
!
this
->
paused
&&
!
packet
->
IsKeyFrame
())
this
->
keyFrameRequestManager
->
ForceKeyFrameNeeded
(
ssrc
);
// Emit the first score event right now.
// Emit the first score event right now.
EmitScore
();
EmitScore
();
return
rtpStream
;
return
rtpStream
;
}
}
void
Producer
::
NotifyNewRtpStream
(
RTC
::
RtpStreamRecv
*
rtpStream
)
{
MS_TRACE
();
auto
mappedSsrc
=
this
->
mapRtpStreamMappedSsrc
.
at
(
rtpStream
);
// Notify the listener.
this
->
listener
->
OnProducerNewRtpStream
(
this
,
static_cast
<
RTC
::
RtpStream
*>
(
rtpStream
),
mappedSsrc
);
}
inline
bool
Producer
::
MangleRtpPacket
(
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpStreamRecv
*
rtpStream
)
const
inline
bool
Producer
::
MangleRtpPacket
(
RTC
::
RtpPacket
*
packet
,
RTC
::
RtpStreamRecv
*
rtpStream
)
const
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -1014,6 +1071,8 @@ namespace RTC
...
@@ -1014,6 +1071,8 @@ namespace RTC
auto
*
rtpStream
=
it
->
second
;
auto
*
rtpStream
=
it
->
second
;
MS_ERROR
(
"----- sending PLI [ssrc:%"
PRIu32
"]"
,
rtpStream
->
GetSsrc
());
rtpStream
->
RequestKeyFrame
();
rtpStream
->
RequestKeyFrame
();
}
}
}
// namespace RTC
}
// namespace RTC
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论