bug fixed

This commit is contained in:
ziyue 2022-05-10 10:44:12 +08:00
parent d037acbf62
commit 45494c020b
2 changed files with 10 additions and 4 deletions

View File

@ -80,7 +80,7 @@ bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data
if (!_sock) {
//第一次运行本函数
_sock = sock;
_addr = *((struct sockaddr_storage *)addr);
_addr.reset(new sockaddr_storage(*((sockaddr_storage *)addr)));
emitOnPublish();
}
@ -198,11 +198,17 @@ void RtpProcess::setOnDetach(const function<void()> &cb) {
}
string RtpProcess::get_peer_ip() {
return SockUtil::inet_ntoa((struct sockaddr *)&_addr);
if (!_addr) {
return "::";
}
return SockUtil::inet_ntoa((sockaddr *)_addr.get());
}
uint16_t RtpProcess::get_peer_port() {
return SockUtil::inet_port((struct sockaddr *)&_addr);
if (!_addr) {
return 0;
}
return SockUtil::inet_port((sockaddr *)_addr.get());
}
string RtpProcess::get_local_ip() {

View File

@ -84,7 +84,7 @@ private:
private:
uint32_t _dts = 0;
uint64_t _total_bytes = 0;
struct sockaddr_storage _addr{0};
std::unique_ptr<sockaddr_storage> _addr;
toolkit::Socket::Ptr _sock;
MediaInfo _media_info;
toolkit::Ticker _last_frame_time;