From 62a465253c96a666a8dfbf099a45aeaae6c975bd Mon Sep 17 00:00:00 2001
From: 554325746@qq.com <554325746@qq.com>
Date: 星期三, 11 三月 2020 11:00:49 +0800
Subject: [PATCH] bug fixed file retry

---
 csrc/wrapper.cpp |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp
index 7ad32f1..a46886b 100644
--- a/csrc/wrapper.cpp
+++ b/csrc/wrapper.cpp
@@ -56,7 +56,7 @@
     ,logit_(false)
     ,fps_(25)
     ,file_finished_(false)
-    ,min_duration_(60)
+    ,min_duration_(0)
     {
         makeTheWorld();
     }
@@ -77,7 +77,7 @@
     ,logit_(true)
     ,fps_(25)
     ,file_finished_(false)
-    ,min_duration_(60)
+    ,min_duration_(0)
     {
         makeTheWorld();
         logif::CreateLogger(logfile, true);
@@ -193,7 +193,8 @@
 
     void Wrapper::run_stream_thread(){
         
-        int64_t rebootime = -1;
+        int64_t file_rebootime = 0;
+        int64_t file_frame = 0;
 
         while(!stop_stream_.load()){
             auto in = init_reader(input_url_.c_str());
@@ -203,8 +204,6 @@
                 sleep(2);
                 continue;
             }
-
-            rebootime++;
 
             fps_ = in->getFPS();
             
@@ -224,8 +223,8 @@
             bool exist = access(input_url_.c_str(), 0) == 0;
             if (exist){
                 wTime <<= 1;
+                file_rebootime++;
             }
-            int64_t file_frame = 0;
 
             logIt("WAIT TIME PER FRAME: %d", wTime);
 
@@ -270,14 +269,15 @@
 
             deinit_worker();
             if (exist) {
-                if (file_frame == 0 && rebootime > 3){
-                    file_finished_ = true;
-                    break;
+                // 涓夋涓�甯ч兘娌¤В鍑烘潵锛岄��鍑�
+                if (file_frame == 0 && file_rebootime < 3){
+                    continue;
                 }
+                // 鏈�灏忛渶瑕佽В鍑哄灏戝抚
                 if (file_frame < min_duration_ * fps_){
                     continue;
                 }
-                logIt("libcffmpeg.so-> local file %s run %lld time, all frames %lld", input_url_.c_str(), rebootime, file_frame);
+                logIt("libcffmpeg.so-> local file %s run %lld time, all frames %lld", input_url_.c_str(), file_rebootime, file_frame);
                 file_finished_ = true;
                 break;
             }

--
Gitblit v1.8.0