summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Gehör <pekka.gehor@qt.io>2021-09-28 09:39:09 +0300
committerPekka Gehör <pekka.gehor@qt.io>2021-09-30 16:18:44 +0000
commit665060d740b37094d87f9bd71a54d95aa5ced548 (patch)
tree48d967c08b555795ca75a01863bb644e9b8fde32
parent23fa175907e19ecf1b33acab5751662bff0070b2 (diff)
Android: Fix recording a video without audio issue
After fix you can mute/unmute input source. Task-number: QTBUG-96097 Pick-to: 6.2 Change-Id: Idc47eb9a50d4970e96f4a5ed42db55d38e1aebeb Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/multimedia/QtAudioDeviceManager.java11
-rw-r--r--src/multimedia/CMakeLists.txt1
-rw-r--r--src/multimedia/platform/android/common/qandroidaudioinput.cpp81
-rw-r--r--src/multimedia/platform/android/common/qandroidaudioinput_p.h72
-rw-r--r--src/multimedia/platform/android/qandroidintegration.cpp6
-rw-r--r--src/multimedia/platform/android/qandroidintegration_p.h1
6 files changed, 172 insertions, 0 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/multimedia/QtAudioDeviceManager.java b/src/android/jar/src/org/qtproject/qt/android/multimedia/QtAudioDeviceManager.java
index 6aa65d8cb..c2a8a0a51 100644
--- a/src/android/jar/src/org/qtproject/qt/android/multimedia/QtAudioDeviceManager.java
+++ b/src/android/jar/src/org/qtproject/qt/android/multimedia/QtAudioDeviceManager.java
@@ -138,6 +138,17 @@ public class QtAudioDeviceManager
return false;
}
+ private static void setInputMuted(boolean mute)
+ {
+ // This method mutes the microphone across the entire platform
+ m_audioManager.setMicrophoneMute(mute);
+ }
+
+ private static boolean isMicrophoneMute()
+ {
+ return m_audioManager.isMicrophoneMute();
+ }
+
private static String audioDeviceTypeToString(int type)
{
switch (type)
diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt
index 5ed0746a3..283beeab2 100644
--- a/src/multimedia/CMakeLists.txt
+++ b/src/multimedia/CMakeLists.txt
@@ -299,6 +299,7 @@ qt_internal_extend_target(Multimedia CONDITION ANDROID
platform/android/audio/qandroidaudiodevice.cpp platform/android/audio/qandroidaudiodevice_p.h
platform/android/audio/qopenslesengine.cpp platform/android/audio/qopenslesengine_p.h
platform/android/common/qandroidaudiooutput_p.h
+ platform/android/common/qandroidaudioinput.cpp platform/android/common/qandroidaudioinput_p.h
platform/android/audio/qandroidaudiodecoder.cpp platform/android/audio/qandroidaudiodecoder_p.h
platform/android/common/qandroidglobal_p.h
platform/android/common/qandroidmultimediautils.cpp platform/android/common/qandroidmultimediautils_p.h
diff --git a/src/multimedia/platform/android/common/qandroidaudioinput.cpp b/src/multimedia/platform/android/common/qandroidaudioinput.cpp
new file mode 100644
index 000000000..71be7869d
--- /dev/null
+++ b/src/multimedia/platform/android/common/qandroidaudioinput.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qandroidaudioinput_p.h"
+
+#include <qaudioinput.h>
+
+#include <QtCore/qjniobject.h>
+
+QT_BEGIN_NAMESPACE
+
+QAndroidAudioInput::QAndroidAudioInput(QAudioInput *parent)
+ : QObject(parent),
+ QPlatformAudioInput(parent)
+{
+ m_muted = isMuted();
+}
+
+QAndroidAudioInput::~QAndroidAudioInput()
+{
+ setMuted(m_muted);
+}
+
+void QAndroidAudioInput::setMuted(bool muted)
+{
+ bool isInputMuted = isMuted();
+ if (muted != isInputMuted) {
+ QJniObject::callStaticMethod<void>(
+ "org/qtproject/qt/android/multimedia/QtAudioDeviceManager",
+ "setInputMuted",
+ "(Z)V",
+ muted);
+ emit mutedChanged(muted);
+ }
+}
+
+bool QAndroidAudioInput::isMuted() const
+{
+ return QJniObject::callStaticMethod<jboolean>(
+ "org/qtproject/qt/android/multimedia/QtAudioDeviceManager",
+ "isMicrophoneMute",
+ "()Z");
+}
+
+QT_END_NAMESPACE
diff --git a/src/multimedia/platform/android/common/qandroidaudioinput_p.h b/src/multimedia/platform/android/common/qandroidaudioinput_p.h
new file mode 100644
index 000000000..02df2594b
--- /dev/null
+++ b/src/multimedia/platform/android/common/qandroidaudioinput_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QANDROIDAUDIOINPUT_H
+#define QANDROIDAUDIOINPUT_H
+
+#include <QtCore/qobject.h>
+
+#include <private/qtmultimediaglobal_p.h>
+#include <private/qplatformaudioinput_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_MULTIMEDIA_EXPORT QAndroidAudioInput : public QObject, public QPlatformAudioInput
+{
+ Q_OBJECT
+
+public:
+ explicit QAndroidAudioInput(QAudioInput *parent);
+ ~QAndroidAudioInput();
+
+ void setMuted(bool muted) override;
+
+ bool isMuted() const;
+
+Q_SIGNALS:
+ void mutedChanged(bool muted);
+
+private:
+ bool m_muted = false;
+
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/multimedia/platform/android/qandroidintegration.cpp b/src/multimedia/platform/android/qandroidintegration.cpp
index 17a4d03be..69625b117 100644
--- a/src/multimedia/platform/android/qandroidintegration.cpp
+++ b/src/multimedia/platform/android/qandroidintegration.cpp
@@ -53,6 +53,7 @@
#include "private/qandroidformatsinfo_p.h"
#include "private/qandroidmediaplayer_p.h"
#include "private/qandroidaudiooutput_p.h"
+#include "private/qandroidaudioinput_p.h"
#include "private/qandroidvideosink_p.h"
#include "private/qandroidaudiodecoder_p.h"
@@ -121,6 +122,11 @@ QPlatformAudioOutput *QAndroidIntegration::createAudioOutput(QAudioOutput *q)
return new QAndroidAudioOutput(q);
}
+QPlatformAudioInput *QAndroidIntegration::createAudioInput(QAudioInput *audioInput)
+{
+ return new QAndroidAudioInput(audioInput);
+}
+
QPlatformVideoSink *QAndroidIntegration::createVideoSink(QVideoSink *sink)
{
return new QAndroidVideoSink(sink);
diff --git a/src/multimedia/platform/android/qandroidintegration_p.h b/src/multimedia/platform/android/qandroidintegration_p.h
index 790ca41f2..57ef0a9d1 100644
--- a/src/multimedia/platform/android/qandroidintegration_p.h
+++ b/src/multimedia/platform/android/qandroidintegration_p.h
@@ -74,6 +74,7 @@ public:
QPlatformImageCapture *createImageCapture(QImageCapture *imageCapture) override;
QPlatformAudioOutput *createAudioOutput(QAudioOutput *q) override;
+ QPlatformAudioInput *createAudioInput(QAudioInput *audioInput) override;
QPlatformVideoSink *createVideoSink(QVideoSink *) override;