Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
c21757a0
提交
c21757a0
authored
6月 20, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some capabilities stuff done
上级
27429d0b
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
102 行增加
和
74 行删除
+102
-74
supportedCapabilities.js
data/supportedCapabilities.js
+2
-2
gulpfile.js
gulpfile.js
+4
-4
Room.js
lib/Room.js
+3
-8
RtpSender.js
lib/RtpSender.js
+11
-4
options.js
test/data/options.js
+1
-1
Peer.h
worker/include/RTC/Peer.h
+1
-0
Room.h
worker/include/RTC/Room.h
+6
-6
RtpReceiver.h
worker/include/RTC/RtpReceiver.h
+0
-3
RtpSender.h
worker/include/RTC/RtpSender.h
+2
-0
Loop.cpp
worker/src/Loop.cpp
+3
-3
Peer.cpp
worker/src/RTC/Peer.cpp
+18
-6
Room.cpp
worker/src/RTC/Room.cpp
+20
-19
Parameters.cpp
worker/src/RTC/RtpDictionaries/Parameters.cpp
+6
-1
RtpCapabilities.cpp
worker/src/RTC/RtpDictionaries/RtpCapabilities.cpp
+1
-5
RtpReceiver.cpp
worker/src/RTC/RtpReceiver.cpp
+0
-7
RtpSender.cpp
worker/src/RTC/RtpSender.cpp
+24
-5
没有找到文件。
data/supported
Rtp
Capabilities.js
→
data/supportedCapabilities.js
浏览文件 @
c21757a0
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* source code once JSONized by gulp.
* source code once JSONized by gulp.
*/
*/
let
supported
Rtp
Capabilities
=
let
supportedCapabilities
=
{
{
codecs
:
codecs
:
[
[
...
@@ -114,4 +114,4 @@ let supportedRtpCapabilities =
...
@@ -114,4 +114,4 @@ let supportedRtpCapabilities =
]
]
};
};
module
.
exports
=
supported
Rtp
Capabilities
;
module
.
exports
=
supportedCapabilities
;
gulpfile.js
浏览文件 @
c21757a0
...
@@ -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'
];
];
...
@@ -35,7 +35,7 @@ gulp.task('lint', () =>
...
@@ -35,7 +35,7 @@ gulp.task('lint', () =>
gulp
.
task
(
'capabilities'
,
()
=>
gulp
.
task
(
'capabilities'
,
()
=>
{
{
let
capabilities
=
require
(
'./data/supported
Rtp
Capabilities'
);
let
capabilities
=
require
(
'./data/supportedCapabilities'
);
return
gulp
.
src
(
'worker/src/RTC/Room.cpp'
)
return
gulp
.
src
(
'worker/src/RTC/Room.cpp'
)
.
pipe
(
replace
(
/
(
std::string capabilities =
)
.*/
,
`$1 R"(
${
JSON
.
stringify
(
capabilities
)}
)";`
))
.
pipe
(
replace
(
/
(
std::string capabilities =
)
.*/
,
`$1 R"(
${
JSON
.
stringify
(
capabilities
)}
)";`
))
...
...
lib/Room.js
浏览文件 @
c21757a0
...
@@ -51,7 +51,7 @@ class Room extends EventEmitter
...
@@ -51,7 +51,7 @@ class Room extends EventEmitter
});
});
// Set room's capabilities.
// Set room's capabilities.
this
.
_setCapabilities
(
data
.
rtpC
apabilities
);
this
.
_setCapabilities
(
data
.
c
apabilities
);
}
}
get
closed
()
get
closed
()
...
@@ -157,7 +157,8 @@ class Room extends EventEmitter
...
@@ -157,7 +157,8 @@ class Room extends EventEmitter
* Create a Peer instance.
* Create a Peer instance.
*
*
* @param {String} peerName - Peer identificator.
* @param {String} peerName - Peer identificator.
* @param {Object} options
* @param {Object} [options]
* @param {RtpCapabilities} [options.capabilities]
*
*
* @return {Peer}
* @return {Peer}
*/
*/
...
@@ -172,12 +173,6 @@ class Room extends EventEmitter
...
@@ -172,12 +173,6 @@ class Room extends EventEmitter
if
(
!
peerName
||
typeof
peerName
!==
'string'
)
if
(
!
peerName
||
typeof
peerName
!==
'string'
)
throw
new
TypeError
(
'peerName must be a string'
);
throw
new
TypeError
(
'peerName must be a string'
);
if
(
!
data
||
typeof
data
!==
'object'
)
throw
new
TypeError
(
'data must be an object'
);
if
(
!
data
.
rtpCapabilities
||
typeof
data
.
rtpCapabilities
!==
'object'
)
throw
new
TypeError
(
'data.rtpCapabilities must be an object'
);
if
(
this
.
_peers
.
has
(
peerName
))
if
(
this
.
_peers
.
has
(
peerName
))
throw
new
Error
(
`peer already exists [peerName:"
${
peerName
}
"]`
);
throw
new
Error
(
`peer already exists [peerName:"
${
peerName
}
"]`
);
...
...
lib/RtpSender.js
浏览文件 @
c21757a0
...
@@ -24,9 +24,10 @@ class RtpSender extends EventEmitter
...
@@ -24,9 +24,10 @@ class RtpSender extends EventEmitter
// RtcSender data.
// RtcSender data.
// - .kind
// - .kind
// - .associatedPeer
// - .transport
// - .transport
// - .rtpParameters
// - .rtpParameters
// - .a
ssociatedPeer
// - .a
vaiable
this
.
_data
=
data
;
this
.
_data
=
data
;
// Channel instance.
// Channel instance.
...
@@ -48,7 +49,8 @@ class RtpSender extends EventEmitter
...
@@ -48,7 +49,8 @@ class RtpSender extends EventEmitter
case
'updateparameters'
:
case
'updateparameters'
:
{
{
this
.
_data
.
rtpParameters
=
data
;
this
.
_data
.
rtpParameters
=
data
.
rtpParameters
;
this
.
_data
.
available
=
data
.
available
;
this
.
emit
(
'updateparameters'
,
data
);
this
.
emit
(
'updateparameters'
,
data
);
break
;
break
;
}
}
...
@@ -69,6 +71,11 @@ class RtpSender extends EventEmitter
...
@@ -69,6 +71,11 @@ class RtpSender extends EventEmitter
return
this
.
_data
.
kind
;
return
this
.
_data
.
kind
;
}
}
get
associatedPeer
()
{
return
this
.
_data
.
associatedPeer
;
}
get
transport
()
get
transport
()
{
{
return
this
.
_data
.
transport
;
return
this
.
_data
.
transport
;
...
@@ -79,9 +86,9 @@ class RtpSender extends EventEmitter
...
@@ -79,9 +86,9 @@ class RtpSender extends EventEmitter
return
this
.
_data
.
rtpParameters
;
return
this
.
_data
.
rtpParameters
;
}
}
get
a
ssociatedPeer
()
get
a
vailable
()
{
{
return
this
.
_data
.
a
ssociatedPeer
;
return
this
.
_data
.
a
vailable
;
}
}
/**
/**
...
...
test/data/options.js
浏览文件 @
c21757a0
...
@@ -50,7 +50,7 @@ module.exports =
...
@@ -50,7 +50,7 @@ module.exports =
peerOptions
:
peerOptions
:
{
{
rtpC
apabilities
:
c
apabilities
:
{
{
codecs
:
codecs
:
[
[
...
...
worker/include/RTC/Peer.h
浏览文件 @
c21757a0
...
@@ -78,6 +78,7 @@ namespace RTC
...
@@ -78,6 +78,7 @@ namespace RTC
Listener
*
listener
=
nullptr
;
Listener
*
listener
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
// Others.
// Others.
RTC
::
RtpCapabilities
capabilities
;
std
::
unordered_map
<
uint32_t
,
RTC
::
Transport
*>
transports
;
std
::
unordered_map
<
uint32_t
,
RTC
::
Transport
*>
transports
;
std
::
unordered_map
<
uint32_t
,
RTC
::
RtpReceiver
*>
rtpReceivers
;
std
::
unordered_map
<
uint32_t
,
RTC
::
RtpReceiver
*>
rtpReceivers
;
std
::
unordered_map
<
uint32_t
,
RTC
::
RtpSender
*>
rtpSenders
;
std
::
unordered_map
<
uint32_t
,
RTC
::
RtpSender
*>
rtpSenders
;
...
...
worker/include/RTC/Room.h
浏览文件 @
c21757a0
...
@@ -30,7 +30,7 @@ namespace RTC
...
@@ -30,7 +30,7 @@ namespace RTC
static
void
ClassInit
();
static
void
ClassInit
();
private
:
private
:
static
RTC
::
RtpCapabilities
supported
Rtp
Capabilities
;
static
RTC
::
RtpCapabilities
supportedCapabilities
;
static
std
::
vector
<
uint8_t
>
availablePayloadTypes
;
static
std
::
vector
<
uint8_t
>
availablePayloadTypes
;
public
:
public
:
...
@@ -40,11 +40,11 @@ namespace RTC
...
@@ -40,11 +40,11 @@ namespace RTC
void
Close
();
void
Close
();
Json
::
Value
toJson
();
Json
::
Value
toJson
();
void
HandleRequest
(
Channel
::
Request
*
request
);
void
HandleRequest
(
Channel
::
Request
*
request
);
RTC
::
RtpCapabilities
&
Get
Rtp
Capabilities
();
RTC
::
RtpCapabilities
&
GetCapabilities
();
private
:
private
:
RTC
::
Peer
*
GetPeerFromRequest
(
Channel
::
Request
*
request
,
uint32_t
*
peerId
=
nullptr
);
RTC
::
Peer
*
GetPeerFromRequest
(
Channel
::
Request
*
request
,
uint32_t
*
peerId
=
nullptr
);
void
Set
Rtp
Capabilities
(
std
::
vector
<
RTC
::
RtpCodecParameters
>&
mediaCodecs
);
void
SetCapabilities
(
std
::
vector
<
RTC
::
RtpCodecParameters
>&
mediaCodecs
);
/* Pure virtual methods inherited from RTC::Peer::Listener. */
/* Pure virtual methods inherited from RTC::Peer::Listener. */
public
:
public
:
...
@@ -64,7 +64,7 @@ namespace RTC
...
@@ -64,7 +64,7 @@ namespace RTC
Listener
*
listener
=
nullptr
;
Listener
*
listener
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
// Others.
// Others.
RTC
::
RtpCapabilities
rtpC
apabilities
;
RTC
::
RtpCapabilities
c
apabilities
;
std
::
unordered_map
<
uint32_t
,
RTC
::
Peer
*>
peers
;
std
::
unordered_map
<
uint32_t
,
RTC
::
Peer
*>
peers
;
std
::
unordered_map
<
RTC
::
RtpReceiver
*
,
std
::
unordered_set
<
RTC
::
RtpSender
*>>
mapRtpReceiverRtpSenders
;
std
::
unordered_map
<
RTC
::
RtpReceiver
*
,
std
::
unordered_set
<
RTC
::
RtpSender
*>>
mapRtpReceiverRtpSenders
;
};
};
...
@@ -72,9 +72,9 @@ namespace RTC
...
@@ -72,9 +72,9 @@ namespace RTC
/* Inline static methods. */
/* Inline static methods. */
inline
inline
RTC
::
RtpCapabilities
&
Room
::
Get
Rtp
Capabilities
()
RTC
::
RtpCapabilities
&
Room
::
GetCapabilities
()
{
{
return
this
->
rtpC
apabilities
;
return
this
->
c
apabilities
;
}
}
}
}
...
...
worker/include/RTC/RtpReceiver.h
浏览文件 @
c21757a0
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
#include "Channel/Request.h"
#include "Channel/Request.h"
#include "Channel/Notifier.h"
#include "Channel/Notifier.h"
#include <string>
#include <string>
#include <unordered_map>
#include <json/json.h>
#include <json/json.h>
namespace
RTC
namespace
RTC
...
@@ -62,8 +61,6 @@ namespace RTC
...
@@ -62,8 +61,6 @@ namespace RTC
// Others.
// Others.
bool
rtpRawEventEnabled
=
false
;
bool
rtpRawEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
std
::
unordered_map
<
uint8_t
,
uint8_t
>
mapPayloadTypes
;
std
::
unordered_map
<
uint32_t
,
uint32_t
>
mapSsrcs
;
};
};
/* Inline methods. */
/* Inline methods. */
...
...
worker/include/RTC/RtpSender.h
浏览文件 @
c21757a0
...
@@ -31,6 +31,7 @@ namespace RTC
...
@@ -31,6 +31,7 @@ namespace RTC
void
Close
();
void
Close
();
Json
::
Value
toJson
();
Json
::
Value
toJson
();
void
HandleRequest
(
Channel
::
Request
*
request
);
void
HandleRequest
(
Channel
::
Request
*
request
);
void
SetPeerCapabilities
(
RTC
::
RtpCapabilities
*
peerCapabilities
);
void
Send
(
RTC
::
RtpParameters
*
rtpParameters
);
void
Send
(
RTC
::
RtpParameters
*
rtpParameters
);
void
SetTransport
(
RTC
::
Transport
*
transport
);
void
SetTransport
(
RTC
::
Transport
*
transport
);
void
RemoveTransport
(
RTC
::
Transport
*
transport
);
void
RemoveTransport
(
RTC
::
Transport
*
transport
);
...
@@ -48,6 +49,7 @@ namespace RTC
...
@@ -48,6 +49,7 @@ namespace RTC
Channel
::
Notifier
*
notifier
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
RTC
::
Transport
*
transport
=
nullptr
;
RTC
::
Transport
*
transport
=
nullptr
;
RTC
::
RtpParameters
*
rtpParameters
=
nullptr
;
RTC
::
RtpParameters
*
rtpParameters
=
nullptr
;
RTC
::
RtpCapabilities
*
peerCapabilities
=
nullptr
;
// Whether this RtpSender is valid according to Peer capabilities.
// Whether this RtpSender is valid according to Peer capabilities.
bool
available
=
false
;
bool
available
=
false
;
};
};
...
...
worker/src/Loop.cpp
浏览文件 @
c21757a0
...
@@ -176,7 +176,7 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
...
@@ -176,7 +176,7 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
case
Channel
:
:
Request
::
MethodId
::
worker_createRoom
:
case
Channel
:
:
Request
::
MethodId
::
worker_createRoom
:
{
{
static
const
Json
::
StaticString
k_
rtpCapabilities
(
"rtpC
apabilities"
);
static
const
Json
::
StaticString
k_
capabilities
(
"c
apabilities"
);
RTC
::
Room
*
room
;
RTC
::
Room
*
room
;
uint32_t
roomId
;
uint32_t
roomId
;
...
@@ -213,8 +213,8 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
...
@@ -213,8 +213,8 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
Json
::
Value
data
(
Json
::
objectValue
);
Json
::
Value
data
(
Json
::
objectValue
);
// Add `
rtpC
apabilities`.
// Add `
c
apabilities`.
data
[
k_
rtpCapabilities
]
=
room
->
GetRtp
Capabilities
().
toJson
();
data
[
k_
capabilities
]
=
room
->
Get
Capabilities
().
toJson
();
request
->
Accept
(
data
);
request
->
Accept
(
data
);
...
...
worker/src/RTC/Peer.cpp
浏览文件 @
c21757a0
...
@@ -17,16 +17,16 @@ namespace RTC
...
@@ -17,16 +17,16 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_
rtpCapabilities
(
"rtpC
apabilities"
);
static
const
Json
::
StaticString
k_
capabilities
(
"c
apabilities"
);
// `mediaCodecs` is mandatory.
// `mediaCodecs` is mandatory.
if
(
!
data
[
k_
rtpC
apabilities
].
isObject
())
if
(
!
data
[
k_
c
apabilities
].
isObject
())
MS_THROW_ERROR
(
"missing
rtpC
apabilities"
);
MS_THROW_ERROR
(
"missing
c
apabilities"
);
auto
&
json_
rtpCapabilities
=
data
[
k_rtpC
apabilities
];
auto
&
json_
capabilities
=
data
[
k_c
apabilities
];
//
TODO: check data (RtpCapabilities)
//
Build peer's capabilities.
RTC
::
RtpCapabilities
rtpCapabilities
(
json_rtpC
apabilities
);
this
->
capabilities
=
RTC
::
RtpCapabilities
(
json_c
apabilities
);
}
}
Peer
::~
Peer
()
Peer
::~
Peer
()
...
@@ -87,6 +87,7 @@ namespace RTC
...
@@ -87,6 +87,7 @@ namespace RTC
static
const
Json
::
StaticString
k_peerId
(
"peerId"
);
static
const
Json
::
StaticString
k_peerId
(
"peerId"
);
static
const
Json
::
StaticString
k_peerName
(
"peerName"
);
static
const
Json
::
StaticString
k_peerName
(
"peerName"
);
static
const
Json
::
StaticString
k_capabilities
(
"capabilities"
);
static
const
Json
::
StaticString
k_transports
(
"transports"
);
static
const
Json
::
StaticString
k_transports
(
"transports"
);
static
const
Json
::
StaticString
k_rtpReceivers
(
"rtpReceivers"
);
static
const
Json
::
StaticString
k_rtpReceivers
(
"rtpReceivers"
);
static
const
Json
::
StaticString
k_rtpSenders
(
"rtpSenders"
);
static
const
Json
::
StaticString
k_rtpSenders
(
"rtpSenders"
);
...
@@ -96,10 +97,16 @@ namespace RTC
...
@@ -96,10 +97,16 @@ namespace RTC
Json
::
Value
json_rtpReceivers
(
Json
::
arrayValue
);
Json
::
Value
json_rtpReceivers
(
Json
::
arrayValue
);
Json
::
Value
json_rtpSenders
(
Json
::
arrayValue
);
Json
::
Value
json_rtpSenders
(
Json
::
arrayValue
);
// Add `peerId`.
json
[
k_peerId
]
=
(
Json
::
UInt
)
this
->
peerId
;
json
[
k_peerId
]
=
(
Json
::
UInt
)
this
->
peerId
;
// Add `peerName`.
json
[
k_peerName
]
=
this
->
peerName
;
json
[
k_peerName
]
=
this
->
peerName
;
// Add `capabilities`.
json
[
k_capabilities
]
=
this
->
capabilities
.
toJson
();
// Add `transports`.
for
(
auto
&
kv
:
this
->
transports
)
for
(
auto
&
kv
:
this
->
transports
)
{
{
RTC
::
Transport
*
transport
=
kv
.
second
;
RTC
::
Transport
*
transport
=
kv
.
second
;
...
@@ -108,6 +115,7 @@ namespace RTC
...
@@ -108,6 +115,7 @@ namespace RTC
}
}
json
[
k_transports
]
=
json_transports
;
json
[
k_transports
]
=
json_transports
;
// Add `rtpReceivers`.
for
(
auto
&
kv
:
this
->
rtpReceivers
)
for
(
auto
&
kv
:
this
->
rtpReceivers
)
{
{
RTC
::
RtpReceiver
*
rtpReceiver
=
kv
.
second
;
RTC
::
RtpReceiver
*
rtpReceiver
=
kv
.
second
;
...
@@ -116,6 +124,7 @@ namespace RTC
...
@@ -116,6 +124,7 @@ namespace RTC
}
}
json
[
k_rtpReceivers
]
=
json_rtpReceivers
;
json
[
k_rtpReceivers
]
=
json_rtpReceivers
;
// Add `rtpSenders`.
for
(
auto
&
kv
:
this
->
rtpSenders
)
for
(
auto
&
kv
:
this
->
rtpSenders
)
{
{
RTC
::
RtpSender
*
rtpSender
=
kv
.
second
;
RTC
::
RtpSender
*
rtpSender
=
kv
.
second
;
...
@@ -415,6 +424,9 @@ namespace RTC
...
@@ -415,6 +424,9 @@ namespace RTC
MS_ASSERT
(
rtpSender
->
GetParameters
(),
"given RtpSender does not have RtpParameters"
);
MS_ASSERT
(
rtpSender
->
GetParameters
(),
"given RtpSender does not have RtpParameters"
);
// Provide the RtpSender with peer's capabilities.
rtpSender
->
SetPeerCapabilities
(
std
::
addressof
(
this
->
capabilities
));
// Store it.
// Store it.
this
->
rtpSenders
[
rtpSender
->
rtpSenderId
]
=
rtpSender
;
this
->
rtpSenders
[
rtpSender
->
rtpSenderId
]
=
rtpSender
;
...
...
worker/src/RTC/Room.cpp
浏览文件 @
c21757a0
...
@@ -12,7 +12,7 @@ namespace RTC
...
@@ -12,7 +12,7 @@ namespace RTC
{
{
/* Class variables. */
/* Class variables. */
RTC
::
RtpCapabilities
Room
::
supported
Rtp
Capabilities
;
RTC
::
RtpCapabilities
Room
::
supportedCapabilities
;
/* Class methods. */
/* Class methods. */
...
@@ -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 fr
mo data/supportedRtp
Capabilities.js.
// NOTE: This line is auto-generated fr
om data/supported
Capabilities.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,"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}]})"
;
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
;
...
@@ -47,7 +47,7 @@ namespace RTC
...
@@ -47,7 +47,7 @@ namespace RTC
try
try
{
{
Room
::
supported
Rtp
Capabilities
=
RTC
::
RtpCapabilities
(
json
);
Room
::
supportedCapabilities
=
RTC
::
RtpCapabilities
(
json
);
}
}
catch
(
const
MediaSoupError
&
error
)
catch
(
const
MediaSoupError
&
error
)
{
{
...
@@ -83,7 +83,7 @@ namespace RTC
...
@@ -83,7 +83,7 @@ namespace RTC
// Set room RTP capabilities.
// Set room RTP capabilities.
// NOTE: This may throw.
// NOTE: This may throw.
Set
Rtp
Capabilities
(
mediaCodecs
);
SetCapabilities
(
mediaCodecs
);
}
}
}
}
...
@@ -127,7 +127,7 @@ namespace RTC
...
@@ -127,7 +127,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_roomId
(
"roomId"
);
static
const
Json
::
StaticString
k_roomId
(
"roomId"
);
static
const
Json
::
StaticString
k_
rtpCapabilities
(
"rtpC
apabilities"
);
static
const
Json
::
StaticString
k_
capabilities
(
"c
apabilities"
);
static
const
Json
::
StaticString
k_peers
(
"peers"
);
static
const
Json
::
StaticString
k_peers
(
"peers"
);
static
const
Json
::
StaticString
k_mapRtpReceiverRtpSenders
(
"mapRtpReceiverRtpSenders"
);
static
const
Json
::
StaticString
k_mapRtpReceiverRtpSenders
(
"mapRtpReceiverRtpSenders"
);
...
@@ -138,8 +138,8 @@ namespace RTC
...
@@ -138,8 +138,8 @@ namespace RTC
// Add `roomId`.
// Add `roomId`.
json
[
k_roomId
]
=
(
Json
::
UInt
)
this
->
roomId
;
json
[
k_roomId
]
=
(
Json
::
UInt
)
this
->
roomId
;
// Add `
rtpC
apabilities`.
// Add `
c
apabilities`.
json
[
k_
rtpCapabilities
]
=
this
->
rtpC
apabilities
.
toJson
();
json
[
k_
capabilities
]
=
this
->
c
apabilities
.
toJson
();
// Add `peers`.
// Add `peers`.
for
(
auto
&
kv
:
this
->
peers
)
for
(
auto
&
kv
:
this
->
peers
)
...
@@ -350,7 +350,7 @@ namespace RTC
...
@@ -350,7 +350,7 @@ namespace RTC
}
}
}
}
void
Room
::
Set
Rtp
Capabilities
(
std
::
vector
<
RTC
::
RtpCodecParameters
>&
mediaCodecs
)
void
Room
::
SetCapabilities
(
std
::
vector
<
RTC
::
RtpCodecParameters
>&
mediaCodecs
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -389,9 +389,9 @@ namespace RTC
...
@@ -389,9 +389,9 @@ namespace RTC
// Search the given codec in the list of supported codec capabilities.
// Search the given codec in the list of supported codec capabilities.
auto
it
=
Room
::
supported
Rtp
Capabilities
.
codecs
.
begin
();
auto
it
=
Room
::
supportedCapabilities
.
codecs
.
begin
();
for
(;
it
!=
Room
::
supported
Rtp
Capabilities
.
codecs
.
end
();
++
it
)
for
(;
it
!=
Room
::
supportedCapabilities
.
codecs
.
end
();
++
it
)
{
{
auto
&
supportedCodecCapability
=
*
it
;
auto
&
supportedCodecCapability
=
*
it
;
...
@@ -408,7 +408,7 @@ namespace RTC
...
@@ -408,7 +408,7 @@ namespace RTC
break
;
break
;
}
}
}
}
if
(
it
==
Room
::
supported
Rtp
Capabilities
.
codecs
.
end
())
if
(
it
==
Room
::
supportedCapabilities
.
codecs
.
end
())
MS_THROW_ERROR
(
"no matching codec capability found"
);
MS_THROW_ERROR
(
"no matching codec capability found"
);
// Reduce the capabilities of the matching capability codec.
// Reduce the capabilities of the matching capability codec.
...
@@ -439,11 +439,11 @@ namespace RTC
...
@@ -439,11 +439,11 @@ namespace RTC
roomPayloadTypes
.
insert
(
payloadType
);
roomPayloadTypes
.
insert
(
payloadType
);
// Append the codec to the room capabilities.
// Append the codec to the room capabilities.
this
->
rtpC
apabilities
.
codecs
.
push_back
(
codecCapability
);
this
->
c
apabilities
.
codecs
.
push_back
(
codecCapability
);
}
}
// Add feature codec capabilities.
// Add feature codec capabilities.
for
(
auto
&
codecCapability
:
Room
::
supported
Rtp
Capabilities
.
codecs
)
for
(
auto
&
codecCapability
:
Room
::
supportedCapabilities
.
codecs
)
{
{
// Just feature codecs.
// Just feature codecs.
if
(
!
codecCapability
.
mime
.
IsFeatureCodec
())
if
(
!
codecCapability
.
mime
.
IsFeatureCodec
())
...
@@ -476,15 +476,15 @@ namespace RTC
...
@@ -476,15 +476,15 @@ namespace RTC
roomPayloadTypes
.
insert
(
payloadType
);
roomPayloadTypes
.
insert
(
payloadType
);
// Append the codec to the room capabilities.
// Append the codec to the room capabilities.
this
->
rtpC
apabilities
.
codecs
.
push_back
(
codecCapability
);
this
->
c
apabilities
.
codecs
.
push_back
(
codecCapability
);
}
}
}
}
// Copy supported RTP header extensions.
// Copy supported RTP header extensions.
this
->
rtpCapabilities
.
headerExtensions
=
Room
::
supportedRtp
Capabilities
.
headerExtensions
;
this
->
capabilities
.
headerExtensions
=
Room
::
supported
Capabilities
.
headerExtensions
;
// Copy supported FEC mechanisms.
// Copy supported FEC mechanisms.
this
->
rtpCapabilities
.
fecMechanisms
=
Room
::
supportedRtp
Capabilities
.
fecMechanisms
;
this
->
capabilities
.
fecMechanisms
=
Room
::
supported
Capabilities
.
fecMechanisms
;
}
}
void
Room
::
onPeerClosed
(
RTC
::
Peer
*
peer
)
void
Room
::
onPeerClosed
(
RTC
::
Peer
*
peer
)
...
@@ -499,21 +499,22 @@ namespace RTC
...
@@ -499,21 +499,22 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
auto
rtpParameters
=
rtpReceiver
->
GetParameters
();
auto
rtpParameters
=
rtpReceiver
->
GetParameters
();
std
::
unordered_map
<
uint8_t
,
RTC
::
RtpCodecParameters
*>
mapPyloadTypeRtpCodecParameters
;
// Check codecs availability. If it fails, throw.
// Check codecs availability. If it fails, throw.
for
(
auto
codec
:
rtpParameters
->
codecs
)
for
(
auto
codec
:
rtpParameters
->
codecs
)
{
{
auto
it
=
this
->
rtpC
apabilities
.
codecs
.
begin
();
auto
it
=
this
->
c
apabilities
.
codecs
.
begin
();
for
(;
it
!=
this
->
rtpC
apabilities
.
codecs
.
end
();
++
it
)
for
(;
it
!=
this
->
c
apabilities
.
codecs
.
end
();
++
it
)
{
{
auto
&
codecCapability
=
*
it
;
auto
&
codecCapability
=
*
it
;
if
(
codecCapability
.
MatchesCodec
(
codec
))
if
(
codecCapability
.
MatchesCodec
(
codec
))
break
;
break
;
}
}
if
(
it
==
this
->
rtpC
apabilities
.
codecs
.
end
())
if
(
it
==
this
->
c
apabilities
.
codecs
.
end
())
{
{
MS_THROW_ERROR
(
"no matching codec capability found [payloadType:%"
PRIu8
"]"
,
MS_THROW_ERROR
(
"no matching codec capability found [payloadType:%"
PRIu8
"]"
,
codec
.
payloadType
);
codec
.
payloadType
);
...
...
worker/src/RTC/RtpDictionaries/Parameters.cpp
浏览文件 @
c21757a0
...
@@ -124,12 +124,17 @@ namespace RTC
...
@@ -124,12 +124,17 @@ namespace RTC
auto
&
entry
=
value
[
i
];
auto
&
entry
=
value
[
i
];
if
(
entry
.
isInt
())
if
(
entry
.
isInt
())
{
arrayOfIntegers
.
push_back
((
int32_t
)
entry
.
asInt
());
arrayOfIntegers
.
push_back
((
int32_t
)
entry
.
asInt
());
}
else
else
{
isValid
=
false
;
isValid
=
false
;
break
;
}
}
}
if
(
isValid
)
if
(
arrayOfIntegers
.
size
()
>
0
&&
isValid
)
this
->
mapKeyValues
[
key
]
=
Value
(
arrayOfIntegers
);
this
->
mapKeyValues
[
key
]
=
Value
(
arrayOfIntegers
);
break
;
break
;
...
...
worker/src/RTC/RtpDictionaries/RtpCapabilities.cpp
浏览文件 @
c21757a0
...
@@ -17,7 +17,7 @@ namespace RTC
...
@@ -17,7 +17,7 @@ namespace RTC
static
const
Json
::
StaticString
k_headerExtensions
(
"headerExtensions"
);
static
const
Json
::
StaticString
k_headerExtensions
(
"headerExtensions"
);
static
const
Json
::
StaticString
k_fecMechanisms
(
"fecMechanisms"
);
static
const
Json
::
StaticString
k_fecMechanisms
(
"fecMechanisms"
);
// `codecs` is
mandatory
.
// `codecs` is
optional
.
if
(
data
[
k_codecs
].
isArray
())
if
(
data
[
k_codecs
].
isArray
())
{
{
auto
&
json_codecs
=
data
[
k_codecs
];
auto
&
json_codecs
=
data
[
k_codecs
];
...
@@ -30,10 +30,6 @@ namespace RTC
...
@@ -30,10 +30,6 @@ namespace RTC
this
->
codecs
.
push_back
(
codec
);
this
->
codecs
.
push_back
(
codec
);
}
}
}
}
else
{
MS_THROW_ERROR
(
"missing RtpCapabilities.codecs"
);
}
// `headerExtensions` is optional.
// `headerExtensions` is optional.
if
(
data
[
k_headerExtensions
].
isArray
())
if
(
data
[
k_headerExtensions
].
isArray
())
...
...
worker/src/RTC/RtpReceiver.cpp
浏览文件 @
c21757a0
...
@@ -237,13 +237,6 @@ namespace RTC
...
@@ -237,13 +237,6 @@ namespace RTC
}
}
}
}
void
RtpReceiver
::
SetPayloadMapping
()
{
MS_TRACE
();
// TODO
}
void
RtpReceiver
::
CreateSenderParameters
()
void
RtpReceiver
::
CreateSenderParameters
()
{
{
MS_TRACE
();
MS_TRACE
();
...
...
worker/src/RTC/RtpSender.cpp
浏览文件 @
c21757a0
...
@@ -92,25 +92,44 @@ namespace RTC
...
@@ -92,25 +92,44 @@ namespace RTC
}
}
}
}
void
RtpSender
::
SetPeerCapabilities
(
RTC
::
RtpCapabilities
*
peerCapabilities
)
{
MS_TRACE
();
this
->
peerCapabilities
=
peerCapabilities
;
}
void
RtpSender
::
Send
(
RTC
::
RtpParameters
*
rtpParameters
)
void
RtpSender
::
Send
(
RTC
::
RtpParameters
*
rtpParameters
)
{
{
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_rtpParameters
(
"rtpParameters"
);
static
const
Json
::
StaticString
k_available
(
"available"
);
bool
hadParameters
=
false
;
// Free the previous rtpParameters.
// Free the previous rtpParameters.
if
(
this
->
rtpParameters
)
if
(
this
->
rtpParameters
)
{
hadParameters
=
true
;
delete
this
->
rtpParameters
;
delete
this
->
rtpParameters
;
}
this
->
rtpParameters
=
rtpParameters
;
this
->
rtpParameters
=
rtpParameters
;
// TODO: Must check new parameters to set this->available, and emit
// TODO: Must check new parameters to set this->available.
// "enabled"/"disabled" if this->available changed.
// For now make it easy:
// For now do it easy:
this
->
available
=
true
;
this
->
available
=
true
;
// Emit "updateparameters".
// Emit "updateparameters" if those are new parameters.
if
(
hadParameters
)
{
Json
::
Value
event_data
(
Json
::
objectValue
);
Json
::
Value
event_data
=
this
->
rtpParameters
->
toJson
();
event_data
[
k_rtpParameters
]
=
this
->
rtpParameters
->
toJson
();
event_data
[
k_available
]
=
this
->
available
;
this
->
notifier
->
Emit
(
this
->
rtpSenderId
,
"updateparameters"
,
event_data
);
this
->
notifier
->
Emit
(
this
->
rtpSenderId
,
"updateparameters"
,
event_data
);
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论