From 9792631e9d038ac34e287323961b78cc3d470873 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期二, 24 九月 2019 17:18:11 +0800
Subject: [PATCH] bug fix

---
 csrc/worker/decoder.cpp |   60 ------------------------------------------------------------
 1 files changed, 0 insertions(+), 60 deletions(-)

diff --git a/csrc/worker/decoder.cpp b/csrc/worker/decoder.cpp
index 4211b41..ae3eb13 100644
--- a/csrc/worker/decoder.cpp
+++ b/csrc/worker/decoder.cpp
@@ -3,7 +3,6 @@
 #include "../ffmpeg/bridge/cvbridge.hpp"
 #include "../ffmpeg/format/FormatIn.hpp"
 #include "../ffmpeg/data/CodedData.hpp"
-#include "../ffmpeg/data/FrameData.hpp"
 #include "../ffmpeg/log/log.hpp"
 
 extern "C"{
@@ -24,24 +23,12 @@
     ,conv_h_(h)
     ,conv_flag_(f)
     ,decRef_(dec)
-    ,thread_(nullptr)
-    ,stop_{false}
     {}
     
     decoder::~decoder(){
-        if (thread_){
-            stop_.store(true);
-            thread_->join();
-        }
 
         if (conv_){
             delete conv_;
-        }
-
-        
-        {
-            std::lock_guard<std::mutex> l(mutex_pkt_);
-            list_pkt_.clear();
         }
 
         {
@@ -102,57 +89,11 @@
         return list_pic_.size();
     }
 
-    void decoder::Start(){
-        if (thread_) return;
-        thread_.reset(new std::thread([&]{
-            if (initDecoder() != 0) {
-                return;
-            }
-
-            while(!stop_.load()){
-
-                std::unique_lock<std::mutex> locker(mutex_pkt_);
-                cv_.wait(locker, [&]{
-                    return !list_pkt_.empty() || stop_.load();
-                });
-                if (stop_.load()){
-                    break;
-                }
-
-                auto pkt = list_pkt_.front();
-                list_pkt_.pop_front();
-
-                AVFrame *frame = av_frame_alloc();
-                AVPacket np(pkt.data->getAVPacket());
-                av_copy_packet(&np, &pkt.data->getAVPacket());
-
-                auto ret = decRef_->decode(frame, &np);
-                av_packet_unref(&np);
-                
-                if (ret == 0){
-                    saveFrame(frame, pkt.id);
-                }
-                av_frame_free(&frame);
-            }
-
-        }));
-    }
-
     int decoder::SetFrame(std::shared_ptr<ffwrapper::CodedData> data, int64_t &id){
 
         if (!data) return -1;
         if (decRef_->isAudioPkt(&data->getAVPacket())) return -2;
         
-        // if (!thread_){
-        //     if (initDecoder() != 0) return -3;
-        //     Start();
-        // }
-
-        // std::lock_guard<std::mutex> l(mutex_pkt_);
-        // list_pkt_.push_back({data, id});
-        // cv_.notify_one();
-        // return list_pkt_.size();
-
         if (!conv_){
             if (initDecoder() != 0) return -3;
         }
@@ -167,7 +108,6 @@
             saveFrame(frame, id);
         }
         av_frame_free(&frame);
-
     }
 
     void decoder::GetFrame(unsigned char **data, int *w, int *h, int64_t *id){

--
Gitblit v1.8.0