63 lines
1.6 KiB
C++
Executable File
63 lines
1.6 KiB
C++
Executable File
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <osg/Camera>
|
|
|
|
|
|
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<osg::GraphicsContext *, osg::ref_ptr<ContextData> >;
|
|
|
|
GLenum _readBuffer;
|
|
unsigned int _contextId;
|
|
std::string _filename;
|
|
int _w;
|
|
int _h;
|
|
int _framerate;
|
|
int _quality;
|
|
mutable ContextDataMap _contextDataMap;
|
|
};
|
|
|
|
}
|