Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qgst_handle_types_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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 QGST_HANDLE_TYPES_P_H
5#define QGST_HANDLE_TYPES_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/private/qcore_unix_p.h>
19#include <QtCore/private/quniquehandle_p.h>
20#include <QtCore/qtconfigmacros.h>
21
22#include <QtMultimedia/private/qtmultimedia-config_p.h>
23
24#include <gst/gst.h>
25
26#if QT_CONFIG(gstreamer_gl)
27# include <gst/gl/gstglcontext.h>
28#endif
29
31
32namespace QGstImpl {
33
34template <typename HandleTraits>
35struct QSharedHandle : private QUniqueHandle<HandleTraits>
36{
37 using BaseClass = QUniqueHandle<HandleTraits>;
38
40
41 QSharedHandle() = default;
42
43 explicit QSharedHandle(typename HandleTraits::Type object, RefMode mode)
44 : BaseClass{ mode == NeedsRef ? HandleTraits::ref(object) : object }
45 {
46 }
47
49 : BaseClass{
50 HandleTraits::ref(o.get()),
51 }
52 {
53 }
54
55 QSharedHandle(QSharedHandle &&) noexcept = default;
56
57 QSharedHandle &operator=(const QSharedHandle &o) // NOLINT: bugprone-unhandled-self-assign
58 {
59 if (BaseClass::get() != o.get())
60 reset(HandleTraits::ref(o.get()));
61 return *this;
62 };
63
64 QSharedHandle &operator=(QSharedHandle &&) noexcept = default;
65
66 [[nodiscard]] friend bool operator==(const QSharedHandle &lhs,
67 const QSharedHandle &rhs) noexcept
68 {
69 return lhs.get() == rhs.get();
70 }
71
72 [[nodiscard]] friend bool operator!=(const QSharedHandle &lhs,
73 const QSharedHandle &rhs) noexcept
74 {
75 return lhs.get() != rhs.get();
76 }
77
78 [[nodiscard]] friend bool operator<(const QSharedHandle &lhs, const QSharedHandle &rhs) noexcept
79 {
80 return lhs.get() < rhs.get();
81 }
82
83 [[nodiscard]] friend bool operator<=(const QSharedHandle &lhs,
84 const QSharedHandle &rhs) noexcept
85 {
86 return lhs.get() <= rhs.get();
87 }
88
89 [[nodiscard]] friend bool operator>(const QSharedHandle &lhs, const QSharedHandle &rhs) noexcept
90 {
91 return lhs.get() > rhs.get();
92 }
93
94 [[nodiscard]] friend bool operator>=(const QSharedHandle &lhs,
95 const QSharedHandle &rhs) noexcept
96 {
97 return lhs.get() >= rhs.get();
98 }
99
100 using BaseClass::get;
101 using BaseClass::isValid;
102 using BaseClass::operator bool;
103 using BaseClass::release;
104 using BaseClass::reset;
105 using BaseClass::operator&;
106 using BaseClass::close;
107};
108
110{
111 using Type = GstTagList *;
112 static constexpr Type invalidValue() noexcept { return nullptr; }
113 static bool close(Type handle) noexcept
114 {
115 gst_tag_list_unref(handle);
116 return true;
117 }
118 static Type ref(Type handle) noexcept { return gst_tag_list_ref(handle); }
119};
120
122{
123 using Type = GstSample *;
124 static constexpr Type invalidValue() noexcept { return nullptr; }
125 static bool close(Type handle) noexcept
126 {
127 gst_sample_unref(handle);
128 return true;
129 }
130 static Type ref(Type handle) noexcept { return gst_sample_ref(handle); }
131};
132
134{
135 using Type = GstStructure *;
136 static constexpr Type invalidValue() noexcept { return nullptr; }
137 static bool close(Type handle) noexcept
138 {
139 gst_structure_free(handle);
140 return true;
141 }
142};
143
145{
146 using Type = gchar *;
147 static constexpr Type invalidValue() noexcept { return nullptr; }
148 static bool close(Type handle) noexcept
149 {
150 g_free(handle);
151 return true;
152 }
153};
154
156{
157 using Type = GError *;
158 static constexpr Type invalidValue() noexcept { return nullptr; }
159 static bool close(Type handle) noexcept
160 {
161 g_error_free(handle);
162 return true;
163 }
164};
165
166
168{
169 using Type = GstDateTime *;
170 static constexpr Type invalidValue() noexcept { return nullptr; }
171 static bool close(Type handle) noexcept
172 {
173 gst_date_time_unref(handle);
174 return true;
175 }
176};
177
179{
180 using Type = int;
181 static constexpr Type invalidValue() noexcept { return -1; }
182 static bool close(Type fd) noexcept
183 {
184 int closeResult = qt_safe_close(fd);
185 return closeResult == 0;
186 }
187};
188
189template <typename GstType>
191{
193 {
194 using Type = GstType *;
195 static constexpr Type invalidValue() noexcept { return nullptr; }
196 static bool close(Type handle) noexcept
197 {
198 gst_object_unref(G_OBJECT(handle));
199 return true;
200 }
201
202 static Type ref(Type handle) noexcept
203 {
204 gst_object_ref_sink(G_OBJECT(handle));
205 return handle;
206 }
207 };
208
209 using SharedHandle = QSharedHandle<QGstSafeObjectHandleTraits>;
210 using UniqueHandle = QUniqueHandle<QGstSafeObjectHandleTraits>;
211};
212
213template <typename GstType>
215{
216 struct Traits
217 {
218 using Type = GstType *;
219 static constexpr Type invalidValue() noexcept { return nullptr; }
220 static bool close(Type handle) noexcept
221 {
222 gst_mini_object_unref(GST_MINI_OBJECT_CAST(handle));
223 return true;
224 }
225
226 static Type ref(Type handle) noexcept
227 {
228 gst_mini_object_ref(GST_MINI_OBJECT_CAST(handle));
229 return handle;
230 }
231 };
232
233 using SharedHandle = QSharedHandle<Traits>;
234 using UniqueHandle = QUniqueHandle<Traits>;
235};
236
237} // namespace QGstImpl
238
245
248
249using QUniqueGstStructureHandle = QUniqueHandle<QGstImpl::QUniqueGstStructureHandleTraits>;
250using QUniqueGStringHandle = QUniqueHandle<QGstImpl::QUniqueGStringHandleTraits>;
251using QUniqueGErrorHandle = QUniqueHandle<QGstImpl::QUniqueGErrorHandleTraits>;
252using QUniqueGstDateTimeHandle = QUniqueHandle<QGstImpl::QUniqueGstDateTimeHandleTraits>;
253using QFileDescriptorHandle = QUniqueHandle<QGstImpl::QFileDescriptorHandleTraits>;
259
260#if QT_CONFIG(gstreamer_gl)
263#endif
264
266
267#endif
void reset(const Type &handle) noexcept
Type release() noexcept
void close() noexcept
Type get() const noexcept
bool isValid() const noexcept
Combined button and popup list for selecting options.
static int qt_safe_close(int fd)
QUniqueHandle< QGstImpl::QUniqueGstDateTimeHandleTraits > QUniqueGstDateTimeHandle
QUniqueHandle< QGstImpl::QFileDescriptorHandleTraits > QFileDescriptorHandle
QUniqueHandle< QGstImpl::QUniqueGstStructureHandleTraits > QUniqueGstStructureHandle
QGstImpl::QGstMiniObjectHandleHelper< GstContext >::UniqueHandle QGstContextHandle
GLuint64 GLenum void * handle
GLenum mode
GLuint object
[3]
GLuint64 GLenum GLint fd
GLint ref
GLboolean reset
static bool close(Type fd) noexcept
static constexpr Type invalidValue() noexcept
static constexpr Type invalidValue() noexcept
static constexpr Type invalidValue() noexcept
static Type ref(Type handle) noexcept
static bool close(Type handle) noexcept
static constexpr Type invalidValue() noexcept
static Type ref(Type handle) noexcept
static bool close(Type handle) noexcept
friend bool operator<=(const QSharedHandle &lhs, const QSharedHandle &rhs) noexcept
QSharedHandle(QSharedHandle &&) noexcept=default
QSharedHandle(typename HandleTraits::Type object, RefMode mode)
Type get() const noexcept
QSharedHandle(const QSharedHandle &o)
friend bool operator!=(const QSharedHandle &lhs, const QSharedHandle &rhs) noexcept
friend bool operator<(const QSharedHandle &lhs, const QSharedHandle &rhs) noexcept
QSharedHandle & operator=(QSharedHandle &&) noexcept=default
friend bool operator>(const QSharedHandle &lhs, const QSharedHandle &rhs) noexcept
friend bool operator>=(const QSharedHandle &lhs, const QSharedHandle &rhs) noexcept
static bool close(Type handle) noexcept
static constexpr Type invalidValue() noexcept
static constexpr Type invalidValue() noexcept
static bool close(Type handle) noexcept
static bool close(Type handle) noexcept
static constexpr Type invalidValue() noexcept
static constexpr Type invalidValue() noexcept
static bool close(Type handle) noexcept
Definition moc.h:23