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
1d161bcd
Commit
1d161bcd
authored
Aug 13, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复webrtc srtp相关功能在大端64位系统崩溃的问题
parent
8fd9853b
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
19 行增加
和
19 行删除
+19
-19
webrtc/SrtpSession.cpp
+4
-4
webrtc/SrtpSession.hpp
+4
-4
webrtc/WebRtcTransport.cpp
+4
-4
webrtc/WebRtcTransport.h
+7
-7
没有找到文件。
webrtc/SrtpSession.cpp
查看文件 @
1d161bcd
...
@@ -231,7 +231,7 @@ namespace RTC
...
@@ -231,7 +231,7 @@ namespace RTC
}
}
}
}
bool
SrtpSession
::
EncryptRtp
(
uint8_t
*
data
,
size_
t
*
len
)
bool
SrtpSession
::
EncryptRtp
(
uint8_t
*
data
,
in
t
*
len
)
{
{
MS_TRACE
();
MS_TRACE
();
srtp_err_status_t
err
=
srtp_err_status_t
err
=
...
@@ -246,7 +246,7 @@ namespace RTC
...
@@ -246,7 +246,7 @@ namespace RTC
return
true
;
return
true
;
}
}
bool
SrtpSession
::
DecryptSrtp
(
uint8_t
*
data
,
size_
t
*
len
)
bool
SrtpSession
::
DecryptSrtp
(
uint8_t
*
data
,
in
t
*
len
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -262,7 +262,7 @@ namespace RTC
...
@@ -262,7 +262,7 @@ namespace RTC
return
true
;
return
true
;
}
}
bool
SrtpSession
::
EncryptRtcp
(
uint8_t
*
data
,
size_
t
*
len
)
bool
SrtpSession
::
EncryptRtcp
(
uint8_t
*
data
,
in
t
*
len
)
{
{
MS_TRACE
();
MS_TRACE
();
srtp_err_status_t
err
=
srtp_protect_rtcp
(
srtp_err_status_t
err
=
srtp_protect_rtcp
(
...
@@ -277,7 +277,7 @@ namespace RTC
...
@@ -277,7 +277,7 @@ namespace RTC
return
true
;
return
true
;
}
}
bool
SrtpSession
::
DecryptSrtcp
(
uint8_t
*
data
,
size_
t
*
len
)
bool
SrtpSession
::
DecryptSrtcp
(
uint8_t
*
data
,
in
t
*
len
)
{
{
MS_TRACE
();
MS_TRACE
();
...
...
webrtc/SrtpSession.hpp
查看文件 @
1d161bcd
...
@@ -64,10 +64,10 @@ namespace RTC
...
@@ -64,10 +64,10 @@ namespace RTC
~
SrtpSession
();
~
SrtpSession
();
public
:
public
:
bool
EncryptRtp
(
uint8_t
*
data
,
size_
t
*
len
);
bool
EncryptRtp
(
uint8_t
*
data
,
in
t
*
len
);
bool
DecryptSrtp
(
uint8_t
*
data
,
size_
t
*
len
);
bool
DecryptSrtp
(
uint8_t
*
data
,
in
t
*
len
);
bool
EncryptRtcp
(
uint8_t
*
data
,
size_
t
*
len
);
bool
EncryptRtcp
(
uint8_t
*
data
,
in
t
*
len
);
bool
DecryptSrtcp
(
uint8_t
*
data
,
size_
t
*
len
);
bool
DecryptSrtcp
(
uint8_t
*
data
,
in
t
*
len
);
void
RemoveStream
(
uint32_t
ssrc
)
void
RemoveStream
(
uint32_t
ssrc
)
{
{
srtp_remove_stream
(
this
->
session
,
uint32_t
{
htonl
(
ssrc
)
});
srtp_remove_stream
(
this
->
session
,
uint32_t
{
htonl
(
ssrc
)
});
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
1d161bcd
...
@@ -236,7 +236,7 @@ bool is_rtcp(char *buf) {
...
@@ -236,7 +236,7 @@ bool is_rtcp(char *buf) {
return
((
header
->
pt
>=
64
)
&&
(
header
->
pt
<
96
));
return
((
header
->
pt
>=
64
)
&&
(
header
->
pt
<
96
));
}
}
void
WebRtcTransport
::
inputSockData
(
char
*
buf
,
size_
t
len
,
RTC
::
TransportTuple
*
tuple
)
{
void
WebRtcTransport
::
inputSockData
(
char
*
buf
,
in
t
len
,
RTC
::
TransportTuple
*
tuple
)
{
if
(
RTC
::
StunPacket
::
IsStun
((
const
uint8_t
*
)
buf
,
len
))
{
if
(
RTC
::
StunPacket
::
IsStun
((
const
uint8_t
*
)
buf
,
len
))
{
RTC
::
StunPacket
*
packet
=
RTC
::
StunPacket
::
Parse
((
const
uint8_t
*
)
buf
,
len
);
RTC
::
StunPacket
*
packet
=
RTC
::
StunPacket
::
Parse
((
const
uint8_t
*
)
buf
,
len
);
if
(
packet
==
nullptr
)
{
if
(
packet
==
nullptr
)
{
...
@@ -264,7 +264,7 @@ void WebRtcTransport::inputSockData(char *buf, size_t len, RTC::TransportTuple *
...
@@ -264,7 +264,7 @@ void WebRtcTransport::inputSockData(char *buf, size_t len, RTC::TransportTuple *
}
}
}
}
void
WebRtcTransport
::
sendRtpPacket
(
const
char
*
buf
,
size_
t
len
,
bool
flush
,
void
*
ctx
)
{
void
WebRtcTransport
::
sendRtpPacket
(
const
char
*
buf
,
in
t
len
,
bool
flush
,
void
*
ctx
)
{
if
(
_srtp_session_send
)
{
if
(
_srtp_session_send
)
{
//预留rtx加入的两个字节
//预留rtx加入的两个字节
CHECK
(
len
+
SRTP_MAX_TRAILER_LEN
+
2
<=
sizeof
(
_srtp_buf
));
CHECK
(
len
+
SRTP_MAX_TRAILER_LEN
+
2
<=
sizeof
(
_srtp_buf
));
...
@@ -276,7 +276,7 @@ void WebRtcTransport::sendRtpPacket(const char *buf, size_t len, bool flush, voi
...
@@ -276,7 +276,7 @@ void WebRtcTransport::sendRtpPacket(const char *buf, size_t len, bool flush, voi
}
}
}
}
void
WebRtcTransport
::
sendRtcpPacket
(
const
char
*
buf
,
size_
t
len
,
bool
flush
,
void
*
ctx
){
void
WebRtcTransport
::
sendRtcpPacket
(
const
char
*
buf
,
in
t
len
,
bool
flush
,
void
*
ctx
){
if
(
_srtp_session_send
)
{
if
(
_srtp_session_send
)
{
CHECK
(
len
+
SRTP_MAX_TRAILER_LEN
<=
sizeof
(
_srtp_buf
));
CHECK
(
len
+
SRTP_MAX_TRAILER_LEN
<=
sizeof
(
_srtp_buf
));
memcpy
(
_srtp_buf
,
buf
,
len
);
memcpy
(
_srtp_buf
,
buf
,
len
);
...
@@ -901,7 +901,7 @@ void WebRtcTransportImp::onSendRtp(const RtpPacket::Ptr &rtp, bool flush, bool r
...
@@ -901,7 +901,7 @@ void WebRtcTransportImp::onSendRtp(const RtpPacket::Ptr &rtp, bool flush, bool r
_bytes_usage
+=
rtp
->
size
()
-
RtpPacket
::
kRtpTcpHeaderSize
;
_bytes_usage
+=
rtp
->
size
()
-
RtpPacket
::
kRtpTcpHeaderSize
;
}
}
void
WebRtcTransportImp
::
onBeforeEncryptRtp
(
const
char
*
buf
,
size_
t
&
len
,
void
*
ctx
)
{
void
WebRtcTransportImp
::
onBeforeEncryptRtp
(
const
char
*
buf
,
in
t
&
len
,
void
*
ctx
)
{
auto
pr
=
(
pair
<
bool
/*rtx*/
,
MediaTrack
*>
*
)
ctx
;
auto
pr
=
(
pair
<
bool
/*rtx*/
,
MediaTrack
*>
*
)
ctx
;
auto
header
=
(
RtpHeader
*
)
buf
;
auto
header
=
(
RtpHeader
*
)
buf
;
...
...
webrtc/WebRtcTransport.h
查看文件 @
1d161bcd
...
@@ -56,7 +56,7 @@ public:
...
@@ -56,7 +56,7 @@ public:
* @param len 数据长度
* @param len 数据长度
* @param tuple 数据来源
* @param tuple 数据来源
*/
*/
void
inputSockData
(
char
*
buf
,
size_
t
len
,
RTC
::
TransportTuple
*
tuple
);
void
inputSockData
(
char
*
buf
,
in
t
len
,
RTC
::
TransportTuple
*
tuple
);
/**
/**
* 发送rtp
* 发送rtp
...
@@ -65,8 +65,8 @@ public:
...
@@ -65,8 +65,8 @@ public:
* @param flush 是否flush socket
* @param flush 是否flush socket
* @param ctx 用户指针
* @param ctx 用户指针
*/
*/
void
sendRtpPacket
(
const
char
*
buf
,
size_
t
len
,
bool
flush
,
void
*
ctx
=
nullptr
);
void
sendRtpPacket
(
const
char
*
buf
,
in
t
len
,
bool
flush
,
void
*
ctx
=
nullptr
);
void
sendRtcpPacket
(
const
char
*
buf
,
size_
t
len
,
bool
flush
,
void
*
ctx
=
nullptr
);
void
sendRtcpPacket
(
const
char
*
buf
,
in
t
len
,
bool
flush
,
void
*
ctx
=
nullptr
);
const
EventPoller
::
Ptr
&
getPoller
()
const
;
const
EventPoller
::
Ptr
&
getPoller
()
const
;
...
@@ -103,8 +103,8 @@ protected:
...
@@ -103,8 +103,8 @@ protected:
virtual
void
onRtp
(
const
char
*
buf
,
size_t
len
)
=
0
;
virtual
void
onRtp
(
const
char
*
buf
,
size_t
len
)
=
0
;
virtual
void
onRtcp
(
const
char
*
buf
,
size_t
len
)
=
0
;
virtual
void
onRtcp
(
const
char
*
buf
,
size_t
len
)
=
0
;
virtual
void
onShutdown
(
const
SockException
&
ex
)
=
0
;
virtual
void
onShutdown
(
const
SockException
&
ex
)
=
0
;
virtual
void
onBeforeEncryptRtp
(
const
char
*
buf
,
size_
t
&
len
,
void
*
ctx
)
=
0
;
virtual
void
onBeforeEncryptRtp
(
const
char
*
buf
,
in
t
&
len
,
void
*
ctx
)
=
0
;
virtual
void
onBeforeEncryptRtcp
(
const
char
*
buf
,
size_
t
&
len
,
void
*
ctx
)
=
0
;
virtual
void
onBeforeEncryptRtcp
(
const
char
*
buf
,
in
t
&
len
,
void
*
ctx
)
=
0
;
protected
:
protected
:
const
RtcSession
&
getSdp
(
SdpType
type
)
const
;
const
RtcSession
&
getSdp
(
SdpType
type
)
const
;
...
@@ -176,8 +176,8 @@ protected:
...
@@ -176,8 +176,8 @@ protected:
void
onRtp
(
const
char
*
buf
,
size_t
len
)
override
;
void
onRtp
(
const
char
*
buf
,
size_t
len
)
override
;
void
onRtcp
(
const
char
*
buf
,
size_t
len
)
override
;
void
onRtcp
(
const
char
*
buf
,
size_t
len
)
override
;
void
onBeforeEncryptRtp
(
const
char
*
buf
,
size_
t
&
len
,
void
*
ctx
)
override
;
void
onBeforeEncryptRtp
(
const
char
*
buf
,
in
t
&
len
,
void
*
ctx
)
override
;
void
onBeforeEncryptRtcp
(
const
char
*
buf
,
size_
t
&
len
,
void
*
ctx
)
override
{};
void
onBeforeEncryptRtcp
(
const
char
*
buf
,
in
t
&
len
,
void
*
ctx
)
override
{};
void
onShutdown
(
const
SockException
&
ex
)
override
;
void
onShutdown
(
const
SockException
&
ex
)
override
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论