From 7e1e36784448845c858e2cf16b3bcfdde84595e8 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 29 Dec 2019 17:14:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96FFmpeg=E6=8B=89=E6=B5=81?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=87=8D=E8=AF=95=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/FFmpegSource.cpp | 6 +++++- server/FFmpegSource.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/FFmpegSource.cpp b/server/FFmpegSource.cpp index 2ea621a8..e76df0ed 100644 --- a/server/FFmpegSource.cpp +++ b/server/FFmpegSource.cpp @@ -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 { diff --git a/server/FFmpegSource.h b/server/FFmpegSource.h index f71091da..a11144d7 100644 --- a/server/FFmpegSource.h +++ b/server/FFmpegSource.h @@ -70,6 +70,7 @@ private: string _dst_url; function _onClose; std::weak_ptr _listener; + Ticker _replay_ticker; };