DxDecoderWrap.h
1.65 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef __DX__DxDecoderWrap__
#define __DX__DxDecoderWrap__
#include <memory>
#include <queue>
#include <string>
#include <mutex>
#include "cuda_kernels.h"
#include "FFNvDecoder.h"
#define DX_GPU_FRAME_DEFAULT_SIZE 1
typedef struct DxConfig
{
int devId; // 设备(GPU)ID
int decMode; // 解码模式: 0 全解码; 1 关键帧解码
int colorFmt; // 颜色空间
bool forceTcp; // 对于实时流,是否强制为TCP取流
std::string name;
}DxConfig;
typedef struct DxGPUFrame
{
void * frame;
unsigned int size;
unsigned int width;
unsigned int height;
unsigned long long timestamp;
}DxGPUFrame;
typedef struct DxGPUFrames
{
unsigned int size;
unsigned int read;
unsigned int write;
unsigned int width;
unsigned int height;
unsigned int counts;
DxGPUFrame * frames;
}DxGPUFrames;
class DxDecoderWrap
{
public:
DxDecoderWrap( const DxConfig * cfg );
virtual ~DxDecoderWrap();
int DxOpenDecoder( const char * uri, unsigned int skip );
int DxCloseDecoder();
bool DxDecoderIsRun() const;
int DxGetFrameCount();
int DxGetResolution( int &width, int &height );
bool DxFrameIsEmpty();
int DxLockFrame(DxGPUFrame& frame );
int PauseDecoder();
int ResumeDecoder();
public:
string GetName() {return m_name;};
void post_decode_callback(GPUFrame * gpuFrame);
void decode_finished_callback();
private:
bool m_bClose;
FFDecConfig m_cfg;
string m_name;
FFNvDecoder* m_pDec;
std::queue<DxGPUFrame> m_queue_frames;
std::mutex m_queue_frames_mutex;
int m_decMode{0};
};
#endif