Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
e5ee62f1
提交
e5ee62f1
authored
2月 13, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use capitalized CamelCase for C++ classes.
上级
80d70719
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
34 个修改的文件
包含
531 行增加
和
539 行删除
+531
-539
DtlsTransport.h
worker/include/RTC/DtlsTransport.h
+30
-30
IceCandidate.h
worker/include/RTC/IceCandidate.h
+4
-4
IceServer.h
worker/include/RTC/IceServer.h
+15
-15
RtcpPacket.h
worker/include/RTC/RtcpPacket.h
+8
-8
RtpListener.h
worker/include/RTC/RtpListener.h
+2
-2
RtpPacket.h
worker/include/RTC/RtpPacket.h
+24
-24
SrtpSession.h
worker/include/RTC/SrtpSession.h
+9
-9
StunMessage.h
worker/include/RTC/StunMessage.h
+34
-34
TcpConnection.h
worker/include/RTC/TcpConnection.h
+8
-8
TcpServer.h
worker/include/RTC/TcpServer.h
+13
-13
Transport.h
worker/include/RTC/Transport.h
+40
-44
TransportTuple.h
worker/include/RTC/TransportTuple.h
+8
-8
UdpSocket.h
worker/include/RTC/UdpSocket.h
+8
-8
TcpConnection.h
worker/include/handles/TcpConnection.h
+15
-15
TcpServer.h
worker/include/handles/TcpServer.h
+14
-14
UdpSocket.h
worker/include/handles/UdpSocket.h
+12
-12
DtlsTransport.cpp
worker/src/RTC/DtlsTransport.cpp
+0
-0
IceCandidate.cpp
worker/src/RTC/IceCandidate.cpp
+2
-2
IceServer.cpp
worker/src/RTC/IceServer.cpp
+44
-44
Peer.cpp
worker/src/RTC/Peer.cpp
+1
-1
RtcpPacket.cpp
worker/src/RTC/RtcpPacket.cpp
+7
-7
RtpListener.cpp
worker/src/RTC/RtpListener.cpp
+2
-2
RtpPacket.cpp
worker/src/RTC/RtpPacket.cpp
+12
-12
RtpParameters.cpp
worker/src/RTC/RtpParameters.cpp
+0
-1
SrtpSession.cpp
worker/src/RTC/SrtpSession.cpp
+20
-20
StunMessage.cpp
worker/src/RTC/StunMessage.cpp
+33
-33
TcpConnection.cpp
worker/src/RTC/TcpConnection.cpp
+7
-7
TcpServer.cpp
worker/src/RTC/TcpServer.cpp
+36
-38
Transport.cpp
worker/src/RTC/Transport.cpp
+0
-0
UdpSocket.cpp
worker/src/RTC/UdpSocket.cpp
+31
-31
TcpConnection.cpp
worker/src/handles/TcpConnection.cpp
+26
-26
TcpServer.cpp
worker/src/handles/TcpServer.cpp
+33
-34
UdpSocket.cpp
worker/src/handles/UdpSocket.cpp
+24
-24
main.cpp
worker/src/main.cpp
+9
-9
没有找到文件。
worker/include/RTC/D
TLS
Transport.h
→
worker/include/RTC/D
tls
Transport.h
浏览文件 @
e5ee62f1
...
...
@@ -2,7 +2,7 @@
#define MS_RTC_DTLS_TRANSPORT_H
#include "common.h"
#include "RTC/S
RTP
Session.h"
#include "RTC/S
rtp
Session.h"
#include "handles/Timer.h"
#include <string>
#include <map>
...
...
@@ -15,7 +15,7 @@
namespace
RTC
{
class
D
TLS
Transport
:
class
D
tls
Transport
:
public
Timer
::
Listener
{
public
:
...
...
@@ -58,7 +58,7 @@ namespace RTC
private
:
struct
SrtpProfileMapEntry
{
RTC
::
S
RTP
Session
::
Profile
profile
;
RTC
::
S
rtp
Session
::
Profile
profile
;
const
char
*
name
;
};
...
...
@@ -69,24 +69,24 @@ namespace RTC
// DTLS is in the process of negotiating a secure connection. Incoming
// media can flow through.
// NOTE: The caller MUST NOT call any method during this callback.
virtual
void
onD
TLSConnecting
(
DTLS
Transport
*
dtlsTransport
)
=
0
;
virtual
void
onD
tlsConnecting
(
Dtls
Transport
*
dtlsTransport
)
=
0
;
// DTLS has completed negotiation of a secure connection (including DTLS-SRTP
// and remote fingerprint verification). Outgoing media can now flow through.
// NOTE: The caller MUST NOT call any method during this callback.
virtual
void
onD
TLSConnected
(
DTLSTransport
*
dtlsTransport
,
RTC
::
SRTP
Session
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
=
0
;
virtual
void
onD
tlsConnected
(
DtlsTransport
*
dtlsTransport
,
RTC
::
Srtp
Session
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
=
0
;
// The DTLS connection has been closed as the result of an error (such as a
// DTLS alert or a failure to validate the remote fingerprint).
// NOTE: The caller MUST NOT call Close() during this callback.
virtual
void
onD
TLSFailed
(
DTLS
Transport
*
dtlsTransport
)
=
0
;
virtual
void
onD
tlsFailed
(
Dtls
Transport
*
dtlsTransport
)
=
0
;
// The DTLS connection has been closed due to receipt of a close_notify alert.
// NOTE: The caller MUST NOT call Close() during this callback.
virtual
void
onD
TLSClosed
(
DTLS
Transport
*
dtlsTransport
)
=
0
;
virtual
void
onD
tlsClosed
(
Dtls
Transport
*
dtlsTransport
)
=
0
;
// Need to send DTLS data to the peer.
// NOTE: The caller MUST NOT call Close() during this callback.
virtual
void
onOutgoingD
TLSData
(
DTLS
Transport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
virtual
void
onOutgoingD
tlsData
(
Dtls
Transport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
// DTLS application data received.
// NOTE: The caller MUST NOT call Close() during this callback.
virtual
void
onD
TLSApplicationData
(
DTLS
Transport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
virtual
void
onD
tlsApplicationData
(
Dtls
Transport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
};
public
:
...
...
@@ -95,7 +95,7 @@ namespace RTC
static
Json
::
Value
&
GetLocalFingerprints
();
static
Role
StringToRole
(
std
::
string
role
);
static
FingerprintAlgorithm
GetFingerprintAlgorithm
(
std
::
string
fingerprint
);
static
bool
IsD
TLS
(
const
uint8_t
*
data
,
size_t
len
);
static
bool
IsD
tls
(
const
uint8_t
*
data
,
size_t
len
);
private
:
static
void
GenerateCertificateAndPrivateKey
();
...
...
@@ -114,14 +114,14 @@ namespace RTC
static
std
::
vector
<
SrtpProfileMapEntry
>
srtpProfiles
;
public
:
D
TLS
Transport
(
Listener
*
listener
);
virtual
~
D
TLS
Transport
();
D
tls
Transport
(
Listener
*
listener
);
virtual
~
D
tls
Transport
();
void
Close
();
void
Dump
();
void
Run
(
Role
localRole
);
void
SetRemoteFingerprint
(
Fingerprint
fingerprint
);
void
ProcessD
TLS
Data
(
const
uint8_t
*
data
,
size_t
len
);
void
ProcessD
tls
Data
(
const
uint8_t
*
data
,
size_t
len
);
DtlsState
GetState
();
Role
GetLocalRole
();
void
SendApplicationData
(
const
uint8_t
*
data
,
size_t
len
);
...
...
@@ -130,12 +130,12 @@ namespace RTC
bool
IsRunning
();
void
Reset
();
bool
CheckStatus
(
int
return_code
);
void
SendPendingOutgoingD
TLS
Data
();
void
SendPendingOutgoingD
tls
Data
();
bool
SetTimeout
();
void
ProcessHandshake
();
bool
CheckRemoteFingerprint
();
void
ExtractS
RTPKeys
(
RTC
::
SRTP
Session
::
Profile
srtp_profile
);
RTC
::
S
RTPSession
::
Profile
GetNegotiatedSRTP
Profile
();
void
ExtractS
rtpKeys
(
RTC
::
Srtp
Session
::
Profile
srtp_profile
);
RTC
::
S
rtpSession
::
Profile
GetNegotiatedSrtp
Profile
();
/* Callbacks fired by OpenSSL events. */
public
:
...
...
@@ -164,35 +164,35 @@ namespace RTC
/* Inline static methods. */
inline
Json
::
Value
&
D
TLS
Transport
::
GetLocalFingerprints
()
Json
::
Value
&
D
tls
Transport
::
GetLocalFingerprints
()
{
return
D
TLS
Transport
::
localFingerprints
;
return
D
tls
Transport
::
localFingerprints
;
}
inline
D
TLSTransport
::
Role
DTLS
Transport
::
StringToRole
(
std
::
string
role
)
D
tlsTransport
::
Role
Dtls
Transport
::
StringToRole
(
std
::
string
role
)
{
auto
it
=
D
TLS
Transport
::
string2Role
.
find
(
role
);
auto
it
=
D
tls
Transport
::
string2Role
.
find
(
role
);
if
(
it
!=
D
TLS
Transport
::
string2Role
.
end
())
if
(
it
!=
D
tls
Transport
::
string2Role
.
end
())
return
it
->
second
;
else
return
D
TLS
Transport
::
Role
::
NONE
;
return
D
tls
Transport
::
Role
::
NONE
;
}
inline
D
TLSTransport
::
FingerprintAlgorithm
DTLS
Transport
::
GetFingerprintAlgorithm
(
std
::
string
fingerprint
)
D
tlsTransport
::
FingerprintAlgorithm
Dtls
Transport
::
GetFingerprintAlgorithm
(
std
::
string
fingerprint
)
{
auto
it
=
D
TLS
Transport
::
string2FingerprintAlgorithm
.
find
(
fingerprint
);
auto
it
=
D
tls
Transport
::
string2FingerprintAlgorithm
.
find
(
fingerprint
);
if
(
it
!=
D
TLS
Transport
::
string2FingerprintAlgorithm
.
end
())
if
(
it
!=
D
tls
Transport
::
string2FingerprintAlgorithm
.
end
())
return
it
->
second
;
else
return
D
TLS
Transport
::
FingerprintAlgorithm
::
NONE
;
return
D
tls
Transport
::
FingerprintAlgorithm
::
NONE
;
}
inline
bool
D
TLSTransport
::
IsDTLS
(
const
uint8_t
*
data
,
size_t
len
)
bool
D
tlsTransport
::
IsDtls
(
const
uint8_t
*
data
,
size_t
len
)
{
return
(
// Minimum DTLS record length is 13 bytes.
...
...
@@ -205,7 +205,7 @@ namespace RTC
/* Inline instance methods. */
inline
bool
D
TLS
Transport
::
IsRunning
()
bool
D
tls
Transport
::
IsRunning
()
{
switch
(
this
->
state
)
{
...
...
@@ -224,13 +224,13 @@ namespace RTC
}
inline
D
TLSTransport
::
DtlsState
DTLS
Transport
::
GetState
()
D
tlsTransport
::
DtlsState
Dtls
Transport
::
GetState
()
{
return
this
->
state
;
}
inline
D
TLSTransport
::
Role
DTLS
Transport
::
GetLocalRole
()
D
tlsTransport
::
Role
Dtls
Transport
::
GetLocalRole
()
{
return
this
->
localRole
;
}
...
...
worker/include/RTC/IceCandidate.h
浏览文件 @
e5ee62f1
...
...
@@ -2,8 +2,8 @@
#define MS_RTC_ICE_CANDIDATE_H
#include "common.h"
#include "RTC/U
DP
Socket.h"
#include "RTC/T
CP
Server.h"
#include "RTC/U
dp
Socket.h"
#include "RTC/T
cp
Server.h"
#include <string>
#include <json/json.h>
...
...
@@ -31,8 +31,8 @@ namespace RTC
};
public
:
IceCandidate
(
RTC
::
U
DP
Socket
*
udpSocket
,
uint32_t
priority
);
IceCandidate
(
RTC
::
T
CP
Server
*
tcpServer
,
uint32_t
priority
);
IceCandidate
(
RTC
::
U
dp
Socket
*
udpSocket
,
uint32_t
priority
);
IceCandidate
(
RTC
::
T
cp
Server
*
tcpServer
,
uint32_t
priority
);
Json
::
Value
toJson
();
...
...
worker/include/RTC/I
CE
Server.h
→
worker/include/RTC/I
ce
Server.h
浏览文件 @
e5ee62f1
#ifndef MS_RTC_I
CE
_SERVER_H
#define MS_RTC_I
CE
_SERVER_H
#ifndef MS_RTC_I
ce
_SERVER_H
#define MS_RTC_I
ce
_SERVER_H
#include "common.h"
#include "RTC/S
TUN
Message.h"
#include "RTC/S
tun
Message.h"
#include "RTC/TransportTuple.h"
#include <string>
#include <list>
namespace
RTC
{
class
I
CE
Server
class
I
ce
Server
{
public
:
enum
class
IceState
...
...
@@ -25,21 +25,21 @@ namespace RTC
{
public
:
/**
* These callbacks are guaranteed to be called before ProcessS
TUN
Message()
* These callbacks are guaranteed to be called before ProcessS
tun
Message()
* returns, so the given pointers are still usable.
*/
virtual
void
onOutgoingS
TUNMessage
(
ICEServer
*
iceServer
,
RTC
::
STUN
Message
*
msg
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
onI
CESelectedTuple
(
ICE
Server
*
iceServer
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
onI
CEConnected
(
ICE
Server
*
iceServer
)
=
0
;
virtual
void
onI
CECompleted
(
ICE
Server
*
iceServer
)
=
0
;
virtual
void
onI
CEDisconnected
(
ICE
Server
*
iceServer
)
=
0
;
virtual
void
onOutgoingS
tunMessage
(
IceServer
*
iceServer
,
RTC
::
Stun
Message
*
msg
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
onI
ceSelectedTuple
(
Ice
Server
*
iceServer
,
RTC
::
TransportTuple
*
tuple
)
=
0
;
virtual
void
onI
ceConnected
(
Ice
Server
*
iceServer
)
=
0
;
virtual
void
onI
ceCompleted
(
Ice
Server
*
iceServer
)
=
0
;
virtual
void
onI
ceDisconnected
(
Ice
Server
*
iceServer
)
=
0
;
};
public
:
I
CE
Server
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
password
);
I
ce
Server
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
password
);
void
Close
();
void
ProcessS
TUNMessage
(
RTC
::
STUN
Message
*
msg
,
RTC
::
TransportTuple
*
tuple
);
void
ProcessS
tunMessage
(
RTC
::
Stun
Message
*
msg
,
RTC
::
TransportTuple
*
tuple
);
std
::
string
&
GetUsernameFragment
();
std
::
string
&
GetPassword
();
IceState
GetState
();
...
...
@@ -79,19 +79,19 @@ namespace RTC
/* Inline methods. */
inline
std
::
string
&
I
CE
Server
::
GetUsernameFragment
()
std
::
string
&
I
ce
Server
::
GetUsernameFragment
()
{
return
this
->
usernameFragment
;
}
inline
std
::
string
&
I
CE
Server
::
GetPassword
()
std
::
string
&
I
ce
Server
::
GetPassword
()
{
return
this
->
password
;
}
inline
I
CEServer
::
IceState
ICE
Server
::
GetState
()
I
ceServer
::
IceState
Ice
Server
::
GetState
()
{
return
this
->
state
;
}
...
...
worker/include/RTC/R
TCP
Packet.h
→
worker/include/RTC/R
tcp
Packet.h
浏览文件 @
e5ee62f1
...
...
@@ -5,7 +5,7 @@
namespace
RTC
{
class
R
TCP
Packet
class
R
tcp
Packet
{
public
:
/* Struct for RTCP common header. */
...
...
@@ -25,12 +25,12 @@ namespace RTC
};
public
:
static
bool
IsR
TCP
(
const
uint8_t
*
data
,
size_t
len
);
static
R
TCP
Packet
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
static
bool
IsR
tcp
(
const
uint8_t
*
data
,
size_t
len
);
static
R
tcp
Packet
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
public
:
R
TCP
Packet
(
CommonHeader
*
header
,
const
uint8_t
*
raw
,
size_t
length
);
~
R
TCP
Packet
();
R
tcp
Packet
(
CommonHeader
*
header
,
const
uint8_t
*
raw
,
size_t
length
);
~
R
tcp
Packet
();
const
uint8_t
*
GetRaw
();
size_t
GetLength
();
...
...
@@ -45,7 +45,7 @@ namespace RTC
/* Inline static methods. */
inline
bool
R
TCPPacket
::
IsRTCP
(
const
uint8_t
*
data
,
size_t
len
)
bool
R
tcpPacket
::
IsRtcp
(
const
uint8_t
*
data
,
size_t
len
)
{
CommonHeader
*
header
=
(
CommonHeader
*
)
data
;
...
...
@@ -65,13 +65,13 @@ namespace RTC
/* Inline instance methods. */
inline
const
uint8_t
*
R
TCP
Packet
::
GetRaw
()
const
uint8_t
*
R
tcp
Packet
::
GetRaw
()
{
return
this
->
raw
;
}
inline
size_t
R
TCP
Packet
::
GetLength
()
size_t
R
tcp
Packet
::
GetLength
()
{
return
this
->
length
;
}
...
...
worker/include/RTC/RtpListener.h
浏览文件 @
e5ee62f1
...
...
@@ -4,7 +4,7 @@
#include "common.h"
#include "RTC/RtpReceiver.h"
#include "RTC/RtpParameters.h"
#include "RTC/R
TP
Packet.h"
#include "RTC/R
tp
Packet.h"
#include <unordered_map>
#include <json/json.h>
...
...
@@ -19,7 +19,7 @@ namespace RTC
Json
::
Value
toJson
();
void
AddRtpReceiver
(
RTC
::
RtpReceiver
*
rtpReceiver
,
RTC
::
RtpParameters
*
rtpParameters
);
void
RemoveRtpReceiver
(
RTC
::
RtpReceiver
*
rtpReceiver
);
RTC
::
RtpReceiver
*
GetRtpReceiver
(
RTC
::
R
TP
Packet
*
packet
);
RTC
::
RtpReceiver
*
GetRtpReceiver
(
RTC
::
R
tp
Packet
*
packet
);
private
:
// Others.
...
...
worker/include/RTC/R
TP
Packet.h
→
worker/include/RTC/R
tp
Packet.h
浏览文件 @
e5ee62f1
...
...
@@ -5,7 +5,7 @@
namespace
RTC
{
class
R
TP
Packet
class
R
tp
Packet
{
public
:
/* Struct for RTP header. */
...
...
@@ -40,12 +40,12 @@ namespace RTC
};
public
:
static
bool
IsR
TP
(
const
uint8_t
*
data
,
size_t
len
);
static
R
TP
Packet
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
static
bool
IsR
tp
(
const
uint8_t
*
data
,
size_t
len
);
static
R
tp
Packet
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
public
:
R
TP
Packet
(
Header
*
header
,
ExtensionHeader
*
extensionHeader
,
const
uint8_t
*
payload
,
size_t
payloadLen
,
uint8_t
payloadPadding
,
const
uint8_t
*
raw
,
size_t
length
);
~
R
TP
Packet
();
R
tp
Packet
(
Header
*
header
,
ExtensionHeader
*
extensionHeader
,
const
uint8_t
*
payload
,
size_t
payloadLen
,
uint8_t
payloadPadding
,
const
uint8_t
*
raw
,
size_t
length
);
~
R
tp
Packet
();
void
Dump
();
const
uint8_t
*
GetRaw
();
...
...
@@ -56,8 +56,8 @@ namespace RTC
void
SetMarker
(
bool
marker
);
uint16_t
GetSequenceNumber
();
uint32_t
GetTimestamp
();
uint32_t
GetS
SRC
();
void
SetS
SRC
(
uint32_t
ssrc
);
// TODO: yes?
uint32_t
GetS
src
();
void
SetS
src
(
uint32_t
ssrc
);
// TODO: yes?
bool
HasExtensionHeader
();
uint16_t
GetExtensionHeaderId
();
size_t
GetExtensionHeaderLength
();
...
...
@@ -82,9 +82,9 @@ namespace RTC
/* Inline static methods. */
inline
bool
R
TPPacket
::
IsRTP
(
const
uint8_t
*
data
,
size_t
len
)
bool
R
tpPacket
::
IsRtp
(
const
uint8_t
*
data
,
size_t
len
)
{
// NOTE: R
TCPPacket::IsRTCP
() must always be called before this method.
// NOTE: R
tcpPacket::IsRtcp
() must always be called before this method.
Header
*
header
=
(
Header
*
)
data
;
...
...
@@ -100,74 +100,74 @@ namespace RTC
/* Inline instance methods. */
inline
const
uint8_t
*
R
TP
Packet
::
GetRaw
()
const
uint8_t
*
R
tp
Packet
::
GetRaw
()
{
return
this
->
raw
;
}
inline
size_t
R
TP
Packet
::
GetLength
()
size_t
R
tp
Packet
::
GetLength
()
{
return
this
->
length
;
}
inline
uint8_t
R
TP
Packet
::
GetPayloadType
()
uint8_t
R
tp
Packet
::
GetPayloadType
()
{
return
this
->
header
->
payload_type
;
}
inline
void
R
TP
Packet
::
SetPayloadType
(
uint8_t
payload_type
)
void
R
tp
Packet
::
SetPayloadType
(
uint8_t
payload_type
)
{
this
->
header
->
payload_type
=
payload_type
;
}
inline
bool
R
TP
Packet
::
HasMarker
()
bool
R
tp
Packet
::
HasMarker
()
{
return
this
->
header
->
marker
;
}
inline
void
R
TP
Packet
::
SetMarker
(
bool
marker
)
void
R
tp
Packet
::
SetMarker
(
bool
marker
)
{
this
->
header
->
marker
=
marker
;
}
inline
uint16_t
R
TP
Packet
::
GetSequenceNumber
()
uint16_t
R
tp
Packet
::
GetSequenceNumber
()
{
return
(
uint16_t
)
ntohs
(
this
->
header
->
sequence_number
);
}
inline
uint32_t
R
TP
Packet
::
GetTimestamp
()
uint32_t
R
tp
Packet
::
GetTimestamp
()
{
return
(
uint32_t
)
ntohl
(
this
->
header
->
timestamp
);
}
inline
uint32_t
R
TPPacket
::
GetSSRC
()
uint32_t
R
tpPacket
::
GetSsrc
()
{
return
(
uint32_t
)
ntohl
(
this
->
header
->
ssrc
);
}
// TODO temp
inline
void
R
TPPacket
::
SetSSRC
(
uint32_t
ssrc
)
void
R
tpPacket
::
SetSsrc
(
uint32_t
ssrc
)
{
this
->
header
->
ssrc
=
htonl
(
ssrc
);
}
inline
bool
R
TP
Packet
::
HasExtensionHeader
()
bool
R
tp
Packet
::
HasExtensionHeader
()
{
return
(
this
->
extensionHeader
?
true
:
false
);
}
inline
uint16_t
R
TP
Packet
::
GetExtensionHeaderId
()
uint16_t
R
tp
Packet
::
GetExtensionHeaderId
()
{
if
(
this
->
extensionHeader
)
return
uint16_t
(
ntohs
(
this
->
extensionHeader
->
id
));
...
...
@@ -176,7 +176,7 @@ namespace RTC
}
inline
size_t
R
TP
Packet
::
GetExtensionHeaderLength
()
size_t
R
tp
Packet
::
GetExtensionHeaderLength
()
{
if
(
this
->
extensionHeader
)
return
size_t
(
ntohs
(
this
->
extensionHeader
->
length
)
*
4
);
...
...
@@ -185,13 +185,13 @@ namespace RTC
}
inline
uint8_t
*
R
TP
Packet
::
GetPayload
()
uint8_t
*
R
tp
Packet
::
GetPayload
()
{
return
this
->
payload
;
}
inline
size_t
R
TP
Packet
::
GetPayloadLength
()
size_t
R
tp
Packet
::
GetPayloadLength
()
{
return
this
->
payloadLength
;
}
...
...
worker/include/RTC/S
RTP
Session.h
→
worker/include/RTC/S
rtp
Session.h
浏览文件 @
e5ee62f1
...
...
@@ -7,7 +7,7 @@
namespace
RTC
{
class
S
RTP
Session
class
S
rtp
Session
{
public
:
enum
class
Profile
...
...
@@ -28,19 +28,19 @@ namespace RTC
static
void
ClassInit
();
// private:
// static void onS
RTP
Event(srtp_event_data_t* data);
// static void onS
rtp
Event(srtp_event_data_t* data);
private
:
static
uint8_t
encryptBuffer
[];
public
:
S
RTP
Session
(
Type
type
,
Profile
profile
,
uint8_t
*
key
,
size_t
key_len
);
~
S
RTP
Session
();
S
rtp
Session
(
Type
type
,
Profile
profile
,
uint8_t
*
key
,
size_t
key_len
);
~
S
rtp
Session
();
bool
EncryptR
TP
(
const
uint8_t
**
data
,
size_t
*
len
);
bool
DecryptS
RTP
(
const
uint8_t
*
data
,
size_t
*
len
);
bool
EncryptR
TCP
(
const
uint8_t
**
data
,
size_t
*
len
);
bool
DecryptS
RTCP
(
const
uint8_t
*
data
,
size_t
*
len
);
bool
EncryptR
tp
(
const
uint8_t
**
data
,
size_t
*
len
);
bool
DecryptS
rtp
(
const
uint8_t
*
data
,
size_t
*
len
);
bool
EncryptR
tcp
(
const
uint8_t
**
data
,
size_t
*
len
);
bool
DecryptS
rtcp
(
const
uint8_t
*
data
,
size_t
*
len
);
const
char
*
GetLastErrorDesc
();
void
Close
();
...
...
@@ -54,7 +54,7 @@ namespace RTC
/* Inline instance methods. */
inline
const
char
*
S
RTP
Session
::
GetLastErrorDesc
()
const
char
*
S
rtp
Session
::
GetLastErrorDesc
()
{
const
char
*
error_string
;
...
...
worker/include/RTC/S
TUN
Message.h
→
worker/include/RTC/S
tun
Message.h
浏览文件 @
e5ee62f1
...
...
@@ -6,7 +6,7 @@
namespace
RTC
{
class
S
TUN
Message
class
S
tun
Message
{
public
:
// STUN message class.
...
...
@@ -53,15 +53,15 @@ namespace RTC
};
public
:
static
bool
IsS
TUN
(
const
uint8_t
*
data
,
size_t
len
);
static
S
TUN
Message
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
static
bool
IsS
tun
(
const
uint8_t
*
data
,
size_t
len
);
static
S
tun
Message
*
Parse
(
const
uint8_t
*
data
,
size_t
len
);
private
:
static
const
uint8_t
magicCookie
[];
public
:
S
TUN
Message
(
Class
klass
,
Method
method
,
const
uint8_t
*
transactionId
,
const
uint8_t
*
raw
,
size_t
length
);
~
S
TUN
Message
();
S
tun
Message
(
Class
klass
,
Method
method
,
const
uint8_t
*
transactionId
,
const
uint8_t
*
raw
,
size_t
length
);
~
S
tun
Message
();
void
Dump
();
Class
GetClass
();
...
...
@@ -87,8 +87,8 @@ namespace RTC
bool
HasMessageIntegrity
();
bool
HasFingerprint
();
Authentication
CheckAuthentication
(
const
std
::
string
&
local_username
,
const
std
::
string
&
local_password
);
S
TUN
Message
*
CreateSuccessResponse
();
S
TUN
Message
*
CreateErrorResponse
(
uint16_t
errorCode
);
S
tun
Message
*
CreateSuccessResponse
();
S
tun
Message
*
CreateErrorResponse
(
uint16_t
errorCode
);
void
Authenticate
(
const
std
::
string
&
password
);
void
Serialize
();
...
...
@@ -117,7 +117,7 @@ namespace RTC
/* Inline methods. */
inline
bool
S
TUNMessage
::
IsSTUN
(
const
uint8_t
*
data
,
size_t
len
)
bool
S
tunMessage
::
IsStun
(
const
uint8_t
*
data
,
size_t
len
)
{
return
(
// STUN headers are 20 bytes.
...
...
@@ -125,147 +125,147 @@ namespace RTC
// DOC: https://tools.ietf.org/html/draft-petithuguenin-avtcore-rfc5764-mux-fixes-00
(
data
[
0
]
<
20
)
&&
// Magic cookie must match.
(
data
[
4
]
==
S
TUN
Message
::
magicCookie
[
0
])
&&
(
data
[
5
]
==
S
TUN
Message
::
magicCookie
[
1
])
&&
(
data
[
6
]
==
S
TUN
Message
::
magicCookie
[
2
])
&&
(
data
[
7
]
==
S
TUN
Message
::
magicCookie
[
3
])
(
data
[
4
]
==
S
tun
Message
::
magicCookie
[
0
])
&&
(
data
[
5
]
==
S
tun
Message
::
magicCookie
[
1
])
&&
(
data
[
6
]
==
S
tun
Message
::
magicCookie
[
2
])
&&
(
data
[
7
]
==
S
tun
Message
::
magicCookie
[
3
])
);
}
inline
S
TUNMessage
::
Class
STUN
Message
::
GetClass
()
S
tunMessage
::
Class
Stun
Message
::
GetClass
()
{
return
this
->
klass
;
}
inline
S
TUNMessage
::
Method
STUN
Message
::
GetMethod
()
S
tunMessage
::
Method
Stun
Message
::
GetMethod
()
{
return
this
->
method
;
}
inline
const
uint8_t
*
S
TUN
Message
::
GetRaw
()
const
uint8_t
*
S
tun
Message
::
GetRaw
()
{
return
this
->
raw
;
}
inline
void
S
TUN
Message
::
SetLength
(
size_t
length
)
void
S
tun
Message
::
SetLength
(
size_t
length
)
{
this
->
length
=
length
;
}
inline
size_t
S
TUN
Message
::
GetLength
()
size_t
S
tun
Message
::
GetLength
()
{
return
this
->
length
;
}
inline
void
S
TUN
Message
::
SetUsername
(
const
char
*
username
,
size_t
len
)
void
S
tun
Message
::
SetUsername
(
const
char
*
username
,
size_t
len
)
{
if
(
this
->
username
.
empty
())
this
->
username
=
std
::
string
(
username
,
len
);
}
inline
void
S
TUN
Message
::
SetPriority
(
const
uint32_t
priority
)
void
S
tun
Message
::
SetPriority
(
const
uint32_t
priority
)
{
if
(
!
this
->
priority
)
this
->
priority
=
priority
;
}
inline
void
S
TUN
Message
::
SetIceControlling
(
const
uint64_t
iceControlling
)
void
S
tun
Message
::
SetIceControlling
(
const
uint64_t
iceControlling
)
{
if
(
!
this
->
iceControlling
)
this
->
iceControlling
=
iceControlling
;
}
inline
void
S
TUN
Message
::
SetIceControlled
(
const
uint64_t
iceControlled
)
void
S
tun
Message
::
SetIceControlled
(
const
uint64_t
iceControlled
)
{
if
(
!
this
->
iceControlled
)
this
->
iceControlled
=
iceControlled
;
}
inline
void
S
TUN
Message
::
SetUseCandidate
()
void
S
tun
Message
::
SetUseCandidate
()
{
this
->
hasUseCandidate
=
true
;
}
inline
void
S
TUN
Message
::
SetXorMappedAddress
(
const
struct
sockaddr
*
xorMappedAddress
)
void
S
tun
Message
::
SetXorMappedAddress
(
const
struct
sockaddr
*
xorMappedAddress
)
{
if
(
!
this
->
xorMappedAddress
)
this
->
xorMappedAddress
=
xorMappedAddress
;
}
inline
void
S
TUN
Message
::
SetErrorCode
(
uint16_t
errorCode
)
void
S
tun
Message
::
SetErrorCode
(
uint16_t
errorCode
)
{
this
->
errorCode
=
errorCode
;
}
inline
void
S
TUN
Message
::
SetMessageIntegrity
(
const
uint8_t
*
messageIntegrity
)
void
S
tun
Message
::
SetMessageIntegrity
(
const
uint8_t
*
messageIntegrity
)
{
if
(
!
this
->
messageIntegrity
)
this
->
messageIntegrity
=
messageIntegrity
;
}
inline
void
S
TUN
Message
::
SetFingerprint
()
void
S
tun
Message
::
SetFingerprint
()
{
this
->
hasFingerprint
=
true
;
}
inline
const
std
::
string
&
S
TUN
Message
::
GetUsername
()
const
std
::
string
&
S
tun
Message
::
GetUsername
()
{
return
this
->
username
;
}
inline
const
uint32_t
S
TUN
Message
::
GetPriority
()
const
uint32_t
S
tun
Message
::
GetPriority
()
{
return
this
->
priority
;
}
inline
const
uint64_t
S
TUN
Message
::
GetIceControlling
()
const
uint64_t
S
tun
Message
::
GetIceControlling
()
{
return
this
->
iceControlling
;
}
inline
const
uint64_t
S
TUN
Message
::
GetIceControlled
()
const
uint64_t
S
tun
Message
::
GetIceControlled
()
{
return
this
->
iceControlled
;
}
inline
bool
S
TUN
Message
::
HasUseCandidate
()
bool
S
tun
Message
::
HasUseCandidate
()
{
return
this
->
hasUseCandidate
;
}
inline
uint16_t
S
TUN
Message
::
GetErrorCode
()
uint16_t
S
tun
Message
::
GetErrorCode
()
{
return
this
->
errorCode
;
}
inline
bool
S
TUN
Message
::
HasMessageIntegrity
()
bool
S
tun
Message
::
HasMessageIntegrity
()
{
return
(
this
->
messageIntegrity
?
true
:
false
);
}
inline
bool
S
TUN
Message
::
HasFingerprint
()
bool
S
tun
Message
::
HasFingerprint
()
{
return
this
->
hasFingerprint
;
}
...
...
worker/include/RTC/T
CP
Connection.h
→
worker/include/RTC/T
cp
Connection.h
浏览文件 @
e5ee62f1
...
...
@@ -2,29 +2,29 @@
#define MS_RTC_TCP_CONNECTION_H
#include "common.h"
#include "handles/T
CP
Connection.h"
#include "handles/T
cp
Connection.h"
namespace
RTC
{
class
T
CP
Connection
:
public
::
T
CP
Connection
class
T
cp
Connection
:
public
::
T
cp
Connection
{
public
:
class
Listener
{
public
:
virtual
void
onPacketRecv
(
RTC
::
T
CP
Connection
*
connection
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
virtual
void
onPacketRecv
(
RTC
::
T
cp
Connection
*
connection
,
const
uint8_t
*
data
,
size_t
len
)
=
0
;
};
public
:
T
CP
Connection
(
Listener
*
listener
,
size_t
bufferSize
);
virtual
~
T
CP
Connection
();
T
cp
Connection
(
Listener
*
listener
,
size_t
bufferSize
);
virtual
~
T
cp
Connection
();
void
Send
(
const
uint8_t
*
data
,
size_t
len
);
/* Pure virtual methods inherited from ::T
CP
Connection. */
/* Pure virtual methods inherited from ::T
cp
Connection. */
public
:
virtual
void
userOnT
CP
ConnectionRead
()
override
;
virtual
void
userOnT
cp
ConnectionRead
()
override
;
private
:
// Passed by argument.
...
...
worker/include/RTC/T
CP
Server.h
→
worker/include/RTC/T
cp
Server.h
浏览文件 @
e5ee62f1
...
...
@@ -2,22 +2,22 @@
#define MS_RTC_TCP_SERVER_H
#include "common.h"
#include "handles/T
CP
Server.h"
#include "handles/T
CP
Connection.h"
#include "RTC/T
CP
Connection.h"
#include "handles/T
cp
Server.h"
#include "handles/T
cp
Connection.h"
#include "RTC/T
cp
Connection.h"
#include <unordered_map>
#include <uv.h>
namespace
RTC
{
class
T
CP
Server
:
public
::
T
CP
Server
class
T
cp
Server
:
public
::
T
cp
Server
{
public
:
class
Listener
{
public
:
virtual
void
onR
TCTCPConnectionClosed
(
RTC
::
TCPServer
*
tcpServer
,
RTC
::
TCP
Connection
*
connection
,
bool
is_closed_by_peer
)
=
0
;
virtual
void
onR
tcTcpConnectionClosed
(
RTC
::
TcpServer
*
tcpServer
,
RTC
::
Tcp
Connection
*
connection
,
bool
is_closed_by_peer
)
=
0
;
};
public
:
...
...
@@ -35,19 +35,19 @@ namespace RTC
static
std
::
unordered_map
<
uint16_t
,
bool
>
availableIPv6Ports
;
public
:
T
CPServer
(
Listener
*
listener
,
RTC
::
TCP
Connection
::
Listener
*
connListener
,
int
address_family
);
T
cpServer
(
Listener
*
listener
,
RTC
::
Tcp
Connection
::
Listener
*
connListener
,
int
address_family
);
/* Pure virtual methods inherited from ::T
CP
Server. */
/* Pure virtual methods inherited from ::T
cp
Server. */
public
:
virtual
void
userOnT
CPConnectionAlloc
(
::
TCP
Connection
**
connection
)
override
;
virtual
void
userOnNewT
CPConnection
(
::
TCP
Connection
*
connection
)
override
;
virtual
void
userOnT
CPConnectionClosed
(
::
TCP
Connection
*
connection
,
bool
is_closed_by_peer
)
override
;
virtual
void
userOnT
CP
ServerClosed
()
override
;
virtual
void
userOnT
cpConnectionAlloc
(
::
Tcp
Connection
**
connection
)
override
;
virtual
void
userOnNewT
cpConnection
(
::
Tcp
Connection
*
connection
)
override
;
virtual
void
userOnT
cpConnectionClosed
(
::
Tcp
Connection
*
connection
,
bool
is_closed_by_peer
)
override
;
virtual
void
userOnT
cp
ServerClosed
()
override
;
private
:
// Passed by argument.
Listener
*
listener
=
nullptr
;
RTC
::
T
CP
Connection
::
Listener
*
connListener
=
nullptr
;
RTC
::
T
cp
Connection
::
Listener
*
connListener
=
nullptr
;
};
}
...
...
worker/include/RTC/Transport.h
浏览文件 @
e5ee62f1
...
...
@@ -2,18 +2,15 @@
#define MS_RTC_TRANSPORT_H
#include "common.h"
#include "RTC/U
DP
Socket.h"
#include "RTC/T
CP
Server.h"
#include "RTC/T
CP
Connection.h"
#include "RTC/U
dp
Socket.h"
#include "RTC/T
cp
Server.h"
#include "RTC/T
cp
Connection.h"
#include "RTC/IceCandidate.h"
#include "RTC/I
CE
Server.h"
#include "RTC/S
TUN
Message.h"
#include "RTC/I
ce
Server.h"
#include "RTC/S
tun
Message.h"
#include "RTC/TransportTuple.h"
#include "RTC/DTLSTransport.h"
#include "RTC/RTPPacket.h"
#include "RTC/RTCPPacket.h"
#include "RTC/DtlsTransport.h"
#include "RTC/RtpListener.h"
#include "RTC/RtpReceiver.h" // TODO: let's see if needed here or not
#include "Channel/Request.h"
#include "Channel/Notifier.h"
#include <string>
...
...
@@ -24,12 +21,11 @@
namespace
RTC
{
class
Transport
:
public
RTC
::
UDPSocket
::
Listener
,
public
RTC
::
TCPServer
::
Listener
,
public
RTC
::
TCPConnection
::
Listener
,
public
RTC
::
ICEServer
::
Listener
,
public
RTC
::
DTLSTransport
::
Listener
,
// Transport is also a RtpListener.
public
RTC
::
UdpSocket
::
Listener
,
public
RTC
::
TcpServer
::
Listener
,
public
RTC
::
TcpConnection
::
Listener
,
public
RTC
::
IceServer
::
Listener
,
public
RTC
::
DtlsTransport
::
Listener
,
public
RTC
::
RtpListener
{
public
:
...
...
@@ -48,44 +44,44 @@ namespace RTC
void
HandleRequest
(
Channel
::
Request
*
request
);
private
:
void
MayRunD
TLS
Transport
();
void
MayRunD
tls
Transport
();
/* Private methods to unify UDP and TCP behavior. */
private
:
void
onPacketRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
onS
TUN
DataRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
onD
TLS
DataRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
onR
TP
DataRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
onR
TCP
DataRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
onS
tun
DataRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
onD
tls
DataRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
onR
tp
DataRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
void
onR
tcp
DataRecv
(
RTC
::
TransportTuple
*
tuple
,
const
uint8_t
*
data
,
size_t
len
);
/* Pure virtual methods inherited from RTC::U
DP
Socket::Listener. */
/* Pure virtual methods inherited from RTC::U
dp
Socket::Listener. */
public
:
virtual
void
onPacketRecv
(
RTC
::
U
DP
Socket
*
socket
,
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
remote_addr
)
override
;
virtual
void
onPacketRecv
(
RTC
::
U
dp
Socket
*
socket
,
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
remote_addr
)
override
;
/* Pure virtual methods inherited from RTC::T
CP
Server::Listener. */
/* Pure virtual methods inherited from RTC::T
cp
Server::Listener. */
public
:
virtual
void
onR
TCTCPConnectionClosed
(
RTC
::
TCPServer
*
tcpServer
,
RTC
::
TCP
Connection
*
connection
,
bool
is_closed_by_peer
)
override
;
virtual
void
onR
tcTcpConnectionClosed
(
RTC
::
TcpServer
*
tcpServer
,
RTC
::
Tcp
Connection
*
connection
,
bool
is_closed_by_peer
)
override
;
/* Pure virtual methods inherited from RTC::T
CP
Connection::Listener. */
/* Pure virtual methods inherited from RTC::T
cp
Connection::Listener. */
public
:
virtual
void
onPacketRecv
(
RTC
::
T
CP
Connection
*
connection
,
const
uint8_t
*
data
,
size_t
len
)
override
;
virtual
void
onPacketRecv
(
RTC
::
T
cp
Connection
*
connection
,
const
uint8_t
*
data
,
size_t
len
)
override
;
/* Pure virtual methods inherited from RTC::I
CE
Server::Listener. */
/* Pure virtual methods inherited from RTC::I
ce
Server::Listener. */
public
:
virtual
void
onOutgoingS
TUNMessage
(
RTC
::
ICEServer
*
iceServer
,
RTC
::
STUN
Message
*
msg
,
RTC
::
TransportTuple
*
tuple
)
override
;
virtual
void
onI
CESelectedTuple
(
ICE
Server
*
iceServer
,
RTC
::
TransportTuple
*
tuple
)
override
;
virtual
void
onI
CEConnected
(
ICE
Server
*
iceServer
)
override
;
virtual
void
onI
CECompleted
(
ICE
Server
*
iceServer
)
override
;
virtual
void
onI
CEDisconnected
(
ICE
Server
*
iceServer
)
override
;
virtual
void
onOutgoingS
tunMessage
(
RTC
::
IceServer
*
iceServer
,
RTC
::
Stun
Message
*
msg
,
RTC
::
TransportTuple
*
tuple
)
override
;
virtual
void
onI
ceSelectedTuple
(
Ice
Server
*
iceServer
,
RTC
::
TransportTuple
*
tuple
)
override
;
virtual
void
onI
ceConnected
(
Ice
Server
*
iceServer
)
override
;
virtual
void
onI
ceCompleted
(
Ice
Server
*
iceServer
)
override
;
virtual
void
onI
ceDisconnected
(
Ice
Server
*
iceServer
)
override
;
/* Pure virtual methods inherited from RTC::D
TLS
Transport::Listener. */
/* Pure virtual methods inherited from RTC::D
tls
Transport::Listener. */
public
:
virtual
void
onD
TLSConnecting
(
DTLS
Transport
*
dtlsTransport
)
override
;
virtual
void
onD
TLSConnected
(
DTLSTransport
*
dtlsTransport
,
RTC
::
SRTP
Session
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
override
;
virtual
void
onD
TLSFailed
(
DTLS
Transport
*
dtlsTransport
)
override
;
virtual
void
onD
TLSClosed
(
DTLS
Transport
*
dtlsTransport
)
override
;
virtual
void
onOutgoingD
TLSData
(
RTC
::
DTLS
Transport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
virtual
void
onD
TLSApplicationData
(
RTC
::
DTLS
Transport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
virtual
void
onD
tlsConnecting
(
Dtls
Transport
*
dtlsTransport
)
override
;
virtual
void
onD
tlsConnected
(
DtlsTransport
*
dtlsTransport
,
RTC
::
Srtp
Session
::
Profile
srtp_profile
,
uint8_t
*
srtp_local_key
,
size_t
srtp_local_key_len
,
uint8_t
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
override
;
virtual
void
onD
tlsFailed
(
Dtls
Transport
*
dtlsTransport
)
override
;
virtual
void
onD
tlsClosed
(
Dtls
Transport
*
dtlsTransport
)
override
;
virtual
void
onOutgoingD
tlsData
(
RTC
::
Dtls
Transport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
virtual
void
onD
tlsApplicationData
(
RTC
::
Dtls
Transport
*
dtlsTransport
,
const
uint8_t
*
data
,
size_t
len
)
override
;
public
:
// Passed by argument.
...
...
@@ -96,10 +92,10 @@ namespace RTC
Listener
*
listener
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
// Allocated by this.
RTC
::
I
CE
Server
*
iceServer
=
nullptr
;
std
::
vector
<
RTC
::
U
DP
Socket
*>
udpSockets
;
std
::
vector
<
RTC
::
T
CP
Server
*>
tcpServers
;
RTC
::
D
TLS
Transport
*
dtlsTransport
=
nullptr
;
RTC
::
I
ce
Server
*
iceServer
=
nullptr
;
std
::
vector
<
RTC
::
U
dp
Socket
*>
udpSockets
;
std
::
vector
<
RTC
::
T
cp
Server
*>
tcpServers
;
RTC
::
D
tls
Transport
*
dtlsTransport
=
nullptr
;
// Others.
bool
allocated
=
false
;
// Others (ICE).
...
...
@@ -107,7 +103,7 @@ namespace RTC
RTC
::
TransportTuple
*
selectedTuple
=
nullptr
;
// Others (DTLS).
bool
remoteDtlsParametersGiven
=
false
;
RTC
::
D
TLSTransport
::
Role
dtlsLocalRole
=
RTC
::
DTLS
Transport
::
Role
::
AUTO
;
RTC
::
D
tlsTransport
::
Role
dtlsLocalRole
=
RTC
::
Dtls
Transport
::
Role
::
AUTO
;
};
}
...
...
worker/include/RTC/TransportTuple.h
浏览文件 @
e5ee62f1
...
...
@@ -2,8 +2,8 @@
#define MS_RTC_TRANSPORT_TUPLE_H
#include "common.h"
#include "RTC/U
DP
Socket.h"
#include "RTC/T
CP
Connection.h"
#include "RTC/U
dp
Socket.h"
#include "RTC/T
cp
Connection.h"
#include "Utils.h"
#include <json/json.h>
...
...
@@ -19,8 +19,8 @@ namespace RTC
};
public
:
TransportTuple
(
RTC
::
U
DP
Socket
*
udpSocket
,
const
struct
sockaddr
*
udpRemoteAddr
);
TransportTuple
(
RTC
::
T
CP
Connection
*
tcpConnection
);
TransportTuple
(
RTC
::
U
dp
Socket
*
udpSocket
,
const
struct
sockaddr
*
udpRemoteAddr
);
TransportTuple
(
RTC
::
T
cp
Connection
*
tcpConnection
);
void
Close
();
Json
::
Value
toJson
();
...
...
@@ -34,10 +34,10 @@ namespace RTC
private
:
// Passed by argument.
RTC
::
U
DP
Socket
*
udpSocket
=
nullptr
;
RTC
::
U
dp
Socket
*
udpSocket
=
nullptr
;
struct
sockaddr
*
udpRemoteAddr
=
nullptr
;
sockaddr_storage
udpRemoteAddrStorage
;
RTC
::
T
CP
Connection
*
tcpConnection
=
nullptr
;
RTC
::
T
cp
Connection
*
tcpConnection
=
nullptr
;
// Others.
Protocol
protocol
;
};
...
...
@@ -52,14 +52,14 @@ namespace RTC
}
inline
TransportTuple
::
TransportTuple
(
RTC
::
U
DP
Socket
*
udpSocket
,
const
struct
sockaddr
*
udpRemoteAddr
)
:
TransportTuple
::
TransportTuple
(
RTC
::
U
dp
Socket
*
udpSocket
,
const
struct
sockaddr
*
udpRemoteAddr
)
:
udpSocket
(
udpSocket
),
udpRemoteAddr
((
struct
sockaddr
*
)
udpRemoteAddr
),
protocol
(
Protocol
::
UDP
)
{}
inline
TransportTuple
::
TransportTuple
(
RTC
::
T
CP
Connection
*
tcpConnection
)
:
TransportTuple
::
TransportTuple
(
RTC
::
T
cp
Connection
*
tcpConnection
)
:
tcpConnection
(
tcpConnection
),
protocol
(
Protocol
::
TCP
)
{}
...
...
worker/include/RTC/U
DP
Socket.h
→
worker/include/RTC/U
dp
Socket.h
浏览文件 @
e5ee62f1
...
...
@@ -2,20 +2,20 @@
#define MS_RTC_UDP_SOCKET_H
#include "common.h"
#include "handles/U
DP
Socket.h"
#include "handles/U
dp
Socket.h"
#include <unordered_map>
#include <uv.h>
namespace
RTC
{
class
U
DP
Socket
:
public
::
U
DP
Socket
class
U
dp
Socket
:
public
::
U
dp
Socket
{
public
:
class
Listener
{
public
:
virtual
void
onPacketRecv
(
RTC
::
U
DP
Socket
*
socket
,
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
remote_addr
)
=
0
;
virtual
void
onPacketRecv
(
RTC
::
U
dp
Socket
*
socket
,
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
remote_addr
)
=
0
;
};
public
:
...
...
@@ -33,12 +33,12 @@ namespace RTC
static
std
::
unordered_map
<
uint16_t
,
bool
>
availableIPv6Ports
;
public
:
U
DP
Socket
(
Listener
*
listener
,
int
address_family
);
U
dp
Socket
(
Listener
*
listener
,
int
address_family
);
/* Pure virtual methods inherited from ::U
DP
Socket. */
/* Pure virtual methods inherited from ::U
dp
Socket. */
public
:
virtual
void
userOnU
DP
DatagramRecv
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
override
;
virtual
void
userOnU
DP
SocketClosed
()
override
;
virtual
void
userOnU
dp
DatagramRecv
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
override
;
virtual
void
userOnU
dp
SocketClosed
()
override
;
private
:
// Passed by argument.
...
...
worker/include/handles/T
CP
Connection.h
→
worker/include/handles/T
cp
Connection.h
浏览文件 @
e5ee62f1
...
...
@@ -5,27 +5,27 @@
#include <string>
#include <uv.h>
class
T
CP
Connection
class
T
cp
Connection
{
public
:
class
Listener
{
public
:
virtual
void
onT
CPConnectionClosed
(
TCP
Connection
*
connection
,
bool
is_closed_by_peer
)
=
0
;
virtual
void
onT
cpConnectionClosed
(
Tcp
Connection
*
connection
,
bool
is_closed_by_peer
)
=
0
;
};
public
:
/* Struct for the data field of uv_req_t when writing into the connection. */
struct
UvWriteData
{
T
CP
Connection
*
connection
;
T
cp
Connection
*
connection
;
uv_write_t
req
;
uint8_t
store
[
1
];
};
public
:
T
CP
Connection
(
size_t
bufferSize
);
virtual
~
T
CP
Connection
();
T
cp
Connection
(
size_t
bufferSize
);
virtual
~
T
cp
Connection
();
void
Close
();
virtual
void
Dump
();
...
...
@@ -56,7 +56,7 @@ public:
/* Pure virtual methods that must be implemented by the subclass. */
protected
:
virtual
void
userOnT
CP
ConnectionRead
()
=
0
;
virtual
void
userOnT
cp
ConnectionRead
()
=
0
;
private
:
// Passed by argument.
...
...
@@ -86,55 +86,55 @@ protected:
/* Inline methods. */
inline
bool
T
CP
Connection
::
IsClosing
()
bool
T
cp
Connection
::
IsClosing
()
{
return
this
->
isClosing
;
}
inline
uv_tcp_t
*
T
CP
Connection
::
GetUvHandle
()
uv_tcp_t
*
T
cp
Connection
::
GetUvHandle
()
{
return
this
->
uvHandle
;
}
inline
void
T
CP
Connection
::
Write
(
const
std
::
string
&
data
)
void
T
cp
Connection
::
Write
(
const
std
::
string
&
data
)
{
Write
((
const
uint8_t
*
)
data
.
c_str
(),
data
.
size
());
}
inline
const
struct
sockaddr
*
T
CP
Connection
::
GetLocalAddress
()
const
struct
sockaddr
*
T
cp
Connection
::
GetLocalAddress
()
{
return
(
const
struct
sockaddr
*
)
this
->
localAddr
;
}
inline
const
std
::
string
&
T
CP
Connection
::
GetLocalIP
()
const
std
::
string
&
T
cp
Connection
::
GetLocalIP
()
{
return
this
->
localIP
;
}
inline
uint16_t
T
CP
Connection
::
GetLocalPort
()
uint16_t
T
cp
Connection
::
GetLocalPort
()
{
return
this
->
localPort
;
}
inline
const
struct
sockaddr
*
T
CP
Connection
::
GetPeerAddress
()
const
struct
sockaddr
*
T
cp
Connection
::
GetPeerAddress
()
{
return
(
const
struct
sockaddr
*
)
&
this
->
peerAddr
;
}
inline
const
std
::
string
&
T
CP
Connection
::
GetPeerIP
()
const
std
::
string
&
T
cp
Connection
::
GetPeerIP
()
{
return
this
->
peerIP
;
}
inline
uint16_t
T
CP
Connection
::
GetPeerPort
()
uint16_t
T
cp
Connection
::
GetPeerPort
()
{
return
this
->
peerPort
;
}
...
...
worker/include/handles/T
CP
Server.h
→
worker/include/handles/T
cp
Server.h
浏览文件 @
e5ee62f1
...
...
@@ -2,20 +2,20 @@
#define MS_TCP_SERVER_H
#include "common.h"
#include "handles/T
CP
Connection.h"
#include "handles/T
cp
Connection.h"
#include <string>
#include <unordered_set>
#include <uv.h>
class
T
CPServer
:
public
TCP
Connection
::
Listener
class
T
cpServer
:
public
Tcp
Connection
::
Listener
{
public
:
T
CP
Server
(
const
std
::
string
&
ip
,
uint16_t
port
,
int
backlog
);
T
cp
Server
(
const
std
::
string
&
ip
,
uint16_t
port
,
int
backlog
);
/**
* uvHandle must be an already initialized and binded uv_tcp_t pointer.
*/
T
CP
Server
(
uv_tcp_t
*
uvHandle
,
int
backlog
);
virtual
~
T
CP
Server
();
T
cp
Server
(
uv_tcp_t
*
uvHandle
,
int
backlog
);
virtual
~
T
cp
Server
();
void
Close
();
virtual
void
Dump
();
...
...
@@ -30,25 +30,25 @@ private:
/* Pure virtual methods that must be implemented by the subclass. */
protected
:
virtual
void
userOnT
CPConnectionAlloc
(
TCP
Connection
**
connection
)
=
0
;
virtual
void
userOnNewT
CPConnection
(
TCP
Connection
*
connection
)
=
0
;
virtual
void
userOnT
CPConnectionClosed
(
TCP
Connection
*
connection
,
bool
is_closed_by_peer
)
=
0
;
virtual
void
userOnT
CP
ServerClosed
()
=
0
;
virtual
void
userOnT
cpConnectionAlloc
(
Tcp
Connection
**
connection
)
=
0
;
virtual
void
userOnNewT
cpConnection
(
Tcp
Connection
*
connection
)
=
0
;
virtual
void
userOnT
cpConnectionClosed
(
Tcp
Connection
*
connection
,
bool
is_closed_by_peer
)
=
0
;
virtual
void
userOnT
cp
ServerClosed
()
=
0
;
/* Callbacks fired by UV events. */
public
:
void
onUvConnection
(
int
status
);
void
onUvClosed
();
/* Methods inherited from T
CP
Connection::Listener. */
/* Methods inherited from T
cp
Connection::Listener. */
public
:
virtual
void
onT
CPConnectionClosed
(
TCP
Connection
*
connection
,
bool
is_closed_by_peer
);
virtual
void
onT
cpConnectionClosed
(
Tcp
Connection
*
connection
,
bool
is_closed_by_peer
);
private
:
// Allocated by this (may be passed by argument).
uv_tcp_t
*
uvHandle
=
nullptr
;
// Others.
std
::
unordered_set
<
T
CP
Connection
*>
connections
;
std
::
unordered_set
<
T
cp
Connection
*>
connections
;
bool
isClosing
=
false
;
protected
:
...
...
@@ -60,13 +60,13 @@ protected:
/* Inline methods. */
inline
bool
T
CP
Server
::
IsClosing
()
bool
T
cp
Server
::
IsClosing
()
{
return
this
->
isClosing
;
}
inline
size_t
T
CP
Server
::
GetNumConnections
()
size_t
T
cp
Server
::
GetNumConnections
()
{
return
this
->
connections
.
size
();
}
...
...
worker/include/handles/U
DP
Socket.h
→
worker/include/handles/U
dp
Socket.h
浏览文件 @
e5ee62f1
...
...
@@ -5,13 +5,13 @@
#include <string>
#include <uv.h>
class
U
DP
Socket
class
U
dp
Socket
{
public
:
/* Struct for the data field of uv_req_t when sending a datagram. */
struct
UvSendData
{
U
DP
Socket
*
socket
;
U
dp
Socket
*
socket
;
uv_udp_send_t
req
;
uint8_t
store
[
1
];
};
...
...
@@ -20,12 +20,12 @@ private:
static
uint8_t
readBuffer
[];
public
:
U
DP
Socket
(
const
std
::
string
&
ip
,
uint16_t
port
);
U
dp
Socket
(
const
std
::
string
&
ip
,
uint16_t
port
);
/**
* uvHandle must be an already initialized and binded uv_udp_t pointer.
*/
U
DP
Socket
(
uv_udp_t
*
uvHandle
);
virtual
~
U
DP
Socket
();
U
dp
Socket
(
uv_udp_t
*
uvHandle
);
virtual
~
U
dp
Socket
();
void
Close
();
virtual
void
Dump
();
...
...
@@ -49,8 +49,8 @@ public:
/* Pure virtual methods that must be implemented by the subclass. */
protected
:
virtual
void
userOnU
DP
DatagramRecv
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
=
0
;
virtual
void
userOnU
DP
SocketClosed
()
=
0
;
virtual
void
userOnU
dp
DatagramRecv
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
=
0
;
virtual
void
userOnU
dp
SocketClosed
()
=
0
;
private
:
// Allocated by this (may be passed by argument).
...
...
@@ -67,31 +67,31 @@ protected:
/* Inline methods. */
inline
void
U
DP
Socket
::
Send
(
const
std
::
string
&
data
,
const
struct
sockaddr
*
addr
)
void
U
dp
Socket
::
Send
(
const
std
::
string
&
data
,
const
struct
sockaddr
*
addr
)
{
Send
((
const
uint8_t
*
)
data
.
c_str
(),
data
.
size
(),
addr
);
}
inline
void
U
DP
Socket
::
Send
(
const
std
::
string
&
data
,
const
std
::
string
&
ip
,
uint16_t
port
)
void
U
dp
Socket
::
Send
(
const
std
::
string
&
data
,
const
std
::
string
&
ip
,
uint16_t
port
)
{
Send
((
const
uint8_t
*
)
data
.
c_str
(),
data
.
size
(),
ip
,
port
);
}
inline
const
struct
sockaddr
*
U
DP
Socket
::
GetLocalAddress
()
const
struct
sockaddr
*
U
dp
Socket
::
GetLocalAddress
()
{
return
(
const
struct
sockaddr
*
)
&
this
->
localAddr
;
}
inline
const
std
::
string
&
U
DP
Socket
::
GetLocalIP
()
const
std
::
string
&
U
dp
Socket
::
GetLocalIP
()
{
return
this
->
localIP
;
}
inline
uint16_t
U
DP
Socket
::
GetLocalPort
()
uint16_t
U
dp
Socket
::
GetLocalPort
()
{
return
this
->
localPort
;
}
...
...
worker/src/RTC/D
TLS
Transport.cpp
→
worker/src/RTC/D
tls
Transport.cpp
浏览文件 @
e5ee62f1
差异被折叠。
点击展开。
worker/src/RTC/IceCandidate.cpp
浏览文件 @
e5ee62f1
...
...
@@ -6,7 +6,7 @@ namespace RTC
{
/* Instance methods. */
IceCandidate
::
IceCandidate
(
RTC
::
U
DP
Socket
*
udpSocket
,
uint32_t
priority
)
:
IceCandidate
::
IceCandidate
(
RTC
::
U
dp
Socket
*
udpSocket
,
uint32_t
priority
)
:
foundation
(
"udpcandidate"
),
priority
(
priority
),
ip
(
udpSocket
->
GetLocalIP
()),
...
...
@@ -15,7 +15,7 @@ namespace RTC
type
(
CandidateType
::
HOST
)
{}
IceCandidate
::
IceCandidate
(
RTC
::
T
CP
Server
*
tcpServer
,
uint32_t
priority
)
:
IceCandidate
::
IceCandidate
(
RTC
::
T
cp
Server
*
tcpServer
,
uint32_t
priority
)
:
foundation
(
"tcpcandidate"
),
priority
(
priority
),
ip
(
tcpServer
->
GetLocalIP
()),
...
...
worker/src/RTC/I
CE
Server.cpp
→
worker/src/RTC/I
ce
Server.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::I
CE
Server"
#define MS_CLASS "RTC::I
ce
Server"
#include "RTC/I
CE
Server.h"
#include "RTC/I
ce
Server.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
I
CEServer
::
ICE
Server
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
password
)
:
I
ceServer
::
Ice
Server
(
Listener
*
listener
,
const
std
::
string
&
usernameFragment
,
const
std
::
string
password
)
:
listener
(
listener
),
usernameFragment
(
usernameFragment
),
password
(
password
)
...
...
@@ -17,28 +17,28 @@ namespace RTC
MS_DEBUG
(
"[usernameFragment:%s, password:%s]"
,
this
->
usernameFragment
.
c_str
(),
this
->
password
.
c_str
());
}
void
I
CE
Server
::
Close
()
void
I
ce
Server
::
Close
()
{
MS_TRACE
();
delete
this
;
}
void
I
CEServer
::
ProcessSTUNMessage
(
RTC
::
STUN
Message
*
msg
,
RTC
::
TransportTuple
*
tuple
)
void
I
ceServer
::
ProcessStunMessage
(
RTC
::
Stun
Message
*
msg
,
RTC
::
TransportTuple
*
tuple
)
{
MS_TRACE
();
// Must be a Binding method.
if
(
msg
->
GetMethod
()
!=
RTC
::
S
TUN
Message
::
Method
::
Binding
)
if
(
msg
->
GetMethod
()
!=
RTC
::
S
tun
Message
::
Method
::
Binding
)
{
if
(
msg
->
GetClass
()
==
RTC
::
S
TUN
Message
::
Class
::
Request
)
if
(
msg
->
GetClass
()
==
RTC
::
S
tun
Message
::
Class
::
Request
)
{
MS_DEBUG
(
"unknown method %#.3x in STUN Request => 400"
,
(
unsigned
int
)
msg
->
GetMethod
());
// Reply 400.
RTC
::
S
TUN
Message
*
response
=
msg
->
CreateErrorResponse
(
400
);
RTC
::
S
tun
Message
*
response
=
msg
->
CreateErrorResponse
(
400
);
response
->
Serialize
();
this
->
listener
->
onOutgoingS
TUN
Message
(
this
,
response
,
tuple
);
this
->
listener
->
onOutgoingS
tun
Message
(
this
,
response
,
tuple
);
delete
response
;
}
else
...
...
@@ -50,16 +50,16 @@ namespace RTC
}
// Must use FINGERPRINT (optional for ICE STUN indications).
if
(
!
msg
->
HasFingerprint
()
&&
msg
->
GetClass
()
!=
RTC
::
S
TUN
Message
::
Class
::
Indication
)
if
(
!
msg
->
HasFingerprint
()
&&
msg
->
GetClass
()
!=
RTC
::
S
tun
Message
::
Class
::
Indication
)
{
if
(
msg
->
GetClass
()
==
RTC
::
S
TUN
Message
::
Class
::
Request
)
if
(
msg
->
GetClass
()
==
RTC
::
S
tun
Message
::
Class
::
Request
)
{
MS_DEBUG
(
"STUN Binding Request without FINGERPRINT => 400"
);
// Reply 400.
RTC
::
S
TUN
Message
*
response
=
msg
->
CreateErrorResponse
(
400
);
RTC
::
S
tun
Message
*
response
=
msg
->
CreateErrorResponse
(
400
);
response
->
Serialize
();
this
->
listener
->
onOutgoingS
TUN
Message
(
this
,
response
,
tuple
);
this
->
listener
->
onOutgoingS
tun
Message
(
this
,
response
,
tuple
);
delete
response
;
}
else
...
...
@@ -72,7 +72,7 @@ namespace RTC
switch
(
msg
->
GetClass
())
{
case
RTC
:
:
S
TUN
Message
::
Class
::
Request
:
case
RTC
:
:
S
tun
Message
::
Class
::
Request
:
{
// USERNAME, MESSAGE-INTEGRITY and PRIORITY are required.
if
(
!
msg
->
HasMessageIntegrity
()
||
!
msg
->
GetPriority
()
||
msg
->
GetUsername
().
empty
())
...
...
@@ -80,9 +80,9 @@ namespace RTC
MS_DEBUG
(
"mising required attributes in STUN Binding Request => 400"
);
// Reply 400.
RTC
::
S
TUN
Message
*
response
=
msg
->
CreateErrorResponse
(
400
);
RTC
::
S
tun
Message
*
response
=
msg
->
CreateErrorResponse
(
400
);
response
->
Serialize
();
this
->
listener
->
onOutgoingS
TUN
Message
(
this
,
response
,
tuple
);
this
->
listener
->
onOutgoingS
tun
Message
(
this
,
response
,
tuple
);
delete
response
;
return
;
...
...
@@ -91,30 +91,30 @@ namespace RTC
// Check authentication.
switch
(
msg
->
CheckAuthentication
(
this
->
usernameFragment
,
this
->
password
))
{
case
RTC
:
:
S
TUN
Message
::
Authentication
::
OK
:
case
RTC
:
:
S
tun
Message
::
Authentication
::
OK
:
break
;
case
RTC
:
:
S
TUN
Message
::
Authentication
::
Unauthorized
:
case
RTC
:
:
S
tun
Message
::
Authentication
::
Unauthorized
:
{
MS_DEBUG
(
"wrong authentication in STUN Binding Request => 401"
);
// Reply 401.
RTC
::
S
TUN
Message
*
response
=
msg
->
CreateErrorResponse
(
401
);
RTC
::
S
tun
Message
*
response
=
msg
->
CreateErrorResponse
(
401
);
response
->
Serialize
();
this
->
listener
->
onOutgoingS
TUN
Message
(
this
,
response
,
tuple
);
this
->
listener
->
onOutgoingS
tun
Message
(
this
,
response
,
tuple
);
delete
response
;
return
;
}
case
RTC
:
:
S
TUN
Message
::
Authentication
::
BadRequest
:
case
RTC
:
:
S
tun
Message
::
Authentication
::
BadRequest
:
{
MS_DEBUG
(
"cannot check authentication in STUN Binding Request => 400"
);
// Reply 400.
RTC
::
S
TUN
Message
*
response
=
msg
->
CreateErrorResponse
(
400
);
RTC
::
S
tun
Message
*
response
=
msg
->
CreateErrorResponse
(
400
);
response
->
Serialize
();
this
->
listener
->
onOutgoingS
TUN
Message
(
this
,
response
,
tuple
);
this
->
listener
->
onOutgoingS
tun
Message
(
this
,
response
,
tuple
);
delete
response
;
return
;
...
...
@@ -127,9 +127,9 @@ namespace RTC
MS_DEBUG
(
"peer indicates ICE-CONTROLLED in STUN Binding Request => 487"
);
// Reply 487 (Role Conflict).
RTC
::
S
TUN
Message
*
response
=
msg
->
CreateErrorResponse
(
487
);
RTC
::
S
tun
Message
*
response
=
msg
->
CreateErrorResponse
(
487
);
response
->
Serialize
();
this
->
listener
->
onOutgoingS
TUN
Message
(
this
,
response
,
tuple
);
this
->
listener
->
onOutgoingS
tun
Message
(
this
,
response
,
tuple
);
delete
response
;
return
;
...
...
@@ -138,7 +138,7 @@ namespace RTC
MS_DEBUG
(
"processing STUN Binding Request [Priority:%"
PRIu32
", UseCandidate:%s]"
,
(
uint32_t
)
msg
->
GetPriority
(),
msg
->
HasUseCandidate
()
?
"true"
:
"false"
);
// Create a success response.
RTC
::
S
TUN
Message
*
response
=
msg
->
CreateSuccessResponse
();
RTC
::
S
tun
Message
*
response
=
msg
->
CreateSuccessResponse
();
// Add XOR-MAPPED-ADDRESS.
response
->
SetXorMappedAddress
(
tuple
->
GetRemoteAddress
());
...
...
@@ -148,7 +148,7 @@ namespace RTC
// Send back.
response
->
Serialize
();
this
->
listener
->
onOutgoingS
TUN
Message
(
this
,
response
,
tuple
);
this
->
listener
->
onOutgoingS
tun
Message
(
this
,
response
,
tuple
);
delete
response
;
// Handle the tuple.
...
...
@@ -157,21 +157,21 @@ namespace RTC
break
;
}
case
RTC
:
:
S
TUN
Message
::
Class
::
Indication
:
case
RTC
:
:
S
tun
Message
::
Class
::
Indication
:
{
MS_DEBUG
(
"STUN Binding Indication processed"
);
break
;
}
case
RTC
:
:
S
TUN
Message
::
Class
::
SuccessResponse
:
case
RTC
:
:
S
tun
Message
::
Class
::
SuccessResponse
:
{
MS_DEBUG
(
"STUN Binding Success Response processed"
);
break
;
}
case
RTC
:
:
S
TUN
Message
::
Class
::
ErrorResponse
:
case
RTC
:
:
S
tun
Message
::
Class
::
ErrorResponse
:
{
MS_DEBUG
(
"STUN Binding Error Response processed"
);
...
...
@@ -180,7 +180,7 @@ namespace RTC
}
}
bool
I
CE
Server
::
IsValidTuple
(
RTC
::
TransportTuple
*
tuple
)
bool
I
ce
Server
::
IsValidTuple
(
RTC
::
TransportTuple
*
tuple
)
{
MS_TRACE
();
...
...
@@ -191,7 +191,7 @@ namespace RTC
}
void
I
CE
Server
::
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
)
void
I
ce
Server
::
RemoveTuple
(
RTC
::
TransportTuple
*
tuple
)
{
auto
it
=
this
->
tuples
.
begin
();
RTC
::
TransportTuple
*
removed_tuple
=
nullptr
;
...
...
@@ -237,12 +237,12 @@ namespace RTC
this
->
state
=
IceState
::
DISCONNECTED
;
// Notify the listener.
this
->
listener
->
onI
CE
Disconnected
(
this
);
this
->
listener
->
onI
ce
Disconnected
(
this
);
}
}
}
void
I
CE
Server
::
ForceSelectedTuple
(
RTC
::
TransportTuple
*
tuple
)
void
I
ce
Server
::
ForceSelectedTuple
(
RTC
::
TransportTuple
*
tuple
)
{
MS_TRACE
();
...
...
@@ -256,7 +256,7 @@ namespace RTC
SetSelectedTuple
(
stored_tuple
);
}
void
I
CE
Server
::
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
has_use_candidate
)
void
I
ce
Server
::
HandleTuple
(
RTC
::
TransportTuple
*
tuple
,
bool
has_use_candidate
)
{
MS_TRACE
();
...
...
@@ -284,7 +284,7 @@ namespace RTC
this
->
state
=
IceState
::
CONNECTED
;
// Notify the listener.
this
->
listener
->
onI
CE
Connected
(
this
);
this
->
listener
->
onI
ce
Connected
(
this
);
}
else
{
...
...
@@ -300,7 +300,7 @@ namespace RTC
this
->
state
=
IceState
::
COMPLETED
;
// Notify the listener.
this
->
listener
->
onI
CE
Completed
(
this
);
this
->
listener
->
onI
ce
Completed
(
this
);
}
break
;
...
...
@@ -328,7 +328,7 @@ namespace RTC
this
->
state
=
IceState
::
CONNECTED
;
// Notify the listener.
this
->
listener
->
onI
CE
Connected
(
this
);
this
->
listener
->
onI
ce
Connected
(
this
);
}
else
{
...
...
@@ -344,7 +344,7 @@ namespace RTC
this
->
state
=
IceState
::
COMPLETED
;
// Notify the listener.
this
->
listener
->
onI
CE
Completed
(
this
);
this
->
listener
->
onI
ce
Completed
(
this
);
}
break
;
...
...
@@ -381,7 +381,7 @@ namespace RTC
this
->
state
=
IceState
::
COMPLETED
;
// Notify the listener.
this
->
listener
->
onI
CE
Completed
(
this
);
this
->
listener
->
onI
ce
Completed
(
this
);
}
break
;
...
...
@@ -419,7 +419,7 @@ namespace RTC
}
inline
RTC
::
TransportTuple
*
I
CE
Server
::
AddTuple
(
RTC
::
TransportTuple
*
tuple
)
RTC
::
TransportTuple
*
I
ce
Server
::
AddTuple
(
RTC
::
TransportTuple
*
tuple
)
{
MS_TRACE
();
...
...
@@ -438,7 +438,7 @@ namespace RTC
}
inline
RTC
::
TransportTuple
*
I
CE
Server
::
HasTuple
(
RTC
::
TransportTuple
*
tuple
)
RTC
::
TransportTuple
*
I
ce
Server
::
HasTuple
(
RTC
::
TransportTuple
*
tuple
)
{
MS_TRACE
();
...
...
@@ -464,7 +464,7 @@ namespace RTC
}
inline
void
I
CE
Server
::
SetSelectedTuple
(
RTC
::
TransportTuple
*
stored_tuple
)
void
I
ce
Server
::
SetSelectedTuple
(
RTC
::
TransportTuple
*
stored_tuple
)
{
MS_TRACE
();
...
...
@@ -475,6 +475,6 @@ namespace RTC
this
->
selectedTuple
=
stored_tuple
;
// Notify the listener.
this
->
listener
->
onI
CE
SelectedTuple
(
this
,
this
->
selectedTuple
);
this
->
listener
->
onI
ce
SelectedTuple
(
this
,
this
->
selectedTuple
);
}
}
worker/src/RTC/Peer.cpp
浏览文件 @
e5ee62f1
...
...
@@ -236,7 +236,7 @@ namespace RTC
MS_DEBUG
(
"RtpReceiver created [rtpReceiverId:%"
PRIu32
"]"
,
rtpReceiverId
);
// RTC::Transport inherits from RTC::RtpListener, but the API of
// RTC:RtpReceiver requires RT
P
::RtpListener.
// RTC:RtpReceiver requires RT
C
::RtpListener.
RTC
::
RtpListener
*
rtpListener
=
transport
;
// Set the RtpListener.
...
...
worker/src/RTC/R
TCP
Packet.cpp
→
worker/src/RTC/R
tcp
Packet.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::R
TCP
Packet"
#define MS_CLASS "RTC::R
tcp
Packet"
#include "RTC/R
TCP
Packet.h"
#include "RTC/R
tcp
Packet.h"
#include "Logger.h"
namespace
RTC
{
/* Class methods. */
R
TCPPacket
*
RTCP
Packet
::
Parse
(
const
uint8_t
*
data
,
size_t
len
)
R
tcpPacket
*
Rtcp
Packet
::
Parse
(
const
uint8_t
*
data
,
size_t
len
)
{
MS_TRACE
();
if
(
!
R
TCPPacket
::
IsRTCP
(
data
,
len
))
if
(
!
R
tcpPacket
::
IsRtcp
(
data
,
len
))
return
nullptr
;
// TODO: Do it.
...
...
@@ -19,12 +19,12 @@ namespace RTC
// Get the header.
CommonHeader
*
header
=
(
CommonHeader
*
)
data
;
return
new
R
TCP
Packet
(
header
,
data
,
len
);
return
new
R
tcp
Packet
(
header
,
data
,
len
);
}
/* Instance methods. */
R
TCPPacket
::
RTCP
Packet
(
CommonHeader
*
header
,
const
uint8_t
*
raw
,
size_t
length
)
:
R
tcpPacket
::
Rtcp
Packet
(
CommonHeader
*
header
,
const
uint8_t
*
raw
,
size_t
length
)
:
header
(
header
),
raw
((
uint8_t
*
)
raw
),
length
(
length
)
...
...
@@ -32,7 +32,7 @@ namespace RTC
MS_TRACE
();
}
R
TCPPacket
::~
RTCP
Packet
()
R
tcpPacket
::~
Rtcp
Packet
()
{
MS_TRACE
();
}
...
...
worker/src/RTC/RtpListener.cpp
浏览文件 @
e5ee62f1
...
...
@@ -108,7 +108,7 @@ namespace RTC
}
}
RTC
::
RtpReceiver
*
RtpListener
::
GetRtpReceiver
(
RTC
::
R
TP
Packet
*
packet
)
RTC
::
RtpReceiver
*
RtpListener
::
GetRtpReceiver
(
RTC
::
R
tp
Packet
*
packet
)
{
MS_TRACE
();
...
...
@@ -116,7 +116,7 @@ namespace RTC
// Check the SSRC table.
auto
it
=
this
->
ssrcTable
.
find
(
packet
->
GetS
SRC
());
auto
it
=
this
->
ssrcTable
.
find
(
packet
->
GetS
src
());
if
(
it
==
this
->
ssrcTable
.
end
())
{
...
...
worker/src/RTC/R
TP
Packet.cpp
→
worker/src/RTC/R
tp
Packet.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::R
TP
Packet"
#define MS_CLASS "RTC::R
tp
Packet"
#include "RTC/R
TP
Packet.h"
#include "RTC/R
tp
Packet.h"
#include "Utils.h"
#include "Logger.h"
#include <cstring> // std::memcmp(), std::memcpy()
...
...
@@ -9,11 +9,11 @@ namespace RTC
{
/* Class methods. */
R
TPPacket
*
RTP
Packet
::
Parse
(
const
uint8_t
*
data
,
size_t
len
)
R
tpPacket
*
Rtp
Packet
::
Parse
(
const
uint8_t
*
data
,
size_t
len
)
{
MS_TRACE
();
if
(
!
R
TPPacket
::
IsRTP
(
data
,
len
))
if
(
!
R
tpPacket
::
IsRtp
(
data
,
len
))
return
nullptr
;
// Get the header.
...
...
@@ -109,12 +109,12 @@ namespace RTC
MS_ASSERT
(
len
==
sizeof
(
Header
)
+
csrc_list_size
+
(
extensionHeader
?
4
+
extension_value_size
:
0
)
+
payloadLength
+
(
size_t
)
payloadPadding
,
"packet's computed length does not match received length"
);
return
new
R
TP
Packet
(
header
,
extensionHeader
,
payload
,
payloadLength
,
payloadPadding
,
data
,
len
);
return
new
R
tp
Packet
(
header
,
extensionHeader
,
payload
,
payloadLength
,
payloadPadding
,
data
,
len
);
}
/* Instance methods. */
R
TPPacket
::
RTP
Packet
(
Header
*
header
,
ExtensionHeader
*
extensionHeader
,
const
uint8_t
*
payload
,
size_t
payloadLength
,
uint8_t
payloadPadding
,
const
uint8_t
*
raw
,
size_t
length
)
:
R
tpPacket
::
Rtp
Packet
(
Header
*
header
,
ExtensionHeader
*
extensionHeader
,
const
uint8_t
*
payload
,
size_t
payloadLength
,
uint8_t
payloadPadding
,
const
uint8_t
*
raw
,
size_t
length
)
:
header
(
header
),
extensionHeader
(
extensionHeader
),
payload
((
uint8_t
*
)
payload
),
...
...
@@ -129,7 +129,7 @@ namespace RTC
this
->
csrcList
=
(
uint8_t
*
)
raw
+
sizeof
(
Header
);
}
R
TPPacket
::~
RTP
Packet
()
R
tpPacket
::~
Rtp
Packet
()
{
MS_TRACE
();
...
...
@@ -137,14 +137,14 @@ namespace RTC
delete
this
->
raw
;
}
void
R
TP
Packet
::
Dump
()
void
R
tp
Packet
::
Dump
()
{
MS_TRACE
();
if
(
!
Logger
::
HasDebugLevel
())
return
;
MS_DEBUG
(
"<R
TP
Packet>"
);
MS_DEBUG
(
"<R
tp
Packet>"
);
MS_DEBUG
(
"padding: %s"
,
this
->
header
->
padding
?
"true"
:
"false"
);
MS_DEBUG
(
"extension: %s"
,
HasExtensionHeader
()
?
"true"
:
"false"
);
if
(
HasExtensionHeader
())
...
...
@@ -157,12 +157,12 @@ namespace RTC
MS_DEBUG
(
"payload type: %"
PRIu8
,
GetPayloadType
());
MS_DEBUG
(
"sequence number: %"
PRIu16
,
GetSequenceNumber
());
MS_DEBUG
(
"timestamp: %"
PRIu32
,
GetTimestamp
());
MS_DEBUG
(
"SSRC: %"
PRIu32
,
GetS
SRC
());
MS_DEBUG
(
"SSRC: %"
PRIu32
,
GetS
src
());
MS_DEBUG
(
"payload size: %zu bytes"
,
GetPayloadLength
());
MS_DEBUG
(
"</R
TP
Packet>"
);
MS_DEBUG
(
"</R
tp
Packet>"
);
}
void
R
TP
Packet
::
Serialize
()
void
R
tp
Packet
::
Serialize
()
{
MS_TRACE
();
...
...
worker/src/RTC/RtpParameters.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::RtpParameters"
#include "RTC/RtpParameters.h"
// #include "Utils.h" // TODO: let's see
#include "MediaSoupError.h"
#include "Logger.h"
...
...
worker/src/RTC/S
RTP
Session.cpp
→
worker/src/RTC/S
rtp
Session.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::S
RTP
Session"
#define MS_CLASS "RTC::S
rtp
Session"
#include "RTC/S
RTP
Session.h"
#include "RTC/S
rtp
Session.h"
#include "MediaSoupError.h"
#include "Logger.h"
#include <cstring> // std::memset(), std::memcpy()
...
...
@@ -12,24 +12,24 @@ namespace RTC
{
/* Class variables. */
uint8_t
S
RTP
Session
::
encryptBuffer
[
MS_ENCRYPT_BUFFER_SIZE
];
uint8_t
S
rtp
Session
::
encryptBuffer
[
MS_ENCRYPT_BUFFER_SIZE
];
/* Class methods. */
void
S
RTP
Session
::
ClassInit
()
void
S
rtp
Session
::
ClassInit
()
{
/* Set libsrtp event handler. */
// srtp_err_status_t err;
// err = srtp_install_event_handler((srtp_event_handler_func_t*)onS
RTP
Event);
// err = srtp_install_event_handler((srtp_event_handler_func_t*)onS
rtp
Event);
// if (DepLibSRTP::IsError(err))
// {
// MS_THROW_ERROR("srtp_install_event_handler() failed: %s", DepLibSRTP::GetErrorString(err));
// }
}
// void S
RTPSession::onSRTP
Event(srtp_event_data_t* data)
// void S
rtpSession::onSrtp
Event(srtp_event_data_t* data)
// {
// MS_TRACE();
...
...
@@ -57,7 +57,7 @@ namespace RTC
/* Instance methods. */
S
RTPSession
::
SRTP
Session
(
Type
type
,
Profile
profile
,
uint8_t
*
key
,
size_t
key_len
)
S
rtpSession
::
Srtp
Session
(
Type
type
,
Profile
profile
,
uint8_t
*
key
,
size_t
key_len
)
{
MS_TRACE
();
...
...
@@ -92,7 +92,7 @@ namespace RTC
policy
.
ssrc
.
type
=
ssrc_any_outbound
;
break
;
default
:
MS_ABORT
(
"unknown S
RTP
Session::Type"
);
MS_ABORT
(
"unknown S
rtp
Session::Type"
);
}
policy
.
ssrc
.
value
=
0
;
policy
.
key
=
key
;
...
...
@@ -108,7 +108,7 @@ namespace RTC
}
}
S
RTPSession
::~
SRTP
Session
()
S
rtpSession
::~
Srtp
Session
()
{
MS_TRACE
();
...
...
@@ -126,7 +126,7 @@ namespace RTC
// TODO: It must not memcpy it but instead the provided packet must already be
// allocated into a buffer.
bool
S
RTPSession
::
EncryptRTP
(
const
uint8_t
**
data
,
size_t
*
len
)
bool
S
rtpSession
::
EncryptRtp
(
const
uint8_t
**
data
,
size_t
*
len
)
{
MS_TRACE
();
...
...
@@ -139,9 +139,9 @@ namespace RTC
return
false
;
}
std
::
memcpy
(
S
RTP
Session
::
encryptBuffer
,
*
data
,
*
len
);
std
::
memcpy
(
S
rtp
Session
::
encryptBuffer
,
*
data
,
*
len
);
this
->
lastError
=
srtp_protect
(
this
->
session
,
(
void
*
)
S
RTP
Session
::
encryptBuffer
,
(
int
*
)
len
);
this
->
lastError
=
srtp_protect
(
this
->
session
,
(
void
*
)
S
rtp
Session
::
encryptBuffer
,
(
int
*
)
len
);
if
(
DepLibSRTP
::
IsError
(
this
->
lastError
))
{
MS_DEBUG
(
"srtp_protect() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
this
->
lastError
));
...
...
@@ -150,12 +150,12 @@ namespace RTC
}
// Update the given data pointer.
*
data
=
(
const
uint8_t
*
)
S
RTP
Session
::
encryptBuffer
;
*
data
=
(
const
uint8_t
*
)
S
rtp
Session
::
encryptBuffer
;
return
true
;
}
bool
S
RTPSession
::
DecryptSRTP
(
const
uint8_t
*
data
,
size_t
*
len
)
bool
S
rtpSession
::
DecryptSrtp
(
const
uint8_t
*
data
,
size_t
*
len
)
{
MS_TRACE
();
...
...
@@ -170,7 +170,7 @@ namespace RTC
return
true
;
}
bool
S
RTPSession
::
EncryptRTCP
(
const
uint8_t
**
data
,
size_t
*
len
)
bool
S
rtpSession
::
EncryptRtcp
(
const
uint8_t
**
data
,
size_t
*
len
)
{
MS_TRACE
();
...
...
@@ -183,9 +183,9 @@ namespace RTC
return
false
;
}
std
::
memcpy
(
S
RTP
Session
::
encryptBuffer
,
*
data
,
*
len
);
std
::
memcpy
(
S
rtp
Session
::
encryptBuffer
,
*
data
,
*
len
);
this
->
lastError
=
srtp_protect_rtcp
(
this
->
session
,
(
void
*
)
S
RTP
Session
::
encryptBuffer
,
(
int
*
)
len
);
this
->
lastError
=
srtp_protect_rtcp
(
this
->
session
,
(
void
*
)
S
rtp
Session
::
encryptBuffer
,
(
int
*
)
len
);
if
(
DepLibSRTP
::
IsError
(
this
->
lastError
))
{
MS_DEBUG
(
"srtp_protect_rtcp() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
this
->
lastError
));
...
...
@@ -194,12 +194,12 @@ namespace RTC
}
// Update the given data pointer.
*
data
=
(
const
uint8_t
*
)
S
RTP
Session
::
encryptBuffer
;
*
data
=
(
const
uint8_t
*
)
S
rtp
Session
::
encryptBuffer
;
return
true
;
}
bool
S
RTPSession
::
DecryptSRTCP
(
const
uint8_t
*
data
,
size_t
*
len
)
bool
S
rtpSession
::
DecryptSrtcp
(
const
uint8_t
*
data
,
size_t
*
len
)
{
MS_TRACE
();
...
...
@@ -214,7 +214,7 @@ namespace RTC
return
true
;
}
void
S
RTP
Session
::
Close
()
void
S
rtp
Session
::
Close
()
{
MS_TRACE
();
...
...
worker/src/RTC/S
TUN
Message.cpp
→
worker/src/RTC/S
tun
Message.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::S
TUN
Message"
#define MS_CLASS "RTC::S
tun
Message"
#include "RTC/S
TUN
Message.h"
#include "RTC/S
tun
Message.h"
#include "Utils.h"
#include "Logger.h"
#include <cstdio> // std::snprintf()
...
...
@@ -10,15 +10,15 @@ namespace RTC
{
/* Class variables. */
const
uint8_t
S
TUN
Message
::
magicCookie
[]
=
{
0x21
,
0x12
,
0xA4
,
0x42
};
const
uint8_t
S
tun
Message
::
magicCookie
[]
=
{
0x21
,
0x12
,
0xA4
,
0x42
};
/* Class methods. */
S
TUNMessage
*
STUN
Message
::
Parse
(
const
uint8_t
*
data
,
size_t
len
)
S
tunMessage
*
Stun
Message
::
Parse
(
const
uint8_t
*
data
,
size_t
len
)
{
MS_TRACE
();
if
(
!
S
TUNMessage
::
IsSTUN
(
data
,
len
))
if
(
!
S
tunMessage
::
IsStun
(
data
,
len
))
return
nullptr
;
/*
...
...
@@ -60,8 +60,8 @@ namespace RTC
// Get STUN class.
uint16_t
msg_class
=
((
data
[
0
]
&
0x01
)
<<
1
)
|
((
data
[
1
]
&
0x10
)
>>
4
);
// Create a new S
TUN
Message (data + 8 points to the received TransactionID field).
S
TUNMessage
*
msg
=
new
STUN
Message
((
Class
)
msg_class
,
(
Method
)
msg_method
,
data
+
8
,
data
,
len
);
// Create a new S
tun
Message (data + 8 points to the received TransactionID field).
S
tunMessage
*
msg
=
new
Stun
Message
((
Class
)
msg_class
,
(
Method
)
msg_method
,
data
+
8
,
data
,
len
);
/*
STUN Attributes
...
...
@@ -201,7 +201,7 @@ namespace RTC
/* Instance methods. */
S
TUNMessage
::
STUN
Message
(
Class
klass
,
Method
method
,
const
uint8_t
*
transactionId
,
const
uint8_t
*
raw
,
size_t
length
)
:
S
tunMessage
::
Stun
Message
(
Class
klass
,
Method
method
,
const
uint8_t
*
transactionId
,
const
uint8_t
*
raw
,
size_t
length
)
:
klass
(
klass
),
method
(
method
),
transactionId
(
transactionId
),
...
...
@@ -211,7 +211,7 @@ namespace RTC
MS_TRACE
();
}
S
TUNMessage
::~
STUN
Message
()
S
tunMessage
::~
Stun
Message
()
{
MS_TRACE
();
...
...
@@ -219,14 +219,14 @@ namespace RTC
delete
this
->
raw
;
}
void
S
TUN
Message
::
Dump
()
void
S
tun
Message
::
Dump
()
{
MS_TRACE
();
if
(
!
Logger
::
HasDebugLevel
())
return
;
MS_DEBUG
(
"<S
TUN
Message>"
);
MS_DEBUG
(
"<S
tun
Message>"
);
std
::
string
klass
;
switch
(
this
->
klass
)
{
...
...
@@ -279,10 +279,10 @@ namespace RTC
}
if
(
this
->
hasFingerprint
)
MS_DEBUG
(
"fingerprint"
);
MS_DEBUG
(
"</S
TUN
Message>"
);
MS_DEBUG
(
"</S
tun
Message>"
);
}
S
TUNMessage
::
Authentication
STUN
Message
::
CheckAuthentication
(
const
std
::
string
&
local_username
,
const
std
::
string
&
local_password
)
S
tunMessage
::
Authentication
Stun
Message
::
CheckAuthentication
(
const
std
::
string
&
local_username
,
const
std
::
string
&
local_password
)
{
MS_TRACE
();
...
...
@@ -341,29 +341,29 @@ namespace RTC
return
result
;
}
S
TUNMessage
*
STUN
Message
::
CreateSuccessResponse
()
S
tunMessage
*
Stun
Message
::
CreateSuccessResponse
()
{
MS_TRACE
();
MS_ASSERT
(
this
->
klass
==
Class
::
Request
,
"attempt to create a success response for a non Request STUN message"
);
return
new
S
TUN
Message
(
Class
::
SuccessResponse
,
this
->
method
,
this
->
transactionId
,
nullptr
,
0
);
return
new
S
tun
Message
(
Class
::
SuccessResponse
,
this
->
method
,
this
->
transactionId
,
nullptr
,
0
);
}
S
TUNMessage
*
STUN
Message
::
CreateErrorResponse
(
uint16_t
errorCode
)
S
tunMessage
*
Stun
Message
::
CreateErrorResponse
(
uint16_t
errorCode
)
{
MS_TRACE
();
MS_ASSERT
(
this
->
klass
==
Class
::
Request
,
"attempt to create an error response for a non Request STUN message"
);
S
TUNMessage
*
response
=
new
STUN
Message
(
Class
::
ErrorResponse
,
this
->
method
,
this
->
transactionId
,
nullptr
,
0
);
S
tunMessage
*
response
=
new
Stun
Message
(
Class
::
ErrorResponse
,
this
->
method
,
this
->
transactionId
,
nullptr
,
0
);
response
->
SetErrorCode
(
errorCode
);
return
response
;
}
void
S
TUN
Message
::
Authenticate
(
const
std
::
string
&
password
)
void
S
tun
Message
::
Authenticate
(
const
std
::
string
&
password
)
{
// Just for Request, Indication and SuccessResponse messages.
if
(
this
->
klass
==
Class
::
ErrorResponse
)
...
...
@@ -376,7 +376,7 @@ namespace RTC
this
->
password
=
password
;
}
void
S
TUN
Message
::
Serialize
()
void
S
tun
Message
::
Serialize
()
{
MS_TRACE
();
...
...
@@ -389,7 +389,7 @@ namespace RTC
// Some useful variables.
uint16_t
username_padded_len
=
0
;
uint16_t
xor_mapped_address_padded_len
=
0
;
bool
add_xor_mapped_address
=
(
this
->
xorMappedAddress
&&
this
->
method
==
S
TUN
Message
::
Method
::
Binding
&&
this
->
klass
==
Class
::
SuccessResponse
);
bool
add_xor_mapped_address
=
(
this
->
xorMappedAddress
&&
this
->
method
==
S
tun
Message
::
Method
::
Binding
&&
this
->
klass
==
Class
::
SuccessResponse
);
bool
add_error_code
=
(
this
->
errorCode
&&
this
->
klass
==
Class
::
ErrorResponse
);
bool
add_message_integrity
=
(
this
->
klass
!=
Class
::
ErrorResponse
&&
!
this
->
password
.
empty
());
bool
add_fingerprint
=
true
;
// Do always.
...
...
@@ -459,7 +459,7 @@ namespace RTC
Utils
::
Byte
::
Set2Bytes
(
this
->
raw
,
2
,
(
uint16_t
)
this
->
length
-
20
);
// Set magic cookie.
std
::
memcpy
(
this
->
raw
+
4
,
S
TUN
Message
::
magicCookie
,
4
);
std
::
memcpy
(
this
->
raw
+
4
,
S
tun
Message
::
magicCookie
,
4
);
// Set TransactionId field.
std
::
memcpy
(
this
->
raw
+
8
,
this
->
transactionId
,
12
);
...
...
@@ -529,14 +529,14 @@ namespace RTC
attr_value
[
1
]
=
0x01
;
// Set port and XOR it.
std
::
memcpy
(
attr_value
+
2
,
&
((
const
sockaddr_in
*
)(
this
->
xorMappedAddress
))
->
sin_port
,
2
);
attr_value
[
2
]
^=
S
TUN
Message
::
magicCookie
[
0
];
attr_value
[
3
]
^=
S
TUN
Message
::
magicCookie
[
1
];
attr_value
[
2
]
^=
S
tun
Message
::
magicCookie
[
0
];
attr_value
[
3
]
^=
S
tun
Message
::
magicCookie
[
1
];
// Set address and XOR it.
std
::
memcpy
(
attr_value
+
4
,
&
((
const
sockaddr_in
*
)
this
->
xorMappedAddress
)
->
sin_addr
.
s_addr
,
4
);
attr_value
[
4
]
^=
S
TUN
Message
::
magicCookie
[
0
];
attr_value
[
5
]
^=
S
TUN
Message
::
magicCookie
[
1
];
attr_value
[
6
]
^=
S
TUN
Message
::
magicCookie
[
2
];
attr_value
[
7
]
^=
S
TUN
Message
::
magicCookie
[
3
];
attr_value
[
4
]
^=
S
tun
Message
::
magicCookie
[
0
];
attr_value
[
5
]
^=
S
tun
Message
::
magicCookie
[
1
];
attr_value
[
6
]
^=
S
tun
Message
::
magicCookie
[
2
];
attr_value
[
7
]
^=
S
tun
Message
::
magicCookie
[
3
];
pos
+=
4
+
8
;
break
;
...
...
@@ -549,14 +549,14 @@ namespace RTC
attr_value
[
1
]
=
0x02
;
// Set port and XOR it.
std
::
memcpy
(
attr_value
+
2
,
&
((
const
sockaddr_in6
*
)(
this
->
xorMappedAddress
))
->
sin6_port
,
2
);
attr_value
[
2
]
^=
S
TUN
Message
::
magicCookie
[
0
];
attr_value
[
3
]
^=
S
TUN
Message
::
magicCookie
[
1
];
attr_value
[
2
]
^=
S
tun
Message
::
magicCookie
[
0
];
attr_value
[
3
]
^=
S
tun
Message
::
magicCookie
[
1
];
// Set address and XOR it.
std
::
memcpy
(
attr_value
+
4
,
&
((
const
sockaddr_in6
*
)
this
->
xorMappedAddress
)
->
sin6_addr
.
s6_addr
,
16
);
attr_value
[
4
]
^=
S
TUN
Message
::
magicCookie
[
0
];
attr_value
[
5
]
^=
S
TUN
Message
::
magicCookie
[
1
];
attr_value
[
6
]
^=
S
TUN
Message
::
magicCookie
[
2
];
attr_value
[
7
]
^=
S
TUN
Message
::
magicCookie
[
3
];
attr_value
[
4
]
^=
S
tun
Message
::
magicCookie
[
0
];
attr_value
[
5
]
^=
S
tun
Message
::
magicCookie
[
1
];
attr_value
[
6
]
^=
S
tun
Message
::
magicCookie
[
2
];
attr_value
[
7
]
^=
S
tun
Message
::
magicCookie
[
3
];
attr_value
[
8
]
^=
this
->
transactionId
[
0
];
attr_value
[
9
]
^=
this
->
transactionId
[
1
];
attr_value
[
10
]
^=
this
->
transactionId
[
2
];
...
...
worker/src/RTC/T
CP
Connection.cpp
→
worker/src/RTC/T
cp
Connection.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::T
CP
Connection"
#define MS_CLASS "RTC::T
cp
Connection"
#include "RTC/T
CP
Connection.h"
#include "RTC/T
cp
Connection.h"
#include "Utils.h"
#include "Logger.h"
#include <cstring> // std::memmove()
...
...
@@ -9,19 +9,19 @@ namespace RTC
{
/* Instance methods. */
T
CPConnection
::
TCP
Connection
(
Listener
*
listener
,
size_t
bufferSize
)
:
::
T
CP
Connection
(
bufferSize
),
T
cpConnection
::
Tcp
Connection
(
Listener
*
listener
,
size_t
bufferSize
)
:
::
T
cp
Connection
(
bufferSize
),
listener
(
listener
)
{
MS_TRACE
();
}
T
CPConnection
::~
TCP
Connection
()
T
cpConnection
::~
Tcp
Connection
()
{
MS_TRACE
();
}
void
T
CPConnection
::
userOnTCP
ConnectionRead
()
void
T
cpConnection
::
userOnTcp
ConnectionRead
()
{
MS_TRACE
();
...
...
@@ -139,7 +139,7 @@ namespace RTC
}
}
void
T
CP
Connection
::
Send
(
const
uint8_t
*
data
,
size_t
len
)
void
T
cp
Connection
::
Send
(
const
uint8_t
*
data
,
size_t
len
)
{
MS_TRACE
();
...
...
worker/src/RTC/T
CP
Server.cpp
→
worker/src/RTC/T
cp
Server.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::T
CP
Server"
#define MS_CLASS "RTC::T
cp
Server"
#include "RTC/TCPServer.h"
#include "RTC/STUNMessage.h"
#include "RTC/RTPPacket.h"
#include "RTC/TcpServer.h"
#include "Settings.h"
#include "Utils.h"
#include "DepLibUV.h"
...
...
@@ -25,16 +23,16 @@ namespace RTC
{
/* Class variables. */
struct
sockaddr_storage
T
CP
Server
::
sockaddrStorageIPv4
;
struct
sockaddr_storage
T
CP
Server
::
sockaddrStorageIPv6
;
uint16_t
T
CP
Server
::
minPort
;
uint16_t
T
CP
Server
::
maxPort
;
std
::
unordered_map
<
uint16_t
,
bool
>
T
CP
Server
::
availableIPv4Ports
;
std
::
unordered_map
<
uint16_t
,
bool
>
T
CP
Server
::
availableIPv6Ports
;
struct
sockaddr_storage
T
cp
Server
::
sockaddrStorageIPv4
;
struct
sockaddr_storage
T
cp
Server
::
sockaddrStorageIPv6
;
uint16_t
T
cp
Server
::
minPort
;
uint16_t
T
cp
Server
::
maxPort
;
std
::
unordered_map
<
uint16_t
,
bool
>
T
cp
Server
::
availableIPv4Ports
;
std
::
unordered_map
<
uint16_t
,
bool
>
T
cp
Server
::
availableIPv6Ports
;
/* Class methods. */
void
T
CP
Server
::
ClassInit
()
void
T
cp
Server
::
ClassInit
()
{
MS_TRACE
();
...
...
@@ -42,31 +40,31 @@ namespace RTC
if
(
!
Settings
::
configuration
.
rtcListenIPv4
.
empty
())
{
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcListenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
T
CP
Server
::
sockaddrStorageIPv4
);
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcListenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
T
cp
Server
::
sockaddrStorageIPv4
);
if
(
err
)
MS_ABORT
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
}
if
(
!
Settings
::
configuration
.
rtcListenIPv6
.
empty
())
{
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcListenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
T
CP
Server
::
sockaddrStorageIPv6
);
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcListenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
T
cp
Server
::
sockaddrStorageIPv6
);
if
(
err
)
MS_ABORT
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
}
T
CP
Server
::
minPort
=
Settings
::
configuration
.
rtcMinPort
;
T
CP
Server
::
maxPort
=
Settings
::
configuration
.
rtcMaxPort
;
T
cp
Server
::
minPort
=
Settings
::
configuration
.
rtcMinPort
;
T
cp
Server
::
maxPort
=
Settings
::
configuration
.
rtcMaxPort
;
uint16_t
i
=
RTC
::
T
CP
Server
::
minPort
;
uint16_t
i
=
RTC
::
T
cp
Server
::
minPort
;
do
{
RTC
::
T
CP
Server
::
availableIPv4Ports
[
i
]
=
true
;
RTC
::
T
CP
Server
::
availableIPv6Ports
[
i
]
=
true
;
RTC
::
T
cp
Server
::
availableIPv4Ports
[
i
]
=
true
;
RTC
::
T
cp
Server
::
availableIPv6Ports
[
i
]
=
true
;
}
while
(
i
++
!=
RTC
::
T
CP
Server
::
maxPort
);
while
(
i
++
!=
RTC
::
T
cp
Server
::
maxPort
);
}
uv_tcp_t
*
T
CP
Server
::
GetRandomPort
(
int
address_family
)
uv_tcp_t
*
T
cp
Server
::
GetRandomPort
(
int
address_family
)
{
MS_TRACE
();
...
...
@@ -89,14 +87,14 @@ namespace RTC
switch
(
address_family
)
{
case
AF_INET
:
available_ports
=
&
RTC
::
T
CP
Server
::
availableIPv4Ports
;
bind_addr
=
RTC
::
T
CP
Server
::
sockaddrStorageIPv4
;
available_ports
=
&
RTC
::
T
cp
Server
::
availableIPv4Ports
;
bind_addr
=
RTC
::
T
cp
Server
::
sockaddrStorageIPv4
;
listen_ip
=
Settings
::
configuration
.
rtcListenIPv4
.
c_str
();
break
;
case
AF_INET6
:
available_ports
=
&
RTC
::
T
CP
Server
::
availableIPv6Ports
;
bind_addr
=
RTC
::
T
CP
Server
::
sockaddrStorageIPv6
;
available_ports
=
&
RTC
::
T
cp
Server
::
availableIPv6Ports
;
bind_addr
=
RTC
::
T
cp
Server
::
sockaddrStorageIPv6
;
listen_ip
=
Settings
::
configuration
.
rtcListenIPv6
.
c_str
();
// Don't also bind into IPv4 when listening in IPv6.
flags
|=
UV_TCP_IPV6ONLY
;
...
...
@@ -108,7 +106,7 @@ namespace RTC
}
// Choose a random first port to start from.
initial_port
=
(
uint16_t
)
Utils
::
Crypto
::
GetRandomUInt
((
uint32_t
)
RTC
::
T
CPServer
::
minPort
,
(
uint32_t
)
RTC
::
TCP
Server
::
maxPort
);
initial_port
=
(
uint16_t
)
Utils
::
Crypto
::
GetRandomUInt
((
uint32_t
)
RTC
::
T
cpServer
::
minPort
,
(
uint32_t
)
RTC
::
Tcp
Server
::
maxPort
);
iterating_port
=
initial_port
;
...
...
@@ -119,10 +117,10 @@ namespace RTC
attempt
++
;
// Increase the iterate port) within the range of RTC TCP ports.
if
(
iterating_port
<
RTC
::
T
CP
Server
::
maxPort
)
if
(
iterating_port
<
RTC
::
T
cp
Server
::
maxPort
)
iterating_port
+=
1
;
else
iterating_port
=
RTC
::
T
CP
Server
::
minPort
;
iterating_port
=
RTC
::
T
cp
Server
::
minPort
;
// Check whether the chosen port is available.
if
(
!
(
*
available_ports
)[
iterating_port
])
...
...
@@ -204,26 +202,26 @@ namespace RTC
/* Instance methods. */
T
CPServer
::
TCPServer
(
Listener
*
listener
,
RTC
::
TCP
Connection
::
Listener
*
connListener
,
int
address_family
)
:
T
cpServer
::
TcpServer
(
Listener
*
listener
,
RTC
::
Tcp
Connection
::
Listener
*
connListener
,
int
address_family
)
:
// Provide the parent class constructor with a UDP uv handle.
// NOTE: This may throw a MediaSoupError exception if the address family is not available
// or there are no available ports.
::
T
CPServer
::
TCP
Server
(
GetRandomPort
(
address_family
),
256
),
::
T
cpServer
::
Tcp
Server
(
GetRandomPort
(
address_family
),
256
),
listener
(
listener
),
connListener
(
connListener
)
{
MS_TRACE
();
}
void
T
CPServer
::
userOnTCPConnectionAlloc
(
::
TCP
Connection
**
connection
)
void
T
cpServer
::
userOnTcpConnectionAlloc
(
::
Tcp
Connection
**
connection
)
{
MS_TRACE
();
// Allocate a new RTC::T
CPConnection for the TCP
Server to handle it.
*
connection
=
new
RTC
::
T
CP
Connection
(
this
->
connListener
,
65536
);
// Allocate a new RTC::T
cpConnection for the Tcp
Server to handle it.
*
connection
=
new
RTC
::
T
cp
Connection
(
this
->
connListener
,
65536
);
}
void
T
CPServer
::
userOnNewTCPConnection
(
::
TCP
Connection
*
connection
)
void
T
cpServer
::
userOnNewTcpConnection
(
::
Tcp
Connection
*
connection
)
{
MS_TRACE
();
...
...
@@ -232,7 +230,7 @@ namespace RTC
connection
->
Close
();
}
void
T
CPServer
::
userOnTCPConnectionClosed
(
::
TCP
Connection
*
connection
,
bool
is_closed_by_peer
)
void
T
cpServer
::
userOnTcpConnectionClosed
(
::
Tcp
Connection
*
connection
,
bool
is_closed_by_peer
)
{
MS_TRACE
();
...
...
@@ -240,17 +238,17 @@ namespace RTC
// NOTE: Don't do it if closing (since at this point the listener is already freed).
// At the end, this is just called if the connection was remotely closed.
if
(
!
IsClosing
())
this
->
listener
->
onR
TCTCPConnectionClosed
(
this
,
static_cast
<
RTC
::
TCP
Connection
*>
(
connection
),
is_closed_by_peer
);
this
->
listener
->
onR
tcTcpConnectionClosed
(
this
,
static_cast
<
RTC
::
Tcp
Connection
*>
(
connection
),
is_closed_by_peer
);
}
void
T
CPServer
::
userOnTCP
ServerClosed
()
void
T
cpServer
::
userOnTcp
ServerClosed
()
{
MS_TRACE
();
// Mark the port as available again.
if
(
this
->
localAddr
.
ss_family
==
AF_INET
)
RTC
::
T
CP
Server
::
availableIPv4Ports
[
this
->
localPort
]
=
true
;
RTC
::
T
cp
Server
::
availableIPv4Ports
[
this
->
localPort
]
=
true
;
else
if
(
this
->
localAddr
.
ss_family
==
AF_INET6
)
RTC
::
T
CP
Server
::
availableIPv6Ports
[
this
->
localPort
]
=
true
;
RTC
::
T
cp
Server
::
availableIPv6Ports
[
this
->
localPort
]
=
true
;
}
}
worker/src/RTC/Transport.cpp
浏览文件 @
e5ee62f1
差异被折叠。
点击展开。
worker/src/RTC/U
DP
Socket.cpp
→
worker/src/RTC/U
dp
Socket.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "RTC::U
DP
Socket"
#define MS_CLASS "RTC::U
dp
Socket"
#include "RTC/U
DP
Socket.h"
#include "RTC/U
dp
Socket.h"
#include "Settings.h"
#include "Utils.h"
#include "DepLibUV.h"
...
...
@@ -22,16 +22,16 @@ namespace RTC
{
/* Class variables. */
struct
sockaddr_storage
U
DP
Socket
::
sockaddrStorageIPv4
;
struct
sockaddr_storage
U
DP
Socket
::
sockaddrStorageIPv6
;
uint16_t
U
DP
Socket
::
minPort
;
uint16_t
U
DP
Socket
::
maxPort
;
std
::
unordered_map
<
uint16_t
,
bool
>
U
DP
Socket
::
availableIPv4Ports
;
std
::
unordered_map
<
uint16_t
,
bool
>
U
DP
Socket
::
availableIPv6Ports
;
struct
sockaddr_storage
U
dp
Socket
::
sockaddrStorageIPv4
;
struct
sockaddr_storage
U
dp
Socket
::
sockaddrStorageIPv6
;
uint16_t
U
dp
Socket
::
minPort
;
uint16_t
U
dp
Socket
::
maxPort
;
std
::
unordered_map
<
uint16_t
,
bool
>
U
dp
Socket
::
availableIPv4Ports
;
std
::
unordered_map
<
uint16_t
,
bool
>
U
dp
Socket
::
availableIPv6Ports
;
/* Class methods. */
void
U
DP
Socket
::
ClassInit
()
void
U
dp
Socket
::
ClassInit
()
{
MS_TRACE
();
...
...
@@ -39,31 +39,31 @@ namespace RTC
if
(
Settings
::
configuration
.
hasIPv4
)
{
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcListenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
U
DP
Socket
::
sockaddrStorageIPv4
);
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcListenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
U
dp
Socket
::
sockaddrStorageIPv4
);
if
(
err
)
MS_ABORT
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
}
if
(
Settings
::
configuration
.
hasIPv6
)
{
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcListenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
U
DP
Socket
::
sockaddrStorageIPv6
);
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcListenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
U
dp
Socket
::
sockaddrStorageIPv6
);
if
(
err
)
MS_ABORT
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
}
U
DP
Socket
::
minPort
=
Settings
::
configuration
.
rtcMinPort
;
U
DP
Socket
::
maxPort
=
Settings
::
configuration
.
rtcMaxPort
;
U
dp
Socket
::
minPort
=
Settings
::
configuration
.
rtcMinPort
;
U
dp
Socket
::
maxPort
=
Settings
::
configuration
.
rtcMaxPort
;
uint16_t
i
=
RTC
::
U
DP
Socket
::
minPort
;
uint16_t
i
=
RTC
::
U
dp
Socket
::
minPort
;
do
{
RTC
::
U
DP
Socket
::
availableIPv4Ports
[
i
]
=
true
;
RTC
::
U
DP
Socket
::
availableIPv6Ports
[
i
]
=
true
;
RTC
::
U
dp
Socket
::
availableIPv4Ports
[
i
]
=
true
;
RTC
::
U
dp
Socket
::
availableIPv6Ports
[
i
]
=
true
;
}
while
(
i
++
!=
RTC
::
U
DP
Socket
::
maxPort
);
while
(
i
++
!=
RTC
::
U
dp
Socket
::
maxPort
);
}
uv_udp_t
*
U
DP
Socket
::
GetRandomPort
(
int
address_family
)
uv_udp_t
*
U
dp
Socket
::
GetRandomPort
(
int
address_family
)
{
MS_TRACE
();
...
...
@@ -86,14 +86,14 @@ namespace RTC
switch
(
address_family
)
{
case
AF_INET
:
available_ports
=
&
RTC
::
U
DP
Socket
::
availableIPv4Ports
;
bind_addr
=
RTC
::
U
DP
Socket
::
sockaddrStorageIPv4
;
available_ports
=
&
RTC
::
U
dp
Socket
::
availableIPv4Ports
;
bind_addr
=
RTC
::
U
dp
Socket
::
sockaddrStorageIPv4
;
listen_ip
=
Settings
::
configuration
.
rtcListenIPv4
.
c_str
();
break
;
case
AF_INET6
:
available_ports
=
&
RTC
::
U
DP
Socket
::
availableIPv6Ports
;
bind_addr
=
RTC
::
U
DP
Socket
::
sockaddrStorageIPv6
;
available_ports
=
&
RTC
::
U
dp
Socket
::
availableIPv6Ports
;
bind_addr
=
RTC
::
U
dp
Socket
::
sockaddrStorageIPv6
;
listen_ip
=
Settings
::
configuration
.
rtcListenIPv6
.
c_str
();
// Don't also bind into IPv4 when listening in IPv6.
flags
|=
UV_UDP_IPV6ONLY
;
...
...
@@ -105,7 +105,7 @@ namespace RTC
}
// Choose a random port to start from.
initial_port
=
(
uint16_t
)
Utils
::
Crypto
::
GetRandomUInt
((
uint32_t
)
RTC
::
U
DPSocket
::
minPort
,
(
uint32_t
)
RTC
::
UDP
Socket
::
maxPort
);
initial_port
=
(
uint16_t
)
Utils
::
Crypto
::
GetRandomUInt
((
uint32_t
)
RTC
::
U
dpSocket
::
minPort
,
(
uint32_t
)
RTC
::
Udp
Socket
::
maxPort
);
iterating_port
=
initial_port
;
...
...
@@ -116,10 +116,10 @@ namespace RTC
attempt
++
;
// Increase the iterate port within the range of RTC UDP ports.
if
(
iterating_port
<
RTC
::
U
DP
Socket
::
maxPort
)
if
(
iterating_port
<
RTC
::
U
dp
Socket
::
maxPort
)
iterating_port
++
;
else
iterating_port
=
RTC
::
U
DP
Socket
::
minPort
;
iterating_port
=
RTC
::
U
dp
Socket
::
minPort
;
// Check whether the chosen port is available.
if
(
!
(
*
available_ports
)[
iterating_port
])
...
...
@@ -200,17 +200,17 @@ namespace RTC
/* Instance methods. */
U
DPSocket
::
UDP
Socket
(
Listener
*
listener
,
int
address_family
)
:
U
dpSocket
::
Udp
Socket
(
Listener
*
listener
,
int
address_family
)
:
// Provide the parent class constructor with a UDP uv handle.
// NOTE: This may throw a MediaSoupError exception if the address family is not available
// or there are no available ports.
::
U
DPSocket
::
UDP
Socket
(
GetRandomPort
(
address_family
)),
::
U
dpSocket
::
Udp
Socket
(
GetRandomPort
(
address_family
)),
listener
(
listener
)
{
MS_TRACE
();
}
void
U
DPSocket
::
userOnUDP
DatagramRecv
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
void
U
dpSocket
::
userOnUdp
DatagramRecv
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
{
MS_TRACE
();
...
...
@@ -236,14 +236,14 @@ namespace RTC
this
->
listener
->
onPacketRecv
(
this
,
data
,
len
,
addr
);
}
void
U
DPSocket
::
userOnUDP
SocketClosed
()
void
U
dpSocket
::
userOnUdp
SocketClosed
()
{
MS_TRACE
();
// Mark the port as available again.
if
(
this
->
localAddr
.
ss_family
==
AF_INET
)
RTC
::
U
DP
Socket
::
availableIPv4Ports
[
this
->
localPort
]
=
true
;
RTC
::
U
dp
Socket
::
availableIPv4Ports
[
this
->
localPort
]
=
true
;
else
if
(
this
->
localAddr
.
ss_family
==
AF_INET6
)
RTC
::
U
DP
Socket
::
availableIPv6Ports
[
this
->
localPort
]
=
true
;
RTC
::
U
dp
Socket
::
availableIPv6Ports
[
this
->
localPort
]
=
true
;
}
}
worker/src/handles/T
CP
Connection.cpp
→
worker/src/handles/T
cp
Connection.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "T
CP
Connection"
#define MS_CLASS "T
cp
Connection"
#include "handles/T
CP
Connection.h"
#include "handles/T
cp
Connection.h"
#include "Utils.h"
#include "DepLibUV.h"
#include "MediaSoupError.h"
...
...
@@ -13,25 +13,25 @@
static
inline
void
on_alloc
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
static_cast
<
T
CP
Connection
*>
(
handle
->
data
)
->
onUvReadAlloc
(
suggested_size
,
buf
);
static_cast
<
T
cp
Connection
*>
(
handle
->
data
)
->
onUvReadAlloc
(
suggested_size
,
buf
);
}
static
inline
void
on_read
(
uv_stream_t
*
handle
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
static_cast
<
T
CP
Connection
*>
(
handle
->
data
)
->
onUvRead
(
nread
,
buf
);
static_cast
<
T
cp
Connection
*>
(
handle
->
data
)
->
onUvRead
(
nread
,
buf
);
}
static
inline
void
on_write
(
uv_write_t
*
req
,
int
status
)
{
T
CPConnection
::
UvWriteData
*
write_data
=
static_cast
<
TCP
Connection
::
UvWriteData
*>
(
req
->
data
);
T
CP
Connection
*
connection
=
write_data
->
connection
;
T
cpConnection
::
UvWriteData
*
write_data
=
static_cast
<
Tcp
Connection
::
UvWriteData
*>
(
req
->
data
);
T
cp
Connection
*
connection
=
write_data
->
connection
;
// Delete the UvWriteData struct (which includes the uv_req_t and the store char[]).
std
::
free
(
write_data
);
// Just notify the T
CP
Connection when error.
// Just notify the T
cp
Connection when error.
if
(
status
)
connection
->
onUvWriteError
(
status
);
}
...
...
@@ -39,18 +39,18 @@ void on_write(uv_write_t* req, int status)
static
inline
void
on_shutdown
(
uv_shutdown_t
*
req
,
int
status
)
{
static_cast
<
T
CP
Connection
*>
(
req
->
data
)
->
onUvShutdown
(
req
,
status
);
static_cast
<
T
cp
Connection
*>
(
req
->
data
)
->
onUvShutdown
(
req
,
status
);
}
static
inline
void
on_close
(
uv_handle_t
*
handle
)
{
static_cast
<
T
CP
Connection
*>
(
handle
->
data
)
->
onUvClosed
();
static_cast
<
T
cp
Connection
*>
(
handle
->
data
)
->
onUvClosed
();
}
/* Instance methods. */
T
CPConnection
::
TCP
Connection
(
size_t
bufferSize
)
:
T
cpConnection
::
Tcp
Connection
(
size_t
bufferSize
)
:
bufferSize
(
bufferSize
)
{
MS_TRACE
();
...
...
@@ -61,7 +61,7 @@ TCPConnection::TCPConnection(size_t bufferSize) :
// NOTE: Don't allocate the buffer here. Instead wait for the first uv_alloc_cb().
}
T
CPConnection
::~
TCP
Connection
()
T
cpConnection
::~
Tcp
Connection
()
{
MS_TRACE
();
...
...
@@ -71,7 +71,7 @@ TCPConnection::~TCPConnection()
delete
[]
this
->
buffer
;
}
void
T
CP
Connection
::
Setup
(
Listener
*
listener
,
struct
sockaddr_storage
*
localAddr
,
const
std
::
string
&
localIP
,
uint16_t
localPort
)
void
T
cp
Connection
::
Setup
(
Listener
*
listener
,
struct
sockaddr_storage
*
localAddr
,
const
std
::
string
&
localIP
,
uint16_t
localPort
)
{
MS_TRACE
();
...
...
@@ -95,7 +95,7 @@ void TCPConnection::Setup(Listener* listener, struct sockaddr_storage* localAddr
this
->
localPort
=
localPort
;
}
void
T
CP
Connection
::
Close
()
void
T
cp
Connection
::
Close
()
{
MS_TRACE
();
...
...
@@ -129,15 +129,15 @@ void TCPConnection::Close()
}
}
void
T
CP
Connection
::
Dump
()
void
T
cp
Connection
::
Dump
()
{
MS_DEBUG
(
"[T
CP
, local:%s :%"
PRIu16
", remote:%s :%"
PRIu16
", status:%s]"
,
MS_DEBUG
(
"[T
cp
, local:%s :%"
PRIu16
", remote:%s :%"
PRIu16
", status:%s]"
,
this
->
localIP
.
c_str
(),
(
uint16_t
)
this
->
localPort
,
this
->
peerIP
.
c_str
(),
(
uint16_t
)
this
->
peerPort
,
(
!
this
->
isClosing
)
?
"open"
:
"closed"
);
}
void
T
CP
Connection
::
Start
()
void
T
cp
Connection
::
Start
()
{
MS_TRACE
();
...
...
@@ -155,7 +155,7 @@ void TCPConnection::Start()
MS_THROW_ERROR
(
"error setting peer IP and port"
);
}
void
T
CP
Connection
::
Write
(
const
uint8_t
*
data
,
size_t
len
)
void
T
cp
Connection
::
Write
(
const
uint8_t
*
data
,
size_t
len
)
{
MS_TRACE
();
...
...
@@ -213,7 +213,7 @@ void TCPConnection::Write(const uint8_t* data, size_t len)
MS_ABORT
(
"uv_write() failed: %s"
,
uv_strerror
(
err
));
}
void
T
CP
Connection
::
Write
(
const
uint8_t
*
data1
,
size_t
len1
,
const
uint8_t
*
data2
,
size_t
len2
)
void
T
cp
Connection
::
Write
(
const
uint8_t
*
data1
,
size_t
len1
,
const
uint8_t
*
data2
,
size_t
len2
)
{
MS_TRACE
();
...
...
@@ -283,7 +283,7 @@ void TCPConnection::Write(const uint8_t* data1, size_t len1, const uint8_t* data
MS_ABORT
(
"uv_write() failed: %s"
,
uv_strerror
(
err
));
}
bool
T
CP
Connection
::
SetPeerAddress
()
bool
T
cp
Connection
::
SetPeerAddress
()
{
MS_TRACE
();
...
...
@@ -305,7 +305,7 @@ bool TCPConnection::SetPeerAddress()
}
inline
void
T
CP
Connection
::
onUvReadAlloc
(
size_t
suggested_size
,
uv_buf_t
*
buf
)
void
T
cp
Connection
::
onUvReadAlloc
(
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
MS_TRACE
();
...
...
@@ -329,7 +329,7 @@ void TCPConnection::onUvReadAlloc(size_t suggested_size, uv_buf_t* buf)
}
inline
void
T
CP
Connection
::
onUvRead
(
ssize_t
nread
,
const
uv_buf_t
*
buf
)
void
T
cp
Connection
::
onUvRead
(
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
MS_TRACE
();
...
...
@@ -346,7 +346,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf)
this
->
bufferDataLen
+=
(
size_t
)
nread
;
// Notify the subclass.
userOnT
CP
ConnectionRead
();
userOnT
cp
ConnectionRead
();
}
// Client disconneted.
else
if
(
nread
==
UV_EOF
||
nread
==
UV_ECONNRESET
)
...
...
@@ -371,7 +371,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf)
}
inline
void
T
CP
Connection
::
onUvWriteError
(
int
error
)
void
T
cp
Connection
::
onUvWriteError
(
int
error
)
{
MS_TRACE
();
...
...
@@ -393,7 +393,7 @@ void TCPConnection::onUvWriteError(int error)
}
inline
void
T
CP
Connection
::
onUvShutdown
(
uv_shutdown_t
*
req
,
int
status
)
void
T
cp
Connection
::
onUvShutdown
(
uv_shutdown_t
*
req
,
int
status
)
{
MS_TRACE
();
...
...
@@ -409,12 +409,12 @@ void TCPConnection::onUvShutdown(uv_shutdown_t* req, int status)
}
inline
void
T
CP
Connection
::
onUvClosed
()
void
T
cp
Connection
::
onUvClosed
()
{
MS_TRACE
();
// Notify the listener.
this
->
listener
->
onT
CP
ConnectionClosed
(
this
,
this
->
isClosedByPeer
);
this
->
listener
->
onT
cp
ConnectionClosed
(
this
,
this
->
isClosedByPeer
);
// And delete this.
delete
this
;
...
...
worker/src/handles/T
CP
Server.cpp
→
worker/src/handles/T
cp
Server.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "T
CP
Server"
#define MS_CLASS "T
cp
Server"
#include "handles/T
CP
Server.h"
#include "handles/T
cp
Server.h"
#include "Utils.h"
#include "DepLibUV.h"
#include "MediaSoupError.h"
...
...
@@ -11,13 +11,13 @@
static
inline
void
on_connection
(
uv_stream_t
*
handle
,
int
status
)
{
static_cast
<
T
CP
Server
*>
(
handle
->
data
)
->
onUvConnection
(
status
);
static_cast
<
T
cp
Server
*>
(
handle
->
data
)
->
onUvConnection
(
status
);
}
static
inline
void
on_close
(
uv_handle_t
*
handle
)
{
static_cast
<
T
CP
Server
*>
(
handle
->
data
)
->
onUvClosed
();
static_cast
<
T
cp
Server
*>
(
handle
->
data
)
->
onUvClosed
();
}
static
inline
...
...
@@ -28,7 +28,7 @@ void on_error_close(uv_handle_t* handle)
/* Instance methods. */
T
CPServer
::
TCP
Server
(
const
std
::
string
&
ip
,
uint16_t
port
,
int
backlog
)
T
cpServer
::
Tcp
Server
(
const
std
::
string
&
ip
,
uint16_t
port
,
int
backlog
)
{
MS_TRACE
();
...
...
@@ -92,7 +92,7 @@ TCPServer::TCPServer(const std::string &ip, uint16_t port, int backlog)
}
}
T
CPServer
::
TCP
Server
(
uv_tcp_t
*
uvHandle
,
int
backlog
)
:
T
cpServer
::
Tcp
Server
(
uv_tcp_t
*
uvHandle
,
int
backlog
)
:
uvHandle
(
uvHandle
)
{
MS_TRACE
();
...
...
@@ -116,7 +116,7 @@ TCPServer::TCPServer(uv_tcp_t* uvHandle, int backlog) :
}
}
T
CPServer
::~
TCP
Server
()
T
cpServer
::~
Tcp
Server
()
{
MS_TRACE
();
...
...
@@ -124,7 +124,7 @@ TCPServer::~TCPServer()
delete
this
->
uvHandle
;
}
void
T
CP
Server
::
Close
()
void
T
cp
Server
::
Close
()
{
MS_TRACE
();
...
...
@@ -145,13 +145,13 @@ void TCPServer::Close()
for
(
auto
it
=
this
->
connections
.
begin
();
it
!=
this
->
connections
.
end
();
++
it
)
{
T
CP
Connection
*
connection
=
*
it
;
T
cp
Connection
*
connection
=
*
it
;
connection
->
Close
();
}
}
}
void
T
CP
Server
::
Dump
()
void
T
cp
Server
::
Dump
()
{
MS_DEBUG
(
"[TCP, local:%s :%"
PRIu16
", status:%s, connections:%zu]"
,
this
->
localIP
.
c_str
(),
(
uint16_t
)
this
->
localPort
,
...
...
@@ -159,28 +159,28 @@ void TCPServer::Dump()
this
->
connections
.
size
());
}
const
struct
sockaddr
*
T
CP
Server
::
GetLocalAddress
()
const
struct
sockaddr
*
T
cp
Server
::
GetLocalAddress
()
{
MS_TRACE
();
return
(
const
struct
sockaddr
*
)
&
this
->
localAddr
;
}
const
std
::
string
&
T
CP
Server
::
GetLocalIP
()
const
std
::
string
&
T
cp
Server
::
GetLocalIP
()
{
MS_TRACE
();
return
this
->
localIP
;
}
uint16_t
T
CP
Server
::
GetLocalPort
()
uint16_t
T
cp
Server
::
GetLocalPort
()
{
MS_TRACE
();
return
this
->
localPort
;
}
bool
T
CP
Server
::
SetLocalAddress
()
bool
T
cp
Server
::
SetLocalAddress
()
{
MS_TRACE
();
...
...
@@ -202,7 +202,7 @@ bool TCPServer::SetLocalAddress()
}
inline
void
T
CP
Server
::
onUvConnection
(
int
status
)
void
T
cp
Server
::
onUvConnection
(
int
status
)
{
MS_TRACE
();
...
...
@@ -219,9 +219,9 @@ void TCPServer::onUvConnection(int status)
}
// Notify the subclass so it provides an allocated derived class of TCPConnection.
T
CP
Connection
*
connection
=
nullptr
;
userOnT
CP
ConnectionAlloc
(
&
connection
);
MS_ASSERT
(
connection
!=
nullptr
,
"T
CP
Connection pointer was not allocated by the user"
);
T
cp
Connection
*
connection
=
nullptr
;
userOnT
cp
ConnectionAlloc
(
&
connection
);
MS_ASSERT
(
connection
!=
nullptr
,
"T
cp
Connection pointer was not allocated by the user"
);
try
{
...
...
@@ -238,7 +238,7 @@ void TCPServer::onUvConnection(int status)
if
(
err
)
MS_ABORT
(
"uv_accept() failed: %s"
,
uv_strerror
(
err
));
// Insert the T
CP
Connection in the set.
// Insert the T
cp
Connection in the set.
this
->
connections
.
insert
(
connection
);
// Start receiving data.
...
...
@@ -249,56 +249,55 @@ void TCPServer::onUvConnection(int status)
catch
(
const
MediaSoupError
&
error
)
{
MS_ERROR
(
"cannot run the TCP connection, closing the connection: %s"
,
error
.
what
());
connection
->
Close
();
// NOTE: Don't return here so the user won't be notified about a "onclose" for a TCP connection
// for which there was not a previous "onnew" event.
}
MS_DEBUG
(
"new TCP connection:"
);
connection
->
Dump
();
// NOTE: Don't return here so the user won't be notified about a TCP connection
// closure for which there was not a previous creation event.
}
// Notify the subclass.
userOnNewT
CP
Connection
(
connection
);
userOnNewT
cp
Connection
(
connection
);
}
inline
void
T
CP
Server
::
onUvClosed
()
void
T
cp
Server
::
onUvClosed
()
{
MS_TRACE
();
// Motify the subclass.
userOnT
CP
ServerClosed
();
userOnT
cp
ServerClosed
();
// And delete this.
delete
this
;
}
inline
void
T
CPServer
::
onTCPConnectionClosed
(
TCP
Connection
*
connection
,
bool
is_closed_by_peer
)
void
T
cpServer
::
onTcpConnectionClosed
(
Tcp
Connection
*
connection
,
bool
is_closed_by_peer
)
{
MS_TRACE
();
// NOTE:
// Worst scenario is that in which this is the latest connection,
// which is remotely closed (no T
CP
Server.Close() was called) and the user
// call T
CPServer.Close() on userOnTCP
ConnectionClosed() callback, so Close()
// which is remotely closed (no T
cp
Server.Close() was called) and the user
// call T
cpServer.Close() on userOnTcp
ConnectionClosed() callback, so Close()
// is called with zero connections and calls uv_close(), but then
// onT
CP
ConnectionClosed() continues and finds that isClosing is true and
// onT
cp
ConnectionClosed() continues and finds that isClosing is true and
// there are zero connections, so calls uv_close() again and get a crash.
//
// SOLUTION:
// Check isClosing value *before* onT
CP
ConnectionClosed() callback.
// Check isClosing value *before* onT
cp
ConnectionClosed() callback.
bool
wasClosing
=
this
->
isClosing
;
MS_DEBUG
(
"TCP connection closed:"
);
connection
->
Dump
();
// Remove the T
CP
Connection from the set.
// Remove the T
cp
Connection from the set.
this
->
connections
.
erase
(
connection
);
// Notify the subclass.
userOnT
CP
ConnectionClosed
(
connection
,
is_closed_by_peer
);
userOnT
cp
ConnectionClosed
(
connection
,
is_closed_by_peer
);
// Check if the server was closing connections, and if this is the last
// connection then close the server now.
...
...
worker/src/handles/U
DP
Socket.cpp
→
worker/src/handles/U
dp
Socket.cpp
浏览文件 @
e5ee62f1
#define MS_CLASS "U
DP
Socket"
#define MS_CLASS "U
dp
Socket"
#include "handles/U
DP
Socket.h"
#include "handles/U
dp
Socket.h"
#include "Utils.h"
#include "DepLibUV.h"
#include "MediaSoupError.h"
...
...
@@ -13,25 +13,25 @@
static
inline
void
on_alloc
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
static_cast
<
U
DP
Socket
*>
(
handle
->
data
)
->
onUvRecvAlloc
(
suggested_size
,
buf
);
static_cast
<
U
dp
Socket
*>
(
handle
->
data
)
->
onUvRecvAlloc
(
suggested_size
,
buf
);
}
static
inline
void
on_recv
(
uv_udp_t
*
handle
,
ssize_t
nread
,
const
uv_buf_t
*
buf
,
const
struct
sockaddr
*
addr
,
unsigned
int
flags
)
{
static_cast
<
U
DP
Socket
*>
(
handle
->
data
)
->
onUvRecv
(
nread
,
buf
,
addr
,
flags
);
static_cast
<
U
dp
Socket
*>
(
handle
->
data
)
->
onUvRecv
(
nread
,
buf
,
addr
,
flags
);
}
static
inline
void
on_send
(
uv_udp_send_t
*
req
,
int
status
)
{
U
DPSocket
::
UvSendData
*
send_data
=
static_cast
<
UDP
Socket
::
UvSendData
*>
(
req
->
data
);
U
DP
Socket
*
socket
=
send_data
->
socket
;
U
dpSocket
::
UvSendData
*
send_data
=
static_cast
<
Udp
Socket
::
UvSendData
*>
(
req
->
data
);
U
dp
Socket
*
socket
=
send_data
->
socket
;
// Delete the UvSendData struct (which includes the uv_req_t and the store char[]).
std
::
free
(
send_data
);
// Just notify the U
DP
Socket when error.
// Just notify the U
dp
Socket when error.
if
(
status
)
socket
->
onUvSendError
(
status
);
}
...
...
@@ -39,7 +39,7 @@ void on_send(uv_udp_send_t* req, int status)
static
inline
void
on_close
(
uv_handle_t
*
handle
)
{
static_cast
<
U
DP
Socket
*>
(
handle
->
data
)
->
onUvClosed
();
static_cast
<
U
dp
Socket
*>
(
handle
->
data
)
->
onUvClosed
();
}
static
inline
...
...
@@ -50,11 +50,11 @@ void on_error_close(uv_handle_t* handle)
/* Class variables. */
uint8_t
U
DP
Socket
::
readBuffer
[
MS_READ_BUFFER_SIZE
];
uint8_t
U
dp
Socket
::
readBuffer
[
MS_READ_BUFFER_SIZE
];
/* Instance methods. */
U
DPSocket
::
UDP
Socket
(
const
std
::
string
&
ip
,
uint16_t
port
)
U
dpSocket
::
Udp
Socket
(
const
std
::
string
&
ip
,
uint16_t
port
)
{
MS_TRACE
();
...
...
@@ -118,7 +118,7 @@ UDPSocket::UDPSocket(const std::string &ip, uint16_t port)
}
}
U
DPSocket
::
UDP
Socket
(
uv_udp_t
*
uvHandle
)
:
U
dpSocket
::
Udp
Socket
(
uv_udp_t
*
uvHandle
)
:
uvHandle
(
uvHandle
)
{
MS_TRACE
();
...
...
@@ -142,7 +142,7 @@ UDPSocket::UDPSocket(uv_udp_t* uvHandle) :
}
}
U
DPSocket
::~
UDP
Socket
()
U
dpSocket
::~
Udp
Socket
()
{
MS_TRACE
();
...
...
@@ -150,7 +150,7 @@ UDPSocket::~UDPSocket()
delete
this
->
uvHandle
;
}
void
U
DP
Socket
::
Close
()
void
U
dp
Socket
::
Close
()
{
MS_TRACE
();
...
...
@@ -169,14 +169,14 @@ void UDPSocket::Close()
uv_close
((
uv_handle_t
*
)
this
->
uvHandle
,
(
uv_close_cb
)
on_close
);
}
void
U
DP
Socket
::
Dump
()
void
U
dp
Socket
::
Dump
()
{
MS_DEBUG
(
"[UDP, local:%s :%"
PRIu16
", status:%s]"
,
this
->
localIP
.
c_str
(),
(
uint16_t
)
this
->
localPort
,
(
!
this
->
isClosing
)
?
"open"
:
"closed"
);
}
void
U
DP
Socket
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
void
U
dp
Socket
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
)
{
MS_TRACE
();
...
...
@@ -239,7 +239,7 @@ void UDPSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* add
}
}
void
U
DP
Socket
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
std
::
string
&
ip
,
uint16_t
port
)
void
U
dp
Socket
::
Send
(
const
uint8_t
*
data
,
size_t
len
,
const
std
::
string
&
ip
,
uint16_t
port
)
{
MS_TRACE
();
...
...
@@ -276,7 +276,7 @@ void UDPSocket::Send(const uint8_t* data, size_t len, const std::string &ip, uin
Send
(
data
,
len
,
(
struct
sockaddr
*
)
&
addr
);
}
bool
U
DP
Socket
::
SetLocalAddress
()
bool
U
dp
Socket
::
SetLocalAddress
()
{
MS_TRACE
();
...
...
@@ -298,18 +298,18 @@ bool UDPSocket::SetLocalAddress()
}
inline
void
U
DP
Socket
::
onUvRecvAlloc
(
size_t
suggested_size
,
uv_buf_t
*
buf
)
void
U
dp
Socket
::
onUvRecvAlloc
(
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
MS_TRACE
();
// Tell UV to write into the static buffer.
buf
->
base
=
(
char
*
)
U
DP
Socket
::
readBuffer
;
buf
->
base
=
(
char
*
)
U
dp
Socket
::
readBuffer
;
// Give UV all the buffer space.
buf
->
len
=
MS_READ_BUFFER_SIZE
;
}
inline
void
U
DP
Socket
::
onUvRecv
(
ssize_t
nread
,
const
uv_buf_t
*
buf
,
const
struct
sockaddr
*
addr
,
unsigned
int
flags
)
void
U
dp
Socket
::
onUvRecv
(
ssize_t
nread
,
const
uv_buf_t
*
buf
,
const
struct
sockaddr
*
addr
,
unsigned
int
flags
)
{
MS_TRACE
();
...
...
@@ -333,7 +333,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad
if
(
nread
>
0
)
{
// Notify the subclass.
userOnU
DP
DatagramRecv
((
uint8_t
*
)
buf
->
base
,
nread
,
addr
);
userOnU
dp
DatagramRecv
((
uint8_t
*
)
buf
->
base
,
nread
,
addr
);
}
// Some error.
...
...
@@ -344,7 +344,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad
}
inline
void
U
DP
Socket
::
onUvSendError
(
int
error
)
void
U
dp
Socket
::
onUvSendError
(
int
error
)
{
MS_TRACE
();
...
...
@@ -355,12 +355,12 @@ void UDPSocket::onUvSendError(int error)
}
inline
void
U
DP
Socket
::
onUvClosed
()
void
U
dp
Socket
::
onUvClosed
()
{
MS_TRACE
();
// Notify the subclass.
userOnU
DP
SocketClosed
();
userOnU
dp
SocketClosed
();
// And delete this.
delete
this
;
...
...
worker/src/main.cpp
浏览文件 @
e5ee62f1
...
...
@@ -8,10 +8,10 @@
#include "DepUsrSCTP.h"
#include "Utils.h"
#include "Channel/UnixStreamSocket.h"
#include "RTC/U
DP
Socket.h"
#include "RTC/T
CP
Server.h"
#include "RTC/D
TLS
Transport.h"
#include "RTC/S
RTP
Session.h"
#include "RTC/U
dp
Socket.h"
#include "RTC/T
cp
Server.h"
#include "RTC/D
tls
Transport.h"
#include "RTC/S
rtp
Session.h"
#include "Loop.h"
#include "MediaSoupError.h"
#include "Logger.h"
...
...
@@ -115,10 +115,10 @@ void init()
DepOpenSSL
::
ClassInit
();
DepLibSRTP
::
ClassInit
();
DepUsrSCTP
::
ClassInit
();
RTC
::
U
DP
Socket
::
ClassInit
();
RTC
::
T
CP
Server
::
ClassInit
();
RTC
::
D
TLS
Transport
::
ClassInit
();
RTC
::
S
RTP
Session
::
ClassInit
();
RTC
::
U
dp
Socket
::
ClassInit
();
RTC
::
T
cp
Server
::
ClassInit
();
RTC
::
D
tls
Transport
::
ClassInit
();
RTC
::
S
rtp
Session
::
ClassInit
();
Utils
::
Crypto
::
ClassInit
();
}
...
...
@@ -163,7 +163,7 @@ void destroy()
DepOpenSSL
::
ClassDestroy
();
DepLibSRTP
::
ClassDestroy
();
DepUsrSCTP
::
ClassDestroy
();
RTC
::
D
TLS
Transport
::
ClassDestroy
();
RTC
::
D
tls
Transport
::
ClassDestroy
();
Utils
::
Crypto
::
ClassDestroy
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论