修复rtsp seek播放时rtsp server返回npt字段不对问题

This commit is contained in:
baiyfcu 2020-04-08 15:37:16 +08:00
parent f7fa4e6407
commit fb77293648
2 changed files with 23 additions and 20 deletions

View File

@ -744,14 +744,14 @@ void RtspSession::handleReq_Play(const Parser &parser) {
bool useBuf = true; bool useBuf = true;
_enableSendRtp = false; _enableSendRtp = false;
float iStartTime = 0;
if (strRange.size() && !_bFirstPlay) { if (strRange.size() && !_bFirstPlay) {
//这个是seek操作 //这个是seek操作
auto strStart = FindField(strRange.data(), "npt=", "-"); auto strStart = FindField(strRange.data(), "npt=", "-");
if (strStart == "now") { if (strStart == "now") {
strStart = "0"; strStart = "0";
} }
auto iStartTime = 1000 * atof(strStart.data()); iStartTime = 1000 * atof(strStart.data());
InfoP(this) << "rtsp seekTo(ms):" << iStartTime; InfoP(this) << "rtsp seekTo(ms):" << iStartTime;
useBuf = !pMediaSrc->seekTo(iStartTime); useBuf = !pMediaSrc->seekTo(iStartTime);
}else if(pMediaSrc->totalReaderCount() == 0){ }else if(pMediaSrc->totalReaderCount() == 0){
@ -779,7 +779,7 @@ void RtspSession::handleReq_Play(const Parser &parser) {
rtp_info.pop_back(); rtp_info.pop_back();
sendRtspResponse("200 OK", sendRtspResponse("200 OK",
{"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0 << "-", {"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << /*pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0*/iStartTime/1000,
"RTP-Info",rtp_info "RTP-Info",rtp_info
}); });

View File

@ -85,7 +85,10 @@ int main(int argc,char *argv[]) {
//此处选择是否导出调试文件 //此处选择是否导出调试文件
// mINI::Instance()[RtpProxy::kDumpDir] = "/Users/xzl/Desktop/"; // mINI::Instance()[RtpProxy::kDumpDir] = "/Users/xzl/Desktop/";
if (argc == 2)
loadFile(argv[1]); loadFile(argv[1]);
else
ErrorL << "parameter error.";
#else #else
ErrorL << "please ENABLE_RTPPROXY and then test"; ErrorL << "please ENABLE_RTPPROXY and then test";
#endif//#if defined(ENABLE_RTPPROXY) #endif//#if defined(ENABLE_RTPPROXY)