mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-03-09 23:50:56 +08:00
优化pauseRtpCheck接口,新增pause_seconds参数
This commit is contained in:
@@ -203,27 +203,24 @@ void RtpProcess::doCachedFunc() {
|
||||
}
|
||||
|
||||
bool RtpProcess::alive() {
|
||||
if (_stop_rtp_check.load()) {
|
||||
if(_last_check_alive.elapsedTime() > 5 * 60 * 1000){
|
||||
// 最多暂停5分钟的rtp超时检测,因为NAT映射有效期一般不会太长 [AUTO-TRANSLATED:2df59aad]
|
||||
// Pause the RTP timeout detection for a maximum of 5 minutes, because the NAT mapping validity period is generally not very long.
|
||||
_stop_rtp_check = false;
|
||||
} else {
|
||||
if (_pause_timeout) {
|
||||
if (_last_check_alive.elapsedTime() < _pause_seconds * 1000) {
|
||||
return true;
|
||||
}
|
||||
// 最多暂停_pause_seconds秒的rtp超时检测,因为NAT映射有效期一般不会太长
|
||||
_pause_timeout = false;
|
||||
}
|
||||
|
||||
_last_check_alive.resetTime();
|
||||
GET_CONFIG(uint64_t, timeoutSec, RtpProxy::kTimeoutSec)
|
||||
if (_last_frame_time.elapsedTime() / 1000 < timeoutSec) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return _last_frame_time.elapsedTime() < timeoutSec * 1000;
|
||||
}
|
||||
|
||||
void RtpProcess::setStopCheckRtp(bool is_check){
|
||||
_stop_rtp_check = is_check;
|
||||
if (!is_check) {
|
||||
void RtpProcess::pauseRtpTimeout(bool pause, uint32_t pause_seconds) {
|
||||
_pause_timeout = pause;
|
||||
// 默认5分钟恢复超时监测
|
||||
_pause_seconds = pause_seconds ? pause_seconds : 300;
|
||||
if (!pause) {
|
||||
_last_frame_time.resetTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +69,11 @@ public:
|
||||
void setOnDetach(onDetachCB cb);
|
||||
|
||||
/**
|
||||
* 设置onDetach事件回调,false检查RTP超时,true停止
|
||||
* Set onDetach event callback, false checks RTP timeout, true stops
|
||||
|
||||
* [AUTO-TRANSLATED:2780397f]
|
||||
* 暂停或恢复rtp超时监测
|
||||
* @param pause 是否暂停超时检测
|
||||
* @param pause_seconds 暂停超时检测最大时间(单位秒),超过这个时间后将恢复超时检测; 设置为0时默认为300
|
||||
*/
|
||||
void setStopCheckRtp(bool is_check=false);
|
||||
void pauseRtpTimeout(bool pause, uint32_t pause_seconds = 0);
|
||||
|
||||
/**
|
||||
* 设置为单track,单音频/单视频时可以加快媒体注册速度
|
||||
@@ -129,10 +128,12 @@ private:
|
||||
void createTimer();
|
||||
|
||||
private:
|
||||
OnlyTrack _only_track = kAll;
|
||||
std::string _auth_err;
|
||||
bool _pause_timeout = false;
|
||||
uint32_t _pause_seconds = 5 * 60;
|
||||
uint64_t _dts = 0;
|
||||
uint64_t _total_bytes = 0;
|
||||
OnlyTrack _only_track = kAll;
|
||||
std::string _auth_err;
|
||||
std::unique_ptr<sockaddr_storage> _addr;
|
||||
toolkit::Socket::Ptr _sock;
|
||||
MediaInfo _media_info;
|
||||
@@ -142,7 +143,6 @@ private:
|
||||
std::shared_ptr<FILE> _save_file_video;
|
||||
ProcessInterface::Ptr _process;
|
||||
MultiMediaSourceMuxer::Ptr _muxer;
|
||||
std::atomic_bool _stop_rtp_check{false};
|
||||
toolkit::Timer::Ptr _timer;
|
||||
toolkit::Ticker _last_check_alive;
|
||||
std::recursive_mutex _func_mtx;
|
||||
|
||||
Reference in New Issue
Block a user