1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QGSTUTILS_P_H |
41 | #define QGSTUTILS_P_H |
42 | |
43 | // |
44 | // W A R N I N G |
45 | // ------------- |
46 | // |
47 | // This file is not part of the Qt API. It exists purely as an |
48 | // implementation detail. This header file may change from version to |
49 | // version without notice, or even be removed. |
50 | // |
51 | // We mean it. |
52 | // |
53 | |
54 | #include <private/qgsttools_global_p.h> |
55 | #include <QtCore/qmap.h> |
56 | #include <QtCore/qset.h> |
57 | #include <QtCore/qvector.h> |
58 | #include <gst/gst.h> |
59 | #include <gst/video/video.h> |
60 | #include <qaudioformat.h> |
61 | #include <qcamera.h> |
62 | #include <qabstractvideobuffer.h> |
63 | #include <qvideoframe.h> |
64 | #include <QDebug> |
65 | |
66 | #if GST_CHECK_VERSION(1,0,0) |
67 | # define QT_GSTREAMER_PLAYBIN_ELEMENT_NAME "playbin" |
68 | # define QT_GSTREAMER_CAMERABIN_ELEMENT_NAME "camerabin" |
69 | # define QT_GSTREAMER_COLORCONVERSION_ELEMENT_NAME "videoconvert" |
70 | # define QT_GSTREAMER_RAW_AUDIO_MIME "audio/x-raw" |
71 | # define QT_GSTREAMER_VIDEOOVERLAY_INTERFACE_NAME "GstVideoOverlay" |
72 | #else |
73 | # define QT_GSTREAMER_PLAYBIN_ELEMENT_NAME "playbin2" |
74 | # define QT_GSTREAMER_CAMERABIN_ELEMENT_NAME "camerabin2" |
75 | # define QT_GSTREAMER_COLORCONVERSION_ELEMENT_NAME "ffmpegcolorspace" |
76 | # define QT_GSTREAMER_RAW_AUDIO_MIME "audio/x-raw-int" |
77 | # define QT_GSTREAMER_VIDEOOVERLAY_INTERFACE_NAME "GstXOverlay" |
78 | #endif |
79 | |
80 | QT_BEGIN_NAMESPACE |
81 | |
82 | class QSize; |
83 | class QVariant; |
84 | class QByteArray; |
85 | class QImage; |
86 | class QVideoSurfaceFormat; |
87 | |
88 | namespace QGstUtils { |
89 | struct Q_GSTTOOLS_EXPORT CameraInfo |
90 | { |
91 | QString name; |
92 | QString description; |
93 | int orientation; |
94 | QCamera::Position position; |
95 | QByteArray driver; |
96 | }; |
97 | |
98 | Q_GSTTOOLS_EXPORT QMap<QByteArray, QVariant> gstTagListToMap(const GstTagList *list); |
99 | |
100 | Q_GSTTOOLS_EXPORT QSize capsResolution(const GstCaps *caps); |
101 | Q_GSTTOOLS_EXPORT QSize capsCorrectedResolution(const GstCaps *caps); |
102 | Q_GSTTOOLS_EXPORT QAudioFormat audioFormatForCaps(const GstCaps *caps); |
103 | #if GST_CHECK_VERSION(1,0,0) |
104 | Q_GSTTOOLS_EXPORT QAudioFormat audioFormatForSample(GstSample *sample); |
105 | #else |
106 | Q_GSTTOOLS_EXPORT QAudioFormat audioFormatForBuffer(GstBuffer *buffer); |
107 | #endif |
108 | Q_GSTTOOLS_EXPORT GstCaps *capsForAudioFormat(const QAudioFormat &format); |
109 | Q_GSTTOOLS_EXPORT void initializeGst(); |
110 | Q_GSTTOOLS_EXPORT QMultimedia::SupportEstimate hasSupport(const QString &mimeType, |
111 | const QStringList &codecs, |
112 | const QSet<QString> &supportedMimeTypeSet); |
113 | |
114 | Q_GSTTOOLS_EXPORT QVector<CameraInfo> enumerateCameras(GstElementFactory *factory = 0); |
115 | Q_GSTTOOLS_EXPORT QList<QByteArray> cameraDevices(GstElementFactory * factory = 0); |
116 | Q_GSTTOOLS_EXPORT QString cameraDescription(const QString &device, GstElementFactory * factory = 0); |
117 | Q_GSTTOOLS_EXPORT QCamera::Position cameraPosition(const QString &device, GstElementFactory * factory = 0); |
118 | Q_GSTTOOLS_EXPORT int cameraOrientation(const QString &device, GstElementFactory * factory = 0); |
119 | Q_GSTTOOLS_EXPORT QByteArray cameraDriver(const QString &device, GstElementFactory * factory = 0); |
120 | |
121 | Q_GSTTOOLS_EXPORT QSet<QString> supportedMimeTypes(bool (*isValidFactory)(GstElementFactory *factory)); |
122 | |
123 | #if GST_CHECK_VERSION(1,0,0) |
124 | Q_GSTTOOLS_EXPORT QImage bufferToImage(GstBuffer *buffer, const GstVideoInfo &info); |
125 | Q_GSTTOOLS_EXPORT QVideoSurfaceFormat formatForCaps( |
126 | GstCaps *caps, |
127 | GstVideoInfo *info = 0, |
128 | QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle); |
129 | #else |
130 | Q_GSTTOOLS_EXPORT QImage bufferToImage(GstBuffer *buffer); |
131 | Q_GSTTOOLS_EXPORT QVideoSurfaceFormat formatForCaps( |
132 | GstCaps *caps, |
133 | int *bytesPerLine = 0, |
134 | QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle); |
135 | #endif |
136 | |
137 | Q_GSTTOOLS_EXPORT GstCaps *capsForFormats(const QList<QVideoFrame::PixelFormat> &formats); |
138 | void setFrameTimeStamps(QVideoFrame *frame, GstBuffer *buffer); |
139 | |
140 | Q_GSTTOOLS_EXPORT void setMetaData(GstElement *element, const QMap<QByteArray, QVariant> &data); |
141 | Q_GSTTOOLS_EXPORT void setMetaData(GstBin *bin, const QMap<QByteArray, QVariant> &data); |
142 | |
143 | Q_GSTTOOLS_EXPORT GstCaps *videoFilterCaps(); |
144 | |
145 | Q_GSTTOOLS_EXPORT QSize structureResolution(const GstStructure *s); |
146 | Q_GSTTOOLS_EXPORT QVideoFrame::PixelFormat structurePixelFormat(const GstStructure *s, int *bpp = 0); |
147 | Q_GSTTOOLS_EXPORT QSize structurePixelAspectRatio(const GstStructure *s); |
148 | Q_GSTTOOLS_EXPORT QPair<qreal, qreal> structureFrameRateRange(const GstStructure *s); |
149 | |
150 | Q_GSTTOOLS_EXPORT QString fileExtensionForMimeType(const QString &mimeType); |
151 | |
152 | #if GST_CHECK_VERSION(0,10,30) |
153 | Q_GSTTOOLS_EXPORT QVariant fromGStreamerOrientation(const QVariant &value); |
154 | Q_GSTTOOLS_EXPORT QVariant toGStreamerOrientation(const QVariant &value); |
155 | #endif |
156 | |
157 | Q_GSTTOOLS_EXPORT bool useOpenGL(); |
158 | } |
159 | |
160 | Q_GSTTOOLS_EXPORT void qt_gst_object_ref_sink(gpointer object); |
161 | Q_GSTTOOLS_EXPORT GstCaps *qt_gst_pad_get_current_caps(GstPad *pad); |
162 | Q_GSTTOOLS_EXPORT GstCaps *qt_gst_pad_get_caps(GstPad *pad); |
163 | Q_GSTTOOLS_EXPORT GstStructure *qt_gst_structure_new_empty(const char *name); |
164 | Q_GSTTOOLS_EXPORT gboolean qt_gst_element_query_position(GstElement *element, GstFormat format, gint64 *cur); |
165 | Q_GSTTOOLS_EXPORT gboolean qt_gst_element_query_duration(GstElement *element, GstFormat format, gint64 *cur); |
166 | Q_GSTTOOLS_EXPORT GstCaps *qt_gst_caps_normalize(GstCaps *caps); |
167 | Q_GSTTOOLS_EXPORT const gchar *qt_gst_element_get_factory_name(GstElement *element); |
168 | Q_GSTTOOLS_EXPORT gboolean qt_gst_caps_can_intersect(const GstCaps * caps1, const GstCaps * caps2); |
169 | Q_GSTTOOLS_EXPORT GList *qt_gst_video_sinks(); |
170 | Q_GSTTOOLS_EXPORT void qt_gst_util_double_to_fraction(gdouble src, gint *dest_n, gint *dest_d); |
171 | |
172 | Q_GSTTOOLS_EXPORT QDebug operator <<(QDebug debug, GstCaps *caps); |
173 | |
174 | QT_END_NAMESPACE |
175 | |
176 | #endif |
177 | |