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
qandroidintegration.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 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
12#include "qandroidcamera_p.h"
13#include "qandroidimagecapture_p.h"
22#include <private/qplatformvideodevices_p.h>
23
24#include <QCoreApplication>
25#include <QtCore/qjnitypes.h>
26
27#include <QtMultimedia/private/qplatformmediaplugin_p.h>
28
30
31Q_LOGGING_CATEGORY(qtAndroidMediaPlugin, "qt.multimedia.android")
32
33namespace {
35{
36public:
38
39protected:
41 {
42 return QAndroidCameraSession::availableCameras();
43 }
44};
45} // namespace
46
48{
49 Q_OBJECT
50 Q_PLUGIN_METADATA(IID QPlatformMediaPlugin_iid FILE "android.json")
51
52public:
56
58 {
59 if (name == u"android")
60 return new QAndroidIntegration;
61 return nullptr;
62 }
63};
64
66
68{
69 return new QAndroidAudioDecoder(decoder);
70}
71
73{
74 return new QAndroidFormatInfo;
75}
76
81
83{
84 return new QAndroidMediaPlayer(player);
85}
86
87q23::expected<QPlatformCamera *, QString> QAndroidIntegration::createCamera(QCamera *camera)
88{
89 return new QAndroidCamera(camera);
90}
91
93{
94 return new QAndroidMediaEncoder(recorder);
95}
96
98{
99 return new QAndroidImageCapture(imageCapture);
100}
101
103{
104 return new QAndroidAudioOutput(q);
105}
106
108{
109 return new QAndroidAudioInput(audioInput);
110}
111
112q23::expected<QPlatformVideoSink *, QString> QAndroidIntegration::createVideoSink(QVideoSink *sink)
113{
114 return new QAndroidVideoSink(sink);
115}
116
117Q_DECLARE_JNI_CLASS(QtMultimediaUtils, "org/qtproject/qt/android/multimedia/QtMultimediaUtils")
118
120{
121 static const bool result = []{
122 const auto context = QNativeInterface::QAndroidApplication::context();
123 QtJniTypes::QtMultimediaUtils::callStaticMethod<void>("setContext", context);
124
130 }();
131 return result;
132}
133
135{
136 return new AndroidVideoDevices(this);
137}
138
139QT_END_NAMESPACE
140
141extern "C" Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/)
142{
143 static bool initialized = false;
144 if (initialized)
145 return JNI_VERSION_1_6;
146 initialized = true;
147
148 QT_USE_NAMESPACE
149 typedef union {
150 JNIEnv *nativeEnvironment;
151 void *venv;
152 } UnionJNIEnvToVoid;
153
154 UnionJNIEnvToVoid uenv;
155 uenv.venv = NULL;
156
157 if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK)
158 return JNI_ERR;
159
160 if (!QAndroidIntegration::registerNativeMethods())
161 return JNI_ERR;
162
163 return JNI_VERSION_1_6;
164}
165
166#include "qandroidintegration.moc"
static bool registerNativeMethods()
static bool registerNativeMethods()
static bool registerNativeMethods()
QPlatformVideoDevices * createVideoDevices() override
q23::expected< QPlatformAudioInput *, QString > createAudioInput(QAudioInput *audioInput) override
q23::expected< QPlatformAudioDecoder *, QString > createAudioDecoder(QAudioDecoder *decoder) override
q23::expected< QPlatformAudioOutput *, QString > createAudioOutput(QAudioOutput *q) override
q23::expected< QPlatformImageCapture *, QString > createImageCapture(QImageCapture *imageCapture) override
q23::expected< QPlatformMediaRecorder *, QString > createRecorder(QMediaRecorder *recorder) override
q23::expected< QPlatformMediaPlayer *, QString > createPlayer(QMediaPlayer *player) override
QPlatformMediaFormatInfo * createFormatInfo() override
q23::expected< QPlatformMediaCaptureSession *, QString > createCaptureSession() override
static bool registerNativeMethods()
QList< QCameraDevice > findVideoInputs() const override
Combined button and popup list for selecting options.
Q_DECLARE_JNI_CLASS(MotionEvent, "android/view/MotionEvent")