Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
2ee3ea87
提交
2ee3ea87
authored
5月 11, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Sync RtpParameters with ORTC
上级
85e698b8
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
559 行增加
和
295 行删除
+559
-295
test_RtpReceiver.js
test/test_RtpReceiver.js
+45
-16
RtpParameters.h
worker/include/RTC/RtpParameters.h
+85
-67
mediasoup-worker.gyp
worker/mediasoup-worker.gyp
+4
-3
CustomParameterValue.cpp
worker/src/RTC/RtpParameters/CustomParameterValue.cpp
+34
-0
RtcpParameters.cpp
worker/src/RTC/RtpParameters/RtcpParameters.cpp
+10
-9
RtpCodecParameters.cpp
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
+20
-78
RtpEncodingParameters.cpp
worker/src/RTC/RtpParameters/RtpEncodingParameters.cpp
+111
-29
RtpFecParameters.cpp
worker/src/RTC/RtpParameters/RtpFecParameters.cpp
+14
-14
RtpHeaderExtensionParameters.cpp
...er/src/RTC/RtpParameters/RtpHeaderExtensionParameters.cpp
+144
-0
RtpParameters.cpp
worker/src/RTC/RtpParameters/RtpParameters.cpp
+48
-24
RtpRtxParameters.cpp
worker/src/RTC/RtpParameters/RtpRtxParameters.cpp
+44
-0
RtxCodecParameters.cpp
worker/src/RTC/RtpParameters/RtxCodecParameters.cpp
+0
-55
没有找到文件。
test/test_RtpReceiver.js
浏览文件 @
2ee3ea87
...
...
@@ -23,18 +23,11 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
codecs
:
[
{
name
:
'H264'
,
payloadType
:
100
,
numChannels
:
2
,
rtx
:
{
payloadType
:
96
,
rtxTime
:
1000
},
fec
:
[
{
mechanism
:
'foo'
,
payloadType
:
97
}
],
name
:
'H264'
,
payloadType
:
100
,
maxptime
:
80
,
ptime
:
60
,
numChannels
:
2
,
rtcpFeedback
:
[
{
type
:
'ccm'
,
parameter
:
'fir'
},
...
...
@@ -42,7 +35,7 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
{
type
:
'nack'
,
parameter
:
'pli'
},
{
type
:
'google-remb'
,
parameter
:
''
}
],
parameters
:
parameters
:
{
profileLevelId
:
2
,
packetizationMode
:
1
,
...
...
@@ -54,9 +47,45 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
encodings
:
[
{
ssrc
:
100000021
,
rtxSsrc
:
100000022
,
fecSsrc
:
100000023
ssrc
:
100000
,
codecPayloadType
:
100
,
fec
:
{
ssrc
:
200000
,
mechanism
:
'foo'
},
rtx
:
{
ssrc
:
300000
},
resolutionScale
:
2.2
,
framerateScale
:
1.5
,
maxFramerate
:
30
,
active
:
false
,
encodingId
:
'ENC3'
,
dependencyEncodingIds
:
[
'ENC1'
,
'ENC2'
]
}
],
headerExtensions
:
[
{
uri
:
'urn:ietf:params:rtp-hdrext:foo'
,
id
:
1234
,
encrypt
:
false
},
{
uri
:
'urn:ietf:params:rtp-hdrext:bar'
,
id
:
5678
,
encrypt
:
true
},
{
uri
:
'urn:ietf:params:rtp-hdrext:ssrc-audio-level'
,
id
:
6
,
encrypt
:
false
,
parameters
:
{
vad
:
'on'
}
}
],
rtcp
:
...
...
worker/include/RTC/RtpParameters.h
浏览文件 @
2ee3ea87
...
...
@@ -9,95 +9,91 @@
namespace
RTC
{
class
RtxCodecParameters
class
CustomParameterValue
{
public
:
enum
class
Type
{
BOOLEAN
=
1
,
STRING
,
INTEGER
};
public
:
CustomParameterValue
()
{};
CustomParameterValue
(
bool
booleanValue
);
CustomParameterValue
(
uint32_t
integerValue
);
CustomParameterValue
(
std
::
string
&
stringValue
);
virtual
~
CustomParameterValue
();
Json
::
Value
toJson
();
public
:
Type
type
;
bool
booleanValue
=
false
;
uint32_t
integerValue
=
0
;
std
::
string
stringValue
=
""
;
};
typedef
std
::
unordered_map
<
std
::
string
,
CustomParameterValue
>
CustomParameters
;
class
RtcpFeedback
{
public
:
RtxCodecParameters
()
{};
RtxCodecParameters
(
Json
::
Value
&
data
);
virtual
~
RtxCodecParameters
();
RtcpFeedback
(
Json
::
Value
&
data
);
virtual
~
RtcpFeedback
();
Json
::
Value
toJson
();
public
:
uint8_t
payloadType
=
0
;
uint32_t
rtxTime
=
0
;
std
::
string
type
;
std
::
string
parameter
;
};
class
Fec
CodecParameters
class
Rtp
CodecParameters
{
public
:
FecCodecParameters
()
{};
FecCodecParameters
(
Json
::
Value
&
data
);
virtual
~
FecCodecParameters
();
RtpCodecParameters
(
Json
::
Value
&
data
);
virtual
~
RtpCodecParameters
();
Json
::
Value
toJson
();
public
:
std
::
string
mechanism
;
uint8_t
payloadType
=
0
;
// TODO: optional parameters
// https://github.com/openpeer/ortc/issues/444#issuecomment-203560671
std
::
string
name
;
uint8_t
payloadType
=
0
;
uint32_t
clockRate
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
ptime
=
0
;
uint32_t
numChannels
=
0
;
std
::
vector
<
RtcpFeedback
>
rtcpFeedback
;
CustomParameters
parameters
;
};
class
Rt
cpFeedback
class
Rt
pFecParameters
{
public
:
RtcpFeedback
(
Json
::
Value
&
data
);
virtual
~
RtcpFeedback
();
RtpFecParameters
()
{};
RtpFecParameters
(
Json
::
Value
&
data
);
virtual
~
RtpFecParameters
();
Json
::
Value
toJson
();
public
:
std
::
string
type
;
std
::
string
parameter
;
uint32_t
ssrc
=
0
;
std
::
string
mechanism
;
};
class
Rtp
Codec
Parameters
class
Rtp
Rtx
Parameters
{
public
:
class
ParameterValue
{
public
:
enum
class
Type
{
BOOLEAN
=
1
,
STRING
,
INTEGER
};
public
:
ParameterValue
()
{};
ParameterValue
(
bool
booleanValue
);
ParameterValue
(
uint32_t
integerValue
);
ParameterValue
(
std
::
string
&
stringValue
);
virtual
~
ParameterValue
();
Json
::
Value
toJson
();
public
:
Type
type
;
bool
booleanValue
=
false
;
uint32_t
integerValue
=
0
;
std
::
string
stringValue
=
""
;
};
public
:
RtpCodecParameters
(
Json
::
Value
&
data
);
virtual
~
RtpCodecParameters
();
RtpRtxParameters
()
{};
RtpRtxParameters
(
Json
::
Value
&
data
);
virtual
~
RtpRtxParameters
();
Json
::
Value
toJson
();
public
:
std
::
string
name
;
uint8_t
payloadType
=
0
;
uint32_t
clockRate
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
numChannels
=
0
;
bool
hasRtx
=
false
;
RtxCodecParameters
rtx
;
std
::
vector
<
FecCodecParameters
>
fec
;
std
::
vector
<
RtcpFeedback
>
rtcpFeedback
;
std
::
unordered_map
<
std
::
string
,
ParameterValue
>
parameters
;
uint32_t
ssrc
=
0
;
};
class
RtpEncodingParameters
...
...
@@ -109,10 +105,18 @@ namespace RTC
Json
::
Value
toJson
();
public
:
uint8_t
codecPayloadType
=
0
;
uint32_t
ssrc
=
0
;
uint32_t
rtxSsrc
=
0
;
uint32_t
fecSsrc
=
0
;
uint32_t
ssrc
=
0
;
uint8_t
codecPayloadType
=
0
;
RtpFecParameters
fec
;
bool
hasFec
=
false
;
RtpRtxParameters
rtx
;
bool
hasRtx
=
false
;
double
resolutionScale
=
1
.
0
;
double
framerateScale
=
1
.
0
;
uint32_t
maxFramerate
=
0
;
bool
active
=
true
;
std
::
string
encodingId
;
std
::
vector
<
std
::
string
>
dependencyEncodingIds
;
};
class
RtcpParameters
...
...
@@ -130,6 +134,22 @@ namespace RTC
bool
reducedSize
=
false
;
};
class
RtpHeaderExtensionParameters
{
public
:
RtpHeaderExtensionParameters
()
{};
RtpHeaderExtensionParameters
(
Json
::
Value
&
data
);
virtual
~
RtpHeaderExtensionParameters
();
Json
::
Value
toJson
();
public
:
std
::
string
uri
;
uint16_t
id
=
0
;
bool
encrypt
=
false
;
CustomParameters
parameters
;
};
class
RtpParameters
{
public
:
...
...
@@ -143,12 +163,10 @@ namespace RTC
// TODO: not sure if 1 or 2 bytes or what.
std
::
string
muxId
;
std
::
vector
<
RtpCodecParameters
>
codecs
;
// TODO:
// std::vector<RtpHeaderExtensionParameters> headerExtensions;
std
::
vector
<
RtpEncodingParameters
>
encodings
;
std
::
vector
<
RtpHeaderExtensionParameters
>
headerExtensions
;
RtcpParameters
rtcp
;
// TODO:
// DegradationPreference degradationPreference = "balanced";
bool
hasRtcp
=
false
;
};
}
...
...
worker/mediasoup-worker.gyp
浏览文件 @
2ee3ea87
...
...
@@ -43,14 +43,15 @@
'src/RTC/Transport.cpp',
'src/RTC/TransportTuple.cpp',
'src/RTC/UdpSocket.cpp',
'src/RTC/RtpParameters/FecCodecParameters.cpp',
'src/RTC/RtpParameters/CustomParameterValue.cpp',
'src/RTC/RtpParameters/RtcpFeedback.cpp',
'src/RTC/RtpParameters/RtcpParameters.cpp',
'src/RTC/RtpParameters/RtpCodecParameters.cpp',
'src/RTC/RtpParameters/RtpEncodingParameters.cpp',
'src/RTC/RtpParameters/RtpFecParameters.cpp',
'src/RTC/RtpParameters/RtpHeaderExtensionParameters.cpp',
'src/RTC/RtpParameters/RtpParameters.cpp',
'src/RTC/RtpParameters/Rt
xCodec
Parameters.cpp',
'src/RTC/RtpParameters/Rt
pRtx
Parameters.cpp',
'src/Utils/Crypto.cpp',
'src/Utils/File.cpp',
'src/Utils/IP.cpp',
...
...
worker/src/RTC/RtpParameters/CustomParameterValue.cpp
0 → 100644
浏览文件 @
2ee3ea87
#define MS_CLASS "RTC::CustomParameterValue"
#include "RTC/RtpParameters.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
CustomParameterValue
::
CustomParameterValue
(
bool
booleanValue
)
:
type
(
Type
::
BOOLEAN
),
booleanValue
(
booleanValue
)
{
MS_TRACE
();
}
CustomParameterValue
::
CustomParameterValue
(
uint32_t
integerValue
)
:
type
(
Type
::
INTEGER
),
integerValue
(
integerValue
)
{
MS_TRACE
();
}
CustomParameterValue
::
CustomParameterValue
(
std
::
string
&
stringValue
)
:
type
(
Type
::
STRING
),
stringValue
(
stringValue
)
{
MS_TRACE
();
}
CustomParameterValue
::~
CustomParameterValue
()
{
MS_TRACE
();
}
}
worker/src/RTC/RtpParameters/RtcpParameters.cpp
浏览文件 @
2ee3ea87
...
...
@@ -17,15 +17,15 @@ namespace RTC
static
const
Json
::
StaticString
k_reducedSize
(
"reducedSize"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"
RtcpPa`
rameters` is not an object"
);
MS_THROW_ERROR
(
"
`RtcpPa
rameters` is not an object"
);
// `cname` is
mandatory
.
if
(
!
data
[
k_cname
].
isString
())
MS_THROW_ERROR
(
"missing `RtcpParameters.cname`"
);
this
->
cname
=
data
[
k_cname
].
asString
();
if
(
this
->
cname
.
empty
())
MS_THROW_ERROR
(
"empty `RtcpParameters.cname`"
);
// `cname` is
optional
.
if
(
data
[
k_cname
].
isString
())
{
this
->
cname
=
data
[
k_cname
].
asString
();
if
(
this
->
cname
.
empty
())
MS_THROW_ERROR
(
"empty `RtcpParameters.cname`"
);
}
// `ssrc` is optional.
if
(
data
[
k_ssrc
].
isUInt
())
...
...
@@ -52,7 +52,8 @@ namespace RTC
Json
::
Value
json
(
Json
::
objectValue
);
// Add `cname`.
json
[
k_cname
]
=
this
->
cname
;
if
(
!
this
->
cname
.
empty
())
json
[
k_cname
]
=
this
->
cname
;
// Add `ssrc`.
if
(
this
->
ssrc
)
...
...
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
浏览文件 @
2ee3ea87
...
...
@@ -16,9 +16,8 @@ namespace RTC
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_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_fec
(
"fec"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
...
...
@@ -47,31 +46,14 @@ namespace RTC
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
();
// `rtx` is optional.
if
(
data
[
k_rtx
].
isObject
())
{
this
->
rtx
=
RtxCodecParameters
(
data
[
k_rtx
]);
this
->
hasRtx
=
true
;
}
// `fec` is optional.
if
(
data
[
k_fec
].
isArray
())
{
auto
&
json_fec
=
data
[
k_fec
];
for
(
Json
::
UInt
i
=
0
;
i
<
json_fec
.
size
();
i
++
)
{
FecCodecParameters
fec
(
json_fec
[
i
]);
// Append to the fec vector.
this
->
fec
.
push_back
(
fec
);
}
}
// `rtcpFeedback` is optional.
if
(
data
[
k_rtcpFeedback
].
isArray
())
{
...
...
@@ -102,7 +84,7 @@ namespace RTC
{
bool
booleanValue
=
value
.
asBool
();
this
->
parameters
[
key
]
=
ParameterValue
(
booleanValue
);
this
->
parameters
[
key
]
=
RTC
::
Custom
ParameterValue
(
booleanValue
);
break
;
}
...
...
@@ -112,7 +94,7 @@ namespace RTC
{
uint32_t
integerValue
=
(
uint32_t
)
value
.
asUInt
();
this
->
parameters
[
key
]
=
ParameterValue
(
integerValue
);
this
->
parameters
[
key
]
=
RTC
::
Custom
ParameterValue
(
integerValue
);
break
;
}
...
...
@@ -121,7 +103,7 @@ namespace RTC
{
std
::
string
stringValue
=
value
.
asString
();
this
->
parameters
[
key
]
=
ParameterValue
(
stringValue
);
this
->
parameters
[
key
]
=
RTC
::
Custom
ParameterValue
(
stringValue
);
break
;
}
...
...
@@ -146,9 +128,8 @@ namespace RTC
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_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_fec
(
"fec"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
...
...
@@ -168,35 +149,22 @@ namespace RTC
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
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
// Add `rtx`
if
(
this
->
hasRtx
)
json
[
k_rtx
]
=
this
->
rtx
.
toJson
();
// Add `fec` (if any).
if
(
!
this
->
fec
.
empty
())
{
json
[
k_fec
]
=
Json
::
arrayValue
;
for
(
auto
it
=
this
->
fec
.
begin
();
it
!=
this
->
fec
.
end
();
++
it
)
{
FecCodecParameters
*
fec
=
std
::
addressof
(
*
it
);
json
[
k_fec
].
append
(
fec
->
toJson
());
}
}
// Add `rtcpFeedback` (if any).
if
(
!
this
->
rtcpFeedback
.
empty
())
{
json
[
k_rtcpFeedback
]
=
Json
::
arrayValue
;
for
(
auto
it
=
this
->
rtcpFeedback
.
begin
();
it
!=
this
->
rtcpFeedback
.
end
();
++
it
)
{
RtcpFeedback
*
rtcpFeedback
=
std
::
addressof
(
*
it
);
json
[
k_rtcpFeedback
].
append
(
rtcpFeedback
->
toJson
());
for
(
auto
&
entry
:
this
->
rtcpFeedback
)
{
json
[
k_rtcpFeedback
].
append
(
entry
.
toJson
());
}
}
...
...
@@ -208,19 +176,19 @@ namespace RTC
for
(
auto
&
kv
:
this
->
parameters
)
{
const
std
::
string
&
key
=
kv
.
first
;
ParameterValue
&
parameterValue
=
kv
.
second
;
RTC
::
Custom
ParameterValue
&
parameterValue
=
kv
.
second
;
switch
(
parameterValue
.
type
)
{
case
ParameterValue
:
:
Type
::
BOOLEAN
:
case
RTC
:
:
Custom
ParameterValue
::
Type
::
BOOLEAN
:
json_parameters
[
key
]
=
parameterValue
.
booleanValue
;
break
;
case
ParameterValue
:
:
Type
::
INTEGER
:
case
RTC
:
:
Custom
ParameterValue
::
Type
::
INTEGER
:
json_parameters
[
key
]
=
(
Json
::
UInt
)
parameterValue
.
integerValue
;
break
;
case
ParameterValue
:
:
Type
::
STRING
:
case
RTC
:
:
Custom
ParameterValue
::
Type
::
STRING
:
json_parameters
[
key
]
=
parameterValue
.
stringValue
;
break
;
}
...
...
@@ -231,30 +199,4 @@ namespace RTC
return
json
;
}
RtpCodecParameters
::
ParameterValue
::
ParameterValue
(
bool
booleanValue
)
:
type
(
Type
::
BOOLEAN
),
booleanValue
(
booleanValue
)
{
MS_TRACE
();
}
RtpCodecParameters
::
ParameterValue
::
ParameterValue
(
uint32_t
integerValue
)
:
type
(
Type
::
INTEGER
),
integerValue
(
integerValue
)
{
MS_TRACE
();
}
RtpCodecParameters
::
ParameterValue
::
ParameterValue
(
std
::
string
&
stringValue
)
:
type
(
Type
::
STRING
),
stringValue
(
stringValue
)
{
MS_TRACE
();
}
RtpCodecParameters
::
ParameterValue
::~
ParameterValue
()
{
MS_TRACE
();
}
}
worker/src/RTC/RtpParameters/RtpEncodingParameters.cpp
浏览文件 @
2ee3ea87
...
...
@@ -13,30 +13,75 @@ namespace RTC
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
static
const
Json
::
StaticString
k_rtxSsrc
(
"rtxSsrc"
);
static
const
Json
::
StaticString
k_fecSsrc
(
"fecSsrc"
);
static
const
Json
::
StaticString
k_codecPayloadType
(
"codecPayloadType"
);
static
const
Json
::
StaticString
k_fec
(
"fec"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_resolutionScale
(
"resolutionScale"
);
static
const
Json
::
StaticString
k_framerateScale
(
"framerateScale"
);
static
const
Json
::
StaticString
k_maxFramerate
(
"maxFramerate"
);
static
const
Json
::
StaticString
k_active
(
"active"
);
static
const
Json
::
StaticString
k_encodingId
(
"encodingId"
);
static
const
Json
::
StaticString
k_dependencyEncodingIds
(
"dependencyEncodingIds"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"`RtpEncodingParameters is not an object"
);
// `ssrc` is mandatory.
if
(
!
data
[
k_ssrc
].
isUInt
())
MS_THROW_ERROR
(
"missing `RtpEncodingParameters.ssrc`"
);
this
->
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
// `rtxSsrc` is optional.
if
(
data
[
k_rtxSsrc
].
isUInt
())
this
->
rtxSsrc
=
(
uint32_t
)
data
[
k_rtxSsrc
].
asUInt
();
// `fecSsrc` is optional.
if
(
data
[
k_fecSsrc
].
isUInt
())
this
->
fecSsrc
=
(
uint32_t
)
data
[
k_fecSsrc
].
asUInt
();
// `codecPayloadType` is optional.
if
(
data
[
k_codecPayloadType
].
isUInt
())
this
->
codecPayloadType
=
(
uint8_t
)
data
[
k_codecPayloadType
].
asUInt
();
// `ssrc` is optional.
if
(
data
[
k_ssrc
].
isUInt
())
this
->
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
// `fec` is optional.
if
(
data
[
k_fec
].
isObject
())
{
this
->
fec
=
RtpFecParameters
(
data
[
k_fec
]);
this
->
hasFec
=
true
;
}
// `rtx` is optional.
if
(
data
[
k_rtx
].
isObject
())
{
this
->
rtx
=
RtpRtxParameters
(
data
[
k_rtx
]);
this
->
hasRtx
=
true
;
}
// `resolutionScale` is optional.
if
(
data
[
k_resolutionScale
].
isDouble
())
this
->
resolutionScale
=
data
[
k_resolutionScale
].
asDouble
();
// `framerateScale` is optional.
if
(
data
[
k_framerateScale
].
isDouble
())
this
->
framerateScale
=
data
[
k_framerateScale
].
asDouble
();
// `maxFramerate` is optional.
if
(
data
[
k_maxFramerate
].
isUInt
())
this
->
maxFramerate
=
(
uint32_t
)
data
[
k_maxFramerate
].
asUInt
();
// `active` is optional.
if
(
data
[
k_active
].
isBool
())
this
->
active
=
data
[
k_active
].
asBool
();
// `encodingId` is optional.
if
(
data
[
k_encodingId
].
isString
())
this
->
encodingId
=
data
[
k_encodingId
].
asString
();
// `dependencyEncodingIds` is optional.
if
(
data
[
k_dependencyEncodingIds
].
isArray
())
{
auto
&
json_array
=
data
[
k_dependencyEncodingIds
];
for
(
Json
::
UInt
i
=
0
;
i
<
json_array
.
size
();
i
++
)
{
auto
&
entry
=
json_array
[
i
];
// Append to the dependencyEncodingIds vector.
if
(
entry
.
isString
())
this
->
dependencyEncodingIds
.
push_back
(
entry
.
asString
());
}
}
}
RtpEncodingParameters
::~
RtpEncodingParameters
()
...
...
@@ -49,27 +94,64 @@ namespace RTC
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
static
const
Json
::
StaticString
k_rtxSsrc
(
"rtxSsrc"
);
static
const
Json
::
StaticString
k_fecSsrc
(
"fecSsrc"
);
static
const
Json
::
StaticString
k_codecPayloadType
(
"codecPayloadType"
);
static
const
Json
::
StaticString
k_fec
(
"fec"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_resolutionScale
(
"resolutionScale"
);
static
const
Json
::
StaticString
k_framerateScale
(
"framerateScale"
);
static
const
Json
::
StaticString
k_maxFramerate
(
"maxFramerate"
);
static
const
Json
::
StaticString
k_active
(
"active"
);
static
const
Json
::
StaticString
k_encodingId
(
"encodingId"
);
static
const
Json
::
StaticString
k_dependencyEncodingIds
(
"dependencyEncodingIds"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `ssrc`.
json
[
k_ssrc
]
=
(
Json
::
UInt
)
this
->
ssrc
;
// Add `rtxSsrc`.
if
(
this
->
rtxSsrc
)
json
[
k_rtxSsrc
]
=
(
Json
::
UInt
)
this
->
rtxSsrc
;
// Add `fecSsrc`.
if
(
this
->
fecSsrc
)
json
[
k_fecSsrc
]
=
(
Json
::
UInt
)
this
->
fecSsrc
;
// Add `codecPayloadType`.
if
(
this
->
codecPayloadType
)
json
[
k_codecPayloadType
]
=
(
Json
::
UInt
)
this
->
codecPayloadType
;
// Add `ssrc`.
if
(
this
->
ssrc
)
json
[
k_ssrc
]
=
(
Json
::
UInt
)
this
->
ssrc
;
// Add `fec`
if
(
this
->
hasFec
)
json
[
k_fec
]
=
this
->
fec
.
toJson
();
// Add `rtx`
if
(
this
->
hasRtx
)
json
[
k_rtx
]
=
this
->
rtx
.
toJson
();
// Add `resolutionScale` (if different than the default value).
if
(
this
->
resolutionScale
!=
1.0
)
json
[
k_resolutionScale
]
=
this
->
resolutionScale
;
// Add `framerateScale` (if different than the default value).
if
(
this
->
framerateScale
!=
1.0
)
json
[
k_framerateScale
]
=
this
->
framerateScale
;
// Add `maxFramerate`.
if
(
this
->
maxFramerate
)
json
[
k_maxFramerate
]
=
(
Json
::
UInt
)
this
->
maxFramerate
;
// Add `active`.
json
[
k_active
]
=
this
->
active
;
// Add `encodingId`.
if
(
!
this
->
encodingId
.
empty
())
json
[
k_encodingId
]
=
this
->
encodingId
;
// Add `dependencyEncodingIds` (if any).
if
(
!
this
->
dependencyEncodingIds
.
empty
())
{
json
[
k_dependencyEncodingIds
]
=
Json
::
arrayValue
;
for
(
auto
&
entry
:
this
->
dependencyEncodingIds
)
{
json
[
k_dependencyEncodingIds
].
append
(
entry
);
}
}
return
json
;
}
}
worker/src/RTC/RtpParameters/
FecCod
ecParameters.cpp
→
worker/src/RTC/RtpParameters/
RtpF
ecParameters.cpp
浏览文件 @
2ee3ea87
#define MS_CLASS "RTC::
FecCod
ecParameters"
#define MS_CLASS "RTC::
RtpF
ecParameters"
#include "RTC/RtpParameters.h"
#include "MediaSoupError.h"
...
...
@@ -8,47 +8,47 @@ namespace RTC
{
/* Instance methods. */
FecCodecParameters
::
FecCod
ecParameters
(
Json
::
Value
&
data
)
RtpFecParameters
::
RtpF
ecParameters
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
static
const
Json
::
StaticString
k_mechanism
(
"mechanism"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"`
FecCodecParameters`
is not an object"
);
MS_THROW_ERROR
(
"`
RtpFecParameters
is not an object"
);
// `mechanism` is mandatory.
if
(
!
data
[
k_mechanism
].
isString
())
MS_THROW_ERROR
(
"missing `
FecCod
ecParameters.mechanism`"
);
MS_THROW_ERROR
(
"missing `
RtpF
ecParameters.mechanism`"
);
this
->
mechanism
=
data
[
k_mechanism
].
asString
();
// `
payloadType
` is optional.
if
(
data
[
k_
payloadType
].
isUInt
())
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
// `
ssrc
` is optional.
if
(
data
[
k_
ssrc
].
isUInt
())
this
->
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
}
FecCodecParameters
::~
FecCod
ecParameters
()
RtpFecParameters
::~
RtpF
ecParameters
()
{
MS_TRACE
();
}
Json
::
Value
FecCod
ecParameters
::
toJson
()
Json
::
Value
RtpF
ecParameters
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
static
const
Json
::
StaticString
k_mechanism
(
"mechanism"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `mechanism`.
json
[
k_mechanism
]
=
this
->
mechanism
;
// Add `
payloadType
`.
if
(
this
->
payloadType
)
json
[
k_
payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
// Add `
ssrc
`.
if
(
this
->
ssrc
)
json
[
k_
ssrc
]
=
(
Json
::
UInt
)
this
->
ssrc
;
return
json
;
}
...
...
worker/src/RTC/RtpParameters/RtpHeaderExtensionParameters.cpp
0 → 100644
浏览文件 @
2ee3ea87
#define MS_CLASS "RTC::RtpHeaderExtensionParameters"
#include "RTC/RtpParameters.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtpHeaderExtensionParameters
::
RtpHeaderExtensionParameters
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_uri
(
"uri"
);
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_encrypt
(
"encrypt"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"`RtpHeaderExtensionParameters` is not an object"
);
// `uri` is mandatory.
if
(
!
data
[
k_uri
].
isString
())
MS_THROW_ERROR
(
"missing `RtpHeaderExtensionParameters.uri`"
);
this
->
uri
=
data
[
k_uri
].
asString
();
if
(
this
->
uri
.
empty
())
MS_THROW_ERROR
(
"empty `RtpHeaderExtensionParameters.uri`"
);
// `id` is mandatory.
if
(
!
data
[
k_id
].
asUInt
())
MS_THROW_ERROR
(
"missing `RtpHeaderExtensionParameters.id`"
);
this
->
id
=
(
uint16_t
)
data
[
k_id
].
asUInt
();
// `encrypt` is optional.
if
(
data
[
k_encrypt
].
isBool
())
this
->
encrypt
=
data
[
k_encrypt
].
asBool
();
// `parameters` is optional.
if
(
data
[
k_parameters
].
isObject
())
{
auto
&
parameters
=
data
[
k_parameters
];
for
(
Json
::
Value
::
iterator
it
=
parameters
.
begin
();
it
!=
parameters
.
end
();
++
it
)
{
std
::
string
key
=
it
.
key
().
asString
();
Json
::
Value
value
=
(
*
it
);
switch
(
value
.
type
())
{
case
Json
:
:
booleanValue
:
{
bool
booleanValue
=
value
.
asBool
();
this
->
parameters
[
key
]
=
RTC
::
CustomParameterValue
(
booleanValue
);
break
;
}
case
Json
:
:
uintValue
:
case
Json
:
:
intValue
:
{
uint32_t
integerValue
=
(
uint32_t
)
value
.
asUInt
();
this
->
parameters
[
key
]
=
RTC
::
CustomParameterValue
(
integerValue
);
break
;
}
case
Json
:
:
stringValue
:
{
std
::
string
stringValue
=
value
.
asString
();
this
->
parameters
[
key
]
=
RTC
::
CustomParameterValue
(
stringValue
);
break
;
}
default
:
;
// Just ignore other value types
}
}
}
}
RtpHeaderExtensionParameters
::~
RtpHeaderExtensionParameters
()
{
MS_TRACE
();
}
Json
::
Value
RtpHeaderExtensionParameters
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_uri
(
"uri"
);
static
const
Json
::
StaticString
k_id
(
"id"
);
static
const
Json
::
StaticString
k_encrypt
(
"encrypt"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `uri`.
json
[
k_uri
]
=
this
->
uri
;
// Add `id`.
json
[
k_id
]
=
(
Json
::
UInt
)
this
->
id
;
// Add `encrypt`.
json
[
k_encrypt
]
=
this
->
encrypt
;
// Add `parameters` (if any).
if
(
this
->
parameters
.
size
()
>
0
)
{
Json
::
Value
json_parameters
(
Json
::
objectValue
);
for
(
auto
&
kv
:
this
->
parameters
)
{
const
std
::
string
&
key
=
kv
.
first
;
RTC
::
CustomParameterValue
&
parameterValue
=
kv
.
second
;
switch
(
parameterValue
.
type
)
{
case
RTC
:
:
CustomParameterValue
::
Type
::
BOOLEAN
:
json_parameters
[
key
]
=
parameterValue
.
booleanValue
;
break
;
case
RTC
:
:
CustomParameterValue
::
Type
::
INTEGER
:
json_parameters
[
key
]
=
(
Json
::
UInt
)
parameterValue
.
integerValue
;
break
;
case
RTC
:
:
CustomParameterValue
::
Type
::
STRING
:
json_parameters
[
key
]
=
parameterValue
.
stringValue
;
break
;
}
}
json
[
k_parameters
]
=
json_parameters
;
}
return
json
;
}
}
worker/src/RTC/RtpParameters/RtpParameters.cpp
浏览文件 @
2ee3ea87
...
...
@@ -15,13 +15,12 @@ namespace RTC
static
const
Json
::
StaticString
k_muxId
(
"muxId"
);
static
const
Json
::
StaticString
k_codecs
(
"codecs"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_headerExtensions
(
"headerExtensions"
);
static
const
Json
::
StaticString
k_rtcp
(
"rtcp"
);
// `muxId` is optional.
if
(
data
[
k_muxId
].
isString
())
{
this
->
muxId
=
data
[
k_muxId
].
asString
();
}
// `codecs` is mandatory.
if
(
data
[
k_codecs
].
isArray
())
...
...
@@ -38,35 +37,42 @@ namespace RTC
}
else
{
MS_THROW_ERROR
(
"missing `codecs`"
);
MS_THROW_ERROR
(
"missing `
RtpCodecParameters.
codecs`"
);
}
// `encodings` is
mandatory
.
// `encodings` is
optional
.
if
(
data
[
k_encodings
].
isArray
())
{
auto
&
json_
encodings
=
data
[
k_encodings
];
auto
&
json_
array
=
data
[
k_encodings
];
for
(
Json
::
UInt
i
=
0
;
i
<
json_
encodings
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_
array
.
size
();
i
++
)
{
RtpEncodingParameters
encoding
(
json_
encodings
[
i
]);
RtpEncodingParameters
encoding
(
json_
array
[
i
]);
// Append to the encodings vector.
this
->
encodings
.
push_back
(
encoding
);
}
}
else
// `headerExtensions` is optional.
if
(
data
[
k_headerExtensions
].
isArray
())
{
MS_THROW_ERROR
(
"missing `encodings`"
);
auto
&
json_array
=
data
[
k_headerExtensions
];
for
(
Json
::
UInt
i
=
0
;
i
<
json_array
.
size
();
i
++
)
{
RtpHeaderExtensionParameters
headerExtension
(
json_array
[
i
]);
// Append to the headerExtensions vector.
this
->
headerExtensions
.
push_back
(
headerExtension
);
}
}
// `rtcp` is
mandatory
.
// `rtcp` is
optional
.
if
(
data
[
k_rtcp
].
isObject
())
{
this
->
rtcp
=
RtcpParameters
(
data
[
k_rtcp
]);
}
else
{
MS_THROW_ERROR
(
"missing `rtcp`"
);
this
->
hasRtcp
=
true
;
}
}
...
...
@@ -92,33 +98,51 @@ namespace RTC
static
const
Json
::
StaticString
k_muxId
(
"muxId"
);
static
const
Json
::
StaticString
k_codecs
(
"codecs"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_headerExtensions
(
"headerExtensions"
);
static
const
Json
::
StaticString
k_rtcp
(
"rtcp"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `muxId`.
json
[
k_muxId
]
=
this
->
muxId
;
if
(
!
this
->
muxId
.
empty
())
json
[
k_muxId
]
=
this
->
muxId
;
// Add `codecs`.
json
[
k_codecs
]
=
Json
::
arrayValue
;
for
(
auto
it
=
this
->
codecs
.
begin
();
it
!=
this
->
codecs
.
end
();
++
it
)
if
(
!
this
->
codecs
.
empty
())
{
RtpCodecParameters
*
codec
=
std
::
addressof
(
*
it
)
;
json
[
k_codecs
]
=
Json
::
arrayValue
;
json
[
k_codecs
].
append
(
codec
->
toJson
());
for
(
auto
&
entry
:
this
->
codecs
)
{
json
[
k_codecs
].
append
(
entry
.
toJson
());
}
}
// Add `encodings`.
json
[
k_encodings
]
=
Json
::
arrayValue
;
for
(
auto
it
=
this
->
encodings
.
begin
();
it
!=
this
->
encodings
.
end
();
++
it
)
if
(
!
this
->
encodings
.
empty
())
{
json
[
k_encodings
]
=
Json
::
arrayValue
;
for
(
auto
&
entry
:
this
->
encodings
)
{
json
[
k_encodings
].
append
(
entry
.
toJson
());
}
}
// Add `headerExtensions`.
if
(
!
this
->
headerExtensions
.
empty
())
{
RtpEncodingParameters
*
encoding
=
std
::
addressof
(
*
it
)
;
json
[
k_headerExtensions
]
=
Json
::
arrayValue
;
json
[
k_encodings
].
append
(
encoding
->
toJson
());
for
(
auto
&
entry
:
this
->
headerExtensions
)
{
json
[
k_headerExtensions
].
append
(
entry
.
toJson
());
}
}
// Add `rtcp`.
json
[
k_rtcp
]
=
this
->
rtcp
.
toJson
();
if
(
this
->
hasRtcp
)
json
[
k_rtcp
]
=
this
->
rtcp
.
toJson
();
return
json
;
}
...
...
worker/src/RTC/RtpParameters/RtpRtxParameters.cpp
0 → 100644
浏览文件 @
2ee3ea87
#define MS_CLASS "RTC::RtpRtxParameters"
#include "RTC/RtpParameters.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtpRtxParameters
::
RtpRtxParameters
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"`RtpRtxParameters is not an object"
);
// `ssrc` is optional.
if
(
data
[
k_ssrc
].
isUInt
())
this
->
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
}
RtpRtxParameters
::~
RtpRtxParameters
()
{
MS_TRACE
();
}
Json
::
Value
RtpRtxParameters
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `ssrc`.
if
(
this
->
ssrc
)
json
[
k_ssrc
]
=
(
Json
::
UInt
)
this
->
ssrc
;
return
json
;
}
}
worker/src/RTC/RtpParameters/RtxCodecParameters.cpp
deleted
100644 → 0
浏览文件 @
85e698b8
#define MS_CLASS "RTC::RtxCodecParameters"
#include "RTC/RtpParameters.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtxCodecParameters
::
RtxCodecParameters
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_rtxTime
(
"rtxTime"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"`RtxCodecParameters is not an object"
);
// `payloadType` is mandatory.
if
(
!
data
[
k_payloadType
].
isUInt
())
MS_THROW_ERROR
(
"missing `RtpEncodingParameters.payloadType`"
);
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
// `rtxTime` is optional.
if
(
data
[
k_rtxTime
].
isUInt
())
this
->
rtxTime
=
(
uint32_t
)
data
[
k_rtxTime
].
asUInt
();
}
RtxCodecParameters
::~
RtxCodecParameters
()
{
MS_TRACE
();
}
Json
::
Value
RtxCodecParameters
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_rtxTime
(
"rtxTime"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `payloadType`.
json
[
k_payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
// Add `rtxTime`.
if
(
this
->
rtxTime
)
json
[
k_rtxTime
]
=
(
Json
::
UInt
)
this
->
rtxTime
;
return
json
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论