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
qplatformlibcameraintegration.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 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
5
6#include <QtMultimedia/private/qplatformlibcameraplugin_p.h>
7
8#include <QtCore/qapplicationstatic.h>
9#include <QtCore/private/qfactoryloader_p.h>
10
12
13namespace QLibCamera {
14
15Q_STATIC_LOGGING_CATEGORY(qLcMediaPlugin, "qt.multimedia.plugin")
16
19
20namespace {
21
22Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, libCameraLoader,
23 (QPlatformLibCameraPlugin_iid, QLatin1String("/libcamera")))
24
25struct LibCameraInstanceHolder
26{
27 LibCameraInstanceHolder() { init(); }
28
29 void init()
30 {
31 qCDebug(qLcMediaPlugin) << "Loading libcamera plugin";
32 QObject *factoryObject = libCameraLoader()->instance(0);
33 if (auto *factory = qobject_cast<QPlatformLibCameraPlugin *>(factoryObject))
34 instance = factory->create();
35
36 if (!instance)
37 qCWarning(qLcMediaPlugin)
38 << "libcamera plugin failed to load; falling back to the platform's default "
39 "camera support";
40 }
41
42 std::unique_ptr<QPlatformLibCameraIntegration> instance;
43};
44
45Q_APPLICATION_STATIC(LibCameraInstanceHolder, s_libCameraInstanceHolder);
46
47} // namespace
48
50{
51 return s_libCameraInstanceHolder->instance.get();
52}
53
54} // namespace QLibCamera
55
56QT_END_NAMESPACE
57
58#include "moc_qplatformlibcameraintegration_p.cpp"
QPlatformLibCameraIntegration * libCameraIntegration()
Combined button and popup list for selecting options.