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
fd9df3f5
Commit
fd9df3f5
authored
7 years ago
by
xzl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
防止线程竞争的bug
parent
53c2c92f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
5 行删除
+11
-5
src/Rtmp/RtmpPusher.cpp
+7
-3
src/Rtmp/RtmpPusher.h
+4
-2
没有找到文件。
src/Rtmp/RtmpPusher.cpp
查看文件 @
fd9df3f5
...
@@ -41,9 +41,12 @@ void RtmpPusher::teardown() {
...
@@ -41,9 +41,12 @@ void RtmpPusher::teardown() {
m_strApp
.
clear
();
m_strApp
.
clear
();
m_strStream
.
clear
();
m_strStream
.
clear
();
m_strTcUrl
.
clear
();
m_strTcUrl
.
clear
();
m_mapOnResultCB
.
clear
();
{
lock_guard
<
recursive_mutex
>
lck
(
m_mtxOnResultCB
);
m_mapOnResultCB
.
clear
();
}
{
{
lock_guard
<
recursive_mutex
>
lck
(
m_mtx
Deque
);
lock_guard
<
recursive_mutex
>
lck
(
m_mtx
OnStatusCB
);
m_dqOnStatusCB
.
clear
();
m_dqOnStatusCB
.
clear
();
}
}
m_pPlayTimer
.
reset
();
m_pPlayTimer
.
reset
();
...
@@ -198,6 +201,7 @@ inline void RtmpPusher::send_metaData(){
...
@@ -198,6 +201,7 @@ inline void RtmpPusher::send_metaData(){
}
}
void
RtmpPusher
::
onCmd_result
(
AMFDecoder
&
dec
){
void
RtmpPusher
::
onCmd_result
(
AMFDecoder
&
dec
){
auto
iReqId
=
dec
.
load
<
int
>
();
auto
iReqId
=
dec
.
load
<
int
>
();
lock_guard
<
recursive_mutex
>
lck
(
m_mtxOnResultCB
);
auto
it
=
m_mapOnResultCB
.
find
(
iReqId
);
auto
it
=
m_mapOnResultCB
.
find
(
iReqId
);
if
(
it
!=
m_mapOnResultCB
.
end
()){
if
(
it
!=
m_mapOnResultCB
.
end
()){
it
->
second
(
dec
);
it
->
second
(
dec
);
...
@@ -218,7 +222,7 @@ void RtmpPusher::onCmd_onStatus(AMFDecoder &dec) {
...
@@ -218,7 +222,7 @@ void RtmpPusher::onCmd_onStatus(AMFDecoder &dec) {
throw
std
::
runtime_error
(
"onStatus: 未找到结果对象"
);
throw
std
::
runtime_error
(
"onStatus: 未找到结果对象"
);
}
}
lock_guard
<
recursive_mutex
>
lck
(
m_mtx
Deque
);
lock_guard
<
recursive_mutex
>
lck
(
m_mtx
OnStatusCB
);
if
(
m_dqOnStatusCB
.
size
()){
if
(
m_dqOnStatusCB
.
size
()){
m_dqOnStatusCB
.
front
()(
val
);
m_dqOnStatusCB
.
front
()(
val
);
m_dqOnStatusCB
.
pop_front
();
m_dqOnStatusCB
.
pop_front
();
...
...
This diff is collapsed.
Click to expand it.
src/Rtmp/RtmpPusher.h
查看文件 @
fd9df3f5
...
@@ -53,11 +53,12 @@ private:
...
@@ -53,11 +53,12 @@ private:
template
<
typename
FUN
>
template
<
typename
FUN
>
inline
void
addOnResultCB
(
const
FUN
&
fun
)
{
inline
void
addOnResultCB
(
const
FUN
&
fun
)
{
lock_guard
<
recursive_mutex
>
lck
(
m_mtxOnResultCB
);
m_mapOnResultCB
.
emplace
(
m_iReqID
,
fun
);
m_mapOnResultCB
.
emplace
(
m_iReqID
,
fun
);
}
}
template
<
typename
FUN
>
template
<
typename
FUN
>
inline
void
addOnStatusCB
(
const
FUN
&
fun
)
{
inline
void
addOnStatusCB
(
const
FUN
&
fun
)
{
lock_guard
<
recursive_mutex
>
lck
(
m_mtx
Deque
);
lock_guard
<
recursive_mutex
>
lck
(
m_mtx
OnStatusCB
);
m_dqOnStatusCB
.
emplace_back
(
fun
);
m_dqOnStatusCB
.
emplace_back
(
fun
);
}
}
...
@@ -75,8 +76,9 @@ private:
...
@@ -75,8 +76,9 @@ private:
string
m_strTcUrl
;
string
m_strTcUrl
;
unordered_map
<
int
,
function
<
void
(
AMFDecoder
&
dec
)
>
>
m_mapOnResultCB
;
unordered_map
<
int
,
function
<
void
(
AMFDecoder
&
dec
)
>
>
m_mapOnResultCB
;
recursive_mutex
m_mtxOnResultCB
;
deque
<
function
<
void
(
AMFValue
&
dec
)
>
>
m_dqOnStatusCB
;
deque
<
function
<
void
(
AMFValue
&
dec
)
>
>
m_dqOnStatusCB
;
recursive_mutex
m_mtx
Deque
;
recursive_mutex
m_mtx
OnStatusCB
;
typedef
void
(
RtmpPusher
::*
rtmpCMDHandle
)(
AMFDecoder
&
dec
);
typedef
void
(
RtmpPusher
::*
rtmpCMDHandle
)(
AMFDecoder
&
dec
);
static
unordered_map
<
string
,
rtmpCMDHandle
>
g_mapCmd
;
static
unordered_map
<
string
,
rtmpCMDHandle
>
g_mapCmd
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论