SfxDecoder.h
3.14 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
#ifndef __SFX__SfxDecoder__MODULE__
#define __SFX__SfxDecoder__MODULE__
#include "SfxStreamHandlerInterface.h"
#include <string>
using namespace std;
typedef enum DxLogLevel
{
DX_LOG_LEVEL_UNKNOW = 0, // 未知日志等级
DX_LOG_LEVEL_INFO, // 普通日志信息 (如:无关紧要的信息输出)
DX_LOG_LEVEL_IMPORTANT, // 重要的日志通知,模块一切正常(如:重要流程通知)
DX_LOG_LEVEL_WARNING, // 警告日志,即将可能发生致命错误(如:资源不足)
DX_LOG_LEVEL_FATAL, // 致命错误,模块将停止工作(如:网络断开)
DX_LOG_LEVEL_CLEANUP // 此模块已退出所有线程、流程,不再执行任何代码,
// 通常通过该日志等级回调,实现在回调内释放模块自身
// 本日志等级在模块生命周期内只会发生一次调用
}DxLogLevel;
typedef int (*DxLogHandler)( const void * userPtr, DxLogLevel level, const char * log, unsigned int logLen );
typedef void(*LOG_ALL_CALLBACK)(const void * userPtr, int log_level, const char* log, unsigned int logLen);
typedef void (*DXDECODER_CALLBACK)( const void * userPtr, void * buf, unsigned int size, int width, int height, unsigned long long timestamp );
typedef struct DxDecoderConfig
{
DxLogHandler logcbk; // 日志回调接口
LOG_ALL_CALLBACK log_all{ nullptr };
void* log_user_ptr{nullptr};
const void * userPtr; // 用户数据
DXDECODER_CALLBACK escbk; // 解码后帧数据回调接口
int devId;
string uri;
string dec_name;
}DxDecoderConfig;
typedef struct DxVideoConfig // 视频相关配置信息,根据实际应用,填充部分或全部数据
{
float minQP; // 编码时最小量化步长(仅在打开编码器时填充)
float maxQP; // 编码时最大量化步长(仅在打开编码器时填充)
int width; // 图像宽度值
int height; // 图像高度值
int gopSize; // 视频流GOP大小(仅在打开编码器时填充)
//DxCodecType codec; // 视频编解码器类型
unsigned int frame_count{1};
}DxVideoConfig;
class SfxDecoder
{
public:
SfxDecoder();
~SfxDecoder();
bool OpenDecoder(DxDecoderConfig& cfg);
bool isFinished();
int CloseDecoder();
unsigned int GetFrameCount();
public:
DxVideoConfig m_video;
SfxStreamHandlerInterface * m_handler;
string m_dec_name;
private:
static sfx_32 sfx_stdcall SfxStreamCallback(
const sfx_void * userPtr,
SfxFrameType type,
const sfx_u8 * buf,
sfx_u32 segLen,
sfx_u32 len,
sfx_u32 timestamp
);
static sfx_32 sfx_stdcall SfxLogDefaultHandler(
const sfx_void * userPtr,
SfxLogLevel level,
const sfx_8 * log,
sfx_u32 logLen
);
private:
DxDecoderConfig m_cfg;
sfx_bool m_bRun;
bool m_bReal{false};
};
#endif