From 24627225c21738ec4f0737da536874e99d58d6ac Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期四, 19 九月 2019 18:01:29 +0800 Subject: [PATCH] update --- csrc/ffmpeg/format/FormatIn.cpp | 45 ++++++++++++++++++++++++++++----------------- 1 files changed, 28 insertions(+), 17 deletions(-) diff --git a/csrc/ffmpeg/format/FormatIn.cpp b/csrc/ffmpeg/format/FormatIn.cpp index 81d6c5f..603fe96 100644 --- a/csrc/ffmpeg/format/FormatIn.cpp +++ b/csrc/ffmpeg/format/FormatIn.cpp @@ -21,7 +21,6 @@ #include "../data/FrameData.hpp" #include "../../common/gpu/info.h" -#include "PsToEs.hpp" using namespace logif; @@ -34,13 +33,18 @@ ,io_ctx_(NULL) ,read_io_buff_(NULL) ,read_io_buff_size_(32768) + ,handle_gb28181(NULL) {} FormatIn::~FormatIn() { if(io_ctx_){ - free(read_io_buff_); - avio_close(io_ctx_); + if(read_io_buff_){ + // av_free(read_io_buff_); + read_io_buff_ = NULL; + } + avio_context_free(&io_ctx_); + io_ctx_ = NULL; } if(ctx_){ avformat_close_input(&ctx_); @@ -48,7 +52,11 @@ ctx_ = NULL; if(dec_ctx_){ avcodec_close(dec_ctx_); + dec_ctx_ = NULL; } + } + if (handle_gb28181){ + delete handle_gb28181; } } @@ -85,19 +93,23 @@ int FormatIn::openGb28181(const char *filename, AVDictionary **options){ std::string fn = filename; - addCamera(fn); + //GB28181API gb28181(fn); + if (handle_gb28181){ + delete handle_gb28181; + } + handle_gb28181 = new GB28181API; + handle_gb28181->addCamera(fn); - int ret = openWithCustomIO(NULL, readData, options); + int ret = openWithCustomIO(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; } @@ -106,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; } @@ -253,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