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
d611a189
Commit
d611a189
authored
Mar 25, 2023
by
xiongguangjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtmp repush replace pre pusher
parent
67d5ca02
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
50 行增加
和
21 行删除
+50
-21
src/Rtmp/RtmpSession.cpp
+44
-19
src/Rtsp/RtspSession.cpp
+6
-2
没有找到文件。
src/Rtmp/RtmpSession.cpp
查看文件 @
d611a189
...
...
@@ -11,6 +11,7 @@
#include "RtmpSession.h"
#include "Common/config.h"
#include "Util/onceToken.h"
#include "Network/Server.h"
using
namespace
std
;
using
namespace
toolkit
;
...
...
@@ -142,7 +143,24 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
_media_info
.
_schema
=
RTMP_SCHEMA
;
auto
now_stream_index
=
_now_stream_index
;
auto
on_res
=
[
this
,
token
,
now_stream_index
](
const
string
&
err
,
const
ProtocolOption
&
option
)
{
auto
on_res_push
=
[
this
](
ProtocolOption
option
){
if
(
!
_push_src
)
{
_push_src
=
std
::
make_shared
<
RtmpMediaSourceImp
>
(
_media_info
.
_vhost
,
_media_info
.
_app
,
_media_info
.
_streamid
);
//获取所有权
_push_src_ownership
=
_push_src
->
getOwnership
();
_push_src
->
setProtocolOption
(
option
);
}
_push_src
->
setListener
(
dynamic_pointer_cast
<
MediaSourceEvent
>
(
shared_from_this
()));
_continue_push_ms
=
option
.
continue_push_ms
;
sendStatus
({
"level"
,
"status"
,
"code"
,
"NetStream.Publish.Start"
,
"description"
,
"Started publishing stream."
,
"clientid"
,
"0"
});
setSocketFlags
();
};
auto
on_res
=
[
this
,
on_res_push
,
token
,
now_stream_index
](
const
string
&
err
,
const
ProtocolOption
&
option
)
{
_now_stream_index
=
now_stream_index
;
if
(
!
err
.
empty
())
{
sendStatus
({
"level"
,
"error"
,
...
...
@@ -156,10 +174,10 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
assert
(
!
_push_src
);
auto
src
=
MediaSource
::
find
(
RTMP_SCHEMA
,
_media_info
.
_vhost
,
_media_info
.
_app
,
_media_info
.
_streamid
);
auto
push_failed
=
(
bool
)
src
;
RtmpMediaSourceImp
::
Ptr
rtmp_src
;
while
(
src
)
{
//尝试断连后继续推流
auto
rtmp_src
=
dynamic_pointer_cast
<
RtmpMediaSourceImp
>
(
src
);
rtmp_src
=
dynamic_pointer_cast
<
RtmpMediaSourceImp
>
(
src
);
if
(
!
rtmp_src
)
{
//源不是rtmp推流产生的
break
;
...
...
@@ -175,7 +193,28 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
break
;
}
if
(
push_failed
)
{
if
(
push_failed
&&
rtmp_src
)
{
auto
sock
=
rtmp_src
->
getOriginSock
();
if
(
sock
){
auto
session
=
SessionMap
::
Instance
().
get
(
sock
->
getIdentifier
());
if
(
session
){
session
->
getPoller
()
->
async_first
([
this
,
rtmp_src
,
on_res_push
,
option
,
session
](){
session
->
shutdown
(
SockException
(
Err_eof
,
"other pusher kick session"
));
_push_src_ownership
=
rtmp_src
->
getOwnership
();
if
(
_push_src_ownership
){
_push_src
=
std
::
move
(
rtmp_src
);
}
else
{
WarnL
<<
"not reach this"
;
}
this
->
getPoller
()
->
async_first
([
option
,
on_res_push
](){
on_res_push
(
option
);
});
});
return
;
}
else
{
TraceL
;
}
}
sendStatus
({
"level"
,
"error"
,
"code"
,
"NetStream.Publish.BadName"
,
"description"
,
"Already publishing."
,
...
...
@@ -184,21 +223,7 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
return
;
}
if
(
!
_push_src
)
{
_push_src
=
std
::
make_shared
<
RtmpMediaSourceImp
>
(
_media_info
.
_vhost
,
_media_info
.
_app
,
_media_info
.
_streamid
);
//获取所有权
_push_src_ownership
=
_push_src
->
getOwnership
();
_push_src
->
setProtocolOption
(
option
);
}
_push_src
->
setListener
(
dynamic_pointer_cast
<
MediaSourceEvent
>
(
shared_from_this
()));
_continue_push_ms
=
option
.
continue_push_ms
;
sendStatus
({
"level"
,
"status"
,
"code"
,
"NetStream.Publish.Start"
,
"description"
,
"Started publishing stream."
,
"clientid"
,
"0"
});
setSocketFlags
();
on_res_push
(
option
);
};
if
(
_media_info
.
_app
.
empty
()
||
_media_info
.
_streamid
.
empty
()){
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
d611a189
...
...
@@ -287,9 +287,13 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
if
(
session
&&
rtsp_session
){
rtsp_src_imp
=
rtsp_session
->
getPushSrc
();
session
->
getPoller
()
->
async_first
([
this
,
rtsp_src
,
option
,
rtsp_src_imp
,
onResPushSrc
,
session
](){
session
->
shutdown
(
SockException
(
Err_
shutdown
,
"other pusher kick session"
));
session
->
shutdown
(
SockException
(
Err_
eof
,
"other pusher kick session"
));
_push_src_ownership
=
rtsp_src_imp
->
getOwnership
();
_push_src
=
std
::
move
(
rtsp_src_imp
);
if
(
_push_src_ownership
){
_push_src
=
std
::
move
(
rtsp_src_imp
);
}
else
{
WarnL
<<
"not reach this"
;
}
this
->
getPoller
()
->
async_first
([
option
,
onResPushSrc
](){
onResPushSrc
(
option
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论