Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
4a794f71
提交
4a794f71
authored
3月 22, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add options to server.Room() method.
上级
15f1fb7d
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
35 行增加
和
9 行删除
+35
-9
Server.js
lib/Server.js
+5
-3
Worker.js
lib/Worker.js
+3
-3
Room.h
worker/include/RTC/Room.h
+8
-1
Loop.cpp
worker/src/Loop.cpp
+1
-1
Room.cpp
worker/src/RTC/Room.cpp
+18
-1
没有找到文件。
lib/Server.js
浏览文件 @
4a794f71
...
...
@@ -196,18 +196,20 @@ class Server extends EventEmitter
/**
* Create a Room instance
* @param {[Object]} options
* @param {[Boolean]} options.forceUniquePayloadTypes
* @return {Room}
*/
Room
()
Room
(
options
)
{
logger
.
debug
(
'Room()
'
);
logger
.
debug
(
'Room()
[options:%o]'
,
options
);
if
(
this
.
_closed
)
throw
new
errors
.
InvalidStateError
(
'Server closed'
);
let
worker
=
this
.
_getRandomWorker
();
return
worker
.
Room
();
return
worker
.
Room
(
options
);
}
_addWorker
(
worker
)
...
...
lib/Worker.js
浏览文件 @
4a794f71
...
...
@@ -152,9 +152,9 @@ class Worker extends EventEmitter
});
}
Room
()
Room
(
options
)
{
logger
.
debug
(
'Room()
'
);
logger
.
debug
(
'Room()
[options:%o]'
,
options
);
let
internal
=
{
...
...
@@ -168,7 +168,7 @@ class Worker extends EventEmitter
this
.
_rooms
.
add
(
room
);
room
.
on
(
'close'
,
()
=>
this
.
_rooms
.
delete
(
room
));
this
.
_channel
.
request
(
'worker.createRoom'
,
internal
)
this
.
_channel
.
request
(
'worker.createRoom'
,
internal
,
options
)
.
then
(()
=>
logger
.
debug
(
'"worker.createRoom" request succeeded'
))
.
catch
((
error
)
=>
{
...
...
worker/include/RTC/Room.h
浏览文件 @
4a794f71
...
...
@@ -25,8 +25,14 @@ namespace RTC
virtual
void
onRoomClosed
(
RTC
::
Room
*
room
)
=
0
;
};
private
:
struct
Options
{
bool
forceUniquePayloadTypes
=
false
;
};
public
:
Room
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
roomId
);
Room
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
roomId
,
Json
::
Value
&
data
);
virtual
~
Room
();
void
Close
();
...
...
@@ -55,6 +61,7 @@ namespace RTC
// Others.
std
::
unordered_map
<
uint32_t
,
RTC
::
Peer
*>
peers
;
std
::
unordered_map
<
RTC
::
RtpReceiver
*
,
std
::
unordered_set
<
RTC
::
RtpSender
*>>
mapRtpReceiverRtpSenders
;
Options
options
;
};
}
...
...
worker/src/Loop.cpp
浏览文件 @
4a794f71
...
...
@@ -198,7 +198,7 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
try
{
room
=
new
RTC
::
Room
(
this
,
this
->
notifier
,
roomId
);
room
=
new
RTC
::
Room
(
this
,
this
->
notifier
,
roomId
,
request
->
data
);
}
catch
(
const
MediaSoupError
&
error
)
{
...
...
worker/src/RTC/Room.cpp
浏览文件 @
4a794f71
...
...
@@ -10,12 +10,18 @@ namespace RTC
{
/* Instance methods. */
Room
::
Room
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
roomId
)
:
Room
::
Room
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
roomId
,
Json
::
Value
&
data
)
:
roomId
(
roomId
),
listener
(
listener
),
notifier
(
notifier
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_forceUniquePayloadTypes
(
"forceUniquePayloadTypes"
);
// `forceUniquePayloadTypes` is optional.
if
(
data
[
k_forceUniquePayloadTypes
].
isBool
())
this
->
options
.
forceUniquePayloadTypes
=
data
[
k_forceUniquePayloadTypes
].
asBool
();
}
Room
::~
Room
()
...
...
@@ -58,15 +64,25 @@ namespace RTC
MS_TRACE
();
static
const
Json
::
StaticString
k_roomId
(
"roomId"
);
static
const
Json
::
StaticString
k_options
(
"options"
);
static
const
Json
::
StaticString
k_forceUniquePayloadTypes
(
"forceUniquePayloadTypes"
);
static
const
Json
::
StaticString
k_peers
(
"peers"
);
static
const
Json
::
StaticString
k_mapRtpReceiverRtpSenders
(
"mapRtpReceiverRtpSenders"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json_options
(
Json
::
objectValue
);
Json
::
Value
json_peers
(
Json
::
objectValue
);
Json
::
Value
json_mapRtpReceiverRtpSenders
(
Json
::
objectValue
);
// Add `roomId`.
json
[
k_roomId
]
=
(
Json
::
UInt
)
this
->
roomId
;
// Add `options`.
json_options
[
k_forceUniquePayloadTypes
]
=
this
->
options
.
forceUniquePayloadTypes
;
json
[
k_options
]
=
json_options
;
// Add `peers`.
for
(
auto
&
kv
:
this
->
peers
)
{
RTC
::
Peer
*
peer
=
kv
.
second
;
...
...
@@ -89,6 +105,7 @@ namespace RTC
json_mapRtpReceiverRtpSenders
[
std
::
to_string
(
rtpReceiver
->
rtpReceiverId
)]
=
json_rtpReceivers
;
}
// Add `mapRtpReceiverRtpSenders`.
json
[
k_mapRtpReceiverRtpSenders
]
=
json_mapRtpReceiverRtpSenders
;
return
json
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论