summaryrefslogtreecommitdiffstats
path: root/src/gsttools/qgstutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gsttools/qgstutils.cpp')
-rw-r--r--src/gsttools/qgstutils.cpp66
1 files changed, 39 insertions, 27 deletions
diff --git a/src/gsttools/qgstutils.cpp b/src/gsttools/qgstutils.cpp
index b9e04e3f1..b5299f151 100644
--- a/src/gsttools/qgstutils.cpp
+++ b/src/gsttools/qgstutils.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** 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 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** 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.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** 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$
**
@@ -480,7 +486,7 @@ QMultimedia::SupportEstimate QGstUtils::hasSupport(const QString &mimeType,
}
int supportedCodecCount = 0;
- foreach (const QString &codec, codecs) {
+ for (const QString &codec : codecs) {
QString codecLowcase = codec.toLower();
const char* codecAlias = getCodecAlias(codecLowcase);
if (codecAlias) {
@@ -583,10 +589,10 @@ QVector<QGstUtils::CameraInfo> QGstUtils::enumerateCameras(GstElementFactory *fa
QDir devDir(QStringLiteral("/dev"));
devDir.setFilter(QDir::System);
- QFileInfoList entries = devDir.entryInfoList(QStringList()
+ const QFileInfoList entries = devDir.entryInfoList(QStringList()
<< QStringLiteral("video*"));
- foreach (const QFileInfo &entryInfo, entries) {
+ for (const QFileInfo &entryInfo : entries) {
//qDebug() << "Try" << entryInfo.filePath();
int fd = qt_safe_open(entryInfo.filePath().toLatin1().constData(), O_RDWR );
@@ -643,7 +649,9 @@ QList<QByteArray> QGstUtils::cameraDevices(GstElementFactory * factory)
{
QList<QByteArray> devices;
- foreach (const CameraInfo &camera, enumerateCameras(factory))
+ const auto cameras = enumerateCameras(factory);
+ devices.reserve(cameras.size());
+ for (const CameraInfo &camera : cameras)
devices.append(camera.name.toUtf8());
return devices;
@@ -651,7 +659,8 @@ QList<QByteArray> QGstUtils::cameraDevices(GstElementFactory * factory)
QString QGstUtils::cameraDescription(const QString &device, GstElementFactory * factory)
{
- foreach (const CameraInfo &camera, enumerateCameras(factory)) {
+ const auto cameras = enumerateCameras(factory);
+ for (const CameraInfo &camera : cameras) {
if (camera.name == device)
return camera.description;
}
@@ -660,7 +669,8 @@ QString QGstUtils::cameraDescription(const QString &device, GstElementFactory *
QCamera::Position QGstUtils::cameraPosition(const QString &device, GstElementFactory * factory)
{
- foreach (const CameraInfo &camera, enumerateCameras(factory)) {
+ const auto cameras = enumerateCameras(factory);
+ for (const CameraInfo &camera : cameras) {
if (camera.name == device)
return camera.position;
}
@@ -669,7 +679,8 @@ QCamera::Position QGstUtils::cameraPosition(const QString &device, GstElementFac
int QGstUtils::cameraOrientation(const QString &device, GstElementFactory * factory)
{
- foreach (const CameraInfo &camera, enumerateCameras(factory)) {
+ const auto cameras = enumerateCameras(factory);
+ for (const CameraInfo &camera : cameras) {
if (camera.name == device)
return camera.orientation;
}
@@ -678,7 +689,8 @@ int QGstUtils::cameraOrientation(const QString &device, GstElementFactory * fact
QByteArray QGstUtils::cameraDriver(const QString &device, GstElementFactory *factory)
{
- foreach (const CameraInfo &camera, enumerateCameras(factory)) {
+ const auto cameras = enumerateCameras(factory);
+ for (const CameraInfo &camera : cameras) {
if (camera.name == device)
return camera.driver;
}
@@ -749,8 +761,8 @@ QSet<QString> QGstUtils::supportedMimeTypes(bool (*isValidFactory)(GstElementFac
if (value) {
gchar *str = gst_value_serialize(value);
QString versions(str);
- QStringList elements = versions.split(QRegExp("\\D+"), QString::SkipEmptyParts);
- foreach (const QString &e, elements)
+ const QStringList elements = versions.split(QRegExp("\\D+"), QString::SkipEmptyParts);
+ for (const QString &e : elements)
supportedMimeTypes.insert(nameLowcase + e);
g_free(str);
}
@@ -768,7 +780,7 @@ QSet<QString> QGstUtils::supportedMimeTypes(bool (*isValidFactory)(GstElementFac
QStringList list = supportedMimeTypes.toList();
list.sort();
if (qgetenv("QT_DEBUG_PLUGINS").toInt() > 0) {
- foreach (const QString &type, list)
+ for (const QString &type : qAsConst(list))
qDebug() << type;
}
#endif
@@ -1110,7 +1122,7 @@ GstCaps *QGstUtils::capsForFormats(const QList<QVideoFrame::PixelFormat> &format
GstCaps *caps = gst_caps_new_empty();
#if GST_CHECK_VERSION(1,0,0)
- foreach (QVideoFrame::PixelFormat format, formats) {
+ for (QVideoFrame::PixelFormat format : formats) {
int index = indexOfVideoFormat(format);
if (index != -1) {
@@ -1121,7 +1133,7 @@ GstCaps *QGstUtils::capsForFormats(const QList<QVideoFrame::PixelFormat> &format
}
}
#else
- foreach (QVideoFrame::PixelFormat format, formats) {
+ for (QVideoFrame::PixelFormat format : formats) {
int index = indexOfYuvColor(format);
if (index != -1) {