From d0fc37db65da5f6be4eff2159adf7ab7c5de42bf Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 8 Jun 2020 15:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DFFmpeg=E6=8E=A8=E6=B5=81?= =?UTF-8?q?=E7=BB=99=E7=AC=AC=E4=B8=89=E6=96=B9=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E9=87=8D=E8=AF=95=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/FFmpegSource.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/FFmpegSource.cpp b/server/FFmpegSource.cpp index 0ed137a2..50492f22 100644 --- a/server/FFmpegSource.cpp +++ b/server/FFmpegSource.cpp @@ -196,7 +196,19 @@ void FFmpegSource::startTimer(int timeout_ms) { //推流给其他服务器的,我们通过判断FFmpeg进程是否在线,如果FFmpeg推流中断,那么它应该会自动退出 if (!strongSelf->_process.wait(false)) { //ffmpeg不在线,重新拉流 - strongSelf->play(strongSelf->_src_url, strongSelf->_dst_url, timeout_ms, [](const SockException &) {}); + strongSelf->play(strongSelf->_src_url, strongSelf->_dst_url, timeout_ms, [weakSelf](const SockException &ex) { + if(!ex){ + //没有错误 + return; + } + auto strongSelf = weakSelf.lock(); + if (!strongSelf) { + //自身已经销毁 + return; + } + //上次重试时间超过10秒,那么再重试FFmpeg拉流 + strongSelf->startTimer(10 * 1000); + }); } } return true;