Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
80d70719
提交
80d70719
authored
2月 11, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Room: got mapRtpReceiverRtpSenders.
上级
1db95262
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
65 行增加
和
13 行删除
+65
-13
Room.h
worker/include/RTC/Room.h
+1
-1
Loop.cpp
worker/src/Loop.cpp
+1
-1
Peer.cpp
worker/src/RTC/Peer.cpp
+8
-4
Room.cpp
worker/src/RTC/Room.cpp
+55
-7
没有找到文件。
worker/include/RTC/Room.h
浏览文件 @
80d70719
...
@@ -51,7 +51,7 @@ namespace RTC
...
@@ -51,7 +51,7 @@ namespace RTC
Channel
::
Notifier
*
notifier
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
// Others.
// Others.
std
::
unordered_map
<
uint32_t
,
RTC
::
Peer
*>
peers
;
std
::
unordered_map
<
uint32_t
,
RTC
::
Peer
*>
peers
;
std
::
unordered_map
<
RTC
::
RtpReceiver
*
,
std
::
unordered_set
<
RTC
::
RtpSender
*>>
mapR
eceiver
Senders
;
std
::
unordered_map
<
RTC
::
RtpReceiver
*
,
std
::
unordered_set
<
RTC
::
RtpSender
*>>
mapR
tpReceiverRtp
Senders
;
};
};
}
}
...
...
worker/src/Loop.cpp
浏览文件 @
80d70719
...
@@ -69,7 +69,7 @@ void Loop::Close()
...
@@ -69,7 +69,7 @@ void Loop::Close()
// Close all the Rooms.
// Close all the Rooms.
// NOTE: Upon Room closure the onRoomClosed() method is called which
// NOTE: Upon Room closure the onRoomClosed() method is called which
// removes it from the map, so this is the safe way to iterate the ma
o
// removes it from the map, so this is the safe way to iterate the ma
p
// and remove elements.
// and remove elements.
for
(
auto
it
=
this
->
rooms
.
begin
();
it
!=
this
->
rooms
.
end
();)
for
(
auto
it
=
this
->
rooms
.
begin
();
it
!=
this
->
rooms
.
end
();)
{
{
...
...
worker/src/RTC/Peer.cpp
浏览文件 @
80d70719
...
@@ -503,17 +503,21 @@ namespace RTC
...
@@ -503,17 +503,21 @@ namespace RTC
rtpListener
->
RemoveRtpReceiver
(
rtpReceiver
);
rtpListener
->
RemoveRtpReceiver
(
rtpReceiver
);
}
}
// TODO: Must notify the listener (Room) so it can remove this RtpReceiver.
// Remove from the map.
this
->
rtpReceivers
.
erase
(
rtpReceiver
->
rtpReceiverId
);
this
->
rtpReceivers
.
erase
(
rtpReceiver
->
rtpReceiverId
);
// Notify the listener (Room) so it can remove this RtpReceiver from its map.
this
->
listener
->
onPeerRtpReceiverClosed
(
this
,
rtpReceiver
);
}
}
void
Peer
::
onRtpSenderClosed
(
RTC
::
RtpSender
*
rtpSender
)
void
Peer
::
onRtpSenderClosed
(
RTC
::
RtpSender
*
rtpSender
)
{
{
MS_TRACE
();
MS_TRACE
();
// TODO: Must notify the listener (Room) so it can remove this RtpSender.
// Remove from the map.
this
->
rtpSenders
.
erase
(
rtpSender
->
rtpSenderId
);
this
->
rtpSenders
.
erase
(
rtpSender
->
rtpSenderId
);
// Notify the listener (Room) so it can remove this RtpSender from its map.
this
->
listener
->
onPeerRtpSenderClosed
(
this
,
rtpSender
);
}
}
}
}
worker/src/RTC/Room.cpp
浏览文件 @
80d70719
...
@@ -33,7 +33,7 @@ namespace RTC
...
@@ -33,7 +33,7 @@ namespace RTC
// Close all the Peers.
// Close all the Peers.
// NOTE: Upon Peer closure the onPeerClosed() method is called which
// NOTE: Upon Peer closure the onPeerClosed() method is called which
// removes it from the map, so this is the safe way to iterate the ma
o
// removes it from the map, so this is the safe way to iterate the ma
p
// and remove elements.
// and remove elements.
for
(
auto
it
=
this
->
peers
.
begin
();
it
!=
this
->
peers
.
end
();)
for
(
auto
it
=
this
->
peers
.
begin
();
it
!=
this
->
peers
.
end
();)
{
{
...
@@ -59,9 +59,11 @@ namespace RTC
...
@@ -59,9 +59,11 @@ namespace RTC
static
const
Json
::
StaticString
k_roomId
(
"roomId"
);
static
const
Json
::
StaticString
k_roomId
(
"roomId"
);
static
const
Json
::
StaticString
k_peers
(
"peers"
);
static
const
Json
::
StaticString
k_peers
(
"peers"
);
static
const
Json
::
StaticString
k_mapRtpReceiverRtpSenders
(
"mapRtpReceiverRtpSenders"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json_peers
(
Json
::
objectValue
);
Json
::
Value
json_peers
(
Json
::
objectValue
);
Json
::
Value
json_mapRtpReceiverRtpSenders
(
Json
::
objectValue
);
json
[
k_roomId
]
=
(
Json
::
UInt
)
this
->
roomId
;
json
[
k_roomId
]
=
(
Json
::
UInt
)
this
->
roomId
;
...
@@ -73,6 +75,22 @@ namespace RTC
...
@@ -73,6 +75,22 @@ namespace RTC
}
}
json
[
k_peers
]
=
json_peers
;
json
[
k_peers
]
=
json_peers
;
for
(
auto
&
kv
:
this
->
mapRtpReceiverRtpSenders
)
{
auto
rtpReceiver
=
kv
.
first
;
auto
&
rtpSenders
=
kv
.
second
;
Json
::
Value
json_rtpReceivers
(
Json
::
arrayValue
);
for
(
auto
&
rtpSender
:
rtpSenders
)
{
json_rtpReceivers
.
append
(
std
::
to_string
(
rtpSender
->
rtpSenderId
));
}
json_mapRtpReceiverRtpSenders
[
std
::
to_string
(
rtpReceiver
->
rtpReceiverId
)]
=
json_rtpReceivers
;
}
json
[
k_mapRtpReceiverRtpSenders
]
=
json_mapRtpReceiverRtpSenders
;
return
json
;
return
json
;
}
}
...
@@ -149,9 +167,6 @@ namespace RTC
...
@@ -149,9 +167,6 @@ namespace RTC
return
;
return
;
}
}
// Store the new Peer.
this
->
peers
[
peerId
]
=
peer
;
MS_DEBUG
(
"Peer created [peerId:%u, peerName:'%s']"
,
peerId
,
peerName
.
c_str
());
MS_DEBUG
(
"Peer created [peerId:%u, peerName:'%s']"
,
peerId
,
peerName
.
c_str
());
request
->
Accept
();
request
->
Accept
();
...
@@ -170,6 +185,9 @@ namespace RTC
...
@@ -170,6 +185,9 @@ namespace RTC
uint32_t
rtpSenderId
=
Utils
::
Crypto
::
GetRandomUInt
(
10000000
,
99999999
);
uint32_t
rtpSenderId
=
Utils
::
Crypto
::
GetRandomUInt
(
10000000
,
99999999
);
RTC
::
RtpSender
*
rtpSender
=
new
RTC
::
RtpSender
(
peer
,
this
->
notifier
,
rtpSenderId
);
RTC
::
RtpSender
*
rtpSender
=
new
RTC
::
RtpSender
(
peer
,
this
->
notifier
,
rtpSenderId
);
// Store into the map.
this
->
mapRtpReceiverRtpSenders
[
rtpReceiver
].
insert
(
rtpSender
);
// Clone receiver RtpParameters.
// Clone receiver RtpParameters.
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
...
@@ -180,6 +198,10 @@ namespace RTC
...
@@ -180,6 +198,10 @@ namespace RTC
}
}
}
}
// Store the new Peer.
// NOTE: Do it after iterating existing Peers.
this
->
peers
[
peerId
]
=
peer
;
break
;
break
;
}
}
...
@@ -271,7 +293,7 @@ namespace RTC
...
@@ -271,7 +293,7 @@ namespace RTC
MS_ASSERT
(
rtpReceiver
->
GetRtpParameters
(),
"rtpReceiver->GetRtpParameters() returns no RtpParameters"
);
MS_ASSERT
(
rtpReceiver
->
GetRtpParameters
(),
"rtpReceiver->GetRtpParameters() returns no RtpParameters"
);
// The RtpReceiver may already be set previously.
// The RtpReceiver may already be set previously.
bool
is_new_RtpReceiver
=
this
->
mapR
eceiverSenders
.
find
(
rtpReceiver
)
==
this
->
mapReceiver
Senders
.
end
();
bool
is_new_RtpReceiver
=
this
->
mapR
tpReceiverRtpSenders
.
find
(
rtpReceiver
)
==
this
->
mapRtpReceiverRtp
Senders
.
end
();
// If this is a new RtpReceiver, iterate all the peers but this one and
// If this is a new RtpReceiver, iterate all the peers but this one and
// create a RtpSender associated to this RtpReceiver for each Peer.
// create a RtpSender associated to this RtpReceiver for each Peer.
...
@@ -290,7 +312,7 @@ namespace RTC
...
@@ -290,7 +312,7 @@ namespace RTC
RTC
::
RtpSender
*
rtpSender
=
new
RTC
::
RtpSender
(
sender_peer
,
this
->
notifier
,
rtpSenderId
);
RTC
::
RtpSender
*
rtpSender
=
new
RTC
::
RtpSender
(
sender_peer
,
this
->
notifier
,
rtpSenderId
);
// Store into the map.
// Store into the map.
this
->
mapR
eceiver
Senders
[
rtpReceiver
].
insert
(
rtpSender
);
this
->
mapR
tpReceiverRtp
Senders
[
rtpReceiver
].
insert
(
rtpSender
);
// Clone RtpParameters.
// Clone RtpParameters.
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
...
@@ -306,7 +328,7 @@ namespace RTC
...
@@ -306,7 +328,7 @@ namespace RTC
// and update with them all the associated RtpSenders.
// and update with them all the associated RtpSenders.
else
else
{
{
for
(
auto
rtpSender
:
this
->
mapR
eceiver
Senders
[
rtpReceiver
])
for
(
auto
rtpSender
:
this
->
mapR
tpReceiverRtp
Senders
[
rtpReceiver
])
{
{
// Clone RtpParameters.
// Clone RtpParameters.
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
RTC
::
RtpParameters
*
rtpSenderParameters
=
new
RTC
::
RtpParameters
(
rtpReceiver
->
GetRtpParameters
());
...
@@ -324,11 +346,37 @@ namespace RTC
...
@@ -324,11 +346,37 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// If the RtpReceiver is in the map, iterate the map and close all the
// RtpSenders associated to the closed RtpReceiver.
if
(
this
->
mapRtpReceiverRtpSenders
.
find
(
rtpReceiver
)
!=
this
->
mapRtpReceiverRtpSenders
.
end
())
{
// Make a copy of the set of RtpSenders given that Close() will be called
// in all of them, producing onPeerRtpSenderClosed() that will remove it
// from the map.
auto
rtpSenders
=
this
->
mapRtpReceiverRtpSenders
[
rtpReceiver
];
// Safey iterate the copy of the set.
for
(
auto
&
rtpSender
:
rtpSenders
)
{
rtpSender
->
Close
();
}
// Finally delete the RtpReceiver entry in the map.
this
->
mapRtpReceiverRtpSenders
.
erase
(
rtpReceiver
);
}
}
}
void
Room
::
onPeerRtpSenderClosed
(
RTC
::
Peer
*
peer
,
RTC
::
RtpSender
*
rtpSender
)
void
Room
::
onPeerRtpSenderClosed
(
RTC
::
Peer
*
peer
,
RTC
::
RtpSender
*
rtpSender
)
{
{
MS_TRACE
();
MS_TRACE
();
// Iterate all the map and remove the closed RtpSender from all the
// RtpReceiver entries.
for
(
auto
&
kv
:
this
->
mapRtpReceiverRtpSenders
)
{
auto
&
rtpSenders
=
kv
.
second
;
rtpSenders
.
erase
(
rtpSender
);
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论