Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
c0541171
提交
c0541171
authored
1月 24, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use libsrtp 2.X
上级
c1b8c7a3
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
57 行增加
和
57 行删除
+57
-57
Makefile
Makefile
+1
-1
DepLibSRTP.h
worker/include/DepLibSRTP.h
+6
-6
SRTPSession.h
worker/include/RTC/SRTPSession.h
+5
-5
DepLibSRTP.cpp
worker/src/DepLibSRTP.cpp
+2
-2
SRTPSession.cpp
worker/src/RTC/SRTPSession.cpp
+43
-43
没有找到文件。
Makefile
浏览文件 @
c0541171
...
@@ -47,7 +47,7 @@ SYSTEM_LIBS := pthread
...
@@ -47,7 +47,7 @@ SYSTEM_LIBS := pthread
PKG_LIBS
:=
PKG_LIBS
:=
PKG_LIBS
+=
libuv
>=
1.6.1
PKG_LIBS
+=
libuv
>=
1.6.1
PKG_LIBS
+=
openssl
>=
1.0.1
PKG_LIBS
+=
openssl
>=
1.0.1
PKG_LIBS
+=
libsrtp
>=
1.5.2
PKG_LIBS
+=
libsrtp
2
>=
2.0.0
# Dependencies source files.
# Dependencies source files.
DEP_SOURCES
:=
DEP_SOURCES
:=
...
...
worker/include/DepLibSRTP.h
浏览文件 @
c0541171
...
@@ -2,15 +2,15 @@
...
@@ -2,15 +2,15 @@
#define MS_DEP_LIBSRTP_H
#define MS_DEP_LIBSRTP_H
#include <vector>
#include <vector>
#include <srtp/srtp.h>
#include <srtp
2
/srtp.h>
class
DepLibSRTP
class
DepLibSRTP
{
{
public
:
public
:
static
void
ClassInit
();
static
void
ClassInit
();
static
void
ClassDestroy
();
static
void
ClassDestroy
();
static
bool
IsError
(
err_status_t
code
);
static
bool
IsError
(
srtp_
err_status_t
code
);
static
const
char
*
GetErrorString
(
err_status_t
code
);
static
const
char
*
GetErrorString
(
srtp_
err_status_t
code
);
private
:
private
:
static
std
::
vector
<
const
char
*>
errors
;
static
std
::
vector
<
const
char
*>
errors
;
...
@@ -19,13 +19,13 @@ private:
...
@@ -19,13 +19,13 @@ private:
/* Inline static methods. */
/* Inline static methods. */
inline
inline
bool
DepLibSRTP
::
IsError
(
err_status_t
code
)
bool
DepLibSRTP
::
IsError
(
srtp_
err_status_t
code
)
{
{
return
(
code
!=
err_status_ok
);
return
(
code
!=
srtp_
err_status_ok
);
}
}
inline
inline
const
char
*
DepLibSRTP
::
GetErrorString
(
err_status_t
code
)
const
char
*
DepLibSRTP
::
GetErrorString
(
srtp_
err_status_t
code
)
{
{
// This throws out_of_range if the given index is not in the vector.
// This throws out_of_range if the given index is not in the vector.
return
DepLibSRTP
::
errors
.
at
(
code
);
return
DepLibSRTP
::
errors
.
at
(
code
);
...
...
worker/include/RTC/SRTPSession.h
浏览文件 @
c0541171
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#include "common.h"
#include "common.h"
#include "DepLibSRTP.h"
#include "DepLibSRTP.h"
#include <srtp/srtp.h>
#include <srtp
2
/srtp.h>
namespace
RTC
namespace
RTC
{
{
...
@@ -27,8 +27,8 @@ namespace RTC
...
@@ -27,8 +27,8 @@ namespace RTC
public
:
public
:
static
void
ClassInit
();
static
void
ClassInit
();
private
:
//
private:
static
void
onSRTPEvent
(
srtp_event_data_t
*
data
);
//
static void onSRTPEvent(srtp_event_data_t* data);
private
:
private
:
static
uint8_t
encryptBuffer
[];
static
uint8_t
encryptBuffer
[];
...
@@ -48,7 +48,7 @@ namespace RTC
...
@@ -48,7 +48,7 @@ namespace RTC
// Allocated by this.
// Allocated by this.
srtp_t
session
=
nullptr
;
srtp_t
session
=
nullptr
;
// Others.
// Others.
err_status_t
lastError
=
(
err_status_t
)
0
;
srtp_err_status_t
lastError
=
(
srtp_
err_status_t
)
0
;
};
};
/* Inline instance methods. */
/* Inline instance methods. */
...
@@ -59,7 +59,7 @@ namespace RTC
...
@@ -59,7 +59,7 @@ namespace RTC
const
char
*
error_string
;
const
char
*
error_string
;
error_string
=
DepLibSRTP
::
GetErrorString
(
this
->
lastError
);
error_string
=
DepLibSRTP
::
GetErrorString
(
this
->
lastError
);
this
->
lastError
=
(
err_status_t
)
0
;
// Reset it.
this
->
lastError
=
(
srtp_
err_status_t
)
0
;
// Reset it.
return
error_string
;
return
error_string
;
}
}
...
...
worker/src/DepLibSRTP.cpp
浏览文件 @
c0541171
...
@@ -42,7 +42,7 @@ void DepLibSRTP::ClassInit()
...
@@ -42,7 +42,7 @@ void DepLibSRTP::ClassInit()
{
{
MS_TRACE
();
MS_TRACE
();
err_status_t
err
;
srtp_
err_status_t
err
;
err
=
srtp_init
();
err
=
srtp_init
();
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
...
@@ -53,7 +53,7 @@ void DepLibSRTP::ClassDestroy()
...
@@ -53,7 +53,7 @@ void DepLibSRTP::ClassDestroy()
{
{
MS_TRACE
();
MS_TRACE
();
err_status_t
err
;
srtp_
err_status_t
err
;
err
=
srtp_shutdown
();
err
=
srtp_shutdown
();
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
...
...
worker/src/RTC/SRTPSession.cpp
浏览文件 @
c0541171
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include "MediaSoupError.h"
#include "MediaSoupError.h"
#include "Logger.h"
#include "Logger.h"
#include <cstring> // std::memset(), std::memcpy()
#include <cstring> // std::memset(), std::memcpy()
#include <srtp
/srtp_priv.h> // TODO: This allows data->stream->ssrc, but it is not public. Wait ofr libsrtp new API.
// #include <srtp2
/srtp_priv.h> // TODO: This allows data->stream->ssrc, but it is not public. Wait ofr libsrtp new API.
#define MS_ENCRYPT_BUFFER_SIZE 65536
#define MS_ENCRYPT_BUFFER_SIZE 65536
...
@@ -20,40 +20,40 @@ namespace RTC
...
@@ -20,40 +20,40 @@ namespace RTC
{
{
/* Set libsrtp event handler. */
/* Set libsrtp event handler. */
err_status_t
err
;
// srtp_
err_status_t err;
err
=
srtp_install_event_handler
((
srtp_event_handler_func_t
*
)
onSRTPEvent
);
//
err = srtp_install_event_handler((srtp_event_handler_func_t*)onSRTPEvent);
if
(
DepLibSRTP
::
IsError
(
err
))
//
if (DepLibSRTP::IsError(err))
{
//
{
MS_THROW_ERROR
(
"srtp_install_event_handler() failed: %s"
,
DepLibSRTP
::
GetErrorString
(
err
));
//
MS_THROW_ERROR("srtp_install_event_handler() failed: %s", DepLibSRTP::GetErrorString(err));
}
//
}
}
}
void
SRTPSession
::
onSRTPEvent
(
srtp_event_data_t
*
data
)
//
void SRTPSession::onSRTPEvent(srtp_event_data_t* data)
{
//
{
MS_TRACE
();
//
MS_TRACE();
const
char
*
event_desc
=
""
;
//
const char* event_desc = "";
switch
(
data
->
event
)
//
switch (data->event)
{
//
{
case
event_ssrc_collision
:
//
case event_ssrc_collision:
event_desc
=
"collision occurred"
;
//
event_desc = "collision occurred";
break
;
//
break;
case
event_key_soft_limit
:
//
case event_key_soft_limit:
event_desc
=
"stream reached the soft key usage limit and will expire soon"
;
//
event_desc = "stream reached the soft key usage limit and will expire soon";
break
;
//
break;
case
event_key_hard_limit
:
//
case event_key_hard_limit:
event_desc
=
"stream reached the hard key usage limit and has expired"
;
//
event_desc = "stream reached the hard key usage limit and has expired";
break
;
//
break;
case
event_packet_index_limit
:
//
case event_packet_index_limit:
event_desc
=
"stream reached the hard packet limit (2^48 packets)"
;
//
event_desc = "stream reached the hard packet limit (2^48 packets)";
break
;
//
break;
}
//
}
// TODO: u64?
//
// TODO: u64?
MS_WARN
(
"SSRC %"
PRIu64
": %s"
,
(
uint64_t
)
data
->
stream
->
ssrc
,
event_desc
);
//
MS_WARN("SSRC %" PRIu64 ": %s", (uint64_t)data->stream->ssrc, event_desc);
}
//
}
/* Instance methods. */
/* Instance methods. */
...
@@ -61,7 +61,7 @@ namespace RTC
...
@@ -61,7 +61,7 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
err_status_t
err
;
srtp_
err_status_t
err
;
srtp_policy_t
policy
;
srtp_policy_t
policy
;
// Set all policy fields to 0.
// Set all policy fields to 0.
...
@@ -70,12 +70,12 @@ namespace RTC
...
@@ -70,12 +70,12 @@ namespace RTC
switch
(
profile
)
switch
(
profile
)
{
{
case
SRTPProfile
:
:
AES_CM_128_HMAC_SHA1_80
:
case
SRTPProfile
:
:
AES_CM_128_HMAC_SHA1_80
:
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtp
);
srtp_
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtp
);
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
srtp_
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
break
;
break
;
case
SRTPProfile
:
:
AES_CM_128_HMAC_SHA1_32
:
case
SRTPProfile
:
:
AES_CM_128_HMAC_SHA1_32
:
crypto_policy_set_aes_cm_128_hmac_sha1_32
(
&
policy
.
rtp
);
srtp_
crypto_policy_set_aes_cm_128_hmac_sha1_32
(
&
policy
.
rtp
);
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
// NOTE: Must be 80 for RTCP!.
srtp_
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
// NOTE: Must be 80 for RTCP!.
break
;
break
;
default
:
default
:
MS_ABORT
(
"unknown SRTP suite"
);
MS_ABORT
(
"unknown SRTP suite"
);
...
@@ -114,7 +114,7 @@ namespace RTC
...
@@ -114,7 +114,7 @@ namespace RTC
if
(
this
->
session
)
if
(
this
->
session
)
{
{
err_status_t
err
;
srtp_
err_status_t
err
;
err
=
srtp_dealloc
(
this
->
session
);
err
=
srtp_dealloc
(
this
->
session
);
if
(
DepLibSRTP
::
IsError
(
err
))
if
(
DepLibSRTP
::
IsError
(
err
))
...
@@ -134,7 +134,7 @@ namespace RTC
...
@@ -134,7 +134,7 @@ namespace RTC
if
(
*
len
+
SRTP_MAX_TRAILER_LEN
>
MS_ENCRYPT_BUFFER_SIZE
)
if
(
*
len
+
SRTP_MAX_TRAILER_LEN
>
MS_ENCRYPT_BUFFER_SIZE
)
{
{
MS_WARN
(
"cannot encrypt RTP packet, size too big (%zu bytes)"
,
*
len
);
MS_WARN
(
"cannot encrypt RTP packet, size too big (%zu bytes)"
,
*
len
);
this
->
lastError
=
err_status_fail
;
this
->
lastError
=
srtp_
err_status_fail
;
return
false
;
return
false
;
}
}
...
@@ -175,7 +175,7 @@ namespace RTC
...
@@ -175,7 +175,7 @@ namespace RTC
if
(
*
len
+
SRTP_MAX_TRAILER_LEN
>
MS_ENCRYPT_BUFFER_SIZE
)
if
(
*
len
+
SRTP_MAX_TRAILER_LEN
>
MS_ENCRYPT_BUFFER_SIZE
)
{
{
MS_WARN
(
"cannot encrypt RTCP packet, size too big (%zu bytes)"
,
*
len
);
MS_WARN
(
"cannot encrypt RTCP packet, size too big (%zu bytes)"
,
*
len
);
this
->
lastError
=
err_status_fail
;
this
->
lastError
=
srtp_
err_status_fail
;
return
false
;
return
false
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论