mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-29 22:55:52 +08:00
优化FFmpeg拉流失败重试机制
This commit is contained in:
parent
4d42459004
commit
7e1e367844
@ -192,8 +192,12 @@ void FFmpegSource::startTimer(int timeout_ms) {
|
|||||||
//同步查找流
|
//同步查找流
|
||||||
if (!src) {
|
if (!src) {
|
||||||
//流不在线,重新拉流
|
//流不在线,重新拉流
|
||||||
|
if(strongSelf->_replay_ticker.elapsedTime() > 10 * 1000){
|
||||||
|
//上次重试时间超过10秒,那么再重试FFmpeg拉流
|
||||||
|
strongSelf->_replay_ticker.resetTime();
|
||||||
strongSelf->play(strongSelf->_src_url, strongSelf->_dst_url, timeout_ms, [](const SockException &) {});
|
strongSelf->play(strongSelf->_src_url, strongSelf->_dst_url, timeout_ms, [](const SockException &) {});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
//推流给其他服务器的,我们通过判断FFmpeg进程是否在线,如果FFmpeg推流中断,那么它应该会自动退出
|
//推流给其他服务器的,我们通过判断FFmpeg进程是否在线,如果FFmpeg推流中断,那么它应该会自动退出
|
||||||
|
@ -70,6 +70,7 @@ private:
|
|||||||
string _dst_url;
|
string _dst_url;
|
||||||
function<void()> _onClose;
|
function<void()> _onClose;
|
||||||
std::weak_ptr<MediaSourceEvent> _listener;
|
std::weak_ptr<MediaSourceEvent> _listener;
|
||||||
|
Ticker _replay_ticker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user