Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
076a21db
提交
076a21db
authored
2月 29, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split RTC::RtpParameters into different classes and source files.
上级
b9e5b396
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
198 行增加
和
138 行删除
+198
-138
RtpParameters.h
worker/include/RTC/RtpParameters.h
+31
-24
RtpParameters.cpp
worker/src/RTC/RtpParameters.cpp
+18
-114
RtpCodecParameters.cpp
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
+104
-0
RtpEncodingParameters.cpp
worker/src/RTC/RtpParameters/RtpEncodingParameters.cpp
+45
-0
没有找到文件。
worker/include/RTC/RtpParameters.h
浏览文件 @
076a21db
...
@@ -8,8 +8,28 @@
...
@@ -8,8 +8,28 @@
namespace
RTC
namespace
RTC
{
{
// Lazy declarations.
class
RtpCodecParameters
;
class
RtpEncodingParameters
;
class
RtpParameters
class
RtpParameters
{
{
public
:
RtpParameters
(
Json
::
Value
&
data
);
RtpParameters
(
const
RtpParameters
*
RtpParameters
);
virtual
~
RtpParameters
();
Json
::
Value
toJson
();
public
:
// TODO: not sure if 1 or 2 bytes or what.
std
::
string
muxId
=
""
;
std
::
vector
<
RtpCodecParameters
>
codecs
;
std
::
vector
<
RtpEncodingParameters
>
encodings
;
};
class
RtpCodecParameters
{
public
:
public
:
enum
class
Kind
enum
class
Kind
{
{
...
@@ -19,43 +39,30 @@ namespace RTC
...
@@ -19,43 +39,30 @@ namespace RTC
};
};
public
:
public
:
struct
CodecParameters
RtpCodecParameters
(
Json
::
Value
&
data
);
{
virtual
~
RtpCodecParameters
();
Json
::
Value
toJson
();
public
:
std
::
string
name
;
std
::
string
name
;
Kind
kind
=
Kind
::
BOTH
;
Kind
kind
=
Kind
::
BOTH
;
uint8_t
payloadType
;
uint8_t
payloadType
=
0
;
uint32_t
clockRate
=
0
;
uint32_t
clockRate
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
maxptime
=
0
;
uint32_t
numChannels
=
0
;
uint32_t
numChannels
=
0
;
// sequence<RTCRtcpFeedback> rtcpFeedback;
// Dictionary parameters;
};
};
public
:
class
RtpEncodingParameters
struct
EncodingParameters
{
{
uint32_t
ssrc
=
0
;
uint8_t
codecPayloadType
=
0
;
// [...]
};
public
:
public
:
RtpParameters
(
Json
::
Value
&
data
);
RtpEncodingParameters
(
Json
::
Value
&
data
);
RtpParameters
(
const
RtpParameters
*
RtpParameters
);
virtual
~
RtpEncodingParameters
();
virtual
~
RtpParameters
();
Json
::
Value
toJson
();
Json
::
Value
toJson
();
private
:
void
AddCodec
(
Json
::
Value
&
data
);
void
AddEncoding
(
Json
::
Value
&
data
);
public
:
public
:
// TODO: not sure if 1 or 2 bytes or what...
uint32_t
ssrc
=
0
;
std
::
string
muxId
=
""
;
std
::
vector
<
CodecParameters
>
codecs
;
std
::
vector
<
EncodingParameters
>
encodings
;
// TODO: more fields missing
};
};
}
}
...
...
worker/src/RTC/RtpParameters.cpp
浏览文件 @
076a21db
...
@@ -25,10 +25,15 @@ namespace RTC
...
@@ -25,10 +25,15 @@ namespace RTC
// `codecs` is mandatory.
// `codecs` is mandatory.
if
(
data
[
k_codecs
].
isArray
())
if
(
data
[
k_codecs
].
isArray
())
{
{
auto
json_codecs
=
data
[
k_codecs
];
auto
&
json_codecs
=
data
[
k_codecs
];
for
(
Json
::
UInt
i
=
0
;
i
<
json_codecs
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_codecs
.
size
();
i
++
)
AddCodec
(
json_codecs
[
i
]);
{
RtpCodecParameters
codec
(
json_codecs
[
i
]);
// Append to the codecs vector.
this
->
codecs
.
push_back
(
codec
);
}
}
}
else
else
{
{
...
@@ -38,10 +43,15 @@ namespace RTC
...
@@ -38,10 +43,15 @@ namespace RTC
// `encodings` is mandatory.
// `encodings` is mandatory.
if
(
data
[
k_encodings
].
isArray
())
if
(
data
[
k_encodings
].
isArray
())
{
{
auto
json_encodings
=
data
[
k_encodings
];
auto
&
json_encodings
=
data
[
k_encodings
];
for
(
Json
::
UInt
i
=
0
;
i
<
json_encodings
.
size
();
i
++
)
for
(
Json
::
UInt
i
=
0
;
i
<
json_encodings
.
size
();
i
++
)
AddEncoding
(
json_encodings
[
i
]);
{
RtpEncodingParameters
encoding
(
json_encodings
[
i
]);
// Append to the encodings vector.
this
->
encodings
.
push_back
(
encoding
);
}
}
}
else
else
{
{
...
@@ -69,15 +79,7 @@ namespace RTC
...
@@ -69,15 +79,7 @@ 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_name
(
"name"
);
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
v_both
(
""
);
static
const
Json
::
StaticString
v_audio
(
"audio"
);
static
const
Json
::
StaticString
v_video
(
"video"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_clockRate
(
"clockRate"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_encodings
(
"encodings"
);
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
(
Json
::
objectValue
);
...
@@ -88,118 +90,20 @@ namespace RTC
...
@@ -88,118 +90,20 @@ namespace RTC
json
[
k_codecs
]
=
Json
::
arrayValue
;
json
[
k_codecs
]
=
Json
::
arrayValue
;
for
(
auto
it
=
this
->
codecs
.
begin
();
it
!=
this
->
codecs
.
end
();
++
it
)
for
(
auto
it
=
this
->
codecs
.
begin
();
it
!=
this
->
codecs
.
end
();
++
it
)
{
{
CodecParameters
*
codec
=
std
::
addressof
(
*
it
);
RtpCodecParameters
*
codec
=
std
::
addressof
(
*
it
);
Json
::
Value
json_codec
;
json_codec
[
k_name
]
=
codec
->
name
;
json
[
k_codecs
].
append
(
codec
->
toJson
());
switch
(
codec
->
kind
)
{
case
Kind
:
:
BOTH
:
json_codec
[
k_kind
]
=
v_both
;
break
;
case
Kind
:
:
AUDIO
:
json_codec
[
k_kind
]
=
v_audio
;
break
;
case
Kind
:
:
VIDEO
:
json_codec
[
k_kind
]
=
v_video
;
break
;
}
json_codec
[
k_payloadType
]
=
(
Json
::
UInt
)
codec
->
payloadType
;
if
(
codec
->
clockRate
)
json_codec
[
k_clockRate
]
=
(
Json
::
UInt
)
codec
->
clockRate
;
else
json_codec
[
k_clockRate
]
=
Json
::
nullValue
;
json
[
k_codecs
].
append
(
json_codec
);
}
}
// Add `encodings`.
// Add `encodings`.
json
[
k_encodings
]
=
Json
::
arrayValue
;
json
[
k_encodings
]
=
Json
::
arrayValue
;
for
(
auto
it
=
this
->
encodings
.
begin
();
it
!=
this
->
encodings
.
end
();
++
it
)
for
(
auto
it
=
this
->
encodings
.
begin
();
it
!=
this
->
encodings
.
end
();
++
it
)
{
{
EncodingParameters
*
encoding
=
std
::
addressof
(
*
it
);
RtpEncodingParameters
*
encoding
=
std
::
addressof
(
*
it
);
Json
::
Value
json_encoding
;
json_encoding
[
k_ssrc
]
=
(
Json
::
UInt
)
encoding
->
ssrc
;
json
[
k_encodings
].
append
(
json_encoding
);
json
[
k_encodings
].
append
(
encoding
->
toJson
()
);
}
}
return
json
;
return
json
;
}
}
void
RtpParameters
::
AddCodec
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_name
(
"name"
);
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_clockRate
(
"clockRate"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"data is not an object"
);
struct
CodecParameters
codec
;
// `name` is mandatory.
if
(
!
data
[
k_name
].
isString
())
MS_THROW_ERROR
(
"missing `name`"
);
codec
.
name
=
data
[
k_name
].
asString
();
if
(
codec
.
name
.
empty
())
MS_THROW_ERROR
(
"empty `name`"
);
// `kind` is optional.
if
(
data
[
k_kind
].
isString
())
{
std
::
string
kind
=
data
[
k_kind
].
asString
();
if
(
kind
==
"audio"
)
codec
.
kind
=
Kind
::
AUDIO
;
else
if
(
kind
==
"video"
)
codec
.
kind
=
Kind
::
VIDEO
;
else
if
(
kind
.
empty
())
codec
.
kind
=
Kind
::
BOTH
;
else
MS_THROW_ERROR
(
"invalid `kind`"
);
}
// `payloadType` is mandatory.
if
(
!
data
[
k_payloadType
].
isUInt
())
MS_THROW_ERROR
(
"missing `payloadType`"
);
codec
.
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
// `clockRate` is optional.
if
(
data
[
k_clockRate
].
isUInt
())
codec
.
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
// Append to the codecs vector.
this
->
codecs
.
push_back
(
codec
);
}
void
RtpParameters
::
AddEncoding
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"data is not an object"
);
struct
EncodingParameters
encoding
;
// `ssrc` is mandatory.
if
(
!
data
[
k_ssrc
].
isUInt
())
MS_THROW_ERROR
(
"missing `ssrc`"
);
encoding
.
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
// Append to the encodings vector.
this
->
encodings
.
push_back
(
encoding
);
}
}
}
worker/src/RTC/RtpParameters/RtpCodecParameters.cpp
0 → 100644
浏览文件 @
076a21db
#define MS_CLASS "RTC::RtpCodecParameters"
#include "RTC/RtpParameters.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtpCodecParameters
::
RtpCodecParameters
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_name
(
"name"
);
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_clockRate
(
"clockRate"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"data is not an object"
);
// `name` is mandatory.
if
(
!
data
[
k_name
].
isString
())
MS_THROW_ERROR
(
"missing `codec.name`"
);
this
->
name
=
data
[
k_name
].
asString
();
if
(
this
->
name
.
empty
())
MS_THROW_ERROR
(
"empty `codec.name`"
);
// `kind` is optional.
if
(
data
[
k_kind
].
isString
())
{
std
::
string
kind
=
data
[
k_kind
].
asString
();
if
(
kind
==
"audio"
)
this
->
kind
=
Kind
::
AUDIO
;
else
if
(
kind
==
"video"
)
this
->
kind
=
Kind
::
VIDEO
;
else
if
(
kind
.
empty
())
this
->
kind
=
Kind
::
BOTH
;
else
MS_THROW_ERROR
(
"invalid `codec.kind`"
);
}
// `payloadType` is mandatory.
if
(
!
data
[
k_payloadType
].
isUInt
())
MS_THROW_ERROR
(
"missing `codec.payloadType`"
);
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
// `clockRate` is optional.
if
(
data
[
k_clockRate
].
isUInt
())
this
->
clockRate
=
(
uint32_t
)
data
[
k_clockRate
].
asUInt
();
}
RtpCodecParameters
::~
RtpCodecParameters
()
{
MS_TRACE
();
}
Json
::
Value
RtpCodecParameters
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_name
(
"name"
);
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
v_both
(
""
);
static
const
Json
::
StaticString
v_audio
(
"audio"
);
static
const
Json
::
StaticString
v_video
(
"video"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_clockRate
(
"clockRate"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `name`.
json
[
k_name
]
=
this
->
name
;
// Add `kind`.
switch
(
this
->
kind
)
{
case
Kind
:
:
BOTH
:
json
[
k_kind
]
=
v_both
;
break
;
case
Kind
:
:
AUDIO
:
json
[
k_kind
]
=
v_audio
;
break
;
case
Kind
:
:
VIDEO
:
json
[
k_kind
]
=
v_video
;
break
;
}
// Add `payloadType`.
json
[
k_payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
// Add `clockRate`.
if
(
this
->
clockRate
)
json
[
k_clockRate
]
=
(
Json
::
UInt
)
this
->
clockRate
;
else
json
[
k_clockRate
]
=
Json
::
nullValue
;
return
json
;
}
}
worker/src/RTC/RtpParameters/RtpEncodingParameters.cpp
0 → 100644
浏览文件 @
076a21db
#define MS_CLASS "RTC::RtpEncodingParameters"
#include "RTC/RtpParameters.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtpEncodingParameters
::
RtpEncodingParameters
(
Json
::
Value
&
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
if
(
!
data
.
isObject
())
MS_THROW_ERROR
(
"data is not an object"
);
// `ssrc` is mandatory.
if
(
!
data
[
k_ssrc
].
isUInt
())
MS_THROW_ERROR
(
"missing `encoding.ssrc`"
);
this
->
ssrc
=
(
uint32_t
)
data
[
k_ssrc
].
asUInt
();
}
RtpEncodingParameters
::~
RtpEncodingParameters
()
{
MS_TRACE
();
}
Json
::
Value
RtpEncodingParameters
::
toJson
()
{
MS_TRACE
();
static
const
Json
::
StaticString
k_ssrc
(
"ssrc"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `ssrc`.
json
[
k_ssrc
]
=
this
->
ssrc
;
return
json
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论