mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
轮流发送rtcp与GET_PARAMETER保活:#642
This commit is contained in:
parent
9447ef70ca
commit
4b22e189d5
@ -385,7 +385,7 @@ void RtspPlayer::sendOptions(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RtspPlayer::sendKeepAlive(){
|
void RtspPlayer::sendKeepAlive(){
|
||||||
_on_response = [this](const Parser& parser){};
|
_on_response = [](const Parser &parser) {};
|
||||||
if(_supported_cmd.find("GET_PARAMETER") != _supported_cmd.end()){
|
if(_supported_cmd.find("GET_PARAMETER") != _supported_cmd.end()){
|
||||||
//支持GET_PARAMETER,用此命令保活
|
//支持GET_PARAMETER,用此命令保活
|
||||||
sendRtspRequest("GET_PARAMETER", _content_base);
|
sendRtspRequest("GET_PARAMETER", _content_base);
|
||||||
@ -728,20 +728,25 @@ void RtspPlayer::onRecvRTP_l(const RtpPacket::Ptr &rtp, const SdpTrack::Ptr &tra
|
|||||||
RtcpCounter &counter = _rtcp_counter[track_idx];
|
RtcpCounter &counter = _rtcp_counter[track_idx];
|
||||||
counter.pktCnt = rtp->sequence;
|
counter.pktCnt = rtp->sequence;
|
||||||
auto &ticker = _rtcp_send_ticker[track_idx];
|
auto &ticker = _rtcp_send_ticker[track_idx];
|
||||||
if (ticker.elapsedTime() > 5 * 1000) {
|
if (ticker.elapsedTime() > 3 * 1000) {
|
||||||
//send rtcp every 5 second
|
//每3秒发送一次心跳,rtcp与rtsp信令轮流心跳,该特性用于兼容issue:642
|
||||||
counter.lastTimeStamp = counter.timeStamp;
|
if (_send_rtcp) {
|
||||||
//直接保存网络字节序
|
counter.lastTimeStamp = counter.timeStamp;
|
||||||
memcpy(&counter.timeStamp, rtp->data() + 8, 4);
|
//直接保存网络字节序
|
||||||
if (counter.lastTimeStamp != 0) {
|
memcpy(&counter.timeStamp, rtp->data() + 8, 4);
|
||||||
sendReceiverReport(_rtp_type == Rtsp::RTP_TCP, track_idx);
|
if (counter.lastTimeStamp != 0) {
|
||||||
ticker.resetTime();
|
sendReceiverReport(_rtp_type == Rtsp::RTP_TCP, track_idx);
|
||||||
}
|
ticker.resetTime();
|
||||||
|
_send_rtcp = false;
|
||||||
//有些rtsp服务器需要rtcp保活,有些需要发送信令保活
|
}
|
||||||
if (track_idx == 0) {
|
} else {
|
||||||
//只需要发送一次心跳信令包
|
//有些rtsp服务器需要rtcp保活,有些需要发送信令保活
|
||||||
sendKeepAlive();
|
if (track_idx == 0) {
|
||||||
|
//只需要发送一次心跳信令包
|
||||||
|
sendKeepAlive();
|
||||||
|
ticker.resetTime();
|
||||||
|
_send_rtcp = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,11 @@ private:
|
|||||||
void createUdpSockIfNecessary(int track_idx);
|
void createUdpSockIfNecessary(int track_idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//是否为性能测试模式
|
||||||
|
bool _benchmark_mode = false;
|
||||||
|
//轮流发送rtcp与GET_PARAMETER保活
|
||||||
|
bool _send_rtcp = true;
|
||||||
|
|
||||||
string _play_url;
|
string _play_url;
|
||||||
vector<SdpTrack::Ptr> _sdp_track;
|
vector<SdpTrack::Ptr> _sdp_track;
|
||||||
function<void(const Parser&)> _on_response;
|
function<void(const Parser&)> _on_response;
|
||||||
@ -143,9 +148,6 @@ private:
|
|||||||
//rtcp发送时间,trackid idx 为数组下标
|
//rtcp发送时间,trackid idx 为数组下标
|
||||||
Ticker _rtcp_send_ticker[2];
|
Ticker _rtcp_send_ticker[2];
|
||||||
|
|
||||||
//是否为性能测试模式
|
|
||||||
bool _benchmark_mode = false;
|
|
||||||
|
|
||||||
//服务器支持的命令
|
//服务器支持的命令
|
||||||
set<string> _supported_cmd;
|
set<string> _supported_cmd;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user