mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
修复rtsp seek播放时rtsp server返回npt字段不对问题
This commit is contained in:
parent
f7fa4e6407
commit
fb77293648
@ -743,22 +743,22 @@ void RtspSession::handleReq_Play(const Parser &parser) {
|
||||
}
|
||||
|
||||
bool useBuf = true;
|
||||
_enableSendRtp = false;
|
||||
|
||||
if (strRange.size() && !_bFirstPlay) {
|
||||
_enableSendRtp = false;
|
||||
float iStartTime = 0;
|
||||
if (strRange.size() && !_bFirstPlay) {
|
||||
//这个是seek操作
|
||||
auto strStart = FindField(strRange.data(), "npt=", "-");
|
||||
if (strStart == "now") {
|
||||
strStart = "0";
|
||||
}
|
||||
auto iStartTime = 1000 * atof(strStart.data());
|
||||
InfoP(this) << "rtsp seekTo(ms):" << iStartTime;
|
||||
useBuf = !pMediaSrc->seekTo(iStartTime);
|
||||
}else if(pMediaSrc->totalReaderCount() == 0){
|
||||
//第一个消费者
|
||||
pMediaSrc->seekTo(0);
|
||||
}
|
||||
_bFirstPlay = false;
|
||||
auto strStart = FindField(strRange.data(), "npt=", "-");
|
||||
if (strStart == "now") {
|
||||
strStart = "0";
|
||||
}
|
||||
iStartTime = 1000 * atof(strStart.data());
|
||||
InfoP(this) << "rtsp seekTo(ms):" << iStartTime;
|
||||
useBuf = !pMediaSrc->seekTo(iStartTime);
|
||||
}else if(pMediaSrc->totalReaderCount() == 0){
|
||||
//第一个消费者
|
||||
pMediaSrc->seekTo(0);
|
||||
}
|
||||
_bFirstPlay = false;
|
||||
|
||||
_StrPrinter rtp_info;
|
||||
for(auto &track : _aTrackInfo){
|
||||
@ -778,10 +778,10 @@ void RtspSession::handleReq_Play(const Parser &parser) {
|
||||
|
||||
rtp_info.pop_back();
|
||||
|
||||
sendRtspResponse("200 OK",
|
||||
{"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0 << "-",
|
||||
"RTP-Info",rtp_info
|
||||
});
|
||||
sendRtspResponse("200 OK",
|
||||
{"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << /*pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0*/iStartTime/1000,
|
||||
"RTP-Info",rtp_info
|
||||
});
|
||||
|
||||
_enableSendRtp = true;
|
||||
setSocketFlags();
|
||||
|
@ -85,7 +85,10 @@ int main(int argc,char *argv[]) {
|
||||
//此处选择是否导出调试文件
|
||||
// mINI::Instance()[RtpProxy::kDumpDir] = "/Users/xzl/Desktop/";
|
||||
|
||||
loadFile(argv[1]);
|
||||
if (argc == 2)
|
||||
loadFile(argv[1]);
|
||||
else
|
||||
ErrorL << "parameter error.";
|
||||
#else
|
||||
ErrorL << "please ENABLE_RTPPROXY and then test";
|
||||
#endif//#if defined(ENABLE_RTPPROXY)
|
||||
|
Loading…
Reference in New Issue
Block a user