video analysis2.0拆分,ffmpeg封装go接口库
chenshijun
2019-12-26 3c0752f11213fb14eeae9e02fd6bc14f295ed378
csrc/wrapper.cpp
@@ -47,6 +47,7 @@
    ,cpu_(0)
    ,run_dec_(false)
    ,run_stream_(true)
    ,run_rec_(false)
    ,thread_(nullptr)
    ,stop_stream_(false)
    ,stream_(nullptr)
@@ -65,6 +66,7 @@
    ,cpu_(0)
    ,run_dec_(false)
    ,run_stream_(true)
    ,run_rec_(false)
    ,thread_(nullptr)
    ,stop_stream_(false)
    ,stream_(nullptr)
@@ -170,7 +172,7 @@
        int flag = 0;
        if (run_stream_ && stream_) stream_->SetPacket(pkt);
        if (run_dec_ && decoder_) flag = decoder_->SetFrame(pkt);
        if (rec_->Loaded()) rec_->SetPacket(pkt);
        if (run_rec_ && rec_->Loaded()) rec_->SetPacket(pkt);
        return flag;
    }
@@ -251,6 +253,10 @@
        rec_->SetRecMinCacheTime(mind);
    }
    void Wrapper::OpenRecorder(){
        run_rec_ = true;
    }
    void Wrapper::BuildRecorder(const char* id, const char *output, const int64_t &fid, const int mindur, const int maxdur, const bool audio){
        bool a = audio;
        if (gb_) a = false;
@@ -275,7 +281,7 @@
        }
    }
    ////////decoder
    void Wrapper::BuildDecoder(){
    void Wrapper::OpenDecoder(){
        run_dec_ = true;
    }
@@ -397,5 +403,26 @@
        return flag;
    }
    int GetGb28181Pic(const char *rtspUrl, char *retData, int *retDataLen){
        int ret = 0;
        std::string fn = rtspUrl;
        auto handle_gb28181 = new GB28181API;
        if(handle_gb28181->addCamera(fn) == -1){
            delete(handle_gb28181);
            logIt("do addCamera Error\n");
            return -1;
        }
        int retLen = handle_gb28181->capturePic(handle_gb28181, retData, retDataLen);
        if(retLen == 0){
            logIt("do capturePic failed:%d");
            ret = -1;
        }
        handle_gb28181->deleteCamera();
        return ret;
    }
}