mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 12:11:36 +08:00
修复udp单端口模式下rtp鉴权失败后无法关闭流的问题(#2985)
如果rtp推流鉴权失败,在udp模式下延时断开连接,等待超时自动关闭,防止频繁创建销毁RtpSession对象, tcp模式则立即断开链接。
This commit is contained in:
parent
2a9a51af1f
commit
7865f2c360
@ -79,6 +79,9 @@ bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data
|
|||||||
WarnP(this) << "Not rtp packet";
|
WarnP(this) << "Not rtp packet";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!_auth_err.empty()) {
|
||||||
|
throw toolkit::SockException(toolkit::Err_other, _auth_err);
|
||||||
|
}
|
||||||
if (_sock != sock) {
|
if (_sock != sock) {
|
||||||
// 第一次运行本函数
|
// 第一次运行本函数
|
||||||
bool first = !_sock;
|
bool first = !_sock;
|
||||||
@ -260,6 +263,7 @@ void RtpProcess::emitOnPublish() {
|
|||||||
strong_self->doCachedFunc();
|
strong_self->doCachedFunc();
|
||||||
InfoP(strong_self) << "允许RTP推流";
|
InfoP(strong_self) << "允许RTP推流";
|
||||||
} else {
|
} else {
|
||||||
|
strong_self->_auth_err = err;
|
||||||
WarnP(strong_self) << "禁止RTP推流:" << err;
|
WarnP(strong_self) << "禁止RTP推流:" << err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -94,6 +94,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool _only_audio = false;
|
bool _only_audio = false;
|
||||||
|
std::string _auth_err;
|
||||||
uint64_t _dts = 0;
|
uint64_t _dts = 0;
|
||||||
uint64_t _total_bytes = 0;
|
uint64_t _total_bytes = 0;
|
||||||
std::unique_ptr<sockaddr_storage> _addr;
|
std::unique_ptr<sockaddr_storage> _addr;
|
||||||
|
@ -139,9 +139,16 @@ void RtpSession::onRtpPacket(const char *data, size_t len) {
|
|||||||
} else {
|
} else {
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (std::exception &ex) {
|
||||||
|
if (!_is_udp) {
|
||||||
|
// tcp情况下立即断开连接
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
// udp情况下延时断开连接(等待超时自动关闭),防止频繁创建销毁RtpSession对象
|
||||||
|
WarnP(this) << ex.what();
|
||||||
|
_delay_close = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
_ticker.resetTime();
|
_ticker.resetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user