Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
73859792
提交
73859792
authored
6月 14, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Lot of work in room capabilities.
上级
4b8aaead
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
165 行增加
和
36 行删除
+165
-36
supportedRtpCapabilities.js
data/supportedRtpCapabilities.js
+5
-1
Room.js
lib/Room.js
+4
-0
options.js
test/data/options.js
+16
-1
test_Room.js
test/test_Room.js
+5
-0
Room.h
worker/include/RTC/Room.h
+1
-1
RtpDictionaries.h
worker/include/RTC/RtpDictionaries.h
+1
-1
Room.cpp
worker/src/RTC/Room.cpp
+105
-27
RtpCodecCapability.cpp
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
+27
-4
RtpCodecParameters.cpp
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
+1
-1
没有找到文件。
data/supportedRtpCapabilities.js
浏览文件 @
73859792
...
@@ -64,7 +64,11 @@ let supportedRtpCapabilities =
...
@@ -64,7 +64,11 @@ let supportedRtpCapabilities =
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/H264'
,
name
:
'video/H264'
,
preferredPayloadType
:
112
,
preferredPayloadType
:
112
,
clockRate
:
90000
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
[
0
,
1
,
2
]
}
},
},
// Depth codecs:
// Depth codecs:
{
{
...
...
lib/Room.js
浏览文件 @
73859792
...
@@ -258,6 +258,9 @@ class Room extends EventEmitter
...
@@ -258,6 +258,9 @@ class Room extends EventEmitter
}
}
}
}
// Ignore if there are no media codecs of this kind.
if
(
kindCapabilities
.
codecs
.
length
>
0
)
{
for
(
let
headerExtension
of
capabilities
.
headerExtensions
)
for
(
let
headerExtension
of
capabilities
.
headerExtensions
)
{
{
if
(
headerExtension
.
kind
===
kind
)
if
(
headerExtension
.
kind
===
kind
)
...
@@ -276,6 +279,7 @@ class Room extends EventEmitter
...
@@ -276,6 +279,7 @@ class Room extends EventEmitter
kindCapabilities
.
fecMechanisms
=
capabilities
.
fecMechanisms
;
kindCapabilities
.
fecMechanisms
=
capabilities
.
fecMechanisms
;
}
}
}
}
}
}
}
module
.
exports
=
Room
;
module
.
exports
=
Room
;
test/data/options.js
浏览文件 @
73859792
...
@@ -9,13 +9,28 @@ module.exports =
...
@@ -9,13 +9,28 @@ module.exports =
{
{
kind
:
'audio'
,
kind
:
'audio'
,
name
:
'audio/opus'
,
name
:
'audio/opus'
,
clockRate
:
48000
clockRate
:
48000
,
numChannels
:
2
},
{
kind
:
'audio'
,
name
:
'audio/PCMU'
,
clockRate
:
8000
},
},
{
{
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/vp8'
,
name
:
'video/vp8'
,
clockRate
:
90000
clockRate
:
90000
},
},
{
kind
:
'video'
,
name
:
'video/h264'
,
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
1
}
},
{
{
kind
:
'depth'
,
kind
:
'depth'
,
name
:
'video/vp8'
,
name
:
'video/vp8'
,
...
...
test/test_Room.js
浏览文件 @
73859792
...
@@ -139,6 +139,11 @@ tap.test('room.getCapabilities() must retrieve current room capabilities', { tim
...
@@ -139,6 +139,11 @@ tap.test('room.getCapabilities() must retrieve current room capabilities', { tim
server
.
createRoom
(
roomOptions
)
server
.
createRoom
(
roomOptions
)
.
then
((
room
)
=>
.
then
((
room
)
=>
{
{
// TODO: REMOVE
// console.log(JSON.stringify(room.getCapabilities('audio'), null, '\t'));
// console.log(JSON.stringify(room.getCapabilities('video'), null, '\t'));
// console.log(JSON.stringify(room.getCapabilities('depth'), null, '\t'));
t
.
ok
(
room
.
getCapabilities
(
'audio'
),
'room.getCapabilities("audio") returns an object'
);
t
.
ok
(
room
.
getCapabilities
(
'audio'
),
'room.getCapabilities("audio") returns an object'
);
t
.
ok
(
room
.
getCapabilities
(
'video'
),
'room.getCapabilities("video") returns an object'
);
t
.
ok
(
room
.
getCapabilities
(
'video'
),
'room.getCapabilities("video") returns an object'
);
t
.
ok
(
room
.
getCapabilities
(
'depth'
),
'room.getCapabilities("depth") returns an object'
);
t
.
ok
(
room
.
getCapabilities
(
'depth'
),
'room.getCapabilities("depth") returns an object'
);
...
...
worker/include/RTC/Room.h
浏览文件 @
73859792
...
@@ -31,6 +31,7 @@ namespace RTC
...
@@ -31,6 +31,7 @@ namespace RTC
private
:
private
:
static
RTC
::
RtpCapabilities
supportedRtpCapabilities
;
static
RTC
::
RtpCapabilities
supportedRtpCapabilities
;
static
std
::
vector
<
uint8_t
>
availablePayloadTypes
;
public
:
public
:
Room
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
roomId
,
Json
::
Value
&
data
);
Room
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
roomId
,
Json
::
Value
&
data
);
...
@@ -44,7 +45,6 @@ namespace RTC
...
@@ -44,7 +45,6 @@ namespace RTC
private
:
private
:
RTC
::
Peer
*
GetPeerFromRequest
(
Channel
::
Request
*
request
,
uint32_t
*
peerId
=
nullptr
);
RTC
::
Peer
*
GetPeerFromRequest
(
Channel
::
Request
*
request
,
uint32_t
*
peerId
=
nullptr
);
void
SetRtpCapabilities
(
std
::
vector
<
RTC
::
RtpRoomMediaCodec
>&
roomMediaCodecs
);
void
SetRtpCapabilities
(
std
::
vector
<
RTC
::
RtpRoomMediaCodec
>&
roomMediaCodecs
);
RTC
::
RtpCodecCapability
GetRtpCodecCapability
(
RTC
::
RtpRoomMediaCodec
&
roomMediaCodec
);
/* Pure virtual methods inherited from RTC::Peer::Listener. */
/* Pure virtual methods inherited from RTC::Peer::Listener. */
public
:
public
:
...
...
worker/include/RTC/RtpDictionaries.h
浏览文件 @
73859792
...
@@ -119,7 +119,7 @@ namespace RTC
...
@@ -119,7 +119,7 @@ namespace RTC
uint32_t
clockRate
=
0
;
uint32_t
clockRate
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
ptime
=
0
;
uint32_t
ptime
=
0
;
uint32_t
numChannels
=
0
;
uint32_t
numChannels
=
1
;
RTC
::
CustomParameters
parameters
;
RTC
::
CustomParameters
parameters
;
};
};
...
...
worker/src/RTC/Room.cpp
浏览文件 @
73859792
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "Utils.h"
#include "Utils.h"
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <set>
namespace
RTC
namespace
RTC
{
{
...
@@ -30,7 +31,7 @@ namespace RTC
...
@@ -30,7 +31,7 @@ namespace RTC
Json
::
CharReader
*
jsonReader
=
builder
.
newCharReader
();
Json
::
CharReader
*
jsonReader
=
builder
.
newCharReader
();
// NOTE: This line is auto-generated frmo data/supportedRtpCapabilities.js.
// NOTE: This line is auto-generated frmo data/supportedRtpCapabilities.js.
const
std
::
string
capabilities
=
R"({"codecs":[{"kind":"audio","name":"audio/opus","preferredPayloadType":96,"clockRate":48000,"numChannels":2},{"kind":"audio","name":"audio/ISAC","preferredPayloadType":97,"clockRate":16000},{"kind":"audio","name":"audio/ISAC","preferredPayloadType":98,"clockRate":32000},{"kind":"audio","name":"audio/G722","preferredPayloadType":9,"clockRate":8000},{"kind":"audio","name":"audio/PCMU","preferredPayloadType":0,"clockRate":8000},{"kind":"audio","name":"audio/PCMA","preferredPayloadType":8,"clockRate":8000},{"kind":"video","name":"video/VP8","preferredPayloadType":110,"clockRate":90000},{"kind":"video","name":"video/VP9","preferredPayloadType":111,"clockRate":90000},{"kind":"video","name":"video/H264","preferredPayloadType":112,"clockRate":90000},{"kind":"depth","name":"video/VP8","preferredPayloadType":120,"clockRate":90000},{"kind":"audio","name":"audio/CN","preferredPayloadType":77,"clockRate":32000},{"kind":"audio","name":"audio/CN","preferredPayloadType":78,"clockRate":16000},{"kind":"audio","name":"audio/CN","preferredPayloadType":13,"clockRate":8000},{"kind":"audio","name":"audio/telephone-event","preferredPayloadType":79,"clockRate":8000}],"headerExtensions":[{"kind":"","uri":"urn:ietf:params:rtp-hdrext:sdes:mid","preferredId":1,"preferredEncrypt":false}]})"
;
const
std
::
string
capabilities
=
R"({"codecs":[{"kind":"audio","name":"audio/opus","preferredPayloadType":96,"clockRate":48000,"numChannels":2},{"kind":"audio","name":"audio/ISAC","preferredPayloadType":97,"clockRate":16000},{"kind":"audio","name":"audio/ISAC","preferredPayloadType":98,"clockRate":32000},{"kind":"audio","name":"audio/G722","preferredPayloadType":9,"clockRate":8000},{"kind":"audio","name":"audio/PCMU","preferredPayloadType":0,"clockRate":8000},{"kind":"audio","name":"audio/PCMA","preferredPayloadType":8,"clockRate":8000},{"kind":"video","name":"video/VP8","preferredPayloadType":110,"clockRate":90000},{"kind":"video","name":"video/VP9","preferredPayloadType":111,"clockRate":90000},{"kind":"video","name":"video/H264","preferredPayloadType":112,"clockRate":90000
,"parameters":{"packetizationMode":[0,1,2]}
},{"kind":"depth","name":"video/VP8","preferredPayloadType":120,"clockRate":90000},{"kind":"audio","name":"audio/CN","preferredPayloadType":77,"clockRate":32000},{"kind":"audio","name":"audio/CN","preferredPayloadType":78,"clockRate":16000},{"kind":"audio","name":"audio/CN","preferredPayloadType":13,"clockRate":8000},{"kind":"audio","name":"audio/telephone-event","preferredPayloadType":79,"clockRate":8000}],"headerExtensions":[{"kind":"","uri":"urn:ietf:params:rtp-hdrext:sdes:mid","preferredId":1,"preferredEncrypt":false}]})"
;
Json
::
Value
json
;
Json
::
Value
json
;
std
::
string
json_parse_error
;
std
::
string
json_parse_error
;
...
@@ -39,7 +40,7 @@ namespace RTC
...
@@ -39,7 +40,7 @@ namespace RTC
{
{
delete
jsonReader
;
delete
jsonReader
;
MS_THROW_ERROR_STD
(
"JSON parsing error in
default
RTP capabilities: %s"
,
json_parse_error
.
c_str
());
MS_THROW_ERROR_STD
(
"JSON parsing error in
supported
RTP capabilities: %s"
,
json_parse_error
.
c_str
());
}
}
delete
jsonReader
;
delete
jsonReader
;
...
@@ -50,7 +51,7 @@ namespace RTC
...
@@ -50,7 +51,7 @@ namespace RTC
}
}
catch
(
const
MediaSoupError
&
error
)
catch
(
const
MediaSoupError
&
error
)
{
{
MS_THROW_ERROR_STD
(
"wrong
default
RTP capabilities: %s"
,
error
.
what
());
MS_THROW_ERROR_STD
(
"wrong
supported
RTP capabilities: %s"
,
error
.
what
());
}
}
}
}
}
}
...
@@ -353,32 +354,40 @@ namespace RTC
...
@@ -353,32 +354,40 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
// Check codecs.
// Set codecs.
{
// Available dynamic payload types.
static
const
std
::
vector
<
const
uint8_t
>
dynamicPayloadTypes
{
100
,
101
,
102
,
103
,
104
,
105
,
106
,
107
,
108
,
109
,
110
,
111
,
112
,
113
,
114
,
115
,
116
,
117
,
118
,
119
,
120
,
121
,
122
,
123
,
124
,
125
,
126
,
127
,
96
,
97
,
98
,
99
,
77
,
78
,
79
,
80
,
81
,
82
,
83
,
84
,
85
,
86
,
87
,
88
,
89
,
90
,
91
,
92
,
93
,
94
,
95
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
,
51
,
52
,
53
,
54
,
55
,
56
,
57
,
58
,
59
,
60
,
61
,
62
,
63
,
64
,
65
,
66
,
67
,
68
,
69
,
70
,
71
};
// Maximum static payload type.
static
const
uint8_t
maxStaticPayloadType
=
34
;
// Iterator for available dynamic payload types.
auto
dynamicPayloadTypeIt
=
dynamicPayloadTypes
.
begin
();
// Payload types used by the room.
std
::
set
<
uint8_t
>
roomPayloadTypes
;
// Given media kinds.
std
::
set
<
RTC
::
Media
::
Kind
>
roomKinds
;
// Set the given room codecs.
for
(
auto
&
roomMediaCodec
:
roomMediaCodecs
)
for
(
auto
&
roomMediaCodec
:
roomMediaCodecs
)
{
{
auto
rtpCodecCapability
=
GetRtpCodecCapability
(
roomMediaCodec
);
// Append the codec to the room capabilities.
this
->
rtpCapabilities
.
codecs
.
push_back
(
rtpCodecCapability
);
}
// TODO: Add feature codecs.
// Copy supported RTP header extensions.
this
->
rtpCapabilities
.
headerExtensions
=
Room
::
supportedRtpCapabilities
.
headerExtensions
;
// Copy supported FEC mechanisms.
this
->
rtpCapabilities
.
fecMechanisms
=
Room
::
supportedRtpCapabilities
.
fecMechanisms
;
}
RTC
::
RtpCodecCapability
Room
::
GetRtpCodecCapability
(
RTC
::
RtpRoomMediaCodec
&
roomMediaCodec
)
{
MS_TRACE
();
RTC
::
RtpCodecCapability
codecCapability
;
RTC
::
RtpCodecCapability
codecCapability
;
// Search the given codec in the list of supported codecs.
// The room has this kind.
roomKinds
.
insert
(
roomMediaCodec
.
kind
);
// Search the given codec in the list of supported codec capabilities.
auto
it
=
Room
::
supportedRtpCapabilities
.
codecs
.
begin
();
auto
it
=
Room
::
supportedRtpCapabilities
.
codecs
.
begin
();
...
@@ -393,6 +402,7 @@ namespace RTC
...
@@ -393,6 +402,7 @@ namespace RTC
// Check whether the codec capability matches the given codec.
// Check whether the codec capability matches the given codec.
if
(
supportedCodecCapability
.
MatchesCodec
(
roomMediaCodec
))
if
(
supportedCodecCapability
.
MatchesCodec
(
roomMediaCodec
))
{
{
// Deep copy.
codecCapability
=
supportedCodecCapability
;
codecCapability
=
supportedCodecCapability
;
break
;
break
;
...
@@ -405,9 +415,77 @@ namespace RTC
...
@@ -405,9 +415,77 @@ namespace RTC
// example set the H264 packetizationMode parameter to a single value).
// example set the H264 packetizationMode parameter to a single value).
// NOTE: Maybe a RtpCodecCapability.Reduce(codec) method.
// NOTE: Maybe a RtpCodecCapability.Reduce(codec) method.
// Set proper payloadType (it may not be the preferred one in some cases).
// Set unique PT.
auto
payloadType
=
codecCapability
.
preferredPayloadType
;
// If the codec capability has static PT and such a PT is not already used,
// let it untouched.
if
(
payloadType
>
maxStaticPayloadType
||
roomPayloadTypes
.
find
(
payloadType
)
!=
roomPayloadTypes
.
end
())
{
// If there are no more dynamic PTs throw.
if
(
dynamicPayloadTypeIt
==
dynamicPayloadTypes
.
end
())
MS_THROW_ERROR
(
"not enough available dynamic payload types for given media codecs"
);
// Assign preferred PT.
payloadType
=
*
dynamicPayloadTypeIt
;
codecCapability
.
preferredPayloadType
=
payloadType
;
// Increment the iterator.
dynamicPayloadTypeIt
++
;
}
// Store the selected PT.
roomPayloadTypes
.
insert
(
payloadType
);
return
codecCapability
;
// Append the codec to the room capabilities.
this
->
rtpCapabilities
.
codecs
.
push_back
(
codecCapability
);
}
// Add feature codec capabilities.
for
(
auto
&
codecCapability
:
Room
::
supportedRtpCapabilities
.
codecs
)
{
// Just feature codecs.
if
(
!
codecCapability
.
mime
.
IsFeatureCodec
())
continue
;
// Ignore if no media codecs of this kind were given.
if
(
roomKinds
.
find
(
codecCapability
.
kind
)
==
roomKinds
.
end
())
continue
;
// Set unique PT.
auto
payloadType
=
codecCapability
.
preferredPayloadType
;
if
(
payloadType
>
maxStaticPayloadType
||
roomPayloadTypes
.
find
(
payloadType
)
!=
roomPayloadTypes
.
end
())
{
// If there are no more dynamic PTs throw.
if
(
dynamicPayloadTypeIt
==
dynamicPayloadTypes
.
end
())
MS_THROW_ERROR
(
"not enough available dynamic payload types for feature codecs"
);
// Assign preferred PT.
payloadType
=
*
dynamicPayloadTypeIt
;
codecCapability
.
preferredPayloadType
=
payloadType
;
// Increment the iterator.
dynamicPayloadTypeIt
++
;
}
// Store the selected PT.
roomPayloadTypes
.
insert
(
payloadType
);
// Append the codec to the room capabilities.
this
->
rtpCapabilities
.
codecs
.
push_back
(
codecCapability
);
}
}
// Copy supported RTP header extensions.
this
->
rtpCapabilities
.
headerExtensions
=
Room
::
supportedRtpCapabilities
.
headerExtensions
;
// Copy supported FEC mechanisms.
this
->
rtpCapabilities
.
fecMechanisms
=
Room
::
supportedRtpCapabilities
.
fecMechanisms
;
}
}
void
Room
::
onPeerClosed
(
RTC
::
Peer
*
peer
)
void
Room
::
onPeerClosed
(
RTC
::
Peer
*
peer
)
...
...
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
浏览文件 @
73859792
...
@@ -106,7 +106,7 @@ namespace RTC
...
@@ -106,7 +106,7 @@ namespace RTC
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
// Add `numChannels`.
// Add `numChannels`.
if
(
this
->
numChannels
)
if
(
this
->
numChannels
>
1
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
// Add `rtcpFeedback`.
// Add `rtcpFeedback`.
...
@@ -150,14 +150,37 @@ namespace RTC
...
@@ -150,14 +150,37 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
// MIME must match.
// MIME must match.
if
(
codec
.
mime
!=
this
->
mime
)
if
(
this
->
mime
!=
codec
.
mime
)
return
false
;
return
false
;
// Clock rate must match.
// Clock rate must match.
if
(
codec
.
clockRate
!=
this
->
clockRate
)
if
(
this
->
clockRate
!=
codec
.
clockRate
)
return
false
;
return
false
;
// TODO: Match per codec parameters, ptime, numChannels, etc.
// Per kind checks.
switch
(
this
->
kind
)
{
case
RTC
:
:
Media
::
Kind
::
AUDIO
:
{
// Num channels must match
if
(
this
->
numChannels
!=
codec
.
numChannels
)
return
false
;
break
;
}
case
RTC
:
:
Media
::
Kind
::
VIDEO
:
{
// TODO: check SVC stuff.
break
;
}
default
:
;
}
// TODO: Match per codec parameters, etc.
return
true
;
return
true
;
}
}
...
...
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
浏览文件 @
73859792
...
@@ -80,7 +80,7 @@ namespace RTC
...
@@ -80,7 +80,7 @@ namespace RTC
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
// Add `numChannels`.
// Add `numChannels`.
if
(
this
->
numChannels
)
if
(
this
->
numChannels
>
1
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
// Add `rtx`
// Add `rtx`
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论