Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
180a19d5
提交
180a19d5
authored
12月 31, 2015
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup and optimize JSON usage.
上级
9bc4d37a
隐藏空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
227 行增加
和
96 行删除
+227
-96
Peer.js
lib/Peer.js
+4
-1
Room.js
lib/Room.js
+4
-1
Server.js
lib/Server.js
+4
-1
Transport.js
lib/Transport.js
+4
-1
Worker.js
lib/Worker.js
+4
-1
DepLibUV.h
worker/include/DepLibUV.h
+1
-0
Loop.h
worker/include/Loop.h
+6
-1
Peer.h
worker/include/RTC/Peer.h
+1
-1
Room.h
worker/include/RTC/Room.h
+12
-2
Transport.h
worker/include/RTC/Transport.h
+6
-10
Request.cpp
worker/src/Channel/Request.cpp
+27
-15
DepLibUV.cpp
worker/src/DepLibUV.cpp
+7
-0
Loop.cpp
worker/src/Loop.cpp
+24
-13
IceCandidate.cpp
worker/src/RTC/IceCandidate.cpp
+20
-8
Peer.cpp
worker/src/RTC/Peer.cpp
+52
-6
Room.cpp
worker/src/RTC/Room.cpp
+16
-9
Transport.cpp
worker/src/RTC/Transport.cpp
+33
-21
SignalsHandler.cpp
worker/src/handles/SignalsHandler.cpp
+0
-2
main.cpp
worker/src/main.cpp
+2
-3
没有找到文件。
lib/Peer.js
浏览文件 @
180a19d5
...
...
@@ -38,7 +38,10 @@ class Peer extends EventEmitter
*/
close
(
error
,
dontSendChannel
)
{
logger
.
debug
(
'close() [error:%s]'
,
error
);
if
(
!
error
)
logger
.
debug
(
'close()'
);
else
logger
.
error
(
'close() [error:%s]'
,
error
);
if
(
this
.
_closed
)
return
;
...
...
lib/Room.js
浏览文件 @
180a19d5
...
...
@@ -35,7 +35,10 @@ class Room extends EventEmitter
*/
close
(
error
,
dontSendChannel
)
{
logger
.
debug
(
'close() [error:%s]'
,
error
);
if
(
!
error
)
logger
.
debug
(
'close()'
);
else
logger
.
error
(
'close() [error:%s]'
,
error
);
if
(
this
.
_closed
)
return
;
...
...
lib/Server.js
浏览文件 @
180a19d5
...
...
@@ -114,7 +114,10 @@ class Server extends EventEmitter
*/
close
(
error
)
{
logger
.
debug
(
'close() [error:%s]'
,
error
);
if
(
!
error
)
logger
.
debug
(
'close()'
);
else
logger
.
error
(
'close() [error:%s]'
,
error
);
if
(
this
.
_closed
)
return
;
...
...
lib/Transport.js
浏览文件 @
180a19d5
...
...
@@ -40,7 +40,10 @@ class Transport extends EventEmitter
*/
close
(
error
,
dontSendChannel
)
{
logger
.
debug
(
'close() [error:%s]'
,
error
);
if
(
!
error
)
logger
.
debug
(
'close()'
);
else
logger
.
error
(
'close() [error:%s]'
,
error
);
if
(
this
.
_closed
)
return
;
...
...
lib/Worker.js
浏览文件 @
180a19d5
...
...
@@ -88,7 +88,10 @@ class Worker extends EventEmitter
close
(
error
)
{
logger
.
debug
(
'close() [error:%s]'
,
error
);
if
(
!
error
)
logger
.
debug
(
'close()'
);
else
logger
.
error
(
'close() [error:%s]'
,
error
);
// Close every Room
this
.
_rooms
.
forEach
((
room
)
=>
room
.
close
(
undefined
,
true
));
...
...
worker/include/DepLibUV.h
浏览文件 @
180a19d5
...
...
@@ -8,6 +8,7 @@ class DepLibUV
public
:
static
void
ClassInit
();
static
void
ClassDestroy
();
static
void
PrintVersion
();
static
void
RunLoop
();
static
uv_loop_t
*
GetLoop
();
...
...
worker/include/Loop.h
浏览文件 @
180a19d5
...
...
@@ -10,7 +10,8 @@
class
Loop
:
public
SignalsHandler
::
Listener
,
public
Channel
::
UnixStreamSocket
::
Listener
public
Channel
::
UnixStreamSocket
::
Listener
,
public
RTC
::
Room
::
Listener
{
public
:
Loop
(
Channel
::
UnixStreamSocket
*
channel
);
...
...
@@ -30,6 +31,10 @@ public:
virtual
void
onChannelRequest
(
Channel
::
UnixStreamSocket
*
channel
,
Channel
::
Request
*
request
)
override
;
virtual
void
onChannelUnixStreamSocketRemotelyClosed
(
Channel
::
UnixStreamSocket
*
channel
)
override
;
/* Methods inherited from RTC::Room::Listener. */
public
:
virtual
void
onRoomClosed
(
RTC
::
Room
*
room
)
override
;
private
:
// Passed by argument.
Channel
::
UnixStreamSocket
*
channel
=
nullptr
;
...
...
worker/include/RTC/Peer.h
浏览文件 @
180a19d5
...
...
@@ -32,7 +32,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::Transport::Listener. */
public
:
// TODO
virtual
void
onTransportClosed
(
RTC
::
Transport
*
transport
)
override
;
public
:
// Passed by argument.
...
...
worker/include/RTC/Room.h
浏览文件 @
180a19d5
...
...
@@ -9,10 +9,18 @@
namespace
RTC
{
class
Room
:
public
RTC
::
Peer
::
Listener
class
Room
:
public
RTC
::
Peer
::
Listener
{
public
:
Room
(
unsigned
int
roomId
,
Json
::
Value
&
data
);
class
Listener
{
public
:
virtual
void
onRoomClosed
(
RTC
::
Room
*
room
)
=
0
;
};
public
:
Room
(
Listener
*
listener
,
unsigned
int
roomId
,
Json
::
Value
&
data
);
virtual
~
Room
();
void
Close
();
...
...
@@ -31,6 +39,8 @@ namespace RTC
unsigned
int
roomId
;
private
:
// Passed by argument.
Listener
*
listener
=
nullptr
;
// Others.
typedef
std
::
unordered_map
<
std
::
string
,
RTC
::
Peer
*>
Peers
;
Peers
peers
;
...
...
worker/include/RTC/Transport.h
浏览文件 @
180a19d5
...
...
@@ -25,7 +25,7 @@ namespace RTC
class
Listener
{
public
:
// TODO
virtual
void
onTransportClosed
(
RTC
::
Transport
*
transport
)
=
0
;
};
public
:
...
...
@@ -35,18 +35,12 @@ namespace RTC
RTCP
=
2
};
public
:
typedef
struct
IceParameters
{
std
::
string
usernameFragment
;
std
::
string
password
;
}
IceParameters
;
public
:
Transport
(
Listener
*
listener
,
unsigned
int
transportId
,
Json
::
Value
&
data
,
Transport
*
rtpTransport
=
nullptr
);
virtual
~
Transport
();
void
Close
();
Json
::
Value
Dump
();
Json
::
Value
toJson
();
std
::
string
&
GetIceUsernameFragment
();
std
::
string
&
GetIcePassword
();
...
...
@@ -88,17 +82,19 @@ namespace RTC
bool
hasIPv4tcp
=
false
;
bool
hasIPv6tcp
=
false
;
public
:
// Passed by argument.
unsigned
int
transportId
;
private
:
// Passed by argument.
Listener
*
listener
=
nullptr
;
unsigned
int
transportId
;
RTC
::
Transport
::
IceComponent
iceComponent
;
// Allocated by this.
RTC
::
IceServer
*
iceServer
=
nullptr
;
std
::
vector
<
RTC
::
UDPSocket
*>
udpSockets
;
std
::
vector
<
RTC
::
TCPServer
*>
tcpServers
;
// Others.
IceParameters
iceLocalParameters
;
std
::
vector
<
IceCandidate
>
iceLocalCandidates
;
bool
allocated
=
false
;
};
...
...
worker/src/Channel/Request.cpp
浏览文件 @
180a19d5
...
...
@@ -32,17 +32,21 @@ namespace Channel
{
MS_TRACE
();
if
(
json
[
"id"
].
isUInt
())
this
->
id
=
json
[
"id"
].
asUInt
();
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_method
(
"method"
);
static
const
Json
::
StaticString
k_data
(
"data"
);
if
(
json
[
k_id
].
isUInt
())
this
->
id
=
json
[
k_id
].
asUInt
();
else
MS_THROW_ERROR
(
"json has no numeric .id field"
);
if
(
json
[
"method"
].
isString
())
this
->
method
=
json
[
"method"
].
asString
();
if
(
json
[
k_method
].
isString
())
this
->
method
=
json
[
k_method
].
asString
();
else
MS_THROW_ERROR
(
"json has no string .method field"
);
auto
it
=
Request
::
string2MethodId
.
find
(
method
);
auto
it
=
Request
::
string2MethodId
.
find
(
this
->
method
);
if
(
it
!=
Request
::
string2MethodId
.
end
())
{
...
...
@@ -52,11 +56,11 @@ namespace Channel
{
Reject
(
405
,
"method not allowed"
);
MS_THROW_ERROR
(
"unknown .method '%s'"
,
method
.
c_str
());
MS_THROW_ERROR
(
"unknown .method '%s'"
,
this
->
method
.
c_str
());
}
if
(
json
[
"data"
].
isObject
())
this
->
data
=
json
[
"data"
];
if
(
json
[
k_data
].
isObject
())
this
->
data
=
json
[
k_data
];
else
this
->
data
=
Json
::
Value
(
Json
::
objectValue
);
}
...
...
@@ -80,15 +84,19 @@ namespace Channel
MS_ASSERT
(
!
this
->
replied
,
"Request already replied"
);
this
->
replied
=
true
;
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_status
(
"status"
);
static
const
Json
::
StaticString
k_data
(
"data"
);
Json
::
Value
json
;
json
[
"id"
]
=
this
->
id
;
json
[
"status"
]
=
200
;
json
[
k_id
]
=
this
->
id
;
json
[
k_status
]
=
200
;
if
(
data
.
isObject
())
json
[
"data"
]
=
data
;
json
[
k_data
]
=
data
;
else
json
[
"data"
]
=
empty_data
;
json
[
k_data
]
=
empty_data
;
this
->
channel
->
Send
(
json
);
}
...
...
@@ -114,13 +122,17 @@ namespace Channel
MS_ASSERT
(
status
>=
400
&&
status
<=
599
,
"status must be between 400 and 500"
);
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_status
(
"status"
);
static
const
Json
::
StaticString
k_reason
(
"reason"
);
Json
::
Value
json
;
json
[
"id"
]
=
this
->
id
;
json
[
"status"
]
=
status
;
json
[
k_id
]
=
this
->
id
;
json
[
k_status
]
=
status
;
if
(
reason
)
json
[
"reason"
]
=
reason
;
json
[
k_reason
]
=
reason
;
this
->
channel
->
Send
(
json
);
}
...
...
worker/src/DepLibUV.cpp
浏览文件 @
180a19d5
...
...
@@ -34,6 +34,13 @@ void DepLibUV::ClassDestroy()
delete
DepLibUV
::
loop
;
}
void
DepLibUV
::
PrintVersion
()
{
MS_TRACE
();
MS_DEBUG
(
"loaded libuv version: %s"
,
uv_version_string
());
}
void
DepLibUV
::
RunLoop
()
{
MS_TRACE
();
...
...
worker/src/Loop.cpp
浏览文件 @
180a19d5
...
...
@@ -43,7 +43,9 @@ RTC::Room* Loop::GetRoomFromRequest(Channel::Request* request, unsigned int* roo
{
MS_TRACE
();
auto
jsonRoomId
=
request
->
data
[
"roomId"
];
static
const
Json
::
StaticString
k_roomId
(
"roomId"
);
auto
jsonRoomId
=
request
->
data
[
k_roomId
];
if
(
!
jsonRoomId
.
isUInt
())
MS_THROW_ERROR
(
"Request has not numeric .roomId field"
);
...
...
@@ -92,10 +94,14 @@ void Loop::Close()
this
->
signalsHandler
->
Close
();
// Close all the Rooms.
for
(
auto
&
kv
:
this
->
rooms
)
// NOTE: Upon Room closure the onRoomClosed() method is called which
// removes it from the map, so this is the safe way to iterate the mao
// and remove elements.
for
(
auto
it
=
this
->
rooms
.
begin
();
it
!=
this
->
rooms
.
end
();)
{
RTC
::
Room
*
room
=
kv
.
second
;
RTC
::
Room
*
room
=
it
->
second
;
it
=
this
->
rooms
.
erase
(
it
);
room
->
Close
();
}
...
...
@@ -142,19 +148,20 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
{
case
Channel
:
:
Request
::
MethodId
::
dumpWorker
:
{
static
const
Json
::
StaticString
k_rooms
(
"rooms"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
W
orker
(
Json
::
objectValue
);
Json
::
Value
json
R
ooms
(
Json
::
objectValue
);
Json
::
Value
json
_w
orker
(
Json
::
objectValue
);
Json
::
Value
json
_r
ooms
(
Json
::
objectValue
);
for
(
auto
&
kv
:
this
->
rooms
)
{
auto
room
=
kv
.
second
;
json
R
ooms
[
std
::
to_string
(
room
->
roomId
)]
=
room
->
Dump
();
json
_r
ooms
[
std
::
to_string
(
room
->
roomId
)]
=
room
->
Dump
();
}
jsonWorker
[
"rooms"
]
=
jsonRooms
;
json
[
Logger
::
id
]
=
jsonWorker
;
json_worker
[
k_rooms
]
=
json_rooms
;
json
[
Logger
::
id
]
=
json_worker
;
request
->
Accept
(
json
);
...
...
@@ -192,7 +199,7 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
try
{
room
=
new
RTC
::
Room
(
roomId
,
request
->
data
);
room
=
new
RTC
::
Room
(
this
,
roomId
,
request
->
data
);
}
catch
(
const
MediaSoupError
&
error
)
{
...
...
@@ -233,9 +240,6 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
room
->
Close
();
// TODO: Instead of this, the Room should fire an onRoomClosed() here.
this
->
rooms
.
erase
(
roomId
);
MS_DEBUG
(
"Room closed [roomId:%u]"
,
roomId
);
request
->
Accept
();
...
...
@@ -295,3 +299,10 @@ void Loop::onChannelUnixStreamSocketRemotelyClosed(Channel::UnixStreamSocket* so
Close
();
}
void
Loop
::
onRoomClosed
(
RTC
::
Room
*
room
)
{
MS_TRACE
();
this
->
rooms
.
erase
(
room
->
roomId
);
}
worker/src/RTC/IceCandidate.cpp
浏览文件 @
180a19d5
...
...
@@ -27,31 +27,43 @@ namespace RTC
Json
::
Value
IceCandidate
::
toJson
()
{
static
const
Json
::
StaticString
k_foundation
(
"foundation"
);
static
const
Json
::
StaticString
k_priority
(
"priority"
);
static
const
Json
::
StaticString
k_ip
(
"ip"
);
static
const
Json
::
StaticString
k_port
(
"port"
);
static
const
Json
::
StaticString
k_type
(
"type"
);
static
const
Json
::
StaticString
v_host
(
"host"
);
static
const
Json
::
StaticString
k_protocol
(
"protocol"
);
static
const
Json
::
StaticString
v_udp
(
"udp"
);
static
const
Json
::
StaticString
v_tcp
(
"tcp"
);
static
const
Json
::
StaticString
k_tcpType
(
"tcpType"
);
static
const
Json
::
StaticString
v_passive
(
"passive"
);
Json
::
Value
data
;
data
[
"foundation"
]
=
this
->
foundation
;
data
[
"priority"
]
=
(
unsigned
int
)
this
->
priority
;
data
[
"ip"
]
=
this
->
ip
;
data
[
"port"
]
=
this
->
port
;
data
[
k_foundation
]
=
this
->
foundation
;
data
[
k_priority
]
=
(
unsigned
int
)
this
->
priority
;
data
[
k_ip
]
=
this
->
ip
;
data
[
k_port
]
=
this
->
port
;
switch
(
this
->
type
)
{
case
CandidateType
:
:
HOST
:
data
[
"type"
]
=
"host"
;
data
[
k_type
]
=
v_host
;
break
;
}
switch
(
this
->
protocol
)
{
case
Protocol
:
:
UDP
:
data
[
"protocol"
]
=
"udp"
;
data
[
k_protocol
]
=
v_udp
;
break
;
case
Protocol
:
:
TCP
:
data
[
"protocol"
]
=
"tcp"
;
data
[
k_protocol
]
=
v_tcp
;
switch
(
this
->
tcpType
)
{
case
TcpCandidateType
:
:
PASSIVE
:
data
[
"tcpType"
]
=
"passive"
;
data
[
k_tcpType
]
=
v_passive
;
break
;
}
break
;
...
...
worker/src/RTC/Peer.cpp
浏览文件 @
180a19d5
...
...
@@ -28,10 +28,14 @@ namespace RTC
MS_TRACE
();
// Close all the Transports.
for
(
auto
&
kv
:
this
->
transports
)
// NOTE: Upon Transport closure the onTransportClosed() method is called which
// removes it from the map, so this is the safe way to iterate the mao
// and remove elements.
for
(
auto
it
=
this
->
transports
.
begin
();
it
!=
this
->
transports
.
end
();)
{
RTC
::
Transport
*
transport
=
kv
.
second
;
RTC
::
Transport
*
transport
=
it
->
second
;
it
=
this
->
transports
.
erase
(
it
);
transport
->
Close
();
}
...
...
@@ -45,9 +49,18 @@ namespace RTC
{
MS_TRACE
();
static
const
Json
::
StaticString
k_transports
(
"transports"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json_transports
(
Json
::
objectValue
);
// TODO
for
(
auto
&
kv
:
this
->
transports
)
{
RTC
::
Transport
*
transport
=
kv
.
second
;
json_transports
[
std
::
to_string
(
transport
->
transportId
)]
=
transport
->
Dump
();
}
json
[
k_transports
]
=
json_transports
;
return
json
;
}
...
...
@@ -125,7 +138,9 @@ namespace RTC
return
;
}
auto
jsonRtpTransportId
=
request
->
data
[
"rtpTransportId"
];
static
const
Json
::
StaticString
k_rtpTransportId
(
"rtpTransportId"
);
auto
jsonRtpTransportId
=
request
->
data
[
k_rtpTransportId
];
if
(
!
jsonRtpTransportId
.
isUInt
())
{
...
...
@@ -170,8 +185,30 @@ namespace RTC
case
Channel
:
:
Request
::
MethodId
::
closeTransport
:
{
// TODO
RTC
::
Transport
*
transport
;
unsigned
int
transportId
;
try
{
transport
=
GetTransportFromRequest
(
request
,
&
transportId
);
}
catch
(
const
MediaSoupError
&
error
)
{
request
->
Reject
(
500
,
error
.
what
());
return
;
}
if
(
!
transport
)
{
MS_ERROR
(
"Transport does not exist"
);
request
->
Reject
(
500
,
"Transport does not exist"
);
return
;
}
transport
->
Close
();
MS_DEBUG
(
"Transport closed [transportId:%u]"
,
transportId
);
request
->
Accept
();
break
;
...
...
@@ -188,7 +225,9 @@ namespace RTC
{
MS_TRACE
();
auto
jsonTransportId
=
request
->
data
[
"transportId"
];
static
const
Json
::
StaticString
k_transportId
(
"transportId"
);
auto
jsonTransportId
=
request
->
data
[
k_transportId
];
if
(
!
jsonTransportId
.
isUInt
())
MS_THROW_ERROR
(
"Request has not numeric .transportId field"
);
...
...
@@ -210,4 +249,11 @@ namespace RTC
return
nullptr
;
}
}
void
Peer
::
onTransportClosed
(
RTC
::
Transport
*
transport
)
{
MS_TRACE
();
this
->
transports
.
erase
(
transport
->
transportId
);
}
}
worker/src/RTC/Room.cpp
浏览文件 @
180a19d5
...
...
@@ -8,8 +8,9 @@ namespace RTC
{
/* Instance methods. */
Room
::
Room
(
unsigned
int
roomId
,
Json
::
Value
&
data
)
:
roomId
(
roomId
)
Room
::
Room
(
Listener
*
listener
,
unsigned
int
roomId
,
Json
::
Value
&
data
)
:
roomId
(
roomId
),
listener
(
listener
)
{
MS_TRACE
();
...
...
@@ -31,12 +32,15 @@ namespace RTC
// and remove elements.
for
(
auto
it
=
this
->
peers
.
begin
();
it
!=
this
->
peers
.
end
();)
{
auto
peer
=
it
->
second
;
RTC
::
Peer
*
peer
=
it
->
second
;
it
=
this
->
peers
.
erase
(
it
);
peer
->
Close
();
}
// Notify the listener.
this
->
listener
->
onRoomClosed
(
this
);
delete
this
;
}
...
...
@@ -44,17 +48,18 @@ namespace RTC
{
MS_TRACE
();
static
const
Json
::
StaticString
k_peers
(
"peers"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
P
eers
(
Json
::
objectValue
);
Json
::
Value
json
_p
eers
(
Json
::
objectValue
);
for
(
auto
&
kv
:
this
->
peers
)
{
auto
peer
=
kv
.
second
;
RTC
::
Peer
*
peer
=
kv
.
second
;
json
P
eers
[
peer
->
peerId
]
=
peer
->
Dump
();
json
_p
eers
[
peer
->
peerId
]
=
peer
->
Dump
();
}
json
[
"peers"
]
=
jsonPeers
;
json
[
k_peers
]
=
json_peers
;
return
json
;
}
...
...
@@ -175,7 +180,9 @@ namespace RTC
{
MS_TRACE
();
auto
jsonPeerId
=
request
->
data
[
"peerId"
];
static
const
Json
::
StaticString
k_peerId
(
"peerId"
);
auto
jsonPeerId
=
request
->
data
[
k_peerId
];
if
(
!
jsonPeerId
.
isString
())
MS_THROW_ERROR
(
"Request has not string .peerId field"
);
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
180a19d5
...
...
@@ -21,13 +21,13 @@ namespace RTC
/* Instance methods. */
Transport
::
Transport
(
Listener
*
listener
,
unsigned
int
transportId
,
Json
::
Value
&
data
,
Transport
*
rtpTransport
)
:
listener
(
listener
),
transportId
(
transportId
)
transportId
(
transportId
),
listener
(
listener
)
{
MS_TRACE
();
static
const
Json
::
StaticString
udp
(
"udp"
);
static
const
Json
::
StaticString
tcp
(
"tcp"
);
static
const
Json
::
StaticString
k_
udp
(
"udp"
);
static
const
Json
::
StaticString
k_
tcp
(
"tcp"
);
bool
try_IPv4_udp
=
false
;
bool
try_IPv6_udp
=
false
;
...
...
@@ -43,11 +43,11 @@ namespace RTC
Utils
::
Crypto
::
GetRandomString
(
16
),
Utils
::
Crypto
::
GetRandomString
(
32
));
if
(
data
[
udp
].
isBool
())
try_IPv4_udp
=
try_IPv6_udp
=
data
[
udp
].
asBool
();
if
(
data
[
k_
udp
].
isBool
())
try_IPv4_udp
=
try_IPv6_udp
=
data
[
k_
udp
].
asBool
();
if
(
data
[
tcp
].
isBool
())
try_IPv4_tcp
=
try_IPv6_tcp
=
data
[
tcp
].
asBool
();
if
(
data
[
k_
tcp
].
isBool
())
try_IPv4_tcp
=
try_IPv6_tcp
=
data
[
k_
tcp
].
asBool
();
}
// RTCP transport associated to a given RTP transport.
else
...
...
@@ -64,10 +64,6 @@ namespace RTC
try_IPv6_tcp
=
rtpTransport
->
hasIPv6tcp
;
}
// Fill IceParameters.
this
->
iceLocalParameters
.
usernameFragment
=
this
->
iceServer
->
GetUsernameFragment
();
this
->
iceLocalParameters
.
password
=
this
->
iceServer
->
GetPassword
();
// Open a IPv4 UDP socket.
if
(
try_IPv4_udp
&&
Settings
::
configuration
.
hasIPv4
)
{
...
...
@@ -208,32 +204,48 @@ namespace RTC
server
->
Close
();
if
(
this
->
allocated
)
{
// Notify the listener.
this
->
listener
->
onTransportClosed
(
this
);
delete
this
;
}
}
Json
::
Value
Transport
::
toJson
()
Json
::
Value
Transport
::
Dump
()
{
MS_TRACE
();
return
toJson
();
}
Json
::
Value
Transport
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
iceLocalParameters
(
"iceLocalParameters"
);
static
const
Json
::
StaticString
iceLocalCandidates
(
"iceLocalCandidates"
);
static
const
Json
::
StaticString
k_iceComponent
(
"iceComponent"
);
static
const
Json
::
StaticString
k_iceLocalParameters
(
"iceLocalParameters"
);
static
const
Json
::
StaticString
k_usernameFragment
(
"usernameFragment"
);
static
const
Json
::
StaticString
k_password
(
"password"
);
static
const
Json
::
StaticString
k_iceLocalCandidates
(
"iceLocalCandidates"
);
static
const
Json
::
StaticString
v_RTP
(
"RTP"
);
static
const
Json
::
StaticString
v_RTCP
(
"RTCP"
);
Json
::
Value
data
;
if
(
this
->
iceComponent
==
IceComponent
::
RTP
)
data
[
"iceComponent"
]
=
"RTP"
;
data
[
k_iceComponent
]
=
v_RTP
;
else
data
[
"iceComponent"
]
=
"RTCP"
;
data
[
k_iceComponent
]
=
v_RTCP
;
data
[
iceLocalParameters
][
"usernameFragment"
]
=
this
->
iceLocalParameters
.
usernameFragment
;
data
[
iceLocalParameters
][
"password"
]
=
this
->
iceLocalParameters
.
password
;
data
[
k_iceLocalParameters
][
k_usernameFragment
]
=
this
->
iceServer
->
GetUsernameFragment
()
;
data
[
k_iceLocalParameters
][
k_password
]
=
this
->
iceServer
->
GetPassword
()
;
data
[
iceLocalCandidates
]
=
Json
::
arrayValue
;
data
[
k_
iceLocalCandidates
]
=
Json
::
arrayValue
;
for
(
auto
iceCandidate
:
this
->
iceLocalCandidates
)
{
data
[
iceLocalCandidates
].
append
(
iceCandidate
.
toJson
());
data
[
k_
iceLocalCandidates
].
append
(
iceCandidate
.
toJson
());
}
return
data
;
...
...
worker/src/handles/SignalsHandler.cpp
浏览文件 @
180a19d5
...
...
@@ -49,8 +49,6 @@ void SignalsHandler::AddSignal(int signum, std::string name)
// Enter the UV handle into the vector.
this
->
uvHandles
.
push_back
(
uvHandle
);
MS_DEBUG
(
"signal %s added"
,
name
.
c_str
());
}
void
SignalsHandler
::
Close
()
...
...
worker/src/main.cpp
浏览文件 @
180a19d5
...
...
@@ -41,9 +41,6 @@ int main(int argc, char* argv[], char** envp)
Logger
::
Init
(
id
,
channel
);
// Print libuv version.
MS_DEBUG
(
"loaded libuv version: %s"
,
uv_version_string
());
try
{
Settings
::
SetConfiguration
(
argc
,
argv
);
...
...
@@ -100,6 +97,8 @@ void init()
ignoreSignals
();
DepLibUV
::
PrintVersion
();
// Initialize static stuff.
DepOpenSSL
::
ClassInit
();
DepLibSRTP
::
ClassInit
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论