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
07c5341f
Commit
07c5341f
authored
Aug 23, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兼容一些奇怪的rtsp流:#1031
parent
8b1d1d6e
全部展开
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
28 行增加
和
38 行删除
+28
-38
src/Extension/Factory.cpp
+27
-37
src/Rtsp/Rtsp.cpp
+0
-0
src/Rtsp/Rtsp.h
+1
-1
没有找到文件。
src/Extension/Factory.cpp
查看文件 @
07c5341f
...
...
@@ -26,7 +26,18 @@
namespace
mediakit
{
Track
::
Ptr
Factory
::
getTrackBySdp
(
const
SdpTrack
::
Ptr
&
track
)
{
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"mpeg4-generic"
)
==
0
)
{
auto
codec
=
getCodecId
(
track
->
_codec
);
if
(
codec
==
CodecInvalid
)
{
//根据传统的payload type 获取编码类型以及采样率等信息
codec
=
RtpPayload
::
getCodecId
(
track
->
_pt
);
}
switch
(
codec
)
{
case
CodecG711A
:
case
CodecG711U
:
return
std
::
make_shared
<
G711Track
>
(
codec
,
track
->
_samplerate
,
track
->
_channel
,
16
);
case
CodecL16
:
return
std
::
make_shared
<
L16Track
>
(
track
->
_samplerate
,
track
->
_channel
);
case
CodecOpus
:
return
std
::
make_shared
<
OpusTrack
>
();
case
CodecAAC
:
{
string
aac_cfg_str
=
FindField
(
track
->
_fmtp
.
data
(),
"config="
,
";"
);
if
(
aac_cfg_str
.
empty
())
{
aac_cfg_str
=
FindField
(
track
->
_fmtp
.
data
(),
"config="
,
nullptr
);
...
...
@@ -36,70 +47,49 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) {
return
nullptr
;
}
string
aac_cfg
;
for
(
size_t
i
=
0
;
i
<
aac_cfg_str
.
size
()
/
2
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
aac_cfg_str
.
size
()
/
2
;
++
i
)
{
unsigned
int
cfg
;
sscanf
(
aac_cfg_str
.
substr
(
i
*
2
,
2
).
data
(),
"%02X"
,
&
cfg
);
cfg
&=
0x00FF
;
aac_cfg
.
push_back
((
char
)
cfg
);
aac_cfg
.
push_back
((
char
)
cfg
);
}
return
std
::
make_shared
<
AACTrack
>
(
aac_cfg
);
}
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"opus"
)
==
0
)
{
return
std
::
make_shared
<
OpusTrack
>
();
}
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"PCMA"
)
==
0
)
{
return
std
::
make_shared
<
G711Track
>
(
CodecG711A
,
track
->
_samplerate
,
track
->
_channel
,
16
);
}
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"PCMU"
)
==
0
)
{
return
std
::
make_shared
<
G711Track
>
(
CodecG711U
,
track
->
_samplerate
,
track
->
_channel
,
16
);
}
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"L16"
)
==
0
)
{
return
std
::
make_shared
<
L16Track
>
(
track
->
_samplerate
,
track
->
_channel
);
}
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"h264"
)
==
0
)
{
case
CodecH264
:
{
//a=fmtp:96 packetization-mode=1;profile-level-id=42C01F;sprop-parameter-sets=Z0LAH9oBQBboQAAAAwBAAAAPI8YMqA==,aM48gA==
auto
map
=
Parser
::
parseArgs
(
FindField
(
track
->
_fmtp
.
data
(),
" "
,
nullptr
),
";"
,
"="
);
auto
map
=
Parser
::
parseArgs
(
track
->
_fmtp
,
";"
,
"="
);
auto
sps_pps
=
map
[
"sprop-parameter-sets"
];
string
base64_SPS
=
FindField
(
sps_pps
.
data
(),
NULL
,
","
);
string
base64_PPS
=
FindField
(
sps_pps
.
data
(),
","
,
NULL
);
auto
sps
=
decodeBase64
(
base64_SPS
);
auto
pps
=
decodeBase64
(
base64_PPS
);
if
(
sps
.
empty
()
||
pps
.
empty
())
{
if
(
sps
.
empty
()
||
pps
.
empty
())
{
//如果sdp里面没有sps/pps,那么可能在后续的rtp里面恢复出sps/pps
return
std
::
make_shared
<
H264Track
>
();
}
return
std
::
make_shared
<
H264Track
>
(
sps
,
pps
,
0
,
0
);
return
std
::
make_shared
<
H264Track
>
(
sps
,
pps
,
0
,
0
);
}
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"h265"
)
==
0
)
{
case
CodecH265
:
{
//a=fmtp:96 sprop-sps=QgEBAWAAAAMAsAAAAwAAAwBdoAKAgC0WNrkky/AIAAADAAgAAAMBlQg=; sprop-pps=RAHA8vA8kAA=
auto
map
=
Parser
::
parseArgs
(
FindField
(
track
->
_fmtp
.
data
(),
" "
,
nullptr
),
";"
,
"="
);
auto
map
=
Parser
::
parseArgs
(
track
->
_fmtp
,
";"
,
"="
);
auto
vps
=
decodeBase64
(
map
[
"sprop-vps"
]);
auto
sps
=
decodeBase64
(
map
[
"sprop-sps"
]);
auto
pps
=
decodeBase64
(
map
[
"sprop-pps"
]);
if
(
sps
.
empty
()
||
pps
.
empty
())
{
if
(
sps
.
empty
()
||
pps
.
empty
())
{
//如果sdp里面没有sps/pps,那么可能在后续的rtp里面恢复出sps/pps
return
std
::
make_shared
<
H265Track
>
();
}
return
std
::
make_shared
<
H265Track
>
(
vps
,
sps
,
pps
,
0
,
0
,
0
);
}
//可以根据传统的payload type 获取编码类型以及采样率等信息
CodecId
codec_id
=
RtpPayload
::
getCodecId
(
track
->
_pt
);
switch
(
codec_id
){
case
CodecG711A
:
case
CodecG711U
:
return
std
::
make_shared
<
G711Track
>
(
codec_id
,
track
->
_samplerate
,
track
->
_channel
,
16
);
default
:
break
;
return
std
::
make_shared
<
H265Track
>
(
vps
,
sps
,
pps
,
0
,
0
,
0
);
}
WarnL
<<
"暂不支持该sdp:"
<<
track
->
getName
();
default
:
{
//其他codec不支持
WarnL
<<
"暂不支持该rtsp编码类型:"
<<
track
->
getName
();
return
nullptr
;
}
}
}
RtpCodec
::
Ptr
Factory
::
getRtpEncoderBySdp
(
const
Sdp
::
Ptr
&
sdp
)
{
...
...
src/Rtsp/Rtsp.cpp
查看文件 @
07c5341f
差异被折叠。
点击展开。
src/Rtsp/Rtsp.h
查看文件 @
07c5341f
...
...
@@ -220,7 +220,7 @@ public:
float
_end
=
0
;
map
<
char
,
string
>
_other
;
map
<
string
,
string
>
_attr
;
m
ultim
ap
<
string
,
string
>
_attr
;
string
toString
()
const
;
string
getName
()
const
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论