File indexing completed on 2024-05-12 05:53:13

0001 /*
0002  * Copyright 2019 Eike Hein <hein@kde.org>
0003  *
0004  * This program is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU General Public License as
0006  * published by the Free Software Foundation; either version 2 of
0007  * the License or (at your option) version 3 or any later version
0008  * accepted by the membership of KDE e.V. (or its successor approved
0009  * by the membership of KDE e.V.), which shall act as a proxy
0010  * defined in Section 14 of version 3 of the license.
0011  *
0012  * This program is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015  * GNU General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU General Public License
0018  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0019  */
0020 
0021 #pragma once
0022 
0023 #include <QLoggingCategory>
0024 #include <QObject>
0025 
0026 class QQuickWindow;
0027 
0028 struct _GstElement;
0029 struct _GstMessage;
0030 typedef struct _GstElement GstElement;
0031 typedef struct _GstMessage GstMessage;
0032 
0033 class GStreamerIntegration : public QObject
0034 {
0035     Q_OBJECT
0036 
0037     Q_PROPERTY(bool playing READ playing WRITE setPlaying NOTIFY playingChanged)
0038     Q_PROPERTY(QString stringPipeline READ stringPipeline WRITE setStringPipeline NOTIFY stringPipelineChanged)
0039 
0040 public:
0041     explicit GStreamerIntegration(QObject *parent = nullptr);
0042     ~GStreamerIntegration();
0043 
0044     bool playing() const;
0045     void setPlaying(bool playing);
0046 
0047     QString stringPipeline() const;
0048     void setStringPipeline(const QString &pipeline);
0049     static void init();
0050 
0051     GstElement *videoSink() const
0052     {
0053         return m_videoSink;
0054     }
0055     GstElement *pipeline() const
0056     {
0057         return m_gstPipeline;
0058     }
0059 
0060     void takeSnapshot();
0061     static void processPipelineMessage(GstMessage *message);
0062 
0063 Q_SIGNALS:
0064     void playingChanged();
0065     void stringPipelineChanged();
0066 
0067 private:
0068     void updateGstPipeline();
0069 
0070     bool m_playing;
0071 
0072     QString m_stringPipeline;
0073     GstElement *m_gstPipeline;
0074     GstElement *m_videoSink;
0075 
0076     bool m_fallback;
0077 };
0078 
0079 Q_DECLARE_LOGGING_CATEGORY(videoLogging)