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
d2406d23
Commit
d2406d23
authored
Oct 12, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兼容一些奇怪的rtsp url
parent
c4aaaa11
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
14 行删除
+25
-14
src/Rtsp/RtspPlayer.cpp
+24
-13
src/Rtsp/RtspPlayer.h
+1
-1
没有找到文件。
src/Rtsp/RtspPlayer.cpp
查看文件 @
d2406d23
...
...
@@ -76,24 +76,35 @@ void RtspPlayer::teardown(){
}
void
RtspPlayer
::
play
(
const
string
&
strUrl
){
auto
userAndPwd
=
FindField
(
strUrl
.
data
(),
"://"
,
"@"
);
Rtsp
::
eRtpType
eType
=
(
Rtsp
::
eRtpType
)(
int
)(
*
this
)[
kRtpType
];
if
(
userAndPwd
.
empty
()){
play
(
strUrl
,
""
,
""
,
eType
);
return
;
auto
schema
=
FindField
(
strUrl
.
data
(),
nullptr
,
"://"
);
bool
isSSL
=
strcasecmp
(
schema
.
data
(),
"rtsps"
)
==
0
;
//查找"://"与"/"之间的字符串,用于提取用户名密码
auto
middle_url
=
FindField
(
strUrl
.
data
(),
"://"
,
"/"
);
if
(
middle_url
.
empty
()){
middle_url
=
FindField
(
strUrl
.
data
(),
"://"
,
nullptr
);
}
auto
pos
=
middle_url
.
rfind
(
'@'
);
if
(
pos
==
string
::
npos
){
//并没有用户名密码
play
(
isSSL
,
strUrl
,
""
,
""
,
eType
);
return
;
}
auto
suffix
=
FindField
(
strUrl
.
data
(),
"@"
,
nullptr
);
//包含用户名密码
auto
user_pwd
=
middle_url
.
substr
(
0
,
pos
);
auto
suffix
=
strUrl
.
substr
(
schema
.
size
()
+
3
+
pos
+
1
);
auto
url
=
StrPrinter
<<
"rtsp://"
<<
suffix
<<
endl
;
if
(
user
AndP
wd
.
find
(
":"
)
==
string
::
npos
){
play
(
url
,
userAndP
wd
,
""
,
eType
);
if
(
user
_p
wd
.
find
(
":"
)
==
string
::
npos
){
play
(
isSSL
,
url
,
user_p
wd
,
""
,
eType
);
return
;
}
auto
user
=
FindField
(
user
AndP
wd
.
data
(),
nullptr
,
":"
);
auto
pwd
=
FindField
(
user
AndP
wd
.
data
(),
":"
,
nullptr
);
play
(
url
,
user
,
pwd
,
eType
);
auto
user
=
FindField
(
user
_p
wd
.
data
(),
nullptr
,
":"
);
auto
pwd
=
FindField
(
user
_p
wd
.
data
(),
":"
,
nullptr
);
play
(
isSSL
,
url
,
user
,
pwd
,
eType
);
}
//播放,指定是否走rtp over tcp
void
RtspPlayer
::
play
(
const
string
&
strUrl
,
const
string
&
strUser
,
const
string
&
strPwd
,
Rtsp
::
eRtpType
eType
)
{
void
RtspPlayer
::
play
(
bool
isSSL
,
const
string
&
strUrl
,
const
string
&
strUser
,
const
string
&
strPwd
,
Rtsp
::
eRtpType
eType
)
{
DebugL
<<
strUrl
<<
" "
<<
(
strUser
.
size
()
?
strUser
:
"null"
)
<<
" "
<<
(
strPwd
.
size
()
?
strPwd
:
"null"
)
<<
" "
...
...
@@ -117,7 +128,7 @@ void RtspPlayer::play(const string &strUrl, const string &strUser, const string
auto
port
=
atoi
(
FindField
(
ip
.
data
(),
":"
,
NULL
).
data
());
if
(
port
<=
0
)
{
//rtsp 默认端口554
port
=
554
;
port
=
isSSL
?
322
:
554
;
}
else
{
//服务器域名
ip
=
FindField
(
ip
.
data
(),
NULL
,
":"
);
...
...
src/Rtsp/RtspPlayer.h
查看文件 @
d2406d23
...
...
@@ -107,7 +107,7 @@ private:
int
getTrackIndexByInterleaved
(
int
interleaved
)
const
;
int
getTrackIndexByTrackType
(
TrackType
trackType
)
const
;
void
play
(
const
string
&
strUrl
,
const
string
&
strUser
,
const
string
&
strPwd
,
Rtsp
::
eRtpType
eType
);
void
play
(
bool
isSSL
,
const
string
&
strUrl
,
const
string
&
strUser
,
const
string
&
strPwd
,
Rtsp
::
eRtpType
eType
);
void
handleResSETUP
(
const
Parser
&
parser
,
unsigned
int
uiTrackIndex
);
void
handleResDESCRIBE
(
const
Parser
&
parser
);
bool
handleAuthenticationFailure
(
const
string
&
wwwAuthenticateParamsStr
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论