mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-26 03:42:21 +08:00
整理代码
This commit is contained in:
@@ -733,28 +733,12 @@ void RtspPlayer::onRecvRTP_l(const RtpPacket::Ptr &rtp, const SdpTrack::Ptr &tra
|
||||
}
|
||||
|
||||
void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshakeCompleted) {
|
||||
WarnL << ex.getErrCode() << " " << ex.what();
|
||||
|
||||
if(!ex){
|
||||
//播放成功,恢复rtp接收超时定时器
|
||||
_rtp_recv_ticker.resetTime();
|
||||
weak_ptr<RtspPlayer> weakSelf = dynamic_pointer_cast<RtspPlayer>(shared_from_this());
|
||||
int timeoutMS = (*this)[kMediaTimeoutMS].as<int>();
|
||||
//创建rtp数据接收超时检测定时器
|
||||
_rtp_check_timer.reset(new Timer(timeoutMS / 2000.0, [weakSelf,timeoutMS]() {
|
||||
auto strongSelf=weakSelf.lock();
|
||||
if(!strongSelf) {
|
||||
return false;
|
||||
}
|
||||
if(strongSelf->_rtp_recv_ticker.elapsedTime() > timeoutMS) {
|
||||
//接收rtp媒体数据包超时
|
||||
strongSelf->onPlayResult_l(SockException(Err_timeout,"receive rtp timeout"), true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, getPoller()));
|
||||
if (ex.getErrCode() == Err_shutdown) {
|
||||
//主动shutdown的,不触发回调
|
||||
return;
|
||||
}
|
||||
|
||||
WarnL << ex.getErrCode() << " " << ex.what();
|
||||
if (!handshakeCompleted) {
|
||||
//开始播放阶段
|
||||
_play_check_timer.reset();
|
||||
@@ -769,7 +753,26 @@ void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshakeComplete
|
||||
onResume();
|
||||
}
|
||||
|
||||
if(ex){
|
||||
if (!ex) {
|
||||
//播放成功,恢复rtp接收超时定时器
|
||||
_rtp_recv_ticker.resetTime();
|
||||
int timeoutMS = (*this)[kMediaTimeoutMS].as<int>();
|
||||
weak_ptr<RtspPlayer> weakSelf = dynamic_pointer_cast<RtspPlayer>(shared_from_this());
|
||||
auto lam = [weakSelf, timeoutMS]() {
|
||||
auto strongSelf = weakSelf.lock();
|
||||
if (!strongSelf) {
|
||||
return false;
|
||||
}
|
||||
if (strongSelf->_rtp_recv_ticker.elapsedTime() > timeoutMS) {
|
||||
//接收rtp媒体数据包超时
|
||||
strongSelf->onPlayResult_l(SockException(Err_timeout, "receive rtp timeout"), true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
//创建rtp数据接收超时检测定时器
|
||||
_rtp_check_timer = std::make_shared<Timer>(timeoutMS / 2000.0, lam, getPoller());
|
||||
} else {
|
||||
teardown();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user