23 #include <QQuickWidget> 24 #include <QOpenGLFunctions> 25 #include <QOpenGLShaderProgram> 26 #include <QOpenGLFramebufferObject> 27 #include <QOpenGLContext> 28 #include <QOffscreenSurface> 32 #include "mltcontroller.h" 33 #include "sharedframe.h" 35 class QOpenGLFunctions_3_2_Core;
46 typedef void* ( *thread_function_t )(
void* );
48 class GLWidget :
public QQuickWidget,
public Controller,
protected QOpenGLFunctions
51 Q_PROPERTY(QRect rect READ rect NOTIFY rectChanged)
52 Q_PROPERTY(
float zoom READ zoom NOTIFY zoomChanged)
53 Q_PROPERTY(QPoint offset READ offset NOTIFY offsetChanged)
56 GLWidget(QObject *parent = 0);
59 void createThread(RenderThread** thread, thread_function_t
function,
void* data);
62 int setProducer(Mlt::Producer*,
bool isMulti =
false);
63 int reconfigure(
bool isMulti);
65 void play(
double speed = 1.0) {
66 Controller::play(speed);
67 if (speed == 0) emit paused();
70 void seek(
int position) {
71 Controller::seek(position);
78 int displayWidth()
const {
return m_rect.width(); }
79 int displayHeight()
const {
return m_rect.height(); }
81 QObject* videoWidget() {
return this; }
82 Filter* glslManager()
const {
return m_glslManager; }
83 QRect rect()
const {
return m_rect; }
84 float zoom()
const {
return m_zoom * MLT.profile().width() / m_rect.width(); }
85 QPoint offset()
const;
87 void requestImage()
const;
91 void setZoom(
float zoom);
92 void setOffsetX(
int x);
93 void setOffsetY(
int y);
95 void setCurrentFilter(QmlFilter* filter, QmlMetadata* meta);
101 void gpuNotSupported();
107 void offsetChanged();
113 QOpenGLShaderProgram* m_shader;
115 Filter* m_glslManager;
116 QSemaphore m_initSem;
117 bool m_isInitialized;
118 Event* m_threadStartEvent;
119 Event* m_threadStopEvent;
120 Event* m_threadCreateEvent;
121 Event* m_threadJoinEvent;
122 FrameRenderer* m_frameRenderer;
123 int m_projectionLocation;
124 int m_modelViewLocation;
125 int m_vertexLocation;
126 int m_texCoordLocation;
127 int m_colorspaceLocation;
128 int m_textureLocation[3];
131 QOffscreenSurface m_offscreenSurface;
132 QOpenGLContext* m_shareContext;
136 static void on_frame_show(mlt_consumer,
void*
self, mlt_frame frame);
140 void resizeGL(
int width,
int height);
141 void updateTexture(GLuint yName, GLuint uName, GLuint vName);
145 void resizeEvent(QResizeEvent* event);
146 void mousePressEvent(QMouseEvent *);
147 void mouseMoveEvent(QMouseEvent *);
148 void keyPressEvent(QKeyEvent* event);
152 class RenderThread :
public QThread
156 RenderThread(thread_function_t
function,
void* data, QOpenGLContext *context, QSurface* surface);
162 thread_function_t m_function;
164 QOpenGLContext* m_context;
168 class FrameRenderer :
public QThread
172 FrameRenderer(QOpenGLContext* shareContext, QSurface* surface);
174 QSemaphore* semaphore() {
return &m_semaphore; }
175 QOpenGLContext* context()
const {
return m_context; }
177 Q_INVOKABLE
void showFrame(Mlt::Frame frame);
179 QImage image()
const {
return m_image; }
185 void textureReady(GLuint yName, GLuint uName = 0, GLuint vName = 0);
190 QSemaphore m_semaphore;
192 QOpenGLContext* m_context;
194 qint64 m_previousMSecs;
195 bool m_imageRequested;
199 GLuint m_renderTexture[3];
200 GLuint m_displayTexture[3];
201 QOpenGLFunctions_3_2_Core* m_gl32;
Definition: encodedock.h:35
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition: sharedframe.h:48