From 7950b86a4bf821e126d5e5659b772ce32faa1445 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期二, 25 五月 2021 11:32:24 +0800
Subject: [PATCH] bug fixed declaration

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

diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp
index a46886b..4b6bd93 100644
--- a/csrc/wrapper.cpp
+++ b/csrc/wrapper.cpp
@@ -45,6 +45,7 @@
     ,audio_(false)
     ,gb_(0)
     ,cpu_(0)
+    ,devid_(-1)
     ,run_dec_(false)
     ,run_stream_(true)
     ,run_rec_(false)
@@ -66,6 +67,7 @@
     ,audio_(false)
     ,gb_(0)
     ,cpu_(0)
+    ,devid_(-1)
     ,run_dec_(false)
     ,run_stream_(true)
     ,run_rec_(false)
@@ -108,8 +110,9 @@
         prop.url_ = input;
         prop.rtsp_tcp_ = true;
         prop.gpu_acc_ = !cpu_;
+        prop.gpu_index_ = devid_;
 
-    	std::unique_ptr<FormatIn> in(new FormatIn(prop.gpuAccl()));
+    	std::unique_ptr<FormatIn> in(new FormatIn(prop, prop.gpuAccl()));
     	int flag = -1;
         if (gb_){
             flag = in->openGb28181(input, NULL);
@@ -222,7 +225,7 @@
 
             bool exist = access(input_url_.c_str(), 0) == 0;
             if (exist){
-                wTime <<= 1;
+                wTime += wTime/2;
                 file_rebootime++;
             }
 
@@ -259,10 +262,10 @@
                 id++;
 
                 //鏈湴鏂囦欢澶揩sleep涓�涓�
-                if (exist){
-                    usleep(wTime);
+                if (exist && in->isVideoPkt(&data->getAVPacket())){
                     // 璁板綍瑙g爜鐨勬枃浠舵湁澶氬皯甯�
                     file_frame++;
+                    usleep(wTime);
                 }
 
             }
@@ -271,13 +274,17 @@
             if (exist) {
                 // 涓夋涓�甯ч兘娌¤В鍑烘潵锛岄��鍑�
                 if (file_frame == 0 && file_rebootime < 3){
+                    logIt("libcffmpeg.so-> run %lld time, current frames %lld", file_rebootime, file_frame);
                     continue;
                 }
                 // 鏈�灏忛渶瑕佽В鍑哄灏戝抚
                 if (file_frame < min_duration_ * fps_){
+                    logIt("libcffmpeg.so-> run %lld time, current frames %lld, mind %d, fps: %d",
+                     file_rebootime, file_frame, min_duration_, fps_);
                     continue;
                 }
-                logIt("libcffmpeg.so-> local file %s run %lld time, all frames %lld", input_url_.c_str(), file_rebootime, file_frame);
+                logIt("libcffmpeg.so-> local file %s run %lld time, all frames %lld, mind %d, fps: %d", 
+                    input_url_.c_str(), file_rebootime, file_frame, min_duration_, fps_);
                 file_finished_ = true;
                 break;
             }
@@ -446,7 +453,7 @@
         return flag;
     }
 
-    int GetGb28181Pic(const char *rtspUrl, char *retData, int *retDataLen){
+    int GetGb28181Pic(const char *rtspUrl, char *retData, int *retDataLen, const int tt){
         int ret = 0;
         std::string fn = rtspUrl;
 
@@ -457,7 +464,7 @@
             return -1;
         }
 
-        int retLen = handle_gb28181->capturePic(handle_gb28181, retData, retDataLen);
+        int retLen = handle_gb28181->capturePic(handle_gb28181, retData, retDataLen, tt);
         if(retLen == 0){
             logIt("do capturePic failed:%d");
             ret = -1;

--
Gitblit v1.8.0