Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
8352f119
Commit
8352f119
authored
Sep 07, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复webrtc MediaTrack对象循环引用导致内存泄露的问题
parent
209d47cf
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
10 行删除
+10
-10
webrtc/WebRtcTransport.cpp
+9
-9
webrtc/WebRtcTransport.h
+1
-1
没有找到文件。
webrtc/WebRtcTransport.cpp
查看文件 @
8352f119
...
@@ -441,7 +441,7 @@ void WebRtcTransportImp::onStartWebRTC() {
...
@@ -441,7 +441,7 @@ void WebRtcTransportImp::onStartWebRTC() {
//ssrc --> MediaTrack
//ssrc --> MediaTrack
auto
track
=
weak_track
.
lock
();
auto
track
=
weak_track
.
lock
();
assert
(
track
);
assert
(
track
);
_ssrc_to_track
[
ssrc
]
=
track
;
_ssrc_to_track
[
ssrc
]
=
std
::
move
(
track
)
;
InfoL
<<
"get rtp, pt:"
<<
(
int
)
pt
<<
", ssrc:"
<<
ssrc
<<
", rid:"
<<
rid
;
InfoL
<<
"get rtp, pt:"
<<
(
int
)
pt
<<
", ssrc:"
<<
ssrc
<<
", rid:"
<<
rid
;
});
});
...
@@ -750,20 +750,20 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) {
...
@@ -750,20 +750,20 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) {
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
void
WebRtcTransportImp
::
createRtpChannel
(
const
string
&
rid
,
uint32_t
ssrc
,
const
MediaTrack
::
Ptr
&
track
)
{
void
WebRtcTransportImp
::
createRtpChannel
(
const
string
&
rid
,
uint32_t
ssrc
,
MediaTrack
&
track
)
{
//rid --> RtpReceiverImp
//rid --> RtpReceiverImp
auto
&
ref
=
track
->
rtp_channel
[
rid
];
auto
&
ref
=
track
.
rtp_channel
[
rid
];
weak_ptr
<
WebRtcTransportImp
>
weak_self
=
dynamic_pointer_cast
<
WebRtcTransportImp
>
(
shared_from_this
());
weak_ptr
<
WebRtcTransportImp
>
weak_self
=
dynamic_pointer_cast
<
WebRtcTransportImp
>
(
shared_from_this
());
ref
=
std
::
make_shared
<
RtpChannel
>
(
getPoller
(),
[
track
,
this
,
rid
](
RtpPacket
::
Ptr
rtp
)
mutable
{
ref
=
std
::
make_shared
<
RtpChannel
>
(
getPoller
(),
[
&
track
,
this
,
rid
](
RtpPacket
::
Ptr
rtp
)
mutable
{
onSortedRtp
(
*
track
,
rid
,
std
::
move
(
rtp
));
onSortedRtp
(
track
,
rid
,
std
::
move
(
rtp
));
},
[
track
,
weak_self
,
ssrc
](
const
FCI_NACK
&
nack
)
mutable
{
},
[
&
track
,
weak_self
,
ssrc
](
const
FCI_NACK
&
nack
)
mutable
{
//nack发送可能由定时器异步触发
//nack发送可能由定时器异步触发
auto
strong_self
=
weak_self
.
lock
();
auto
strong_self
=
weak_self
.
lock
();
if
(
strong_self
)
{
if
(
strong_self
)
{
strong_self
->
onSendNack
(
*
track
,
nack
,
ssrc
);
strong_self
->
onSendNack
(
track
,
nack
,
ssrc
);
}
}
});
});
InfoL
<<
"create rtp receiver of ssrc:"
<<
ssrc
<<
", rid:"
<<
rid
<<
", codec:"
<<
track
->
plan_rtp
->
codec
;
InfoL
<<
"create rtp receiver of ssrc:"
<<
ssrc
<<
", rid:"
<<
rid
<<
", codec:"
<<
track
.
plan_rtp
->
codec
;
}
}
void
WebRtcTransportImp
::
onRtp
(
const
char
*
buf
,
size_t
len
)
{
void
WebRtcTransportImp
::
onRtp
(
const
char
*
buf
,
size_t
len
)
{
...
@@ -792,7 +792,7 @@ void WebRtcTransportImp::onRtp(const char *buf, size_t len) {
...
@@ -792,7 +792,7 @@ void WebRtcTransportImp::onRtp(const char *buf, size_t len) {
WarnL
<<
"unknown rtx rtp, rid:"
<<
rid
<<
", ssrc:"
<<
ssrc
<<
", codec:"
<<
track
->
plan_rtp
->
codec
<<
", seq:"
<<
ntohs
(
rtp
->
seq
);
WarnL
<<
"unknown rtx rtp, rid:"
<<
rid
<<
", ssrc:"
<<
ssrc
<<
", codec:"
<<
track
->
plan_rtp
->
codec
<<
", seq:"
<<
ntohs
(
rtp
->
seq
);
return
;
return
;
}
}
createRtpChannel
(
rid
,
ssrc
,
track
);
createRtpChannel
(
rid
,
ssrc
,
*
track
);
}
}
if
(
!
is_rtx
)
{
if
(
!
is_rtx
)
{
...
...
webrtc/WebRtcTransport.h
查看文件 @
8352f119
...
@@ -216,7 +216,7 @@ private:
...
@@ -216,7 +216,7 @@ private:
void
onSortedRtp
(
MediaTrack
&
track
,
const
string
&
rid
,
RtpPacket
::
Ptr
rtp
);
void
onSortedRtp
(
MediaTrack
&
track
,
const
string
&
rid
,
RtpPacket
::
Ptr
rtp
);
void
onSendNack
(
MediaTrack
&
track
,
const
FCI_NACK
&
nack
,
uint32_t
ssrc
);
void
onSendNack
(
MediaTrack
&
track
,
const
FCI_NACK
&
nack
,
uint32_t
ssrc
);
void
createRtpChannel
(
const
string
&
rid
,
uint32_t
ssrc
,
const
MediaTrack
::
Ptr
&
track
);
void
createRtpChannel
(
const
string
&
rid
,
uint32_t
ssrc
,
MediaTrack
&
track
);
private
:
private
:
bool
_simulcast
=
false
;
bool
_simulcast
=
false
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论