Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
ccd6588c
提交
ccd6588c
authored
6月 12, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More stuff in codecs
上级
a668bb05
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
278 行增加
和
80 行删除
+278
-80
supportedRtpCapabilities.js
data/supportedRtpCapabilities.js
+41
-13
gulpfile.js
gulpfile.js
+6
-6
options.js
test/data/options.js
+15
-3
test_RtpReceiver.js
test/test_RtpReceiver.js
+71
-27
CustomParameters.h
worker/include/RTC/CustomParameters.h
+35
-6
Room.h
worker/include/RTC/Room.h
+2
-0
RtpDictionaries.h
worker/include/RTC/RtpDictionaries.h
+13
-1
CustomParameters.cpp
worker/src/RTC/CustomParameters.cpp
+21
-0
Room.cpp
worker/src/RTC/Room.cpp
+47
-9
Media.cpp
worker/src/RTC/RtpDictionaries/Media.cpp
+4
-2
RtpCodecCapability.cpp
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
+6
-5
RtpCodecParameters.cpp
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
+6
-5
RtpRoomMediaCodec.cpp
worker/src/RTC/RtpDictionaries/RtpRoomMediaCodec.cpp
+11
-3
没有找到文件。
data/supportedRtpCapabilities.js
浏览文件 @
ccd6588c
...
@@ -9,7 +9,7 @@ let supportedRtpCapabilities =
...
@@ -9,7 +9,7 @@ let supportedRtpCapabilities =
{
{
codecs
:
codecs
:
[
[
// Audio codecs
.
// Audio codecs
:
{
{
kind
:
'audio'
,
kind
:
'audio'
,
name
:
'audio/opus'
,
name
:
'audio/opus'
,
...
@@ -47,37 +47,65 @@ let supportedRtpCapabilities =
...
@@ -47,37 +47,65 @@ let supportedRtpCapabilities =
preferredPayloadType
:
8
,
preferredPayloadType
:
8
,
clockRate
:
8000
clockRate
:
8000
},
},
// Video codecs
.
// Video codecs
:
{
{
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/VP8'
,
name
:
'video/VP8'
,
preferredPayloadType
:
1
0
0
,
preferredPayloadType
:
1
1
0
,
clockRate
:
90000
clockRate
:
90000
},
},
{
{
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/VP9'
,
name
:
'video/VP9'
,
preferredPayloadType
:
1
0
1
,
preferredPayloadType
:
1
1
1
,
clockRate
:
90000
clockRate
:
90000
},
},
{
{
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/H264'
,
name
:
'video/H264'
,
preferredPayloadType
:
1
0
2
,
preferredPayloadType
:
1
1
2
,
clockRate
:
90000
clockRate
:
90000
},
},
{
// Depth codecs:
kind
:
'video'
,
name
:
'video/H265'
,
preferredPayloadType
:
103
,
clockRate
:
90000
},
// Depth codecs.
{
{
kind
:
'depth'
,
kind
:
'depth'
,
name
:
'video/VP8'
,
name
:
'video/VP8'
,
preferredPayloadType
:
1
1
0
,
preferredPayloadType
:
1
2
0
,
clockRate
:
90000
clockRate
:
90000
},
// Feature codecs:
{
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
}
}
]
]
};
};
...
...
gulpfile.js
浏览文件 @
ccd6588c
...
@@ -10,13 +10,13 @@ const shell = require('gulp-shell');
...
@@ -10,13 +10,13 @@ const shell = require('gulp-shell');
let
tests
=
let
tests
=
[
[
'test/test_mediasoup.js'
,
//
'test/test_mediasoup.js',
'test/test_Server.js'
,
//
'test/test_Server.js',
'test/test_Room.js'
,
//
'test/test_Room.js',
'test/test_Peer.js'
,
//
'test/test_Peer.js',
'test/test_Transport.js'
,
//
'test/test_Transport.js',
'test/test_RtpReceiver.js'
,
'test/test_RtpReceiver.js'
,
'test/test_extra.js'
//
'test/test_extra.js'
// NOTE: Disable this test until fixed
// NOTE: Disable this test until fixed
// 'test/test_scene_1.js'
// 'test/test_scene_1.js'
];
];
...
...
test/data/options.js
浏览文件 @
ccd6588c
...
@@ -6,9 +6,21 @@ module.exports =
...
@@ -6,9 +6,21 @@ module.exports =
{
{
mediaCodecs
:
mediaCodecs
:
[
[
{
kind
:
'audio'
,
name
:
'audio/opus'
},
{
{
kind
:
'video'
,
name
:
'video/vp8'
},
kind
:
'audio'
,
{
kind
:
'depth'
,
name
:
'audio/opus'
}
name
:
'audio/opus'
,
clockRate
:
48000
},
{
kind
:
'video'
,
name
:
'video/vp8'
,
clockRate
:
90000
},
{
kind
:
'depth'
,
name
:
'video/vp8'
,
clockRate
:
90000
}
]
]
},
},
...
...
test/test_RtpReceiver.js
浏览文件 @
ccd6588c
...
@@ -40,7 +40,8 @@ tap.test('rtpReceiver.receive() with no encodings must succeed', { timeout: 2000
...
@@ -40,7 +40,8 @@ tap.test('rtpReceiver.receive() with no encodings must succeed', { timeout: 2000
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
100
payloadType
:
100
,
clockRate
:
48000
}
}
]
]
})
})
...
@@ -73,11 +74,13 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
...
@@ -73,11 +74,13 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
[
[
{
{
name
:
'video/H264'
,
name
:
'video/H264'
,
payloadType
:
101
payloadType
:
101
,
clockRate
:
90000
},
},
{
{
name
:
'video/H265'
,
name
:
'video/H265'
,
payloadType
:
102
payloadType
:
102
,
clockRate
:
90000
}
}
],
],
encodings
:
encodings
:
...
@@ -148,7 +151,8 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
...
@@ -148,7 +151,8 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
foo
:
'barœæ€'
,
foo
:
'barœæ€'
,
bar
:
true
,
bar
:
true
,
baz
:
-
123
,
baz
:
-
123
,
lol
:
-
456.789
lol
:
-
456.789
,
ids
:
[
123
,
2
,
3
]
}
}
}
}
],
],
...
@@ -243,7 +247,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
...
@@ -243,7 +247,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
101
,
payloadType
:
101
,
clockRate
:
90
000
clockRate
:
48
000
}
}
],
],
encodings
:
encodings
:
...
@@ -265,7 +269,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
...
@@ -265,7 +269,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
101
,
payloadType
:
101
,
clockRate
:
90
000
clockRate
:
48
000
}
}
],
],
encodings
:
encodings
:
...
@@ -339,7 +343,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -339,7 +343,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'/opus'
,
name
:
'/opus'
,
payloadType
:
101
payloadType
:
101
,
clockRate
:
48000
}
}
]
]
})
})
...
@@ -358,7 +363,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -358,7 +363,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'audio/'
,
name
:
'audio/'
,
payloadType
:
101
payloadType
:
101
,
clockRate
:
48000
}
}
]
]
})
})
...
@@ -376,7 +382,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -376,7 +382,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
codecs
:
codecs
:
[
[
{
{
payloadType
:
102
payloadType
:
102
,
clockRate
:
90000
}
}
]
]
})
})
...
@@ -394,7 +401,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -394,7 +401,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
codecs
:
codecs
:
[
[
{
{
name
:
'audio/opus'
name
:
'audio/opus'
,
clockRate
:
48000
}
}
]
]
})
})
...
@@ -405,6 +413,25 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -405,6 +413,25 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
});
});
});
});
funcs
.
push
(
function
()
{
return
rtpReceiver
.
receive
(
{
codecs
:
[
{
name
:
'audio/opus'
,
payloadType
:
102
}
]
})
.
then
(()
=>
t
.
fail
(
'rtpReceiver.receive() succeeded'
))
.
catch
((
error
)
=>
{
t
.
pass
(
`rtpReceiver.receive() without codec.clockRate failed:
${
error
}
`
);
});
});
funcs
.
push
(
function
()
funcs
.
push
(
function
()
{
{
return
rtpReceiver
.
receive
(
return
rtpReceiver
.
receive
(
...
@@ -414,6 +441,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -414,6 +441,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
101
,
payloadType
:
101
,
clockRate
:
48000
,
rtx
:
{}
rtx
:
{}
}
}
]
]
...
@@ -433,11 +461,13 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -433,11 +461,13 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
101
payloadType
:
101
,
clockRate
:
48000
},
},
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
101
payloadType
:
101
,
clockRate
:
48000
}
}
]
]
})
})
...
@@ -457,6 +487,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -457,6 +487,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
100
,
payloadType
:
100
,
clockRate
:
48000
,
rtx
:
rtx
:
{
{
payloadType
:
101
payloadType
:
101
...
@@ -464,7 +495,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -464,7 +495,8 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
},
},
{
{
name
:
'audio/G722'
,
name
:
'audio/G722'
,
payloadType
:
101
payloadType
:
101
,
clockRate
:
8000
}
}
]
]
})
})
...
@@ -497,7 +529,8 @@ tap.test('rtpReceiver.receive() with wrong encodings must fail', { timeout: 2000
...
@@ -497,7 +529,8 @@ tap.test('rtpReceiver.receive() with wrong encodings must fail', { timeout: 2000
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
101
payloadType
:
101
,
clockRate
:
48000
}
}
],
],
encodings
:
encodings
:
...
@@ -522,11 +555,13 @@ tap.test('rtpReceiver.receive() with wrong encodings must fail', { timeout: 2000
...
@@ -522,11 +555,13 @@ tap.test('rtpReceiver.receive() with wrong encodings must fail', { timeout: 2000
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
101
payloadType
:
101
,
clockRate
:
48000
},
},
{
{
name
:
'audio/CN'
,
name
:
'audio/CN'
,
payloadType
:
102
payloadType
:
102
,
clockRate
:
16000
}
}
],
],
encodings
:
encodings
:
...
@@ -565,7 +600,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
...
@@ -565,7 +600,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
101
,
payloadType
:
101
,
clockRate
:
90
000
clockRate
:
48
000
}
}
]
]
})
})
...
@@ -581,7 +616,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
...
@@ -581,7 +616,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
{
{
name
:
'audio/PCMU'
,
name
:
'audio/PCMU'
,
payloadType
:
101
,
payloadType
:
101
,
clockRate
:
90
000
clockRate
:
8
000
}
}
]
]
})
})
...
@@ -613,7 +648,8 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
...
@@ -613,7 +648,8 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
100
payloadType
:
100
,
clockRate
:
48000
}
}
]
]
})
})
...
@@ -647,11 +683,13 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
...
@@ -647,11 +683,13 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
100
payloadType
:
100
,
clockRate
:
48000
},
},
{
{
name
:
'audio/PCMU'
,
name
:
'audio/PCMU'
,
payloadType
:
0
payloadType
:
0
,
clockRate
:
8000
}
}
]
]
})
})
...
@@ -688,11 +726,13 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
...
@@ -688,11 +726,13 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
100
payloadType
:
100
,
clockRate
:
48000
},
},
{
{
name
:
'audio/PCMU'
,
name
:
'audio/PCMU'
,
payloadType
:
0
payloadType
:
0
,
clockRate
:
8000
}
}
],
],
encodings
:
encodings
:
...
@@ -739,11 +779,13 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
...
@@ -739,11 +779,13 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
100
payloadType
:
100
,
clockRate
:
48000
},
},
{
{
name
:
'audio/PCMU'
,
name
:
'audio/PCMU'
,
payloadType
:
0
payloadType
:
0
,
clockRate
:
8000
}
}
],
],
encodings
:
encodings
:
...
@@ -788,11 +830,13 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
...
@@ -788,11 +830,13 @@ tap.test('rtpReceiver.receive() should produce the expected RTP listener routing
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
100
payloadType
:
100
,
clockRate
:
48000
},
},
{
{
name
:
'audio/PCMU'
,
name
:
'audio/PCMU'
,
payloadType
:
0
payloadType
:
0
,
clockRate
:
8000
}
}
],
],
encodings
:
encodings
:
...
...
worker/include/RTC/CustomParameters.h
浏览文件 @
ccd6588c
...
@@ -17,7 +17,8 @@ namespace RTC
...
@@ -17,7 +17,8 @@ namespace RTC
BOOLEAN
=
1
,
BOOLEAN
=
1
,
INTEGER
,
INTEGER
,
DOUBLE
,
DOUBLE
,
STRING
STRING
,
ARRAY_POSITIVE_INTEGER
};
};
public
:
public
:
...
@@ -43,18 +44,40 @@ namespace RTC
...
@@ -43,18 +44,40 @@ namespace RTC
stringValue
(
stringValue
)
stringValue
(
stringValue
)
{}
{}
CustomParameterValue
(
std
::
vector
<
uint32_t
>&
arrayPositiveInteger
)
:
type
(
Type
::
ARRAY_POSITIVE_INTEGER
),
arrayPositiveInteger
(
arrayPositiveInteger
)
{}
Json
::
Value
toJson
()
Json
::
Value
toJson
()
{
{
switch
(
this
->
type
)
switch
(
this
->
type
)
{
{
case
Type
:
:
BOOLEAN
:
case
Type
:
:
BOOLEAN
:
{
return
this
->
booleanValue
;
return
this
->
booleanValue
;
}
case
Type
:
:
INTEGER
:
case
Type
:
:
INTEGER
:
{
return
(
Json
::
Int
)
this
->
integerValue
;
return
(
Json
::
Int
)
this
->
integerValue
;
}
case
Type
:
:
DOUBLE
:
case
Type
:
:
DOUBLE
:
{
return
this
->
doubleValue
;
return
this
->
doubleValue
;
}
case
Type
:
:
STRING
:
case
Type
:
:
STRING
:
{
return
this
->
stringValue
;
return
this
->
stringValue
;
}
case
Type
:
:
ARRAY_POSITIVE_INTEGER
:
{
Json
::
Value
array
(
Json
::
arrayValue
);
for
(
auto
&
entry
:
this
->
arrayPositiveInteger
)
array
.
append
((
Json
::
UInt
)
entry
);
return
array
;
}
default
:
default
:
return
Json
::
nullValue
;
return
Json
::
nullValue
;
}
}
...
@@ -90,14 +113,20 @@ namespace RTC
...
@@ -90,14 +113,20 @@ namespace RTC
return
this
->
type
==
Type
::
STRING
;
return
this
->
type
==
Type
::
STRING
;
}
}
bool
IsArrayPositiveInteger
()
{
return
this
->
type
==
Type
::
ARRAY_POSITIVE_INTEGER
;
}
private
:
private
:
Type
type
;
Type
type
;
public
:
public
:
bool
booleanValue
=
false
;
bool
booleanValue
=
false
;
int32_t
integerValue
=
0
;
int32_t
integerValue
=
0
;
double
doubleValue
=
0
.
0
;
double
doubleValue
=
0
.
0
;
std
::
string
stringValue
;
std
::
string
stringValue
;
std
::
vector
<
uint32_t
>
arrayPositiveInteger
;
};
};
typedef
std
::
unordered_map
<
std
::
string
,
CustomParameterValue
>
CustomParameters
;
typedef
std
::
unordered_map
<
std
::
string
,
CustomParameterValue
>
CustomParameters
;
...
...
worker/include/RTC/Room.h
浏览文件 @
ccd6588c
...
@@ -42,6 +42,8 @@ namespace RTC
...
@@ -42,6 +42,8 @@ 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
);
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
浏览文件 @
ccd6588c
...
@@ -18,7 +18,8 @@ namespace RTC
...
@@ -18,7 +18,8 @@ namespace RTC
{
{
AUDIO
=
1
,
AUDIO
=
1
,
VIDEO
,
VIDEO
,
DEPTH
DEPTH
,
ALL
};
};
public
:
public
:
...
@@ -72,6 +73,16 @@ namespace RTC
...
@@ -72,6 +73,16 @@ namespace RTC
public
:
public
:
RtpCodecMime
()
{};
RtpCodecMime
()
{};
bool
operator
==
(
const
RtpCodecMime
&
other
)
{
return
this
->
type
==
other
.
type
&&
this
->
subtype
==
other
.
subtype
;
}
bool
operator
!=
(
const
RtpCodecMime
&
other
)
{
return
!
(
*
this
==
other
);
}
void
SetName
(
std
::
string
&
name
);
void
SetName
(
std
::
string
&
name
);
std
::
string
&
GetName
()
std
::
string
&
GetName
()
...
@@ -244,6 +255,7 @@ namespace RTC
...
@@ -244,6 +255,7 @@ namespace RTC
class
RtpCodecCapability
class
RtpCodecCapability
{
{
public
:
public
:
RtpCodecCapability
()
{};
RtpCodecCapability
(
Json
::
Value
&
data
);
RtpCodecCapability
(
Json
::
Value
&
data
);
Json
::
Value
toJson
();
Json
::
Value
toJson
();
...
...
worker/src/RTC/CustomParameters.cpp
浏览文件 @
ccd6588c
...
@@ -56,6 +56,27 @@ namespace RTC
...
@@ -56,6 +56,27 @@ namespace RTC
break
;
break
;
}
}
case
Json
:
:
arrayValue
:
{
std
::
vector
<
uint32_t
>
arrayPositiveInteger
;
bool
isValid
=
true
;
for
(
Json
::
UInt
i
=
0
;
i
<
value
.
size
()
&&
isValid
;
i
++
)
{
auto
&
entry
=
value
[
i
];
if
(
entry
.
isUInt
())
arrayPositiveInteger
.
push_back
((
uint32_t
)
entry
.
asUInt
());
else
isValid
=
false
;
}
if
(
isValid
)
parameters
[
key
]
=
CustomParameterValue
(
arrayPositiveInteger
);
break
;
}
default
:
default
:
;
// Just ignore other value types.
;
// Just ignore other value types.
}
}
...
...
worker/src/RTC/Room.cpp
浏览文件 @
ccd6588c
...
@@ -30,7 +30,7 @@ namespace RTC
...
@@ -30,7 +30,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":1
00,"clockRate":90000},{"kind":"video","name":"video/VP9","preferredPayloadType":101,"clockRate":90000},{"kind":"video","name":"video/H264","preferredPayloadType":102,"clockRate":90000},{"kind":"video","name":"video/H265","preferredPayloadType":103,"clockRate":90000},{"kind":"depth","name":"video/VP8","preferredPayloadType":110,"clockRate":90
000}]})"
;
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":1
10,"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":8
000}]})"
;
Json
::
Value
json
;
Json
::
Value
json
;
std
::
string
json_parse_error
;
std
::
string
json_parse_error
;
...
@@ -66,18 +66,12 @@ namespace RTC
...
@@ -66,18 +66,12 @@ namespace RTC
static
const
Json
::
StaticString
k_mediaCodecs
(
"mediaCodecs"
);
static
const
Json
::
StaticString
k_mediaCodecs
(
"mediaCodecs"
);
// Initialize room RTP capabilities with all the supported ones.
this
->
rtpCapabilities
=
Room
::
supportedRtpCapabilities
;
// `mediaCodecs` is mandatory.
// `mediaCodecs` is mandatory.
if
(
!
data
[
k_mediaCodecs
].
isArray
())
if
(
!
data
[
k_mediaCodecs
].
isArray
())
MS_THROW_ERROR
(
"missing mediaCodecs"
);
MS_THROW_ERROR
(
"missing mediaCodecs"
);
auto
&
json_mediaCodecs
=
data
[
k_mediaCodecs
];
auto
&
json_mediaCodecs
=
data
[
k_mediaCodecs
];
if
(
json_mediaCodecs
.
size
()
==
0
)
MS_THROW_ERROR
(
"empty mediaCodecs"
);
std
::
vector
<
RtpRoomMediaCodec
>
mediaCodecs
;
std
::
vector
<
RtpRoomMediaCodec
>
mediaCodecs
;
for
(
Json
::
UInt
i
=
0
;
i
<
json_mediaCodecs
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_mediaCodecs
.
size
();
i
++
)
...
@@ -85,9 +79,11 @@ namespace RTC
...
@@ -85,9 +79,11 @@ namespace RTC
RTC
::
RtpRoomMediaCodec
mediaCodec
(
json_mediaCodecs
[
i
]);
RTC
::
RtpRoomMediaCodec
mediaCodec
(
json_mediaCodecs
[
i
]);
mediaCodecs
.
push_back
(
mediaCodec
);
mediaCodecs
.
push_back
(
mediaCodec
);
// TODO: MORE
}
}
// Set room RTP capabilities.
// NOTE: This may throw.
SetRtpCapabilities
(
mediaCodecs
);
}
}
Room
::~
Room
()
Room
::~
Room
()
...
@@ -360,6 +356,48 @@ namespace RTC
...
@@ -360,6 +356,48 @@ namespace RTC
}
}
}
}
void
Room
::
SetRtpCapabilities
(
std
::
vector
<
RTC
::
RtpRoomMediaCodec
>&
roomMediaCodecs
)
{
MS_TRACE
();
for
(
auto
&
roomMediaCodec
:
roomMediaCodecs
)
{
auto
rtpCodecCapability
=
GetRtpCodecCapability
(
roomMediaCodec
);
}
}
RTC
::
RtpCodecCapability
Room
::
GetRtpCodecCapability
(
RTC
::
RtpRoomMediaCodec
&
roomMediaCodec
)
{
MS_TRACE
();
RTC
::
RtpCodecCapability
codecCapability
;
// Search the given codec in the list of supported codecs.
auto
it
=
Room
::
supportedRtpCapabilities
.
codecs
.
begin
();
for
(;
it
!=
Room
::
supportedRtpCapabilities
.
codecs
.
end
();
++
it
)
{
auto
&
supportedCodecapability
=
*
it
;
if
(
// Kind must match.
(
roomMediaCodec
.
kind
==
supportedCodecapability
.
kind
)
&&
// MIME must match.
(
roomMediaCodec
.
mime
==
supportedCodecapability
.
mime
)
&&
// Clock rate must match.
(
roomMediaCodec
.
clockRate
==
supportedCodecapability
.
clockRate
)
)
{
codecCapability
=
supportedCodecapability
;
}
}
if
(
it
==
Room
::
supportedRtpCapabilities
.
codecs
.
end
())
MS_THROW_ERROR
(
"no matching codec found"
);
return
codecCapability
;
}
void
Room
::
onPeerClosed
(
RTC
::
Peer
*
peer
)
void
Room
::
onPeerClosed
(
RTC
::
Peer
*
peer
)
{
{
MS_TRACE
();
MS_TRACE
();
...
...
worker/src/RTC/RtpDictionaries/Media.cpp
浏览文件 @
ccd6588c
...
@@ -13,14 +13,16 @@ namespace RTC
...
@@ -13,14 +13,16 @@ namespace RTC
{
{
{
"audio"
,
Media
::
Kind
::
AUDIO
},
{
"audio"
,
Media
::
Kind
::
AUDIO
},
{
"video"
,
Media
::
Kind
::
VIDEO
},
{
"video"
,
Media
::
Kind
::
VIDEO
},
{
"depth"
,
Media
::
Kind
::
DEPTH
}
{
"depth"
,
Media
::
Kind
::
DEPTH
},
{
""
,
Media
::
Kind
::
ALL
}
};
};
std
::
map
<
Media
::
Kind
,
Json
::
StaticString
>
Media
::
kind2Json
=
std
::
map
<
Media
::
Kind
,
Json
::
StaticString
>
Media
::
kind2Json
=
{
{
{
Media
::
Kind
::
AUDIO
,
Json
::
StaticString
(
"audio"
)
},
{
Media
::
Kind
::
AUDIO
,
Json
::
StaticString
(
"audio"
)
},
{
Media
::
Kind
::
VIDEO
,
Json
::
StaticString
(
"video"
)
},
{
Media
::
Kind
::
VIDEO
,
Json
::
StaticString
(
"video"
)
},
{
Media
::
Kind
::
DEPTH
,
Json
::
StaticString
(
"depth"
)
}
{
Media
::
Kind
::
DEPTH
,
Json
::
StaticString
(
"depth"
)
},
{
Media
::
Kind
::
ALL
,
Json
::
StaticString
(
""
)
}
};
};
/* Class methods. */
/* Class methods. */
...
...
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
浏览文件 @
ccd6588c
...
@@ -53,9 +53,11 @@ namespace RTC
...
@@ -53,9 +53,11 @@ namespace RTC
this
->
preferredPayloadType
=
(
uint8_t
)
data
[
k_preferredPayloadType
].
asUInt
();
this
->
preferredPayloadType
=
(
uint8_t
)
data
[
k_preferredPayloadType
].
asUInt
();
// `clockRate` is optional.
// `clockRate` is mandatory.
if
(
data
[
k_clockRate
].
isUInt
())
if
(
!
data
[
k_clockRate
].
isUInt
())
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
MS_THROW_ERROR
(
"missing RtpCodecParameters.clockRate"
);
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
// `maxptime` is optional.
// `maxptime` is optional.
if
(
data
[
k_maxptime
].
isUInt
())
if
(
data
[
k_maxptime
].
isUInt
())
...
@@ -129,8 +131,7 @@ namespace RTC
...
@@ -129,8 +131,7 @@ namespace RTC
json
[
k_preferredPayloadType
]
=
(
Json
::
UInt
)
this
->
preferredPayloadType
;
json
[
k_preferredPayloadType
]
=
(
Json
::
UInt
)
this
->
preferredPayloadType
;
// Add `clockRate`.
// Add `clockRate`.
if
(
this
->
clockRate
)
json
[
k_clockRate
]
=
(
Json
::
UInt
)
this
->
clockRate
;
json
[
k_clockRate
]
=
(
Json
::
UInt
)
this
->
clockRate
;
// Add `maxptime`.
// Add `maxptime`.
if
(
this
->
maxptime
)
if
(
this
->
maxptime
)
...
...
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
浏览文件 @
ccd6588c
...
@@ -41,9 +41,11 @@ namespace RTC
...
@@ -41,9 +41,11 @@ namespace RTC
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
// `clockRate` is optional.
// `clockRate` is mandatory.
if
(
data
[
k_clockRate
].
isUInt
())
if
(
!
data
[
k_clockRate
].
isUInt
())
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
MS_THROW_ERROR
(
"missing RtpCodecParameters.clockRate"
);
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
// `maxptime` is optional.
// `maxptime` is optional.
if
(
data
[
k_maxptime
].
isUInt
())
if
(
data
[
k_maxptime
].
isUInt
())
...
@@ -106,8 +108,7 @@ namespace RTC
...
@@ -106,8 +108,7 @@ namespace RTC
json
[
k_payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
json
[
k_payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
// Add `clockRate`.
// Add `clockRate`.
if
(
this
->
clockRate
)
json
[
k_clockRate
]
=
(
Json
::
UInt
)
this
->
clockRate
;
json
[
k_clockRate
]
=
(
Json
::
UInt
)
this
->
clockRate
;
// Add `maxptime`.
// Add `maxptime`.
if
(
this
->
maxptime
)
if
(
this
->
maxptime
)
...
...
worker/src/RTC/RtpDictionaries/RtpRoomMediaCodec.cpp
浏览文件 @
ccd6588c
...
@@ -39,12 +39,20 @@ namespace RTC
...
@@ -39,12 +39,20 @@ namespace RTC
// NOTE: This may throw.
// NOTE: This may throw.
this
->
mime
.
SetName
(
name
);
this
->
mime
.
SetName
(
name
);
// `clockRate` is optional.
// `clockRate` is mandatory.
if
(
data
[
k_clockRate
].
isUInt
())
if
(
!
data
[
k_clockRate
].
isUInt
())
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
MS_THROW_ERROR
(
"missing RtpCodecParameters.clockRate"
);
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
// `parameters` is optional.
// `parameters` is optional.
if
(
data
[
k_parameters
].
isObject
())
if
(
data
[
k_parameters
].
isObject
())
RTC
::
FillCustomParameters
(
this
->
parameters
,
data
[
k_parameters
]);
RTC
::
FillCustomParameters
(
this
->
parameters
,
data
[
k_parameters
]);
// Validate codec.
// It must not be a feature codec.
if
(
this
->
mime
.
IsFeatureCodec
())
MS_THROW_ERROR
(
"RtpRoomMediaCodec can not be a feature coedc"
);
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论