/****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg Copyright (C) 2012-2016 Wang Bin * This file is part of QtAV (from 2014) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ******************************************************************************/ #ifndef QTAV_OPENGLVIDEO_H #define QTAV_OPENGLVIDEO_H #ifndef QT_NO_OPENGL #include "_fav_constants.h" #include "VideoFormat.h" #include #include #include #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include #else #include #define QOpenGLContext QGLContext #endif QT_BEGIN_NAMESPACE class QColor; QT_END_NAMESPACE namespace FAV { class VideoFrame; class VideoShader; class OpenGLVideoPrivate; /*! * \brief The OpenGLVideo class * high level api for renderering a video frame. use VideoShader, VideoMaterial and ShaderManager internally. * By default, VBO is used. Set environment var QTAV_NO_VBO=1 or 0 to disable/enable VBO. * VAO will be enabled if supported. Disabling VAO is the same as VBO. */ class Q_AV_EXPORT OpenGLVideo : public QObject { Q_OBJECT DPTR_DECLARE_PRIVATE(OpenGLVideo) public: enum MeshType { RectMesh, SphereMesh }; #if (RM_MODEL_360) typedef struct{ bool bVFlip; bool bHFlip; double dAngleX; double dAngleY; int mode; int aspectMode; qreal sourceAspectRatio; // Video Mode 일 경우 바로 적용되지 않아 강제 변경 } RENDER_INFO_360; #endif // RM_MODEL_360 static bool isSupported(VideoFormat::PixelFormat pixfmt); OpenGLVideo(); /*! * \brief setOpenGLContext * a context must be set before renderering. * \param ctx * 0: current context in OpenGL is done. shaders will be released. * QOpenGLContext is QObject in Qt5, and gl resources here will be released automatically if context is destroyed. * But you have to call setOpenGLContext(0) for Qt4 explicitly in the old context. * Viewport is also set here using context surface/paintDevice size and devicePixelRatio. * devicePixelRatio may be wrong for multi-screen with 5.0 확대1,2,3,4 -> 원본 // 화면 클릭 (xy 0.0 ~ 1.0) ZOOM (0->5->10->20->0) void zoomPos(double rx, double ry); QSize frameSize(); #if (USE_POINT_ZOOM) int zoomLevel2D; QPointF centerZoom; float getZoomScale(); QRectF getROI(QRectF src); QPointF getZoomCenter(float rx, float ry); #endif #if (!USE_POINT_ZOOM || USE_HYBRID_ZOOM) bool bROI; QRectF rROI; void setROI(double x, double y, double w, double h); // OpenGL ROI #endif void clearROI(); bool bVRFlip; // 360 FLIP (각도 뒤집힘...) double sx; double sy; void startDrag(); // mouse press void drag(double rx,double ry); // mouse move (원점에서 이동) void scroll(double rx,double ry); // 현재 각도에서 이동 //! \brief 3D 모드 변경 //! \param mode : 0:2D, 1:PANORAMA 2CH, 2:3D #endif // RM_MODEL_360 #if (RM_MODEL_360 || SUPPORT_WIDE_MODE) void setMode(int mode); int mode(); void setVFlip(bool flip); // 상하반전 bool isVFlip(); void setHFlip(bool flip); // 좌우반전 bool isHFlip(); #endif // SUPPORT_WIDE_MODE #if (MODEL_360) QMatrix4x4& tune360(); void setTune360(QMatrix4x4 m); void setDualMode(int mode); void setDualFront(bool front); #if (TUNE_360) void setMode(int mode); // 0:WIDE, 1:VR #endif // TUNE_360 #endif // MODEL_360 #if (MODEL_360) void setZoom(bool a); bool zoom(); void setAngle(double a); double angle(); void setPitch(double a); double pitch(); #endif Q_SIGNALS: void beforeRendering(); /*! * \brief afterRendering * Emitted when video frame is rendered. * With DirectConnection, it can be used to draw GL on top of video, or to do screen scraping of the current frame buffer. */ void afterRendering(); protected: DPTR_DECLARE(OpenGLVideo) private Q_SLOTS: /* used by Qt5 whose QOpenGLContext is QObject and we can call this when context is about to destroy. * shader manager and material will be reset */ void resetGL(); }; } //namespace FAV #endif //QT_NO_OPENGL #endif // QTAV_OPENGLVIDEO_H