| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #pragma once
- #include "WallpaperEngine/Core/CVideo.h"
- #include "WallpaperEngine/Render/CWallpaper.h"
- extern "C"
- {
- #include <libavcodec/avcodec.h>
- #include <libavformat/avformat.h>
- #include <libavutil/imgutils.h>
- #include <libswscale/swscale.h>
- }
- namespace WallpaperEngine::Render
- {
- class CVideo : public CWallpaper
- {
- public:
- CVideo (Core::CVideo* video, CContainer* container, CContext* context);
- Core::CVideo* getVideo ();
- int getWidth ();
- int getHeight ();
- protected:
- void renderFrame (glm::vec4 viewport) override;
- friend class CWallpaper;
- static const std::string Type;
- private:
- void setSize (int width, int height);
- void restartStream ();
- void getNextFrame ();
- void writeFrameToImage ();
- void setupShaders ();
- AVFormatContext* m_formatCtx = nullptr;
- AVCodecContext* m_codecCtx = nullptr;
- AVFrame* m_videoFrameRGB = nullptr;
- AVFrame* m_videoFrame = nullptr;
- SwsContext* m_swsCtx = nullptr;
- uint8_t* m_buffer = nullptr;
- int m_videoStream = -1, m_audioStream = -1;
- /**
- * The texture used for the video output
- */
- GLuint m_texture;
- GLuint m_texCoordBuffer;
- GLuint m_positionBuffer;
- GLuint m_shader;
- // shader variables
- GLint g_Texture0;
- GLint a_Position;
- GLint a_TexCoord;
- };
- };
|