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 个修改的文件
包含
531 行增加
和
267 行删除
+531
-267
test_RtpReceiver.js
test/test_RtpReceiver.js
+41
-12
RtpParameters.h
worker/include/RTC/RtpParameters.h
+72
-54
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
+6
-5
RtpCodecParameters.cpp
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
+20
-78
RtpEncodingParameters.cpp
worker/src/RTC/RtpParameters/RtpEncodingParameters.cpp
+107
-25
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
+45
-21
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
...
@@ -25,16 +25,9 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
...
@@ -25,16 +25,9 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
{
{
name
:
'H264'
,
name
:
'H264'
,
payloadType
:
100
,
payloadType
:
100
,
maxptime
:
80
,
ptime
:
60
,
numChannels
:
2
,
numChannels
:
2
,
rtx
:
{
payloadType
:
96
,
rtxTime
:
1000
},
fec
:
[
{
mechanism
:
'foo'
,
payloadType
:
97
}
],
rtcpFeedback
:
rtcpFeedback
:
[
[
{
type
:
'ccm'
,
parameter
:
'fir'
},
{
type
:
'ccm'
,
parameter
:
'fir'
},
...
@@ -54,9 +47,45 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
...
@@ -54,9 +47,45 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
encodings
:
encodings
:
[
[
{
{
ssrc
:
100000021
,
ssrc
:
100000
,
rtxSsrc
:
100000022
,
codecPayloadType
:
100
,
fecSsrc
:
100000023
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
:
rtcp
:
...
...
worker/include/RTC/RtpParameters.h
浏览文件 @
2ee3ea87
...
@@ -9,36 +9,34 @@
...
@@ -9,36 +9,34 @@
namespace
RTC
namespace
RTC
{
{
class
RtxCodecParameters
class
CustomParameterValue
{
{
public
:
public
:
RtxCodecParameters
()
{};
enum
class
Type
RtxCodecParameters
(
Json
::
Value
&
data
);
{
virtual
~
RtxCodecParameters
();
BOOLEAN
=
1
,
STRING
,
Json
::
Value
toJson
();
INTEGER
public
:
uint8_t
payloadType
=
0
;
uint32_t
rtxTime
=
0
;
};
};
class
FecCodecParameters
{
public
:
public
:
FecCodecParameters
()
{};
CustomParameterValue
()
{};
FecCodecParameters
(
Json
::
Value
&
data
);
CustomParameterValue
(
bool
booleanValue
);
virtual
~
FecCodecParameters
();
CustomParameterValue
(
uint32_t
integerValue
);
CustomParameterValue
(
std
::
string
&
stringValue
);
virtual
~
CustomParameterValue
();
Json
::
Value
toJson
();
Json
::
Value
toJson
();
public
:
public
:
std
::
string
mechanism
;
Type
type
;
uint8_t
payloadType
=
0
;
bool
booleanValue
=
false
;
// TODO: optional parameters
uint32_t
integerValue
=
0
;
// https://github.com/openpeer/ortc/issues/444#issuecomment-203560671
std
::
string
stringValue
=
""
;
};
};
typedef
std
::
unordered_map
<
std
::
string
,
CustomParameterValue
>
CustomParameters
;
class
RtcpFeedback
class
RtcpFeedback
{
{
public
:
public
:
...
@@ -55,49 +53,47 @@ namespace RTC
...
@@ -55,49 +53,47 @@ namespace RTC
class
RtpCodecParameters
class
RtpCodecParameters
{
{
public
:
public
:
class
ParameterValue
RtpCodecParameters
(
Json
::
Value
&
data
);
{
virtual
~
RtpCodecParameters
();
Json
::
Value
toJson
();
public
:
public
:
enum
class
Type
std
::
string
name
;
{
uint8_t
payloadType
=
0
;
BOOLEAN
=
1
,
uint32_t
clockRate
=
0
;
STRING
,
uint32_t
maxptime
=
0
;
INTEGER
uint32_t
ptime
=
0
;
uint32_t
numChannels
=
0
;
std
::
vector
<
RtcpFeedback
>
rtcpFeedback
;
CustomParameters
parameters
;
};
};
class
RtpFecParameters
{
public
:
public
:
ParameterValue
()
{};
RtpFecParameters
()
{};
ParameterValue
(
bool
booleanValue
);
RtpFecParameters
(
Json
::
Value
&
data
);
ParameterValue
(
uint32_t
integerValue
);
virtual
~
RtpFecParameters
();
ParameterValue
(
std
::
string
&
stringValue
);
virtual
~
ParameterValue
();
Json
::
Value
toJson
();
Json
::
Value
toJson
();
public
:
public
:
Type
type
;
uint32_t
ssrc
=
0
;
bool
booleanValue
=
false
;
std
::
string
mechanism
;
uint32_t
integerValue
=
0
;
std
::
string
stringValue
=
""
;
};
};
class
RtpRtxParameters
{
public
:
public
:
RtpCodecParameters
(
Json
::
Value
&
data
);
RtpRtxParameters
()
{};
virtual
~
RtpCodecParameters
();
RtpRtxParameters
(
Json
::
Value
&
data
);
virtual
~
RtpRtxParameters
();
Json
::
Value
toJson
();
Json
::
Value
toJson
();
public
:
public
:
std
::
string
name
;
uint32_t
ssrc
=
0
;
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
;
};
};
class
RtpEncodingParameters
class
RtpEncodingParameters
...
@@ -109,10 +105,18 @@ namespace RTC
...
@@ -109,10 +105,18 @@ namespace RTC
Json
::
Value
toJson
();
Json
::
Value
toJson
();
public
:
public
:
uint8_t
codecPayloadType
=
0
;
uint32_t
ssrc
=
0
;
uint32_t
ssrc
=
0
;
uint32_t
rtxSsrc
=
0
;
uint8_t
codecPayloadType
=
0
;
uint32_t
fecSsrc
=
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
class
RtcpParameters
...
@@ -130,6 +134,22 @@ namespace RTC
...
@@ -130,6 +134,22 @@ namespace RTC
bool
reducedSize
=
false
;
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
class
RtpParameters
{
{
public
:
public
:
...
@@ -143,12 +163,10 @@ namespace RTC
...
@@ -143,12 +163,10 @@ namespace RTC
// TODO: not sure if 1 or 2 bytes or what.
// TODO: not sure if 1 or 2 bytes or what.
std
::
string
muxId
;
std
::
string
muxId
;
std
::
vector
<
RtpCodecParameters
>
codecs
;
std
::
vector
<
RtpCodecParameters
>
codecs
;
// TODO:
// std::vector<RtpHeaderExtensionParameters> headerExtensions;
std
::
vector
<
RtpEncodingParameters
>
encodings
;
std
::
vector
<
RtpEncodingParameters
>
encodings
;
std
::
vector
<
RtpHeaderExtensionParameters
>
headerExtensions
;
RtcpParameters
rtcp
;
RtcpParameters
rtcp
;
// TODO:
bool
hasRtcp
=
false
;
// DegradationPreference degradationPreference = "balanced";
};
};
}
}
...
...
worker/mediasoup-worker.gyp
浏览文件 @
2ee3ea87
...
@@ -43,14 +43,15 @@
...
@@ -43,14 +43,15 @@
'src/RTC/Transport.cpp',
'src/RTC/Transport.cpp',
'src/RTC/TransportTuple.cpp',
'src/RTC/TransportTuple.cpp',
'src/RTC/UdpSocket.cpp',
'src/RTC/UdpSocket.cpp',
'src/RTC/RtpParameters/CustomParameterValue.cpp',
'src/RTC/RtpParameters/FecCodecParameters.cpp',
'src/RTC/RtpParameters/RtcpFeedback.cpp',
'src/RTC/RtpParameters/RtcpFeedback.cpp',
'src/RTC/RtpParameters/RtcpParameters.cpp',
'src/RTC/RtpParameters/RtcpParameters.cpp',
'src/RTC/RtpParameters/RtpCodecParameters.cpp',
'src/RTC/RtpParameters/RtpCodecParameters.cpp',
'src/RTC/RtpParameters/RtpEncodingParameters.cpp',
'src/RTC/RtpParameters/RtpEncodingParameters.cpp',
'src/RTC/RtpParameters/RtpFecParameters.cpp',
'src/RTC/RtpParameters/RtpHeaderExtensionParameters.cpp',
'src/RTC/RtpParameters/RtpParameters.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/Crypto.cpp',
'src/Utils/File.cpp',
'src/Utils/File.cpp',
'src/Utils/IP.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
...
@@ -17,15 +17,15 @@ namespace RTC
static
const
Json
::
StaticString
k_reducedSize
(
"reducedSize"
);
static
const
Json
::
StaticString
k_reducedSize
(
"reducedSize"
);
if
(
!
data
.
isObject
())
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"RtcpPa`rameters` is not an object"
);
MS_THROW_ERROR
(
"`RtcpParameters` is not an object"
);
// `cname` is mandatory.
if
(
!
data
[
k_cname
].
isString
())
MS_THROW_ERROR
(
"missing `RtcpParameters.cname`"
);
// `cname` is optional.
if
(
data
[
k_cname
].
isString
())
{
this
->
cname
=
data
[
k_cname
].
asString
();
this
->
cname
=
data
[
k_cname
].
asString
();
if
(
this
->
cname
.
empty
())
if
(
this
->
cname
.
empty
())
MS_THROW_ERROR
(
"empty `RtcpParameters.cname`"
);
MS_THROW_ERROR
(
"empty `RtcpParameters.cname`"
);
}
// `ssrc` is optional.
// `ssrc` is optional.
if
(
data
[
k_ssrc
].
isUInt
())
if
(
data
[
k_ssrc
].
isUInt
())
...
@@ -52,6 +52,7 @@ namespace RTC
...
@@ -52,6 +52,7 @@ namespace RTC
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `cname`.
// Add `cname`.
if
(
!
this
->
cname
.
empty
())
json
[
k_cname
]
=
this
->
cname
;
json
[
k_cname
]
=
this
->
cname
;
// Add `ssrc`.
// Add `ssrc`.
...
...
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
浏览文件 @
2ee3ea87
...
@@ -16,9 +16,8 @@ namespace RTC
...
@@ -16,9 +16,8 @@ namespace RTC
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_clockRate
(
"clockRate"
);
static
const
Json
::
StaticString
k_maxptime
(
"maxptime"
);
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_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_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
...
@@ -47,31 +46,14 @@ namespace RTC
...
@@ -47,31 +46,14 @@ namespace RTC
if
(
data
[
k_maxptime
].
isUInt
())
if
(
data
[
k_maxptime
].
isUInt
())
this
->
maxptime
=
(
uint32_t
)
data
[
k_maxptime
].
asUInt
();
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.
// `numChannels` is optional.
if
(
data
[
k_numChannels
].
isUInt
())
if
(
data
[
k_numChannels
].
isUInt
())
this
->
numChannels
=
(
uint32_t
)
data
[
k_numChannels
].
asUInt
();
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.
// `rtcpFeedback` is optional.
if
(
data
[
k_rtcpFeedback
].
isArray
())
if
(
data
[
k_rtcpFeedback
].
isArray
())
{
{
...
@@ -102,7 +84,7 @@ namespace RTC
...
@@ -102,7 +84,7 @@ namespace RTC
{
{
bool
booleanValue
=
value
.
asBool
();
bool
booleanValue
=
value
.
asBool
();
this
->
parameters
[
key
]
=
ParameterValue
(
booleanValue
);
this
->
parameters
[
key
]
=
RTC
::
Custom
ParameterValue
(
booleanValue
);
break
;
break
;
}
}
...
@@ -112,7 +94,7 @@ namespace RTC
...
@@ -112,7 +94,7 @@ namespace RTC
{
{
uint32_t
integerValue
=
(
uint32_t
)
value
.
asUInt
();
uint32_t
integerValue
=
(
uint32_t
)
value
.
asUInt
();
this
->
parameters
[
key
]
=
ParameterValue
(
integerValue
);
this
->
parameters
[
key
]
=
RTC
::
Custom
ParameterValue
(
integerValue
);
break
;
break
;
}
}
...
@@ -121,7 +103,7 @@ namespace RTC
...
@@ -121,7 +103,7 @@ namespace RTC
{
{
std
::
string
stringValue
=
value
.
asString
();
std
::
string
stringValue
=
value
.
asString
();
this
->
parameters
[
key
]
=
ParameterValue
(
stringValue
);
this
->
parameters
[
key
]
=
RTC
::
Custom
ParameterValue
(
stringValue
);
break
;
break
;
}
}
...
@@ -146,9 +128,8 @@ namespace RTC
...
@@ -146,9 +128,8 @@ namespace RTC
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_clockRate
(
"clockRate"
);
static
const
Json
::
StaticString
k_maxptime
(
"maxptime"
);
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_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_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
...
@@ -168,35 +149,22 @@ namespace RTC
...
@@ -168,35 +149,22 @@ namespace RTC
if
(
this
->
maxptime
)
if
(
this
->
maxptime
)
json
[
k_maxptime
]
=
(
Json
::
UInt
)
this
->
maxptime
;
json
[
k_maxptime
]
=
(
Json
::
UInt
)
this
->
maxptime
;
// Add `ptime`.
if
(
this
->
ptime
)
json
[
k_ptime
]
=
(
Json
::
UInt
)
this
->
ptime
;
// Add `numChannels`.
// Add `numChannels`.
if
(
this
->
numChannels
)
if
(
this
->
numChannels
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
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).
// Add `rtcpFeedback` (if any).
if
(
!
this
->
rtcpFeedback
.
empty
())
if
(
!
this
->
rtcpFeedback
.
empty
())
{
{
json
[
k_rtcpFeedback
]
=
Json
::
arrayValue
;
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
...
@@ -208,19 +176,19 @@ namespace RTC
for
(
auto
&
kv
:
this
->
parameters
)
for
(
auto
&
kv
:
this
->
parameters
)
{
{
const
std
::
string
&
key
=
kv
.
first
;
const
std
::
string
&
key
=
kv
.
first
;
ParameterValue
&
parameterValue
=
kv
.
second
;
RTC
::
Custom
ParameterValue
&
parameterValue
=
kv
.
second
;
switch
(
parameterValue
.
type
)
switch
(
parameterValue
.
type
)
{
{
case
ParameterValue
:
:
Type
::
BOOLEAN
:
case
RTC
:
:
Custom
ParameterValue
::
Type
::
BOOLEAN
:
json_parameters
[
key
]
=
parameterValue
.
booleanValue
;
json_parameters
[
key
]
=
parameterValue
.
booleanValue
;
break
;
break
;
case
ParameterValue
:
:
Type
::
INTEGER
:
case
RTC
:
:
Custom
ParameterValue
::
Type
::
INTEGER
:
json_parameters
[
key
]
=
(
Json
::
UInt
)
parameterValue
.
integerValue
;
json_parameters
[
key
]
=
(
Json
::
UInt
)
parameterValue
.
integerValue
;
break
;
break
;
case
ParameterValue
:
:
Type
::
STRING
:
case
RTC
:
:
Custom
ParameterValue
::
Type
::
STRING
:
json_parameters
[
key
]
=
parameterValue
.
stringValue
;
json_parameters
[
key
]
=
parameterValue
.
stringValue
;
break
;
break
;
}
}
...
@@ -231,30 +199,4 @@ namespace RTC
...
@@ -231,30 +199,4 @@ namespace RTC
return
json
;
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
...
@@ -13,30 +13,75 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
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_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
())
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"`RtpEncodingParameters is not an object"
);
MS_THROW_ERROR
(
"`RtpEncodingParameters is not an object"
);
// `
ssrc` is mandatory
.
// `
codecPayloadType` is optional
.
if
(
!
data
[
k_ssrc
].
isUInt
())
if
(
data
[
k_codecPayloadType
].
isUInt
())
MS_THROW_ERROR
(
"missing `RtpEncodingParameters.ssrc`"
);
this
->
codecPayloadType
=
(
uint8_t
)
data
[
k_codecPayloadType
].
asUInt
(
);
// `ssrc` is optional.
if
(
data
[
k_ssrc
].
isUInt
())
this
->
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
this
->
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
// `rtxSsrc` is optional.
// `fec` is optional.
if
(
data
[
k_rtxSsrc
].
isUInt
())
if
(
data
[
k_fec
].
isObject
())
this
->
rtxSsrc
=
(
uint32_t
)
data
[
k_rtxSsrc
].
asUInt
();
{
this
->
fec
=
RtpFecParameters
(
data
[
k_fec
]);
this
->
hasFec
=
true
;
}
// `fecSsrc` is optional.
// `rtx` is optional.
if
(
data
[
k_fecSsrc
].
isUInt
())
if
(
data
[
k_rtx
].
isObject
())
this
->
fecSsrc
=
(
uint32_t
)
data
[
k_fecSsrc
].
asUInt
();
{
this
->
rtx
=
RtpRtxParameters
(
data
[
k_rtx
]);
this
->
hasRtx
=
true
;
}
// `codecPayloadType` is optional.
// `resolutionScale` is optional.
if
(
data
[
k_codecPayloadType
].
isUInt
())
if
(
data
[
k_resolutionScale
].
isDouble
())
this
->
codecPayloadType
=
(
uint8_t
)
data
[
k_codecPayloadType
].
asUInt
();
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
()
RtpEncodingParameters
::~
RtpEncodingParameters
()
...
@@ -49,26 +94,63 @@ namespace RTC
...
@@ -49,26 +94,63 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
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_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
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `codecPayloadType`.
if
(
this
->
codecPayloadType
)
json
[
k_codecPayloadType
]
=
(
Json
::
UInt
)
this
->
codecPayloadType
;
// Add `ssrc`.
// Add `ssrc`.
if
(
this
->
ssrc
)
json
[
k_ssrc
]
=
(
Json
::
UInt
)
this
->
ssrc
;
json
[
k_ssrc
]
=
(
Json
::
UInt
)
this
->
ssrc
;
// Add `
rtxSsrc`.
// Add `
fec`
if
(
this
->
rtxSsr
c
)
if
(
this
->
hasFe
c
)
json
[
k_
rtxSsrc
]
=
(
Json
::
UInt
)
this
->
rtxSsrc
;
json
[
k_
fec
]
=
this
->
fec
.
toJson
()
;
// Add `
fecSsrc`.
// Add `
rtx`
if
(
this
->
fecSsrc
)
if
(
this
->
hasRtx
)
json
[
k_
fecSsrc
]
=
(
Json
::
UInt
)
this
->
fecSsrc
;
json
[
k_
rtx
]
=
this
->
rtx
.
toJson
()
;
// Add `codecPayloadType`.
// Add `resolutionScale` (if different than the default value).
if
(
this
->
codecPayloadType
)
if
(
this
->
resolutionScale
!=
1.0
)
json
[
k_codecPayloadType
]
=
(
Json
::
UInt
)
this
->
codecPayloadType
;
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
;
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 "RTC/RtpParameters.h"
#include "MediaSoupError.h"
#include "MediaSoupError.h"
...
@@ -8,47 +8,47 @@ namespace RTC
...
@@ -8,47 +8,47 @@ namespace RTC
{
{
/* Instance methods. */
/* Instance methods. */
FecCodecParameters
::
FecCod
ecParameters
(
Json
::
Value
&
data
)
RtpFecParameters
::
RtpF
ecParameters
(
Json
::
Value
&
data
)
{
{
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
static
const
Json
::
StaticString
k_mechanism
(
"mechanism"
);
static
const
Json
::
StaticString
k_mechanism
(
"mechanism"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
if
(
!
data
.
isObject
())
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"`
FecCodecParameters`
is not an object"
);
MS_THROW_ERROR
(
"`
RtpFecParameters
is not an object"
);
// `mechanism` is mandatory.
// `mechanism` is mandatory.
if
(
!
data
[
k_mechanism
].
isString
())
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
();
this
->
mechanism
=
data
[
k_mechanism
].
asString
();
// `
payloadType
` is optional.
// `
ssrc
` is optional.
if
(
data
[
k_
payloadType
].
isUInt
())
if
(
data
[
k_
ssrc
].
isUInt
())
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
this
->
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
}
}
FecCodecParameters
::~
FecCod
ecParameters
()
RtpFecParameters
::~
RtpF
ecParameters
()
{
{
MS_TRACE
();
MS_TRACE
();
}
}
Json
::
Value
FecCod
ecParameters
::
toJson
()
Json
::
Value
RtpF
ecParameters
::
toJson
()
{
{
MS_TRACE
();
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
static
const
Json
::
StaticString
k_mechanism
(
"mechanism"
);
static
const
Json
::
StaticString
k_mechanism
(
"mechanism"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `mechanism`.
// Add `mechanism`.
json
[
k_mechanism
]
=
this
->
mechanism
;
json
[
k_mechanism
]
=
this
->
mechanism
;
// Add `
payloadType
`.
// Add `
ssrc
`.
if
(
this
->
payloadType
)
if
(
this
->
ssrc
)
json
[
k_
payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
json
[
k_
ssrc
]
=
(
Json
::
UInt
)
this
->
ssrc
;
return
json
;
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
...
@@ -15,13 +15,12 @@ namespace RTC
static
const
Json
::
StaticString
k_muxId
(
"muxId"
);
static
const
Json
::
StaticString
k_muxId
(
"muxId"
);
static
const
Json
::
StaticString
k_codecs
(
"codecs"
);
static
const
Json
::
StaticString
k_codecs
(
"codecs"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_headerExtensions
(
"headerExtensions"
);
static
const
Json
::
StaticString
k_rtcp
(
"rtcp"
);
static
const
Json
::
StaticString
k_rtcp
(
"rtcp"
);
// `muxId` is optional.
// `muxId` is optional.
if
(
data
[
k_muxId
].
isString
())
if
(
data
[
k_muxId
].
isString
())
{
this
->
muxId
=
data
[
k_muxId
].
asString
();
this
->
muxId
=
data
[
k_muxId
].
asString
();
}
// `codecs` is mandatory.
// `codecs` is mandatory.
if
(
data
[
k_codecs
].
isArray
())
if
(
data
[
k_codecs
].
isArray
())
...
@@ -38,35 +37,42 @@ namespace RTC
...
@@ -38,35 +37,42 @@ namespace RTC
}
}
else
else
{
{
MS_THROW_ERROR
(
"missing `codecs`"
);
MS_THROW_ERROR
(
"missing `
RtpCodecParameters.
codecs`"
);
}
}
// `encodings` is
mandatory
.
// `encodings` is
optional
.
if
(
data
[
k_encodings
].
isArray
())
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.
// Append to the encodings vector.
this
->
encodings
.
push_back
(
encoding
);
this
->
encodings
.
push_back
(
encoding
);
}
}
}
}
else
// `headerExtensions` is optional.
if
(
data
[
k_headerExtensions
].
isArray
())
{
auto
&
json_array
=
data
[
k_headerExtensions
];
for
(
Json
::
UInt
i
=
0
;
i
<
json_array
.
size
();
i
++
)
{
{
MS_THROW_ERROR
(
"missing `encodings`"
);
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
())
if
(
data
[
k_rtcp
].
isObject
())
{
{
this
->
rtcp
=
RtcpParameters
(
data
[
k_rtcp
]);
this
->
rtcp
=
RtcpParameters
(
data
[
k_rtcp
]);
}
this
->
hasRtcp
=
true
;
else
{
MS_THROW_ERROR
(
"missing `rtcp`"
);
}
}
}
}
...
@@ -92,32 +98,50 @@ namespace RTC
...
@@ -92,32 +98,50 @@ namespace RTC
static
const
Json
::
StaticString
k_muxId
(
"muxId"
);
static
const
Json
::
StaticString
k_muxId
(
"muxId"
);
static
const
Json
::
StaticString
k_codecs
(
"codecs"
);
static
const
Json
::
StaticString
k_codecs
(
"codecs"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_headerExtensions
(
"headerExtensions"
);
static
const
Json
::
StaticString
k_rtcp
(
"rtcp"
);
static
const
Json
::
StaticString
k_rtcp
(
"rtcp"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `muxId`.
// Add `muxId`.
if
(
!
this
->
muxId
.
empty
())
json
[
k_muxId
]
=
this
->
muxId
;
json
[
k_muxId
]
=
this
->
muxId
;
// Add `codecs`.
// Add `codecs`.
json
[
k_codecs
]
=
Json
::
arrayValue
;
if
(
!
this
->
codecs
.
empty
())
for
(
auto
it
=
this
->
codecs
.
begin
();
it
!=
this
->
codecs
.
end
();
++
it
)
{
{
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`.
// Add `encodings`.
if
(
!
this
->
encodings
.
empty
())
{
json
[
k_encodings
]
=
Json
::
arrayValue
;
json
[
k_encodings
]
=
Json
::
arrayValue
;
for
(
auto
it
=
this
->
encodings
.
begin
();
it
!=
this
->
encodings
.
end
();
++
it
)
for
(
auto
&
entry
:
this
->
encodings
)
{
{
RtpEncodingParameters
*
encoding
=
std
::
addressof
(
*
it
);
json
[
k_encodings
].
append
(
entry
.
toJson
());
}
}
// Add `headerExtensions`.
if
(
!
this
->
headerExtensions
.
empty
())
{
json
[
k_headerExtensions
]
=
Json
::
arrayValue
;
json
[
k_encodings
].
append
(
encoding
->
toJson
());
for
(
auto
&
entry
:
this
->
headerExtensions
)
{
json
[
k_headerExtensions
].
append
(
entry
.
toJson
());
}
}
}
// Add `rtcp`.
// Add `rtcp`.
if
(
this
->
hasRtcp
)
json
[
k_rtcp
]
=
this
->
rtcp
.
toJson
();
json
[
k_rtcp
]
=
this
->
rtcp
.
toJson
();
return
json
;
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论