Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
79570051
提交
79570051
authored
2月 22, 2023
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RtpStreamSend.cpp: cosmetic, use braces
上级
72794578
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
0 行删除
+42
-0
RtpStreamSend.cpp
worker/src/RTC/RtpStreamSend.cpp
+42
-0
没有找到文件。
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
79570051
...
@@ -49,12 +49,16 @@ namespace RTC
...
@@ -49,12 +49,16 @@ namespace RTC
RtpStreamSend
::
StorageItem
*
RtpStreamSend
::
StorageItemBuffer
::
Get
(
uint16_t
seq
)
const
RtpStreamSend
::
StorageItem
*
RtpStreamSend
::
StorageItemBuffer
::
Get
(
uint16_t
seq
)
const
{
{
if
(
RTC
::
SeqManager
<
uint16_t
>::
IsSeqLowerThan
(
seq
,
this
->
startSeq
))
if
(
RTC
::
SeqManager
<
uint16_t
>::
IsSeqLowerThan
(
seq
,
this
->
startSeq
))
{
return
nullptr
;
return
nullptr
;
}
auto
idx
{
static_cast
<
uint16_t
>
(
seq
-
this
->
startSeq
)
};
auto
idx
{
static_cast
<
uint16_t
>
(
seq
-
this
->
startSeq
)
};
if
(
this
->
buffer
.
empty
()
||
idx
>
static_cast
<
uint16_t
>
(
this
->
buffer
.
size
()
-
1
))
if
(
this
->
buffer
.
empty
()
||
idx
>
static_cast
<
uint16_t
>
(
this
->
buffer
.
size
()
-
1
))
{
return
nullptr
;
return
nullptr
;
}
return
this
->
buffer
.
at
(
idx
);
return
this
->
buffer
.
at
(
idx
);
}
}
...
@@ -141,7 +145,9 @@ namespace RTC
...
@@ -141,7 +145,9 @@ namespace RTC
for
(
auto
*
storageItem
:
this
->
buffer
)
for
(
auto
*
storageItem
:
this
->
buffer
)
{
{
if
(
!
storageItem
)
if
(
!
storageItem
)
{
continue
;
continue
;
}
// Reset the storage item (decrease RTP packet shared pointer counter).
// Reset the storage item (decrease RTP packet shared pointer counter).
storageItem
->
Reset
();
storageItem
->
Reset
();
...
@@ -205,11 +211,15 @@ namespace RTC
...
@@ -205,11 +211,15 @@ namespace RTC
// Call the parent method.
// Call the parent method.
if
(
!
RtpStream
::
ReceiveStreamPacket
(
packet
))
if
(
!
RtpStream
::
ReceiveStreamPacket
(
packet
))
{
return
false
;
return
false
;
}
// If NACK is enabled, store the packet into the buffer.
// If NACK is enabled, store the packet into the buffer.
if
(
this
->
params
.
useNack
)
if
(
this
->
params
.
useNack
)
{
StorePacket
(
packet
,
sharedPacket
);
StorePacket
(
packet
,
sharedPacket
);
}
// Increase transmission counter.
// Increase transmission counter.
this
->
transmissionCounter
.
Update
(
packet
);
this
->
transmissionCounter
.
Update
(
packet
);
...
@@ -234,7 +244,9 @@ namespace RTC
...
@@ -234,7 +244,9 @@ namespace RTC
for
(
auto
*
storageItem
:
RetransmissionContainer
)
for
(
auto
*
storageItem
:
RetransmissionContainer
)
{
{
if
(
!
storageItem
)
if
(
!
storageItem
)
{
break
;
break
;
}
// Note that this is an already RTX encoded packet if RTX is used
// Note that this is an already RTX encoded packet if RTX is used
// (FillRetransmissionContainer() did it).
// (FillRetransmissionContainer() did it).
...
@@ -249,7 +261,9 @@ namespace RTC
...
@@ -249,7 +261,9 @@ namespace RTC
// Mark the packet as repaired (only if this is the first retransmission).
// Mark the packet as repaired (only if this is the first retransmission).
if
(
storageItem
->
sentTimes
==
1
)
if
(
storageItem
->
sentTimes
==
1
)
{
RTC
::
RtpStream
::
PacketRepaired
(
packet
.
get
());
RTC
::
RtpStream
::
PacketRepaired
(
packet
.
get
());
}
if
(
HasRtx
())
if
(
HasRtx
())
{
{
...
@@ -302,7 +316,9 @@ namespace RTC
...
@@ -302,7 +316,9 @@ namespace RTC
// If no Sender Report was received by the remote endpoint yet, ignore lastSr
// If no Sender Report was received by the remote endpoint yet, ignore lastSr
// and dlsr values in the Receiver Report.
// and dlsr values in the Receiver Report.
if
(
lastSr
&&
dlsr
&&
(
compactNtp
>
dlsr
+
lastSr
))
if
(
lastSr
&&
dlsr
&&
(
compactNtp
>
dlsr
+
lastSr
))
{
rtt
=
compactNtp
-
dlsr
-
lastSr
;
rtt
=
compactNtp
-
dlsr
-
lastSr
;
}
// RTT in milliseconds.
// RTT in milliseconds.
this
->
rtt
=
static_cast
<
float
>
(
rtt
>>
16
)
*
1000
;
this
->
rtt
=
static_cast
<
float
>
(
rtt
>>
16
)
*
1000
;
...
@@ -343,7 +359,9 @@ namespace RTC
...
@@ -343,7 +359,9 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
if
(
this
->
transmissionCounter
.
GetPacketCount
()
==
0u
)
if
(
this
->
transmissionCounter
.
GetPacketCount
()
==
0u
)
{
return
nullptr
;
return
nullptr
;
}
auto
ntp
=
Utils
::
Time
::
TimeMs2Ntp
(
nowMs
);
auto
ntp
=
Utils
::
Time
::
TimeMs2Ntp
(
nowMs
);
auto
*
report
=
new
RTC
::
RTCP
::
SenderReport
();
auto
*
report
=
new
RTC
::
RTCP
::
SenderReport
();
...
@@ -371,7 +389,9 @@ namespace RTC
...
@@ -371,7 +389,9 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
if
(
this
->
lastRrReceivedMs
==
0u
)
if
(
this
->
lastRrReceivedMs
==
0u
)
{
return
nullptr
;
return
nullptr
;
}
// Get delay in milliseconds.
// Get delay in milliseconds.
auto
delayMs
=
static_cast
<
uint32_t
>
(
nowMs
-
this
->
lastRrReceivedMs
);
auto
delayMs
=
static_cast
<
uint32_t
>
(
nowMs
-
this
->
lastRrReceivedMs
);
...
@@ -469,7 +489,9 @@ namespace RTC
...
@@ -469,7 +489,9 @@ namespace RTC
// RTP packet is older than the retransmission buffer size.
// RTP packet is older than the retransmission buffer size.
if
(
static_cast
<
uint32_t
>
(
diffTs
*
1000
/
this
->
params
.
clockRate
)
>=
this
->
retransmissionBufferSize
)
if
(
static_cast
<
uint32_t
>
(
diffTs
*
1000
/
this
->
params
.
clockRate
)
>=
this
->
retransmissionBufferSize
)
{
return
;
return
;
}
}
}
}
}
...
@@ -483,7 +505,9 @@ namespace RTC
...
@@ -483,7 +505,9 @@ namespace RTC
if
(
storageItem
)
if
(
storageItem
)
{
{
if
(
packet
->
GetTimestamp
()
==
storageItem
->
timestamp
)
if
(
packet
->
GetTimestamp
()
==
storageItem
->
timestamp
)
{
return
;
return
;
}
// Reset the storage item.
// Reset the storage item.
storageItem
->
Reset
();
storageItem
->
Reset
();
...
@@ -527,11 +551,15 @@ namespace RTC
...
@@ -527,11 +551,15 @@ namespace RTC
// Processing RTP packet is older than first one.
// Processing RTP packet is older than first one.
if
(
RTC
::
SeqManager
<
uint32_t
>::
IsSeqLowerThan
(
packet
->
GetTimestamp
(),
storageItem
->
timestamp
))
if
(
RTC
::
SeqManager
<
uint32_t
>::
IsSeqLowerThan
(
packet
->
GetTimestamp
(),
storageItem
->
timestamp
))
{
break
;
break
;
}
// First RTP packet is recent enough.
// First RTP packet is recent enough.
if
(
static_cast
<
uint32_t
>
(
diffTs
*
1000
/
clockRate
)
<
this
->
retransmissionBufferSize
)
if
(
static_cast
<
uint32_t
>
(
diffTs
*
1000
/
clockRate
)
<
this
->
retransmissionBufferSize
)
{
break
;
break
;
}
// Unfill the buffer start item.
// Unfill the buffer start item.
this
->
storageItemBuffer
.
RemoveFirst
();
this
->
storageItemBuffer
.
RemoveFirst
();
...
@@ -603,7 +631,9 @@ namespace RTC
...
@@ -603,7 +631,9 @@ namespace RTC
// Update MID RTP extension value.
// Update MID RTP extension value.
if
(
!
this
->
mid
.
empty
())
if
(
!
this
->
mid
.
empty
())
{
packet
->
UpdateMid
(
mid
);
packet
->
UpdateMid
(
mid
);
}
const
uint32_t
diffTs
=
this
->
maxPacketTs
-
packet
->
GetTimestamp
();
const
uint32_t
diffTs
=
this
->
maxPacketTs
-
packet
->
GetTimestamp
();
...
@@ -670,7 +700,9 @@ namespace RTC
...
@@ -670,7 +700,9 @@ namespace RTC
sent
=
true
;
sent
=
true
;
if
(
isFirstPacket
)
if
(
isFirstPacket
)
{
firstPacketSent
=
true
;
firstPacketSent
=
true
;
}
}
}
}
}
...
@@ -728,9 +760,13 @@ namespace RTC
...
@@ -728,9 +760,13 @@ namespace RTC
uint32_t
lost
;
uint32_t
lost
;
if
(
totalLost
<
this
->
lostPriorScore
)
if
(
totalLost
<
this
->
lostPriorScore
)
{
lost
=
0
;
lost
=
0
;
}
else
else
{
lost
=
totalLost
-
this
->
lostPriorScore
;
lost
=
totalLost
-
this
->
lostPriorScore
;
}
this
->
lostPriorScore
=
totalLost
;
this
->
lostPriorScore
=
totalLost
;
...
@@ -755,10 +791,14 @@ namespace RTC
...
@@ -755,10 +791,14 @@ namespace RTC
}
}
if
(
lost
>
sent
)
if
(
lost
>
sent
)
{
lost
=
sent
;
lost
=
sent
;
}
if
(
repaired
>
lost
)
if
(
repaired
>
lost
)
{
repaired
=
lost
;
repaired
=
lost
;
}
#if MS_LOG_DEV_LEVEL == 3
#if MS_LOG_DEV_LEVEL == 3
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
...
@@ -783,7 +823,9 @@ namespace RTC
...
@@ -783,7 +823,9 @@ namespace RTC
MS_ASSERT
(
retransmitted
>=
repaired
,
"repaired packets cannot be more than retransmitted ones"
);
MS_ASSERT
(
retransmitted
>=
repaired
,
"repaired packets cannot be more than retransmitted ones"
);
if
(
retransmitted
>
0
)
if
(
retransmitted
>
0
)
{
repairedWeight
*=
static_cast
<
float
>
(
repaired
)
/
retransmitted
;
repairedWeight
*=
static_cast
<
float
>
(
repaired
)
/
retransmitted
;
}
lost
-=
repaired
*
repairedWeight
;
lost
-=
repaired
*
repairedWeight
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论