Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
bfaf8834
Unverified
提交
bfaf8834
authored
1月 27, 2023
作者:
José Luis Millán
提交者:
GitHub
1月 27, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Worker: const correctness (#994)
上级
8287299f
显示空白字符变更
内嵌
并排
正在显示
25 个修改的文件
包含
99 行增加
和
93 行删除
+99
-93
.clang-format
worker/.clang-format
+1
-0
.clang-tidy
worker/.clang-tidy
+1
-0
ActiveSpeakerObserver.cpp
worker/src/RTC/ActiveSpeakerObserver.cpp
+8
-8
Consumer.cpp
worker/src/RTC/Consumer.cpp
+2
-2
DtlsTransport.cpp
worker/src/RTC/DtlsTransport.cpp
+3
-3
NackGenerator.cpp
worker/src/RTC/NackGenerator.cpp
+3
-3
PortManager.cpp
worker/src/RTC/PortManager.cpp
+3
-3
Producer.cpp
worker/src/RTC/Producer.cpp
+2
-2
RateCalculator.cpp
worker/src/RTC/RateCalculator.cpp
+2
-2
RtpPacket.cpp
worker/src/RTC/RtpPacket.cpp
+5
-5
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+4
-4
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+7
-7
RtpStreamSend.cpp
worker/src/RTC/RtpStreamSend.cpp
+8
-8
RtxStream.cpp
worker/src/RTC/RtxStream.cpp
+7
-7
SctpAssociation.cpp
worker/src/RTC/SctpAssociation.cpp
+9
-8
SenderBandwidthEstimator.cpp
worker/src/RTC/SenderBandwidthEstimator.cpp
+2
-2
SimpleConsumer.cpp
worker/src/RTC/SimpleConsumer.cpp
+1
-1
SimulcastConsumer.cpp
worker/src/RTC/SimulcastConsumer.cpp
+3
-3
SrtpSession.cpp
worker/src/RTC/SrtpSession.cpp
+8
-7
StunPacket.cpp
worker/src/RTC/StunPacket.cpp
+12
-10
SvcConsumer.cpp
worker/src/RTC/SvcConsumer.cpp
+2
-2
TcpConnection.cpp
worker/src/RTC/TcpConnection.cpp
+1
-1
Transport.cpp
worker/src/RTC/Transport.cpp
+1
-1
TransportCongestionControlClient.cpp
worker/src/RTC/TransportCongestionControlClient.cpp
+3
-3
TestFeedbackRtpTransport.cpp
worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp
+1
-1
没有找到文件。
worker/.clang-format
浏览文件 @
bfaf8834
...
@@ -36,6 +36,7 @@ BreakBeforeTernaryOperators: true
...
@@ -36,6 +36,7 @@ BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: false
BreakStringLiterals: false
ColumnLimit: 100
ColumnLimit: 100
QualifierAlignment: Left
CommentPragmas: 'NOLINT'
CommentPragmas: 'NOLINT'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ConstructorInitializerIndentWidth: 2
...
...
worker/.clang-tidy
浏览文件 @
bfaf8834
...
@@ -4,6 +4,7 @@ Checks: '*,-llvmlibc-*,-boost-use-to-string,-cert-*,-clang-analyzer-osx.*,-clang
...
@@ -4,6 +4,7 @@ Checks: '*,-llvmlibc-*,-boost-use-to-string,-cert-*,-clang-analyzer-osx.*,-clang
HeaderFilterRegex: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
AnalyzeTemporaryDtors: false
User: mediasoup
User: mediasoup
FormatStyle: file
CheckOptions:
CheckOptions:
- key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
- key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
value: ''
value: ''
...
...
worker/src/RTC/ActiveSpeakerObserver.cpp
浏览文件 @
bfaf8834
...
@@ -33,7 +33,7 @@ namespace RTC
...
@@ -33,7 +33,7 @@ namespace RTC
inline
int64_t
BinomialCoefficient
(
int32_t
n
,
int32_t
r
)
inline
int64_t
BinomialCoefficient
(
int32_t
n
,
int32_t
r
)
{
{
int32_t
m
=
n
-
r
;
const
int32_t
m
=
n
-
r
;
if
(
r
<
m
)
if
(
r
<
m
)
{
{
...
@@ -69,14 +69,14 @@ namespace RTC
...
@@ -69,14 +69,14 @@ namespace RTC
{
{
uint32_t
littleLen
=
littles
.
size
();
uint32_t
littleLen
=
littles
.
size
();
uint32_t
bigLen
=
bigs
.
size
();
uint32_t
bigLen
=
bigs
.
size
();
uint32_t
littleLenPerBig
=
littleLen
/
bigLen
;
const
uint32_t
littleLenPerBig
=
littleLen
/
bigLen
;
bool
changed
{
false
};
bool
changed
{
false
};
for
(
uint32_t
b
=
0u
,
l
=
0u
;
b
<
bigLen
;
++
b
)
for
(
uint32_t
b
=
0u
,
l
=
0u
;
b
<
bigLen
;
++
b
)
{
{
uint8_t
sum
{
0u
};
uint8_t
sum
{
0u
};
for
(
uint32_t
lEnd
=
l
+
littleLenPerBig
;
l
<
lEnd
;
++
l
)
for
(
const
uint32_t
lEnd
=
l
+
littleLenPerBig
;
l
<
lEnd
;
++
l
)
{
{
if
(
littles
[
l
]
>
threashold
)
if
(
littles
[
l
]
>
threashold
)
{
{
...
@@ -261,7 +261,7 @@ namespace RTC
...
@@ -261,7 +261,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint64_t
now
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
now
=
DepLibUV
::
GetTimeMs
();
if
(
now
-
this
->
lastLevelIdleTime
>=
LevelIdleTimeout
)
if
(
now
-
this
->
lastLevelIdleTime
>=
LevelIdleTimeout
)
{
{
...
@@ -452,7 +452,7 @@ namespace RTC
...
@@ -452,7 +452,7 @@ namespace RTC
{
{
if
(
this
->
lastLevelChangeTime
<=
now
)
if
(
this
->
lastLevelChangeTime
<=
now
)
{
{
uint64_t
elapsed
=
now
-
this
->
lastLevelChangeTime
;
const
uint64_t
elapsed
=
now
-
this
->
lastLevelChangeTime
;
this
->
lastLevelChangeTime
=
now
;
this
->
lastLevelChangeTime
=
now
;
...
@@ -498,7 +498,7 @@ namespace RTC
...
@@ -498,7 +498,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
int8_t
minLevel
=
this
->
minLevel
+
SubunitLengthN1
;
const
int8_t
minLevel
=
this
->
minLevel
+
SubunitLengthN1
;
bool
changed
=
false
;
bool
changed
=
false
;
for
(
uint32_t
i
=
0
;
i
<
ImmediateBuffLen
;
++
i
)
for
(
uint32_t
i
=
0
;
i
<
ImmediateBuffLen
;
++
i
)
...
@@ -506,7 +506,7 @@ namespace RTC
...
@@ -506,7 +506,7 @@ namespace RTC
// this->levels is a circular buffer where new samples are written in the
// this->levels is a circular buffer where new samples are written in the
// next vector index. this->immediates is a buffer where the most recent
// next vector index. this->immediates is a buffer where the most recent
// value is always in index 0.
// value is always in index 0.
size_t
levelIndex
=
this
->
nextLevelIndex
>=
(
i
+
1
)
const
size_t
levelIndex
=
this
->
nextLevelIndex
>=
(
i
+
1
)
?
this
->
nextLevelIndex
-
i
-
1
?
this
->
nextLevelIndex
-
i
-
1
:
this
->
nextLevelIndex
+
LevelsBuffLen
-
i
-
1
;
:
this
->
nextLevelIndex
+
LevelsBuffLen
-
i
-
1
;
uint8_t
level
=
this
->
levels
[
levelIndex
];
uint8_t
level
=
this
->
levels
[
levelIndex
];
...
@@ -516,7 +516,7 @@ namespace RTC
...
@@ -516,7 +516,7 @@ namespace RTC
level
=
MinLevel
;
level
=
MinLevel
;
}
}
uint8_t
immediate
=
(
level
/
SubunitLengthN1
);
const
uint8_t
immediate
=
(
level
/
SubunitLengthN1
);
if
(
this
->
immediates
[
i
]
!=
immediate
)
if
(
this
->
immediates
[
i
]
!=
immediate
)
{
{
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
bfaf8834
...
@@ -273,7 +273,7 @@ namespace RTC
...
@@ -273,7 +273,7 @@ namespace RTC
return
;
return
;
}
}
bool
wasActive
=
IsActive
();
const
bool
wasActive
=
IsActive
();
this
->
paused
=
true
;
this
->
paused
=
true
;
...
@@ -410,7 +410,7 @@ namespace RTC
...
@@ -410,7 +410,7 @@ namespace RTC
if
(
this
->
producerPaused
)
if
(
this
->
producerPaused
)
return
;
return
;
bool
wasActive
=
IsActive
();
const
bool
wasActive
=
IsActive
();
this
->
producerPaused
=
true
;
this
->
producerPaused
=
true
;
...
...
worker/src/RTC/DtlsTransport.cpp
浏览文件 @
bfaf8834
...
@@ -647,7 +647,7 @@ namespace RTC
...
@@ -647,7 +647,7 @@ namespace RTC
localRole
==
Role
::
CLIENT
||
localRole
==
Role
::
SERVER
,
localRole
==
Role
::
CLIENT
||
localRole
==
Role
::
SERVER
,
"local DTLS role must be 'client' or 'server'"
);
"local DTLS role must be 'client' or 'server'"
);
Role
previousLocalRole
=
this
->
localRole
;
const
Role
previousLocalRole
=
this
->
localRole
;
if
(
localRole
==
previousLocalRole
)
if
(
localRole
==
previousLocalRole
)
{
{
...
@@ -860,7 +860,7 @@ namespace RTC
...
@@ -860,7 +860,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
int
err
;
int
err
;
bool
wasHandshakeDone
=
this
->
handshakeDone
;
const
bool
wasHandshakeDone
=
this
->
handshakeDone
;
err
=
SSL_get_error
(
this
->
ssl
,
returnCode
);
err
=
SSL_get_error
(
this
->
ssl
,
returnCode
);
...
@@ -1342,7 +1342,7 @@ namespace RTC
...
@@ -1342,7 +1342,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
int
w
=
where
&
-
SSL_ST_MASK
;
const
int
w
=
where
&
-
SSL_ST_MASK
;
const
char
*
role
;
const
char
*
role
;
if
((
w
&
SSL_ST_CONNECT
)
!=
0
)
if
((
w
&
SSL_ST_CONNECT
)
!=
0
)
...
...
worker/src/RTC/NackGenerator.cpp
浏览文件 @
bfaf8834
...
@@ -43,7 +43,7 @@ namespace RTC
...
@@ -43,7 +43,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
bool
isKeyFrame
=
packet
->
IsKeyFrame
();
const
bool
isKeyFrame
=
packet
->
IsKeyFrame
();
if
(
!
this
->
started
)
if
(
!
this
->
started
)
{
{
...
@@ -156,7 +156,7 @@ namespace RTC
...
@@ -156,7 +156,7 @@ namespace RTC
// If the nack list is too large, remove packets from the nack list until
// If the nack list is too large, remove packets from the nack list until
// the latest first packet of a keyframe. If the list is still too large,
// the latest first packet of a keyframe. If the list is still too large,
// clear it and request a keyframe.
// clear it and request a keyframe.
uint16_t
numNewNacks
=
seqEnd
-
seqStart
;
const
uint16_t
numNewNacks
=
seqEnd
-
seqStart
;
if
(
static_cast
<
uint16_t
>
(
this
->
nackList
.
size
())
+
numNewNacks
>
MaxNackPackets
)
if
(
static_cast
<
uint16_t
>
(
this
->
nackList
.
size
())
+
numNewNacks
>
MaxNackPackets
)
{
{
...
@@ -228,7 +228,7 @@ namespace RTC
...
@@ -228,7 +228,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
std
::
vector
<
uint16_t
>
nackBatch
;
std
::
vector
<
uint16_t
>
nackBatch
;
auto
it
=
this
->
nackList
.
begin
();
auto
it
=
this
->
nackList
.
begin
();
...
...
worker/src/RTC/PortManager.cpp
浏览文件 @
bfaf8834
...
@@ -505,7 +505,7 @@ namespace RTC
...
@@ -505,7 +505,7 @@ namespace RTC
return
;
return
;
}
}
size_t
portIdx
=
static_cast
<
size_t
>
(
port
)
-
Settings
::
configuration
.
rtcMinPort
;
const
size_t
portIdx
=
static_cast
<
size_t
>
(
port
)
-
Settings
::
configuration
.
rtcMinPort
;
switch
(
transport
)
switch
(
transport
)
{
{
...
@@ -564,7 +564,7 @@ namespace RTC
...
@@ -564,7 +564,7 @@ namespace RTC
}
}
// Otherwise add an entry in the map and return it.
// Otherwise add an entry in the map and return it.
uint16_t
numPorts
=
const
uint16_t
numPorts
=
Settings
::
configuration
.
rtcMaxPort
-
Settings
::
configuration
.
rtcMinPort
+
1
;
Settings
::
configuration
.
rtcMaxPort
-
Settings
::
configuration
.
rtcMinPort
+
1
;
// Emplace a new vector filled with numPorts false values, meaning that
// Emplace a new vector filled with numPorts false values, meaning that
...
@@ -591,7 +591,7 @@ namespace RTC
...
@@ -591,7 +591,7 @@ namespace RTC
}
}
// Otherwise add an entry in the map and return it.
// Otherwise add an entry in the map and return it.
uint16_t
numPorts
=
const
uint16_t
numPorts
=
Settings
::
configuration
.
rtcMaxPort
-
Settings
::
configuration
.
rtcMinPort
+
1
;
Settings
::
configuration
.
rtcMaxPort
-
Settings
::
configuration
.
rtcMinPort
+
1
;
// Emplace a new vector filled with numPorts false values, meaning that
// Emplace a new vector filled with numPorts false values, meaning that
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
bfaf8834
...
@@ -1351,7 +1351,7 @@ namespace RTC
...
@@ -1351,7 +1351,7 @@ namespace RTC
extenLen
=
3u
;
extenLen
=
3u
;
// NOTE: Add value 0. The sending Transport will update it.
// NOTE: Add value 0. The sending Transport will update it.
uint32_t
absSendTime
{
0u
};
const
uint32_t
absSendTime
{
0u
};
Utils
::
Byte
::
Set3Bytes
(
bufferPtr
,
0
,
absSendTime
);
Utils
::
Byte
::
Set3Bytes
(
bufferPtr
,
0
,
absSendTime
);
...
@@ -1367,7 +1367,7 @@ namespace RTC
...
@@ -1367,7 +1367,7 @@ namespace RTC
extenLen
=
2u
;
extenLen
=
2u
;
// NOTE: Add value 0. The sending Transport will update it.
// NOTE: Add value 0. The sending Transport will update it.
uint16_t
wideSeqNumber
{
0u
};
const
uint16_t
wideSeqNumber
{
0u
};
Utils
::
Byte
::
Set2Bytes
(
bufferPtr
,
0
,
wideSeqNumber
);
Utils
::
Byte
::
Set2Bytes
(
bufferPtr
,
0
,
wideSeqNumber
);
...
...
worker/src/RTC/RateCalculator.cpp
浏览文件 @
bfaf8834
...
@@ -69,7 +69,7 @@ namespace RTC
...
@@ -69,7 +69,7 @@ namespace RTC
RemoveOldData
(
nowMs
);
RemoveOldData
(
nowMs
);
float
scale
=
this
->
scale
/
this
->
windowSizeMs
;
const
float
scale
=
this
->
scale
/
this
->
windowSizeMs
;
this
->
lastTime
=
nowMs
;
this
->
lastTime
=
nowMs
;
this
->
lastRate
=
static_cast
<
uint32_t
>
(
std
::
trunc
(
this
->
totalCount
*
scale
+
0.5
f
));
this
->
lastRate
=
static_cast
<
uint32_t
>
(
std
::
trunc
(
this
->
totalCount
*
scale
+
0.5
f
));
...
@@ -85,7 +85,7 @@ namespace RTC
...
@@ -85,7 +85,7 @@ namespace RTC
if
(
this
->
newestItemIndex
<
0
||
this
->
oldestItemIndex
<
0
)
if
(
this
->
newestItemIndex
<
0
||
this
->
oldestItemIndex
<
0
)
return
;
return
;
uint64_t
newOldestTime
=
nowMs
-
this
->
windowSizeMs
;
const
uint64_t
newOldestTime
=
nowMs
-
this
->
windowSizeMs
;
// Oldest item already removed.
// Oldest item already removed.
if
(
newOldestTime
<
this
->
oldestItemStartTime
)
if
(
newOldestTime
<
this
->
oldestItemStartTime
)
...
...
worker/src/RTC/RtpPacket.cpp
浏览文件 @
bfaf8834
...
@@ -434,7 +434,7 @@ namespace RTC
...
@@ -434,7 +434,7 @@ namespace RTC
auto
paddedExtensionsTotalSize
=
auto
paddedExtensionsTotalSize
=
static_cast
<
size_t
>
(
Utils
::
Byte
::
PadTo4Bytes
(
static_cast
<
uint16_t
>
(
extensionsTotalSize
)));
static_cast
<
size_t
>
(
Utils
::
Byte
::
PadTo4Bytes
(
static_cast
<
uint16_t
>
(
extensionsTotalSize
)));
size_t
padding
=
paddedExtensionsTotalSize
-
extensionsTotalSize
;
const
size_t
padding
=
paddedExtensionsTotalSize
-
extensionsTotalSize
;
extensionsTotalSize
=
paddedExtensionsTotalSize
;
extensionsTotalSize
=
paddedExtensionsTotalSize
;
...
@@ -876,8 +876,8 @@ namespace RTC
...
@@ -876,8 +876,8 @@ namespace RTC
// One-Byte extensions cannot have length 0.
// One-Byte extensions cannot have length 0.
while
(
ptr
<
extensionEnd
)
while
(
ptr
<
extensionEnd
)
{
{
uint8_t
id
=
(
*
ptr
&
0xF0
)
>>
4
;
const
uint8_t
id
=
(
*
ptr
&
0xF0
)
>>
4
;
size_t
len
=
static_cast
<
size_t
>
(
*
ptr
&
0x0F
)
+
1
;
const
size_t
len
=
static_cast
<
size_t
>
(
*
ptr
&
0x0F
)
+
1
;
// id=15 in One-Byte extensions means "stop parsing here".
// id=15 in One-Byte extensions means "stop parsing here".
if
(
id
==
15u
)
if
(
id
==
15u
)
...
@@ -929,8 +929,8 @@ namespace RTC
...
@@ -929,8 +929,8 @@ namespace RTC
// Two-Byte extensions can have length 0.
// Two-Byte extensions can have length 0.
while
(
ptr
+
1
<
extensionEnd
)
while
(
ptr
+
1
<
extensionEnd
)
{
{
uint8_t
id
=
*
ptr
;
const
uint8_t
id
=
*
ptr
;
uint8_t
len
=
*
(
ptr
+
1
);
const
uint8_t
len
=
*
(
ptr
+
1
);
// Valid extension id.
// Valid extension id.
if
(
id
!=
0u
)
if
(
id
!=
0u
)
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
bfaf8834
...
@@ -49,7 +49,7 @@ namespace RTC
...
@@ -49,7 +49,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
jsonObject
[
"timestamp"
]
=
nowMs
;
jsonObject
[
"timestamp"
]
=
nowMs
;
jsonObject
[
"ssrc"
]
=
this
->
params
.
ssrc
;
jsonObject
[
"ssrc"
]
=
this
->
params
.
ssrc
;
...
@@ -113,7 +113,7 @@ namespace RTC
...
@@ -113,7 +113,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
const
uint16_t
seq
=
packet
->
GetSequenceNumber
();
// If this is the first packet seen, initialize stuff.
// If this is the first packet seen, initialize stuff.
if
(
!
this
->
started
)
if
(
!
this
->
started
)
...
@@ -174,8 +174,8 @@ namespace RTC
...
@@ -174,8 +174,8 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
const
uint16_t
seq
=
packet
->
GetSequenceNumber
();
uint16_t
udelta
=
seq
-
this
->
maxSeq
;
const
uint16_t
udelta
=
seq
-
this
->
maxSeq
;
// If the new packet sequence number is greater than the max seen but not
// If the new packet sequence number is greater than the max seen but not
// "so much bigger", accept it.
// "so much bigger", accept it.
...
...
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
bfaf8834
...
@@ -216,7 +216,7 @@ namespace RTC
...
@@ -216,7 +216,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
RTC
::
RtpStream
::
FillJsonStats
(
jsonObject
);
RTC
::
RtpStream
::
FillJsonStats
(
jsonObject
);
...
@@ -429,7 +429,7 @@ namespace RTC
...
@@ -429,7 +429,7 @@ namespace RTC
report
->
SetSsrc
(
GetSsrc
());
report
->
SetSsrc
(
GetSsrc
());
uint32_t
prevPacketsLost
=
this
->
packetsLost
;
const
uint32_t
prevPacketsLost
=
this
->
packetsLost
;
// Calculate Packets Expected and Lost.
// Calculate Packets Expected and Lost.
auto
expected
=
GetExpectedPackets
();
auto
expected
=
GetExpectedPackets
();
...
@@ -448,7 +448,7 @@ namespace RTC
...
@@ -448,7 +448,7 @@ namespace RTC
this
->
receivedPrior
=
this
->
mediaTransmissionCounter
.
GetPacketCount
();
this
->
receivedPrior
=
this
->
mediaTransmissionCounter
.
GetPacketCount
();
int32_t
lostInterval
=
expectedInterval
-
receivedInterval
;
const
int32_t
lostInterval
=
expectedInterval
-
receivedInterval
;
if
(
expectedInterval
==
0
||
lostInterval
<=
0
)
if
(
expectedInterval
==
0
||
lostInterval
<=
0
)
this
->
fractionLost
=
0
;
this
->
fractionLost
=
0
;
...
@@ -466,7 +466,7 @@ namespace RTC
...
@@ -466,7 +466,7 @@ namespace RTC
else
else
{
{
// Recalculate packetsLost.
// Recalculate packetsLost.
uint32_t
newLostInterval
=
(
worstRemoteFractionLost
*
expectedInterval
)
>>
8
;
const
uint32_t
newLostInterval
=
(
worstRemoteFractionLost
*
expectedInterval
)
>>
8
;
this
->
reportedPacketLost
+=
newLostInterval
;
this
->
reportedPacketLost
+=
newLostInterval
;
...
@@ -545,7 +545,7 @@ namespace RTC
...
@@ -545,7 +545,7 @@ namespace RTC
/* Calculate RTT. */
/* Calculate RTT. */
// Get the NTP representation of the current timestamp.
// Get the NTP representation of the current timestamp.
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
auto
ntp
=
Utils
::
Time
::
TimeMs2Ntp
(
nowMs
);
auto
ntp
=
Utils
::
Time
::
TimeMs2Ntp
(
nowMs
);
// Get the compact NTP representation of the current timestamp.
// Get the compact NTP representation of the current timestamp.
...
@@ -553,8 +553,8 @@ namespace RTC
...
@@ -553,8 +553,8 @@ namespace RTC
compactNtp
|=
(
ntp
.
fractions
&
0xFFFF0000
)
>>
16
;
compactNtp
|=
(
ntp
.
fractions
&
0xFFFF0000
)
>>
16
;
uint32_t
lastRr
=
ssrcInfo
->
GetLastReceiverReport
();
const
uint32_t
lastRr
=
ssrcInfo
->
GetLastReceiverReport
();
uint32_t
dlrr
=
ssrcInfo
->
GetDelaySinceLastReceiverReport
();
const
uint32_t
dlrr
=
ssrcInfo
->
GetDelaySinceLastReceiverReport
();
// RTT in 1/2^16 second fractions.
// RTT in 1/2^16 second fractions.
uint32_t
rtt
{
0
};
uint32_t
rtt
{
0
};
...
...
worker/src/RTC/RtpStreamSend.cpp
浏览文件 @
bfaf8834
...
@@ -285,7 +285,7 @@ namespace RTC
...
@@ -285,7 +285,7 @@ namespace RTC
/* Calculate RTT. */
/* Calculate RTT. */
// Get the NTP representation of the current timestamp.
// Get the NTP representation of the current timestamp.
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
auto
ntp
=
Utils
::
Time
::
TimeMs2Ntp
(
nowMs
);
auto
ntp
=
Utils
::
Time
::
TimeMs2Ntp
(
nowMs
);
// Get the compact NTP representation of the current timestamp.
// Get the compact NTP representation of the current timestamp.
...
@@ -293,8 +293,8 @@ namespace RTC
...
@@ -293,8 +293,8 @@ namespace RTC
compactNtp
|=
(
ntp
.
fractions
&
0xFFFF0000
)
>>
16
;
compactNtp
|=
(
ntp
.
fractions
&
0xFFFF0000
)
>>
16
;
uint32_t
lastSr
=
report
->
GetLastSenderReport
();
const
uint32_t
lastSr
=
report
->
GetLastSenderReport
();
uint32_t
dlsr
=
report
->
GetDelaySinceLastSenderReport
();
const
uint32_t
dlsr
=
report
->
GetDelaySinceLastSenderReport
();
// RTT in 1/2^16 second fractions.
// RTT in 1/2^16 second fractions.
uint32_t
rtt
{
0
};
uint32_t
rtt
{
0
};
...
@@ -567,14 +567,14 @@ namespace RTC
...
@@ -567,14 +567,14 @@ namespace RTC
}
}
// Look for each requested packet.
// Look for each requested packet.
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
uint16_t
rtt
=
(
this
->
rtt
!=
0u
?
this
->
rtt
:
DefaultRtt
);
const
uint16_t
rtt
=
(
this
->
rtt
!=
0u
?
this
->
rtt
:
DefaultRtt
);
uint16_t
currentSeq
=
seq
;
uint16_t
currentSeq
=
seq
;
bool
requested
{
true
};
bool
requested
{
true
};
size_t
containerIdx
{
0
};
size_t
containerIdx
{
0
};
// Variables for debugging.
// Variables for debugging.
uint16_t
origBitmask
=
bitmask
;
const
uint16_t
origBitmask
=
bitmask
;
uint16_t
sentBitmask
{
0
b0000000000000000
};
uint16_t
sentBitmask
{
0
b0000000000000000
};
bool
isFirstPacket
{
true
};
bool
isFirstPacket
{
true
};
bool
firstPacketSent
{
false
};
bool
firstPacketSent
{
false
};
...
@@ -724,7 +724,7 @@ namespace RTC
...
@@ -724,7 +724,7 @@ namespace RTC
this
->
sentPriorScore
=
totalSent
;
this
->
sentPriorScore
=
totalSent
;
// Calculate number of packets lost in this interval.
// Calculate number of packets lost in this interval.
uint32_t
totalLost
=
report
->
GetTotalLost
()
>
0
?
report
->
GetTotalLost
()
:
0
;
const
uint32_t
totalLost
=
report
->
GetTotalLost
()
>
0
?
report
->
GetTotalLost
()
:
0
;
uint32_t
lost
;
uint32_t
lost
;
if
(
totalLost
<
this
->
lostPriorScore
)
if
(
totalLost
<
this
->
lostPriorScore
)
...
@@ -742,7 +742,7 @@ namespace RTC
...
@@ -742,7 +742,7 @@ namespace RTC
// Calculate number of packets retransmitted in this interval.
// Calculate number of packets retransmitted in this interval.
auto
totatRetransmitted
=
this
->
packetsRetransmitted
;
auto
totatRetransmitted
=
this
->
packetsRetransmitted
;
uint32_t
retransmitted
=
totatRetransmitted
-
this
->
retransmittedPriorScore
;
const
uint32_t
retransmitted
=
totatRetransmitted
-
this
->
retransmittedPriorScore
;
this
->
retransmittedPriorScore
=
totatRetransmitted
;
this
->
retransmittedPriorScore
=
totatRetransmitted
;
...
...
worker/src/RTC/RtxStream.cpp
浏览文件 @
bfaf8834
...
@@ -40,7 +40,7 @@ namespace RTC
...
@@ -40,7 +40,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
const
uint16_t
seq
=
packet
->
GetSequenceNumber
();
// If this is the first packet seen, initialize stuff.
// If this is the first packet seen, initialize stuff.
if
(
!
this
->
started
)
if
(
!
this
->
started
)
...
@@ -86,7 +86,7 @@ namespace RTC
...
@@ -86,7 +86,7 @@ namespace RTC
report
->
SetSsrc
(
GetSsrc
());
report
->
SetSsrc
(
GetSsrc
());
uint32_t
prevPacketsLost
=
this
->
packetsLost
;
const
uint32_t
prevPacketsLost
=
this
->
packetsLost
;
// Calculate Packets Expected and Lost.
// Calculate Packets Expected and Lost.
auto
expected
=
GetExpectedPackets
();
auto
expected
=
GetExpectedPackets
();
...
@@ -97,15 +97,15 @@ namespace RTC
...
@@ -97,15 +97,15 @@ namespace RTC
this
->
packetsLost
=
0u
;
this
->
packetsLost
=
0u
;
// Calculate Fraction Lost.
// Calculate Fraction Lost.
uint32_t
expectedInterval
=
expected
-
this
->
expectedPrior
;
const
uint32_t
expectedInterval
=
expected
-
this
->
expectedPrior
;
this
->
expectedPrior
=
expected
;
this
->
expectedPrior
=
expected
;
uint32_t
receivedInterval
=
this
->
packetsCount
-
this
->
receivedPrior
;
const
uint32_t
receivedInterval
=
this
->
packetsCount
-
this
->
receivedPrior
;
this
->
receivedPrior
=
this
->
packetsCount
;
this
->
receivedPrior
=
this
->
packetsCount
;
int32_t
lostInterval
=
expectedInterval
-
receivedInterval
;
const
int32_t
lostInterval
=
expectedInterval
-
receivedInterval
;
if
(
expectedInterval
==
0
||
lostInterval
<=
0
)
if
(
expectedInterval
==
0
||
lostInterval
<=
0
)
this
->
fractionLost
=
0
;
this
->
fractionLost
=
0
;
...
@@ -157,8 +157,8 @@ namespace RTC
...
@@ -157,8 +157,8 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
const
uint16_t
seq
=
packet
->
GetSequenceNumber
();
uint16_t
udelta
=
seq
-
this
->
maxSeq
;
const
uint16_t
udelta
=
seq
-
this
->
maxSeq
;
// If the new packet sequence number is greater than the max seen but not
// If the new packet sequence number is greater than the max seen but not
// "so much bigger", accept it.
// "so much bigger", accept it.
...
...
worker/src/RTC/SctpAssociation.cpp
浏览文件 @
bfaf8834
...
@@ -58,9 +58,9 @@ inline static int onRecvSctpData(
...
@@ -58,9 +58,9 @@ inline static int onRecvSctpData(
}
}
else
else
{
{
uint16_t
streamId
=
rcv
.
rcv_sid
;
const
uint16_t
streamId
=
rcv
.
rcv_sid
;
uint32_t
ppid
=
ntohl
(
rcv
.
rcv_ppid
);
uint32_t
ppid
=
ntohl
(
rcv
.
rcv_ppid
);
uint16_t
ssn
=
rcv
.
rcv_ssn
;
const
uint16_t
ssn
=
rcv
.
rcv_ssn
;
MS_DEBUG_TAG
(
MS_DEBUG_TAG
(
sctp
,
sctp
,
...
@@ -191,7 +191,7 @@ namespace RTC
...
@@ -191,7 +191,7 @@ namespace RTC
}
}
// Set SCTP_NODELAY.
// Set SCTP_NODELAY.
uint32_t
noDelay
=
1
;
const
uint32_t
noDelay
=
1
;
ret
=
usrsctp_setsockopt
(
this
->
socket
,
IPPROTO_SCTP
,
SCTP_NODELAY
,
&
noDelay
,
sizeof
(
noDelay
));
ret
=
usrsctp_setsockopt
(
this
->
socket
,
IPPROTO_SCTP
,
SCTP_NODELAY
,
&
noDelay
,
sizeof
(
noDelay
));
...
@@ -772,7 +772,7 @@ namespace RTC
...
@@ -772,7 +772,7 @@ namespace RTC
static
const
size_t
BufferSize
{
1024
};
static
const
size_t
BufferSize
{
1024
};
thread_local
static
char
buffer
[
BufferSize
];
thread_local
static
char
buffer
[
BufferSize
];
uint32_t
len
=
const
uint32_t
len
=
notification
->
sn_assoc_change
.
sac_length
-
sizeof
(
struct
sctp_assoc_change
);
notification
->
sn_assoc_change
.
sac_length
-
sizeof
(
struct
sctp_assoc_change
);
for
(
uint32_t
i
{
0
};
i
<
len
;
++
i
)
for
(
uint32_t
i
{
0
};
i
<
len
;
++
i
)
...
@@ -841,7 +841,7 @@ namespace RTC
...
@@ -841,7 +841,7 @@ namespace RTC
static
const
size_t
BufferSize
{
1024
};
static
const
size_t
BufferSize
{
1024
};
thread_local
static
char
buffer
[
BufferSize
];
thread_local
static
char
buffer
[
BufferSize
];
uint32_t
len
=
const
uint32_t
len
=
notification
->
sn_assoc_change
.
sac_length
-
sizeof
(
struct
sctp_assoc_change
);
notification
->
sn_assoc_change
.
sac_length
-
sizeof
(
struct
sctp_assoc_change
);
for
(
uint32_t
i
{
0
};
i
<
len
;
++
i
)
for
(
uint32_t
i
{
0
};
i
<
len
;
++
i
)
...
@@ -883,7 +883,8 @@ namespace RTC
...
@@ -883,7 +883,8 @@ namespace RTC
static
const
size_t
BufferSize
{
1024
};
static
const
size_t
BufferSize
{
1024
};
thread_local
static
char
buffer
[
BufferSize
];
thread_local
static
char
buffer
[
BufferSize
];
uint32_t
len
=
notification
->
sn_remote_error
.
sre_length
-
sizeof
(
struct
sctp_remote_error
);
const
uint32_t
len
=
notification
->
sn_remote_error
.
sre_length
-
sizeof
(
struct
sctp_remote_error
);
for
(
uint32_t
i
{
0
};
i
<
len
;
i
++
)
for
(
uint32_t
i
{
0
};
i
<
len
;
i
++
)
{
{
...
@@ -919,7 +920,7 @@ namespace RTC
...
@@ -919,7 +920,7 @@ namespace RTC
static
const
size_t
BufferSize
{
1024
};
static
const
size_t
BufferSize
{
1024
};
thread_local
static
char
buffer
[
BufferSize
];
thread_local
static
char
buffer
[
BufferSize
];
uint32_t
len
=
const
uint32_t
len
=
notification
->
sn_send_failed_event
.
ssfe_length
-
sizeof
(
struct
sctp_send_failed_event
);
notification
->
sn_send_failed_event
.
ssfe_length
-
sizeof
(
struct
sctp_send_failed_event
);
for
(
uint32_t
i
{
0
};
i
<
len
;
++
i
)
for
(
uint32_t
i
{
0
};
i
<
len
;
++
i
)
...
@@ -944,7 +945,7 @@ namespace RTC
...
@@ -944,7 +945,7 @@ namespace RTC
{
{
bool
incoming
{
false
};
bool
incoming
{
false
};
bool
outgoing
{
false
};
bool
outgoing
{
false
};
uint16_t
numStreams
=
const
uint16_t
numStreams
=
(
notification
->
sn_strreset_event
.
strreset_length
-
sizeof
(
struct
sctp_stream_reset_event
))
/
(
notification
->
sn_strreset_event
.
strreset_length
-
sizeof
(
struct
sctp_stream_reset_event
))
/
sizeof
(
uint16_t
);
sizeof
(
uint16_t
);
...
...
worker/src/RTC/SenderBandwidthEstimator.cpp
浏览文件 @
bfaf8834
...
@@ -84,7 +84,7 @@ namespace RTC
...
@@ -84,7 +84,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
auto
nowMs
=
DepLibUV
::
GetTimeMs
();
auto
nowMs
=
DepLibUV
::
GetTimeMs
();
uint64_t
elapsedMs
=
nowMs
-
this
->
cummulativeResult
.
GetStartedAtMs
();
const
uint64_t
elapsedMs
=
nowMs
-
this
->
cummulativeResult
.
GetStartedAtMs
();
// Drop ongoing cummulative result if too old.
// Drop ongoing cummulative result if too old.
if
(
elapsedMs
>
1000u
)
if
(
elapsedMs
>
1000u
)
...
@@ -172,7 +172,7 @@ namespace RTC
...
@@ -172,7 +172,7 @@ namespace RTC
auto
previousAvailableBitrate
=
this
->
availableBitrate
;
auto
previousAvailableBitrate
=
this
->
availableBitrate
;
double
ratio
=
static_cast
<
double
>
(
cummulativeResult
.
GetReceiveBitrate
())
/
const
double
ratio
=
static_cast
<
double
>
(
cummulativeResult
.
GetReceiveBitrate
())
/
static_cast
<
double
>
(
cummulativeResult
.
GetSendBitrate
());
static_cast
<
double
>
(
cummulativeResult
.
GetSendBitrate
());
auto
bitrate
=
auto
bitrate
=
std
::
min
<
uint32_t
>
(
cummulativeResult
.
GetReceiveBitrate
(),
cummulativeResult
.
GetSendBitrate
());
std
::
min
<
uint32_t
>
(
cummulativeResult
.
GetReceiveBitrate
(),
cummulativeResult
.
GetSendBitrate
());
...
...
worker/src/RTC/SimpleConsumer.cpp
浏览文件 @
bfaf8834
...
@@ -301,7 +301,7 @@ namespace RTC
...
@@ -301,7 +301,7 @@ namespace RTC
return
;
return
;
// Whether this is the first packet after re-sync.
// Whether this is the first packet after re-sync.
bool
isSyncPacket
=
this
->
syncRequired
;
const
bool
isSyncPacket
=
this
->
syncRequired
;
// Sync sequence number and timestamp if required.
// Sync sequence number and timestamp if required.
if
(
isSyncPacket
)
if
(
isSyncPacket
)
...
...
worker/src/RTC/SimulcastConsumer.cpp
浏览文件 @
bfaf8834
...
@@ -709,7 +709,7 @@ namespace RTC
...
@@ -709,7 +709,7 @@ namespace RTC
return
;
return
;
// Whether this is the first packet after re-sync.
// Whether this is the first packet after re-sync.
bool
isSyncPacket
=
this
->
syncRequired
;
const
bool
isSyncPacket
=
this
->
syncRequired
;
// Sync sequence number and timestamp if required.
// Sync sequence number and timestamp if required.
if
(
isSyncPacket
&&
(
this
->
spatialLayerToSync
==
-
1
||
this
->
spatialLayerToSync
==
spatialLayer
))
if
(
isSyncPacket
&&
(
this
->
spatialLayerToSync
==
-
1
||
this
->
spatialLayerToSync
==
spatialLayer
))
...
@@ -751,7 +751,7 @@ namespace RTC
...
@@ -751,7 +751,7 @@ namespace RTC
diffMs
=
-
1
*
(
ntpMs1
-
ntpMs2
);
diffMs
=
-
1
*
(
ntpMs1
-
ntpMs2
);
int64_t
diffTs
=
diffMs
*
this
->
rtpStream
->
GetClockRate
()
/
1000
;
int64_t
diffTs
=
diffMs
*
this
->
rtpStream
->
GetClockRate
()
/
1000
;
uint32_t
newTs2
=
ts2
-
diffTs
;
const
uint32_t
newTs2
=
ts2
-
diffTs
;
// Apply offset. This is the difference that later must be removed from the
// Apply offset. This is the difference that later must be removed from the
// sending RTP packet.
// sending RTP packet.
...
@@ -902,7 +902,7 @@ namespace RTC
...
@@ -902,7 +902,7 @@ namespace RTC
// Update RTP seq number and timestamp based on NTP offset.
// Update RTP seq number and timestamp based on NTP offset.
uint16_t
seq
;
uint16_t
seq
;
uint32_t
timestamp
=
packet
->
GetTimestamp
()
-
this
->
tsOffset
;
const
uint32_t
timestamp
=
packet
->
GetTimestamp
()
-
this
->
tsOffset
;
this
->
rtpSeqManager
.
Input
(
packet
->
GetSequenceNumber
(),
seq
);
this
->
rtpSeqManager
.
Input
(
packet
->
GetSequenceNumber
(),
seq
);
...
...
worker/src/RTC/SrtpSession.cpp
浏览文件 @
bfaf8834
...
@@ -19,7 +19,7 @@ namespace RTC
...
@@ -19,7 +19,7 @@ namespace RTC
void
SrtpSession
::
ClassInit
()
void
SrtpSession
::
ClassInit
()
{
{
// Set libsrtp event handler.
// Set libsrtp event handler.
srtp_err_status_t
err
=
const
srtp_err_status_t
err
=
srtp_install_event_handler
(
static_cast
<
srtp_event_handler_func_t
*>
(
OnSrtpEvent
));
srtp_install_event_handler
(
static_cast
<
srtp_event_handler_func_t
*>
(
OnSrtpEvent
));
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
...
@@ -127,7 +127,7 @@ namespace RTC
...
@@ -127,7 +127,7 @@ namespace RTC
policy
.
next
=
nullptr
;
policy
.
next
=
nullptr
;
// Set the SRTP session.
// Set the SRTP session.
srtp_err_status_t
err
=
srtp_create
(
&
this
->
session
,
&
policy
);
const
srtp_err_status_t
err
=
srtp_create
(
&
this
->
session
,
&
policy
);
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
MS_THROW_ERROR
(
"srtp_create() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
MS_THROW_ERROR
(
"srtp_create() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
...
@@ -139,7 +139,7 @@ namespace RTC
...
@@ -139,7 +139,7 @@ namespace RTC
if
(
this
->
session
!=
nullptr
)
if
(
this
->
session
!=
nullptr
)
{
{
srtp_err_status_t
err
=
srtp_dealloc
(
this
->
session
);
const
srtp_err_status_t
err
=
srtp_dealloc
(
this
->
session
);
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
MS_ABORT
(
"srtp_dealloc() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
MS_ABORT
(
"srtp_dealloc() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
...
@@ -160,7 +160,7 @@ namespace RTC
...
@@ -160,7 +160,7 @@ namespace RTC
std
::
memcpy
(
EncryptBuffer
,
*
data
,
*
len
);
std
::
memcpy
(
EncryptBuffer
,
*
data
,
*
len
);
srtp_err_status_t
err
=
srtp_protect
(
this
->
session
,
static_cast
<
void
*>
(
EncryptBuffer
),
len
);
const
srtp_err_status_t
err
=
srtp_protect
(
this
->
session
,
static_cast
<
void
*>
(
EncryptBuffer
),
len
);
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
{
{
...
@@ -179,7 +179,7 @@ namespace RTC
...
@@ -179,7 +179,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
srtp_err_status_t
err
=
srtp_unprotect
(
this
->
session
,
static_cast
<
void
*>
(
data
),
len
);
const
srtp_err_status_t
err
=
srtp_unprotect
(
this
->
session
,
static_cast
<
void
*>
(
data
),
len
);
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
{
{
...
@@ -205,7 +205,8 @@ namespace RTC
...
@@ -205,7 +205,8 @@ namespace RTC
std
::
memcpy
(
EncryptBuffer
,
*
data
,
*
len
);
std
::
memcpy
(
EncryptBuffer
,
*
data
,
*
len
);
srtp_err_status_t
err
=
srtp_protect_rtcp
(
this
->
session
,
static_cast
<
void
*>
(
EncryptBuffer
),
len
);
const
srtp_err_status_t
err
=
srtp_protect_rtcp
(
this
->
session
,
static_cast
<
void
*>
(
EncryptBuffer
),
len
);
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
{
{
...
@@ -224,7 +225,7 @@ namespace RTC
...
@@ -224,7 +225,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
srtp_err_status_t
err
=
srtp_unprotect_rtcp
(
this
->
session
,
static_cast
<
void
*>
(
data
),
len
);
const
srtp_err_status_t
err
=
srtp_unprotect_rtcp
(
this
->
session
,
static_cast
<
void
*>
(
data
),
len
);
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
{
{
...
...
worker/src/RTC/StunPacket.cpp
浏览文件 @
bfaf8834
...
@@ -42,10 +42,10 @@ namespace RTC
...
@@ -42,10 +42,10 @@ namespace RTC
*/
*/
// Get type field.
// Get type field.
uint16_t
msgType
=
Utils
::
Byte
::
Get2Bytes
(
data
,
0
);
const
uint16_t
msgType
=
Utils
::
Byte
::
Get2Bytes
(
data
,
0
);
// Get length field.
// Get length field.
uint16_t
msgLength
=
Utils
::
Byte
::
Get2Bytes
(
data
,
2
);
const
uint16_t
msgLength
=
Utils
::
Byte
::
Get2Bytes
(
data
,
2
);
// length field must be total size minus header's 20 bytes, and must be multiple of 4 Bytes.
// length field must be total size minus header's 20 bytes, and must be multiple of 4 Bytes.
if
((
static_cast
<
size_t
>
(
msgLength
)
!=
len
-
20
)
||
((
msgLength
&
0x03
)
!=
0
))
if
((
static_cast
<
size_t
>
(
msgLength
)
!=
len
-
20
)
||
((
msgLength
&
0x03
)
!=
0
))
...
@@ -59,10 +59,11 @@ namespace RTC
...
@@ -59,10 +59,11 @@ namespace RTC
}
}
// Get STUN method.
// Get STUN method.
uint16_t
msgMethod
=
(
msgType
&
0x000f
)
|
((
msgType
&
0x00e0
)
>>
1
)
|
((
msgType
&
0x3E00
)
>>
2
);
const
uint16_t
msgMethod
=
(
msgType
&
0x000f
)
|
((
msgType
&
0x00e0
)
>>
1
)
|
((
msgType
&
0x3E00
)
>>
2
);
// Get STUN class.
// Get STUN class.
uint16_t
msgClass
=
((
data
[
0
]
&
0x01
)
<<
1
)
|
((
data
[
1
]
&
0x10
)
>>
4
);
const
uint16_t
msgClass
=
((
data
[
0
]
&
0x01
)
<<
1
)
|
((
data
[
1
]
&
0x10
)
>>
4
);
// Create a new StunPacket (data + 8 points to the received TransactionID field).
// Create a new StunPacket (data + 8 points to the received TransactionID field).
auto
*
packet
=
new
StunPacket
(
auto
*
packet
=
new
StunPacket
(
...
@@ -101,7 +102,7 @@ namespace RTC
...
@@ -101,7 +102,7 @@ namespace RTC
auto
attrType
=
static_cast
<
Attribute
>
(
Utils
::
Byte
::
Get2Bytes
(
data
,
pos
));
auto
attrType
=
static_cast
<
Attribute
>
(
Utils
::
Byte
::
Get2Bytes
(
data
,
pos
));
// Get the attribute length.
// Get the attribute length.
uint16_t
attrLength
=
Utils
::
Byte
::
Get2Bytes
(
data
,
pos
+
2
);
const
uint16_t
attrLength
=
Utils
::
Byte
::
Get2Bytes
(
data
,
pos
+
2
);
// Ensure the attribute length is not greater than the remaining size.
// Ensure the attribute length is not greater than the remaining size.
if
((
pos
+
4
+
attrLength
)
>
len
)
if
((
pos
+
4
+
attrLength
)
>
len
)
...
@@ -273,8 +274,8 @@ namespace RTC
...
@@ -273,8 +274,8 @@ namespace RTC
return
nullptr
;
return
nullptr
;
}
}
uint8_t
errorClass
=
Utils
::
Byte
::
Get1Byte
(
attrValuePos
,
2
);
const
uint8_t
errorClass
=
Utils
::
Byte
::
Get1Byte
(
attrValuePos
,
2
);
uint8_t
errorNumber
=
Utils
::
Byte
::
Get1Byte
(
attrValuePos
,
3
);
const
uint8_t
errorNumber
=
Utils
::
Byte
::
Get1Byte
(
attrValuePos
,
3
);
auto
errorCode
=
static_cast
<
uint16_t
>
(
errorClass
*
100
+
errorNumber
);
auto
errorCode
=
static_cast
<
uint16_t
>
(
errorClass
*
100
+
errorNumber
);
packet
->
SetErrorCode
(
errorCode
);
packet
->
SetErrorCode
(
errorCode
);
...
@@ -304,7 +305,8 @@ namespace RTC
...
@@ -304,7 +305,8 @@ namespace RTC
{
{
// Compute the CRC32 of the received packet up to (but excluding) the
// Compute the CRC32 of the received packet up to (but excluding) the
// FINGERPRINT attribute and XOR it with 0x5354554e.
// FINGERPRINT attribute and XOR it with 0x5354554e.
uint32_t
computedFingerprint
=
Utils
::
Crypto
::
GetCRC32
(
data
,
fingerprintAttrPos
)
^
0x5354554e
;
const
uint32_t
computedFingerprint
=
Utils
::
Crypto
::
GetCRC32
(
data
,
fingerprintAttrPos
)
^
0x5354554e
;
// Compare with the FINGERPRINT value in the packet.
// Compare with the FINGERPRINT value in the packet.
if
(
fingerprint
!=
computedFingerprint
)
if
(
fingerprint
!=
computedFingerprint
)
...
@@ -531,7 +533,7 @@ namespace RTC
...
@@ -531,7 +533,7 @@ namespace RTC
this
->
klass
==
Class
::
SUCCESS_RESPONSE
);
this
->
klass
==
Class
::
SUCCESS_RESPONSE
);
bool
addErrorCode
=
((
this
->
errorCode
!=
0u
)
&&
this
->
klass
==
Class
::
ERROR_RESPONSE
);
bool
addErrorCode
=
((
this
->
errorCode
!=
0u
)
&&
this
->
klass
==
Class
::
ERROR_RESPONSE
);
bool
addMessageIntegrity
=
(
this
->
klass
!=
Class
::
ERROR_RESPONSE
&&
!
this
->
password
.
empty
());
bool
addMessageIntegrity
=
(
this
->
klass
!=
Class
::
ERROR_RESPONSE
&&
!
this
->
password
.
empty
());
bool
addFingerprint
{
true
};
// Do always.
const
bool
addFingerprint
{
true
};
// Do always.
// Update data pointer.
// Update data pointer.
this
->
data
=
buffer
;
this
->
data
=
buffer
;
...
@@ -789,7 +791,7 @@ namespace RTC
...
@@ -789,7 +791,7 @@ namespace RTC
{
{
// Compute the CRC32 of the packet up to (but excluding) the FINGERPRINT
// Compute the CRC32 of the packet up to (but excluding) the FINGERPRINT
// attribute and XOR it with 0x5354554e.
// attribute and XOR it with 0x5354554e.
uint32_t
computedFingerprint
=
Utils
::
Crypto
::
GetCRC32
(
buffer
,
pos
)
^
0x5354554e
;
const
uint32_t
computedFingerprint
=
Utils
::
Crypto
::
GetCRC32
(
buffer
,
pos
)
^
0x5354554e
;
Utils
::
Byte
::
Set2Bytes
(
buffer
,
pos
,
static_cast
<
uint16_t
>
(
Attribute
::
FINGERPRINT
));
Utils
::
Byte
::
Set2Bytes
(
buffer
,
pos
,
static_cast
<
uint16_t
>
(
Attribute
::
FINGERPRINT
));
Utils
::
Byte
::
Set2Bytes
(
buffer
,
pos
+
2
,
4
);
Utils
::
Byte
::
Set2Bytes
(
buffer
,
pos
+
2
,
4
);
...
...
worker/src/RTC/SvcConsumer.cpp
浏览文件 @
bfaf8834
...
@@ -577,7 +577,7 @@ namespace RTC
...
@@ -577,7 +577,7 @@ namespace RTC
return
;
return
;
// Whether this is the first packet after re-sync.
// Whether this is the first packet after re-sync.
bool
isSyncPacket
=
this
->
syncRequired
;
const
bool
isSyncPacket
=
this
->
syncRequired
;
// Sync sequence number and timestamp if required.
// Sync sequence number and timestamp if required.
if
(
isSyncPacket
)
if
(
isSyncPacket
)
...
@@ -595,7 +595,7 @@ namespace RTC
...
@@ -595,7 +595,7 @@ namespace RTC
auto
previousTemporalLayer
=
this
->
encodingContext
->
GetCurrentTemporalLayer
();
auto
previousTemporalLayer
=
this
->
encodingContext
->
GetCurrentTemporalLayer
();
bool
marker
{
false
};
bool
marker
{
false
};
bool
origMarker
=
packet
->
HasMarker
();
const
bool
origMarker
=
packet
->
HasMarker
();
if
(
!
packet
->
ProcessPayload
(
this
->
encodingContext
.
get
(),
marker
))
if
(
!
packet
->
ProcessPayload
(
this
->
encodingContext
.
get
(),
marker
))
{
{
...
...
worker/src/RTC/TcpConnection.cpp
浏览文件 @
bfaf8834
...
@@ -62,7 +62,7 @@ namespace RTC
...
@@ -62,7 +62,7 @@ namespace RTC
if
(
IsClosed
())
if
(
IsClosed
())
return
;
return
;
size_t
dataLen
=
this
->
bufferDataLen
-
this
->
frameStart
;
const
size_t
dataLen
=
this
->
bufferDataLen
-
this
->
frameStart
;
size_t
packetLen
;
size_t
packetLen
;
if
(
dataLen
>=
2
)
if
(
dataLen
>=
2
)
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
bfaf8834
...
@@ -3077,7 +3077,7 @@ namespace RTC
...
@@ -3077,7 +3077,7 @@ namespace RTC
if
(
timer
==
this
->
rtcpTimer
)
if
(
timer
==
this
->
rtcpTimer
)
{
{
auto
interval
=
static_cast
<
uint64_t
>
(
RTC
::
RTCP
::
MaxVideoIntervalMs
);
auto
interval
=
static_cast
<
uint64_t
>
(
RTC
::
RTCP
::
MaxVideoIntervalMs
);
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
const
uint64_t
nowMs
=
DepLibUV
::
GetTimeMs
();
SendRtcp
(
nowMs
);
SendRtcp
(
nowMs
);
...
...
worker/src/RTC/TransportCongestionControlClient.cpp
浏览文件 @
bfaf8834
...
@@ -161,7 +161,7 @@ namespace RTC
...
@@ -161,7 +161,7 @@ namespace RTC
}
}
// Notify the transport feedback adapter about the sent packet.
// Notify the transport feedback adapter about the sent packet.
rtc
::
SentPacket
sentPacket
(
packetInfo
.
transport_sequence_number
,
nowMs
);
rtc
::
SentPacket
const
sentPacket
(
packetInfo
.
transport_sequence_number
,
nowMs
);
this
->
rtpTransportControllerSend
->
OnSentPacket
(
sentPacket
,
packetInfo
.
length
);
this
->
rtpTransportControllerSend
->
OnSentPacket
(
sentPacket
,
packetInfo
.
length
);
}
}
...
@@ -214,7 +214,7 @@ namespace RTC
...
@@ -214,7 +214,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
// Update packet loss history.
// Update packet loss history.
size_t
expected_packets
=
feedback
->
GetPacketStatusCount
();
const
size_t
expected_packets
=
feedback
->
GetPacketStatusCount
();
size_t
lost_packets
=
0
;
size_t
lost_packets
=
0
;
for
(
const
auto
&
result
:
feedback
->
GetPacketResults
())
for
(
const
auto
&
result
:
feedback
->
GetPacketResults
())
{
{
...
@@ -411,7 +411,7 @@ namespace RTC
...
@@ -411,7 +411,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint64_t
nowMs
=
DepLibUV
::
GetTimeMsInt64
();
const
uint64_t
nowMs
=
DepLibUV
::
GetTimeMsInt64
();
bool
notify
{
false
};
bool
notify
{
false
};
// Ignore if first event.
// Ignore if first event.
...
...
worker/test/src/RTC/RTCP/TestFeedbackRtpTransport.cpp
浏览文件 @
bfaf8834
...
@@ -723,7 +723,7 @@ SCENARIO("RTCP Feeback RTP transport", "[parser][rtcp][feedback-rtp][transport]"
...
@@ -723,7 +723,7 @@ SCENARIO("RTCP Feeback RTP transport", "[parser][rtcp][feedback-rtp][transport]"
auto
packetsResults
=
feedback
->
GetPacketResults
();
auto
packetsResults
=
feedback
->
GetPacketResults
();
int
deltasIt
=
0
;
int
deltasIt
=
0
;
for
(
auto
const
&
delta
:
packetMeta
.
deltas
)
for
(
const
auto
&
delta
:
packetMeta
.
deltas
)
{
{
auto
resultDelta
=
packetsResults
[
deltasIt
].
delta
;
auto
resultDelta
=
packetsResults
[
deltasIt
].
delta
;
REQUIRE
(
static_cast
<
int16_t
>
(
resultDelta
/
4
)
==
delta
);
REQUIRE
(
static_cast
<
int16_t
>
(
resultDelta
/
4
)
==
delta
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论