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
a09de232
Commit
a09de232
authored
3 years ago
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复调用mk_media_stop_send_rtp函数导致崩溃的bug
parent
4d0db1b7
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
17 行增加
和
13 行删除
+17
-13
api/source/mk_media.cpp
+3
-2
src/Common/MediaSource.h
+6
-5
src/Common/MultiMediaSourceMuxer.cpp
+8
-6
没有找到文件。
api/source/mk_media.cpp
查看文件 @
a09de232
...
@@ -193,7 +193,7 @@ API_EXPORT void API_CALL mk_media_start_send_rtp(mk_media ctx, const char *dst_u
...
@@ -193,7 +193,7 @@ API_EXPORT void API_CALL mk_media_start_send_rtp(mk_media ctx, const char *dst_u
assert
(
ctx
&&
dst_url
&&
ssrc
);
assert
(
ctx
&&
dst_url
&&
ssrc
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
//sender参数无用
//sender参数无用
(
*
obj
)
->
getChannel
()
->
startSendRtp
(
*
(
MediaSource
*
)
1
,
dst_url
,
dst_port
,
ssrc
,
is_udp
,
0
,
[
cb
,
user_data
](
uint16_t
local_port
,
const
SockException
&
ex
){
(
*
obj
)
->
getChannel
()
->
startSendRtp
(
*
MediaSource
::
NullMediaSource
,
dst_url
,
dst_port
,
ssrc
,
is_udp
,
0
,
[
cb
,
user_data
](
uint16_t
local_port
,
const
SockException
&
ex
){
if
(
cb
)
{
if
(
cb
)
{
cb
(
user_data
,
local_port
,
ex
.
getErrCode
(),
ex
.
what
());
cb
(
user_data
,
local_port
,
ex
.
getErrCode
(),
ex
.
what
());
}
}
...
@@ -204,5 +204,5 @@ API_EXPORT int API_CALL mk_media_stop_send_rtp(mk_media ctx){
...
@@ -204,5 +204,5 @@ API_EXPORT int API_CALL mk_media_stop_send_rtp(mk_media ctx){
assert
(
ctx
);
assert
(
ctx
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
//sender参数无用
//sender参数无用
return
(
*
obj
)
->
getChannel
()
->
stopSendRtp
(
*
(
MediaSource
*
)
1
,
""
);
return
(
*
obj
)
->
getChannel
()
->
stopSendRtp
(
*
MediaSource
::
NullMediaSource
,
""
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Common/MediaSource.h
查看文件 @
a09de232
...
@@ -191,11 +191,12 @@ private:
...
@@ -191,11 +191,12 @@ private:
*/
*/
class
MediaSource
:
public
TrackSource
,
public
enable_shared_from_this
<
MediaSource
>
{
class
MediaSource
:
public
TrackSource
,
public
enable_shared_from_this
<
MediaSource
>
{
public
:
public
:
typedef
std
::
shared_ptr
<
MediaSource
>
Ptr
;
static
constexpr
MediaSource
*
NullMediaSource
=
nullptr
;
typedef
unordered_map
<
string
,
weak_ptr
<
MediaSource
>
>
StreamMap
;
using
Ptr
=
std
::
shared_ptr
<
MediaSource
>
;
typedef
unordered_map
<
string
,
StreamMap
>
AppStreamMap
;
using
StreamMap
=
unordered_map
<
string
,
weak_ptr
<
MediaSource
>
>
;
typedef
unordered_map
<
string
,
AppStreamMap
>
VhostAppStreamMap
;
using
AppStreamMap
=
unordered_map
<
string
,
StreamMap
>
;
typedef
unordered_map
<
string
,
VhostAppStreamMap
>
SchemaVhostAppStreamMap
;
using
VhostAppStreamMap
=
unordered_map
<
string
,
AppStreamMap
>
;
using
SchemaVhostAppStreamMap
=
unordered_map
<
string
,
VhostAppStreamMap
>
;
MediaSource
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
)
;
MediaSource
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
)
;
virtual
~
MediaSource
()
;
virtual
~
MediaSource
()
;
...
...
This diff is collapsed.
Click to expand it.
src/Common/MultiMediaSourceMuxer.cpp
查看文件 @
a09de232
...
@@ -338,7 +338,7 @@ bool MultiMediaSourceMuxer::isRecording(MediaSource &sender, Recorder::type type
...
@@ -338,7 +338,7 @@ bool MultiMediaSourceMuxer::isRecording(MediaSource &sender, Recorder::type type
return
_muxer
->
isRecording
(
sender
,
type
);
return
_muxer
->
isRecording
(
sender
,
type
);
}
}
void
MultiMediaSourceMuxer
::
startSendRtp
(
MediaSource
&
sender
,
const
string
&
dst_url
,
uint16_t
dst_port
,
const
string
&
ssrc
,
bool
is_udp
,
uint16_t
src_port
,
const
function
<
void
(
uint16_t
local_port
,
const
SockException
&
ex
)
>
&
cb
){
void
MultiMediaSourceMuxer
::
startSendRtp
(
MediaSource
&
,
const
string
&
dst_url
,
uint16_t
dst_port
,
const
string
&
ssrc
,
bool
is_udp
,
uint16_t
src_port
,
const
function
<
void
(
uint16_t
local_port
,
const
SockException
&
ex
)
>
&
cb
){
#if defined(ENABLE_RTPPROXY)
#if defined(ENABLE_RTPPROXY)
RtpSender
::
Ptr
rtp_sender
=
std
::
make_shared
<
RtpSender
>
(
atoi
(
ssrc
.
data
()));
RtpSender
::
Ptr
rtp_sender
=
std
::
make_shared
<
RtpSender
>
(
atoi
(
ssrc
.
data
()));
weak_ptr
<
MultiMediaSourceMuxer
>
weak_self
=
shared_from_this
();
weak_ptr
<
MultiMediaSourceMuxer
>
weak_self
=
shared_from_this
();
...
@@ -360,12 +360,14 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const string &dst_
...
@@ -360,12 +360,14 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const string &dst_
#endif//ENABLE_RTPPROXY
#endif//ENABLE_RTPPROXY
}
}
bool
MultiMediaSourceMuxer
::
stopSendRtp
(
MediaSource
&
sender
,
const
string
&
ssrc
)
{
bool
MultiMediaSourceMuxer
::
stopSendRtp
(
MediaSource
&
sender
,
const
string
&
ssrc
)
{
#if defined(ENABLE_RTPPROXY)
#if defined(ENABLE_RTPPROXY)
onceToken
token
(
nullptr
,
[
&
]()
{
if
(
&
sender
!=
MediaSource
::
NullMediaSource
)
{
//关闭rtp推流,可能触发无人观看事件
onceToken
token
(
nullptr
,
[
&
]()
{
MediaSourceEventInterceptor
::
onReaderChanged
(
sender
,
totalReaderCount
());
//关闭rtp推流,可能触发无人观看事件
});
MediaSourceEventInterceptor
::
onReaderChanged
(
sender
,
totalReaderCount
());
});
}
if
(
ssrc
.
empty
())
{
if
(
ssrc
.
empty
())
{
//关闭全部
//关闭全部
lock_guard
<
mutex
>
lck
(
_rtp_sender_mtx
);
lock_guard
<
mutex
>
lck
(
_rtp_sender_mtx
);
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论