CVideo.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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, CContext* context);
  17. Core::CVideo* getVideo ();
  18. int getWidth ();
  19. int getHeight ();
  20. protected:
  21. void renderFrame (glm::vec4 viewport) override;
  22. friend class CWallpaper;
  23. static const std::string Type;
  24. private:
  25. void setSize (int width, int height);
  26. void restartStream ();
  27. void getNextFrame ();
  28. void writeFrameToImage ();
  29. void setupShaders ();
  30. AVFormatContext* m_formatCtx = nullptr;
  31. AVCodecContext* m_codecCtx = nullptr;
  32. AVFrame* m_videoFrameRGB = nullptr;
  33. AVFrame* m_videoFrame = nullptr;
  34. SwsContext* m_swsCtx = nullptr;
  35. uint8_t* m_buffer = nullptr;
  36. int m_videoStream = -1, m_audioStream = -1;
  37. /**
  38. * The texture used for the video output
  39. */
  40. GLuint m_texture;
  41. GLuint m_texCoordBuffer;
  42. GLuint m_positionBuffer;
  43. GLuint m_shader;
  44. // shader variables
  45. GLint g_Texture0;
  46. GLint a_Position;
  47. GLint a_TexCoord;
  48. };
  49. };