Blame view

src/FFNvDecoder.h 2.04 KB
aac5773f   hucm   功能基本完成,接口待打磨
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  #include<string>
  #include <pthread.h>
  
  #include "FrameQueue.h"
  
  extern "C"
  {
  	#include <libavcodec/avcodec.h> 
  	#include <libavdevice/avdevice.h> 
  	#include <libavformat/avformat.h> 
  	#include <libavfilter/avfilter.h> 
  	#include <libavutil/avutil.h> 
      #include <libavutil/pixdesc.h> 
  	#include <libswscale/swscale.h>
  }
  
  using namespace std;
  
  /**************************************************
  * 接口:DXDECODER_CALLBACK
  * 功能:解码数据回调接口
  * 参数:const dx_void * userPtr 用户自定义数据
0b43216c   Hu Chunming   添加重要注释
23
  *       AVFrame * gpuFrame 解码结果帧数据,在设置的对应的gpu上,要十分注意这一点,尤其是多线程情况
aac5773f   hucm   功能基本完成,接口待打磨
24
25
26
27
28
29
30
31
  * 返回:无
  * 备注:当解码库数据源为实时流时(RTSP/GB28181),本接
  *       口内不可进行阻塞/耗时操作。当解码库数据源为
  *       非实时流时(本地/网络文件),本接口可以进行
  *       阻塞/耗时操作
  **************************************************/
  typedef void(*POST_DECODE_CALLBACK)(const void * userPtr, AVFrame * gpuFrame);
  
7319ea36   Hu Chunming   多显卡设置
32
33
34
35
36
37
38
39
  struct FFDecConfig
  {
      string uri;
      POST_DECODE_CALLBACK post_decoded_cbk;
      string gpuid;
      bool force_tcp{true};
  };
  
aac5773f   hucm   功能基本完成,接口待打磨
40
41
42
43
  class FFNvDecoder{
  public:
      FFNvDecoder();
      ~FFNvDecoder();
e96e6489   Hu Chunming   优化代码;添加isRunning函数
44
      bool init(FFDecConfig& cfg);
aac5773f   hucm   功能基本完成,接口待打磨
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
      void close();
      void start();
      void pause();
      void resume();
  
      bool isRunning();
      bool getResolution( int &width, int &height );
  
      void setName(string nm);
      string getName();
  
  public:
      AVPixelFormat getHwPixFmt();
  
  private:
      void decode_thread();
      void post_decode_thread();
e96e6489   Hu Chunming   优化代码;添加isRunning函数
62
      bool init(const char* uri, const char* gpuid, bool force_tcp);
aac5773f   hucm   功能基本完成,接口待打磨
63
64
65
66
  
  public:
      POST_DECODE_CALLBACK post_decoded_cbk;
      const void * m_userPtr;
7319ea36   Hu Chunming   多显卡设置
67
      FFDecConfig m_cfg;
aac5773f   hucm   功能基本完成,接口待打磨
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  
  private:
      AVStream* stream;
      AVCodecContext *avctx;
      int stream_index;
      AVFormatContext *fmt_ctx;
      AVPixelFormat hw_pix_fmt;
  
      pthread_t m_decode_thread;
      pthread_t m_post_decode_thread;
      
      bool m_bRunning;
      string name;
  
      bool m_bPause;
      FrameQueue mFrameQueue;
8c180bab   hucm   添加是否实时流判断
84
85
  
      bool m_bReal; // 是否实时流
aac5773f   hucm   功能基本完成,接口待打磨
86
  };