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
d52fc4c3
Commit
d52fc4c3
authored
Jan 12, 2022
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine: 优化rtsp相关代码
parent
5b6ff0af
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
22 行增加
和
17 行删除
+22
-17
src/Rtsp/RtpReceiver.h
+7
-2
src/Rtsp/RtspPlayer.cpp
+3
-3
src/Rtsp/RtspPusher.cpp
+4
-4
src/Rtsp/RtspSession.cpp
+8
-8
没有找到文件。
src/Rtsp/RtpReceiver.h
查看文件 @
d52fc4c3
...
...
@@ -236,7 +236,8 @@ public:
* @param len rtp数据指针长度
* @return 解析成功返回true
*/
bool
handleOneRtp
(
int
index
,
TrackType
type
,
int
sample_rate
,
uint8_t
*
ptr
,
size_t
len
){
bool
handleOneRtp
(
int
index
,
TrackType
type
,
int
sample_rate
,
uint8_t
*
ptr
,
size_t
len
)
{
assert
(
index
<
kCount
&&
index
>=
0
);
return
_track
[
index
].
inputRtp
(
type
,
sample_rate
,
ptr
,
len
).
operator
bool
();
}
...
...
@@ -247,7 +248,8 @@ public:
* @param rtp_stamp rtp时间戳
* @param ntp_stamp_ms ntp时间戳
*/
void
setNtpStamp
(
int
index
,
uint32_t
rtp_stamp
,
uint64_t
ntp_stamp_ms
){
void
setNtpStamp
(
int
index
,
uint32_t
rtp_stamp
,
uint64_t
ntp_stamp_ms
)
{
assert
(
index
<
kCount
&&
index
>=
0
);
_track
[
index
].
setNtpStamp
(
rtp_stamp
,
ntp_stamp_ms
);
}
...
...
@@ -258,14 +260,17 @@ public:
}
size_t
getJitterSize
(
int
index
)
const
{
assert
(
index
<
kCount
&&
index
>=
0
);
return
_track
[
index
].
getJitterSize
();
}
size_t
getCycleCount
(
int
index
)
const
{
assert
(
index
<
kCount
&&
index
>=
0
);
return
_track
[
index
].
getCycleCount
();
}
uint32_t
getSSRC
(
int
index
)
const
{
assert
(
index
<
kCount
&&
index
>=
0
);
return
_track
[
index
].
getSSRC
();
}
...
...
src/Rtsp/RtspPlayer.cpp
查看文件 @
d52fc4c3
...
...
@@ -693,7 +693,7 @@ void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshake_done) {
}
int
RtspPlayer
::
getTrackIndexByInterleaved
(
int
interleaved
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
_sdp_track
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
_sdp_track
.
size
();
++
i
)
{
if
(
_sdp_track
[
i
]
->
_interleaved
==
interleaved
)
{
return
i
;
}
...
...
@@ -705,7 +705,7 @@ int RtspPlayer::getTrackIndexByInterleaved(int interleaved) const {
}
int
RtspPlayer
::
getTrackIndexByTrackType
(
TrackType
track_type
)
const
{
for
(
unsigned
int
i
=
0
;
i
<
_sdp_track
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
_sdp_track
.
size
();
++
i
)
{
if
(
_sdp_track
[
i
]
->
_type
==
track_type
)
{
return
i
;
}
...
...
@@ -713,7 +713,7 @@ int RtspPlayer::getTrackIndexByTrackType(TrackType track_type) const {
if
(
_sdp_track
.
size
()
==
1
)
{
return
0
;
}
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with type:"
<<
(
int
)
track_type
);
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with type:"
<<
getTrackString
(
track_type
)
);
}
}
/* namespace mediakit */
src/Rtsp/RtspPusher.cpp
查看文件 @
d52fc4c3
...
...
@@ -419,7 +419,7 @@ void RtspPusher::sendRtpPacket(const RtspMediaSource::RingDataType &pkt) {
}
int
RtspPusher
::
getTrackIndexByInterleaved
(
int
interleaved
)
const
{
for
(
int
i
=
0
;
i
<
(
int
)
_track_vec
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
_track_vec
.
size
();
++
i
)
{
if
(
_track_vec
[
i
]
->
_interleaved
==
interleaved
)
{
return
i
;
}
...
...
@@ -430,8 +430,8 @@ int RtspPusher::getTrackIndexByInterleaved(int interleaved) const {
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with interleaved:"
<<
interleaved
);
}
int
RtspPusher
::
getTrackIndexByTrackType
(
TrackType
type
)
const
{
for
(
int
i
=
0
;
i
<
(
int
)
_track_vec
.
size
();
++
i
)
{
int
RtspPusher
::
getTrackIndexByTrackType
(
TrackType
type
)
const
{
for
(
size_t
i
=
0
;
i
<
_track_vec
.
size
();
++
i
)
{
if
(
type
==
_track_vec
[
i
]
->
_type
)
{
return
i
;
}
...
...
@@ -439,7 +439,7 @@ int RtspPusher::getTrackIndexByTrackType(TrackType type) const{
if
(
_track_vec
.
size
()
==
1
)
{
return
0
;
}
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with type:"
<<
(
int
)
type
);
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with type:"
<<
getTrackString
(
type
)
);
}
void
RtspPusher
::
sendRecord
()
{
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
d52fc4c3
...
...
@@ -1098,36 +1098,36 @@ bool RtspSession::sendRtspResponse(const string &res_code, const std::initialize
}
int
RtspSession
::
getTrackIndexByTrackType
(
TrackType
type
)
{
for
(
unsigned
int
i
=
0
;
i
<
_sdp_track
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
_sdp_track
.
size
();
++
i
)
{
if
(
type
==
_sdp_track
[
i
]
->
_type
)
{
return
i
;
}
}
if
(
_sdp_track
.
size
()
==
1
)
{
if
(
_sdp_track
.
size
()
==
1
)
{
return
0
;
}
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with type:"
<<
(
int
)
type
);
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with type:"
<<
getTrackString
(
type
)
);
}
int
RtspSession
::
getTrackIndexByControlUrl
(
const
string
&
control_url
)
{
for
(
unsigned
int
i
=
0
;
i
<
_sdp_track
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
_sdp_track
.
size
();
++
i
)
{
if
(
control_url
==
_sdp_track
[
i
]
->
getControlUrl
(
_content_base
))
{
return
i
;
}
}
if
(
_sdp_track
.
size
()
==
1
)
{
if
(
_sdp_track
.
size
()
==
1
)
{
return
0
;
}
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with control url:"
<<
control_url
);
}
int
RtspSession
::
getTrackIndexByInterleaved
(
int
interleaved
){
for
(
unsigned
int
i
=
0
;
i
<
_sdp_track
.
size
();
i
++
)
{
int
RtspSession
::
getTrackIndexByInterleaved
(
int
interleaved
)
{
for
(
size_t
i
=
0
;
i
<
_sdp_track
.
size
();
++
i
)
{
if
(
_sdp_track
[
i
]
->
_interleaved
==
interleaved
)
{
return
i
;
}
}
if
(
_sdp_track
.
size
()
==
1
)
{
if
(
_sdp_track
.
size
()
==
1
)
{
return
0
;
}
throw
SockException
(
Err_shutdown
,
StrPrinter
<<
"no such track with interleaved:"
<<
interleaved
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论