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
537ae2f4
Unverified
Commit
537ae2f4
authored
Dec 27, 2020
by
夏楚
Committed by
GitHub
Dec 27, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #651 from sunhui2013/master
添加停止、恢复rtp代理rtp超时检查功能,解决播放器暂停后断流问题
parents
fd15fe70
cbc1f919
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
127 行增加
和
1 行删除
+127
-1
postman/ZLMediaKit.postman_collection.json
+62
-0
server/WebApi.cpp
+31
-0
src/Rtp/RtpProcess.cpp
+7
-0
src/Rtp/RtpProcess.h
+6
-0
src/Rtp/RtpServer.cpp
+12
-0
src/Rtp/RtpServer.h
+8
-0
src/Rtsp/RtspSession.cpp
+1
-1
没有找到文件。
postman/ZLMediaKit.postman_collection.json
查看文件 @
537ae2f4
...
@@ -1024,6 +1024,68 @@
...
@@ -1024,6 +1024,68 @@
"response"
:
[]
"response"
:
[]
},
},
{
{
"name"
:
"暂停RTP超时检查(pauseRtpCheck)"
,
"request"
:
{
"method"
:
"GET"
,
"header"
:
[],
"url"
:
{
"raw"
:
"{{ZLMediaKit_URL}}/index/api/pauseRtpCheck?secret={{ZLMediaKit_secret}}&stream_id=test"
,
"host"
:
[
"{{ZLMediaKit_URL}}"
],
"path"
:
[
"index"
,
"api"
,
"pauseRtpCheck"
],
"query"
:
[
{
"key"
:
"secret"
,
"value"
:
"{{ZLMediaKit_secret}}"
,
"description"
:
"api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数"
},
{
"key"
:
"stream_id"
,
"value"
:
"test"
,
"description"
:
"该端口绑定的流id"
}
]
}
},
"response"
:
[]
},
{
"name"
:
"恢复RTP超时检查(resumeRtpCheck)"
,
"request"
:
{
"method"
:
"GET"
,
"header"
:
[],
"url"
:
{
"raw"
:
"{{ZLMediaKit_URL}}/index/api/resumeRtpCheck?secret={{ZLMediaKit_secret}}&stream_id=test"
,
"host"
:
[
"{{ZLMediaKit_URL}}"
],
"path"
:
[
"index"
,
"api"
,
"resumeRtpCheck"
],
"query"
:
[
{
"key"
:
"secret"
,
"value"
:
"{{ZLMediaKit_secret}}"
,
"description"
:
"api操作密钥(配置文件配置),如果操作ip是127.0.0.1,则不需要此参数"
},
{
"key"
:
"stream_id"
,
"value"
:
"test"
,
"description"
:
"该端口绑定的流id"
}
]
}
},
"response"
:
[]
},
{
"name"
:
"获取RTP服务器列表(listRtpServer)"
,
"name"
:
"获取RTP服务器列表(listRtpServer)"
,
"request"
:
{
"request"
:
{
"method"
:
"GET"
,
"method"
:
"GET"
,
...
...
server/WebApi.cpp
查看文件 @
537ae2f4
...
@@ -875,6 +875,37 @@ void installWebApi() {
...
@@ -875,6 +875,37 @@ void installWebApi() {
}
}
});
});
api_regist1
(
"/index/api/pauseRtpCheck"
,
[](
API_ARGS1
)
{
CHECK_SECRET
();
CHECK_ARGS
(
"stream_id"
);
//只是暂停流的检查,流媒体服务器做为流负载服务,收流就转发,RTSP/RTMP有自己暂停协议
lock_guard
<
recursive_mutex
>
lck
(
s_rtpServerMapMtx
);
auto
it
=
s_rtpServerMap
.
find
(
allArgs
[
"stream_id"
]);
if
(
it
==
s_rtpServerMap
.
end
())
{
val
[
"hit"
]
=
0
;
return
;
}
auto
server
=
it
->
second
;
server
->
pauseRtpCheck
();
val
[
"hit"
]
=
1
;
});
api_regist1
(
"/index/api/resumeRtpCheck"
,
[](
API_ARGS1
)
{
CHECK_SECRET
();
CHECK_ARGS
(
"stream_id"
);
lock_guard
<
recursive_mutex
>
lck
(
s_rtpServerMapMtx
);
auto
it
=
s_rtpServerMap
.
find
(
allArgs
[
"stream_id"
]);
if
(
it
==
s_rtpServerMap
.
end
())
{
val
[
"hit"
]
=
0
;
return
;
}
auto
server
=
it
->
second
;
server
->
resumeRtpCheck
();
val
[
"hit"
]
=
1
;
});
#endif//ENABLE_RTPPROXY
#endif//ENABLE_RTPPROXY
...
...
src/Rtp/RtpProcess.cpp
查看文件 @
537ae2f4
...
@@ -28,6 +28,7 @@ RtpProcess::RtpProcess(const string &stream_id) {
...
@@ -28,6 +28,7 @@ RtpProcess::RtpProcess(const string &stream_id) {
_media_info
.
_vhost
=
DEFAULT_VHOST
;
_media_info
.
_vhost
=
DEFAULT_VHOST
;
_media_info
.
_app
=
RTP_APP_NAME
;
_media_info
.
_app
=
RTP_APP_NAME
;
_media_info
.
_streamid
=
stream_id
;
_media_info
.
_streamid
=
stream_id
;
_stop_rtp_check
.
store
(
false
);
GET_CONFIG
(
string
,
dump_dir
,
RtpProxy
::
kDumpDir
);
GET_CONFIG
(
string
,
dump_dir
,
RtpProxy
::
kDumpDir
);
{
{
...
@@ -134,6 +135,8 @@ void RtpProcess::addTrackCompleted() {
...
@@ -134,6 +135,8 @@ void RtpProcess::addTrackCompleted() {
}
}
bool
RtpProcess
::
alive
()
{
bool
RtpProcess
::
alive
()
{
if
(
_stop_rtp_check
.
load
())
return
true
;
GET_CONFIG
(
int
,
timeoutSec
,
RtpProxy
::
kTimeoutSec
)
GET_CONFIG
(
int
,
timeoutSec
,
RtpProxy
::
kTimeoutSec
)
if
(
_last_frame_time
.
elapsedTime
()
/
1000
<
timeoutSec
)
{
if
(
_last_frame_time
.
elapsedTime
()
/
1000
<
timeoutSec
)
{
return
true
;
return
true
;
...
@@ -141,6 +144,10 @@ bool RtpProcess::alive() {
...
@@ -141,6 +144,10 @@ bool RtpProcess::alive() {
return
false
;
return
false
;
}
}
void
RtpProcess
::
setStopCheckRtp
(
bool
is_check
){
_stop_rtp_check
=
is_check
;
}
void
RtpProcess
::
onDetach
()
{
void
RtpProcess
::
onDetach
()
{
if
(
_on_detach
)
{
if
(
_on_detach
)
{
_on_detach
();
_on_detach
();
...
...
src/Rtp/RtpProcess.h
查看文件 @
537ae2f4
...
@@ -53,6 +53,11 @@ public:
...
@@ -53,6 +53,11 @@ public:
*/
*/
void
setOnDetach
(
const
function
<
void
()
>
&
cb
);
void
setOnDetach
(
const
function
<
void
()
>
&
cb
);
/**
* 设置onDetach事件回调,false检查RTP超时,true停止
*/
void
setStopCheckRtp
(
bool
is_check
=
false
);
/// SockInfo override
/// SockInfo override
string
get_local_ip
()
override
;
string
get_local_ip
()
override
;
uint16_t
get_local_port
()
override
;
uint16_t
get_local_port
()
override
;
...
@@ -89,6 +94,7 @@ private:
...
@@ -89,6 +94,7 @@ private:
std
::
shared_ptr
<
FILE
>
_save_file_video
;
std
::
shared_ptr
<
FILE
>
_save_file_video
;
ProcessInterface
::
Ptr
_process
;
ProcessInterface
::
Ptr
_process
;
MultiMediaSourceMuxer
::
Ptr
_muxer
;
MultiMediaSourceMuxer
::
Ptr
_muxer
;
std
::
atomic_bool
_stop_rtp_check
;
};
};
}
//namespace mediakit
}
//namespace mediakit
...
...
src/Rtp/RtpServer.cpp
查看文件 @
537ae2f4
...
@@ -90,5 +90,16 @@ uint16_t RtpServer::getPort() {
...
@@ -90,5 +90,16 @@ uint16_t RtpServer::getPort() {
return
_udp_server
?
_udp_server
->
get_local_port
()
:
0
;
return
_udp_server
?
_udp_server
->
get_local_port
()
:
0
;
}
}
void
RtpServer
::
pauseRtpCheck
(){
if
(
_rtp_process
)
_rtp_process
->
setStopCheckRtp
(
true
);
}
void
RtpServer
::
resumeRtpCheck
(){
if
(
_rtp_process
)
_rtp_process
->
setStopCheckRtp
(
false
);
}
}
//namespace mediakit
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/RtpServer.h
查看文件 @
537ae2f4
...
@@ -56,6 +56,14 @@ public:
...
@@ -56,6 +56,14 @@ public:
* 设置RtpProcess onDetach事件回调
* 设置RtpProcess onDetach事件回调
*/
*/
void
setOnDetach
(
const
function
<
void
()
>
&
cb
);
void
setOnDetach
(
const
function
<
void
()
>
&
cb
);
/**
* 暂停Rtp服务的RTP流检测
*/
void
pauseRtpCheck
();
/**
* 恢复Rtp服务的RTP流检测
*/
void
resumeRtpCheck
();
protected
:
protected
:
Socket
::
Ptr
_udp_server
;
Socket
::
Ptr
_udp_server
;
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
537ae2f4
...
@@ -106,7 +106,7 @@ void RtspSession::onManager() {
...
@@ -106,7 +106,7 @@ void RtspSession::onManager() {
}
}
}
}
if
((
_rtp_type
==
Rtsp
::
RTP_UDP
||
_push_src
)
&&
_alive_ticker
.
elapsedTime
()
>
keep_alive_sec
*
1000
)
{
if
((
_rtp_type
==
Rtsp
::
RTP_UDP
||
_push_src
)
&&
_alive_ticker
.
elapsedTime
()
>
keep_alive_sec
*
1000
&&
_enable_send_rtp
)
{
//如果是推流端或者rtp over udp类型的播放端,那么就做超时检测
//如果是推流端或者rtp over udp类型的播放端,那么就做超时检测
shutdown
(
SockException
(
Err_timeout
,
"rtp over udp session timeouted"
));
shutdown
(
SockException
(
Err_timeout
,
"rtp over udp session timeouted"
));
return
;
return
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论