Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
27429d0b
提交
27429d0b
authored
6月 19, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Check RtpReceivers codecs agains room capabilities.
上级
966cabd1
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
158 行增加
和
25 行删除
+158
-25
gulpfile.js
gulpfile.js
+4
-1
Worker.js
lib/Worker.js
+3
-3
options.js
test/data/options.js
+9
-0
test_RtpReceiver.js
test/test_RtpReceiver.js
+12
-4
RtpDictionaries.h
worker/include/RTC/RtpDictionaries.h
+6
-0
mediasoup-worker.gyp
worker/mediasoup-worker.gyp
+1
-0
DepLibUV.cpp
worker/src/DepLibUV.cpp
+1
-1
DtlsTransport.cpp
worker/src/RTC/DtlsTransport.cpp
+1
-1
Room.cpp
worker/src/RTC/Room.cpp
+20
-3
RtpCapabilities.cpp
worker/src/RTC/RtpDictionaries/RtpCapabilities.cpp
+1
-0
RtpCodecCapability.cpp
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
+56
-5
RtpCodecParameters.cpp
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
+38
-2
RtpParameters.cpp
worker/src/RTC/RtpDictionaries/RtpParameters.cpp
+2
-0
TcpServer.cpp
worker/src/RTC/TcpServer.cpp
+2
-2
UdpSocket.cpp
worker/src/RTC/UdpSocket.cpp
+2
-2
main.cpp
worker/src/main.cpp
+0
-1
没有找到文件。
gulpfile.js
浏览文件 @
27429d0b
...
@@ -48,7 +48,10 @@ gulp.task('worker', shell.task(
...
@@ -48,7 +48,10 @@ gulp.task('worker', shell.task(
));
));
gulp
.
task
(
'test'
,
shell
.
task
(
gulp
.
task
(
'test'
,
shell
.
task
(
[
`tap --bail --color --reporter=spec
${
tests
.
join
(
' '
)}
`
]
[
`tap --bail --color --reporter=spec
${
tests
.
join
(
' '
)}
`
],
{
env
:
{
DEBUG
:
'*ABORT*'
}
}
));
));
gulp
.
task
(
'test-debug'
,
shell
.
task
(
gulp
.
task
(
'test-debug'
,
shell
.
task
(
...
...
lib/Worker.js
浏览文件 @
27429d0b
...
@@ -65,8 +65,7 @@ class Worker extends EventEmitter
...
@@ -65,8 +65,7 @@ class Worker extends EventEmitter
// Set of Room instances.
// Set of Room instances.
this
.
_rooms
=
new
Set
();
this
.
_rooms
=
new
Set
();
// Be ready for 3rd party worker libraries logging to stdout/stderr.
// Be ready for 3rd party worker libraries logging to stdout.
this
.
_child
.
stdout
.
on
(
'data'
,
(
buffer
)
=>
this
.
_child
.
stdout
.
on
(
'data'
,
(
buffer
)
=>
{
{
buffer
.
toString
(
'utf8'
).
split
(
'
\
n'
).
forEach
((
line
)
=>
buffer
.
toString
(
'utf8'
).
split
(
'
\
n'
).
forEach
((
line
)
=>
...
@@ -76,12 +75,13 @@ class Worker extends EventEmitter
...
@@ -76,12 +75,13 @@ class Worker extends EventEmitter
});
});
});
});
// In case of a worker bug, mediasoup will call abort() and log to stderr.
this
.
_child
.
stderr
.
on
(
'data'
,
(
buffer
)
=>
this
.
_child
.
stderr
.
on
(
'data'
,
(
buffer
)
=>
{
{
buffer
.
toString
(
'utf8'
).
split
(
'
\
n'
).
forEach
((
line
)
=>
buffer
.
toString
(
'utf8'
).
split
(
'
\
n'
).
forEach
((
line
)
=>
{
{
if
(
line
)
if
(
line
)
logger
.
error
(
`mediasoup-worker's stderr:
${
line
}
`
);
console
.
error
(
`mediasoup-worker's stderr:
${
line
}
`
);
});
});
});
});
...
...
test/data/options.js
浏览文件 @
27429d0b
...
@@ -22,6 +22,15 @@ module.exports =
...
@@ -22,6 +22,15 @@ module.exports =
name
:
'video/vp8'
,
name
:
'video/vp8'
,
clockRate
:
90000
clockRate
:
90000
},
},
{
kind
:
'video'
,
name
:
'video/h264'
,
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
0
}
},
{
{
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/h264'
,
name
:
'video/h264'
,
...
...
test/test_RtpReceiver.js
浏览文件 @
27429d0b
...
@@ -79,12 +79,20 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
...
@@ -79,12 +79,20 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
{
{
name
:
'video/H264'
,
name
:
'video/H264'
,
payloadType
:
101
,
payloadType
:
101
,
clockRate
:
90000
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
0
}
},
},
{
{
name
:
'video/H26
5
'
,
name
:
'video/H26
4
'
,
payloadType
:
102
,
payloadType
:
102
,
clockRate
:
90000
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
1
}
}
}
],
],
encodings
:
encodings
:
...
@@ -129,7 +137,7 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
...
@@ -129,7 +137,7 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
codecs
:
codecs
:
[
[
{
{
name
:
'video/VP
9
'
,
name
:
'video/VP
8
'
,
payloadType
:
100
,
payloadType
:
100
,
clockRate
:
90000
,
clockRate
:
90000
,
maxptime
:
80
,
maxptime
:
80
,
...
...
worker/include/RTC/RtpDictionaries.h
浏览文件 @
27429d0b
...
@@ -158,6 +158,9 @@ namespace RTC
...
@@ -158,6 +158,9 @@ namespace RTC
Json
::
Value
toJson
();
Json
::
Value
toJson
();
private
:
void
CheckCodec
();
private
:
private
:
bool
isRoomCodec
=
false
;
bool
isRoomCodec
=
false
;
...
@@ -279,6 +282,9 @@ namespace RTC
...
@@ -279,6 +282,9 @@ namespace RTC
bool
MatchesCodec
(
RtpCodecParameters
&
codec
);
bool
MatchesCodec
(
RtpCodecParameters
&
codec
);
void
Reduce
(
RtpCodecParameters
&
codec
);
void
Reduce
(
RtpCodecParameters
&
codec
);
private
:
void
CheckCodecCapability
();
public
:
public
:
Media
::
Kind
kind
=
Media
::
Kind
::
ALL
;
Media
::
Kind
kind
=
Media
::
Kind
::
ALL
;
uint8_t
preferredPayloadType
=
0
;
uint8_t
preferredPayloadType
=
0
;
...
...
worker/mediasoup-worker.gyp
浏览文件 @
27429d0b
...
@@ -157,6 +157,7 @@
...
@@ -157,6 +157,7 @@
[ 'OS != "win"', {
[ 'OS != "win"', {
'cflags': [ '-std=c++11', '-Wall', '-Wextra', '-Wno-unused-parameter' ]
'cflags': [ '-std=c++11', '-Wall', '-Wextra', '-Wno-unused-parameter' ]
}],
}],
[ 'OS == "mac"', {
[ 'OS == "mac"', {
'xcode_settings':
'xcode_settings':
{
{
...
...
worker/src/DepLibUV.cpp
浏览文件 @
27429d0b
...
@@ -19,7 +19,7 @@ void DepLibUV::ClassInit()
...
@@ -19,7 +19,7 @@ void DepLibUV::ClassInit()
DepLibUV
::
loop
=
new
uv_loop_t
;
DepLibUV
::
loop
=
new
uv_loop_t
;
err
=
uv_loop_init
(
DepLibUV
::
loop
);
err
=
uv_loop_init
(
DepLibUV
::
loop
);
if
(
err
)
if
(
err
)
std
::
abort
(
);
MS_ABORT
(
"libuv initialization failed"
);
}
}
void
DepLibUV
::
ClassDestroy
()
void
DepLibUV
::
ClassDestroy
()
...
...
worker/src/RTC/DtlsTransport.cpp
浏览文件 @
27429d0b
...
@@ -444,7 +444,7 @@ namespace RTC
...
@@ -444,7 +444,7 @@ namespace RTC
hash_function
=
EVP_sha512
();
hash_function
=
EVP_sha512
();
break
;
break
;
default
:
default
:
MS_
ABORT
(
"unknown algorithm"
);
MS_
THROW_ERROR
(
"unknown algorithm"
);
}
}
ret
=
X509_digest
(
DtlsTransport
::
certificate
,
hash_function
,
binary_fingerprint
,
&
size
);
ret
=
X509_digest
(
DtlsTransport
::
certificate
,
hash_function
,
binary_fingerprint
,
&
size
);
...
...
worker/src/RTC/Room.cpp
浏览文件 @
27429d0b
...
@@ -498,10 +498,27 @@ namespace RTC
...
@@ -498,10 +498,27 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
//
auto rtpParameters = rtpReceiver->GetParameters();
auto
rtpParameters
=
rtpReceiver
->
GetParameters
();
// TODO: Check codecs availability and, optionally, uniqueness of PTs.
// Check codecs availability. If it fails, throw.
// If it fails throw.
for
(
auto
codec
:
rtpParameters
->
codecs
)
{
auto
it
=
this
->
rtpCapabilities
.
codecs
.
begin
();
for
(;
it
!=
this
->
rtpCapabilities
.
codecs
.
end
();
++
it
)
{
auto
&
codecCapability
=
*
it
;
if
(
codecCapability
.
MatchesCodec
(
codec
))
break
;
}
if
(
it
==
this
->
rtpCapabilities
.
codecs
.
end
())
{
MS_THROW_ERROR
(
"no matching codec capability found [payloadType:%"
PRIu8
"]"
,
codec
.
payloadType
);
}
}
}
}
void
Room
::
onPeerRtpReceiverParametersDone
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
void
Room
::
onPeerRtpReceiverParametersDone
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
...
...
worker/src/RTC/RtpDictionaries/RtpCapabilities.cpp
浏览文件 @
27429d0b
...
@@ -106,6 +106,7 @@ namespace RTC
...
@@ -106,6 +106,7 @@ namespace RTC
return
json
;
return
json
;
}
}
inline
void
RtpCapabilities
::
ValidateCodecs
()
void
RtpCapabilities
::
ValidateCodecs
()
{
{
MS_TRACE
();
MS_TRACE
();
...
...
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
浏览文件 @
27429d0b
...
@@ -65,7 +65,8 @@ namespace RTC
...
@@ -65,7 +65,8 @@ namespace RTC
if
(
data
[
k_svcMultiStreamSupport
].
isBool
())
if
(
data
[
k_svcMultiStreamSupport
].
isBool
())
this
->
svcMultiStreamSupport
=
data
[
k_svcMultiStreamSupport
].
asBool
();
this
->
svcMultiStreamSupport
=
data
[
k_svcMultiStreamSupport
].
asBool
();
// TODO: Check per MIME parameters.
// Check codec capability.
CheckCodecCapability
();
}
}
Json
::
Value
RtpCodecCapability
::
toJson
()
Json
::
Value
RtpCodecCapability
::
toJson
()
...
@@ -117,6 +118,8 @@ namespace RTC
...
@@ -117,6 +118,8 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
static
std
::
string
k_packetizationMode
=
"packetizationMode"
;
// MIME must match.
// MIME must match.
if
(
this
->
mime
!=
codec
.
mime
)
if
(
this
->
mime
!=
codec
.
mime
)
return
false
;
return
false
;
...
@@ -137,9 +140,20 @@ namespace RTC
...
@@ -137,9 +140,20 @@ namespace RTC
break
;
break
;
}
}
case
RTC
:
:
Media
::
Kind
::
VIDEO
:
default
:
;
}
// Per MIME checks.
switch
(
this
->
mime
.
subtype
)
{
case
RTC
:
:
RtpCodecMime
::
Subtype
::
H264
:
{
{
// TODO: check SVC stuff.
if
(
!
this
->
parameters
.
IncludesInteger
(
k_packetizationMode
,
codec
.
parameters
.
GetInteger
(
k_packetizationMode
)))
{
return
false
;
}
break
;
break
;
}
}
...
@@ -148,8 +162,6 @@ namespace RTC
...
@@ -148,8 +162,6 @@ namespace RTC
;
;
}
}
// TODO: Match per codec parameters, etc.
return
true
;
return
true
;
}
}
...
@@ -167,6 +179,7 @@ namespace RTC
...
@@ -167,6 +179,7 @@ namespace RTC
{
{
std
::
vector
<
int32_t
>
packetizationMode
;
std
::
vector
<
int32_t
>
packetizationMode
;
// NOTE: `packetizationMode` is set by RtpCodecParameter if not present.
packetizationMode
.
push_back
(
codec
.
parameters
.
GetInteger
(
k_packetizationMode
));
packetizationMode
.
push_back
(
codec
.
parameters
.
GetInteger
(
k_packetizationMode
));
this
->
parameters
.
SetArrayOfIntegers
(
k_packetizationMode
,
packetizationMode
);
this
->
parameters
.
SetArrayOfIntegers
(
k_packetizationMode
,
packetizationMode
);
...
@@ -177,4 +190,42 @@ namespace RTC
...
@@ -177,4 +190,42 @@ namespace RTC
;
;
}
}
}
}
inline
void
RtpCodecCapability
::
CheckCodecCapability
()
{
MS_TRACE
();
static
std
::
string
k_packetizationMode
=
"packetizationMode"
;
// Check per MIME parameters and set default values.
switch
(
this
->
mime
.
subtype
)
{
case
RTC
:
:
RtpCodecMime
::
Subtype
::
OPUS
:
{
// Opus default numChannels is 2.
if
(
this
->
numChannels
<
2
)
this
->
numChannels
=
2
;
break
;
}
case
RTC
:
:
RtpCodecMime
::
Subtype
::
H264
:
{
// H264 default packetizationMode is 0.
std
::
vector
<
int32_t
>
packetizationMode
=
{
0
};
if
(
!
this
->
parameters
.
HasArrayOfIntegers
(
k_packetizationMode
))
this
->
parameters
.
SetArrayOfIntegers
(
k_packetizationMode
,
packetizationMode
);
break
;
}
default
:
;
}
}
}
}
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
浏览文件 @
27429d0b
...
@@ -66,8 +66,8 @@ namespace RTC
...
@@ -66,8 +66,8 @@ namespace RTC
MS_THROW_ERROR
(
"can not be a feature codec"
);
MS_THROW_ERROR
(
"can not be a feature codec"
);
}
}
//
TODO: Check per MIME parameters and set default values
.
//
Check codec
.
// For example, H264 default packetizationMode is 0.
CheckCodec
();
}
}
Json
::
Value
RtpCodecParameters
::
toJson
()
Json
::
Value
RtpCodecParameters
::
toJson
()
...
@@ -111,4 +111,40 @@ namespace RTC
...
@@ -111,4 +111,40 @@ namespace RTC
return
json
;
return
json
;
}
}
inline
void
RtpCodecParameters
::
CheckCodec
()
{
MS_TRACE
();
static
std
::
string
k_packetizationMode
=
"packetizationMode"
;
// Check per MIME parameters and set default values.
switch
(
this
->
mime
.
subtype
)
{
case
RTC
:
:
RtpCodecMime
::
Subtype
::
OPUS
:
{
// Opus default numChannels is 2.
if
(
this
->
numChannels
<
2
)
this
->
numChannels
=
2
;
break
;
}
case
RTC
:
:
RtpCodecMime
::
Subtype
::
H264
:
{
// H264 default packetizationMode is 0.
if
(
!
this
->
parameters
.
HasInteger
(
k_packetizationMode
))
this
->
parameters
.
SetInteger
(
k_packetizationMode
,
0
);
break
;
}
default
:
;
}
}
}
}
worker/src/RTC/RtpDictionaries/RtpParameters.cpp
浏览文件 @
27429d0b
...
@@ -158,6 +158,7 @@ namespace RTC
...
@@ -158,6 +158,7 @@ namespace RTC
return
json
;
return
json
;
}
}
inline
void
RtpParameters
::
ValidateCodecs
()
void
RtpParameters
::
ValidateCodecs
()
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -187,6 +188,7 @@ namespace RTC
...
@@ -187,6 +188,7 @@ namespace RTC
}
}
}
}
inline
void
RtpParameters
::
ValidateEncodings
()
void
RtpParameters
::
ValidateEncodings
()
{
{
uint8_t
firstMediaPayloadType
;
uint8_t
firstMediaPayloadType
;
...
...
worker/src/RTC/TcpServer.cpp
浏览文件 @
27429d0b
...
@@ -42,14 +42,14 @@ namespace RTC
...
@@ -42,14 +42,14 @@ namespace RTC
{
{
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcListenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
TcpServer
::
sockaddrStorageIPv4
);
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcListenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
TcpServer
::
sockaddrStorageIPv4
);
if
(
err
)
if
(
err
)
MS_
ABORT
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
MS_
THROW_ERROR
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
}
}
if
(
!
Settings
::
configuration
.
rtcListenIPv6
.
empty
())
if
(
!
Settings
::
configuration
.
rtcListenIPv6
.
empty
())
{
{
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcListenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
TcpServer
::
sockaddrStorageIPv6
);
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcListenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
TcpServer
::
sockaddrStorageIPv6
);
if
(
err
)
if
(
err
)
MS_
ABORT
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
MS_
THROW_ERROR
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
}
}
TcpServer
::
minPort
=
Settings
::
configuration
.
rtcMinPort
;
TcpServer
::
minPort
=
Settings
::
configuration
.
rtcMinPort
;
...
...
worker/src/RTC/UdpSocket.cpp
浏览文件 @
27429d0b
...
@@ -41,14 +41,14 @@ namespace RTC
...
@@ -41,14 +41,14 @@ namespace RTC
{
{
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcListenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
UdpSocket
::
sockaddrStorageIPv4
);
err
=
uv_ip4_addr
(
Settings
::
configuration
.
rtcListenIPv4
.
c_str
(),
0
,
(
struct
sockaddr_in
*
)
&
RTC
::
UdpSocket
::
sockaddrStorageIPv4
);
if
(
err
)
if
(
err
)
MS_
ABORT
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
MS_
THROW_ERROR
(
"uv_ipv4_addr() failed: %s"
,
uv_strerror
(
err
));
}
}
if
(
Settings
::
configuration
.
hasIPv6
)
if
(
Settings
::
configuration
.
hasIPv6
)
{
{
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcListenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
UdpSocket
::
sockaddrStorageIPv6
);
err
=
uv_ip6_addr
(
Settings
::
configuration
.
rtcListenIPv6
.
c_str
(),
0
,
(
struct
sockaddr_in6
*
)
&
RTC
::
UdpSocket
::
sockaddrStorageIPv6
);
if
(
err
)
if
(
err
)
MS_
ABORT
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
MS_
THROW_ERROR
(
"uv_ipv6_addr() failed: %s"
,
uv_strerror
(
err
));
}
}
UdpSocket
::
minPort
=
Settings
::
configuration
.
rtcMinPort
;
UdpSocket
::
minPort
=
Settings
::
configuration
.
rtcMinPort
;
...
...
worker/src/main.cpp
浏览文件 @
27429d0b
...
@@ -116,7 +116,6 @@ void init()
...
@@ -116,7 +116,6 @@ void init()
DepLibSRTP
::
ClassInit
();
DepLibSRTP
::
ClassInit
();
DepUsrSCTP
::
ClassInit
();
DepUsrSCTP
::
ClassInit
();
Utils
::
Crypto
::
ClassInit
();
Utils
::
Crypto
::
ClassInit
();
Utils
::
Crypto
::
ClassInit
();
RTC
::
UdpSocket
::
ClassInit
();
RTC
::
UdpSocket
::
ClassInit
();
RTC
::
TcpServer
::
ClassInit
();
RTC
::
TcpServer
::
ClassInit
();
RTC
::
DtlsTransport
::
ClassInit
();
RTC
::
DtlsTransport
::
ClassInit
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论