Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
32e83e3a
Unverified
提交
32e83e3a
authored
2月 20, 2024
作者:
Iñaki Baz Castillo
提交者:
GitHub
2月 20, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add server side ICE consent checks to detect silent WebRTC disconnection (#1332)
Fixes #1127
上级
a1cc5507
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
111 行增加
和
53 行删除
+111
-53
CHANGELOG.md
CHANGELOG.md
+1
-0
Router.ts
node/src/Router.ts
+3
-1
WebRtcTransport.ts
node/src/WebRtcTransport.ts
+5
-1
test-WebRtcTransport.ts
node/src/test/test-WebRtcTransport.ts
+6
-2
messages.rs
rust/src/messages.rs
+3
-0
webrtc_transport.rs
rust/src/router/webrtc_transport.rs
+5
-0
Dockerfile
worker/Dockerfile
+2
-2
Dockerfile.alpine
worker/Dockerfile.alpine
+2
-2
webRtcTransport.fbs
worker/fbs/webRtcTransport.fbs
+1
-0
FuzzerStunPacket.cpp
worker/fuzzer/src/RTC/FuzzerStunPacket.cpp
+19
-7
IceServer.hpp
worker/include/RTC/IceServer.hpp
+32
-26
StunPacket.hpp
worker/include/RTC/StunPacket.hpp
+20
-5
IceServer.cpp
worker/src/RTC/IceServer.cpp
+0
-0
KeyFrameRequestManager.cpp
worker/src/RTC/KeyFrameRequestManager.cpp
+1
-1
StunPacket.cpp
worker/src/RTC/StunPacket.cpp
+0
-0
Transport.cpp
worker/src/RTC/Transport.cpp
+2
-2
WebRtcServer.cpp
worker/src/RTC/WebRtcServer.cpp
+1
-1
WebRtcTransport.cpp
worker/src/RTC/WebRtcTransport.cpp
+8
-3
没有找到文件。
CHANGELOG.md
浏览文件 @
32e83e3a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
### Next
### Next
-
Add server side ICE consent checks to detect silent WebRTC disconnections (
[
PR #1332
](
https://github.com/versatica/mediasoup/pull/1332
)
).
-
Fix regression (crash) in transport-cc feedback generation (
[
PR #1339
](
https://github.com/versatica/mediasoup/pull/1339
)
).
-
Fix regression (crash) in transport-cc feedback generation (
[
PR #1339
](
https://github.com/versatica/mediasoup/pull/1339
)
).
### 3.13.19
### 3.13.19
...
...
node/src/Router.ts
浏览文件 @
32e83e3a
...
@@ -454,6 +454,7 @@ export class Router<
...
@@ -454,6 +454,7 @@ export class Router<
numSctpStreams
=
{
OS
:
1024
,
MIS
:
1024
},
numSctpStreams
=
{
OS
:
1024
,
MIS
:
1024
},
maxSctpMessageSize
=
262144
,
maxSctpMessageSize
=
262144
,
sctpSendBufferSize
=
262144
,
sctpSendBufferSize
=
262144
,
iceConsentTimeout
=
30
,
appData
,
appData
,
}:
WebRtcTransportOptions
<
WebRtcTransportAppData
>
):
Promise
<
}:
WebRtcTransportOptions
<
WebRtcTransportAppData
>
):
Promise
<
WebRtcTransport
<
WebRtcTransportAppData
>
WebRtcTransport
<
WebRtcTransportAppData
>
...
@@ -596,7 +597,8 @@ export class Router<
...
@@ -596,7 +597,8 @@ export class Router<
enableUdp
,
enableUdp
,
enableTcp
,
enableTcp
,
preferUdp
,
preferUdp
,
preferTcp
preferTcp
,
iceConsentTimeout
);
);
const
requestOffset
=
new
FbsRouter
.
CreateWebRtcTransportRequestT
(
const
requestOffset
=
new
FbsRouter
.
CreateWebRtcTransportRequestT
(
...
...
node/src/WebRtcTransport.ts
浏览文件 @
32e83e3a
...
@@ -96,6 +96,11 @@ export type WebRtcTransportOptionsBase<WebRtcTransportAppData> = {
...
@@ -96,6 +96,11 @@ export type WebRtcTransportOptionsBase<WebRtcTransportAppData> = {
*/
*/
preferTcp
?:
boolean
;
preferTcp
?:
boolean
;
/**
* ICE consent timeout (in seconds). If 0 it is disabled. Default 30.
*/
iceConsentTimeout
?:
number
;
/**
/**
* Initial available outgoing bitrate (in bps). Default 600000.
* Initial available outgoing bitrate (in bps). Default 600000.
*/
*/
...
@@ -836,7 +841,6 @@ function createConnectRequest({
...
@@ -836,7 +841,6 @@ function createConnectRequest({
// Serialize DtlsParameters. This can throw.
// Serialize DtlsParameters. This can throw.
const
dtlsParametersOffset
=
serializeDtlsParameters
(
builder
,
dtlsParameters
);
const
dtlsParametersOffset
=
serializeDtlsParameters
(
builder
,
dtlsParameters
);
// Create request.
return
FbsWebRtcTransport
.
ConnectRequest
.
createConnectRequest
(
return
FbsWebRtcTransport
.
ConnectRequest
.
createConnectRequest
(
builder
,
builder
,
dtlsParametersOffset
dtlsParametersOffset
...
...
node/src/test/test-WebRtcTransport.ts
浏览文件 @
32e83e3a
...
@@ -299,12 +299,16 @@ test('webRtcTransport.connect() succeeds', async () => {
...
@@ -299,12 +299,16 @@ test('webRtcTransport.connect() succeeds', async () => {
};
};
await
expect
(
await
expect
(
webRtcTransport
.
connect
({
dtlsParameters
:
dtlsRemoteParameters
})
webRtcTransport
.
connect
({
dtlsParameters
:
dtlsRemoteParameters
,
})
).
resolves
.
toBeUndefined
();
).
resolves
.
toBeUndefined
();
// Must fail if connected.
// Must fail if connected.
await
expect
(
await
expect
(
webRtcTransport
.
connect
({
dtlsParameters
:
dtlsRemoteParameters
})
webRtcTransport
.
connect
({
dtlsParameters
:
dtlsRemoteParameters
,
})
).
rejects
.
toThrow
(
Error
);
).
rejects
.
toThrow
(
Error
);
expect
(
webRtcTransport
.
dtlsParameters
.
role
).
toBe
(
'server'
);
expect
(
webRtcTransport
.
dtlsParameters
.
role
).
toBe
(
'server'
);
...
...
rust/src/messages.rs
浏览文件 @
32e83e3a
...
@@ -669,6 +669,7 @@ pub(crate) struct RouterCreateWebrtcTransportData {
...
@@ -669,6 +669,7 @@ pub(crate) struct RouterCreateWebrtcTransportData {
enable_tcp
:
bool
,
enable_tcp
:
bool
,
prefer_udp
:
bool
,
prefer_udp
:
bool
,
prefer_tcp
:
bool
,
prefer_tcp
:
bool
,
ice_consent_timeout
:
u8
,
enable_sctp
:
bool
,
enable_sctp
:
bool
,
num_sctp_streams
:
NumSctpStreams
,
num_sctp_streams
:
NumSctpStreams
,
max_sctp_message_size
:
u32
,
max_sctp_message_size
:
u32
,
...
@@ -701,6 +702,7 @@ impl RouterCreateWebrtcTransportData {
...
@@ -701,6 +702,7 @@ impl RouterCreateWebrtcTransportData {
enable_tcp
:
webrtc_transport_options
.enable_tcp
,
enable_tcp
:
webrtc_transport_options
.enable_tcp
,
prefer_udp
:
webrtc_transport_options
.prefer_udp
,
prefer_udp
:
webrtc_transport_options
.prefer_udp
,
prefer_tcp
:
webrtc_transport_options
.prefer_tcp
,
prefer_tcp
:
webrtc_transport_options
.prefer_tcp
,
ice_consent_timeout
:
webrtc_transport_options
.ice_consent_timeout
,
enable_sctp
:
webrtc_transport_options
.enable_sctp
,
enable_sctp
:
webrtc_transport_options
.enable_sctp
,
num_sctp_streams
:
webrtc_transport_options
.num_sctp_streams
,
num_sctp_streams
:
webrtc_transport_options
.num_sctp_streams
,
max_sctp_message_size
:
webrtc_transport_options
.max_sctp_message_size
,
max_sctp_message_size
:
webrtc_transport_options
.max_sctp_message_size
,
...
@@ -726,6 +728,7 @@ impl RouterCreateWebrtcTransportData {
...
@@ -726,6 +728,7 @@ impl RouterCreateWebrtcTransportData {
enable_tcp
:
self
.enable_tcp
,
enable_tcp
:
self
.enable_tcp
,
prefer_udp
:
self
.prefer_udp
,
prefer_udp
:
self
.prefer_udp
,
prefer_tcp
:
self
.prefer_tcp
,
prefer_tcp
:
self
.prefer_tcp
,
ice_consent_timeout
:
self
.ice_consent_timeout
,
}
}
}
}
}
}
...
...
rust/src/router/webrtc_transport.rs
浏览文件 @
32e83e3a
...
@@ -129,6 +129,9 @@ pub struct WebRtcTransportOptions {
...
@@ -129,6 +129,9 @@ pub struct WebRtcTransportOptions {
/// Prefer TCP.
/// Prefer TCP.
/// Default false.
/// Default false.
pub
prefer_tcp
:
bool
,
pub
prefer_tcp
:
bool
,
/// ICE consent timeout (in seconds). If 0 it is disabled.
/// Default 30.
pub
ice_consent_timeout
:
u8
,
/// Create a SCTP association.
/// Create a SCTP association.
/// Default false.
/// Default false.
pub
enable_sctp
:
bool
,
pub
enable_sctp
:
bool
,
...
@@ -155,6 +158,7 @@ impl WebRtcTransportOptions {
...
@@ -155,6 +158,7 @@ impl WebRtcTransportOptions {
enable_tcp
:
false
,
enable_tcp
:
false
,
prefer_udp
:
false
,
prefer_udp
:
false
,
prefer_tcp
:
false
,
prefer_tcp
:
false
,
ice_consent_timeout
:
30
,
enable_sctp
:
false
,
enable_sctp
:
false
,
num_sctp_streams
:
NumSctpStreams
::
default
(),
num_sctp_streams
:
NumSctpStreams
::
default
(),
max_sctp_message_size
:
262
_144
,
max_sctp_message_size
:
262
_144
,
...
@@ -172,6 +176,7 @@ impl WebRtcTransportOptions {
...
@@ -172,6 +176,7 @@ impl WebRtcTransportOptions {
enable_tcp
:
true
,
enable_tcp
:
true
,
prefer_udp
:
false
,
prefer_udp
:
false
,
prefer_tcp
:
false
,
prefer_tcp
:
false
,
ice_consent_timeout
:
30
,
enable_sctp
:
false
,
enable_sctp
:
false
,
num_sctp_streams
:
NumSctpStreams
::
default
(),
num_sctp_streams
:
NumSctpStreams
::
default
(),
max_sctp_message_size
:
262
_144
,
max_sctp_message_size
:
262
_144
,
...
...
worker/Dockerfile
浏览文件 @
32e83e3a
...
@@ -26,8 +26,8 @@ ENV LANG="C.UTF-8"
...
@@ -26,8 +26,8 @@ ENV LANG="C.UTF-8"
ENV
CC="clang"
ENV
CC="clang"
ENV
CXX="clang++"
ENV
CXX="clang++"
ENV
MEDIASOUP_LOCAL_DEV=
true
ENV
MEDIASOUP_LOCAL_DEV=
"true"
ENV
KEEP_BUILD_ARTIFACTS=
1
ENV
KEEP_BUILD_ARTIFACTS=
"1"
WORKDIR
/mediasoup
WORKDIR
/mediasoup
...
...
worker/Dockerfile.alpine
浏览文件 @
32e83e3a
...
@@ -9,8 +9,8 @@ ENV LANG="C.UTF-8"
...
@@ -9,8 +9,8 @@ ENV LANG="C.UTF-8"
ENV CC="gcc"
ENV CC="gcc"
ENV CXX="g++"
ENV CXX="g++"
ENV MEDIASOUP_LOCAL_DEV=
true
ENV MEDIASOUP_LOCAL_DEV=
"true"
ENV KEEP_BUILD_ARTIFACTS=
1
ENV KEEP_BUILD_ARTIFACTS=
"1"
WORKDIR /mediasoup
WORKDIR /mediasoup
...
...
worker/fbs/webRtcTransport.fbs
浏览文件 @
32e83e3a
...
@@ -23,6 +23,7 @@ table WebRtcTransportOptions {
...
@@ -23,6 +23,7 @@ table WebRtcTransportOptions {
enable_tcp: bool = true;
enable_tcp: bool = true;
prefer_udp: bool = false;
prefer_udp: bool = false;
prefer_tcp: bool = false;
prefer_tcp: bool = false;
ice_consent_timeout: uint8 = 30;
}
}
enum FingerprintAlgorithm: uint8 {
enum FingerprintAlgorithm: uint8 {
...
...
worker/fuzzer/src/RTC/FuzzerStunPacket.cpp
浏览文件 @
32e83e3a
#include "RTC/FuzzerStunPacket.hpp"
#include "RTC/FuzzerStunPacket.hpp"
#include "RTC/StunPacket.hpp"
#include "RTC/StunPacket.hpp"
static
constexpr
size_t
StunSerializeBufferSize
{
65536
};
thread_local
static
uint8_t
StunSerializeBuffer
[
StunSerializeBufferSize
];
void
Fuzzer
::
RTC
::
StunPacket
::
Fuzz
(
const
uint8_t
*
data
,
size_t
len
)
void
Fuzzer
::
RTC
::
StunPacket
::
Fuzz
(
const
uint8_t
*
data
,
size_t
len
)
{
{
if
(
!::
RTC
::
StunPacket
::
IsStun
(
data
,
len
))
if
(
!::
RTC
::
StunPacket
::
IsStun
(
data
,
len
))
...
@@ -21,6 +24,7 @@ void Fuzzer::RTC::StunPacket::Fuzz(const uint8_t* data, size_t len)
...
@@ -21,6 +24,7 @@ void Fuzzer::RTC::StunPacket::Fuzz(const uint8_t* data, size_t len)
packet
->
GetData
();
packet
->
GetData
();
packet
->
GetSize
();
packet
->
GetSize
();
packet
->
SetUsername
(
"foo"
,
3
);
packet
->
SetUsername
(
"foo"
,
3
);
packet
->
SetPassword
(
"lalala"
);
packet
->
SetPriority
(
123
);
packet
->
SetPriority
(
123
);
packet
->
SetIceControlling
(
123
);
packet
->
SetIceControlling
(
123
);
packet
->
SetIceControlled
(
123
);
packet
->
SetIceControlled
(
123
);
...
@@ -37,13 +41,21 @@ void Fuzzer::RTC::StunPacket::Fuzz(const uint8_t* data, size_t len)
...
@@ -37,13 +41,21 @@ void Fuzzer::RTC::StunPacket::Fuzz(const uint8_t* data, size_t len)
packet
->
GetErrorCode
();
packet
->
GetErrorCode
();
packet
->
HasMessageIntegrity
();
packet
->
HasMessageIntegrity
();
packet
->
HasFingerprint
();
packet
->
HasFingerprint
();
packet
->
CheckAuthentication
(
"foo"
,
"bar"
);
packet
->
CheckAuthentication
(
"foo"
,
"xxx"
);
// TODO: packet->CreateSuccessResponse(); // This cannot be easily tested.
// TODO: packet->CreateErrorResponse(); // This cannot be easily tested.
if
(
packet
->
GetClass
()
==
::
RTC
::
StunPacket
::
Class
::
REQUEST
)
packet
->
Authenticate
(
"lalala"
);
{
// TODO: Cannot test Serialize() because we don't know the exact required
auto
*
successResponse
=
packet
->
CreateSuccessResponse
();
// buffer size (setters above may change the total size).
auto
*
errorResponse
=
packet
->
CreateErrorResponse
(
444
);
// TODO: packet->Serialize();
delete
successResponse
;
delete
errorResponse
;
}
if
(
len
<
StunSerializeBufferSize
-
1000
)
{
packet
->
Serialize
(
StunSerializeBuffer
);
}
delete
packet
;
delete
packet
;
}
}
worker/include/RTC/IceServer.hpp
浏览文件 @
32e83e3a
...
@@ -2,15 +2,17 @@
...
@@ -2,15 +2,17 @@
#define MS_RTC_ICE_SERVER_HPP
#define MS_RTC_ICE_SERVER_HPP
#include "common.hpp"
#include "common.hpp"
#include "Utils.hpp"
#include "FBS/webRtcTransport.h"
#include "FBS/webRtcTransport.h"
#include "RTC/StunPacket.hpp"
#include "RTC/StunPacket.hpp"
#include "RTC/TransportTuple.hpp"
#include "RTC/TransportTuple.hpp"
#include "handles/TimerHandle.hpp"
#include <list>
#include <list>
#include <string>
#include <string>
namespace
RTC
namespace
RTC
{
{
class
IceServer
class
IceServer
:
public
TimerHandle
::
Listener
{
{
public
:
public
:
enum
class
IceState
enum
class
IceState
...
@@ -53,8 +55,12 @@ namespace RTC
...
@@ -53,8 +55,12 @@ namespace RTC
};
};
public
:
public
:
IceServer
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
);
IceServer
(
~
IceServer
();
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
,
uint8_t
consentTimeoutSec
);
~
IceServer
()
override
;
public
:
public
:
void
ProcessStunPacket
(
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
);
void
ProcessStunPacket
(
RTC
::
StunPacket
*
packet
,
RTC
::
TransportTuple
*
tuple
);
...
@@ -74,28 +80,7 @@ namespace RTC
...
@@ -74,28 +80,7 @@ namespace RTC
{
{
return
this
->
selectedTuple
;
return
this
->
selectedTuple
;
}
}
void
RestartIce
(
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
)
void
RestartIce
(
const
std
::
string
&
usernameFragment
,
const
std
::
string
&
password
);
{
if
(
!
this
->
oldUsernameFragment
.
empty
())
{
this
->
listener
->
OnIceServerLocalUsernameFragmentRemoved
(
this
,
this
->
oldUsernameFragment
);
}
this
->
oldUsernameFragment
=
this
->
usernameFragment
;
this
->
usernameFragment
=
usernameFragment
;
this
->
oldPassword
=
this
->
password
;
this
->
password
=
password
;
this
->
remoteNomination
=
0u
;
// Notify the listener.
this
->
listener
->
OnIceServerLocalUsernameFragmentAdded
(
this
,
usernameFragment
);
// NOTE: Do not call listener->OnIceServerLocalUsernameFragmentRemoved()
// yet with old usernameFragment. Wait until we receive a STUN packet
// with the new one.
}
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
bool
IsValidTuple
(
const
RTC
::
TransportTuple
*
tuple
)
const
;
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
void
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
);
/**
/**
...
@@ -105,6 +90,9 @@ namespace RTC
...
@@ -105,6 +90,9 @@ namespace RTC
void
MayForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
void
MayForceSelectedTuple
(
const
RTC
::
TransportTuple
*
tuple
);
private
:
private
:
void
ProcessStunRequest
(
RTC
::
StunPacket
*
request
,
RTC
::
TransportTuple
*
tuple
);
void
ProcessStunIndication
(
RTC
::
StunPacket
*
indication
);
void
ProcessStunResponse
(
RTC
::
StunPacket
*
response
);
void
HandleTuple
(
void
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
,
bool
hasNomination
,
uint32_t
nomination
);
RTC
::
TransportTuple
*
tuple
,
bool
hasUseCandidate
,
bool
hasNomination
,
uint32_t
nomination
);
/**
/**
...
@@ -120,19 +108,37 @@ namespace RTC
...
@@ -120,19 +108,37 @@ namespace RTC
* NOTE: The given tuple MUST be already stored within the list.
* NOTE: The given tuple MUST be already stored within the list.
*/
*/
void
SetSelectedTuple
(
RTC
::
TransportTuple
*
storedTuple
);
void
SetSelectedTuple
(
RTC
::
TransportTuple
*
storedTuple
);
bool
IsConsentCheckSupported
()
const
{
return
this
->
consentTimeoutMs
!=
0u
;
}
bool
IsConsentCheckRunning
()
const
{
return
(
this
->
consentCheckTimer
&&
this
->
consentCheckTimer
->
IsActive
());
}
void
StartConsentCheck
();
void
RestartConsentCheck
();
void
StopConsentCheck
();
/* Pure virtual methods inherited from TimerHandle::Listener. */
public
:
void
OnTimer
(
TimerHandle
*
timer
)
override
;
private
:
private
:
// Passed by argument.
// Passed by argument.
Listener
*
listener
{
nullptr
};
Listener
*
listener
{
nullptr
};
// Others.
std
::
string
usernameFragment
;
std
::
string
usernameFragment
;
std
::
string
password
;
std
::
string
password
;
uint16_t
consentTimeoutMs
{
30000u
};
// Others.
std
::
string
oldUsernameFragment
;
std
::
string
oldUsernameFragment
;
std
::
string
oldPassword
;
std
::
string
oldPassword
;
IceState
state
{
IceState
::
NEW
};
IceState
state
{
IceState
::
NEW
};
uint32_t
remoteNomination
{
0u
};
uint32_t
remoteNomination
{
0u
};
std
::
list
<
RTC
::
TransportTuple
>
tuples
;
std
::
list
<
RTC
::
TransportTuple
>
tuples
;
RTC
::
TransportTuple
*
selectedTuple
{
nullptr
};
RTC
::
TransportTuple
*
selectedTuple
{
nullptr
};
TimerHandle
*
consentCheckTimer
{
nullptr
};
uint64_t
lastConsentRequestReceivedAtMs
{
0u
};
};
};
}
// namespace RTC
}
// namespace RTC
...
...
worker/include/RTC/StunPacket.hpp
浏览文件 @
32e83e3a
...
@@ -50,7 +50,7 @@ namespace RTC
...
@@ -50,7 +50,7 @@ namespace RTC
{
{
OK
=
0
,
OK
=
0
,
UNAUTHORIZED
=
1
,
UNAUTHORIZED
=
1
,
BAD_
REQUEST
=
2
BAD_
MESSAGE
=
2
};
};
public
:
public
:
...
@@ -95,6 +95,10 @@ namespace RTC
...
@@ -95,6 +95,10 @@ namespace RTC
{
{
return
this
->
size
;
return
this
->
size
;
}
}
const
uint8_t
*
GetTransactionId
()
const
{
return
this
->
transactionId
;
}
void
SetUsername
(
const
char
*
username
,
size_t
len
)
void
SetUsername
(
const
char
*
username
,
size_t
len
)
{
{
this
->
username
.
assign
(
username
,
len
);
this
->
username
.
assign
(
username
,
len
);
...
@@ -127,6 +131,10 @@ namespace RTC
...
@@ -127,6 +131,10 @@ namespace RTC
{
{
this
->
errorCode
=
errorCode
;
this
->
errorCode
=
errorCode
;
}
}
void
SetSoftware
(
const
char
*
software
,
size_t
len
)
{
this
->
software
.
assign
(
software
,
len
);
}
void
SetMessageIntegrity
(
const
uint8_t
*
messageIntegrity
)
void
SetMessageIntegrity
(
const
uint8_t
*
messageIntegrity
)
{
{
this
->
messageIntegrity
=
messageIntegrity
;
this
->
messageIntegrity
=
messageIntegrity
;
...
@@ -139,6 +147,7 @@ namespace RTC
...
@@ -139,6 +147,7 @@ namespace RTC
{
{
return
this
->
username
;
return
this
->
username
;
}
}
void
SetPassword
(
const
std
::
string
&
password
);
uint32_t
GetPriority
()
const
uint32_t
GetPriority
()
const
{
{
return
this
->
priority
;
return
this
->
priority
;
...
@@ -171,6 +180,10 @@ namespace RTC
...
@@ -171,6 +180,10 @@ namespace RTC
{
{
return
this
->
errorCode
;
return
this
->
errorCode
;
}
}
std
::
string
GetSoftware
()
const
{
return
this
->
software
;
}
bool
HasMessageIntegrity
()
const
bool
HasMessageIntegrity
()
const
{
{
return
(
this
->
messageIntegrity
!=
nullptr
);
return
(
this
->
messageIntegrity
!=
nullptr
);
...
@@ -180,10 +193,11 @@ namespace RTC
...
@@ -180,10 +193,11 @@ namespace RTC
return
this
->
hasFingerprint
;
return
this
->
hasFingerprint
;
}
}
Authentication
CheckAuthentication
(
Authentication
CheckAuthentication
(
const
std
::
string
&
localUsername
,
const
std
::
string
&
localPassword
);
// The first username fragment in the USERNAME attribute.
const
std
::
string
&
usernameFragment1
,
const
std
::
string
&
password
);
StunPacket
*
CreateSuccessResponse
();
StunPacket
*
CreateSuccessResponse
();
StunPacket
*
CreateErrorResponse
(
uint16_t
errorCode
);
StunPacket
*
CreateErrorResponse
(
uint16_t
errorCode
);
void
Authenticate
(
const
std
::
string
&
password
);
void
Serialize
(
uint8_t
*
buffer
);
void
Serialize
(
uint8_t
*
buffer
);
private
:
private
:
...
@@ -194,7 +208,8 @@ namespace RTC
...
@@ -194,7 +208,8 @@ namespace RTC
uint8_t
*
data
{
nullptr
};
// Pointer to binary data.
uint8_t
*
data
{
nullptr
};
// Pointer to binary data.
size_t
size
{
0u
};
// The full message size (including header).
size_t
size
{
0u
};
// The full message size (including header).
// STUN attributes.
// STUN attributes.
std
::
string
username
;
// Less than 513 bytes.
std
::
string
username
;
// Less than 513 bytes.
std
::
string
password
;
uint32_t
priority
{
0u
};
// 4 bytes unsigned integer.
uint32_t
priority
{
0u
};
// 4 bytes unsigned integer.
uint64_t
iceControlling
{
0u
};
// 8 bytes unsigned integer.
uint64_t
iceControlling
{
0u
};
// 8 bytes unsigned integer.
uint64_t
iceControlled
{
0u
};
// 8 bytes unsigned integer.
uint64_t
iceControlled
{
0u
};
// 8 bytes unsigned integer.
...
@@ -205,7 +220,7 @@ namespace RTC
...
@@ -205,7 +220,7 @@ namespace RTC
bool
hasFingerprint
{
false
};
// 4 bytes.
bool
hasFingerprint
{
false
};
// 4 bytes.
const
struct
sockaddr
*
xorMappedAddress
{
nullptr
};
// 8 or 20 bytes.
const
struct
sockaddr
*
xorMappedAddress
{
nullptr
};
// 8 or 20 bytes.
uint16_t
errorCode
{
0u
};
// 4 bytes (no reason phrase).
uint16_t
errorCode
{
0u
};
// 4 bytes (no reason phrase).
std
::
string
password
;
std
::
string
software
;
// Less than 763 bytes.
};
};
}
// namespace RTC
}
// namespace RTC
...
...
worker/src/RTC/IceServer.cpp
浏览文件 @
32e83e3a
差异被折叠。
点击展开。
worker/src/RTC/KeyFrameRequestManager.cpp
浏览文件 @
32e83e3a
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include "RTC/KeyFrameRequestManager.hpp"
#include "RTC/KeyFrameRequestManager.hpp"
#include "Logger.hpp"
#include "Logger.hpp"
static
constexpr
uint32_t
KeyFrameRetransmissionWaitTime
{
1000
};
static
constexpr
uint32_t
KeyFrameRetransmissionWaitTime
{
1000
u
};
/* PendingKeyFrameInfo methods. */
/* PendingKeyFrameInfo methods. */
...
...
worker/src/RTC/StunPacket.cpp
浏览文件 @
32e83e3a
差异被折叠。
点击展开。
worker/src/RTC/Transport.cpp
浏览文件 @
32e83e3a
...
@@ -3083,8 +3083,8 @@ namespace RTC
...
@@ -3083,8 +3083,8 @@ namespace RTC
/*
/*
* The interval between RTCP packets is varied randomly over the range
* The interval between RTCP packets is varied randomly over the range
* [1.0,
1.5] times the calculated interval to avoid unintended synchronization
* [1.0,
1.5] times the calculated interval to avoid unintended
* of all participants.
*
synchronization
of all participants.
*/
*/
interval
*=
static_cast
<
float
>
(
Utils
::
Crypto
::
GetRandomUInt
(
10
,
15
))
/
10
;
interval
*=
static_cast
<
float
>
(
Utils
::
Crypto
::
GetRandomUInt
(
10
,
15
))
/
10
;
...
...
worker/src/RTC/WebRtcServer.cpp
浏览文件 @
32e83e3a
...
@@ -499,7 +499,7 @@ namespace RTC
...
@@ -499,7 +499,7 @@ namespace RTC
if
(
this
->
mapTupleWebRtcTransport
.
find
(
tuple
->
hash
)
==
this
->
mapTupleWebRtcTransport
.
end
())
if
(
this
->
mapTupleWebRtcTransport
.
find
(
tuple
->
hash
)
==
this
->
mapTupleWebRtcTransport
.
end
())
{
{
MS_
WARN
_TAG
(
ice
,
"tuple hash not found in the table"
);
MS_
DEBUG
_TAG
(
ice
,
"tuple hash not found in the table"
);
return
;
return
;
}
}
...
...
worker/src/RTC/WebRtcTransport.cpp
浏览文件 @
32e83e3a
...
@@ -160,9 +160,11 @@ namespace RTC
...
@@ -160,9 +160,11 @@ namespace RTC
iceLocalPreferenceDecrement
+=
100
;
iceLocalPreferenceDecrement
+=
100
;
}
}
auto
iceConsentTimeout
=
options
->
iceConsentTimeout
();
// Create a ICE server.
// Create a ICE server.
this
->
iceServer
=
new
RTC
::
IceServer
(
this
->
iceServer
=
new
RTC
::
IceServer
(
this
,
Utils
::
Crypto
::
GetRandomString
(
32
),
Utils
::
Crypto
::
GetRandomString
(
32
));
this
,
Utils
::
Crypto
::
GetRandomString
(
32
),
Utils
::
Crypto
::
GetRandomString
(
32
)
,
iceConsentTimeout
);
// Create a DTLS transport.
// Create a DTLS transport.
this
->
dtlsTransport
=
new
RTC
::
DtlsTransport
(
this
);
this
->
dtlsTransport
=
new
RTC
::
DtlsTransport
(
this
);
...
@@ -227,9 +229,11 @@ namespace RTC
...
@@ -227,9 +229,11 @@ namespace RTC
MS_THROW_TYPE_ERROR
(
"empty iceCandidates"
);
MS_THROW_TYPE_ERROR
(
"empty iceCandidates"
);
}
}
auto
iceConsentTimeout
=
options
->
iceConsentTimeout
();
// Create a ICE server.
// Create a ICE server.
this
->
iceServer
=
new
RTC
::
IceServer
(
this
->
iceServer
=
new
RTC
::
IceServer
(
this
,
Utils
::
Crypto
::
GetRandomString
(
32
),
Utils
::
Crypto
::
GetRandomString
(
32
));
this
,
Utils
::
Crypto
::
GetRandomString
(
32
),
Utils
::
Crypto
::
GetRandomString
(
32
)
,
iceConsentTimeout
);
// Create a DTLS transport.
// Create a DTLS transport.
this
->
dtlsTransport
=
new
RTC
::
DtlsTransport
(
this
);
this
->
dtlsTransport
=
new
RTC
::
DtlsTransport
(
this
);
...
@@ -435,7 +439,8 @@ namespace RTC
...
@@ -435,7 +439,8 @@ namespace RTC
MS_THROW_ERROR
(
"connect() already called"
);
MS_THROW_ERROR
(
"connect() already called"
);
}
}
const
auto
*
body
=
request
->
data
->
body_as
<
FBS
::
WebRtcTransport
::
ConnectRequest
>
();
const
auto
*
body
=
request
->
data
->
body_as
<
FBS
::
WebRtcTransport
::
ConnectRequest
>
();
const
auto
*
dtlsParameters
=
body
->
dtlsParameters
();
const
auto
*
dtlsParameters
=
body
->
dtlsParameters
();
RTC
::
DtlsTransport
::
Fingerprint
dtlsRemoteFingerprint
;
RTC
::
DtlsTransport
::
Fingerprint
dtlsRemoteFingerprint
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论