-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgstpipeline.h
67 lines (53 loc) · 1.57 KB
/
gstpipeline.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef GSTPIPELINE_H
#define GSTPIPELINE_H
#define GST_USE_UNSTABLE_API
#include <gst/gl/gstglcontext.h>
#include <gst/gl/gstgldisplay.h>
#include <QThread>
#include <QOpenGLWidget>
#include <QMutex>
#include <QWaitCondition>
class GstreamerPipeline : public QObject
{
Q_OBJECT
public:
GstreamerPipeline();
~GstreamerPipeline();
void initialize(QOpenGLContext *context);
void open(const QString& filename) { emit openFileRequested(filename); }
void notifyNewFrame(GLuint texture);
void frameDrawn();
void stop();
signals:
void finished();
void newFrameReady(GLuint texture);
void videoSize(int width, int height);
void openFileRequested(const QString& filename);
public slots:
private:
enum class PipelineState {
STOPPED,
PAUSED,
PLAYING
};
QThread _thread;
QMutex _mutex;
QWaitCondition _wait;
PipelineState _state = PipelineState::STOPPED;
GstBus* m_bus;
GstPipeline* _pipeline = nullptr;
GstElement* _filesrc = nullptr;
GstElement* _glupload = nullptr;
GstGLDisplay* _display;
GstGLContext* _context;
static void on_gst_buffer(GstElement * element, GstBuffer * buf, GstPad * pad, GstreamerPipeline* p);
static gboolean bus_call (GstBus *bus, GstMessage *msg, GstreamerPipeline* p);
static gboolean sync_bus_call (GstBus *bus, GstMessage *msg, GstreamerPipeline* p);
void _signalFinished();
void _startPipeline();
void _pausePipeline();
void _stopPipeline();
private slots:
void _open(const QString& filename);
};
#endif // GSTPIPELINE_H