Debian Codegraph @

src/librssguard/gui/mediaplayer/libmpv/qthelper.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/gui/mediaplayer/libmpv/qthelper.h`/
2
3 #ifndef LIBMPV_QTHELPER_H_
4 #define LIBMPV_QTHELPER_H_cxx . . $ `src/librssguard/gui/mediaplayer/libmpv/qthelper.h:4:9`!
5
6 #include <cstring>
7 #include <mpv/client.h>
8
9 #include <QHash>
10 #include <QList>
11 #include <QMetaType>
12 #include <QSharedPointer>
13 #include <QString>
14 #include <QVariant>
15
16 namespace mpvcxx . . $ mpv/ {
17 namespace qtcxx . . $ mpv/qt/ {
18 // Wrapper around mpv_handle. Does refcounting under the hood.
19 class Handlecxx . . $ mpv/qt/Handle# {
20 struct containercxx . . $ mpv/qt/Handle#container# {
21 containercxx . . $ mpv/qt/Handle#container#container(d2bb5b6faf0312ed).(mpv_handle* h) : mpvcxx . . $ mpv/qt/Handle#container#mpv.(h) {}
22 ~cxx . . $ mpv/qt/Handle#container#`~container`(ced63f7c635d850d).containercxx . . $ mpv/qt/Handle#container#() {
23 mpv_terminate_destroy(mpvcxx . . $ mpv/qt/Handle#container#mpv.);
24 }
25 mpv_handle* mpvcxx . . $ mpv/qt/Handle#container#mpv.;
26 };
27 QSharedPointercxx . . $ QSharedPointer#<containercxx . . $ mpv/qt/Handle#container#> sptrcxx . . $ mpv/qt/Handle#sptr.;
28
29 public:
30 // Construct a new Handle from a raw mpv_handle with refcount 1. If the
31 // last Handle goes out of scope, the mpv_handle will be destroyed with
32 // mpv_terminate_destroy().
33 // Never destroy the mpv_handle manually when using this wrapper. You
34 // will create dangling pointers. Just let the wrapper take care of
35 // destroying the mpv_handle.
36 // Never create multiple wrappers from the same raw mpv_handle; copy the
37 // wrapper instead (that's what it's for).
38 static Handlecxx . . $ mpv/qt/Handle# FromRawHandlecxx . . $ mpv/qt/Handle#FromRawHandle(c424c56be61bea3b).(mpv_handle* handle) {
39 Handlecxx . . $ mpv/qt/Handle# h;
40 h.sptrcxx . . $ mpv/qt/Handle#sptr. =cxx . . $ QSharedPointer#`operator=`(a05fc86396567b9d). QSharedPointercxx . . $ QSharedPointer#<containercxx . . $ mpv/qt/Handle#container#>(new containercxx . . $ mpv/qt/Handle#container#(handle));
41 return h;
42 }
43
44 // Return the raw handle; for use with the libmpv C API.
45 operatorcxx . . $ mpv/qt/Handle#`operator mpv_handle *`(d0b49937f6c1a724). mpv_handle*() const {
46 return sptrcxx . . $ mpv/qt/Handle#sptr. ? (*cxx . . $ QSharedPointer#`operator*`(c93303b41ac66b6d).sptrcxx . . $ mpv/qt/Handle#sptr.).mpvcxx . . $ mpv/qt/Handle#container#mpv. : 0;
47 }
48 };
49
50 static inline QVariantcxx . . $ QVariant# node_to_variantcxx . . $ mpv/qt/node_to_variant(a25eef8ed7d55b25).(const mpv_node* node) {
51 switch (node->format) {
52 case MPV_FORMAT_STRING:
53 return QVariantcxx . . $ QVariant#QVariant(132dd6869045752b).(QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(c74cc94e20614dc9).(nodecxx . . $ QByteArrayView#QByteArrayView(80d8335016fb1bdc).->u.string));
54
55 case MPV_FORMAT_FLAG:
56 return QVariantcxx . . $ QVariant#QVariant(9f0ba574c1c44ffc).(static_cast<bool>(node->u.flag));
57
58 case MPV_FORMAT_INT64:
59 return QVariantcxx . . $ QVariant#QVariant(1ca78f0f7b9b0ce5).(static_cast<qlonglongcxx . . $ qlonglong#>(node->u.int64));
60
61 case MPV_FORMAT_DOUBLE:
62 return QVariantcxx . . $ QVariant#QVariant(4cbbf9c7388e6885).(node->u.double_);
63
64 case MPV_FORMAT_NODE_ARRAY: {
65 mpv_node_list* list = node->u.list;
66 QVariantListcxx . . $ QVariantList# qlistcxx . . $ QList#QList(ced63f7c635d850d).;
67
68 for (int n = 0; n < list->numcxx . . $ mpv_node_list#num.; n++) {
69 qlist.appendcxx . . $ QList#append(1262c8661f7a27a7).(node_to_variantcxx . . $ mpv/qt/node_to_variant(a25eef8ed7d55b25).(&list->valuescxx . . $ mpv_node_list#values.[n]));
70 }
71
72 return QVariantcxx . . $ QVariant#QVariant(28c07a90ecae1ef3).(qlist);
73 }
74 case MPV_FORMAT_NODE_MAP: {
75 mpv_node_list* list = node->u.list;
76 QVariantMapcxx . . $ QVariantMap# qmapcxx . . $ QMap#QMap(49f6e7a06ebc5aa8).;
77
78 for (int n = 0; n < list->numcxx . . $ mpv_node_list#num.; n++) {
79 qmap.insertcxx . . $ QMap#insert(929a1ed410fe8423).(QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(c74cc94e20614dc9).(listcxx . . $ QByteArrayView#QByteArrayView(80d8335016fb1bdc).->keyscxx . . $ mpv_node_list#keys.[n]), node_to_variantcxx . . $ mpv/qt/node_to_variant(a25eef8ed7d55b25).(&list->valuescxx . . $ mpv_node_list#values.[n]));
80 }
81
82 return QVariantcxx . . $ QVariant#QVariant(32f373bacf5935f9).(qmap);
83 }
84 default: // MPV_FORMAT_NONE, unknown values (e.g. future extensions)
85 return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).();
86 }
87 }
88
89 struct node_buildercxx . . $ mpv/qt/node_builder# {
90 node_buildercxx . . $ mpv/qt/node_builder#node_builder(244511558b20107a).(const QVariantcxx . . $ QVariant#& v) {
91 setcxx . . $ mpv/qt/node_builder#set(50c9a94325a49fe0).(&node_cxx . . $ mpv/qt/node_builder#node_., v);
92 }
93
94 ~cxx . . $ mpv/qt/node_builder#`~node_builder`(ced63f7c635d850d).node_buildercxx . . $ mpv/qt/node_builder#() {
95 free_nodecxx . . $ mpv/qt/node_builder#free_node(15db91bf44f8e437).(&node_cxx . . $ mpv/qt/node_builder#node_.);
96 }
97
98 mpv_node* nodecxx . . $ mpv/qt/node_builder#node(98049a0de5819907).() {
99 return &node_cxx . . $ mpv/qt/node_builder#node_.;
100 }
101
102 private:
103 Q_DISABLE_COPYcxx . . $ `<external>/9561028201570787675/qtclasshelpermacros.h:23:9`!(node_builder)
104 mpv_node node_cxx . . $ mpv/qt/node_builder#node_.;
105
106 mpv_node_list* create_listcxx . . $ mpv/qt/node_builder#create_list(43130afe6067b90e).(mpv_node* dst, bool is_map, int num) {
107 dst->format = is_map ? MPV_FORMAT_NODE_MAP : MPV_FORMAT_NODE_ARRAY;
108 mpv_node_list* list = new mpv_node_list();
109 dst->u.list = list;
110
111 if (!list) {
112 goto err;
113 }
114
115 list->valuescxx . . $ mpv_node_list#values. = new mpv_node[num]();
116
117 if (!list->valuescxx . . $ mpv_node_list#values.) {
118 goto err;
119 }
120
121 if (is_map) {
122 list->keyscxx . . $ mpv_node_list#keys. = new char*[num]();
123
124 if (!list->keyscxx . . $ mpv_node_list#keys.) {
125 goto err;
126 }
127 }
128
129 return list;
130
131 err:
132 free_nodecxx . . $ mpv/qt/node_builder#free_node(15db91bf44f8e437).(dst);
133 return nullptr;
134 }
135
136 char* dup_qstringcxx . . $ mpv/qt/node_builder#dup_qstring(f2ecd1eff3a7fb03).(const QStringcxx . . $ QString#& s) {
137 QByteArraycxx . . $ QByteArray# b = s.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).();
138 char* r = new char[b.sizecxx . . $ QByteArray#size(6b0412d51016192f).() + 1];
139
140 if (r) {
141 stdcxx . . $ std/::memcpy(r, b.datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), b.sizecxx . . $ QByteArray#size(6b0412d51016192f).() + 1);
142 }
143
144 return r;
145 }
146
147 bool test_typecxx . . $ mpv/qt/node_builder#test_type(55bb2bf757ed1721).(const QVariantcxx . . $ QVariant#& v, QMetaTypecxx . . $ QMetaType#::Typecxx . . $ QMetaType#Type# t) {
148 // The Qt docs say: "Although this function is declared as returning
149 // "QVariant::Type(obsolete), the return value should be interpreted
150 // as QMetaType::Type."
151 // So a cast really seems to be needed to avoid warnings (urgh).
152 #if QT_VERSION_MAJORcxx . . $ `<external>/9758848313111604122/qconfig.h:67:9`! == 5
153 return v.type() == static_cast<int>(t);
154 #else
155 return v.typeIdcxx . . $ QVariant#typeId(455f465bc33b4cdf).() == static_cast<int>(t);
156 #endif
157 }
158 void setcxx . . $ mpv/qt/node_builder#set(50c9a94325a49fe0).(mpv_node* dst, const QVariantcxx . . $ QVariant#& src) {
159 if (test_typecxx . . $ mpv/qt/node_builder#test_type(55bb2bf757ed1721).(src, QMetaTypecxx . . $ QMetaType#::QStringcxx . . $ QMetaType#QString.)) {
160 dst->format = MPV_FORMAT_STRING;
161 dst->u.string = dup_qstringcxx . . $ mpv/qt/node_builder#dup_qstring(f2ecd1eff3a7fb03).(src.toStringcxx . . $ QVariant#toString(6ef7b6c27b00b43d).());
162
163 if (!dst->u.string) {
164 goto fail;
165 }
166 }
167 else if (test_typecxx . . $ mpv/qt/node_builder#test_type(55bb2bf757ed1721).(src, QMetaTypecxx . . $ QMetaType#::Boolcxx . . $ QMetaType#Bool.)) {
168 dst->format = MPV_FORMAT_FLAG;
169 dst->u.flag = src.toBoolcxx . . $ QVariant#toBool(50ce9a9e25b4a850).() ? 1 : 0;
170 }
171 else if (test_typecxx . . $ mpv/qt/node_builder#test_type(55bb2bf757ed1721).(src, QMetaTypecxx . . $ QMetaType#::Intcxx . . $ QMetaType#Int.) || test_typecxx . . $ mpv/qt/node_builder#test_type(55bb2bf757ed1721).(src, QMetaTypecxx . . $ QMetaType#::LongLongcxx . . $ QMetaType#LongLong.) ||
172 test_typecxx . . $ mpv/qt/node_builder#test_type(55bb2bf757ed1721).(src, QMetaTypecxx . . $ QMetaType#::UIntcxx . . $ QMetaType#UInt.) || test_typecxx . . $ mpv/qt/node_builder#test_type(55bb2bf757ed1721).(src, QMetaTypecxx . . $ QMetaType#::ULongLongcxx . . $ QMetaType#ULongLong.)) {
173 dst->format = MPV_FORMAT_INT64;
174 dst->u.int64 = src.toLongLongcxx . . $ QVariant#toLongLong(4afa307e6140ced).();
175 }
176 else if (test_typecxx . . $ mpv/qt/node_builder#test_type(55bb2bf757ed1721).(src, QMetaTypecxx . . $ QMetaType#::Doublecxx . . $ QMetaType#Double.)) {
177 dst->format = MPV_FORMAT_DOUBLE;
178 dst->u.double_ = src.toDoublecxx . . $ QVariant#toDouble(1bd8e57dd4a29c14).();
179 }
180 else if (src.canConvertcxx . . $ QVariant#canConvert(50ce9a9e25b4a850).<QVariantListcxx . . $ QVariantList#>()) {
181 QVariantListcxx . . $ QVariantList# qlist = src.toListcxx . . $ QVariant#toList(a208304be85d9b76).();
182 mpv_node_list* list = create_listcxx . . $ mpv/qt/node_builder#create_list(43130afe6067b90e).(dst, false, qlist.sizecxx . . $ QList#size(6b0412d51016192f).());
183
184 if (!list) {
185 goto fail;
186 }
187
188 list->numcxx . . $ mpv_node_list#num. = qlist.sizecxx . . $ QList#size(6b0412d51016192f).();
189
190 for (int n = 0; n < qlist.sizecxx . . $ QList#size(6b0412d51016192f).(); n++) {
191 setcxx . . $ mpv/qt/node_builder#set(50c9a94325a49fe0).(&list->valuescxx . . $ mpv_node_list#values.[n], qlist[cxx . . $ QList#`operator[]`(f5945173c490e616).n]);
192 }
193 }
194 else if (src.canConvertcxx . . $ QVariant#canConvert(50ce9a9e25b4a850).<QVariantMapcxx . . $ QVariantMap#>()) {
195 QVariantMapcxx . . $ QVariantMap# qmap = src.toMapcxx . . $ QVariant#toMap(87f780dbe64191c4).();
196 mpv_node_list* list = create_listcxx . . $ mpv/qt/node_builder#create_list(43130afe6067b90e).(dst, true, qmap.sizecxx . . $ QMap#size(98833e9ab7de59a4).());
197
198 if (!list) {
199 goto fail;
200 }
201
202 list->numcxx . . $ mpv_node_list#num. = qmap.sizecxx . . $ QMap#size(98833e9ab7de59a4).();
203
204 for (int n = 0; n < qmap.sizecxx . . $ QMap#size(98833e9ab7de59a4).(); n++) {
205 list->keyscxx . . $ mpv_node_list#keys.[n] = dup_qstringcxx . . $ mpv/qt/node_builder#dup_qstring(f2ecd1eff3a7fb03).(qmap.keyscxx . . $ QMap#keys(bf6c511543d55010).()[cxx . . $ QList#`operator[]`(f5945173c490e616).n]);
206
207 if (!list->keyscxx . . $ mpv_node_list#keys.[n]) {
208 free_nodecxx . . $ mpv/qt/node_builder#free_node(15db91bf44f8e437).(dst);
209 goto fail;
210 }
211
212 setcxx . . $ mpv/qt/node_builder#set(50c9a94325a49fe0).(&list->valuescxx . . $ mpv_node_list#values.[n], qmap.valuescxx . . $ QMap#values(16615713d304f37e).()[cxx . . $ QList#`operator[]`(f5945173c490e616).n]);
213 }
214 }
215 else {
216 goto fail;
217 }
218
219 return;
220
221 fail:
222 dst->format = MPV_FORMAT_NONE;
223 }
224
225 void free_nodecxx . . $ mpv/qt/node_builder#free_node(15db91bf44f8e437).(mpv_node* dst) {
226 switch (dst->format) {
227 case MPV_FORMAT_STRING:
228 delete[] dst->u.string;
229 break;
230
231 case MPV_FORMAT_NODE_ARRAY:
232 case MPV_FORMAT_NODE_MAP: {
233 mpv_node_list* list = dst->u.list;
234
235 if (list) {
236 for (int n = 0; n < list->numcxx . . $ mpv_node_list#num.; n++) {
237 if (list->keyscxx . . $ mpv_node_list#keys.) {
238 delete[] list->keyscxx . . $ mpv_node_list#keys.[n];
239 }
240
241 if (list->valuescxx . . $ mpv_node_list#values.) {
242 free_nodecxx . . $ mpv/qt/node_builder#free_node(15db91bf44f8e437).(&list->valuescxx . . $ mpv_node_list#values.[n]);
243 }
244 }
245
246 delete[] list->keyscxx . . $ mpv_node_list#keys.;
247 delete[] list->valuescxx . . $ mpv_node_list#values.;
248 }
249
250 delete list;
251 break;
252 }
253
254 default:;
255 }
256
257 dst->format = MPV_FORMAT_NONE;
258 }
259 };
260
261 /**
262 * RAII wrapper that calls mpv_free_node_contents() on the pointer.
263 */
264 struct node_autofreecxx . . $ mpv/qt/node_autofree# {
265 mpv_node* ptrcxx . . $ mpv/qt/node_autofree#ptr.;
266
267 node_autofreecxx . . $ mpv/qt/node_autofree#node_autofree(15db91bf44f8e437).(mpv_node* a_ptr) : ptrcxx . . $ mpv/qt/node_autofree#ptr.(a_ptr) {}
268
269 ~cxx . . $ mpv/qt/node_autofree#`~node_autofree`(ced63f7c635d850d).node_autofreecxx . . $ mpv/qt/node_autofree#() {
270 mpv_free_node_contents(ptrcxx . . $ mpv/qt/node_autofree#ptr.);
271 }
272 };
273
274 /**
275 * Return the given property as mpv_node converted to QVariant, or QVariant()
276 * on error.
277 *
278 * @deprecated use get_property() instead
279 *
280 * @param name the property name
281 */
282 static inline QVariantcxx . . $ QVariant# get_property_variantcxx . . $ mpv/qt/get_property_variant(52e28ddba15e277b).(mpv_handle* ctx, const QStringcxx . . $ QString#& name) {
283 mpv_node node;
284
285 if (mpv_get_property(ctx, name.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), MPV_FORMAT_NODE, &node) < 0) {
286 return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).();
287 }
288
289 node_autofreecxx . . $ mpv/qt/node_autofree# fcxx . . $ mpv/qt/node_autofree#node_autofree(15db91bf44f8e437).(&node);
290 return node_to_variantcxx . . $ mpv/qt/node_to_variant(a25eef8ed7d55b25).(&node);
291 }
292
293 /**
294 * Set the given property as mpv_node converted from the QVariant argument.
295
296 * @deprecated use set_property() instead
297 */
298 static inline int set_property_variantcxx . . $ mpv/qt/set_property_variant(42e2a304dba912b7).(mpv_handle* ctx, const QStringcxx . . $ QString#& name, const QVariantcxx . . $ QVariant#& v) {
299 node_buildercxx . . $ mpv/qt/node_builder# nodecxx . . $ mpv/qt/node_builder#node_builder(244511558b20107a).(v);
300
301 return mpv_set_property(ctx, name.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), MPV_FORMAT_NODE, node.nodecxx . . $ mpv/qt/node_builder#node(98049a0de5819907).());
302 }
303
304 /**
305 * Set the given option as mpv_node converted from the QVariant argument.
306 *
307 * @deprecated use set_property() instead
308 */
309 static inline int set_option_variantcxx . . $ mpv/qt/set_option_variant(42e2a304dba912b7).(mpv_handle* ctx, const QStringcxx . . $ QString#& name, const QVariantcxx . . $ QVariant#& v) {
310 node_buildercxx . . $ mpv/qt/node_builder# nodecxx . . $ mpv/qt/node_builder#node_builder(244511558b20107a).(v);
311
312 return mpv_set_option(ctx, name.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), MPV_FORMAT_NODE, node.nodecxx . . $ mpv/qt/node_builder#node(98049a0de5819907).());
313 }
314
315 /**
316 * mpv_command_node() equivalent. Returns QVariant() on error (and
317 * unfortunately, the same on success).
318 *
319 * @deprecated use command() instead
320 */
321 static inline QVariantcxx . . $ QVariant# command_variantcxx . . $ mpv/qt/command_variant(6a27851f8a72fde5).(mpv_handle* ctx, const QVariantcxx . . $ QVariant#& args) {
322 node_buildercxx . . $ mpv/qt/node_builder# nodecxx . . $ mpv/qt/node_builder#node_builder(244511558b20107a).(args);
323 mpv_node res;
324
325 if (mpv_command_node(ctx, node.nodecxx . . $ mpv/qt/node_builder#node(98049a0de5819907).(), &res) < 0) {
326 return QVariantcxx . . $ QVariant#QVariant(ced63f7c635d850d).();
327 }
328
329 node_autofreecxx . . $ mpv/qt/node_autofree# fcxx . . $ mpv/qt/node_autofree#node_autofree(15db91bf44f8e437).(&res);
330 return node_to_variantcxx . . $ mpv/qt/node_to_variant(a25eef8ed7d55b25).(&res);
331 }
332
333 /**
334 * This is used to return error codes wrapped in QVariant for functions which
335 * return QVariant.
336 *
337 * You can use get_error() or is_error() to extract the error status from a
338 * QVariant value.
339 */
340 struct ErrorReturncxx . . $ mpv/qt/ErrorReturn# {
341 /**
342 * enum mpv_error value (or a value outside of it if ABI was extended)
343 */
344 int errorcxx . . $ mpv/qt/ErrorReturn#error.;
345
346 ErrorReturncxx . . $ mpv/qt/ErrorReturn#ErrorReturn(49f6e7a06ebc5aa8).() : errorcxx . . $ mpv/qt/ErrorReturn#error.(0) {}
347 explicit ErrorReturncxx . . $ mpv/qt/ErrorReturn#ErrorReturn(d4f767463ce0a6b3).(int err) : errorcxx . . $ mpv/qt/ErrorReturn#error.(err) {}
348 };
349
350 /**
351 * Return the mpv error code packed into a QVariant, or 0 (success) if it's not
352 * an error value.
353 *
354 * @return error code (<0) or success (>=0)
355 */
356 static inline int get_errorcxx . . $ mpv/qt/get_error(95f90aa8c114a012).(const QVariantcxx . . $ QVariant#& v) {
357 if (!v.canConvertcxx . . $ QVariant#canConvert(50ce9a9e25b4a850).<ErrorReturncxx . . $ mpv/qt/ErrorReturn#>()) {
358 return 0;
359 }
360
361 return v.valuecxx . . $ QVariant#value(7c9259c808893703).<ErrorReturncxx . . $ mpv/qt/ErrorReturn#>().errorcxx . . $ mpv/qt/ErrorReturn#error.;
362 }
363
364 /**
365 * Return whether the QVariant carries a mpv error code.
366 */
367 static inline bool is_errorcxx . . $ mpv/qt/is_error(a4b3364aca7e48c0).(const QVariantcxx . . $ QVariant#& v) {
368 return get_errorcxx . . $ mpv/qt/get_error(95f90aa8c114a012).(v) < 0;
369 }
370
371 /**
372 * Return the given property as mpv_node converted to QVariant, or QVariant()
373 * on error.
374 *
375 * @param name the property name
376 * @return the property value, or an ErrorReturn with the error code
377 */
378 static inline QVariantcxx . . $ QVariant# get_propertycxx . . $ mpv/qt/get_property(52e28ddba15e277b).(mpv_handle* ctx, const QStringcxx . . $ QString#& name) {
379 mpv_node node;
380 int err = mpv_get_property(ctx, name.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), MPV_FORMAT_NODE, &node);
381
382 if (err < 0) {
383 return QVariantcxx . . $ QVariant#::fromValuecxx . . $ QVariant#fromValue(a298f533828df527).(ErrorReturncxx . . $ mpv/qt/ErrorReturn#(err));
384 }
385
386 node_autofreecxx . . $ mpv/qt/node_autofree# fcxx . . $ mpv/qt/node_autofree#node_autofree(15db91bf44f8e437).(&node);
387 return node_to_variantcxx . . $ mpv/qt/node_to_variant(a25eef8ed7d55b25).(&node);
388 }
389
390 /**
391 * Set the given property as mpv_node converted from the QVariant argument.
392 *
393 * @return mpv error code (<0 on error, >= 0 on success)
394 */
395 static inline int set_propertycxx . . $ mpv/qt/set_property(42e2a304dba912b7).(mpv_handle* ctx, const QStringcxx . . $ QString#& name, const QVariantcxx . . $ QVariant#& v) {
396 node_buildercxx . . $ mpv/qt/node_builder# nodecxx . . $ mpv/qt/node_builder#node_builder(244511558b20107a).(v);
397 return mpv_set_property(ctx, name.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).(), MPV_FORMAT_NODE, node.nodecxx . . $ mpv/qt/node_builder#node(98049a0de5819907).());
398 }
399
400 /**
401 * mpv_command_node() equivalent.
402 *
403 * @param args command arguments, with args[0] being the command name as string
404 * @return the property value, or an ErrorReturn with the error code
405 */
406 static inline QVariantcxx . . $ QVariant# commandcxx . . $ mpv/qt/command(6a27851f8a72fde5).(mpv_handle* ctx, const QVariantcxx . . $ QVariant#& args) {
407 node_buildercxx . . $ mpv/qt/node_builder# nodecxx . . $ mpv/qt/node_builder#node_builder(244511558b20107a).(args);
408 mpv_node res;
409 int err = mpv_command_node(ctx, node.nodecxx . . $ mpv/qt/node_builder#node(98049a0de5819907).(), &res);
410
411 if (err < 0) {
412 return QVariantcxx . . $ QVariant#::fromValuecxx . . $ QVariant#fromValue(a298f533828df527).(ErrorReturncxx . . $ mpv/qt/ErrorReturn#(err));
413 }
414
415 node_autofreecxx . . $ mpv/qt/node_autofree# fcxx . . $ mpv/qt/node_autofree#node_autofree(15db91bf44f8e437).(&res);
416 return node_to_variantcxx . . $ mpv/qt/node_to_variant(a25eef8ed7d55b25).(&res);
417 }
418
419 } // namespace qt
420 } // namespace mpv
421
422 Q_DECLARE_METATYPEcxx . . $ `<external>/1389693584836040939/qmetatype.h:1507:9`!(mpv::qt::ErrorReturn)
423
424 #endif