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
d208f697
Commit
d208f697
authored
Mar 28, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化推流器代码
parent
f6b963f0
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
23 行增加
和
29 行删除
+23
-29
src/Rtmp/RtmpPusher.cpp
+16
-6
src/Rtmp/RtmpPusher.h
+1
-13
src/Rtsp/RtspPusher.cpp
+6
-9
src/Rtsp/RtspPusher.h
+0
-1
没有找到文件。
src/Rtmp/RtmpPusher.cpp
查看文件 @
d208f697
...
...
@@ -63,6 +63,20 @@ void RtmpPusher::teardown() {
}
}
void
RtmpPusher
::
onPublishResult
(
const
SockException
&
ex
)
{
_pPublishTimer
.
reset
();
if
(
_onPublished
){
_onPublished
(
ex
);
_onPublished
=
nullptr
;
}
else
if
(
_onShutdown
){
_onShutdown
(
ex
);
}
if
(
ex
){
teardown
();
}
}
void
RtmpPusher
::
publish
(
const
string
&
strUrl
)
{
teardown
();
string
strHost
=
FindField
(
strUrl
.
data
(),
"://"
,
"/"
);
...
...
@@ -93,7 +107,6 @@ void RtmpPusher::publish(const string &strUrl) {
return
false
;
}
strongSelf
->
onPublishResult
(
SockException
(
Err_timeout
,
"publish rtmp timeout"
));
strongSelf
->
teardown
();
return
false
;
},
getPoller
()));
...
...
@@ -105,7 +118,7 @@ void RtmpPusher::publish(const string &strUrl) {
}
void
RtmpPusher
::
onErr
(
const
SockException
&
ex
){
on
Shutdown
(
ex
);
on
PublishResult
(
ex
);
}
void
RtmpPusher
::
onConnect
(
const
SockException
&
err
){
if
(
err
)
{
...
...
@@ -129,8 +142,6 @@ void RtmpPusher::onRecv(const Buffer::Ptr &pBuf){
}
catch
(
exception
&
e
)
{
SockException
ex
(
Err_other
,
e
.
what
());
onPublishResult
(
ex
);
onShutdown
(
ex
);
teardown
();
}
}
...
...
@@ -207,8 +218,7 @@ inline void RtmpPusher::send_metaData(){
_pRtmpReader
->
setDetachCB
([
weakSelf
](){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
strongSelf
){
strongSelf
->
onShutdown
(
SockException
(
Err_other
,
"媒体源被释放"
));
strongSelf
->
teardown
();
strongSelf
->
onPublishResult
(
SockException
(
Err_other
,
"媒体源被释放"
));
}
});
onPublishResult
(
SockException
(
Err_success
,
"success"
));
...
...
src/Rtmp/RtmpPusher.h
查看文件 @
d208f697
...
...
@@ -63,19 +63,7 @@ protected:
send
(
buffer
);
}
private
:
void
onShutdown
(
const
SockException
&
ex
)
{
_pPublishTimer
.
reset
();
if
(
_onShutdown
){
_onShutdown
(
ex
);
}
_pRtmpReader
.
reset
();
}
void
onPublishResult
(
const
SockException
&
ex
)
{
_pPublishTimer
.
reset
();
if
(
_onPublished
){
_onPublished
(
ex
);
}
}
void
onPublishResult
(
const
SockException
&
ex
);
template
<
typename
FUN
>
inline
void
addOnResultCB
(
const
FUN
&
fun
)
{
...
...
src/Rtsp/RtspPusher.cpp
查看文件 @
d208f697
...
...
@@ -62,17 +62,15 @@ void RtspPusher::publish(const string &strUrl) {
publish
(
url
,
user
,
pwd
,
eType
);
}
void
RtspPusher
::
onShutdown
(
const
SockException
&
ex
)
{
if
(
_onShutdown
){
_onShutdown
(
ex
);
}
teardown
();
}
void
RtspPusher
::
onPublishResult
(
const
SockException
&
ex
)
{
_pPublishTimer
.
reset
();
if
(
_onPublished
){
_onPublished
(
ex
);
_onPublished
=
nullptr
;
}
else
if
(
_onShutdown
){
_onShutdown
(
ex
);
}
if
(
ex
){
teardown
();
}
...
...
@@ -128,7 +126,7 @@ void RtspPusher::publish(const string & strUrl, const string &strUser, const str
}
void
RtspPusher
::
onErr
(
const
SockException
&
ex
)
{
on
Shutdown
(
ex
);
on
PublishResult
(
ex
);
}
void
RtspPusher
::
onConnect
(
const
SockException
&
err
)
{
...
...
@@ -145,7 +143,6 @@ void RtspPusher::onRecv(const Buffer::Ptr &pBuf){
}
catch
(
exception
&
e
)
{
SockException
ex
(
Err_other
,
e
.
what
());
onPublishResult
(
ex
);
onShutdown
(
ex
);
}
}
...
...
@@ -366,7 +363,7 @@ void RtspPusher::sendRecord() {
_pRtspReader
->
setDetachCB
([
weakSelf
](){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
strongSelf
){
strongSelf
->
on
Shutdown
(
SockException
(
Err_other
,
"媒体源被释放"
));
strongSelf
->
on
PublishResult
(
SockException
(
Err_other
,
"媒体源被释放"
));
}
});
if
(
_eType
!=
Rtsp
::
RTP_TCP
){
...
...
src/Rtsp/RtspPusher.h
查看文件 @
d208f697
...
...
@@ -50,7 +50,6 @@ protected:
void
onRtpPacket
(
const
char
*
data
,
uint64_t
len
)
override
{};
private
:
void
publish
(
const
string
&
strUrl
,
const
string
&
strUser
,
const
string
&
strPwd
,
Rtsp
::
eRtpType
eType
);
void
onShutdown
(
const
SockException
&
ex
);
void
onPublishResult
(
const
SockException
&
ex
);
void
sendAnnounce
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论