FFNvDecoder.h
2.12 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
106
107
#include<string>
#include <pthread.h>
#include <mutex>
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>
#include <libavutil/imgutils.h>
}
#include "common_header.h"
#include "../interface/AbstractDecoder.h"
using namespace std;
class FFNvDecoder : public AbstractDecoder {
public:
FFNvDecoder();
~FFNvDecoder();
bool init(FFDecConfig& cfg);
void close();
bool start();
void pause();
void resume();
void setDecKeyframe(bool bKeyframe);
bool isRunning();
bool isFinished();
bool isPausing();
bool getResolution( int &width, int &height );
bool isSurport(FFDecConfig& cfg);
int getCachedQueueLength();
float fps();
DECODER_TYPE getDecoderType(){ return DECODER_TYPE_FFMPEG; }
FFImgInfo* snapshot();
void setName(string nm){
m_dec_name = nm;
}
string getName(){
return m_dec_name;
}
void setPostDecArg(const void* postDecArg);
void setFinishedDecArg(const void* finishedDecArg);
public:
AVPixelFormat getHwPixFmt();
private:
void decode_thread();
void post_decode_thread();
bool init(const char* uri, const char* gpuid, bool force_tcp);
void decode_finished();
DeviceRgbMemory* convert2bgr(AVFrame * gpuFrame);
private:
string m_dec_name;
FFDecConfig m_cfg;
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;
bool m_bFinished;
bool m_bPause;
bool m_bReal; // 是否实时流
float m_fps;
queue<AVFrame*> mFrameQueue;
mutex m_queue_mutex;
mutex m_snapshot_mutex;
long m_index{0};
bool m_dec_keyframe;
const void * m_postDecArg;
POST_DECODE_CALLBACK post_decoded_cbk; // 解码数据回调接口
const void * m_finishedDecArg;
DECODE_FINISHED_CALLBACK decode_finished_cbk;
};