57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#ifndef VIDEOVIEWERWIDGET_H
|
|
#define VIDEOVIEWERWIDGET_H
|
|
|
|
#include <QWidget>
|
|
#include <QPushButton>
|
|
#include <QComboBox>
|
|
#include <QLineEdit>
|
|
#include <QLabel>
|
|
#include <QImage>
|
|
#include <gst/gst.h>
|
|
#include <gst/app/gstappsink.h>
|
|
|
|
class VideoViewerWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit VideoViewerWidget(QWidget *parent = nullptr);
|
|
~VideoViewerWidget();
|
|
|
|
signals:
|
|
void newFrameAvailable(const QImage& frame);
|
|
|
|
private slots:
|
|
void onStartViewer();
|
|
void onStopViewer();
|
|
void onSourceTypeChanged(int index);
|
|
void displayFrame(const QImage& frame);
|
|
|
|
private:
|
|
void setupUI();
|
|
void initGStreamer();
|
|
void cleanupGStreamer();
|
|
void startPipeline();
|
|
void stopPipeline();
|
|
QString buildPipelineString();
|
|
|
|
static gboolean busCallback(GstBus* bus, GstMessage* msg, gpointer data);
|
|
static GstFlowReturn newSampleCallback(GstAppSink* appsink, gpointer user_data);
|
|
|
|
// UI elements
|
|
QLabel* m_videoDisplay;
|
|
QPushButton* m_startBtn;
|
|
QPushButton* m_stopBtn;
|
|
QComboBox* m_sourceType;
|
|
QLineEdit* m_hostEdit;
|
|
QLineEdit* m_portEdit;
|
|
QLabel* m_statusLabel;
|
|
|
|
// GStreamer elements
|
|
GstElement* m_pipeline;
|
|
GstElement* m_appSink;
|
|
guint m_busWatchId;
|
|
};
|
|
|
|
#endif // VIDEOVIEWERWIDGET_H
|