Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
6334d2ef
Unverified
提交
6334d2ef
authored
12月 09, 2022
作者:
Iñaki Baz Castillo
提交者:
GitHub
12月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix crash when using WebRtcServer (#970)
Authored-by:
penguinol
<
penguinol@163.com
>
上级
a765833b
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
79 行增加
和
35 行删除
+79
-35
Transport.hpp
worker/include/RTC/Transport.hpp
+3
-3
Transport.cpp
worker/src/RTC/Transport.cpp
+76
-32
没有找到文件。
worker/include/RTC/Transport.hpp
浏览文件 @
6334d2ef
...
@@ -307,10 +307,10 @@ namespace RTC
...
@@ -307,10 +307,10 @@ namespace RTC
absl
::
flat_hash_map
<
uint32_t
,
RTC
::
Consumer
*>
mapSsrcConsumer
;
absl
::
flat_hash_map
<
uint32_t
,
RTC
::
Consumer
*>
mapSsrcConsumer
;
absl
::
flat_hash_map
<
uint32_t
,
RTC
::
Consumer
*>
mapRtxSsrcConsumer
;
absl
::
flat_hash_map
<
uint32_t
,
RTC
::
Consumer
*>
mapRtxSsrcConsumer
;
Timer
*
rtcpTimer
{
nullptr
};
Timer
*
rtcpTimer
{
nullptr
};
RTC
::
TransportCongestionControlClient
*
tccClient
{
nullptr
};
std
::
shared_ptr
<
RTC
::
TransportCongestionControlClient
>
tccClient
{
nullptr
};
RTC
::
TransportCongestionControlServer
*
tccServer
{
nullptr
};
std
::
shared_ptr
<
RTC
::
TransportCongestionControlServer
>
tccServer
{
nullptr
};
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
RTC
::
SenderBandwidthEstimator
*
senderBwe
{
nullptr
};
std
::
shared_ptr
<
RTC
::
SenderBandwidthEstimator
>
senderBwe
{
nullptr
};
#endif
#endif
// Others.
// Others.
bool
direct
{
false
};
// Whether this Transport allows PayloadChannel comm.
bool
direct
{
false
};
// Whether this Transport allows PayloadChannel comm.
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
6334d2ef
...
@@ -228,20 +228,6 @@ namespace RTC
...
@@ -228,20 +228,6 @@ namespace RTC
// Delete the RTCP timer.
// Delete the RTCP timer.
delete
this
->
rtcpTimer
;
delete
this
->
rtcpTimer
;
this
->
rtcpTimer
=
nullptr
;
this
->
rtcpTimer
=
nullptr
;
// Delete Transport-CC client.
delete
this
->
tccClient
;
this
->
tccClient
=
nullptr
;
// Delete Transport-CC server.
delete
this
->
tccServer
;
this
->
tccServer
=
nullptr
;
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
// Delete Sender BWE.
delete
this
->
senderBwe
;
this
->
senderBwe
=
nullptr
;
#endif
}
}
void
Transport
::
CloseProducersAndConsumers
()
void
Transport
::
CloseProducersAndConsumers
()
...
@@ -809,7 +795,8 @@ namespace RTC
...
@@ -809,7 +795,8 @@ namespace RTC
if
(
createTccServer
)
if
(
createTccServer
)
{
{
this
->
tccServer
=
new
RTC
::
TransportCongestionControlServer
(
this
,
bweType
,
RTC
::
MtuSize
);
this
->
tccServer
=
std
::
make_shared
<
RTC
::
TransportCongestionControlServer
>
(
this
,
bweType
,
RTC
::
MtuSize
);
if
(
this
->
maxIncomingBitrate
!=
0u
)
if
(
this
->
maxIncomingBitrate
!=
0u
)
this
->
tccServer
->
SetMaxIncomingBitrate
(
this
->
maxIncomingBitrate
);
this
->
tccServer
->
SetMaxIncomingBitrate
(
this
->
maxIncomingBitrate
);
...
@@ -1014,7 +1001,7 @@ namespace RTC
...
@@ -1014,7 +1001,7 @@ namespace RTC
consumer
->
SetExternallyManagedBitrate
();
consumer
->
SetExternallyManagedBitrate
();
};
};
this
->
tccClient
=
new
RTC
::
TransportCongestionControlClient
(
this
->
tccClient
=
std
::
make_shared
<
RTC
::
TransportCongestionControlClient
>
(
this
,
bweType
,
this
->
initialAvailableOutgoingBitrate
,
this
->
maxOutgoingBitrate
);
this
,
bweType
,
this
->
initialAvailableOutgoingBitrate
,
this
->
maxOutgoingBitrate
);
if
(
IsConnected
())
if
(
IsConnected
())
...
@@ -1061,8 +1048,8 @@ namespace RTC
...
@@ -1061,8 +1048,8 @@ namespace RTC
consumer
->
SetExternallyManagedBitrate
();
consumer
->
SetExternallyManagedBitrate
();
};
};
this
->
senderBwe
=
this
->
senderBwe
=
std
::
make_shared
<
RTC
::
SenderBandwidthEstimator
>
(
new
RTC
::
SenderBandwidthEstimator
(
this
,
this
->
initialAvailableOutgoingBitrate
);
this
,
this
->
initialAvailableOutgoingBitrate
);
if
(
IsConnected
())
if
(
IsConnected
())
this
->
senderBwe
->
TransportConnected
();
this
->
senderBwe
->
TransportConnected
();
...
@@ -2528,7 +2515,6 @@ namespace RTC
...
@@ -2528,7 +2515,6 @@ namespace RTC
{
{
this
->
transportWideCcSeq
++
;
this
->
transportWideCcSeq
++
;
auto
*
tccClient
=
this
->
tccClient
;
webrtc
::
RtpPacketSendInfo
packetInfo
;
webrtc
::
RtpPacketSendInfo
packetInfo
;
packetInfo
.
ssrc
=
packet
->
GetSsrc
();
packetInfo
.
ssrc
=
packet
->
GetSsrc
();
...
@@ -2541,8 +2527,15 @@ namespace RTC
...
@@ -2541,8 +2527,15 @@ namespace RTC
// Indicate the pacer (and prober) that a packet is to be sent.
// Indicate the pacer (and prober) that a packet is to be sent.
this
->
tccClient
->
InsertPacket
(
packetInfo
);
this
->
tccClient
->
InsertPacket
(
packetInfo
);
// When using WebRtcServer, the lifecycle of a RTC::UdpSocket maybe longer
// than WebRtcTransport so there is a chance for the send callback to be
// invoked *after* the WebRtcTransport has been closed (freed). To avoid
// invalid memory access we need to use weak_ptr. Same applies in other
// send callbacks.
std
::
weak_ptr
<
RTC
::
TransportCongestionControlClient
>
tccClientWeakPtr
(
this
->
tccClient
);
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
auto
*
senderBwe
=
this
->
senderBwe
;
std
::
weak_ptr
<
RTC
::
SenderBandwidthEstimator
>
senderBweWeakPtr
(
this
->
senderBwe
)
;
RTC
::
SenderBandwidthEstimator
::
SentInfo
sentInfo
;
RTC
::
SenderBandwidthEstimator
::
SentInfo
sentInfo
;
sentInfo
.
wideSeq
=
this
->
transportWideCcSeq
;
sentInfo
.
wideSeq
=
this
->
transportWideCcSeq
;
...
@@ -2550,25 +2543,41 @@ namespace RTC
...
@@ -2550,25 +2543,41 @@ namespace RTC
sentInfo
.
sendingAtMs
=
DepLibUV
::
GetTimeMs
();
sentInfo
.
sendingAtMs
=
DepLibUV
::
GetTimeMs
();
auto
*
cb
=
new
onSendCallback
(
auto
*
cb
=
new
onSendCallback
(
[
tccClient
,
&
packetInfo
,
senderBwe
,
&
sentInfo
](
bool
sent
)
[
tccClient
WeakPtr
,
&
packetInfo
,
senderBweWeakPtr
,
&
sentInfo
](
bool
sent
)
{
{
if
(
sent
)
if
(
sent
)
{
auto
tccClient
=
tccClientWeakPtr
.
lock
();
if
(
tccClient
)
{
{
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
}
sentInfo
.
sentAtMs
=
DepLibUV
::
GetTimeMs
();
auto
senderBwe
=
senderBweWeakPtr
.
lock
();
if
(
senderBwe
)
{
sentInfo
.
sentAtMs
=
DepLibUV
::
GetTimeMs
();
senderBwe
->
RtpPacketSent
(
sentInfo
);
senderBwe
->
RtpPacketSent
(
sentInfo
);
}
}
}
});
});
SendRtpPacket
(
consumer
,
packet
,
cb
);
SendRtpPacket
(
consumer
,
packet
,
cb
);
#else
#else
const
auto
*
cb
=
new
onSendCallback
(
const
auto
*
cb
=
new
onSendCallback
(
[
tccClient
,
&
packetInfo
](
bool
sent
)
[
tccClient
WeakPtr
,
&
packetInfo
](
bool
sent
)
{
{
if
(
sent
)
if
(
sent
)
{
auto
tccClient
=
tccClientWeakPtr
.
lock
();
if
(
tccClient
)
{
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
}
}
});
});
SendRtpPacket
(
consumer
,
packet
,
cb
);
SendRtpPacket
(
consumer
,
packet
,
cb
);
...
@@ -2600,7 +2609,6 @@ namespace RTC
...
@@ -2600,7 +2609,6 @@ namespace RTC
{
{
this
->
transportWideCcSeq
++
;
this
->
transportWideCcSeq
++
;
auto
*
tccClient
=
this
->
tccClient
;
webrtc
::
RtpPacketSendInfo
packetInfo
;
webrtc
::
RtpPacketSendInfo
packetInfo
;
packetInfo
.
ssrc
=
packet
->
GetSsrc
();
packetInfo
.
ssrc
=
packet
->
GetSsrc
();
...
@@ -2613,8 +2621,10 @@ namespace RTC
...
@@ -2613,8 +2621,10 @@ namespace RTC
// Indicate the pacer (and prober) that a packet is to be sent.
// Indicate the pacer (and prober) that a packet is to be sent.
this
->
tccClient
->
InsertPacket
(
packetInfo
);
this
->
tccClient
->
InsertPacket
(
packetInfo
);
std
::
weak_ptr
<
RTC
::
TransportCongestionControlClient
>
tccClientWeakPtr
(
this
->
tccClient
);
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
auto
*
senderBwe
=
this
->
senderBwe
;
std
::
weak_ptr
<
RTC
::
SenderBandwidthEstimator
>
senderBweWeakPtr
=
this
->
senderBwe
;
RTC
::
SenderBandwidthEstimator
::
SentInfo
sentInfo
;
RTC
::
SenderBandwidthEstimator
::
SentInfo
sentInfo
;
sentInfo
.
wideSeq
=
this
->
transportWideCcSeq
;
sentInfo
.
wideSeq
=
this
->
transportWideCcSeq
;
...
@@ -2622,25 +2632,41 @@ namespace RTC
...
@@ -2622,25 +2632,41 @@ namespace RTC
sentInfo
.
sendingAtMs
=
DepLibUV
::
GetTimeMs
();
sentInfo
.
sendingAtMs
=
DepLibUV
::
GetTimeMs
();
auto
*
cb
=
new
onSendCallback
(
auto
*
cb
=
new
onSendCallback
(
[
tccClient
,
&
packetInfo
,
senderBwe
,
&
sentInfo
](
bool
sent
)
[
tccClient
WeakPtr
,
&
packetInfo
,
senderBweWeakPtr
,
&
sentInfo
](
bool
sent
)
{
{
if
(
sent
)
if
(
sent
)
{
auto
tccClient
=
tccClientWeakPtr
.
lock
();
if
(
tccClient
)
{
{
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
}
sentInfo
.
sentAtMs
=
DepLibUV
::
GetTimeMs
();
auto
senderBwe
=
senderBweWeakPtr
.
lock
();
if
(
senderBwe
)
{
sentInfo
.
sentAtMs
=
DepLibUV
::
GetTimeMs
();
senderBwe
->
RtpPacketSent
(
sentInfo
);
senderBwe
->
RtpPacketSent
(
sentInfo
);
}
}
}
});
});
SendRtpPacket
(
consumer
,
packet
,
cb
);
SendRtpPacket
(
consumer
,
packet
,
cb
);
#else
#else
const
auto
*
cb
=
new
onSendCallback
(
const
auto
*
cb
=
new
onSendCallback
(
[
tccClient
,
&
packetInfo
](
bool
sent
)
[
tccClient
WeakPtr
,
&
packetInfo
](
bool
sent
)
{
{
if
(
sent
)
if
(
sent
)
{
auto
tccClient
=
tccClientWeakPtr
.
lock
();
if
(
tccClient
)
{
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
}
}
});
});
SendRtpPacket
(
consumer
,
packet
,
cb
);
SendRtpPacket
(
consumer
,
packet
,
cb
);
...
@@ -2951,8 +2977,10 @@ namespace RTC
...
@@ -2951,8 +2977,10 @@ namespace RTC
// Indicate the pacer (and prober) that a packet is to be sent.
// Indicate the pacer (and prober) that a packet is to be sent.
this
->
tccClient
->
InsertPacket
(
packetInfo
);
this
->
tccClient
->
InsertPacket
(
packetInfo
);
std
::
weak_ptr
<
RTC
::
TransportCongestionControlClient
>
tccClientWeakPtr
(
this
->
tccClient
);
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
#ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR
auto
*
senderBwe
=
this
->
senderBwe
;
std
::
weak_ptr
<
RTC
::
SenderBandwidthEstimator
>
senderBweWeakPtr
=
this
->
senderBwe
;
RTC
::
SenderBandwidthEstimator
::
SentInfo
sentInfo
;
RTC
::
SenderBandwidthEstimator
::
SentInfo
sentInfo
;
sentInfo
.
wideSeq
=
this
->
transportWideCcSeq
;
sentInfo
.
wideSeq
=
this
->
transportWideCcSeq
;
...
@@ -2961,25 +2989,41 @@ namespace RTC
...
@@ -2961,25 +2989,41 @@ namespace RTC
sentInfo
.
sendingAtMs
=
DepLibUV
::
GetTimeMs
();
sentInfo
.
sendingAtMs
=
DepLibUV
::
GetTimeMs
();
auto
*
cb
=
new
onSendCallback
(
auto
*
cb
=
new
onSendCallback
(
[
tccClient
,
&
packetInfo
,
senderBwe
,
&
sentInfo
](
bool
sent
)
[
tccClient
WeakPtr
,
&
packetInfo
,
senderBweWeakPtr
,
&
sentInfo
](
bool
sent
)
{
{
if
(
sent
)
if
(
sent
)
{
auto
tccClient
=
tccClientWeakPtr
.
lock
();
if
(
tccClient
)
{
{
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
}
sentInfo
.
sentAtMs
=
DepLibUV
::
GetTimeMs
();
auto
senderBwe
=
senderBweWeakPtr
.
lock
();
if
(
senderBwe
)
{
sentInfo
.
sentAtMs
=
DepLibUV
::
GetTimeMs
();
senderBwe
->
RtpPacketSent
(
sentInfo
);
senderBwe
->
RtpPacketSent
(
sentInfo
);
}
}
}
});
});
SendRtpPacket
(
nullptr
,
packet
,
cb
);
SendRtpPacket
(
nullptr
,
packet
,
cb
);
#else
#else
const
auto
*
cb
=
new
onSendCallback
(
const
auto
*
cb
=
new
onSendCallback
(
[
tccClient
,
&
packetInfo
](
bool
sent
)
[
tccClient
WeakPtr
,
&
packetInfo
](
bool
sent
)
{
{
if
(
sent
)
if
(
sent
)
{
auto
tccClient
=
tccClientWeakPtr
.
lock
();
if
(
tccClient
)
{
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
tccClient
->
PacketSent
(
packetInfo
,
DepLibUV
::
GetTimeMsInt64
());
}
}
});
});
SendRtpPacket
(
nullptr
,
packet
,
cb
);
SendRtpPacket
(
nullptr
,
packet
,
cb
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论