Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
966cabd1
提交
966cabd1
authored
6月 17, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify codecs
上级
74e30699
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
136 行增加
和
156 行删除
+136
-156
Room.h
worker/include/RTC/Room.h
+1
-1
RtpDictionaries.h
worker/include/RTC/RtpDictionaries.h
+9
-13
mediasoup-worker.gyp
worker/mediasoup-worker.gyp
+0
-1
Room.cpp
worker/src/RTC/Room.cpp
+19
-19
RtpCodec.cpp
worker/src/RTC/RtpDictionaries/RtpCodec.cpp
+32
-1
RtpCodecCapability.cpp
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
+6
-30
RtpCodecParameters.cpp
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
+68
-57
RtpParameters.cpp
worker/src/RTC/RtpDictionaries/RtpParameters.cpp
+1
-1
RtpRoomMediaCodec.cpp
worker/src/RTC/RtpDictionaries/RtpRoomMediaCodec.cpp
+0
-33
没有找到文件。
worker/include/RTC/Room.h
浏览文件 @
966cabd1
...
...
@@ -44,7 +44,7 @@ namespace RTC
private
:
RTC
::
Peer
*
GetPeerFromRequest
(
Channel
::
Request
*
request
,
uint32_t
*
peerId
=
nullptr
);
void
SetRtpCapabilities
(
std
::
vector
<
RTC
::
Rtp
RoomMediaCodec
>&
roomM
ediaCodecs
);
void
SetRtpCapabilities
(
std
::
vector
<
RTC
::
Rtp
CodecParameters
>&
m
ediaCodecs
);
/* Pure virtual methods inherited from RTC::Peer::Listener. */
public
:
...
...
worker/include/RTC/RtpDictionaries.h
浏览文件 @
966cabd1
...
...
@@ -114,6 +114,8 @@ namespace RTC
RtpCodec
()
{};
RtpCodec
(
Json
::
Value
&
data
);
void
toJson
(
Json
::
Value
&
json
);
public
:
RtpCodecMime
mime
;
uint32_t
clockRate
=
0
;
...
...
@@ -152,11 +154,15 @@ namespace RTC
public
RtpCodec
{
public
:
RtpCodecParameters
(
Json
::
Value
&
data
);
RtpCodecParameters
(
Json
::
Value
&
data
,
bool
isRoomCodec
);
Json
::
Value
toJson
();
private
:
bool
isRoomCodec
=
false
;
public
:
Media
::
Kind
kind
=
Media
::
Kind
::
ALL
;
uint8_t
payloadType
=
0
;
RTCRtpCodecRtxParameters
rtx
;
bool
hasRtx
=
false
;
...
...
@@ -270,8 +276,8 @@ namespace RTC
RtpCodecCapability
(
Json
::
Value
&
data
);
Json
::
Value
toJson
();
bool
MatchesCodec
(
RtpCodec
&
codec
);
void
Reduce
(
RtpCodec
&
codec
);
bool
MatchesCodec
(
RtpCodec
Parameters
&
codec
);
void
Reduce
(
RtpCodec
Parameters
&
codec
);
public
:
Media
::
Kind
kind
=
Media
::
Kind
::
ALL
;
...
...
@@ -312,16 +318,6 @@ namespace RTC
std
::
vector
<
RtpHeaderExtension
>
headerExtensions
;
std
::
vector
<
std
::
string
>
fecMechanisms
;
};
class
RtpRoomMediaCodec
:
public
RtpCodec
{
public
:
RtpRoomMediaCodec
(
Json
::
Value
&
data
);
public
:
Media
::
Kind
kind
=
Media
::
Kind
::
ALL
;
};
}
#endif
worker/mediasoup-worker.gyp
浏览文件 @
966cabd1
...
...
@@ -58,7 +58,6 @@
'src/RTC/RtpDictionaries/RtpHeaderExtension.cpp',
'src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp',
'src/RTC/RtpDictionaries/RtpParameters.cpp',
'src/RTC/RtpDictionaries/RtpRoomMediaCodec.cpp',
'src/RTC/RtpDictionaries/RtpRtxParameters.cpp',
'src/Utils/Crypto.cpp',
'src/Utils/File.cpp',
...
...
worker/src/RTC/Room.cpp
浏览文件 @
966cabd1
...
...
@@ -67,24 +67,24 @@ namespace RTC
static
const
Json
::
StaticString
k_mediaCodecs
(
"mediaCodecs"
);
// `mediaCodecs` is mandatory.
if
(
!
data
[
k_mediaCodecs
].
isArray
())
MS_THROW_ERROR
(
"missing mediaCodecs"
);
// `mediaCodecs` is optional.
if
(
data
[
k_mediaCodecs
].
isArray
())
{
auto
&
json_mediaCodecs
=
data
[
k_mediaCodecs
];
auto
&
json_mediaCodecs
=
data
[
k_mediaCodecs
]
;
std
::
vector
<
RTC
::
RtpCodecParameters
>
mediaCodecs
;
std
::
vector
<
RtpRoomMediaCodec
>
mediaCodecs
;
for
(
Json
::
UInt
i
=
0
;
i
<
json_mediaCodecs
.
size
();
i
++
)
{
RTC
::
RtpCodecParameters
mediaCodec
(
json_mediaCodecs
[
i
],
true
);
for
(
Json
::
UInt
i
=
0
;
i
<
json_mediaCodecs
.
size
();
i
++
)
{
RTC
::
RtpRoomMediaCodec
mediaCodec
(
json_mediaCodecs
[
i
]);
mediaCodecs
.
push_back
(
mediaCodec
);
}
mediaCodecs
.
push_back
(
mediaCodec
);
// Set room RTP capabilities.
// NOTE: This may throw.
SetRtpCapabilities
(
mediaCodecs
);
}
// Set room RTP capabilities.
// NOTE: This may throw.
SetRtpCapabilities
(
mediaCodecs
);
}
Room
::~
Room
()
...
...
@@ -350,7 +350,7 @@ namespace RTC
}
}
void
Room
::
SetRtpCapabilities
(
std
::
vector
<
RTC
::
Rtp
RoomMediaCodec
>&
roomM
ediaCodecs
)
void
Room
::
SetRtpCapabilities
(
std
::
vector
<
RTC
::
Rtp
CodecParameters
>&
m
ediaCodecs
)
{
MS_TRACE
();
...
...
@@ -380,12 +380,12 @@ namespace RTC
std
::
set
<
RTC
::
Media
::
Kind
>
roomKinds
;
// Set the given room codecs.
for
(
auto
&
roomMediaCodec
:
roomM
ediaCodecs
)
for
(
auto
&
mediaCodec
:
m
ediaCodecs
)
{
RTC
::
RtpCodecCapability
codecCapability
;
// The room has this kind.
roomKinds
.
insert
(
roomM
ediaCodec
.
kind
);
roomKinds
.
insert
(
m
ediaCodec
.
kind
);
// Search the given codec in the list of supported codec capabilities.
...
...
@@ -396,11 +396,11 @@ namespace RTC
auto
&
supportedCodecCapability
=
*
it
;
// Kind must match.
if
(
roomM
ediaCodec
.
kind
!=
supportedCodecCapability
.
kind
)
if
(
m
ediaCodec
.
kind
!=
supportedCodecCapability
.
kind
)
continue
;
// Check whether the codec capability matches the given codec.
if
(
supportedCodecCapability
.
MatchesCodec
(
roomM
ediaCodec
))
if
(
supportedCodecCapability
.
MatchesCodec
(
m
ediaCodec
))
{
// Deep copy.
codecCapability
=
supportedCodecCapability
;
...
...
@@ -412,7 +412,7 @@ namespace RTC
MS_THROW_ERROR
(
"no matching codec capability found"
);
// Reduce the capabilities of the matching capability codec.
codecCapability
.
Reduce
(
roomM
ediaCodec
);
codecCapability
.
Reduce
(
m
ediaCodec
);
// Set unique PT.
...
...
worker/src/RTC/RtpDictionaries/RtpCodec.cpp
浏览文件 @
966cabd1
...
...
@@ -53,7 +53,38 @@ namespace RTC
// `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
;
// TODO: Check per MIME parameters and set default values.
// Add `parameters`.
json
[
k_parameters
]
=
this
->
parameters
.
toJson
();
}
}
worker/src/RTC/RtpDictionaries/RtpCodecCapability.cpp
浏览文件 @
966cabd1
...
...
@@ -65,7 +65,7 @@ namespace RTC
if
(
data
[
k_svcMultiStreamSupport
].
isBool
())
this
->
svcMultiStreamSupport
=
data
[
k_svcMultiStreamSupport
].
asBool
();
// TODO: Check per MIME parameters
and set default values
.
// TODO: Check per MIME parameters.
}
Json
::
Value
RtpCodecCapability
::
toJson
()
...
...
@@ -73,44 +73,23 @@ namespace RTC
MS_TRACE
();
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_name
(
"name"
);
static
const
Json
::
StaticString
k_preferredPayloadType
(
"preferredPayloadType"
);
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_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
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 `name`.
json
[
k_name
]
=
this
->
mime
.
GetName
();
// Add `preferredPayloadType`.
json
[
k_preferredPayloadType
]
=
(
Json
::
UInt
)
this
->
preferredPayloadType
;
// 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 `rtcpFeedback`.
json
[
k_rtcpFeedback
]
=
Json
::
arrayValue
;
...
...
@@ -119,9 +98,6 @@ namespace RTC
json
[
k_rtcpFeedback
].
append
(
entry
.
toJson
());
}
// Add `parameters`.
json
[
k_parameters
]
=
this
->
parameters
.
toJson
();
// Add `maxTemporalLayers` (if set).
if
(
this
->
maxTemporalLayers
)
json
[
k_maxTemporalLayers
]
=
(
Json
::
UInt
)
this
->
maxTemporalLayers
;
...
...
@@ -137,7 +113,7 @@ namespace RTC
return
json
;
}
bool
RtpCodecCapability
::
MatchesCodec
(
RtpCodec
&
codec
)
bool
RtpCodecCapability
::
MatchesCodec
(
RtpCodec
Parameters
&
codec
)
{
MS_TRACE
();
...
...
@@ -179,7 +155,7 @@ namespace RTC
// NOTE: This method assumes that MatchesCodec() has been called before
// with same codec and returned true.
void
RtpCodecCapability
::
Reduce
(
RtpCodec
&
codec
)
void
RtpCodecCapability
::
Reduce
(
RtpCodec
Parameters
&
codec
)
{
MS_TRACE
();
...
...
worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp
浏览文件 @
966cabd1
...
...
@@ -8,96 +8,107 @@ namespace RTC
{
/* Instance methods. */
RtpCodecParameters
::
RtpCodecParameters
(
Json
::
Value
&
data
)
:
RtpCodec
(
data
)
RtpCodecParameters
::
RtpCodecParameters
(
Json
::
Value
&
data
,
bool
isRoomCodec
)
:
RtpCodec
(
data
),
isRoomCodec
(
isRoomCodec
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_kind
(
"kind"
);
static
const
Json
::
StaticString
k_payloadType
(
"payloadType"
);
static
const
Json
::
StaticString
k_rtx
(
"rtx"
);
static
const
Json
::
StaticString
k_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
// `payloadType` is mandatory.
if
(
!
data
[
k_payloadType
].
isUInt
())
MS_THROW_ERROR
(
"missing RtpCodecParameters.payloadType"
);
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
// `rtx` is optional.
if
(
data
[
k_rtx
].
isObject
())
// Not a room codec.
if
(
!
this
->
isRoomCodec
)
{
this
->
rtx
=
RTCRtpCodecRtxParameters
(
data
[
k_rtx
]);
this
->
hasRtx
=
true
;
}
// `payloadType` is mandatory.
if
(
!
data
[
k_payloadType
].
isUInt
())
MS_THROW_ERROR
(
"missing RtpCodecParameters.payloadType"
);
// `rtcpFeedback` is optional.
if
(
data
[
k_rtcpFeedback
].
isArray
())
{
auto
&
json_rtcpFeedback
=
data
[
k_rtcpFeedback
];
this
->
payloadType
=
(
uint8_t
)
data
[
k_payloadType
].
asUInt
();
// `rtx` is optional.
if
(
data
[
k_rtx
].
isObject
())
{
this
->
rtx
=
RTCRtpCodecRtxParameters
(
data
[
k_rtx
]);
this
->
hasRtx
=
true
;
}
for
(
Json
::
UInt
i
=
0
;
i
<
json_rtcpFeedback
.
size
();
i
++
)
// `rtcpFeedback` is optional.
if
(
data
[
k_rtcpFeedback
].
isArray
())
{
RtcpFeedback
rtcpFeedback
(
json_rtcpFeedback
[
i
]);
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
);
// Append to the rtcpFeedback vector.
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"
);
}
// TODO: Check per MIME parameters and set default values.
// For example, H264 default packetizationMode is 0.
}
Json
::
Value
RtpCodecParameters
::
toJson
()
{
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"
);
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_rtcpFeedback
(
"rtcpFeedback"
);
static
const
Json
::
StaticString
k_parameters
(
"parameters"
);
Json
::
Value
json
(
Json
::
objectValue
);
// Add `name`.
json
[
k_name
]
=
this
->
mime
.
GetName
();
// Add `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
;
// Call the parent method.
RtpCodec
::
toJson
(
json
);
// Add `numChannels`.
if
(
this
->
numChannels
>
1
)
json
[
k_numChannels
]
=
(
Json
::
UInt
)
this
->
numChannels
;
// Not a room codec.
if
(
!
this
->
isRoomCodec
)
{
// Add `payloadType`.
json
[
k_payloadType
]
=
(
Json
::
UInt
)
this
->
payloadType
;
// Add `rtx`
if
(
this
->
hasRtx
)
json
[
k_rtx
]
=
this
->
rtx
.
toJson
();
// Add `rtx`
if
(
this
->
hasRtx
)
json
[
k_rtx
]
=
this
->
rtx
.
toJson
();
// Add `rtcpFeedback`.
json
[
k_rtcpFeedback
]
=
Json
::
arrayValue
;
// Add `rtcpFeedback`.
json
[
k_rtcpFeedback
]
=
Json
::
arrayValue
;
for
(
auto
&
entry
:
this
->
rtcpFeedback
)
for
(
auto
&
entry
:
this
->
rtcpFeedback
)
{
json
[
k_rtcpFeedback
].
append
(
entry
.
toJson
());
}
}
// Room codec.
else
{
json
[
k_rtcpFeedback
].
append
(
entry
.
toJson
());
// Add `kind`.
json
[
k_kind
]
=
RTC
::
Media
::
GetJsonString
(
this
->
kind
);
}
// Add `parameters`.
json
[
k_parameters
]
=
this
->
parameters
.
toJson
();
return
json
;
}
}
worker/src/RTC/RtpDictionaries/RtpParameters.cpp
浏览文件 @
966cabd1
...
...
@@ -36,7 +36,7 @@ namespace RTC
for
(
Json
::
UInt
i
=
0
;
i
<
json_codecs
.
size
();
i
++
)
{
RtpCodecParameters
codec
(
json_codecs
[
i
]);
RtpCodecParameters
codec
(
json_codecs
[
i
]
,
false
);
// Append to the codecs vector.
this
->
codecs
.
push_back
(
codec
);
...
...
worker/src/RTC/RtpDictionaries/RtpRoomMediaCodec.cpp
deleted
100644 → 0
浏览文件 @
74e30699
#define MS_CLASS "RTC::RtpRoomMediaCodec"
#include "RTC/RtpDictionaries.h"
#include "MediaSoupError.h"
#include "Logger.h"
namespace
RTC
{
/* Instance methods. */
RtpRoomMediaCodec
::
RtpRoomMediaCodec
(
Json
::
Value
&
data
)
:
RtpCodec
(
data
)
{
MS_TRACE
();
static
const
Json
::
StaticString
k_kind
(
"kind"
);
// `kind` is mandatory.
if
(
!
data
[
k_kind
].
isString
())
MS_THROW_ERROR
(
"missing RtpRoomMediaCodec.kind"
);
std
::
string
kind
=
data
[
k_kind
].
asString
();
// NOTE: This may throw.
this
->
kind
=
RTC
::
Media
::
GetKind
(
kind
);
// Validate codec.
// It must not be a feature codec.
if
(
this
->
mime
.
IsFeatureCodec
())
MS_THROW_ERROR
(
"RtpRoomMediaCodec can not be a feature coedc"
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论