CVideo.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "WallpaperEngine/Core/CVideo.h"
  3. #include "WallpaperEngine/Render/CWallpaper.h"
  4. extern "C"
  5. {
  6. #include <libavcodec/avcodec.h>
  7. #include <libavformat/avformat.h>
  8. #include <libavutil/imgutils.h>
  9. #include <libswscale/swscale.h>
  10. }
  11. namespace WallpaperEngine::Render
  12. {
  13. class CVideo : public CWallpaper
  14. {
  15. public:
  16. CVideo (Core::CVideo* video, CContainer* container);
  17. void render () override;
  18. Core::CVideo* getVideo ();
  19. protected:
  20. friend class CWallpaper;
  21. static const std::string Type;
  22. private:
  23. void setSize (int width, int height);
  24. void restartStream ();
  25. void getNextFrame ();
  26. void writeFrameToImage ();
  27. AVFormatContext* m_formatCtx = nullptr;
  28. AVCodecContext* m_codecCtx = nullptr;
  29. AVFrame* m_videoFrame = nullptr;
  30. AVFrame* m_videoFrameRGB = nullptr;
  31. SwsContext* m_swsCtx = nullptr;
  32. uint8_t* m_buffer = nullptr;
  33. int m_videoStream = -1, m_audioStream = -1;
  34. };
  35. };