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
fb1d7dd5
Commit
fb1d7dd5
authored
Aug 22, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtsp推流拉流转发时修整sdp
rtsp推流修整时间戳
parent
bf736371
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
30 行增加
和
27 行删除
+30
-27
.gitignore
+3
-2
src/Common/config.cpp
+4
-1
src/Common/config.h
+2
-0
src/Rtsp/RtspDemuxer.cpp
+0
-4
src/Rtsp/RtspDemuxer.h
+0
-1
src/Rtsp/RtspPlayer.cpp
+3
-3
src/Rtsp/RtspPlayer.h
+1
-2
src/Rtsp/RtspPlayerImp.h
+3
-3
src/Rtsp/RtspSession.cpp
+12
-9
src/Rtsp/RtspSession.h
+2
-2
没有找到文件。
.gitignore
查看文件 @
fb1d7dd5
...
...
@@ -33,4 +33,5 @@
/cmake-build-debug/
/.idea/
/c_wrapper/.idea/
\ No newline at end of file
/c_wrapper/.idea/
/release/mac/Debug/
\ No newline at end of file
src/Common/config.cpp
查看文件 @
fb1d7dd5
...
...
@@ -161,13 +161,16 @@ namespace Rtsp {
const
string
kAuthBasic
=
RTSP_FIELD
"authBasic"
;
const
string
kHandshakeSecond
=
RTSP_FIELD
"handshakeSecond"
;
const
string
kKeepAliveSecond
=
RTSP_FIELD
"keepAliveSecond"
;
const
string
kDirectProxy
=
RTSP_FIELD
"directProxy"
;;
const
string
kDirectProxy
=
RTSP_FIELD
"directProxy"
;
const
string
kModifyStamp
=
RTSP_FIELD
"modifyStamp"
;
onceToken
token
([](){
//默认Md5方式认证
mINI
::
Instance
()[
kAuthBasic
]
=
0
;
mINI
::
Instance
()[
kHandshakeSecond
]
=
15
;
mINI
::
Instance
()[
kKeepAliveSecond
]
=
15
;
mINI
::
Instance
()[
kDirectProxy
]
=
1
;
mINI
::
Instance
()[
kModifyStamp
]
=
true
;
},
nullptr
);
}
//namespace Rtsp
...
...
src/Common/config.h
查看文件 @
fb1d7dd5
...
...
@@ -209,6 +209,8 @@ extern const string kKeepAliveSecond;
//假定您的拉流源地址不是264或265或AAC,那么你可以使用直接代理的方式来支持rtsp代理
//默认开启rtsp直接代理,rtmp由于没有这些问题,是强制开启直接代理的
extern
const
string
kDirectProxy
;
//rtsp推流是否修改时间戳
extern
const
string
kModifyStamp
;
}
//namespace Rtsp
////////////RTMP服务器配置///////////
...
...
src/Rtsp/RtspDemuxer.cpp
查看文件 @
fb1d7dd5
...
...
@@ -38,10 +38,6 @@ RtspDemuxer::RtspDemuxer(const string& sdp) {
loadSdp
(
SdpParser
(
sdp
));
}
RtspDemuxer
::
RtspDemuxer
(
const
SdpParser
&
attr
)
{
loadSdp
(
attr
);
}
void
RtspDemuxer
::
loadSdp
(
const
SdpParser
&
attr
)
{
auto
tracks
=
attr
.
getAvailableTrack
();
for
(
auto
&
track
:
tracks
){
...
...
src/Rtsp/RtspDemuxer.h
查看文件 @
fb1d7dd5
...
...
@@ -41,7 +41,6 @@ class RtspDemuxer : public Demuxer{
public
:
typedef
std
::
shared_ptr
<
RtspDemuxer
>
Ptr
;
RtspDemuxer
(
const
string
&
sdp
);
RtspDemuxer
(
const
SdpParser
&
parser
);
virtual
~
RtspDemuxer
(){};
/**
...
...
src/Rtsp/RtspPlayer.cpp
查看文件 @
fb1d7dd5
...
...
@@ -219,14 +219,14 @@ void RtspPlayer::handleResDESCRIBE(const Parser& parser) {
_strContentBase
.
pop_back
();
}
SdpParser
sdpParser
(
parser
.
Content
());
//解析sdp
_sdpParser
.
load
(
parser
.
Content
());
_aTrackInfo
=
_sdpParser
.
getAvailableTrack
();
_aTrackInfo
=
sdpParser
.
getAvailableTrack
();
if
(
_aTrackInfo
.
empty
())
{
throw
std
::
runtime_error
(
"无有效的Sdp Track"
);
}
if
(
!
onCheckSDP
(
parser
.
Content
(),
_sdpParser
))
{
if
(
!
onCheckSDP
(
sdpParser
.
toString
()
))
{
throw
std
::
runtime_error
(
"onCheckSDP faied"
);
}
...
...
src/Rtsp/RtspPlayer.h
查看文件 @
fb1d7dd5
...
...
@@ -59,7 +59,7 @@ public:
float
getPacketLossRate
(
TrackType
type
)
const
override
;
protected
:
//派生类回调函数
virtual
bool
onCheckSDP
(
const
string
&
strSdp
,
const
SdpParser
&
parser
)
=
0
;
virtual
bool
onCheckSDP
(
const
string
&
strSdp
)
=
0
;
virtual
void
onRecvRTP
(
const
RtpPacket
::
Ptr
&
pRtppt
,
const
SdpTrack
::
Ptr
&
track
)
=
0
;
uint32_t
getProgressMilliSecond
()
const
;
void
seekToMilliSecond
(
uint32_t
ms
);
...
...
@@ -124,7 +124,6 @@ private:
void
createUdpSockIfNecessary
(
int
track_idx
);
private
:
string
_strUrl
;
SdpParser
_sdpParser
;
vector
<
SdpTrack
::
Ptr
>
_aTrackInfo
;
function
<
void
(
const
Parser
&
)
>
_onHandshake
;
Socket
::
Ptr
_apRtpSock
[
2
];
//RTP端口,trackid idx 为数组下标
...
...
src/Rtsp/RtspPlayerImp.h
查看文件 @
fb1d7dd5
...
...
@@ -61,12 +61,12 @@ public:
};
private
:
//派生类回调函数
bool
onCheckSDP
(
const
string
&
sdp
,
const
SdpParser
&
parser
)
override
{
bool
onCheckSDP
(
const
string
&
sdp
)
override
{
_pRtspMediaSrc
=
dynamic_pointer_cast
<
RtspMediaSource
>
(
_pMediaSrc
);
if
(
_pRtspMediaSrc
){
_pRtspMediaSrc
->
onGetSDP
(
parser
.
toString
()
);
_pRtspMediaSrc
->
onGetSDP
(
sdp
);
}
_parser
.
reset
(
new
RtspDemuxer
(
parser
));
_parser
.
reset
(
new
RtspDemuxer
(
sdp
));
return
true
;
}
void
onRecvRTP
(
const
RtpPacket
::
Ptr
&
rtp
,
const
SdpTrack
::
Ptr
&
track
)
override
{
...
...
src/Rtsp/RtspSession.cpp
查看文件 @
fb1d7dd5
...
...
@@ -242,13 +242,13 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
throw
SockException
(
Err_shutdown
,
err
);
}
_strSession
=
makeRandStr
(
12
);
_strS
dp
=
parser
.
Content
(
);
_aTrackInfo
=
SdpParser
(
_strSdp
)
.
getAvailableTrack
();
SdpParser
sdpParser
(
parser
.
Content
()
);
_strS
ession
=
makeRandStr
(
12
);
_aTrackInfo
=
sdpParser
.
getAvailableTrack
();
_pushSrc
=
std
::
make_shared
<
RtspToRtmpMediaSource
>
(
_mediaInfo
.
_vhost
,
_mediaInfo
.
_app
,
_mediaInfo
.
_streamid
);
_pushSrc
->
setListener
(
dynamic_pointer_cast
<
MediaSourceEvent
>
(
shared_from_this
()));
_pushSrc
->
onGetSDP
(
_strSdp
);
_pushSrc
->
onGetSDP
(
sdpParser
.
toString
()
);
sendRtspResponse
(
"200 OK"
);
}
...
...
@@ -362,9 +362,7 @@ void RtspSession::onAuthSuccess() {
return
;
}
//找到了响应的rtsp流
strongSelf
->
_strSdp
=
rtsp_src
->
getSdp
();
SdpParser
sdpParser
(
strongSelf
->
_strSdp
);
strongSelf
->
_aTrackInfo
=
sdpParser
.
getAvailableTrack
();
strongSelf
->
_aTrackInfo
=
SdpParser
(
rtsp_src
->
getSdp
()).
getAvailableTrack
();
if
(
strongSelf
->
_aTrackInfo
.
empty
())
{
//该流无效
strongSelf
->
send_StreamNotFound
();
...
...
@@ -383,7 +381,7 @@ void RtspSession::onAuthSuccess() {
{
"Content-Base"
,
strongSelf
->
_strContentBase
+
"/"
,
"x-Accept-Retransmit"
,
"our-retransmit"
,
"x-Accept-Dynamic-Rate"
,
"1"
},
strongSelf
->
_strSdp
);
},
rtsp_src
->
getSdp
()
);
});
}
void
RtspSession
::
onAuthFailed
(
const
string
&
realm
,
const
string
&
why
,
bool
close
)
{
...
...
@@ -918,7 +916,12 @@ inline void RtspSession::send_NotAcceptable() {
void
RtspSession
::
onRtpSorted
(
const
RtpPacket
::
Ptr
&
rtppt
,
int
trackidx
)
{
GET_CONFIG
(
bool
,
modify_stamp
,
Rtsp
::
kModifyStamp
);
if
(
modify_stamp
){
int64_t
dts_out
;
_stamp
[
trackidx
].
revise
(
0
,
0
,
dts_out
,
dts_out
);
rtppt
->
timeStamp
=
dts_out
;
}
_pushSrc
->
onWrite
(
rtppt
,
false
);
}
inline
void
RtspSession
::
onRcvPeerUdpData
(
int
intervaled
,
const
Buffer
::
Ptr
&
pBuf
,
const
struct
sockaddr
&
addr
)
{
...
...
src/Rtsp/RtspSession.h
查看文件 @
fb1d7dd5
...
...
@@ -190,8 +190,6 @@ private:
int
_iCseq
=
0
;
//ContentBase
string
_strContentBase
;
//推流端发送的sdp或播放端请求的sdp
string
_strSdp
;
//Session号
string
_strSession
;
//是否第一次播放,第一次播放需要鉴权,第二次播放属于暂停恢复
...
...
@@ -235,6 +233,8 @@ private:
RtcpCounter
_aRtcpCnt
[
2
];
//rtcp发送时间,trackid idx 为数组下标
Ticker
_aRtcpTicker
[
2
];
//时间戳修整器
Stamp
_stamp
[
2
];
};
/**
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论