123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- /// <summary>
- /// C语言SDL程序
- /// </summary>
- #pragma once
- #include <qobject.h>
- #include <sdl/SDL.h>
- extern "C"
- {
- #include <libavcodec/avcodec.h>
- #include <libavformat/avformat.h>
- #include <libswscale/swscale.h>
- #include <libavdevice/avdevice.h>
- #include <libavutil/opt.h>
- #include <libavfilter/avfilter.h>
- #include <libavfilter/buffersrc.h>
- #include <libavfilter/buffersink.h>
- #include <libavutil/imgutils.h>
- #include <libavutil/frame.h>
- };
- 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 };
- };
|