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 个修改的文件
包含
196 行增加
和
67 行删除
+196
-67
supportedRtpCapabilities.js
data/supportedRtpCapabilities.js
+5
-1
Room.js
lib/Room.js
+15
-11
options.js
test/data/options.js
+18
-3
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
+6
-6
Room.cpp
worker/src/RTC/Room.cpp
+118
-40
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 =
kind
:
'video'
,
name
:
'video/H264'
,
preferredPayloadType
:
112
,
clockRate
:
90000
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
[
0
,
1
,
2
]
}
},
// Depth codecs:
{
...
...
lib/Room.js
浏览文件 @
73859792
...
...
@@ -258,22 +258,26 @@ class Room extends EventEmitter
}
}
for
(
let
headerExtension
of
capabilities
.
headerExtensions
)
// Ignore if there are no media codecs of this kind.
if
(
kindCapabilities
.
codecs
.
length
>
0
)
{
if
(
headerExtension
.
kind
===
kind
)
for
(
let
headerExtension
of
capabilities
.
headerExtensions
)
{
kindCapabilities
.
headerExtensions
.
push
(
headerExtension
);
if
(
headerExtension
.
kind
===
kind
)
{
kindCapabilities
.
headerExtensions
.
push
(
headerExtension
);
}
else
if
(
headerExtension
.
kind
===
''
)
{
let
clonedHeaderExtension
=
utils
.
cloneObject
(
headerExtension
);
clonedHeaderExtension
.
kind
=
kind
;
kindCapabilities
.
headerExtensions
.
push
(
clonedHeaderExtension
);
}
}
else
if
(
headerExtension
.
kind
===
''
)
{
let
clonedHeaderExtension
=
utils
.
cloneObject
(
headerExtension
);
clonedHeaderExtension
.
kind
=
kind
;
kindCapabilities
.
headerExtensions
.
push
(
clonedHeaderExtension
);
}
kindCapabilities
.
fecMechanisms
=
capabilities
.
fecMechanisms
;
}
kindCapabilities
.
fecMechanisms
=
capabilities
.
fecMechanisms
;
}
}
}
...
...
test/data/options.js
浏览文件 @
73859792
...
...
@@ -7,15 +7,30 @@ module.exports =
mediaCodecs
:
[
{
kind
:
'audio'
,
name
:
'audio/opus'
,
clockRate
:
48000
kind
:
'audio'
,
name
:
'audio/opus'
,
clockRate
:
48000
,
numChannels
:
2
},
{
kind
:
'audio'
,
name
:
'audio/PCMU'
,
clockRate
:
8000
},
{
kind
:
'video'
,
name
:
'video/vp8'
,
clockRate
:
90000
},
{
kind
:
'video'
,
name
:
'video/h264'
,
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
1
}
},
{
kind
:
'depth'
,
name
:
'video/vp8'
,
...
...
test/test_Room.js
浏览文件 @
73859792
...
...
@@ -139,6 +139,11 @@ tap.test('room.getCapabilities() must retrieve current room capabilities', { tim
server
.
createRoom
(
roomOptions
)
.
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
(
'video'
),
'room.getCapabilities("video") 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
private
:
static
RTC
::
RtpCapabilities
supportedRtpCapabilities
;
static
std
::
vector
<
uint8_t
>
availablePayloadTypes
;
public
:
Room
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
roomId
,
Json
::
Value
&
data
);
...
...
@@ -44,7 +45,6 @@ namespace RTC
private
:
RTC
::
Peer
*
GetPeerFromRequest
(
Channel
::
Request
*
request
,
uint32_t
*
peerId
=
nullptr
);
void
SetRtpCapabilities
(
std
::
vector
<
RTC
::
RtpRoomMediaCodec
>&
roomMediaCodecs
);
RTC
::
RtpCodecCapability
GetRtpCodecCapability
(
RTC
::
RtpRoomMediaCodec
&
roomMediaCodec
);
/* Pure virtual methods inherited from RTC::Peer::Listener. */
public
:
...
...
worker/include/RTC/RtpDictionaries.h
浏览文件 @
73859792
...
...
@@ -115,12 +115,12 @@ namespace RTC
RtpCodec
(
Json
::
Value
&
data
);
public
:
RtpCodecMime
mime
;
uint32_t
clockRate
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
ptime
=
0
;
uint32_t
numChannels
=
0
;
RTC
::
CustomParameters
parameters
;
RtpCodecMime
mime
;
uint32_t
clockRate
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
ptime
=
0
;
uint32_t
numChannels
=
1
;
RTC
::
CustomParameters
parameters
;
};
class
RTCRtpCodecRtxParameters
...
...
worker/src/RTC/Room.cpp
浏览文件 @
73859792
...
...
@@ -6,6 +6,7 @@
#include "Utils.h"
#include <string>
#include <vector>
#include <set>
namespace
RTC
{
...
...
@@ -30,7 +31,7 @@ namespace RTC
Json
::
CharReader
*
jsonReader
=
builder
.
newCharReader
();
// 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
;
std
::
string
json_parse_error
;
...
...
@@ -39,7 +40,7 @@ namespace RTC
{
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
;
...
...
@@ -50,7 +51,7 @@ namespace RTC
}
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,61 +354,138 @@ namespace RTC
{
MS_TRACE
();
// Check codecs.
for
(
auto
&
roomMediaCodec
:
roomMediaCodecs
)
// Set codecs.
{
auto
rtpCodecCapability
=
GetRtpCodecCapability
(
roomMediaCodec
);
// 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
)
{
RTC
::
RtpCodecCapability
codecCapability
;
// Append the codec to the room capabilities.
this
->
rtpCapabilities
.
codecs
.
push_back
(
rtpCodecCapability
);
}
// The room has this kind.
roomKinds
.
insert
(
roomMediaCodec
.
kind
);
// TODO: Add feature codec
s.
// Search the given codec in the list of supported codec capabilitie
s.
// Copy supported RTP header extensions.
this
->
rtpCapabilities
.
headerExtensions
=
Room
::
supportedRtpCapabilities
.
headerExtensions
;
auto
it
=
Room
::
supportedRtpCapabilities
.
codecs
.
begin
();
// Copy supported FEC mechanisms.
this
->
rtpCapabilities
.
fecMechanisms
=
Room
::
supportedRtpCapabilities
.
fecMechanisms
;
}
for
(;
it
!=
Room
::
supportedRtpCapabilities
.
codecs
.
end
();
++
it
)
{
auto
&
supportedCodecCapability
=
*
it
;
RTC
::
RtpCodecCapability
Room
::
GetRtpCodecCapability
(
RTC
::
RtpRoomMediaCodec
&
roomMediaCodec
)
{
MS_TRACE
()
;
// Kind must match.
if
(
roomMediaCodec
.
kind
!=
supportedCodecCapability
.
kind
)
continue
;
RTC
::
RtpCodecCapability
codecCapability
;
// Check whether the codec capability matches the given codec.
if
(
supportedCodecCapability
.
MatchesCodec
(
roomMediaCodec
))
{
// Deep copy.
codecCapability
=
supportedCodecCapability
;
// Search the given codec in the list of supported codecs.
break
;
}
}
if
(
it
==
Room
::
supportedRtpCapabilities
.
codecs
.
end
())
MS_THROW_ERROR
(
"no matching codec capability found"
);
auto
it
=
Room
::
supportedRtpCapabilities
.
codecs
.
begin
();
// TODO: Reduce the capabilities of the found (and copied) codec (for
// example set the H264 packetizationMode parameter to a single value).
// NOTE: Maybe a RtpCodecCapability.Reduce(codec) method.
for
(;
it
!=
Room
::
supportedRtpCapabilities
.
codecs
.
end
();
++
it
)
{
auto
&
supportedCodecCapability
=
*
it
;
// Set unique PT.
// Kind must match.
if
(
roomMediaCodec
.
kind
!=
supportedCodecCapability
.
kind
)
continue
;
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
++
;
}
// Check whether the codec capability matches the given codec.
if
(
supportedCodecCapability
.
MatchesCodec
(
roomMediaCodec
))
// Store the selected PT.
roomPayloadTypes
.
insert
(
payloadType
);
// Append the codec to the room capabilities.
this
->
rtpCapabilities
.
codecs
.
push_back
(
codecCapability
);
}
// Add feature codec capabilities.
for
(
auto
&
codecCapability
:
Room
::
supportedRtpCapabilities
.
codecs
)
{
codecCapability
=
supportedCodecCapability
;
// Just feature codecs.
if
(
!
codecCapability
.
mime
.
IsFeatureCodec
())
continue
;
break
;
// 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
);
}
}
if
(
it
==
Room
::
supportedRtpCapabilities
.
codecs
.
end
())
MS_THROW_ERROR
(
"no matching codec capability found"
);
// TODO: Reduce the capabilities of the found (and copied) codec (for
// example set the H264 packetizationMode parameter to a single value).
// NOTE: Maybe a RtpCodecCapability.Reduce(codec) method.
// Set proper payloadType (it may not be the preferred one in some cases).
// Copy supported RTP header extensions.
this
->
rtpCapabilities
.
headerExtensions
=
Room
::
supportedRtpCapabilities
.
headerExtensions
;
return
codecCapability
;
// Copy supported FEC mechanisms.
this
->
rtpCapabilities
.
fecMechanisms
=
Room
::
supportedRtpCapabilities
.
fecMechanisms
;
}
void
Room
::
onPeerClosed
(
RTC
::
Peer
*
peer
)
...
...
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
浏览文件 @
73859792
...
...
@@ -106,7 +106,7 @@ namespace RTC
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
// Add `numChannels`.
if
(
this
->
numChannels
)
if
(
this
->
numChannels
>
1
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
// Add `rtcpFeedback`.
...
...
@@ -150,14 +150,37 @@ namespace RTC
MS_TRACE
();
// MIME must match.
if
(
codec
.
mime
!=
this
->
mime
)
if
(
this
->
mime
!=
codec
.
mime
)
return
false
;
// Clock rate must match.
if
(
codec
.
clockRate
!=
this
->
clockRate
)
if
(
this
->
clockRate
!=
codec
.
clockRate
)
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
;
}
...
...
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
浏览文件 @
73859792
...
...
@@ -80,7 +80,7 @@ namespace RTC
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
// Add `numChannels`.
if
(
this
->
numChannels
)
if
(
this
->
numChannels
>
1
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
// Add `rtx`
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论