Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
f0db9781
提交
f0db9781
authored
6月 26, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Redesign capabilities stuf.
上级
0ad4ae10
全部展开
显示空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
406 行增加
和
585 行删除
+406
-585
supportedCapabilities.js
data/supportedCapabilities.js
+3
-98
Peer.js
lib/Peer.js
+34
-0
Room.js
lib/Room.js
+3
-6
options.js
test/data/options.js
+29
-6
test_Peer.js
test/test_Peer.js
+6
-2
test_RtpReceiver.js
test/test_RtpReceiver.js
+31
-27
test_Transport.js
test/test_Transport.js
+2
-3
Request.h
worker/include/Channel/Request.h
+1
-0
Peer.h
worker/include/RTC/Peer.h
+10
-1
Room.h
worker/include/RTC/Room.h
+1
-0
RtpDictionaries.h
worker/include/RTC/RtpDictionaries.h
+34
-53
mediasoup-worker.gyp
worker/mediasoup-worker.gyp
+0
-2
Request.cpp
worker/src/Channel/Request.cpp
+1
-0
Loop.cpp
worker/src/Loop.cpp
+1
-0
Peer.cpp
worker/src/RTC/Peer.cpp
+62
-12
Room.cpp
worker/src/RTC/Room.cpp
+0
-0
RtpCapabilities.cpp
worker/src/RTC/RtpDictionaries/RtpCapabilities.cpp
+12
-14
RtpCodec.cpp
worker/src/RTC/RtpDictionaries/RtpCodec.cpp
+0
-90
RtpCodecCapability.cpp
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
+0
-231
RtpCodecParameters.cpp
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
+171
-35
RtpParameters.cpp
worker/src/RTC/RtpDictionaries/RtpParameters.cpp
+5
-5
没有找到文件。
data/supportedCapabilities.js
浏览文件 @
f0db9781
...
@@ -7,103 +7,7 @@
...
@@ -7,103 +7,7 @@
let
supportedCapabilities
=
let
supportedCapabilities
=
{
{
codecs
:
headerExtensions
:
[
// Audio 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
},
// Video codecs:
{
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
]
}
},
// Depth codecs:
{
kind
:
'depth'
,
name
:
'video/VP8'
,
preferredPayloadType
:
120
,
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
:
''
,
kind
:
''
,
...
@@ -111,7 +15,8 @@ let supportedCapabilities =
...
@@ -111,7 +15,8 @@ let supportedCapabilities =
preferredId
:
1
,
preferredId
:
1
,
preferredEncrypt
:
false
preferredEncrypt
:
false
}
}
]
],
fecMechanisms
:
[]
};
};
module
.
exports
=
supportedCapabilities
;
module
.
exports
=
supportedCapabilities
;
lib/Peer.js
浏览文件 @
f0db9781
...
@@ -212,6 +212,40 @@ class Peer extends EventEmitter
...
@@ -212,6 +212,40 @@ class Peer extends EventEmitter
});
});
}
}
/**
* Set peer capabilities.
*
* @param {RtpCapabilities} [options.capabilities]
* @param {[Object]} [options]
* @param {[Boolean]} [options.udp=true] - Listen UDP.
* @param {[Boolean]} [options.tcp=true] - Listen TCP.
* @param {[Boolean]} [options.preferIPv4=false] - Prefer IPv4 candidates.
* @param {[Boolean]} [options.preferIPv6=false] - Prefer IPv6 candidates.
* @param {[Boolean]} [options.preferUdp=false] - Prefer UDP candidates.
* @param {[Boolean]} [options.preferTcp=false] - Prefer TCP candidates.
*
* @return {Promise} Resolves to the created Transport.
*/
setCapabilities
(
capabilities
)
{
logger
.
debug
(
'setCapabilities() [capabilities:%o]'
,
capabilities
);
if
(
this
.
_closed
)
return
Promise
.
reject
(
new
errors
.
InvalidStateError
(
'Peer closed'
));
return
this
.
_channel
.
request
(
'peer.setCapabilities'
,
this
.
_internal
,
capabilities
)
.
then
((
data
)
=>
{
logger
.
debug
(
'"peer.setCapabilities" request succeeded'
);
})
.
catch
((
error
)
=>
{
logger
.
error
(
'"peer.setCapabilities" request failed: %s'
,
error
);
throw
error
;
});
}
/**
/**
* Create a Transport instance.
* Create a Transport instance.
*
*
...
...
lib/Room.js
浏览文件 @
f0db9781
...
@@ -157,15 +157,12 @@ class Room extends EventEmitter
...
@@ -157,15 +157,12 @@ 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 {RtpCapabilities} [options.capabilities]
*
*
* @return {Peer}
* @return {Peer}
*/
*/
Peer
(
peerName
,
data
)
Peer
(
peerName
)
{
{
logger
.
debug
(
'Peer() [peerName:"%s", data:%o]'
,
logger
.
debug
(
'Peer() [peerName:"%s]'
,
peerName
);
peerName
,
data
);
if
(
this
.
_closed
)
if
(
this
.
_closed
)
throw
new
errors
.
InvalidStateError
(
'Room closed'
);
throw
new
errors
.
InvalidStateError
(
'Room closed'
);
...
@@ -198,7 +195,7 @@ class Room extends EventEmitter
...
@@ -198,7 +195,7 @@ class Room extends EventEmitter
this
.
_peers
.
delete
(
peerName
);
this
.
_peers
.
delete
(
peerName
);
});
});
this
.
_channel
.
request
(
'room.createPeer'
,
internal
,
data
)
this
.
_channel
.
request
(
'room.createPeer'
,
internal
)
.
then
(()
=>
.
then
(()
=>
{
{
logger
.
debug
(
'"room.createPeer" request succeeded'
);
logger
.
debug
(
'"room.createPeer" request succeeded'
);
...
...
test/data/options.js
浏览文件 @
f0db9781
...
@@ -48,26 +48,49 @@ module.exports =
...
@@ -48,26 +48,49 @@ module.exports =
]
]
},
},
peerOptions
:
peerCapabilities
:
{
capabilities
:
{
{
codecs
:
codecs
:
[
[
{
{
kind
:
'audio'
,
kind
:
'audio'
,
name
:
'audio/opus'
,
name
:
'audio/opus'
,
preferredP
ayloadType
:
100
,
p
ayloadType
:
100
,
clockRate
:
48000
,
clockRate
:
48000
,
numChannels
:
2
numChannels
:
2
},
},
{
kind
:
'audio'
,
name
:
'audio/PCMU'
,
payloadType
:
0
,
clockRate
:
8000
},
{
{
kind
:
'video'
,
kind
:
'video'
,
name
:
'video/VP8'
,
name
:
'video/VP8'
,
preferredP
ayloadType
:
101
,
p
ayloadType
:
101
,
clockRate
:
90000
clockRate
:
90000
},
{
kind
:
'video'
,
name
:
'video/H264'
,
payloadType
:
102
,
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
0
}
}
]
},
{
kind
:
'video'
,
name
:
'video/H264'
,
payloadType
:
103
,
clockRate
:
90000
,
parameters
:
{
packetizationMode
:
1
}
}
}
}
]
}
};
};
test/test_Peer.js
浏览文件 @
f0db9781
...
@@ -4,7 +4,7 @@ const tap = require('tap');
...
@@ -4,7 +4,7 @@ const tap = require('tap');
const
mediasoup
=
require
(
'../'
);
const
mediasoup
=
require
(
'../'
);
const
roomOptions
=
require
(
'./data/options'
).
roomOptions
;
const
roomOptions
=
require
(
'./data/options'
).
roomOptions
;
const
peer
Options
=
require
(
'./data/options'
).
peerOption
s
;
const
peer
Capabilities
=
require
(
'./data/options'
).
peerCapabilitie
s
;
function
initTest
(
t
)
function
initTest
(
t
)
{
{
...
@@ -16,8 +16,12 @@ function initTest(t)
...
@@ -16,8 +16,12 @@ function initTest(t)
return
server
.
createRoom
(
roomOptions
)
return
server
.
createRoom
(
roomOptions
)
.
then
((
room
)
=>
.
then
((
room
)
=>
{
{
peer
=
room
.
Peer
(
'alice'
,
peerOptions
);
peer
=
room
.
Peer
(
'alice'
);
return
peer
.
setCapabilities
(
peerCapabilities
);
})
.
then
(()
=>
{
return
{
peer
:
peer
};
return
{
peer
:
peer
};
});
});
}
}
...
...
test/test_RtpReceiver.js
浏览文件 @
f0db9781
...
@@ -4,7 +4,7 @@ const tap = require('tap');
...
@@ -4,7 +4,7 @@ const tap = require('tap');
const
mediasoup
=
require
(
'../'
);
const
mediasoup
=
require
(
'../'
);
const
roomOptions
=
require
(
'./data/options'
).
roomOptions
;
const
roomOptions
=
require
(
'./data/options'
).
roomOptions
;
const
peer
Options
=
require
(
'./data/options'
).
peerOption
s
;
const
peer
Capabilities
=
require
(
'./data/options'
).
peerCapabilitie
s
;
const
promiseSeries
=
require
(
'./utils/promiseSeries'
);
const
promiseSeries
=
require
(
'./utils/promiseSeries'
);
function
initTest
(
t
)
function
initTest
(
t
)
...
@@ -17,8 +17,12 @@ function initTest(t)
...
@@ -17,8 +17,12 @@ function initTest(t)
return
server
.
createRoom
(
roomOptions
)
return
server
.
createRoom
(
roomOptions
)
.
then
((
room
)
=>
.
then
((
room
)
=>
{
{
peer
=
room
.
Peer
(
'alice'
,
peerOptions
);
peer
=
room
.
Peer
(
'alice'
);
return
peer
.
setCapabilities
(
peerCapabilities
);
})
.
then
(()
=>
{
return
peer
.
createTransport
({
tcp
:
false
});
return
peer
.
createTransport
({
tcp
:
false
});
})
})
.
then
((
transport
)
=>
.
then
((
transport
)
=>
...
@@ -78,7 +82,7 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
...
@@ -78,7 +82,7 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
[
[
{
{
name
:
'video/H264'
,
name
:
'video/H264'
,
payloadType
:
10
1
,
payloadType
:
10
2
,
clockRate
:
90000
,
clockRate
:
90000
,
parameters
:
parameters
:
{
{
...
@@ -87,7 +91,7 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
...
@@ -87,7 +91,7 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
},
},
{
{
name
:
'video/H264'
,
name
:
'video/H264'
,
payloadType
:
10
2
,
payloadType
:
10
3
,
clockRate
:
90000
,
clockRate
:
90000
,
parameters
:
parameters
:
{
{
...
@@ -101,7 +105,7 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
...
@@ -101,7 +105,7 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
ssrc
:
1111
ssrc
:
1111
},
},
{
{
codecPayloadType
:
10
2
codecPayloadType
:
10
3
},
},
{
{
ssrc
:
3333
ssrc
:
3333
...
@@ -115,9 +119,9 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
...
@@ -115,9 +119,9 @@ tap.test('rtpReceiver.receive() with encodings without codecPayloadType must suc
let
rtpParameters
=
rtpReceiver
.
rtpParameters
;
let
rtpParameters
=
rtpReceiver
.
rtpParameters
;
t
.
equal
(
rtpParameters
.
encodings
.
length
,
3
,
'computed rtpParameters has 3 encodings'
);
t
.
equal
(
rtpParameters
.
encodings
.
length
,
3
,
'computed rtpParameters has 3 encodings'
);
t
.
equal
(
rtpParameters
.
encodings
[
0
].
codecPayloadType
,
10
1
,
'first encoding has codecPayloadType 101
'
);
t
.
equal
(
rtpParameters
.
encodings
[
0
].
codecPayloadType
,
10
2
,
'first encoding has codecPayloadType 102
'
);
t
.
equal
(
rtpParameters
.
encodings
[
1
].
codecPayloadType
,
10
2
,
'second encoding has codecPayloadType 102
'
);
t
.
equal
(
rtpParameters
.
encodings
[
1
].
codecPayloadType
,
10
3
,
'second encoding has codecPayloadType 103
'
);
t
.
equal
(
rtpParameters
.
encodings
[
2
].
codecPayloadType
,
10
1
,
'third encoding has codecPayloadType 101
'
);
t
.
equal
(
rtpParameters
.
encodings
[
2
].
codecPayloadType
,
10
2
,
'third encoding has codecPayloadType 102
'
);
})
})
.
catch
((
error
)
=>
t
.
fail
(
`rtpReceiver.receive() failed:
${
error
}
`
));
.
catch
((
error
)
=>
t
.
fail
(
`rtpReceiver.receive() failed:
${
error
}
`
));
});
});
...
@@ -138,7 +142,7 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
...
@@ -138,7 +142,7 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
[
[
{
{
name
:
'video/VP8'
,
name
:
'video/VP8'
,
payloadType
:
10
0
,
payloadType
:
10
1
,
clockRate
:
90000
,
clockRate
:
90000
,
maxptime
:
80
,
maxptime
:
80
,
ptime
:
60
,
ptime
:
60
,
...
@@ -172,7 +176,7 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
...
@@ -172,7 +176,7 @@ tap.test('rtpReceiver.receive() with full rtpParameters must succeed', { timeout
[
[
{
{
ssrc
:
100000
,
ssrc
:
100000
,
codecPayloadType
:
10
0
,
codecPayloadType
:
10
1
,
fec
:
fec
:
{
{
ssrc
:
200000
,
ssrc
:
200000
,
...
@@ -258,7 +262,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
...
@@ -258,7 +262,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
clockRate
:
48000
}
}
],
],
...
@@ -280,7 +284,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
...
@@ -280,7 +284,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
clockRate
:
48000
}
}
],
],
...
@@ -336,7 +340,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -336,7 +340,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'opus'
,
name
:
'opus'
,
payloadType
:
10
1
payloadType
:
10
0
}
}
]
]
})
})
...
@@ -355,7 +359,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -355,7 +359,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'/opus'
,
name
:
'/opus'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
clockRate
:
48000
}
}
]
]
...
@@ -375,7 +379,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -375,7 +379,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'audio/'
,
name
:
'audio/'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
clockRate
:
48000
}
}
]
]
...
@@ -433,7 +437,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -433,7 +437,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
10
2
payloadType
:
10
0
}
}
]
]
})
})
...
@@ -452,7 +456,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -452,7 +456,7 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
,
clockRate
:
48000
,
rtx
:
{}
rtx
:
{}
}
}
...
@@ -473,12 +477,12 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -473,12 +477,12 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
clockRate
:
48000
},
},
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
clockRate
:
48000
}
}
]
]
...
@@ -502,12 +506,12 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
...
@@ -502,12 +506,12 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
clockRate
:
48000
,
clockRate
:
48000
,
rtx
:
rtx
:
{
{
payloadType
:
101
payloadType
:
0
}
}
},
},
{
{
name
:
'audio/
G722
'
,
name
:
'audio/
PCMU
'
,
payloadType
:
101
,
payloadType
:
0
,
clockRate
:
8000
clockRate
:
8000
}
}
]
]
...
@@ -541,7 +545,7 @@ tap.test('rtpReceiver.receive() with wrong encodings must fail', { timeout: 2000
...
@@ -541,7 +545,7 @@ tap.test('rtpReceiver.receive() with wrong encodings must fail', { timeout: 2000
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
clockRate
:
48000
}
}
],
],
...
@@ -611,7 +615,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
...
@@ -611,7 +615,7 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
[
[
{
{
name
:
'audio/opus'
,
name
:
'audio/opus'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
48000
clockRate
:
48000
}
}
]
]
...
@@ -626,9 +630,9 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
...
@@ -626,9 +630,9 @@ tap.test('two rtpReceiver.receive() over the same transport sharing PT values mu
codecs
:
codecs
:
[
[
{
{
name
:
'audio/
PCMU
'
,
name
:
'audio/
opus
'
,
payloadType
:
10
1
,
payloadType
:
10
0
,
clockRate
:
8000
clockRate
:
4
8000
}
}
]
]
})
})
...
...
test/test_Transport.js
浏览文件 @
f0db9781
...
@@ -4,7 +4,6 @@ const tap = require('tap');
...
@@ -4,7 +4,6 @@ const tap = require('tap');
const
mediasoup
=
require
(
'../'
);
const
mediasoup
=
require
(
'../'
);
const
roomOptions
=
require
(
'./data/options'
).
roomOptions
;
const
roomOptions
=
require
(
'./data/options'
).
roomOptions
;
const
peerOptions
=
require
(
'./data/options'
).
peerOptions
;
function
initTest
(
t
)
function
initTest
(
t
)
{
{
...
@@ -16,7 +15,7 @@ function initTest(t)
...
@@ -16,7 +15,7 @@ function initTest(t)
return
server
.
createRoom
(
roomOptions
)
return
server
.
createRoom
(
roomOptions
)
.
then
((
room
)
=>
.
then
((
room
)
=>
{
{
peer
=
room
.
Peer
(
'alice'
,
peerOptions
);
peer
=
room
.
Peer
(
'alice'
);
return
peer
.
createTransport
({
tcp
:
false
});
return
peer
.
createTransport
({
tcp
:
false
});
})
})
...
@@ -180,7 +179,7 @@ tap.test('transport.close() must succeed', { timeout: 2000 }, (t) =>
...
@@ -180,7 +179,7 @@ tap.test('transport.close() must succeed', { timeout: 2000 }, (t) =>
server
.
createRoom
(
roomOptions
)
server
.
createRoom
(
roomOptions
)
.
then
((
room
)
=>
.
then
((
room
)
=>
{
{
let
peer
=
room
.
Peer
(
'alice'
,
peerOptions
);
let
peer
=
room
.
Peer
(
'alice'
);
peer
.
createTransport
({
tcp
:
false
})
peer
.
createTransport
({
tcp
:
false
})
.
then
((
transport
)
=>
.
then
((
transport
)
=>
...
...
worker/include/Channel/Request.h
浏览文件 @
f0db9781
...
@@ -25,6 +25,7 @@ namespace Channel
...
@@ -25,6 +25,7 @@ namespace Channel
room_createPeer
,
room_createPeer
,
peer_close
,
peer_close
,
peer_dump
,
peer_dump
,
peer_setCapabilities
,
peer_createTransport
,
peer_createTransport
,
peer_createRtpReceiver
,
peer_createRtpReceiver
,
transport_close
,
transport_close
,
...
...
worker/include/RTC/Peer.h
浏览文件 @
f0db9781
...
@@ -27,6 +27,7 @@ namespace RTC
...
@@ -27,6 +27,7 @@ namespace RTC
{
{
public
:
public
:
virtual
void
onPeerClosed
(
RTC
::
Peer
*
peer
)
=
0
;
virtual
void
onPeerClosed
(
RTC
::
Peer
*
peer
)
=
0
;
virtual
void
onPeerCapabilities
(
RTC
::
Peer
*
peer
)
=
0
;
virtual
void
onPeerRtpReceiverParameters
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
=
0
;
virtual
void
onPeerRtpReceiverParameters
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
=
0
;
virtual
void
onPeerRtpReceiverParametersDone
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
=
0
;
virtual
void
onPeerRtpReceiverParametersDone
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
=
0
;
virtual
void
onPeerRtpReceiverClosed
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
=
0
;
virtual
void
onPeerRtpReceiverClosed
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
=
0
;
...
@@ -35,12 +36,13 @@ namespace RTC
...
@@ -35,12 +36,13 @@ namespace RTC
};
};
public
:
public
:
Peer
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
peerId
,
std
::
string
&
peerName
,
Json
::
Value
&
data
);
Peer
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
peerId
,
std
::
string
&
peerName
);
virtual
~
Peer
();
virtual
~
Peer
();
void
Close
();
void
Close
();
Json
::
Value
toJson
();
Json
::
Value
toJson
();
void
HandleRequest
(
Channel
::
Request
*
request
);
void
HandleRequest
(
Channel
::
Request
*
request
);
bool
HasCapabilities
();
std
::
vector
<
RTC
::
RtpReceiver
*>
GetRtpReceivers
();
std
::
vector
<
RTC
::
RtpReceiver
*>
GetRtpReceivers
();
/**
/**
* Add a new RtpSender to the Peer.
* Add a new RtpSender to the Peer.
...
@@ -79,6 +81,7 @@ namespace RTC
...
@@ -79,6 +81,7 @@ namespace RTC
Listener
*
listener
=
nullptr
;
Listener
*
listener
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
Channel
::
Notifier
*
notifier
=
nullptr
;
// Others.
// Others.
bool
hasCapabilities
=
false
;
RTC
::
RtpCapabilities
capabilities
;
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
;
...
@@ -87,6 +90,12 @@ namespace RTC
...
@@ -87,6 +90,12 @@ namespace RTC
/* Inline methods. */
/* Inline methods. */
inline
bool
Peer
::
HasCapabilities
()
{
return
this
->
hasCapabilities
;
}
inline
inline
std
::
vector
<
RTC
::
RtpReceiver
*>
Peer
::
GetRtpReceivers
()
std
::
vector
<
RTC
::
RtpReceiver
*>
Peer
::
GetRtpReceivers
()
{
{
...
...
worker/include/RTC/Room.h
浏览文件 @
f0db9781
...
@@ -49,6 +49,7 @@ namespace RTC
...
@@ -49,6 +49,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::Peer::Listener. */
/* Pure virtual methods inherited from RTC::Peer::Listener. */
public
:
public
:
virtual
void
onPeerClosed
(
RTC
::
Peer
*
peer
)
override
;
virtual
void
onPeerClosed
(
RTC
::
Peer
*
peer
)
override
;
virtual
void
onPeerCapabilities
(
RTC
::
Peer
*
peer
)
override
;
virtual
void
onPeerRtpReceiverParameters
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
override
;
virtual
void
onPeerRtpReceiverParameters
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
override
;
virtual
void
onPeerRtpReceiverParametersDone
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
override
;
virtual
void
onPeerRtpReceiverParametersDone
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
override
;
virtual
void
onPeerRtpReceiverClosed
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
override
;
virtual
void
onPeerRtpReceiverClosed
(
RTC
::
Peer
*
peer
,
RTC
::
RtpReceiver
*
rtpReceiver
)
override
;
...
...
worker/include/RTC/RtpDictionaries.h
浏览文件 @
f0db9781
...
@@ -11,6 +11,13 @@
...
@@ -11,6 +11,13 @@
namespace
RTC
namespace
RTC
{
{
enum
class
Scope
:
uint8_t
{
ROOM_CAPABILITY
=
1
,
PEER_CAPABILITY
,
RECEIVE
};
class
Media
class
Media
{
{
public
:
public
:
...
@@ -56,12 +63,13 @@ namespace RTC
...
@@ -56,12 +63,13 @@ namespace RTC
VP9
,
VP9
,
H264
,
H264
,
H265
,
H265
,
// Complementary codecs:
CN
=
300
,
TELEPHONE_EVENT
,
// Feature codecs:
// Feature codecs:
ULPFEC
=
10
00
,
ULPFEC
=
4
00
,
FLEXFEC
,
FLEXFEC
,
RED
,
RED
CN
,
TELEPHONE_EVENT
};
};
private
:
private
:
...
@@ -92,12 +100,17 @@ namespace RTC
...
@@ -92,12 +100,17 @@ namespace RTC
bool
IsMediaCodec
()
bool
IsMediaCodec
()
{
{
return
this
->
subtype
>=
Subtype
(
100
)
&&
this
->
subtype
<
(
Subtype
)
1000
;
return
this
->
subtype
>=
Subtype
(
100
)
&&
this
->
subtype
<
(
Subtype
)
300
;
}
bool
IsComplementaryCodec
()
{
return
this
->
subtype
>=
Subtype
(
300
)
&&
this
->
subtype
<
(
Subtype
)
400
;
}
}
bool
IsFeatureCodec
()
bool
IsFeatureCodec
()
{
{
return
this
->
subtype
>=
Subtype
(
10
00
);
return
this
->
subtype
>=
Subtype
(
4
00
);
}
}
public
:
public
:
...
@@ -108,23 +121,6 @@ namespace RTC
...
@@ -108,23 +121,6 @@ namespace RTC
std
::
string
name
;
std
::
string
name
;
};
};
class
RtpCodec
{
public
:
RtpCodec
()
{};
RtpCodec
(
Json
::
Value
&
data
);
void
toJson
(
Json
::
Value
&
json
);
public
:
RtpCodecMime
mime
;
uint32_t
clockRate
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
ptime
=
0
;
uint32_t
numChannels
=
1
;
RTC
::
Parameters
parameters
;
};
class
RTCRtpCodecRtxParameters
class
RTCRtpCodecRtxParameters
{
{
public
:
public
:
...
@@ -150,23 +146,31 @@ namespace RTC
...
@@ -150,23 +146,31 @@ namespace RTC
std
::
string
parameter
;
std
::
string
parameter
;
};
};
class
RtpCodecParameters
:
class
RtpCodecParameters
public
RtpCodec
{
{
public
:
public
:
RtpCodecParameters
(
Json
::
Value
&
data
,
bool
isRoomCodec
);
RtpCodecParameters
()
{};
// TODO: yes?
RtpCodecParameters
(
Json
::
Value
&
data
,
RTC
::
Scope
scope
);
Json
::
Value
toJson
();
Json
::
Value
toJson
();
bool
Matches
(
RtpCodecParameters
&
codec
,
bool
checkPayloadType
=
false
);
private
:
private
:
void
CheckCodec
();
void
CheckCodec
();
private
:
private
:
bool
isRoomCodec
=
false
;
RTC
::
Scope
scope
=
RTC
::
Scope
::
ROOM_CAPABILITY
;
public
:
public
:
Media
::
Kind
kind
=
Media
::
Kind
::
ALL
;
Media
::
Kind
kind
=
Media
::
Kind
::
ALL
;
RtpCodecMime
mime
;
uint8_t
payloadType
=
0
;
uint8_t
payloadType
=
0
;
bool
hasPayloadType
=
false
;
uint32_t
clockRate
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
ptime
=
0
;
uint32_t
numChannels
=
1
;
RTC
::
Parameters
parameters
;
RTCRtpCodecRtxParameters
rtx
;
RTCRtpCodecRtxParameters
rtx
;
bool
hasRtx
=
false
;
bool
hasRtx
=
false
;
std
::
vector
<
RtcpFeedback
>
rtcpFeedback
;
std
::
vector
<
RtcpFeedback
>
rtcpFeedback
;
...
@@ -271,29 +275,6 @@ namespace RTC
...
@@ -271,29 +275,6 @@ namespace RTC
Json
::
Value
userParameters
;
Json
::
Value
userParameters
;
};
};
class
RtpCodecCapability
:
public
RtpCodec
{
public
:
RtpCodecCapability
()
{};
RtpCodecCapability
(
Json
::
Value
&
data
);
Json
::
Value
toJson
();
bool
MatchesCodec
(
RtpCodecParameters
&
codec
);
void
Reduce
(
RtpCodecParameters
&
codec
);
private
:
void
CheckCodecCapability
();
public
:
Media
::
Kind
kind
=
Media
::
Kind
::
ALL
;
uint8_t
preferredPayloadType
=
0
;
std
::
vector
<
RtcpFeedback
>
rtcpFeedback
;
uint16_t
maxTemporalLayers
=
0
;
uint16_t
maxSpatialLayers
=
0
;
bool
svcMultiStreamSupport
=
false
;
};
class
RtpHeaderExtension
class
RtpHeaderExtension
{
{
public
:
public
:
...
@@ -312,15 +293,15 @@ namespace RTC
...
@@ -312,15 +293,15 @@ namespace RTC
{
{
public
:
public
:
RtpCapabilities
()
{};
RtpCapabilities
()
{};
RtpCapabilities
(
Json
::
Value
&
data
);
RtpCapabilities
(
Json
::
Value
&
data
,
RTC
::
Scope
scope
);
Json
::
Value
toJson
();
Json
::
Value
toJson
();
private
:
private
:
void
ValidateCodecs
();
void
ValidateCodecs
(
RTC
::
Scope
scope
);
public
:
public
:
std
::
vector
<
RtpCodec
Capability
>
codecs
;
std
::
vector
<
RtpCodec
Parameters
>
codecs
;
std
::
vector
<
RtpHeaderExtension
>
headerExtensions
;
std
::
vector
<
RtpHeaderExtension
>
headerExtensions
;
std
::
vector
<
std
::
string
>
fecMechanisms
;
std
::
vector
<
std
::
string
>
fecMechanisms
;
};
};
...
...
worker/mediasoup-worker.gyp
浏览文件 @
f0db9781
...
@@ -49,8 +49,6 @@
...
@@ -49,8 +49,6 @@
'src/RTC/RtpDictionaries/RtcpFeedback.cpp',
'src/RTC/RtpDictionaries/RtcpFeedback.cpp',
'src/RTC/RtpDictionaries/RtcpParameters.cpp',
'src/RTC/RtpDictionaries/RtcpParameters.cpp',
'src/RTC/RtpDictionaries/RtpCapabilities.cpp',
'src/RTC/RtpDictionaries/RtpCapabilities.cpp',
'src/RTC/RtpDictionaries/RtpCodec.cpp',
'src/RTC/RtpDictionaries/RtpCodecCapability.cpp',
'src/RTC/RtpDictionaries/RtpCodecMime.cpp',
'src/RTC/RtpDictionaries/RtpCodecMime.cpp',
'src/RTC/RtpDictionaries/RtpCodecParameters.cpp',
'src/RTC/RtpDictionaries/RtpCodecParameters.cpp',
'src/RTC/RtpDictionaries/RtpEncodingParameters.cpp',
'src/RTC/RtpDictionaries/RtpEncodingParameters.cpp',
...
...
worker/src/Channel/Request.cpp
浏览文件 @
f0db9781
...
@@ -18,6 +18,7 @@ namespace Channel
...
@@ -18,6 +18,7 @@ namespace Channel
{
"room.createPeer"
,
Request
::
MethodId
::
room_createPeer
},
{
"room.createPeer"
,
Request
::
MethodId
::
room_createPeer
},
{
"peer.close"
,
Request
::
MethodId
::
peer_close
},
{
"peer.close"
,
Request
::
MethodId
::
peer_close
},
{
"peer.dump"
,
Request
::
MethodId
::
peer_dump
},
{
"peer.dump"
,
Request
::
MethodId
::
peer_dump
},
{
"peer.setCapabilities"
,
Request
::
MethodId
::
peer_setCapabilities
},
{
"peer.createTransport"
,
Request
::
MethodId
::
peer_createTransport
},
{
"peer.createTransport"
,
Request
::
MethodId
::
peer_createTransport
},
{
"peer.createRtpReceiver"
,
Request
::
MethodId
::
peer_createRtpReceiver
},
{
"peer.createRtpReceiver"
,
Request
::
MethodId
::
peer_createRtpReceiver
},
{
"transport.close"
,
Request
::
MethodId
::
transport_close
},
{
"transport.close"
,
Request
::
MethodId
::
transport_close
},
...
...
worker/src/Loop.cpp
浏览文件 @
f0db9781
...
@@ -226,6 +226,7 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
...
@@ -226,6 +226,7 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
case
Channel
:
:
Request
::
MethodId
::
room_createPeer
:
case
Channel
:
:
Request
::
MethodId
::
room_createPeer
:
case
Channel
:
:
Request
::
MethodId
::
peer_close
:
case
Channel
:
:
Request
::
MethodId
::
peer_close
:
case
Channel
:
:
Request
::
MethodId
::
peer_dump
:
case
Channel
:
:
Request
::
MethodId
::
peer_dump
:
case
Channel
:
:
Request
::
MethodId
::
peer_setCapabilities
:
case
Channel
:
:
Request
::
MethodId
::
peer_createTransport
:
case
Channel
:
:
Request
::
MethodId
::
peer_createTransport
:
case
Channel
:
:
Request
::
MethodId
::
peer_createRtpReceiver
:
case
Channel
:
:
Request
::
MethodId
::
peer_createRtpReceiver
:
case
Channel
:
:
Request
::
MethodId
::
transport_close
:
case
Channel
:
:
Request
::
MethodId
::
transport_close
:
...
...
worker/src/RTC/Peer.cpp
浏览文件 @
f0db9781
...
@@ -9,24 +9,13 @@ namespace RTC
...
@@ -9,24 +9,13 @@ namespace RTC
{
{
/* Instance methods. */
/* Instance methods. */
Peer
::
Peer
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
peerId
,
std
::
string
&
peerName
,
Json
::
Value
&
data
)
:
Peer
::
Peer
(
Listener
*
listener
,
Channel
::
Notifier
*
notifier
,
uint32_t
peerId
,
std
::
string
&
peerName
)
:
peerId
(
peerId
),
peerId
(
peerId
),
peerName
(
peerName
),
peerName
(
peerName
),
listener
(
listener
),
listener
(
listener
),
notifier
(
notifier
)
notifier
(
notifier
)
{
{
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_capabilities
(
"capabilities"
);
// `mediaCodecs` is mandatory.
if
(
!
data
[
k_capabilities
].
isObject
())
MS_THROW_ERROR
(
"missing capabilities"
);
auto
&
json_capabilities
=
data
[
k_capabilities
];
// Build peer's capabilities.
this
->
capabilities
=
RTC
::
RtpCapabilities
(
json_capabilities
);
}
}
Peer
::~
Peer
()
Peer
::~
Peer
()
...
@@ -104,6 +93,7 @@ namespace RTC
...
@@ -104,6 +93,7 @@ namespace RTC
json
[
k_peerName
]
=
this
->
peerName
;
json
[
k_peerName
]
=
this
->
peerName
;
// Add `capabilities`.
// Add `capabilities`.
if
(
this
->
hasCapabilities
)
json
[
k_capabilities
]
=
this
->
capabilities
.
toJson
();
json
[
k_capabilities
]
=
this
->
capabilities
.
toJson
();
// Add `transports`.
// Add `transports`.
...
@@ -163,6 +153,37 @@ namespace RTC
...
@@ -163,6 +153,37 @@ namespace RTC
break
;
break
;
}
}
case
Channel
:
:
Request
::
MethodId
::
peer_setCapabilities
:
{
// Capabilities must not be set.
if
(
this
->
hasCapabilities
)
{
request
->
Reject
(
"peer capabilities already set"
);
return
;
}
try
{
this
->
capabilities
=
RTC
::
RtpCapabilities
(
request
->
data
,
RTC
::
Scope
::
PEER_CAPABILITY
);
}
catch
(
const
MediaSoupError
&
error
)
{
request
->
Reject
(
error
.
what
());
return
;
}
this
->
hasCapabilities
=
true
;
MS_DEBUG
(
"capabilities set"
);
request
->
Accept
();
// Notify the listener.
this
->
listener
->
onPeerCapabilities
(
this
);
break
;
}
case
Channel
:
:
Request
::
MethodId
::
peer_createTransport
:
case
Channel
:
:
Request
::
MethodId
::
peer_createTransport
:
{
{
RTC
::
Transport
*
transport
;
RTC
::
Transport
*
transport
;
...
@@ -213,6 +234,13 @@ namespace RTC
...
@@ -213,6 +234,13 @@ namespace RTC
RTC
::
Transport
*
transport
=
nullptr
;
RTC
::
Transport
*
transport
=
nullptr
;
uint32_t
rtpReceiverId
;
uint32_t
rtpReceiverId
;
// Capabilities must be set.
if
(
!
this
->
hasCapabilities
)
{
request
->
Reject
(
"peer capabilities are not yet set"
);
return
;
}
try
try
{
{
rtpReceiver
=
GetRtpReceiverFromRequest
(
request
,
&
rtpReceiverId
);
rtpReceiver
=
GetRtpReceiverFromRequest
(
request
,
&
rtpReceiverId
);
...
@@ -545,6 +573,28 @@ namespace RTC
...
@@ -545,6 +573,28 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
auto
rtpParameters
=
rtpReceiver
->
GetParameters
();
// Given codecs must be a subset of the capability codecs of the peer.
for
(
auto
codec
:
rtpParameters
->
codecs
)
{
auto
it
=
this
->
capabilities
.
codecs
.
begin
();
for
(;
it
!=
this
->
capabilities
.
codecs
.
end
();
++
it
)
{
auto
&
codecCapability
=
*
it
;
if
(
codecCapability
.
Matches
(
codec
,
true
))
break
;
}
if
(
it
==
this
->
capabilities
.
codecs
.
end
())
{
MS_THROW_ERROR
(
"no matching peer codec found [payloadType:%"
PRIu8
"]"
,
codec
.
payloadType
);
}
}
// Notify the listener (Room) so it can check provided codecs and,
// Notify the listener (Room) so it can check provided codecs and,
// optionally, normalize them.
// optionally, normalize them.
// NOTE: This may throw.
// NOTE: This may throw.
...
...
worker/src/RTC/Room.cpp
浏览文件 @
f0db9781
差异被折叠。
点击展开。
worker/src/RTC/RtpDictionaries/RtpCapabilities.cpp
浏览文件 @
f0db9781
...
@@ -9,7 +9,7 @@ namespace RTC
...
@@ -9,7 +9,7 @@ namespace RTC
{
{
/* Instance methods. */
/* Instance methods. */
RtpCapabilities
::
RtpCapabilities
(
Json
::
Value
&
data
)
RtpCapabilities
::
RtpCapabilities
(
Json
::
Value
&
data
,
RTC
::
Scope
scope
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -24,7 +24,7 @@ namespace RTC
...
@@ -24,7 +24,7 @@ namespace RTC
for
(
Json
::
UInt
i
=
0
;
i
<
json_codecs
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_codecs
.
size
();
i
++
)
{
{
RtpCodec
Capability
codec
(
json_codecs
[
i
]
);
RtpCodec
Parameters
codec
(
json_codecs
[
i
],
scope
);
// Append to the codecs vector.
// Append to the codecs vector.
this
->
codecs
.
push_back
(
codec
);
this
->
codecs
.
push_back
(
codec
);
...
@@ -62,7 +62,7 @@ namespace RTC
...
@@ -62,7 +62,7 @@ namespace RTC
// Validate RTP capabilities.
// Validate RTP capabilities.
ValidateCodecs
();
ValidateCodecs
(
scope
);
}
}
Json
::
Value
RtpCapabilities
::
toJson
()
Json
::
Value
RtpCapabilities
::
toJson
()
...
@@ -103,25 +103,23 @@ namespace RTC
...
@@ -103,25 +103,23 @@ namespace RTC
}
}
inline
inline
void
RtpCapabilities
::
ValidateCodecs
()
void
RtpCapabilities
::
ValidateCodecs
(
RTC
::
Scope
scope
)
{
{
MS_TRACE
();
MS_TRACE
();
// Must be at least one codec.
if
(
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
)
if
(
this
->
codecs
.
size
()
==
0
)
{
MS_THROW_ERROR
(
"empty RtpCapabilities.codecs"
);
// Payload types must be unique.
// Preferred payload types must be unique.
std
::
unordered_set
<
uint8_t
>
preferredP
ayloadTypes
;
std
::
unordered_set
<
uint8_t
>
p
ayloadTypes
;
for
(
auto
&
codec
:
this
->
codecs
)
for
(
auto
&
codec
:
this
->
codecs
)
{
{
// Preferred payload types must be unique.
if
(
payloadTypes
.
find
(
codec
.
payloadType
)
!=
payloadTypes
.
end
())
if
(
preferredPayloadTypes
.
find
(
codec
.
preferredPayloadType
)
!=
preferredPayloadTypes
.
end
())
MS_THROW_ERROR
(
"duplicated codec.payloadType"
);
MS_THROW_ERROR
(
"duplicated codec.preferredPayloadType"
);
else
else
preferredPayloadTypes
.
insert
(
codec
.
preferredPayloadType
);
payloadTypes
.
insert
(
codec
.
payloadType
);
}
}
}
}
}
}
}
worker/src/RTC/RtpDictionaries/RtpCodec.cpp
deleted
100644 → 0
浏览文件 @
0ad4ae10
#define MS_CLASS "RTC::RtpCodec"
#include "RTC/RtpDictionaries.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtpCodec
::
RtpCodec
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_name
(
"name"
);
static
const
Json
::
StaticString
k_clockRate
(
"clockRate"
);
static
const
Json
::
StaticString
k_maxptime
(
"maxptime"
);
static
const
Json
::
StaticString
k_ptime
(
"ptime"
);
static
const
Json
::
StaticString
k_numChannels
(
"numChannels"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"RtpCodec is not an object"
);
// `name` is mandatory.
if
(
!
data
[
k_name
].
isString
())
MS_THROW_ERROR
(
"missing RtpCodec.name"
);
std
::
string
name
=
data
[
k_name
].
asString
();
// Set MIME field.
// NOTE: This may throw.
this
->
mime
.
SetName
(
name
);
// `clockRate` is mandatory.
if
(
!
data
[
k_clockRate
].
isUInt
())
MS_THROW_ERROR
(
"missing RtpCodec.clockRate"
);
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
// `maxptime` is optional.
if
(
data
[
k_maxptime
].
isUInt
())
this
->
maxptime
=
(
uint32_t
)
data
[
k_maxptime
].
asUInt
();
// `ptime` is optional.
if
(
data
[
k_ptime
].
isUInt
())
this
->
ptime
=
(
uint32_t
)
data
[
k_ptime
].
asUInt
();
// `numChannels` is optional.
if
(
data
[
k_numChannels
].
isUInt
())
this
->
numChannels
=
(
uint32_t
)
data
[
k_numChannels
].
asUInt
();
// `parameters` is optional.
if
(
data
[
k_parameters
].
isObject
())
this
->
parameters
.
Set
(
data
[
k_parameters
]);
}
void
RtpCodec
::
toJson
(
Json
::
Value
&
json
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_name
(
"name"
);
static
const
Json
::
StaticString
k_clockRate
(
"clockRate"
);
static
const
Json
::
StaticString
k_maxptime
(
"maxptime"
);
static
const
Json
::
StaticString
k_ptime
(
"ptime"
);
static
const
Json
::
StaticString
k_numChannels
(
"numChannels"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
// Add `name`.
json
[
k_name
]
=
this
->
mime
.
GetName
();
// Add `clockRate`.
json
[
k_clockRate
]
=
(
Json
::
UInt
)
this
->
clockRate
;
// Add `maxptime`.
if
(
this
->
maxptime
)
json
[
k_maxptime
]
=
(
Json
::
UInt
)
this
->
maxptime
;
// Add `ptime`.
if
(
this
->
ptime
)
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
// Add `numChannels`.
if
(
this
->
numChannels
>
1
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
// Add `parameters`.
json
[
k_parameters
]
=
this
->
parameters
.
toJson
();
}
}
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
deleted
100644 → 0
浏览文件 @
0ad4ae10
#define MS_CLASS "RTC::RtpCodecCapability"
#include "RTC/RtpDictionaries.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtpCodecCapability
::
RtpCodecCapability
(
Json
::
Value
&
data
)
:
RtpCodec
(
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_preferredPayloadType
(
"preferredPayloadType"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_maxTemporalLayers
(
"maxTemporalLayers"
);
static
const
Json
::
StaticString
k_maxSpatialLayers
(
"maxSpatialLayers"
);
static
const
Json
::
StaticString
k_svcMultiStreamSupport
(
"svcMultiStreamSupport"
);
// `kind` is mandatory.
if
(
!
data
[
k_kind
].
isString
())
MS_THROW_ERROR
(
"missing RtpCodecCapability.kind"
);
std
::
string
kind
=
data
[
k_kind
].
asString
();
// NOTE: This may throw.
this
->
kind
=
RTC
::
Media
::
GetKind
(
kind
);
// It can not be empty kind (all).
if
(
this
->
kind
==
RTC
::
Media
::
Kind
::
ALL
)
MS_THROW_ERROR
(
"invalid empty RtpCodecCapability.kind"
);
// `preferredPayloadType` is mandatory.
if
(
!
data
[
k_preferredPayloadType
].
isUInt
())
MS_THROW_ERROR
(
"missing RtpCodecCapability.preferredPayloadType"
);
this
->
preferredPayloadType
=
(
uint8_t
)
data
[
k_preferredPayloadType
].
asUInt
();
// `rtcpFeedback` is optional.
if
(
data
[
k_rtcpFeedback
].
isArray
())
{
auto
&
json_rtcpFeedback
=
data
[
k_rtcpFeedback
];
for
(
Json
::
UInt
i
=
0
;
i
<
json_rtcpFeedback
.
size
();
i
++
)
{
RtcpFeedback
rtcpFeedback
(
json_rtcpFeedback
[
i
]);
// Append to the rtcpFeedback vector.
this
->
rtcpFeedback
.
push_back
(
rtcpFeedback
);
}
}
// `maxTemporalLayers` is optional.
if
(
data
[
k_maxTemporalLayers
].
isUInt
())
this
->
maxTemporalLayers
=
(
uint16_t
)
data
[
k_maxTemporalLayers
].
asUInt
();
// `maxSpatialLayers` is optional.
if
(
data
[
k_maxSpatialLayers
].
isUInt
())
this
->
maxSpatialLayers
=
(
uint16_t
)
data
[
k_maxSpatialLayers
].
asUInt
();
// `svcMultiStreamSupport` is optional.
if
(
data
[
k_svcMultiStreamSupport
].
isBool
())
this
->
svcMultiStreamSupport
=
data
[
k_svcMultiStreamSupport
].
asBool
();
// Check codec capability.
CheckCodecCapability
();
}
Json
::
Value
RtpCodecCapability
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_preferredPayloadType
(
"preferredPayloadType"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_maxTemporalLayers
(
"maxTemporalLayers"
);
static
const
Json
::
StaticString
k_maxSpatialLayers
(
"maxSpatialLayers"
);
static
const
Json
::
StaticString
k_svcMultiStreamSupport
(
"svcMultiStreamSupport"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Call the parent method.
RtpCodec
::
toJson
(
json
);
// Add `kind`.
json
[
k_kind
]
=
RTC
::
Media
::
GetJsonString
(
this
->
kind
);
// Add `preferredPayloadType`.
json
[
k_preferredPayloadType
]
=
(
Json
::
UInt
)
this
->
preferredPayloadType
;
// Add `rtcpFeedback`.
json
[
k_rtcpFeedback
]
=
Json
::
arrayValue
;
for
(
auto
&
entry
:
this
->
rtcpFeedback
)
{
json
[
k_rtcpFeedback
].
append
(
entry
.
toJson
());
}
// Add `maxTemporalLayers` (if set).
if
(
this
->
maxTemporalLayers
)
json
[
k_maxTemporalLayers
]
=
(
Json
::
UInt
)
this
->
maxTemporalLayers
;
// Add `maxSpatialLayers` (if set).
if
(
this
->
maxSpatialLayers
)
json
[
k_maxSpatialLayers
]
=
(
Json
::
UInt
)
this
->
maxSpatialLayers
;
// Add `svcMultiStreamSupport` (if set).
if
(
this
->
svcMultiStreamSupport
)
json
[
k_svcMultiStreamSupport
]
=
true
;
return
json
;
}
bool
RtpCodecCapability
::
MatchesCodec
(
RtpCodecParameters
&
codec
)
{
MS_TRACE
();
static
std
::
string
k_packetizationMode
=
"packetizationMode"
;
// MIME must match.
if
(
this
->
mime
!=
codec
.
mime
)
return
false
;
// Clock rate must match.
if
(
this
->
clockRate
!=
codec
.
clockRate
)
return
false
;
// Per kind checks.
switch
(
this
->
kind
)
{
case
RTC
:
:
Media
::
Kind
::
AUDIO
:
{
// Num channels must match
if
(
this
->
numChannels
!=
codec
.
numChannels
)
return
false
;
break
;
}
default
:
;
}
// Per MIME checks.
switch
(
this
->
mime
.
subtype
)
{
case
RTC
:
:
RtpCodecMime
::
Subtype
::
H264
:
{
if
(
!
this
->
parameters
.
IncludesInteger
(
k_packetizationMode
,
codec
.
parameters
.
GetInteger
(
k_packetizationMode
)))
{
return
false
;
}
break
;
}
default
:
;
}
return
true
;
}
// NOTE: This method assumes that MatchesCodec() has been called before
// with same codec and returned true.
void
RtpCodecCapability
::
Reduce
(
RtpCodecParameters
&
codec
)
{
MS_TRACE
();
static
std
::
string
k_packetizationMode
=
"packetizationMode"
;
switch
(
codec
.
mime
.
subtype
)
{
case
RTC
:
:
RtpCodecMime
::
Subtype
::
H264
:
{
std
::
vector
<
int32_t
>
packetizationMode
;
// NOTE: `packetizationMode` is set by RtpCodecParameter if not present.
packetizationMode
.
push_back
(
codec
.
parameters
.
GetInteger
(
k_packetizationMode
));
this
->
parameters
.
SetArrayOfIntegers
(
k_packetizationMode
,
packetizationMode
);
break
;
}
default
:
;
}
}
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
浏览文件 @
f0db9781
...
@@ -8,33 +8,96 @@ namespace RTC
...
@@ -8,33 +8,96 @@ namespace RTC
{
{
/* Instance methods. */
/* Instance methods. */
RtpCodecParameters
::
RtpCodecParameters
(
Json
::
Value
&
data
,
bool
isRoomCodec
)
:
RtpCodecParameters
::
RtpCodecParameters
(
Json
::
Value
&
data
,
RTC
::
Scope
scope
)
:
RtpCodec
(
data
),
scope
(
scope
)
isRoomCodec
(
isRoomCodec
)
{
{
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_name
(
"name"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_clockRate
(
"clockRate"
);
static
const
Json
::
StaticString
k_maxptime
(
"maxptime"
);
static
const
Json
::
StaticString
k_ptime
(
"ptime"
);
static
const
Json
::
StaticString
k_numChannels
(
"numChannels"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
// Not a room codec.
if
(
!
data
.
isObject
())
if
(
!
this
->
isRoomCodec
)
MS_THROW_ERROR
(
"RtpCodecParameters is not an object"
);
if
(
this
->
scope
==
RTC
::
Scope
::
ROOM_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
)
{
{
// `payloadType` is mandatory.
// `kind` is mandatory.
if
(
!
data
[
k_payloadType
].
isUInt
())
if
(
!
data
[
k_kind
].
isString
())
MS_THROW_ERROR
(
"missing RtpCodecParameters.payloadType"
);
MS_THROW_ERROR
(
"missing RtpCodecParameters.kind"
);
std
::
string
kind
=
data
[
k_kind
].
asString
();
// NOTE: This may throw.
this
->
kind
=
RTC
::
Media
::
GetKind
(
kind
);
}
// `name` is mandatory.
if
(
!
data
[
k_name
].
isString
())
MS_THROW_ERROR
(
"missing RtpCodec.name"
);
std
::
string
name
=
data
[
k_name
].
asString
();
// Set MIME field.
// NOTE: This may throw.
this
->
mime
.
SetName
(
name
);
if
(
data
[
k_payloadType
].
isUInt
())
{
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
this
->
hasPayloadType
=
true
;
}
if
(
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
{
if
(
!
this
->
hasPayloadType
)
MS_THROW_ERROR
(
"missing RtpCodecParameters.payloadType"
);
}
// `clockRate` is mandatory.
if
(
!
data
[
k_clockRate
].
isUInt
())
MS_THROW_ERROR
(
"missing RtpCodecParameters.clockRate"
);
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
// `maxptime` is optional.
if
(
data
[
k_maxptime
].
isUInt
())
this
->
maxptime
=
(
uint32_t
)
data
[
k_maxptime
].
asUInt
();
// `ptime` is optional.
if
(
data
[
k_ptime
].
isUInt
())
this
->
ptime
=
(
uint32_t
)
data
[
k_ptime
].
asUInt
();
// `numChannels` is optional.
if
(
data
[
k_numChannels
].
isUInt
())
this
->
numChannels
=
(
uint32_t
)
data
[
k_numChannels
].
asUInt
();
// `parameters` is optional.
if
(
data
[
k_parameters
].
isObject
())
this
->
parameters
.
Set
(
data
[
k_parameters
]);
if
(
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
{
// `rtx` is optional.
// `rtx` is optional.
if
(
data
[
k_rtx
].
isObject
())
if
(
data
[
k_rtx
].
isObject
())
{
{
this
->
rtx
=
RTCRtpCodecRtxParameters
(
data
[
k_rtx
]);
this
->
rtx
=
RTC
::
RTC
RtpCodecRtxParameters
(
data
[
k_rtx
]);
this
->
hasRtx
=
true
;
this
->
hasRtx
=
true
;
}
}
}
if
(
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
{
// `rtcpFeedback` is optional.
// `rtcpFeedback` is optional.
if
(
data
[
k_rtcpFeedback
].
isArray
())
if
(
data
[
k_rtcpFeedback
].
isArray
())
{
{
...
@@ -42,29 +105,13 @@ namespace RTC
...
@@ -42,29 +105,13 @@ namespace RTC
for
(
Json
::
UInt
i
=
0
;
i
<
json_rtcpFeedback
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_rtcpFeedback
.
size
();
i
++
)
{
{
RtcpFeedback
rtcpFeedback
(
json_rtcpFeedback
[
i
]);
R
TC
::
R
tcpFeedback
rtcpFeedback
(
json_rtcpFeedback
[
i
]);
// Append to the rtcpFeedback vector.
// Append to the rtcpFeedback vector.
this
->
rtcpFeedback
.
push_back
(
rtcpFeedback
);
this
->
rtcpFeedback
.
push_back
(
rtcpFeedback
);
}
}
}
}
}
}
// Room codec.
else
{
// `kind` is mandatory.
if
(
!
data
[
k_kind
].
isString
())
MS_THROW_ERROR
(
"missing RtpCodecParameters.kind"
);
std
::
string
kind
=
data
[
k_kind
].
asString
();
// NOTE: This may throw.
this
->
kind
=
RTC
::
Media
::
GetKind
(
kind
);
// It must not be a feature codec.
if
(
this
->
mime
.
IsFeatureCodec
())
MS_THROW_ERROR
(
"can not be a feature codec"
);
}
// Check codec.
// Check codec.
CheckCodec
();
CheckCodec
();
...
@@ -75,25 +122,62 @@ namespace RTC
...
@@ -75,25 +122,62 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_name
(
"name"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_clockRate
(
"clockRate"
);
static
const
Json
::
StaticString
k_maxptime
(
"maxptime"
);
static
const
Json
::
StaticString
k_ptime
(
"ptime"
);
static
const
Json
::
StaticString
k_numChannels
(
"numChannels"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
(
Json
::
objectValue
);
// Call the parent method.
if
(
this
->
scope
==
RTC
::
Scope
::
ROOM_CAPABILITY
||
RtpCodec
::
toJson
(
json
);
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
)
{
// Add `kind`.
json
[
k_kind
]
=
RTC
::
Media
::
GetJsonString
(
this
->
kind
);
}
// Not a room codec.
// Add `name`.
if
(
!
this
->
isRoomCodec
)
json
[
k_name
]
=
this
->
mime
.
GetName
();
if
(
this
->
hasPayloadType
)
{
{
// Add `payloadType`.
// Add `payloadType`.
json
[
k_payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
json
[
k_payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
}
// Add `clockRate`.
json
[
k_clockRate
]
=
(
Json
::
UInt
)
this
->
clockRate
;
// Add `maxptime`.
if
(
this
->
maxptime
)
json
[
k_maxptime
]
=
(
Json
::
UInt
)
this
->
maxptime
;
// Add `ptime`.
if
(
this
->
ptime
)
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
// Add `numChannels`.
if
(
this
->
numChannels
>
1
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
// Add `parameters`.
json
[
k_parameters
]
=
this
->
parameters
.
toJson
();
if
(
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
{
// Add `rtx`
// Add `rtx`
if
(
this
->
hasRtx
)
if
(
this
->
hasRtx
)
json
[
k_rtx
]
=
this
->
rtx
.
toJson
();
json
[
k_rtx
]
=
this
->
rtx
.
toJson
();
}
if
(
this
->
scope
==
RTC
::
Scope
::
PEER_CAPABILITY
||
this
->
scope
==
RTC
::
Scope
::
RECEIVE
)
{
// Add `rtcpFeedback`.
// Add `rtcpFeedback`.
json
[
k_rtcpFeedback
]
=
Json
::
arrayValue
;
json
[
k_rtcpFeedback
]
=
Json
::
arrayValue
;
...
@@ -102,14 +186,66 @@ namespace RTC
...
@@ -102,14 +186,66 @@ namespace RTC
json
[
k_rtcpFeedback
].
append
(
entry
.
toJson
());
json
[
k_rtcpFeedback
].
append
(
entry
.
toJson
());
}
}
}
}
// Room codec.
else
return
json
;
}
bool
RtpCodecParameters
::
Matches
(
RtpCodecParameters
&
codec
,
bool
checkPayloadType
)
{
{
// Add `kind`.
MS_TRACE
();
json
[
k_kind
]
=
RTC
::
Media
::
GetJsonString
(
this
->
kind
);
static
std
::
string
k_packetizationMode
=
"packetizationMode"
;
// MIME must match.
if
(
this
->
mime
!=
codec
.
mime
)
return
false
;
if
(
checkPayloadType
)
{
if
(
this
->
payloadType
!=
codec
.
payloadType
)
return
false
;
}
}
return
json
;
// Clock rate must match.
if
(
this
->
clockRate
!=
codec
.
clockRate
)
return
false
;
// Per kind checks.
switch
(
this
->
kind
)
{
case
RTC
:
:
Media
::
Kind
::
AUDIO
:
{
// Num channels must match
if
(
this
->
numChannels
!=
codec
.
numChannels
)
return
false
;
break
;
}
default
:
;
}
// Per MIME checks.
switch
(
this
->
mime
.
subtype
)
{
case
RTC
:
:
RtpCodecMime
::
Subtype
::
H264
:
{
if
(
this
->
parameters
.
GetInteger
(
k_packetizationMode
)
!=
codec
.
parameters
.
GetInteger
(
k_packetizationMode
))
{
return
false
;
}
break
;
}
default
:
;
}
return
true
;
}
}
inline
inline
...
...
worker/src/RTC/RtpDictionaries/RtpParameters.cpp
浏览文件 @
f0db9781
...
@@ -36,7 +36,7 @@ namespace RTC
...
@@ -36,7 +36,7 @@ namespace RTC
for
(
Json
::
UInt
i
=
0
;
i
<
json_codecs
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_codecs
.
size
();
i
++
)
{
{
R
tpCodecParameters
codec
(
json_codecs
[
i
],
false
);
R
TC
::
RtpCodecParameters
codec
(
json_codecs
[
i
],
RTC
::
Scope
::
RECEIVE
);
// Append to the codecs vector.
// Append to the codecs vector.
this
->
codecs
.
push_back
(
codec
);
this
->
codecs
.
push_back
(
codec
);
...
@@ -54,7 +54,7 @@ namespace RTC
...
@@ -54,7 +54,7 @@ namespace RTC
for
(
Json
::
UInt
i
=
0
;
i
<
json_array
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_array
.
size
();
i
++
)
{
{
RtpEncodingParameters
encoding
(
json_array
[
i
]);
R
TC
::
R
tpEncodingParameters
encoding
(
json_array
[
i
]);
// Append to the encodings vector.
// Append to the encodings vector.
this
->
encodings
.
push_back
(
encoding
);
this
->
encodings
.
push_back
(
encoding
);
...
@@ -68,7 +68,7 @@ namespace RTC
...
@@ -68,7 +68,7 @@ namespace RTC
for
(
Json
::
UInt
i
=
0
;
i
<
json_array
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_array
.
size
();
i
++
)
{
{
RtpHeaderExtensionParameters
headerExtension
(
json_array
[
i
]);
R
TC
::
R
tpHeaderExtensionParameters
headerExtension
(
json_array
[
i
]);
// Append to the headerExtensions vector.
// Append to the headerExtensions vector.
this
->
headerExtensions
.
push_back
(
headerExtension
);
this
->
headerExtensions
.
push_back
(
headerExtension
);
...
@@ -78,7 +78,7 @@ namespace RTC
...
@@ -78,7 +78,7 @@ namespace RTC
// `rtcp` is optional.
// `rtcp` is optional.
if
(
data
[
k_rtcp
].
isObject
())
if
(
data
[
k_rtcp
].
isObject
())
{
{
this
->
rtcp
=
RtcpParameters
(
data
[
k_rtcp
]);
this
->
rtcp
=
R
TC
::
R
tcpParameters
(
data
[
k_rtcp
]);
this
->
hasRtcp
=
true
;
this
->
hasRtcp
=
true
;
}
}
...
@@ -216,7 +216,7 @@ namespace RTC
...
@@ -216,7 +216,7 @@ namespace RTC
// the first media codec.
// the first media codec.
if
(
this
->
encodings
.
size
()
==
0
)
if
(
this
->
encodings
.
size
()
==
0
)
{
{
RtpEncodingParameters
encoding
;
R
TC
::
R
tpEncodingParameters
encoding
;
encoding
.
codecPayloadType
=
firstMediaPayloadType
;
encoding
.
codecPayloadType
=
firstMediaPayloadType
;
encoding
.
hasCodecPayloadType
=
true
;
encoding
.
hasCodecPayloadType
=
true
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论