summaryrefslogtreecommitdiffstats
path: root/examples/multimedia
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multimedia')
-rw-r--r--examples/multimedia/audiodevices/audiodevices.cpp2
-rw-r--r--examples/multimedia/audioinput/audioinput.cpp4
-rw-r--r--examples/multimedia/audiooutput/audiooutput.cpp4
-rw-r--r--examples/multimedia/spectrum/app/engine.cpp12
-rw-r--r--examples/multimedia/spectrum/app/levelmeter.h6
-rw-r--r--examples/multimedia/spectrum/app/mainwidget.cpp2
-rw-r--r--examples/multimedia/spectrum/app/settingsdialog.cpp5
-rw-r--r--examples/multimedia/spectrum/app/waveform.cpp5
-rw-r--r--examples/multimedia/video/android/android.pro5
-rw-r--r--examples/multimedia/video/android/gstreamer/gstreamer.pro23
-rw-r--r--examples/multimedia/video/android/gstreamer/main.cpp115
-rw-r--r--examples/multimedia/video/android/gstreamer/main.qml75
-rw-r--r--examples/multimedia/video/android/gstreamer/qml.qrc5
-rw-r--r--examples/multimedia/video/video.pro2
14 files changed, 242 insertions, 23 deletions
diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp
index 468dbc659..52ff2176a 100644
--- a/examples/multimedia/audiodevices/audiodevices.cpp
+++ b/examples/multimedia/audiodevices/audiodevices.cpp
@@ -150,7 +150,7 @@ void AudioTest::modeChanged(int idx)
deviceBox->clear();
const QAudio::Mode mode = idx == 0 ? QAudio::AudioInput : QAudio::AudioOutput;
for (auto &deviceInfo: QAudioDeviceInfo::availableDevices(mode))
- deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo));
+ deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo));
deviceBox->setCurrentIndex(0);
deviceChanged(0);
diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp
index ec6088780..86da20d51 100644
--- a/examples/multimedia/audioinput/audioinput.cpp
+++ b/examples/multimedia/audioinput/audioinput.cpp
@@ -239,10 +239,10 @@ void InputTest::initializeWindow()
m_deviceBox = new QComboBox(this);
const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultInputDevice();
- m_deviceBox->addItem(defaultDeviceInfo.deviceName(), qVariantFromValue(defaultDeviceInfo));
+ m_deviceBox->addItem(defaultDeviceInfo.deviceName(), QVariant::fromValue(defaultDeviceInfo));
for (auto &deviceInfo: QAudioDeviceInfo::availableDevices(QAudio::AudioInput)) {
if (deviceInfo != defaultDeviceInfo)
- m_deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo));
+ m_deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo));
}
connect(m_deviceBox, QOverload<int>::of(&QComboBox::activated), this, &InputTest::deviceChanged);
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp
index 229727422..69b4470be 100644
--- a/examples/multimedia/audiooutput/audiooutput.cpp
+++ b/examples/multimedia/audiooutput/audiooutput.cpp
@@ -169,10 +169,10 @@ void AudioTest::initializeWindow()
m_deviceBox = new QComboBox(this);
const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultOutputDevice();
- m_deviceBox->addItem(defaultDeviceInfo.deviceName(), qVariantFromValue(defaultDeviceInfo));
+ m_deviceBox->addItem(defaultDeviceInfo.deviceName(), QVariant::fromValue(defaultDeviceInfo));
for (auto &deviceInfo: QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) {
if (deviceInfo != defaultDeviceInfo)
- m_deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo));
+ m_deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo));
}
connect(m_deviceBox, QOverload<int>::of(&QComboBox::activated), this, &AudioTest::deviceChanged);
layout->addWidget(m_deviceBox);
diff --git a/examples/multimedia/spectrum/app/engine.cpp b/examples/multimedia/spectrum/app/engine.cpp
index 7e11d012b..fd977785b 100644
--- a/examples/multimedia/spectrum/app/engine.cpp
+++ b/examples/multimedia/spectrum/app/engine.cpp
@@ -570,14 +570,14 @@ bool Engine::selectFormat()
sampleRatesList += m_audioOutputDevice.supportedSampleRates();
sampleRatesList = sampleRatesList.toSet().toList(); // remove duplicates
- qSort(sampleRatesList);
+ std::sort(sampleRatesList.begin(), sampleRatesList.end());
ENGINE_DEBUG << "Engine::initialize frequenciesList" << sampleRatesList;
QList<int> channelsList;
channelsList += m_audioInputDevice.supportedChannelCounts();
channelsList += m_audioOutputDevice.supportedChannelCounts();
channelsList = channelsList.toSet().toList();
- qSort(channelsList);
+ std::sort(channelsList.begin(), channelsList.end());
ENGINE_DEBUG << "Engine::initialize channelsList" << channelsList;
QAudioFormat format;
@@ -585,12 +585,11 @@ bool Engine::selectFormat()
format.setCodec("audio/pcm");
format.setSampleSize(16);
format.setSampleType(QAudioFormat::SignedInt);
- int sampleRate, channels;
- foreach (sampleRate, sampleRatesList) {
+ for (int sampleRate : qAsConst(sampleRatesList)) {
if (foundSupportedFormat)
break;
format.setSampleRate(sampleRate);
- foreach (channels, channelsList) {
+ for (int channels : qAsConst(channelsList)) {
format.setChannelCount(channels);
const bool inputSupport = m_generateTone ||
m_audioInputDevice.isFormatSupported(format);
@@ -752,8 +751,7 @@ void Engine::createOutputDir()
// Ensure output directory exists and is empty
if (m_outputDir.exists()) {
const QStringList files = m_outputDir.entryList(QDir::Files);
- QString file;
- foreach (file, files)
+ for (const QString &file : files)
m_outputDir.remove(file);
} else {
QDir::current().mkdir("output");
diff --git a/examples/multimedia/spectrum/app/levelmeter.h b/examples/multimedia/spectrum/app/levelmeter.h
index 860e07ffc..987f90e8f 100644
--- a/examples/multimedia/spectrum/app/levelmeter.h
+++ b/examples/multimedia/spectrum/app/levelmeter.h
@@ -51,7 +51,7 @@
#ifndef LEVELMETER_H
#define LEVELMETER_H
-#include <QTime>
+#include <QElapsedTimer>
#include <QWidget>
/**
@@ -99,7 +99,7 @@ private:
/**
* Time at which m_peakLevel was last changed.
*/
- QTime m_peakLevelChanged;
+ QElapsedTimer m_peakLevelChanged;
/**
* Rate at which peak level bar decays.
@@ -116,7 +116,7 @@ private:
/**
* Time at which m_peakHoldLevel was last changed.
*/
- QTime m_peakHoldLevelChanged;
+ QElapsedTimer m_peakHoldLevelChanged;
QTimer *m_redrawTimer;
diff --git a/examples/multimedia/spectrum/app/mainwidget.cpp b/examples/multimedia/spectrum/app/mainwidget.cpp
index 945313f32..235608a05 100644
--- a/examples/multimedia/spectrum/app/mainwidget.cpp
+++ b/examples/multimedia/spectrum/app/mainwidget.cpp
@@ -265,7 +265,7 @@ void MainWidget::createUi()
QScopedPointer<QHBoxLayout> waveformLayout(new QHBoxLayout);
waveformLayout->addWidget(m_progressBar);
m_progressBar->setMinimumHeight(m_waveform->minimumHeight());
- waveformLayout->setMargin(0);
+ waveformLayout->setContentsMargins(0, 0, 0, 0);
m_waveform->setLayout(waveformLayout.data());
waveformLayout.take();
windowLayout->addWidget(m_waveform);
diff --git a/examples/multimedia/spectrum/app/settingsdialog.cpp b/examples/multimedia/spectrum/app/settingsdialog.cpp
index f1723077e..889fcf639 100644
--- a/examples/multimedia/spectrum/app/settingsdialog.cpp
+++ b/examples/multimedia/spectrum/app/settingsdialog.cpp
@@ -72,11 +72,10 @@ SettingsDialog::SettingsDialog(
// Populate combo boxes
- QAudioDeviceInfo device;
- foreach (device, availableInputDevices)
+ for (const QAudioDeviceInfo &device : availableInputDevices)
m_inputDeviceComboBox->addItem(device.deviceName(),
QVariant::fromValue(device));
- foreach (device, availableOutputDevices)
+ for (const QAudioDeviceInfo &device : availableOutputDevices)
m_outputDeviceComboBox->addItem(device.deviceName(),
QVariant::fromValue(device));
diff --git a/examples/multimedia/spectrum/app/waveform.cpp b/examples/multimedia/spectrum/app/waveform.cpp
index 33e0297bc..d0058b2e3 100644
--- a/examples/multimedia/spectrum/app/waveform.cpp
+++ b/examples/multimedia/spectrum/app/waveform.cpp
@@ -243,10 +243,7 @@ void Waveform::audioPositionChanged(qint64 position)
void Waveform::deletePixmaps()
{
- QPixmap *pixmap;
- foreach (pixmap, m_pixmaps)
- delete pixmap;
- m_pixmaps.clear();
+ qDeleteAll(qExchange(m_pixmaps, {}));
}
void Waveform::createPixmaps(const QSize &widgetSize)
diff --git a/examples/multimedia/video/android/android.pro b/examples/multimedia/video/android/android.pro
new file mode 100644
index 000000000..95ed21e17
--- /dev/null
+++ b/examples/multimedia/video/android/android.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+QT_FOR_CONFIG += multimedia-private
+
+qtConfig(gstreamer): SUBDIRS += gstreamer
diff --git a/examples/multimedia/video/android/gstreamer/gstreamer.pro b/examples/multimedia/video/android/gstreamer/gstreamer.pro
new file mode 100644
index 000000000..edc040adc
--- /dev/null
+++ b/examples/multimedia/video/android/gstreamer/gstreamer.pro
@@ -0,0 +1,23 @@
+QT += quick multimedia multimediawidgets
+CONFIG += c++11
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/video/android/gstreamer
+INSTALLS += target
+
+GSTREAMER_ROOT_ANDROID = $$(GSTREAMER_ROOT_ANDROID)
+isEmpty(GSTREAMER_ROOT_ANDROID): error("GSTREAMER_ROOT_ANDROID is empty")
+
+INCLUDEPATH += $(GSTREAMER_ROOT_ANDROID)/armv7/include/ $(GSTREAMER_ROOT_ANDROID)/armv7/include/gstreamer-1.0 $(GSTREAMER_ROOT_ANDROID)/armv7/include/glib-2.0 $(GSTREAMER_ROOT_ANDROID)/armv7/lib/glib-2.0/include
+
+QT+=multimediagsttools-private
+LIBS += -L$(GSTREAMER_ROOT_ANDROID)/armv7/lib/ -L$(GSTREAMER_ROOT_ANDROID)/armv7/lib/gstreamer-1.0 \
+-lgstcoreelements -lgstplayback -lgstvideotestsrc -lgstaudioconvert -lgstvideoconvert -lgstautodetect -lgsttypefindfunctions \
+#PLUGINS codecs
+-lgstvorbis -lvorbis -lgstivorbisdec -lvorbisenc -lvorbisfile -lgstsubparse -lgstaudioparsers \
+-lgstgio -lgstapp -lgstisomp4 -lgstavi -lgstogg -lgstwavenc -lgstwavpack -lgstwavparse -lgsttheora -lgstmpg123 -lgstx264 -lgstlibav \
+-lgsttcp -lgstsoup -logg -ltheora -lmpg123 -lx264 -lavfilter -lavformat -lavcodec -lavutil -lbz2 -lswresample \
+-lsoup-2.4 -lgio-2.0 -lgstrtp-1.0 -lgstriff-1.0 -lgstnet-1.0
diff --git a/examples/multimedia/video/android/gstreamer/main.cpp b/examples/multimedia/video/android/gstreamer/main.cpp
new file mode 100644
index 000000000..56037aece
--- /dev/null
+++ b/examples/multimedia/video/android/gstreamer/main.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+#include <private/qgstutils_p.h>
+
+#include <gst/gstplugin.h>
+extern "C" {
+GST_PLUGIN_STATIC_DECLARE(coreelements);
+GST_PLUGIN_STATIC_DECLARE(playback);
+GST_PLUGIN_STATIC_DECLARE(videotestsrc);
+GST_PLUGIN_STATIC_DECLARE(audioconvert);
+GST_PLUGIN_STATIC_DECLARE(videoconvert);
+GST_PLUGIN_STATIC_DECLARE(autodetect);
+GST_PLUGIN_STATIC_DECLARE(gio);
+GST_PLUGIN_STATIC_DECLARE(soup);
+GST_PLUGIN_STATIC_DECLARE(app);
+GST_PLUGIN_STATIC_DECLARE(isomp4);
+GST_PLUGIN_STATIC_DECLARE(avi);
+GST_PLUGIN_STATIC_DECLARE(ogg);
+GST_PLUGIN_STATIC_DECLARE(vorbis);
+GST_PLUGIN_STATIC_DECLARE(tcp);
+GST_PLUGIN_STATIC_DECLARE(audioparsers);
+GST_PLUGIN_STATIC_DECLARE(theora);
+GST_PLUGIN_STATIC_DECLARE(mpg123);
+GST_PLUGIN_STATIC_DECLARE(typefindfunctions);
+GST_PLUGIN_STATIC_DECLARE(x264);
+GST_PLUGIN_STATIC_DECLARE(libav);
+};
+
+int main(int argc, char *argv[])
+{
+ QGstUtils::initializeGst();
+
+ GST_PLUGIN_STATIC_REGISTER(coreelements);
+ GST_PLUGIN_STATIC_REGISTER(playback);
+ GST_PLUGIN_STATIC_REGISTER(videotestsrc);
+ GST_PLUGIN_STATIC_REGISTER(audioconvert);
+ GST_PLUGIN_STATIC_REGISTER(videoconvert);
+ GST_PLUGIN_STATIC_REGISTER(autodetect);
+ GST_PLUGIN_STATIC_REGISTER(soup);
+ GST_PLUGIN_STATIC_REGISTER(gio);
+ GST_PLUGIN_STATIC_REGISTER(app);
+ GST_PLUGIN_STATIC_REGISTER(isomp4);
+ GST_PLUGIN_STATIC_REGISTER(avi);
+ GST_PLUGIN_STATIC_REGISTER(ogg);
+ GST_PLUGIN_STATIC_REGISTER(vorbis);
+ GST_PLUGIN_STATIC_REGISTER(tcp);
+ GST_PLUGIN_STATIC_REGISTER(audioparsers);
+ GST_PLUGIN_STATIC_REGISTER(theora);
+ GST_PLUGIN_STATIC_REGISTER(mpg123);
+ GST_PLUGIN_STATIC_REGISTER(typefindfunctions);
+ GST_PLUGIN_STATIC_REGISTER(x264);
+ GST_PLUGIN_STATIC_REGISTER(libav);
+
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QLatin1String("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+
+ return app.exec();
+}
diff --git a/examples/multimedia/video/android/gstreamer/main.qml b/examples/multimedia/video/android/gstreamer/main.qml
new file mode 100644
index 000000000..99acb558c
--- /dev/null
+++ b/examples/multimedia/video/android/gstreamer/main.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Controls 2.0
+import QtQuick.Layouts 1.3
+import QtMultimedia 5.12
+
+ApplicationWindow {
+ visible: true
+ width: 640
+ height: 480
+
+ Video {
+ id: video
+ anchors.fill: parent
+ autoPlay: true
+ autoLoad: true
+ source: "gst-pipeline: videotestsrc ! qtvideosink"
+ }
+
+ MouseArea {
+ anchors.fill: video
+ onClicked: {
+ video.play()
+ }
+ }
+}
diff --git a/examples/multimedia/video/android/gstreamer/qml.qrc b/examples/multimedia/video/android/gstreamer/qml.qrc
new file mode 100644
index 000000000..5f6483ac3
--- /dev/null
+++ b/examples/multimedia/video/android/gstreamer/qml.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/multimedia/video/video.pro b/examples/multimedia/video/video.pro
index f38cbc124..ef5bc849d 100644
--- a/examples/multimedia/video/video.pro
+++ b/examples/multimedia/video/video.pro
@@ -5,3 +5,5 @@ SUBDIRS += qmlvideo qmlvideofx
EXAMPLE_FILES += \
qmlvideofilter_opencl \ # FIXME: this one should use a configure check instead
snippets
+
+android: SUBDIRS += android