Commit 7e1e3678 by xiongziliang

优化FFmpeg拉流失败重试机制

parent 4d424590
......@@ -192,7 +192,11 @@ void FFmpegSource::startTimer(int timeout_ms) {
//同步查找流
if (!src) {
//流不在线,重新拉流
strongSelf->play(strongSelf->_src_url, strongSelf->_dst_url, timeout_ms, [](const SockException &) {});
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 &) {});
}
}
});
} else {
......
......@@ -70,6 +70,7 @@ private:
string _dst_url;
function<void()> _onClose;
std::weak_ptr<MediaSourceEvent> _listener;
Ticker _replay_ticker;
};
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论