DxDecoderWrap.h
2.02 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef __DX__DxDecoderWrap__
#define __DX__DxDecoderWrap__
#include <memory>
#include <queue>
#include <string>
#include <mutex>
#include "cuda_kernels.h"
#include "SfxDecoder.h"
#define DX_GPU_FRAME_DEFAULT_SIZE 1
using namespace std;
typedef struct DxConfig
{
int devId; // 设备(GPU)ID
int decMode; // 解码模式: 0 全解码; 1 关键帧解码
int colorFmt; // 颜色空间
bool forceTcp; // 对于实时流,是否强制为TCP取流
std::string name;
int skip_frame;
string uri;
}DxConfig;
typedef struct DxGPUFrame
{
void * frame {nullptr};
unsigned int size;
unsigned int width;
unsigned int height;
unsigned long long timestamp;
std::string dec_name;
}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();
virtual ~DxDecoderWrap();
int DxOpenDecoder(const DxConfig& cfg);
int DxCloseDecoder();
bool DxDecoderIsRun() const;
bool DxDecoderIsFinished();
unsigned int DxGetFrameCount();
int DxGetResolution( int &width, int &height );
bool DxFrameIsEmpty();
int DxLockFrame(DxGPUFrame& frame );
DxGPUFrame DxGetFrame();
int PauseDecoder();
int ResumeDecoder();
public:
string GetName() {return m_name;};
bool isStream(string sVideoFileName);
void DxCUDADecoderCallback(void * buf, unsigned int size, int width, int height, unsigned long long timestamp );
int DxDecoderLogCallback(DxLogLevel level, const char * log, unsigned int logLen );
private:
bool m_bReal;
bool m_bRun;
bool m_bPause;
unsigned int m_nums;
string m_name;
SfxDecoder* m_pDec;
std::queue<DxGPUFrame> m_queue_frames;
std::mutex m_queue_frames_mutex;
unsigned int m_skip;
int m_devId;
int m_width{0};
int m_height{0};
};
#endif