mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-26 20:02:21 +08:00
添加停止、恢复rtp代理rtp超时检查功能
This commit is contained in:
@@ -28,6 +28,7 @@ RtpProcess::RtpProcess(const string &stream_id) {
|
||||
_media_info._vhost = DEFAULT_VHOST;
|
||||
_media_info._app = RTP_APP_NAME;
|
||||
_media_info._streamid = stream_id;
|
||||
_stop_rtp_check.store(false);
|
||||
|
||||
GET_CONFIG(string, dump_dir, RtpProxy::kDumpDir);
|
||||
{
|
||||
@@ -134,6 +135,8 @@ void RtpProcess::addTrackCompleted() {
|
||||
}
|
||||
|
||||
bool RtpProcess::alive() {
|
||||
if(_stop_rtp_check.load())
|
||||
return true;
|
||||
GET_CONFIG(int, timeoutSec, RtpProxy::kTimeoutSec)
|
||||
if (_last_frame_time.elapsedTime() / 1000 < timeoutSec) {
|
||||
return true;
|
||||
@@ -141,6 +144,10 @@ bool RtpProcess::alive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RtpProcess::setStopCheckRtp(bool is_check){
|
||||
_stop_rtp_check = is_check;
|
||||
}
|
||||
|
||||
void RtpProcess::onDetach() {
|
||||
if (_on_detach) {
|
||||
_on_detach();
|
||||
|
||||
@@ -53,6 +53,11 @@ public:
|
||||
*/
|
||||
void setOnDetach(const function<void()> &cb);
|
||||
|
||||
/**
|
||||
* 设置onDetach事件回调,false检查RTP超时,true停止
|
||||
*/
|
||||
void setStopCheckRtp(bool is_check=false);
|
||||
|
||||
/// SockInfo override
|
||||
string get_local_ip() override;
|
||||
uint16_t get_local_port() override;
|
||||
@@ -89,6 +94,7 @@ private:
|
||||
std::shared_ptr<FILE> _save_file_video;
|
||||
ProcessInterface::Ptr _process;
|
||||
MultiMediaSourceMuxer::Ptr _muxer;
|
||||
std::atomic_bool _stop_rtp_check;
|
||||
};
|
||||
|
||||
}//namespace mediakit
|
||||
|
||||
@@ -90,5 +90,16 @@ uint16_t RtpServer::getPort() {
|
||||
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
|
||||
#endif//defined(ENABLE_RTPPROXY)
|
||||
@@ -56,6 +56,14 @@ public:
|
||||
* 设置RtpProcess onDetach事件回调
|
||||
*/
|
||||
void setOnDetach(const function<void()> &cb);
|
||||
/**
|
||||
* 暂停Rtp服务的RTP流检测
|
||||
*/
|
||||
void pauseRtpCheck();
|
||||
/**
|
||||
* 暂停Rtp服务的RTP流检测
|
||||
*/
|
||||
void resumeRtpCheck();
|
||||
|
||||
protected:
|
||||
Socket::Ptr _udp_server;
|
||||
|
||||
@@ -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类型的播放端,那么就做超时检测
|
||||
shutdown(SockException(Err_timeout,"rtp over udp session timeouted"));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user