video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-07-26 bfded635a544a1ab5d252739f4be4f7f30b39b7f
csrc/wrapper.cpp
@@ -246,37 +246,42 @@
            func_rec_(path, index);
        }else{                  // passive api
            std::lock_guard<std::mutex> l(mutex_rec_);
            while(list_rec_.size() > 10){
                for(int i = 0; i < 5; i++){
            while(list_rec_.size() > 100){
                for(int i = 0; i < 25; i++){
                    list_rec_.pop_front();
                }
            }
            struct record_file_info info;
            info.id = id;
            info.file_frame_index = index;
            info.file_path = path;
            list_rec_.emplace_back(info);
            list_rec_map_[path] = id;
            logIt("list rec files count : %d", list_rec_.size());
            map_rec_.erase(id);
        }
    }
    void Wrapper::GetInfoRecorder(std::string &sid, int &index, std::string &path){
    void Wrapper::GetInfoRecorder(int &index, std::string &path){
        std::lock_guard<std::mutex> l(mutex_rec_);
        if(list_rec_.empty()){
            index = -1;
            path = "";
            sid = "";
            return;
        }
        auto info = list_rec_.front();
        index = info.file_frame_index;
        path = info.file_path;
        sid = info.id;
        list_rec_.pop_front();
        // logIt("go get info index: %d, file: %s\n", index, path.c_str());
    }
    std::string Wrapper::GetRecorderID(const std::string &path){
        auto iter = list_rec_map_.find(path);
        if (iter != list_rec_map_.end()){
            return iter->second;
        }
        return "";
    }
    ////////decoder
    void Wrapper::BuildDecoder(){
        use_decoder_ = true;