Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
cc5dee0a
Commit
cc5dee0a
authored
4 years ago
by
xia-chu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化sdp fmtp字段处理逻辑
parent
46e3538d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
28 行删除
+24
-28
webrtc/Sdp.cpp
+20
-26
webrtc/Sdp.h
+4
-2
没有找到文件。
webrtc/Sdp.cpp
查看文件 @
cc5dee0a
...
...
@@ -9,7 +9,6 @@
*/
#include "Sdp.h"
#include "Common/Parser.h"
#include "Rtsp/Rtsp.h"
#include <inttypes.h>
using
namespace
mediakit
;
...
...
@@ -610,12 +609,12 @@ void SdpAttrFmtp::parse(const string &str) {
trim
(
item
);
auto
pos
=
item
.
find
(
'='
);
if
(
pos
==
string
::
npos
){
arr
.
emplace_back
(
std
::
make_pair
(
item
,
""
));
fmtp
.
emplace
(
std
::
make_pair
(
item
,
""
));
}
else
{
arr
.
emplace_back
(
std
::
make_pair
(
item
.
substr
(
0
,
pos
),
item
.
substr
(
pos
+
1
)));
fmtp
.
emplace
(
std
::
make_pair
(
item
.
substr
(
0
,
pos
),
item
.
substr
(
pos
+
1
)));
}
}
if
(
arr
.
empty
())
{
if
(
fmtp
.
empty
())
{
SDP_THROW
();
}
}
...
...
@@ -624,7 +623,7 @@ string SdpAttrFmtp::toString() const {
if
(
value
.
empty
())
{
value
=
to_string
(
pt
);
int
i
=
0
;
for
(
auto
&
pr
:
arr
)
{
for
(
auto
&
pr
:
fmtp
)
{
value
+=
(
i
++
?
';'
:
' '
);
value
+=
pr
.
first
+
"="
+
pr
.
second
;
}
...
...
@@ -918,7 +917,7 @@ void RtcSession::loadFrom(const string &str, bool check) {
auto
fmtp_it
=
fmtp_map
.
find
(
pt
);
if
(
fmtp_it
!=
fmtp_map
.
end
())
{
plan
.
fmtp
=
fmtp_it
->
second
.
arr
;
plan
.
fmtp
=
fmtp_it
->
second
.
fmtp
;
}
for
(
auto
rtpfb_it
=
rtcpfb_map
.
find
(
pt
);
rtpfb_it
!=
rtcpfb_map
.
end
()
&&
rtpfb_it
->
second
.
pt
==
pt
;
++
rtpfb_it
)
{
...
...
@@ -1088,7 +1087,7 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{
if
(
!
p
.
fmtp
.
empty
())
{
auto
fmtp
=
std
::
make_shared
<
SdpAttrFmtp
>
();
fmtp
->
pt
=
p
.
pt
;
fmtp
->
arr
=
p
.
fmtp
;
fmtp
->
fmtp
=
p
.
fmtp
;
sdp_media
.
items
.
emplace_back
(
wrapSdpAttr
(
std
::
move
(
fmtp
)));
}
}
...
...
@@ -1255,12 +1254,14 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
ice_renomination
=
false
;
switch
(
type
)
{
case
TrackAudio
:
{
preferred_codec
=
{
CodecAAC
,
CodecOpus
,
CodecG711U
,
CodecG711A
};
//此处调整偏好的编码格式优先级
preferred_codec
=
{
CodecAAC
,
CodecG711U
,
CodecG711A
,
CodecOpus
};
rtcp_fb
=
{
"transport-cc"
};
extmap
=
{
"1 urn:ietf:params:rtp-hdrext:ssrc-audio-level"
};
break
;
}
case
TrackVideo
:
{
//此处调整偏好的编码格式优先级
preferred_codec
=
{
CodecH264
,
CodecH265
};
rtcp_fb
=
{
"nack"
,
"ccm fir"
,
"nack pli"
,
"goog-remb"
,
"transport-cc"
};
extmap
=
{
"2 urn:ietf:params:rtp-hdrext:toffset"
,
...
...
@@ -1441,6 +1442,7 @@ RETRY:
//添加媒体plan
answer_media
.
plan
.
emplace_back
(
*
offer_plan_ptr
);
onSelectPlan
(
answer_media
.
plan
.
back
(),
codec
);
//添加rtx,red,ulpfec plan
if
(
configure
.
support_red
||
configure
.
support_rtx
||
configure
.
support_ulpfec
)
{
...
...
@@ -1535,14 +1537,6 @@ void RtcConfigure::setPlayRtspInfo(const string &sdp){
}
}
static
map
<
string
,
string
,
StrCaseCompare
>
toMap
(
const
vector
<
std
::
pair
<
string
/*key*/
,
string
/*value*/
>
>
&
fmt
)
{
map
<
string
,
string
,
StrCaseCompare
>
ret
;
for
(
auto
&
pr
:
fmt
)
{
ret
.
emplace
(
pr
);
}
return
ret
;
}
static
const
string
kProfile
{
"profile-level-id"
};
static
const
string
kMode
{
"packetization-mode"
};
...
...
@@ -1555,21 +1549,21 @@ bool RtcConfigure::onCheckCodecProfile(const RtcCodecPlan &plan, CodecId codec){
return
true
;
}
if
(
_rtsp_video_plan
&&
codec
==
CodecH264
&&
getCodecId
(
_rtsp_video_plan
->
codec
)
==
CodecH264
)
{
//h264时,匹配packetization-mode和profile-level-id
auto
rtc_fmt_map
=
toMap
(
plan
.
fmtp
);
auto
rtsp_fmt_map
=
toMap
(
_rtsp_video_plan
->
fmtp
);
auto
&
profile
=
rtsp_fmt_map
[
kProfile
];
if
(
!
profile
.
empty
()
&&
strcasecmp
(
profile
.
data
(),
rtc_fmt_map
[
kProfile
].
data
()))
{
//h264时,profile-level-id
if
(
strcasecmp
(
_rtsp_video_plan
->
fmtp
[
kProfile
].
data
(),
const_cast
<
RtcCodecPlan
&>
(
plan
).
fmtp
[
kProfile
].
data
()))
{
//profile-level-id 不匹配
return
false
;
}
auto
&
mode
=
rtsp_fmt_map
[
kMode
];
if
(
!
mode
.
empty
()
&&
atoi
(
mode
.
data
())
!=
atoi
(
rtc_fmt_map
[
kMode
].
data
()))
{
//packetization-mode不匹配
return
false
;
}
return
true
;
}
return
true
;
}
void
RtcConfigure
::
onSelectPlan
(
RtcCodecPlan
&
plan
,
CodecId
codec
){
if
(
_rtsp_video_plan
&&
codec
==
CodecH264
&&
getCodecId
(
_rtsp_video_plan
->
codec
)
==
CodecH264
)
{
//h264时,设置packetization-mod为一致
auto
mode
=
_rtsp_video_plan
->
fmtp
[
kMode
];
plan
.
fmtp
[
kMode
]
=
mode
.
empty
()
?
"0"
:
mode
;
}
}
This diff is collapsed.
Click to expand it.
webrtc/Sdp.h
查看文件 @
cc5dee0a
...
...
@@ -15,6 +15,7 @@
#include <vector>
#include "assert.h"
#include "Extension/Frame.h"
#include "Common/Parser.h"
using
namespace
std
;
using
namespace
mediakit
;
...
...
@@ -372,7 +373,7 @@ class SdpAttrFmtp : public SdpItem {
public
:
//fmtp:96 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
uint8_t
pt
;
vector
<
std
::
pair
<
string
,
string
>
>
arr
;
map
<
string
/*key*/
,
string
/*value*/
,
StrCaseCompare
>
fmtp
;
void
parse
(
const
string
&
str
)
override
;
string
toString
()
const
override
;
const
char
*
getKey
()
const
override
{
return
"fmtp"
;}
...
...
@@ -589,7 +590,7 @@ public:
uint32_t
channel
=
0
;
//rtcp反馈
vector
<
string
>
rtcp_fb
;
vector
<
std
::
pair
<
string
/*key*/
,
string
/*value*/
>
>
fmtp
;
map
<
string
/*key*/
,
string
/*value*/
,
StrCaseCompare
>
fmtp
;
string
getFmtp
(
const
char
*
key
)
const
;
};
...
...
@@ -715,6 +716,7 @@ public:
private
:
void
matchMedia
(
shared_ptr
<
RtcSession
>
&
ret
,
TrackType
type
,
const
vector
<
RtcMedia
>
&
medias
,
const
RtcTrackConfigure
&
configure
);
bool
onCheckCodecProfile
(
const
RtcCodecPlan
&
plan
,
CodecId
codec
);
void
onSelectPlan
(
RtcCodecPlan
&
plan
,
CodecId
codec
);
private
:
RtcCodecPlan
::
Ptr
_rtsp_video_plan
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论