#pragma once #include struct _GstElement; namespace VCtrl { class WindowCaptureCallback : public osg::Camera::DrawCallback { public: struct ContextData : public osg::Referenced { ContextData(osg::GraphicsContext *gc, GLenum readBuffer, const std::string &path, int w, int h, int framerate, int quality); ~ContextData(); static void getSize(osg::GraphicsContext *gc, int &width, int &height); void read(); osg::GraphicsContext *_gc; GLenum _readBuffer; std::string _fileName; int _width; int _height; std::vector< GLuint > _pboBuffer; osg::Timer_t _previousFrameTick; osg::Timer_t _startTick; _GstElement *_pipeline; _GstElement *_app_source; }; WindowCaptureCallback(GLenum readBuffer, unsigned int contextid, const std::string &path, int w, int h, int framerate, int quality); ~WindowCaptureCallback() = default; ContextData *createContextData(osg::GraphicsContext *gc) const; ContextData *getContextData(osg::GraphicsContext *gc) const; void operator()(osg::RenderInfo &renderInfo) const override; using ContextDataMap = std::map >; GLenum _readBuffer; unsigned int _contextId; std::string _filename; int _w; int _h; int _framerate; int _quality; mutable ContextDataMap _contextDataMap; }; }