Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
d6684542
Commit
d6684542
authored
May 08, 2022
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善ipv6网络适配
parent
3062ea0e
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
57 行增加
和
73 行删除
+57
-73
3rdpart/ZLToolKit
+1
-1
src/Rtp/RtpProcess.cpp
+3
-3
src/Rtp/RtpProcess.h
+1
-1
src/Rtp/RtpServer.cpp
+7
-4
src/Rtp/RtpSession.cpp
+2
-2
src/Rtp/RtpSession.h
+1
-1
src/Rtsp/RtspPlayer.cpp
+17
-23
src/Rtsp/RtspPusher.cpp
+7
-12
src/Rtsp/RtspSession.cpp
+10
-17
src/Rtsp/RtspSession.h
+1
-1
src/Rtsp/UDPServer.cpp
+1
-2
tests/test_rtp.cpp
+2
-2
webrtc/WebRtcSession.cpp
+2
-2
webrtc/WebRtcSession.h
+1
-1
webrtc/WebRtcTransport.cpp
+1
-1
没有找到文件。
ZLToolKit
@
d1bd0e54
Subproject commit
442f682b1aebc67ee60a1c43718b8bf66e3c1667
Subproject commit
d1bd0e5459f5138b59d8e012ef148b0f562d1f29
src/Rtp/RtpProcess.cpp
查看文件 @
d6684542
...
...
@@ -80,7 +80,7 @@ bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data
if
(
!
_sock
)
{
//第一次运行本函数
_sock
=
sock
;
_addr
=
*
addr
;
_addr
=
*
((
struct
sockaddr_storage
*
)
addr
)
;
emitOnPublish
();
}
...
...
@@ -198,11 +198,11 @@ void RtpProcess::setOnDetach(const function<void()> &cb) {
}
string
RtpProcess
::
get_peer_ip
()
{
return
SockUtil
::
inet_ntoa
((
(
struct
sockaddr_in
&
)
_addr
).
sin
_addr
);
return
SockUtil
::
inet_ntoa
((
struct
sockaddr
*
)
&
_addr
);
}
uint16_t
RtpProcess
::
get_peer_port
()
{
return
ntohs
(((
struct
sockaddr_in
&
)
_addr
).
sin_port
);
return
SockUtil
::
inet_port
((
struct
sockaddr
*
)
&
_addr
);
}
string
RtpProcess
::
get_local_ip
()
{
...
...
src/Rtp/RtpProcess.h
查看文件 @
d6684542
...
...
@@ -84,7 +84,7 @@ private:
private
:
uint32_t
_dts
=
0
;
uint64_t
_total_bytes
=
0
;
struct
sockaddr
_addr
{
0
};
struct
sockaddr
_storage
_addr
{
0
};
toolkit
::
Socket
::
Ptr
_sock
;
MediaInfo
_media_info
;
toolkit
::
Ticker
_last_frame_time
;
...
...
src/Rtp/RtpServer.cpp
查看文件 @
d6684542
...
...
@@ -53,7 +53,7 @@ public:
}
if
(
!
strong_self
->
_rtcp_addr
)
{
//只设置一次rtcp对端端口
strong_self
->
_rtcp_addr
=
std
::
make_shared
<
struct
sockaddr
>
();
strong_self
->
_rtcp_addr
=
std
::
make_shared
<
struct
sockaddr
_storage
>
();
memcpy
(
strong_self
->
_rtcp_addr
.
get
(),
addr
,
addr_len
);
}
auto
rtcps
=
RtcpHeader
::
loadFromBytes
(
buf
->
data
(),
buf
->
size
());
...
...
@@ -71,10 +71,13 @@ private:
}
_ticker
.
resetTime
();
auto
rtcp_addr
=
_rtcp_addr
.
get
();
auto
rtcp_addr
=
(
struct
sockaddr
*
)
_rtcp_addr
.
get
();
if
(
!
rtcp_addr
)
{
//默认的,rtcp端口为rtp端口+1
((
sockaddr_in
*
)
addr
)
->
sin_port
=
htons
(
ntohs
(((
sockaddr_in
*
)
addr
)
->
sin_port
)
+
1
);
switch
(
addr
->
sa_family
){
case
AF_INET
:
((
sockaddr_in
*
)
addr
)
->
sin_port
=
htons
(
ntohs
(((
sockaddr_in
*
)
addr
)
->
sin_port
)
+
1
);
break
;
case
AF_INET6
:
((
sockaddr_in6
*
)
addr
)
->
sin6_port
=
htons
(
ntohs
(((
sockaddr_in6
*
)
addr
)
->
sin6_port
)
+
1
);
break
;
}
//未收到rtcp打洞包时,采用默认的rtcp端口
rtcp_addr
=
addr
;
}
...
...
@@ -85,7 +88,7 @@ private:
Ticker
_ticker
;
Socket
::
Ptr
_rtcp_sock
;
uint32_t
_sample_rate
;
std
::
shared_ptr
<
struct
sockaddr
>
_rtcp_addr
;
std
::
shared_ptr
<
struct
sockaddr
_storage
>
_rtcp_addr
;
};
void
RtpServer
::
start
(
uint16_t
local_port
,
const
string
&
stream_id
,
bool
enable_tcp
,
const
char
*
local_ip
,
bool
re_use_port
,
uint32_t
ssrc
)
{
...
...
src/Rtp/RtpSession.cpp
查看文件 @
d6684542
...
...
@@ -40,7 +40,7 @@ void RtpSession::attachServer(const Server &server) {
RtpSession
::
RtpSession
(
const
Socket
::
Ptr
&
sock
)
:
Session
(
sock
)
{
DebugP
(
this
);
socklen_t
addr_len
=
sizeof
(
_addr
);
getpeername
(
sock
->
rawFD
(),
&
_addr
,
&
addr_len
);
getpeername
(
sock
->
rawFD
(),
(
struct
sockaddr
*
)
&
_addr
,
&
addr_len
);
}
RtpSession
::~
RtpSession
()
{
...
...
@@ -110,7 +110,7 @@ void RtpSession::onRtpPacket(const char *data, size_t len) {
WarnP
(
this
)
<<
"ssrc不匹配,rtp已丢弃:"
<<
rtp_ssrc
<<
" != "
<<
_ssrc
;
return
;
}
_process
->
inputRtp
(
false
,
getSock
(),
data
,
len
,
&
_addr
);
_process
->
inputRtp
(
false
,
getSock
(),
data
,
len
,
(
struct
sockaddr
*
)
&
_addr
);
}
catch
(
RtpTrack
::
BadRtpException
&
ex
)
{
if
(
!
_is_udp
)
{
WarnL
<<
ex
.
what
()
<<
",开始搜索ssrc以便恢复上下文"
;
...
...
src/Rtp/RtpSession.h
查看文件 @
d6684542
...
...
@@ -50,7 +50,7 @@ private:
uint32_t
_ssrc
=
0
;
toolkit
::
Ticker
_ticker
;
std
::
string
_stream_id
;
struct
sockaddr
_addr
;
struct
sockaddr
_storage
_addr
;
RtpProcess
::
Ptr
_process
;
std
::
shared_ptr
<
toolkit
::
ObjectStatistic
<
toolkit
::
TcpSession
>
>
_statistic_tcp
;
std
::
shared_ptr
<
toolkit
::
ObjectStatistic
<
toolkit
::
UdpSession
>
>
_statistic_udp
;
...
...
src/Rtsp/RtspPlayer.cpp
查看文件 @
d6684542
...
...
@@ -292,7 +292,8 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) {
//udp组播
auto
multiAddr
=
transport_map
[
"destination"
];
pRtpSockRef
=
createSocket
();
if
(
!
pRtpSockRef
->
bindUdpSock
(
rtp_port
,
"::"
))
{
//目前组播仅支持ipv4
if
(
!
pRtpSockRef
->
bindUdpSock
(
rtp_port
,
"0.0.0.0"
))
{
pRtpSockRef
.
reset
();
throw
std
::
runtime_error
(
"open udp sock err"
);
}
...
...
@@ -303,45 +304,38 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) {
//设置rtcp发送端口
pRtcpSockRef
=
createSocket
();
if
(
!
pRtcpSockRef
->
bindUdpSock
(
0
,
"::"
))
{
//目前组播仅支持ipv4
if
(
!
pRtcpSockRef
->
bindUdpSock
(
0
,
"0.0.0.0"
))
{
//分配端口失败
throw
runtime_error
(
"open udp socket failed"
);
}
//设置发送地址和发送端口
struct
sockaddr_in
rtpto
;
rtpto
.
sin_port
=
ntohs
(
rtcp_port
);
rtpto
.
sin_family
=
AF_INET
;
rtpto
.
sin_addr
.
s_addr
=
inet_addr
(
get_peer_ip
().
data
());
pRtcpSockRef
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
rtpto
));
auto
dst
=
SockUtil
::
make_sockaddr
(
get_peer_ip
().
data
(),
rtcp_port
);
pRtcpSockRef
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
dst
));
}
else
{
createUdpSockIfNecessary
(
track_idx
);
//udp单播
struct
sockaddr_in
rtpto
;
rtpto
.
sin_port
=
ntohs
(
rtp_port
);
rtpto
.
sin_family
=
AF_INET
;
rtpto
.
sin_addr
.
s_addr
=
inet_addr
(
get_peer_ip
().
data
());
pRtpSockRef
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
rtpto
));
auto
dst
=
SockUtil
::
make_sockaddr
(
get_peer_ip
().
data
(),
rtp_port
);
pRtpSockRef
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
dst
));
//发送rtp打洞包
pRtpSockRef
->
send
(
"
\xce\xfa\xed\xfe
"
,
4
);
dst
=
SockUtil
::
make_sockaddr
(
get_peer_ip
().
data
(),
rtcp_port
);
//设置rtcp发送目标,为后续发送rtcp做准备
rtpto
.
sin_port
=
ntohs
(
rtcp_port
);
rtpto
.
sin_family
=
AF_INET
;
rtpto
.
sin_addr
.
s_addr
=
inet_addr
(
get_peer_ip
().
data
());
pRtcpSockRef
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
rtpto
));
pRtcpSockRef
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
dst
));
}
auto
srcIP
=
inet_addr
(
get_peer_ip
().
data
()
);
auto
peer_ip
=
get_peer_ip
(
);
weak_ptr
<
RtspPlayer
>
weakSelf
=
dynamic_pointer_cast
<
RtspPlayer
>
(
shared_from_this
());
//设置rtp over udp接收回调处理函数
pRtpSockRef
->
setOnRead
([
srcIP
,
track_idx
,
weakSelf
](
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
addr
,
int
addr_len
)
{
pRtpSockRef
->
setOnRead
([
peer_ip
,
track_idx
,
weakSelf
](
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
addr
,
int
addr_len
)
{
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
if
(
((
struct
sockaddr_in
*
)
addr
)
->
sin_addr
.
s_addr
!=
srcIP
)
{
WarnL
<<
"收到其他地址的rtp数据:"
<<
SockUtil
::
inet_ntoa
(
((
struct
sockaddr_in
*
)
addr
)
->
sin_
addr
);
if
(
SockUtil
::
inet_ntoa
(
addr
)
!=
peer_ip
)
{
WarnL
<<
"收到其他地址的rtp数据:"
<<
SockUtil
::
inet_ntoa
(
addr
);
return
;
}
strongSelf
->
handleOneRtp
(
track_idx
,
strongSelf
->
_sdp_track
[
track_idx
]
->
_type
,
...
...
@@ -350,13 +344,13 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) {
if
(
pRtcpSockRef
)
{
//设置rtcp over udp接收回调处理函数
pRtcpSockRef
->
setOnRead
([
srcIP
,
track_idx
,
weakSelf
](
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
addr
,
int
addr_len
)
{
pRtcpSockRef
->
setOnRead
([
peer_ip
,
track_idx
,
weakSelf
](
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
addr
,
int
addr_len
)
{
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
if
(
((
struct
sockaddr_in
*
)
addr
)
->
sin_addr
.
s_addr
!=
srcIP
)
{
WarnL
<<
"收到其他地址的rtcp数据:"
<<
SockUtil
::
inet_ntoa
(
((
struct
sockaddr_in
*
)
addr
)
->
sin_
addr
);
if
(
SockUtil
::
inet_ntoa
(
addr
)
!=
peer_ip
)
{
WarnL
<<
"收到其他地址的rtcp数据:"
<<
SockUtil
::
inet_ntoa
(
addr
);
return
;
}
strongSelf
->
onRtcpPacket
(
track_idx
,
strongSelf
->
_sdp_track
[
track_idx
],
(
uint8_t
*
)
buf
->
data
(),
buf
->
size
());
...
...
src/Rtsp/RtspPusher.cpp
查看文件 @
d6684542
...
...
@@ -307,30 +307,25 @@ void RtspPusher::handleResSetup(const Parser &parser, unsigned int track_idx) {
auto
&
rtp_sock
=
_rtp_sock
[
track_idx
];
auto
&
rtcp_sock
=
_rtcp_sock
[
track_idx
];
struct
sockaddr_in
rtpto
;
auto
rtpto
=
SockUtil
::
make_sockaddr
(
get_peer_ip
().
data
(),
rtp_port
)
;
//设置rtp发送目标,为后续发送rtp做准备
rtpto
.
sin_port
=
ntohs
(
rtp_port
);
rtpto
.
sin_family
=
AF_INET
;
rtpto
.
sin_addr
.
s_addr
=
inet_addr
(
get_peer_ip
().
data
());
rtp_sock
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
rtpto
));
//设置rtcp发送目标,为后续发送rtcp做准备
rtpto
.
sin_port
=
ntohs
(
rtcp_port
);
rtpto
.
sin_family
=
AF_INET
;
rtpto
.
sin_addr
.
s_addr
=
inet_addr
(
get_peer_ip
().
data
());
rtcp_sock
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
rtpto
));
auto
rtcpto
=
SockUtil
::
make_sockaddr
(
get_peer_ip
().
data
(),
rtcp_port
);
rtcp_sock
->
bindPeerAddr
((
struct
sockaddr
*
)
&
(
rtcpto
));
auto
srcIP
=
inet_addr
(
get_peer_ip
().
data
()
);
auto
peer_ip
=
get_peer_ip
(
);
weak_ptr
<
RtspPusher
>
weakSelf
=
dynamic_pointer_cast
<
RtspPusher
>
(
shared_from_this
());
if
(
rtcp_sock
)
{
//设置rtcp over udp接收回调处理函数
rtcp_sock
->
setOnRead
([
srcIP
,
track_idx
,
weakSelf
](
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
addr
,
int
addr_len
)
{
rtcp_sock
->
setOnRead
([
peer_ip
,
track_idx
,
weakSelf
](
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
addr
,
int
addr_len
)
{
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
;
}
if
(
((
struct
sockaddr_in
*
)
addr
)
->
sin_addr
.
s_addr
!=
srcIP
)
{
WarnL
<<
"收到其他地址的rtcp数据:"
<<
SockUtil
::
inet_ntoa
(
((
struct
sockaddr_in
*
)
addr
)
->
sin_
addr
);
if
(
SockUtil
::
inet_ntoa
(
addr
)
!=
peer_ip
)
{
WarnL
<<
"收到其他地址的rtcp数据:"
<<
SockUtil
::
inet_ntoa
(
addr
);
return
;
}
strongSelf
->
onRtcpPacket
(
track_idx
,
strongSelf
->
_track_vec
[
track_idx
],
(
uint8_t
*
)
buf
->
data
(),
buf
->
size
());
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
d6684542
...
...
@@ -705,19 +705,12 @@ void RtspSession::handleReq_Setup(const Parser &parser) {
uint16_t
ui16RtpPort
=
atoi
(
FindField
(
strClientPort
.
data
(),
NULL
,
"-"
).
data
());
uint16_t
ui16RtcpPort
=
atoi
(
FindField
(
strClientPort
.
data
(),
"-"
,
NULL
).
data
());
struct
sockaddr_in
peerAddr
;
auto
peerAddr
=
SockUtil
::
make_sockaddr
(
get_peer_ip
().
data
(),
ui16RtpPort
)
;
//设置rtp发送目标地址
peerAddr
.
sin_family
=
AF_INET
;
peerAddr
.
sin_port
=
htons
(
ui16RtpPort
);
peerAddr
.
sin_addr
.
s_addr
=
inet_addr
(
get_peer_ip
().
data
());
bzero
(
&
(
peerAddr
.
sin_zero
),
sizeof
peerAddr
.
sin_zero
);
pr
.
first
->
bindPeerAddr
((
struct
sockaddr
*
)
(
&
peerAddr
));
//设置rtcp发送目标地址
peerAddr
.
sin_family
=
AF_INET
;
peerAddr
.
sin_port
=
htons
(
ui16RtcpPort
);
peerAddr
.
sin_addr
.
s_addr
=
inet_addr
(
get_peer_ip
().
data
());
bzero
(
&
(
peerAddr
.
sin_zero
),
sizeof
peerAddr
.
sin_zero
);
peerAddr
=
SockUtil
::
make_sockaddr
(
get_peer_ip
().
data
(),
ui16RtcpPort
);
pr
.
second
->
bindPeerAddr
((
struct
sockaddr
*
)
(
&
peerAddr
));
//尝试获取客户端nat映射地址
...
...
@@ -953,7 +946,7 @@ void RtspSession::onRtpSorted(RtpPacket::Ptr rtp, int track_idx) {
}
}
void
RtspSession
::
onRcvPeerUdpData
(
int
interleaved
,
const
Buffer
::
Ptr
&
buf
,
const
struct
sockaddr
&
addr
)
{
void
RtspSession
::
onRcvPeerUdpData
(
int
interleaved
,
const
Buffer
::
Ptr
&
buf
,
const
struct
sockaddr
_storage
&
addr
)
{
//这是rtcp心跳包,说明播放器还存活
_alive_ticker
.
resetTime
();
...
...
@@ -965,13 +958,13 @@ void RtspSession::onRcvPeerUdpData(int interleaved, const Buffer::Ptr &buf, cons
}
else
if
(
!
_udp_connected_flags
.
count
(
interleaved
))
{
//这是rtsp播放器的rtp打洞包
_udp_connected_flags
.
emplace
(
interleaved
);
_rtp_socks
[
interleaved
/
2
]
->
bindPeerAddr
(
&
addr
);
_rtp_socks
[
interleaved
/
2
]
->
bindPeerAddr
(
(
struct
sockaddr
*
)
&
addr
);
}
}
else
{
//rtcp包
if
(
!
_udp_connected_flags
.
count
(
interleaved
))
{
_udp_connected_flags
.
emplace
(
interleaved
);
_rtcp_socks
[(
interleaved
-
1
)
/
2
]
->
bindPeerAddr
(
&
addr
);
_rtcp_socks
[(
interleaved
-
1
)
/
2
]
->
bindPeerAddr
(
(
struct
sockaddr
*
)
&
addr
);
}
onRtcpPacket
((
interleaved
-
1
)
/
2
,
_sdp_track
[(
interleaved
-
1
)
/
2
],
buf
->
data
(),
buf
->
size
());
}
...
...
@@ -979,20 +972,20 @@ void RtspSession::onRcvPeerUdpData(int interleaved, const Buffer::Ptr &buf, cons
void
RtspSession
::
startListenPeerUdpData
(
int
track_idx
)
{
weak_ptr
<
RtspSession
>
weakSelf
=
dynamic_pointer_cast
<
RtspSession
>
(
shared_from_this
());
auto
srcIP
=
inet_addr
(
get_peer_ip
().
data
()
);
auto
onUdpData
=
[
weakSelf
,
srcIP
](
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
peer_addr
,
int
interleaved
){
auto
peer_ip
=
get_peer_ip
(
);
auto
onUdpData
=
[
weakSelf
,
peer_ip
](
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
peer_addr
,
int
interleaved
){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
return
false
;
}
if
(
((
struct
sockaddr_in
*
)
peer_addr
)
->
sin_addr
.
s_addr
!=
srcIP
)
{
if
(
SockUtil
::
inet_ntoa
(
peer_addr
)
!=
peer_ip
)
{
WarnP
(
strongSelf
.
get
())
<<
((
interleaved
%
2
==
0
)
?
"收到其他地址的rtp数据:"
:
"收到其他地址的rtcp数据:"
)
<<
SockUtil
::
inet_ntoa
(
((
struct
sockaddr_in
*
)
peer_addr
)
->
sin
_addr
);
<<
SockUtil
::
inet_ntoa
(
peer
_addr
);
return
true
;
}
struct
sockaddr
addr
=
*
peer_addr
;
struct
sockaddr
_storage
addr
=
*
((
struct
sockaddr_storage
*
)
peer_addr
)
;
strongSelf
->
async
([
weakSelf
,
buf
,
addr
,
interleaved
]()
{
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
...
...
src/Rtsp/RtspSession.h
查看文件 @
d6684542
...
...
@@ -133,7 +133,7 @@ private:
int
getTrackIndexByControlUrl
(
const
std
::
string
&
control_url
);
int
getTrackIndexByInterleaved
(
int
interleaved
);
//一般用于接收udp打洞包,也用于rtsp推流
void
onRcvPeerUdpData
(
int
interleaved
,
const
toolkit
::
Buffer
::
Ptr
&
buf
,
const
struct
sockaddr
&
addr
);
void
onRcvPeerUdpData
(
int
interleaved
,
const
toolkit
::
Buffer
::
Ptr
&
buf
,
const
struct
sockaddr
_storage
&
addr
);
//配合onRcvPeerUdpData使用
void
startListenPeerUdpData
(
int
track_idx
);
////rtsp专有认证相关////
...
...
src/Rtsp/UDPServer.cpp
查看文件 @
d6684542
...
...
@@ -75,8 +75,7 @@ void UDPServer::onErr(const string &key, const SockException &err) {
}
void
UDPServer
::
onRecv
(
int
interleaved
,
const
Buffer
::
Ptr
&
buf
,
struct
sockaddr
*
peer_addr
)
{
struct
sockaddr_in
*
in
=
(
struct
sockaddr_in
*
)
peer_addr
;
string
peer_ip
=
SockUtil
::
inet_ntoa
(
in
->
sin_addr
);
string
peer_ip
=
SockUtil
::
inet_ntoa
(
peer_addr
);
lock_guard
<
mutex
>
lck
(
_mtx_on_recv
);
auto
it0
=
_on_recv_map
.
find
(
peer_ip
);
if
(
it0
==
_on_recv_map
.
end
())
{
...
...
tests/test_rtp.cpp
查看文件 @
d6684542
...
...
@@ -37,7 +37,7 @@ static bool loadFile(const char *path){
uint32_t
timeStamp_last
=
0
;
uint16_t
len
;
char
rtp
[
0xFFFF
];
struct
sockaddr
addr
=
{
0
};
struct
sockaddr
_storage
addr
=
{
0
};
auto
sock
=
Socket
::
createSocket
();
size_t
total_size
=
0
;
while
(
true
)
{
...
...
@@ -58,7 +58,7 @@ static bool loadFile(const char *path){
total_size
+=
len
;
uint32_t
timeStamp
;
RtpSelector
::
Instance
().
inputRtp
(
sock
,
rtp
,
len
,
&
addr
,
&
timeStamp
);
RtpSelector
::
Instance
().
inputRtp
(
sock
,
rtp
,
len
,
(
struct
sockaddr
*
)
&
addr
,
&
timeStamp
);
auto
diff
=
timeStamp
-
timeStamp_last
;
if
(
diff
>
0
&&
diff
<
500
)
{
usleep
(
diff
*
1000
);
...
...
webrtc/WebRtcSession.cpp
查看文件 @
d6684542
...
...
@@ -46,7 +46,7 @@ EventPoller::Ptr WebRtcSession::queryPoller(const Buffer::Ptr &buffer) {
WebRtcSession
::
WebRtcSession
(
const
Socket
::
Ptr
&
sock
)
:
UdpSession
(
sock
)
{
socklen_t
addr_len
=
sizeof
(
_peer_addr
);
getpeername
(
sock
->
rawFD
(),
&
_peer_addr
,
&
addr_len
);
getpeername
(
sock
->
rawFD
(),
(
struct
sockaddr
*
)
&
_peer_addr
,
&
addr_len
);
}
WebRtcSession
::~
WebRtcSession
()
{
...
...
@@ -67,7 +67,7 @@ void WebRtcSession::onRecv(const Buffer::Ptr &buffer) {
}
_ticker
.
resetTime
();
CHECK
(
_transport
);
_transport
->
inputSockData
(
buffer
->
data
(),
buffer
->
size
(),
&
_peer_addr
);
_transport
->
inputSockData
(
buffer
->
data
(),
buffer
->
size
(),
(
struct
sockaddr
*
)
&
_peer_addr
);
}
void
WebRtcSession
::
onError
(
const
SockException
&
err
)
{
...
...
webrtc/WebRtcSession.h
查看文件 @
d6684542
...
...
@@ -32,7 +32,7 @@ private:
std
::
string
_identifier
;
bool
_find_transport
=
true
;
Ticker
_ticker
;
struct
sockaddr
_peer_addr
;
struct
sockaddr
_storage
_peer_addr
;
std
::
shared_ptr
<
WebRtcTransportImp
>
_transport
;
};
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
d6684542
...
...
@@ -274,7 +274,7 @@ static bool is_rtcp(char *buf) {
}
static
string
getPeerAddress
(
RTC
::
TransportTuple
*
tuple
){
return
SockUtil
::
inet_ntoa
(
((
struct
sockaddr_in
*
)
tuple
)
->
sin_addr
)
+
":"
+
to_string
(
ntohs
(((
struct
sockaddr_in
*
)
tuple
)
->
sin_port
)
);
return
SockUtil
::
inet_ntoa
(
tuple
);
}
void
WebRtcTransport
::
inputSockData
(
char
*
buf
,
int
len
,
RTC
::
TransportTuple
*
tuple
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论