From 48ced28c279469fd57147cf59419c9655a73c5d4 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期三, 18 九月 2019 09:59:53 +0800
Subject: [PATCH] update

---
 csrc/ffmpeg/format/FormatIn.cpp |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/csrc/ffmpeg/format/FormatIn.cpp b/csrc/ffmpeg/format/FormatIn.cpp
index b0a577b..3e9dd51 100644
--- a/csrc/ffmpeg/format/FormatIn.cpp
+++ b/csrc/ffmpeg/format/FormatIn.cpp
@@ -33,6 +33,7 @@
 	,io_ctx_(NULL)
 	,read_io_buff_(NULL)
 	,read_io_buff_size_(32768)
+	,handle_gb28181(NULL)
 	{}
 
 	FormatIn::~FormatIn()
@@ -53,6 +54,9 @@
 				avcodec_close(dec_ctx_);
 				dec_ctx_ = NULL;
 			}
+		}
+		if (handle_gb28181){
+			delete handle_gb28181;
 		}
 	}
 
@@ -90,19 +94,22 @@
 
 	    std::string fn = filename;
 		//GB28181API gb28181(fn);
-		handle_gb28181.addCamera(fn);
+		if (handle_gb28181){
+			delete handle_gb28181;
+		}
+		handle_gb28181 = new GB28181API;
+		handle_gb28181->addCamera(fn);
 
-        int ret = openWithCustomIO((void *)&handle_gb28181, handle_gb28181.readData, options);
+        int ret = openWithCustomIO((void *)&handle_gb28181, handle_gb28181->readData, options);
         if(ret < 0){
             logIt("do openWithCustomIO failed:%d",ret);
         }
 
         ret = avformat_open_input(&ctx_, "", NULL, options);
-        if(ret < 0){
-            logIt("open %s failed:%s",filename,
-                  getAVErrorDesc(ret).c_str());
-
-        }
+        // if(ret < 0){
+            // logIt("open %s failed:%s",filename,
+            //       getAVErrorDesc(ret).c_str());
+        // }
 
 		return ret;
 	}
@@ -111,11 +118,10 @@
 	int FormatIn::open(const char *filename, AVDictionary **options){
 
 		const int ret = avformat_open_input(&ctx_, filename, NULL, options);
-		if(ret < 0){
-			logIt("open %s failed:%s",filename,
-					getAVErrorDesc(ret).c_str()); 
-
-		}
+		// if(ret < 0){
+		// 	logIt("open %s failed:%s",filename,
+		// 			getAVErrorDesc(ret).c_str()); 
+		// }
 
 		return ret;
 	}
@@ -258,8 +264,8 @@
 		while (!founded){
 			const int ret = av_read_frame(ctx_, &pkt_out);
 			if(ret < 0){
-				logIt("read frame from %s failed:%s",
-						ctx_->filename,getAVErrorDesc(ret).c_str()); 
+				// logIt("read frame from %s failed:%s",
+				// 		ctx_->filename,getAVErrorDesc(ret).c_str()); 
 	
 				return false;
 			}

--
Gitblit v1.8.0