Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
mediabackendutils_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 GPL-3.0-only
3
4#ifndef MEDIABACKENDUTILS_H
5#define MEDIABACKENDUTILS_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 <QtTest/qtestcase.h>
19#include <private/qplatformmediaintegration_p.h>
20#include <QtGui/private/qguiapplication_p.h>
21#include <QtGui/qpa/qplatformintegration.h>
22
24
25using namespace Qt::Literals;
26
28{
29 return QPlatformMediaIntegration::instance()->name() == "gstreamer"_L1;
30}
31
32inline bool isQNXPlatform()
33{
34 return QPlatformMediaIntegration::instance()->name() == "qnx"_L1;
35}
36
37inline bool isDarwinPlatform()
38{
39 return QPlatformMediaIntegration::instance()->name() == "darwin"_L1;
40}
41
42inline bool isAndroidPlatform()
43{
44 return QPlatformMediaIntegration::instance()->name() == "android"_L1;
45}
46
47inline bool isOhosPlatform()
48{
49 return QPlatformMediaIntegration::instance()->name() == "ohos"_L1;
50}
51
52inline bool isFFMPEGPlatform()
53{
54 return QPlatformMediaIntegration::instance()->name() == "ffmpeg"_L1;
55}
56
57inline bool isWindowsPlatform()
58{
59 return QPlatformMediaIntegration::instance()->name() == "windows"_L1;
60}
61
63{
64 return QPlatformMediaIntegration::instance()->name() != "fallback"_L1;
65}
66
68{
69 QString backend = qEnvironmentVariable("QT_MEDIA_BACKEND");
70 if (backend.isEmpty())
71 backend = QPlatformMediaIntegration::defaultBackend();
72 QPlatformMediaIntegration::setBackend(backend);
73}
74
75// Returns true if initialization is successful
77{
78 // VERIFY must be inside a void-returning function.
79 []() {
80 QVERIFY2(
82 "No media backend plugin was loaded; the fallback integration was used. "
83 "Integration tests require a real backend plugin.");
84 }();
85 return !QTest::currentTestFailed();
86}
87
89{
90 return QGuiApplicationPrivate::platformIntegration()->hasCapability(
91 QPlatformIntegration::RhiBasedRendering);
92}
93
94inline bool isOpenGLSupported()
95{
96 return QGuiApplicationPrivate::platformIntegration()->hasCapability(
97 QPlatformIntegration::OpenGL);
98}
99
100inline bool isCI()
101{
102 return qEnvironmentVariable("QTEST_ENVIRONMENT").toLower().split(u' ').contains(u"ci"_s);
103}
104
105} // namespace BackendUtilsImpl
106
107using namespace BackendUtilsImpl;
108
109#define QSKIP_IF(checker, defaultMessage, /*messageOpt*/...)
110 do {
111 if (checker)
112 QSKIP(strlen(__VA_ARGS__ "") ? __VA_ARGS__ "" : defaultMessage);
113 } while (0)
114
115#define QSKIP_GSTREAMER(/*messageOpt*/...)
116 QSKIP_IF(isGStreamerPlatform(), "The feature is not supported on GStreamer", __VA_ARGS__)
117
118#define QSKIP_IF_NOT_FFMPEG(/*messageOpt*/...)
119 QSKIP_IF(!isFFMPEGPlatform(), "The feature is only supported on FFmpeg", __VA_ARGS__)
120
121#define QSKIP_FFMPEG(/*messageOpt*/...)
122 QSKIP_IF(isFFMPEGPlatform(), "The feature is not supported on FFmpeg", __VA_ARGS__)
123
124#define QSKIP_DARWIN(/*messageOpt*/...)
125 QSKIP_IF(isDarwinPlatform(), "The feature is not supported on Darwin", __VA_ARGS__)
126
127#define QSKIP_OHOS(/*messageOpt*/...)
128 QSKIP_IF(isOhosPlatform(), "The feature is not supported on HarmonyOS", __VA_ARGS__)
129
130#define QEXPECT_FAIL_GSTREAMER(dataIndex, comment, mode)
131 do {
132 if (isGStreamerPlatform())
133 QEXPECT_FAIL(dataIndex, comment, mode);
134 } while (0)
135
136#endif // MEDIABACKENDUTILS_H
#define QSKIP_IF(checker, defaultMessage,...)