-
Notifications
You must be signed in to change notification settings - Fork 4
/
mediasourcebase.h
142 lines (121 loc) · 5.08 KB
/
mediasourcebase.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#ifndef MEDIASOURCEBASE_H
#define MEDIASOURCEBASE_H
#include <QObject>
#include <QDebug>
#include <QGroupBox>
#include <QSlider>
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QQueue>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QTimer>
#include <QGlib/Connect>
#include <QGst/Parse>
#include <QGst/Pipeline>
#include <QGst/Bus>
#include <QGst/Message>
#include <QGst/Query>
#include <QGst/Event>
#include "audioappsink.h"
#include "videoappsink.h"
class MediaSourceBase : public QGroupBox
{
Q_OBJECT
public:
/// FIELDS ///
void* userData;
/// PROPERTIES ///
QString getId();
void setId(QString id);
QString getName();
int getQueuedSamplesCount();
bool getMonitor();
qreal getVolume();
QGst::State getState();
virtual QHash<QString, QString> getSourceInfo();
float getGamma();
void setGamma(float gamma);
float getBrightness();
void setBrightness(float brightness);
float getContrast();
void setContrast(float contrast);
float getHue();
void setHue(float hue);
float getSaturation();
void setSaturation(float saturation);
int getFlipMode();
void setFlipMode(int flipMode);
/// METHODS ///
explicit MediaSourceBase(QWidget *parent);
~MediaSourceBase();
void init(QSlider* leftMeterSlider, QSlider* rightMeterSlider, QLabel* meterLabel,
QPushButton* goButton, QGraphicsView* previewGraphicsView,
QSlider* opacitySlider, QCheckBox* fadeCheckBox, QPushButton* monitorButton,
QSlider* volumeSlider, QCheckBox* syncVolToOpacityCheckBox);
float dequeueSample();
void clearQueuedSamples();
void trimQueuedSamples(int remainingSamplesCount);
void onBusMessage(const QGst::MessagePtr & message);
private:
/// POINTERS TO UI ELEMENTS ///
QSlider* leftMeterSlider;
QSlider* rightMeterSlider;
QLabel* meterLabel;
QPushButton* goButton;
QGraphicsView* previewGraphicsView;
QSlider* opacitySlider;
QCheckBox* fadeCheckBox;
QPushButton* monitorButton;
QSlider* volumeSlider;
QCheckBox* syncVolToOpacityCheckBox;
protected:
/// FIELDS ///
QString id;
QString name;
QGst::PipelinePtr pipeline;
QQueue<float> audioData;
QGst::ElementPtr gammaElement;
QGst::ElementPtr videoBalanceElement;
QGst::ElementPtr videoFlipElement;
VideoAppSink videoSink;
AudioAppSink audioSink;
QGraphicsScene scene;
QGraphicsPixmapItem* previewPixmapItem;
qreal fadeStepSize;
QTimer fadeStepTimer;
QTimer audioPeakTimer;
QPalette defaultPalette;
QTimer audioDiscontTimer;
signals:
void fadeMeIn(bool fadeOutOthers = true); // emitted for parent when the GO-Button is clicked
void preListenChanged(bool newState); // emitted for parent when the state of the Pre-Listen value changed
void opacityChanged(qreal newOpacity); // emitted for parent when the opacity changed
void volumeChanged(qreal newVolume); // emitted for parent when the volume changed
void newVideoFrame(QImage image);
void pipelineEOS();
void pipelineError(QString error, QString debugMsg);
void pipelineNewState(QGst::State newState);
public slots:
void setVideoOpacity(qreal opacity, bool diff = false); // set the opacity slider to a new, absolute value or modifiy the current one in a relative manner
void setVolume(qreal volume, bool diff = false); // set the volume fader to a new, absolute value or modifiy the current one in a relative manner
void setPreListen(bool value); // write-only public access to state of Pre-Listen button
void fadeStart(qreal stepSize, qint16 interval); // Start a fade on opacity
void audioDiscontOn(); // Call this slot if a discontinuity in the audio stream has been detected
protected slots:
void opcatiyFaderChanged(); // called when the opacity-fader got changed
void volumeFaderChanged(); // called when the volume-fader got changed
void goButtonClicked(); // called when the GO button is clicked
void sourceOnline(); // UI cleanups/defaults after the source has come online
void sourceOffline(); // UI cleanups/defaults after the source has gone offline
void updateBackground(); // Update the background color and title of the groupBox
void fadeTimeEvent(); // fadeStepTimer had a timeout
void newVideoFrameFromSink(QImage image); // handle images provided by the VideoAppSink
void newAudioBufferFromSink(QByteArray data); // handle audio buffers provided by the AudioAppSink
void audioClipOn(); // call whenever an audio clip has been detected
void audioClipOff(); // call when the audio clip is over to reset the UI
void audioDiscontOff(); // call when the audio discont is over to reset the UI
};
#endif // MEDIASOURCEBASE_H