1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QGSTREAMERVIDEOOUTPUT_P_H |
5 | #define QGSTREAMERVIDEOOUTPUT_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/qobject.h> |
19 | #include <QtCore/qpointer.h> |
20 | #include <QtMultimedia/private/qtmultimediaglobal_p.h> |
21 | #include <QtMultimedia/private/qmultimediautils_p.h> |
22 | #include <common/qgst_p.h> |
23 | #include <common/qgstreamervideosink_p.h> |
24 | #include <common/qgstsubtitlesink_p.h> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class QVideoSink; |
29 | |
30 | class QGstreamerVideoOutput : public QObject, QAbstractSubtitleObserver |
31 | { |
32 | Q_OBJECT |
33 | |
34 | public: |
35 | static QMaybe<QGstreamerVideoOutput *> create(QObject *parent = nullptr); |
36 | ~QGstreamerVideoOutput(); |
37 | |
38 | void setVideoSink(QVideoSink *sink); |
39 | QGstreamerVideoSink *gstreamerVideoSink() const { return m_platformVideoSink; } |
40 | |
41 | QGstElement gstElement() const { return m_outputBin; } |
42 | QGstElement gstSubtitleElement() const { return m_subtitleSink; } |
43 | |
44 | void setActive(bool); |
45 | |
46 | void setIsPreview(); |
47 | void flushSubtitles(); |
48 | |
49 | void setNativeSize(QSize); |
50 | void setRotation(QtVideo::Rotation); |
51 | |
52 | void updateSubtitle(QString) override; |
53 | |
54 | signals: |
55 | void subtitleChanged(QString); |
56 | |
57 | private: |
58 | explicit QGstreamerVideoOutput(QObject *parent); |
59 | |
60 | void updateNativeSize(); |
61 | |
62 | QPointer<QGstreamerVideoSink> m_platformVideoSink; |
63 | |
64 | // Gst elements |
65 | QGstBin m_outputBin; |
66 | QGstElement m_videoQueue; |
67 | QGstElement m_videoConvertScale; |
68 | QGstElement m_videoSink; |
69 | |
70 | QGstElement m_subtitleSink; |
71 | QMetaObject::Connection m_subtitleConnection; |
72 | QString m_lastSubtitleString; |
73 | |
74 | bool m_isActive{ false }; |
75 | QSize m_nativeSize; |
76 | QtVideo::Rotation m_rotation{}; |
77 | }; |
78 | |
79 | QT_END_NAMESPACE |
80 | |
81 | #endif |
82 | |