-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGstreamerThread.h
47 lines (41 loc) · 1.06 KB
/
GstreamerThread.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
#ifndef GSTREAMERTHREAD_H
#define GSTREAMERTHREAD_H
#include <atomic>
#include <QThread>
#include <QImage>
#include <QDebug>
#include <QMutex>
#include <QTimer>
#include <QMutexLocker>
#include <QWaitCondition>
#include <gst/gst.h>
#include <gst/app/app.h>
class GstreamerThread : public QThread
{
Q_OBJECT
GstElement *pipeline = nullptr;
bool mContinue;
bool mDestroy = false;
QMutex playPauseMtx;
QTimer fpsTimer;
int m_port;
public:
explicit GstreamerThread(int port, QObject *parent = nullptr);
~GstreamerThread();
std::atomic<QImage*> atomicFrame;
QMutex mtxFrame;
QWaitCondition frameReadyCond;
std::atomic<int> framecount;
static gboolean my_bus_callback(GstBus *bus, GstMessage *message, gpointer data);
static GstFlowReturn new_sample(GstAppSink *appsink, gpointer);
static GstFlowReturn new_preroll(GstAppSink *, gpointer);
protected:
void run() override;
public slots:
void play();
void pause();
signals:
void signalNewFrame(QImage);
void signalFPS(int);
};
#endif // GSTREAMERTHREAD_H