video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-10-10 b35d0da3fb4ceec328286851d0e2b316872ab04a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _cffmpeg_decoder_hpp_
#define _cffmpeg_decoder_hpp_
 
#include <stdint.h>
#include <memory>
#include <list>
#include <mutex>
#include <thread>
#include <atomic>
#include <condition_variable>
 
struct AVFrame;
struct AVCodecContext;
 
namespace ffwrapper
{
    class FormatIn;
    class CodedData;
} // namespace ffwrapper
 
namespace cffmpeg_wrap
{
    typedef struct _frm{
        uint8_t *data;
        int length;
        int width;
        int height;
        int format;
        int64_t id;
    }FRM;
 
    class decoder
    {
    private:
 
        ffwrapper::FormatIn *decRef_;
 
        std::list<FRM> list_frm_;
        std::mutex mutex_frm_;
        
    private:
        int initDecoder();
        int saveFrame(AVFrame *frame, int64_t &id);
    public: 
        void Start();
        int SetFrame(std::shared_ptr<ffwrapper::CodedData> data, int64_t &id);
        void GetFrame(unsigned char **data, int *w, int *h, int *format, int *length, int64_t *id);
    
    public:
        explicit decoder(ffwrapper::FormatIn *dec);
        ~decoder();
    };
    
} // namespace cffmpeg_wrap
 
 
#endif