修复RtpProcess析构中抛异常导致崩溃的问题 (#2714)

WarnP(this) 时会调用get_peer_ip()接口,此接口可能抛异常;
析构中抛异常可导致程序直接退出。
This commit is contained in:
夏楚 2023-07-29 13:24:07 +08:00 committed by GitHub
parent 73c8a5faf4
commit 00b3c5184a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,31 +210,27 @@ void RtpProcess::setOnDetach(function<void()> cb) {
}
string RtpProcess::get_peer_ip() {
if (!_addr) {
try {
return _addr ? SockUtil::inet_ntoa((sockaddr *)_addr.get()) : "::";
} catch (std::exception &ex) {
return "::";
}
return SockUtil::inet_ntoa((sockaddr *)_addr.get());
}
uint16_t RtpProcess::get_peer_port() {
if (!_addr) {
try {
return _addr ? SockUtil::inet_port((sockaddr *)_addr.get()) : 0;
} catch (std::exception &ex) {
return 0;
}
return SockUtil::inet_port((sockaddr *)_addr.get());
}
string RtpProcess::get_local_ip() {
if (_sock) {
return _sock->get_local_ip();
}
return "::";
return _sock ? _sock->get_local_ip() : "::";
}
uint16_t RtpProcess::get_local_port() {
if (_sock) {
return _sock->get_local_port();
}
return 0;
return _sock ? _sock->get_local_port() : 0;
}
string RtpProcess::getIdentifier() const {
@ -305,4 +301,4 @@ float RtpProcess::getLossRate(MediaSource &sender, TrackType type) {
}
}//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
#endif//defined(ENABLE_RTPPROXY)