video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-08-19 54ea1c13885725584a6a50d520f67e8a75f85b6f
csrc/buz/recorder.cpp
@@ -3,6 +3,7 @@
#include <thread>
#include <unistd.h>
#include <chrono>
extern "C"{
#include <libavcodec/avcodec.h>
@@ -32,6 +33,7 @@
        ,file_path_("")
        ,func_rec_info_(nullptr)
        ,thrd_(nullptr)
        ,error_occured_(false)
        {
            // logIt("RECODER ID: %s", id_.c_str());
        }
@@ -41,8 +43,11 @@
            try
            {
                if (thrd_){
                    stop_recorder_.store(true);
                    cv_.notify_one();
                    {
                        std::unique_lock<std::mutex> locker(mutex_pkt_);
                        stop_recorder_.store(true);
                        cv_.notify_one();
                    }
                    thrd_->join();
                    logIt("REC THREAD JOINED, QUIT!!!");
                }
@@ -138,9 +143,15 @@
                std::list<avpacket> pkts;
                {
                    std::unique_lock<std::mutex> locker(mutex_pkt_);
                    cv_.wait(locker,[&]{
                    auto status = cv_.wait_for(locker, std::chrono::seconds(10), [&]{
                        return !list_pkt_.empty() || stop_recorder_.load();
                    });
                    if (!status){
                        end_writer();
                        error_occured_ = true;
                        break;
                    }
                    if(stop_recorder_.load()){
                        end_writer();
                        break;