mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-03-13 17:40:56 +08:00
Co-authored-by: xia-chu <771730766@qq.com>
This commit is contained in:
@@ -464,7 +464,7 @@ void RtspPlayer::sendPause(int type, uint32_t seekMS) {
|
||||
// Start or pause RTSP
|
||||
switch (type) {
|
||||
case type_pause: sendRtspRequest("PAUSE", _control_url, {}); break;
|
||||
case type_play: sendRtspRequest("PLAY", _content_base); break;
|
||||
case type_play:
|
||||
case type_seek:
|
||||
sendRtspRequest("PLAY", _control_url, { "Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << seekMS / 1000.0 << "-" });
|
||||
break;
|
||||
@@ -582,6 +582,9 @@ void RtspPlayer::onRtcpPacket(int track_idx, SdpTrack::Ptr &track, uint8_t *data
|
||||
|
||||
void RtspPlayer::onRtpSorted(RtpPacket::Ptr rtppt, int trackidx) {
|
||||
_stamp[trackidx] = rtppt->getStampMS();
|
||||
if (!_first_stamp[trackidx]) {
|
||||
_first_stamp[trackidx] = _stamp[trackidx];
|
||||
}
|
||||
_rtp_recv_ticker.resetTime();
|
||||
onRecvRTP(std::move(rtppt), _sdp_track[trackidx]);
|
||||
}
|
||||
@@ -609,7 +612,7 @@ float RtspPlayer::getPacketLossRate(TrackType type) const {
|
||||
}
|
||||
|
||||
uint32_t RtspPlayer::getProgressMilliSecond() const {
|
||||
return MAX(_stamp[0], _stamp[1]);
|
||||
return MAX(_stamp[0] - _first_stamp[0], _stamp[1] - _first_stamp[1]);
|
||||
}
|
||||
|
||||
void RtspPlayer::seekToMilliSecond(uint32_t ms) {
|
||||
@@ -685,14 +688,18 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url, const Str
|
||||
printer << cmd << " " << url << " RTSP/1.0\r\n";
|
||||
|
||||
TraceL << cmd << " "<< url;
|
||||
|
||||
if (cmd == "PLAY") {
|
||||
// play命令时支持覆盖更新rtsp头,用于onvif点播等场景
|
||||
for (auto &pr : _custom_header) {
|
||||
header[pr.first] = pr.second;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &pr : header) {
|
||||
printer << pr.first << ": " << pr.second << "\r\n";
|
||||
}
|
||||
if (cmd == "PLAY") {
|
||||
for (auto &pr : _custom_header) {
|
||||
printer << pr.first << ": " << pr.second << "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
printer << "\r\n";
|
||||
SockSender::send(std::move(printer));
|
||||
}
|
||||
|
||||
@@ -184,9 +184,12 @@ protected:
|
||||
Rtsp::eRtpType _rtp_type = Rtsp::RTP_TCP;
|
||||
|
||||
private:
|
||||
// 起始时间戳
|
||||
uint64_t _first_stamp[2] = {0, 0};
|
||||
|
||||
// 当前rtp时间戳 [AUTO-TRANSLATED:410f2691]
|
||||
// Current rtp timestamp
|
||||
uint32_t _stamp[2] = {0, 0};
|
||||
uint64_t _stamp[2] = {0, 0};
|
||||
|
||||
// 超时功能实现 [AUTO-TRANSLATED:1d603b3a]
|
||||
// Timeout function implementation
|
||||
|
||||
Reference in New Issue
Block a user