From 6de0bbb3eb860934bbe1c5e53a7ff02b8c0844f5 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期六, 19 十月 2019 10:44:37 +0800
Subject: [PATCH] udpate

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

diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp
index 058e499..fe6d576 100644
--- a/csrc/wrapper.cpp
+++ b/csrc/wrapper.cpp
@@ -2,6 +2,7 @@
 
 #include <thread>
 #include <unistd.h>
+#include <sys/time.h>
 
 extern "C"{
 #include <libavformat/avformat.h>
@@ -196,6 +197,8 @@
             init_worker(in.get());
 
             int64_t id = gb_ ? 0 : -1;
+            
+            bool exist = access(input_url_.c_str(), 0) == 0 ? true : false;
 
             while(!stop_stream_.load()){
                 auto data(std::make_shared<CodedData>());
@@ -203,20 +206,23 @@
                     logIt("read packet error, id: %lld", id);
                     break;
                 }
-
                 if (in->notVideoAudio(&data->getAVPacket())){
                     continue;
                 }
-                
+
                 if (!gb_ && id < 0){
                     id++;
                     continue;
                 }
+
     	        // decode error
                 if (run_worker(in.get(), data, id) == -1){
                     break;
                 }
-                // usleep(wTime);
+
+                if (exist){
+                    usleep(wTime);
+                }
 
                 id++;
             }
@@ -228,7 +234,7 @@
     void Wrapper::SetRecMinCacheTime(const int mind){
         rec_->SetRecMinCacheTime(mind);
     }
-    
+
     void Wrapper::BuildRecorder(const char* id, const char *output, const int mindur, const int maxdur, const bool audio){
         bool a = audio;
         if (gb_) a = false;

--
Gitblit v1.8.0