Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
a1ff4db9
提交
a1ff4db9
authored
1月 02, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ICE works.
上级
73d6ae3b
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
178 行增加
和
7 行删除
+178
-7
test_server.js
test/test_server.js
+2
-2
Transport.h
worker/include/RTC/Transport.h
+134
-1
IceServer.cpp
worker/src/RTC/IceServer.cpp
+1
-1
Transport.cpp
worker/src/RTC/Transport.cpp
+41
-3
没有找到文件。
test/test_server.js
浏览文件 @
a1ff4db9
...
@@ -49,7 +49,7 @@ tap.test('server.updateSettings() with invalid options must fail', { timeout: 10
...
@@ -49,7 +49,7 @@ tap.test('server.updateSettings() with invalid options must fail', { timeout: 10
});
});
});
});
tap
.
test
(
'server.updateSettings() in a closed
S
erver must fail'
,
{
timeout
:
1000
},
(
t
)
=>
tap
.
test
(
'server.updateSettings() in a closed
s
erver must fail'
,
{
timeout
:
1000
},
(
t
)
=>
{
{
let
server
=
mediasoup
.
Server
();
let
server
=
mediasoup
.
Server
();
...
@@ -86,7 +86,7 @@ tap.test('server.Room() must succeed', { timeout: 1000 }, (t) =>
...
@@ -86,7 +86,7 @@ tap.test('server.Room() must succeed', { timeout: 1000 }, (t) =>
setTimeout
(()
=>
room
.
close
(),
100
);
setTimeout
(()
=>
room
.
close
(),
100
);
});
});
tap
.
test
(
'server.Room() in a closed
S
erver must fail'
,
{
timeout
:
1000
},
(
t
)
=>
tap
.
test
(
'server.Room() in a closed
s
erver must fail'
,
{
timeout
:
1000
},
(
t
)
=>
{
{
let
server
=
mediasoup
.
Server
();
let
server
=
mediasoup
.
Server
();
...
...
worker/include/RTC/Transport.h
浏览文件 @
a1ff4db9
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include "RTC/TCPConnection.h"
#include "RTC/TCPConnection.h"
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <list>
#include <json/json.h>
#include <json/json.h>
namespace
RTC
namespace
RTC
...
@@ -35,6 +36,9 @@ namespace RTC
...
@@ -35,6 +36,9 @@ namespace RTC
RTCP
=
2
RTCP
=
2
};
};
private
:
static
size_t
maxSources
;
public
:
public
:
Transport
(
Listener
*
listener
,
unsigned
int
transportId
,
Json
::
Value
&
data
,
Transport
*
rtpTransport
=
nullptr
);
Transport
(
Listener
*
listener
,
unsigned
int
transportId
,
Json
::
Value
&
data
,
Transport
*
rtpTransport
=
nullptr
);
virtual
~
Transport
();
virtual
~
Transport
();
...
@@ -45,6 +49,11 @@ namespace RTC
...
@@ -45,6 +49,11 @@ namespace RTC
std
::
string
&
GetIcePassword
();
std
::
string
&
GetIcePassword
();
Transport
*
CreateAssociatedTransport
(
unsigned
int
transportId
);
Transport
*
CreateAssociatedTransport
(
unsigned
int
transportId
);
private
:
bool
SetSendingSource
(
RTC
::
TransportSource
*
source
);
bool
IsValidSource
(
RTC
::
TransportSource
*
source
);
bool
RemoveSource
(
RTC
::
TransportSource
*
source
);
/* Pure virtual methods inherited from RTC::IceServer::Listener. */
/* Pure virtual methods inherited from RTC::IceServer::Listener. */
public
:
public
:
virtual
void
onOutgoingSTUNMessage
(
RTC
::
IceServer
*
iceServer
,
RTC
::
STUNMessage
*
msg
,
RTC
::
TransportSource
*
source
)
override
;
virtual
void
onOutgoingSTUNMessage
(
RTC
::
IceServer
*
iceServer
,
RTC
::
STUNMessage
*
msg
,
RTC
::
TransportSource
*
source
)
override
;
...
@@ -93,8 +102,12 @@ namespace RTC
...
@@ -93,8 +102,12 @@ namespace RTC
std
::
vector
<
RTC
::
UDPSocket
*>
udpSockets
;
std
::
vector
<
RTC
::
UDPSocket
*>
udpSockets
;
std
::
vector
<
RTC
::
TCPServer
*>
tcpServers
;
std
::
vector
<
RTC
::
TCPServer
*>
tcpServers
;
// Others.
// Others.
std
::
vector
<
IceCandidate
>
iceLocalCandidates
;
bool
allocated
=
false
;
bool
allocated
=
false
;
std
::
vector
<
IceCandidate
>
iceLocalCandidates
;
std
::
list
<
RTC
::
TransportSource
>
sources
;
RTC
::
TransportSource
*
sendingSource
=
nullptr
;
bool
icePaired
=
false
;
bool
icePairedWithUseCandidate
=
false
;
};
};
/* Inline methods. */
/* Inline methods. */
...
@@ -110,6 +123,126 @@ namespace RTC
...
@@ -110,6 +123,126 @@ namespace RTC
{
{
return
this
->
iceServer
->
GetPassword
();
return
this
->
iceServer
->
GetPassword
();
}
}
/**
* Set the given source as a valid one and mark it as the sending source for
* outgoing data.
*
* @param source: A RTC::TransportSource (which is a UDP tuple or TCP connection).
* @return: true if the given source was not an already valid source,
* false otherwise.
*/
inline
bool
Transport
::
SetSendingSource
(
RTC
::
TransportSource
*
source
)
{
// If the give source is already a valid one return.
// NOTE: The IsValidSource() method will also mark it as sending source.
if
(
IsValidSource
(
source
))
return
false
;
// If there are Transport::maxSources sources then close and remove the last one.
if
(
this
->
sources
.
size
()
==
Transport
::
maxSources
)
{
RTC
::
TransportSource
*
last_source
=
&
(
*
this
->
sources
.
end
());
last_source
->
Close
();
this
->
sources
.
pop_back
();
}
// Add the new source at the beginning.
this
->
sources
.
push_front
(
*
source
);
// Set it as sending source (make it point to the first source in the list).
this
->
sendingSource
=
&
(
*
this
->
sources
.
begin
());
// If it is UDP then we must store the remote address (until now it is
// just a pointer that will be freed soon).
if
(
this
->
sendingSource
->
IsUDP
())
this
->
sendingSource
->
StoreUdpRemoteAddress
();
return
true
;
}
/**
* Check whether the given source is contained in the list of valid sources for
* this transport. In case it is, the given source is also marked as sending
* source for the outgoing data.
*
* @param source: The RTC::TransportSource to check.
* @return: true if it is a valid source, false otherwise.
*/
inline
bool
Transport
::
IsValidSource
(
RTC
::
TransportSource
*
source
)
{
// If there is no sending source yet then we know that the sources list
// is empty, so return false.
if
(
!
this
->
sendingSource
)
return
false
;
// First check the current sending source. If it matches then return true.
if
(
this
->
sendingSource
->
Compare
(
source
))
return
true
;
// Otherwise check other valid source in the sources list.
for
(
auto
it
=
this
->
sources
.
begin
();
it
!=
this
->
sources
.
end
();
++
it
)
{
RTC
::
TransportSource
*
valid_source
=
&
(
*
it
);
// If found set it as sending source.
if
(
valid_source
->
Compare
(
source
))
{
this
->
sendingSource
=
valid_source
;
return
true
;
}
}
return
false
;
}
/**
* Remove the given source from the list of valid sources. Also update the
* sending source if the given source was the sending source and make it point
* to the next valid source (if any).
*
* @param source: The RTC::TransportSource to remove.
* @return: true if the given source was present in the list of valid
* sources, false otherwise.
*/
inline
bool
Transport
::
RemoveSource
(
RTC
::
TransportSource
*
source
)
{
for
(
auto
it
=
this
->
sources
.
begin
();
it
!=
this
->
sources
.
end
();
++
it
)
{
RTC
::
TransportSource
*
valid_source
=
&
(
*
it
);
// If the source was a valid source then remove it.
if
(
valid_source
->
Compare
(
source
))
{
this
->
sources
.
erase
(
it
);
// If it was the sending source then unset it and set the sending
// source to the first valid source (if any).
if
(
this
->
sendingSource
==
valid_source
)
{
if
(
this
->
sources
.
begin
()
!=
this
->
sources
.
end
())
{
this
->
sendingSource
=
&
(
*
this
->
sources
.
begin
());
}
else
{
this
->
sendingSource
=
nullptr
;
// This is just useful is there are just TCP sources.
this
->
icePaired
=
false
;
this
->
icePairedWithUseCandidate
=
false
;
}
}
return
true
;
}
}
return
false
;
}
}
}
#endif
#endif
worker/src/RTC/IceServer.cpp
浏览文件 @
a1ff4db9
...
@@ -135,7 +135,7 @@ namespace RTC
...
@@ -135,7 +135,7 @@ namespace RTC
return
;
return
;
}
}
MS_DEBUG
(
"processing STUN Binding Request
with Priority %u%s"
,
(
unsigned
int
)
msg
->
GetPriority
(),
msg
->
HasUseCandidate
()
?
" and UseCandidate"
:
"
"
);
MS_DEBUG
(
"processing STUN Binding Request
[Priority:%u, UseCandidate:%s]"
,
(
unsigned
int
)
msg
->
GetPriority
(),
msg
->
HasUseCandidate
()
?
"true"
:
"false
"
);
// Create a success response.
// Create a success response.
RTC
::
STUNMessage
*
response
=
msg
->
CreateSuccessResponse
();
RTC
::
STUNMessage
*
response
=
msg
->
CreateSuccessResponse
();
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
a1ff4db9
...
@@ -26,6 +26,10 @@
...
@@ -26,6 +26,10 @@
namespace
RTC
namespace
RTC
{
{
/* Class variables. */
size_t
Transport
::
maxSources
=
8
;
/* Instance methods. */
/* Instance methods. */
Transport
::
Transport
(
Listener
*
listener
,
unsigned
int
transportId
,
Json
::
Value
&
data
,
Transport
*
rtpTransport
)
:
Transport
::
Transport
(
Listener
*
listener
,
unsigned
int
transportId
,
Json
::
Value
&
data
,
Transport
*
rtpTransport
)
:
...
@@ -268,14 +272,28 @@ namespace RTC
...
@@ -268,14 +272,28 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// TODO
// Send the STUN response over the same transport source.
source
->
Send
(
msg
->
GetRaw
(),
msg
->
GetLength
());
}
}
void
Transport
::
onICEValidPair
(
RTC
::
IceServer
*
iceServer
,
RTC
::
TransportSource
*
source
,
bool
has_use_candidate
)
void
Transport
::
onICEValidPair
(
RTC
::
IceServer
*
iceServer
,
RTC
::
TransportSource
*
source
,
bool
has_use_candidate
)
{
{
MS_TRACE
();
MS_TRACE
();
// TODO
this
->
icePaired
=
true
;
if
(
has_use_candidate
)
this
->
icePairedWithUseCandidate
=
true
;
/*
* RFC 5245 section 11.2 "Receiving Media":
*
* ICE implementations MUST be prepared to receive media on each component
* on any candidates provided for that component.
*/
if
(
SetSendingSource
(
source
))
MS_DEBUG
(
"got an ICE valid pair [UseCandidate:%s]"
,
has_use_candidate
?
"true"
:
"false"
);
// TODO: more
}
}
inline
inline
...
@@ -283,7 +301,17 @@ namespace RTC
...
@@ -283,7 +301,17 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// TODO
RTC
::
STUNMessage
*
msg
=
RTC
::
STUNMessage
::
Parse
(
data
,
len
);
if
(
!
msg
)
{
MS_DEBUG
(
"ignoring wrong STUN message received"
);
return
;
}
// Pass it to the IceServer.
this
->
iceServer
->
ProcessSTUNMessage
(
msg
,
source
);
delete
msg
;
}
}
inline
inline
...
@@ -291,6 +319,16 @@ namespace RTC
...
@@ -291,6 +319,16 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
if
(
!
IsValidSource
(
source
))
{
MS_DEBUG
(
"ignoring DTLS data coming from an invalid source"
);
return
;
}
// TODO: remove
MS_DEBUG
(
"received DTLS data"
);
// TODO
// TODO
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论