///
/// C语言SDL程序
///
#pragma once
#include
#include
extern "C"
{
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
};
class SDL_Window;
class SDL_Renderer;
class SDL_Texture;
class SwsContext;
class AVFrame;
struct _TTF_Font;
class SDL_Rect;
class CSdlProc
{
public:
CSdlProc();
~CSdlProc();
public:
bool Init(void * pWnd, int nVideoWidth, int nVideoHeight, bool bHard);
void DisplayFrame(AVFrame *pFrame);
void DisplayFrame(uint8_t *pData, int nWidth, int nHeight);
void SetRect(int nOffset_x, int nOffset_y, int nWidth, int nHeight);
void Destroy();
SDL_Window* GetWindow()
{
return m_screen;
};
static void SetUseDispalyArea(bool bUseDispalyArea);
void SetDispalyAreaFalse()
{
m_bDisplayArea = false;
}
void UpdateAreaPoint(const QPoint &ptArea)
{
m_ptArea = ptArea;
}
void UpdateAreaRect(const QPoint &ptlt, const QPoint &ptbr)
{
m_ptlt = ptlt;
m_ptbr = ptbr;
}
void SetDispalyRect(bool b)
{
m_bDisplayRect = b;
}
void UpdateAreaText(const std::string &strText)
{
m_strText = strText;
}
void DisplayReconn();
private:
void DisplayChooseArea(const QPoint& pt);
void DisplayChooseAreaRect(const QPoint& ptlt, const QPoint& ptbr);
private:
//sdl显示需要成员
SDL_Window *m_screen{nullptr};
SDL_Renderer* m_sdlRenderer{ nullptr };
SDL_Texture* m_sdlTexture{ nullptr };
SDL_Rect * m_sdlRect { nullptr };
SwsContext *m_img_convert_ctx{ nullptr };
AVFrame *m_pFrameYUV{ nullptr };
uint8_t *m_out_buffer{ nullptr };
QPoint m_ptArea{400,200};
std::string m_strText{"X1"};
_TTF_Font *m_pFont{nullptr};
//全局设置
static bool m_bUseDispalyArea;
//对于全景,不显示通过m_bDisplayArea判断
bool m_bDisplayArea{true};
QPoint m_ptlt{ 200,200 };
QPoint m_ptbr{ 400,300 };
bool m_bDisplayRect{ false };
};