summaryrefslogtreecommitdiffstats
path: root/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp')
-rw-r--r--src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp91
1 files changed, 28 insertions, 63 deletions
diff --git a/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp b/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp
index f83f1d518..6ca23006b 100644
--- a/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp
+++ b/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp
@@ -1,70 +1,34 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qgstreamervideooverlay_p.h"
#include <QtGui/qguiapplication.h>
-#include "qgstutils_p.h"
-#include "qgst_p.h"
-#include "qgstreamermessage_p.h"
-#include "qgstreamervideosink_p.h"
+#include <QtMultimedia/private/qtmultimediaglobal_p.h>
-#include <gst/video/videooverlay.h>
+#include <common/qglist_helper_p.h>
+#include <common/qgst_p.h>
+#include <common/qgstreamermessage_p.h>
+#include <common/qgstreamervideosink_p.h>
+#include <common/qgstutils_p.h>
-#include <QtMultimedia/private/qtmultimediaglobal_p.h>
+#include <gst/video/videooverlay.h>
QT_BEGIN_NAMESPACE
struct ElementMap
{
- const char *qtPlatform;
- const char *gstreamerElement;
+ QStringView qtPlatform;
+ const char *gstreamerElement = nullptr;
};
// Ordered by descending priority
-static constexpr ElementMap elementMap[] =
-{
- { "xcb", "xvimagesink" },
- { "xcb", "ximagesink" },
+static constexpr ElementMap elementMap[] = {
+ { u"xcb", "xvimagesink" },
+ { u"xcb", "ximagesink" },
// wayland
- { "wayland", "waylandsink" }
+ { u"wayland", "waylandsink" },
};
static bool qt_gst_element_is_functioning(QGstElement element)
@@ -80,13 +44,14 @@ static bool qt_gst_element_is_functioning(QGstElement element)
static QGstElement findBestVideoSink()
{
+ using namespace Qt::StringLiterals;
QString platform = QGuiApplication::platformName();
// First, try some known video sinks, depending on the Qt platform plugin in use.
- for (auto i : elementMap) {
- if (platform != QLatin1String(i.qtPlatform))
+ for (const auto &i : elementMap) {
+ if (platform != i.qtPlatform)
continue;
- QGstElement choice(i.gstreamerElement, i.gstreamerElement);
+ QGstElement choice = QGstElement::createFromFactory(i.gstreamerElement, i.gstreamerElement);
if (choice.isNull())
continue;
@@ -96,20 +61,18 @@ static QGstElement findBestVideoSink()
// We need a native window ID to use the GstVideoOverlay interface.
// Bail out if the Qt platform plugin in use cannot provide a sensible WId.
- if (platform != QLatin1String("xcb") && platform != QLatin1String("wayland"))
+ if (platform != QStringView{ u"xcb" } && platform != QStringView{ u"wayland" })
return {};
QGstElement choice;
// If none of the known video sinks are available, try to find one that implements the
// GstVideoOverlay interface and has autoplugging rank.
GList *list = qt_gst_video_sinks();
- for (GList *item = list; item != nullptr; item = item->next) {
- GstElementFactory *f = GST_ELEMENT_FACTORY(item->data);
-
+ for (GstElementFactory *f : QGstUtils::GListRangeAdaptor<GstElementFactory *>(list)) {
if (!gst_element_factory_has_interface(f, "GstVideoOverlay"))
continue;
- choice = QGstElement(gst_element_factory_create(f, nullptr));
+ choice = QGstElement::createFromFactory(f, nullptr);
if (choice.isNull())
continue;
@@ -132,7 +95,7 @@ QGstreamerVideoOverlay::QGstreamerVideoOverlay(QGstreamerVideoSink *parent, cons
{
QGstElement sink;
if (!elementName.isEmpty())
- sink = QGstElement(elementName.constData(), nullptr);
+ sink = QGstElement::createFromFactory(elementName.constData());
else
sink = findBestVideoSink();
@@ -157,7 +120,7 @@ void QGstreamerVideoOverlay::setVideoSink(QGstElement sink)
if (sink.isNull())
return;
- m_videoSink = sink;
+ m_videoSink = std::move(sink);
QGstPad pad = m_videoSink.staticPad("sink");
addProbeToPad(pad.pad());
@@ -220,7 +183,7 @@ void QGstreamerVideoOverlay::applyRenderRect()
void QGstreamerVideoOverlay::probeCaps(GstCaps *caps)
{
- QSize size = QGstCaps(caps).at(0).resolution();
+ QSize size = QGstCaps(caps, QGstCaps::NeedsRef).at(0).resolution();
if (size != m_nativeVideoSize) {
m_nativeVideoSize = size;
m_gstreamerVideoSink->setNativeSize(m_nativeVideoSize);
@@ -244,10 +207,12 @@ void QGstreamerVideoOverlay::setFullScreen(bool fullscreen)
bool QGstreamerVideoOverlay::processSyncMessage(const QGstreamerMessage &message)
{
- if (!gst_is_video_overlay_prepare_window_handle_message(message.rawMessage()))
+ if (!gst_is_video_overlay_prepare_window_handle_message(message.message()))
return false;
gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(m_videoSink.object()), m_windowId);
return true;
}
QT_END_NAMESPACE
+
+#include "moc_qgstreamervideooverlay_p.cpp"