-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer.h
69 lines (53 loc) · 1.48 KB
/
player.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
68
69
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include <QQuickItem>
#include <gst/gst.h>
#include <memory>
#include <map>
extern "C" {
#include "gstnvdsmeta.h"
}
constexpr int MAX_NUM_SOURCES = 128;
struct AppCtx {
GstElement *pipeline;
GstElement *source[MAX_NUM_SOURCES];
GstElement *streammux;
GstElement *pgie;
GstElement *nvvidconv;
GstElement *osd;
GstElement *nvtiler;
GstElement *nvglconv;
GstElement *glupload;
GstElement *glcolorconv;
GstElement *sink;
bool source_enable[MAX_NUM_SOURCES];
// std::map<int, NvOSD_ColorParams> color_map;
};
class Player : public QObject
{
Q_OBJECT
Q_PROPERTY(QList<QString> playlist READ playlist NOTIFY playlistChanged)
Q_PROPERTY(QVariant output WRITE setOutput)
public:
explicit Player(QObject *parent = nullptr);
~Player();
Q_INVOKABLE void addVideo(const QString &uri);
Q_INVOKABLE void removeVideo(int index);
QList<QString> playlist() const { return playlist_; }
void setOutput(QVariant output);
signals:
void playlistChanged();
private:
static void cb_newpad(GstElement *decodebin, GstPad *pad, gpointer data);
static GstPadProbeReturn osd_sink_pad_buffer_probe(GstPad *pad,
GstPadProbeInfo *info, gpointer u_data);
void createPipeline();
void destroyPipeline();
int getUnusedSourceId();
int getSourceId(int index);
int getSourceIndex(int id);
QList<QString> playlist_;
AppCtx ctx_;
};
#endif // PLAYER_H