/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This application is open source and may be redistributed and/or modified * freely and without restriction, both in commericial and non commericial applications, * as long as this copyright notice is maintained. * * This application is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ /* -*-c++-*- * * Copyright (C) 2009 Cedric Pinson * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * * Authors: * Cedric Pinson * */ #pragma once #include // fwd decl for gstreamer objects 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; }; }