summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-03-22 20:05:38 +0100
committerLars Knoll <lars.knoll@qt.io>2021-04-06 08:10:38 +0000
commitcb43c7110b6df863c57fed53772c1584d5d7355c (patch)
treef7f3ebcbe7b1d256c7d6840705c0009b0bb4cd1a /examples
parent3b64b3556ca376fbf81cd0f2c9f3507b4d7f65b8 (diff)
Remove the custom video surface examples
They are actually pretty bad examples, as they use QAbstractVideoSurface (which completely changes), and worse, draw everything in software, which is really bad performance wise. Change-Id: I6e6b51baa0915cc52f0741fc47fcbd105d880491 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/multimediawidgets/CMakeLists.txt1
-rw-r--r--examples/multimediawidgets/customvideosurface/CMakeLists.txt4
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/CMakeLists.txt51
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro16
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp64
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp153
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h88
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp185
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h94
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideosurface.pro4
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/CMakeLists.txt46
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro18
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp63
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp154
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h87
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp123
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h80
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp170
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h90
19 files changed, 0 insertions, 1491 deletions
diff --git a/examples/multimediawidgets/CMakeLists.txt b/examples/multimediawidgets/CMakeLists.txt
index db84752e5..64ee051d8 100644
--- a/examples/multimediawidgets/CMakeLists.txt
+++ b/examples/multimediawidgets/CMakeLists.txt
@@ -5,5 +5,4 @@ if(TARGET Qt::Widgets)
add_subdirectory(videographicsitem)
add_subdirectory(videowidget)
add_subdirectory(player)
- add_subdirectory(customvideosurface)
endif()
diff --git a/examples/multimediawidgets/customvideosurface/CMakeLists.txt b/examples/multimediawidgets/customvideosurface/CMakeLists.txt
deleted file mode 100644
index 895bd6fad..000000000
--- a/examples/multimediawidgets/customvideosurface/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from customvideosurface.pro.
-
-add_subdirectory(customvideoitem)
-add_subdirectory(customvideowidget)
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/CMakeLists.txt b/examples/multimediawidgets/customvideosurface/customvideoitem/CMakeLists.txt
deleted file mode 100644
index a6fa324a2..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-# Generated from customvideoitem.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(customvideoitem LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimediawidgets/customvideosurface/customvideoitem")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Multimedia)
-find_package(Qt6 COMPONENTS MultimediaWidgets)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(customvideoitem
- main.cpp
- videoitem.cpp videoitem.h
- videoplayer.cpp videoplayer.h
-)
-set_target_properties(customvideoitem PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(customvideoitem PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Multimedia
- Qt::MultimediaWidgets
- Qt::Widgets
-)
-
-if(TARGET Qt::OpenGL)
- target_link_libraries(customvideoitem PUBLIC
- Qt::OpenGL
- )
-endif()
-
-install(TARGETS customvideoitem
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro b/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro
deleted file mode 100644
index 2fb123e77..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/customvideoitem.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = app
-TARGET = customvideoitem
-
-QT += multimedia multimediawidgets widgets
-
-qtHaveModule(opengl): QT += opengl
-
-HEADERS += videoplayer.h \
- videoitem.h
-
-SOURCES += main.cpp \
- videoplayer.cpp \
- videoitem.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/customvideosurface/customvideoitem
-INSTALLS += target
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp
deleted file mode 100644
index 8db790deb..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 "videoplayer.h"
-
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- VideoPlayer player;
- player.show();
-
- return app.exec();
-}
-
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp
deleted file mode 100644
index 0271f023a..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 "videoitem.h"
-
-#include <QPainter>
-#include <QTransform>
-#include <QVideoSurfaceFormat>
-
-VideoItem::VideoItem(QGraphicsItem *parent)
- : QGraphicsItem(parent)
- , imageFormat(QImage::Format_Invalid)
- , framePainted(false)
-{
-}
-
-VideoItem::~VideoItem() = default;
-
-QRectF VideoItem::boundingRect() const
-{
- return QRectF(QPointF(0,0), surfaceFormat().sizeHint());
-}
-
-void VideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
-
- if (currentFrame.map(QVideoFrame::ReadOnly)) {
- const QTransform oldTransform = painter->transform();
-
- if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) {
- painter->scale(1, -1);
- painter->translate(0, -boundingRect().height());
- }
-
- painter->drawImage(boundingRect(), QImage(
- currentFrame.bits(),
- imageSize.width(),
- imageSize.height(),
- imageFormat));
-
- painter->setTransform(oldTransform);
-
- framePainted = true;
-
- currentFrame.unmap();
- }
-}
-
-QList<QVideoFrame::PixelFormat> VideoItem::supportedPixelFormats(
- QVideoFrame::HandleType handleType) const
-{
- if (handleType == QVideoFrame::NoHandle) {
- return QList<QVideoFrame::PixelFormat>()
- << QVideoFrame::Format_RGB32
- << QVideoFrame::Format_ARGB32
- << QVideoFrame::Format_ARGB32_Premultiplied
- << QVideoFrame::Format_RGB565
- << QVideoFrame::Format_RGB555;
- }
-
- return QList<QVideoFrame::PixelFormat>();
-}
-
-bool VideoItem::start(const QVideoSurfaceFormat &format)
-{
- if (isFormatSupported(format)) {
- imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
- imageSize = format.frameSize();
- framePainted = true;
-
- QAbstractVideoSurface::start(format);
-
- prepareGeometryChange();
-
- return true;
- }
-
- return false;
-}
-
-void VideoItem::stop()
-{
- currentFrame = QVideoFrame();
- framePainted = false;
-
- QAbstractVideoSurface::stop();
-}
-
-bool VideoItem::present(const QVideoFrame &frame)
-{
- if (!framePainted) {
- if (!QAbstractVideoSurface::isActive())
- setError(StoppedError);
-
- return false;
- }
-
- currentFrame = frame;
- framePainted = false;
-
- update();
-
- return true;
-}
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h
deleted file mode 100644
index 7fff81a2f..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoitem.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOITEM_H
-#define VIDEOITEM_H
-
-#include <QAbstractVideoSurface>
-#include <QGraphicsItem>
-
-class VideoItem
- : public QAbstractVideoSurface,
- public QGraphicsItem
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsItem)
-
-public:
- explicit VideoItem(QGraphicsItem *parentItem = 0);
- ~VideoItem();
-
- QRectF boundingRect() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) override;
-
- //video surface
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QVideoFrame::HandleType handleType = QVideoFrame::NoHandle) const override;
-
- bool start(const QVideoSurfaceFormat &format) override;
- void stop() override;
- bool present(const QVideoFrame &frame) override;
-
-private:
- QImage::Format imageFormat;
- QSize imageSize;
-
- QVideoFrame currentFrame;
- bool framePainted;
-};
-
-#endif // VIDEOITEM_H
-
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
deleted file mode 100644
index 2c2286d72..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 "videoplayer.h"
-#include "videoitem.h"
-
-#include <QtWidgets>
-#include <QVideoSurfaceFormat>
-
-#if !defined(QT_NO_OPENGL)
-# include <QOpenGLWidget>
-#endif
-
-VideoPlayer::VideoPlayer(QWidget *parent)
- : QWidget(parent)
- , mediaPlayer(nullptr)
- , videoItem(nullptr)
- , playButton(nullptr)
- , positionSlider(nullptr)
-{
- videoItem = new VideoItem;
-
- QGraphicsScene *scene = new QGraphicsScene(this);
- QGraphicsView *graphicsView = new QGraphicsView(scene);
-
-#if !defined(QT_NO_OPENGL)
- graphicsView->setViewport(new QOpenGLWidget);
-#endif
-
- scene->addItem(videoItem);
-
- QSlider *rotateSlider = new QSlider(Qt::Horizontal);
- rotateSlider->setRange(-180, 180);
- rotateSlider->setValue(0);
-
- connect(rotateSlider, &QSlider::valueChanged,
- this, &VideoPlayer::rotateVideo);
-
- QAbstractButton *openButton = new QPushButton(tr("Open..."));
- connect(openButton, &QAbstractButton::clicked,
- this, &VideoPlayer::openFile);
-
- playButton = new QPushButton;
- playButton->setEnabled(false);
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
-
- connect(playButton, &QAbstractButton::clicked,
- this, &VideoPlayer::play);
-
- positionSlider = new QSlider(Qt::Horizontal);
- positionSlider->setRange(0, 0);
-
- connect(positionSlider, &QSlider::sliderMoved,
- this, &VideoPlayer::setPosition);
-
- QBoxLayout *controlLayout = new QHBoxLayout;
- controlLayout->setContentsMargins(0, 0, 0, 0);
- controlLayout->addWidget(openButton);
- controlLayout->addWidget(playButton);
- controlLayout->addWidget(positionSlider);
-
- QBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(graphicsView);
- layout->addWidget(rotateSlider);
- layout->addLayout(controlLayout);
-
- setLayout(layout);
-
- mediaPlayer.setVideoOutput(videoItem);
- connect(&mediaPlayer, &QMediaPlayer::stateChanged,
- this, &VideoPlayer::mediaStateChanged);
- connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
- connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
-}
-
-VideoPlayer::~VideoPlayer()
-{
-}
-
-
-void VideoPlayer::openFile()
-{
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath());
-
- if (!fileName.isEmpty()) {
- mediaPlayer.setMedia(QUrl::fromLocalFile(fileName));
-
- playButton->setEnabled(true);
- }
-}
-
-void VideoPlayer::play()
-{
- switch(mediaPlayer.state()) {
- case QMediaPlayer::PlayingState:
- mediaPlayer.pause();
- break;
- default:
- mediaPlayer.play();
- break;
- }
-}
-
-void VideoPlayer::mediaStateChanged(QMediaPlayer::State state)
-{
- switch(state) {
- case QMediaPlayer::PlayingState:
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
- break;
- default:
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- break;
- }
-}
-
-void VideoPlayer::positionChanged(qint64 position)
-{
- positionSlider->setValue(position);
-}
-
-void VideoPlayer::durationChanged(qint64 duration)
-{
- positionSlider->setRange(0, duration);
-}
-
-void VideoPlayer::setPosition(int position)
-{
- mediaPlayer.setPosition(position);
-}
-
-
-void VideoPlayer::rotateVideo(int angle)
-{
- //rotate around the center of video element
- qreal x = videoItem->boundingRect().width() / 2.0;
- qreal y = videoItem->boundingRect().height() / 2.0;
- videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y));
-}
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h
deleted file mode 100644
index 0ee7d751e..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOPLAYER_H
-#define VIDEOPLAYER_H
-
-#include <QMediaPlayer>
-#include <QMovie>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QSlider;
-QT_END_NAMESPACE
-
-class VideoItem;
-
-class VideoPlayer : public QWidget
-{
- Q_OBJECT
-
-public:
- VideoPlayer(QWidget *parent = 0);
- ~VideoPlayer();
-
- QSize sizeHint() const override { return QSize(800, 600); }
-
-public slots:
- void openFile();
- void play();
-
-private slots:
- void mediaStateChanged(QMediaPlayer::State state);
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void setPosition(int position);
- void rotateVideo(int angle);
-
-private:
- QMediaPlayer mediaPlayer;
- VideoItem *videoItem;
- QAbstractButton *playButton;
- QSlider *positionSlider;
-};
-
-#endif // VIDEOPLAYER_H
-
diff --git a/examples/multimediawidgets/customvideosurface/customvideosurface.pro b/examples/multimediawidgets/customvideosurface/customvideosurface.pro
deleted file mode 100644
index baffdaba7..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideosurface.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += customvideoitem customvideowidget
-
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/CMakeLists.txt b/examples/multimediawidgets/customvideosurface/customvideowidget/CMakeLists.txt
deleted file mode 100644
index 5f3b41c50..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# Generated from customvideowidget.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(customvideowidget LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/multimediawidgets/customvideosurface/customvideowidget")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Multimedia)
-find_package(Qt6 COMPONENTS MultimediaWidgets)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_executable(customvideowidget
- main.cpp
- videoplayer.cpp videoplayer.h
- videowidget.cpp videowidget.h
- videowidgetsurface.cpp videowidgetsurface.h
-)
-set_target_properties(customvideowidget PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(customvideowidget PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Multimedia
- Qt::MultimediaWidgets
- Qt::Widgets
-)
-
-install(TARGETS customvideowidget
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro b/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro
deleted file mode 100644
index b4476dfb7..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/customvideowidget.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TEMPLATE = app
-TARGET = customvideowidget
-
-QT += multimedia multimediawidgets widgets
-
-HEADERS = \
- videoplayer.h \
- videowidget.h \
- videowidgetsurface.h
-
-SOURCES = \
- main.cpp \
- videoplayer.cpp \
- videowidget.cpp \
- videowidgetsurface.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/customvideosurface/customvideowidget
-INSTALLS += target
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp
deleted file mode 100644
index 0d5e30849..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/main.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 "videoplayer.h"
-
-#include <QtWidgets/QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- VideoPlayer player;
- player.show();
-
- return app.exec();
-}
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp
deleted file mode 100644
index 260daa7c2..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 "videoplayer.h"
-
-#include "videowidget.h"
-
-#include <QtWidgets>
-#include <qvideosurfaceformat.h>
-
-VideoPlayer::VideoPlayer(QWidget *parent)
- : QWidget(parent)
- , mediaPlayer(nullptr)
- , playButton(nullptr)
- , positionSlider(nullptr)
-{
- VideoWidget *videoWidget = new VideoWidget;
-
- QAbstractButton *openButton = new QPushButton(tr("Open..."));
- connect(openButton, &QAbstractButton::clicked,
- this, &VideoPlayer::openFile);
-
- playButton = new QPushButton;
- playButton->setEnabled(false);
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
-
- connect(playButton, &QAbstractButton::clicked,
- this, &VideoPlayer::play);
-
- positionSlider = new QSlider(Qt::Horizontal);
- positionSlider->setRange(0, 0);
-
- connect(positionSlider, &QSlider::sliderMoved,
- this, &VideoPlayer::setPosition);
-
- QBoxLayout *controlLayout = new QHBoxLayout;
- controlLayout->setContentsMargins(0, 0, 0, 0);
- controlLayout->addWidget(openButton);
- controlLayout->addWidget(playButton);
- controlLayout->addWidget(positionSlider);
-
- QBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(videoWidget);
- layout->addLayout(controlLayout);
-
- setLayout(layout);
-
- mediaPlayer.setVideoOutput(videoWidget->videoSurface());
- connect(&mediaPlayer, &QMediaPlayer::stateChanged,
- this, &VideoPlayer::mediaStateChanged);
- connect(&mediaPlayer, &QMediaPlayer::positionChanged, this, &VideoPlayer::positionChanged);
- connect(&mediaPlayer, &QMediaPlayer::durationChanged, this, &VideoPlayer::durationChanged);
-}
-
-VideoPlayer::~VideoPlayer()
-{
-}
-
-void VideoPlayer::openFile()
-{
- QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"),QDir::homePath());
-
- if (!fileName.isEmpty()) {
- mediaPlayer.setMedia(QUrl::fromLocalFile(fileName));
-
- playButton->setEnabled(true);
- }
-}
-
-void VideoPlayer::play()
-{
- switch(mediaPlayer.state()) {
- case QMediaPlayer::PlayingState:
- mediaPlayer.pause();
- break;
- default:
- mediaPlayer.play();
- break;
- }
-}
-
-void VideoPlayer::mediaStateChanged(QMediaPlayer::State state)
-{
- switch(state) {
- case QMediaPlayer::PlayingState:
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
- break;
- default:
- playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
- break;
- }
-}
-
-void VideoPlayer::positionChanged(qint64 position)
-{
- positionSlider->setValue(position);
-}
-
-void VideoPlayer::durationChanged(qint64 duration)
-{
- positionSlider->setRange(0, duration);
-}
-
-void VideoPlayer::setPosition(int position)
-{
- mediaPlayer.setPosition(position);
-}
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h
deleted file mode 100644
index ea9b6cf6b..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videoplayer.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOPLAYER_H
-#define VIDEOPLAYER_H
-
-#include <QMediaPlayer>
-#include <QMovie>
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QSlider;
-QT_END_NAMESPACE
-
-class VideoPlayer : public QWidget
-{
- Q_OBJECT
-
-public:
- VideoPlayer(QWidget *parent = 0);
- ~VideoPlayer();
-
-public slots:
- void openFile();
- void play();
-
-private slots:
- void mediaStateChanged(QMediaPlayer::State state);
- void positionChanged(qint64 position);
- void durationChanged(qint64 duration);
- void setPosition(int position);
-
-private:
- QMediaPlayer mediaPlayer;
- QAbstractButton *playButton;
- QSlider *positionSlider;
-};
-
-#endif // VIDEOPLAYER_H
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp
deleted file mode 100644
index aae032ca3..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 "videowidget.h"
-
-#include "videowidgetsurface.h"
-
-#include <QtWidgets>
-#include <qvideosurfaceformat.h>
-
-//! [0]
-VideoWidget::VideoWidget(QWidget *parent)
- : QWidget(parent)
- , surface(nullptr)
-{
- setAutoFillBackground(false);
- setAttribute(Qt::WA_NoSystemBackground, true);
-
- QPalette palette = this->palette();
- palette.setColor(QPalette::Window, Qt::black);
- setPalette(palette);
-
- setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
-
- surface = new VideoWidgetSurface(this);
-}
-//! [0]
-
-//! [1]
-VideoWidget::~VideoWidget()
-{
- delete surface;
-}
-//! [1]
-
-//! [2]
-QSize VideoWidget::sizeHint() const
-{
- return surface->surfaceFormat().sizeHint();
-}
-//! [2]
-
-
-//! [3]
-void VideoWidget::paintEvent(QPaintEvent *event)
-{
- QPainter painter(this);
-
- if (surface->isActive()) {
- const QRect videoRect = surface->videoRect();
-
- if (!videoRect.contains(event->rect())) {
- QRegion region = event->region();
- region = region.subtracted(videoRect);
-
- QBrush brush = palette().window();
-
- for (const QRect &rect : region)
- painter.fillRect(rect, brush);
- }
-
- surface->paint(&painter);
- } else {
- painter.fillRect(event->rect(), palette().window());
- }
-}
-//! [3]
-
-//! [4]
-void VideoWidget::resizeEvent(QResizeEvent *event)
-{
- QWidget::resizeEvent(event);
-
- surface->updateVideoRect();
-}
-//! [4]
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h
deleted file mode 100644
index 1b90c3642..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidget.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOWIDGET_H
-#define VIDEOWIDGET_H
-
-#include "videowidgetsurface.h"
-
-#include <QWidget>
-
-//! [0]
-class VideoWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- VideoWidget(QWidget *parent = 0);
- ~VideoWidget();
-
- QAbstractVideoSurface *videoSurface() const { return surface; }
-
- QSize sizeHint() const override;
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void resizeEvent(QResizeEvent *event) override;
-
-private:
- VideoWidgetSurface *surface;
-};
-//! [0]
-
-#endif // VIDEOWIDGET_H
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp
deleted file mode 100644
index 2d67b20f6..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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 "videowidgetsurface.h"
-
-#include <QtWidgets>
-#include <qabstractvideosurface.h>
-#include <qvideosurfaceformat.h>
-
-VideoWidgetSurface::VideoWidgetSurface(QWidget *widget, QObject *parent)
- : QAbstractVideoSurface(parent)
- , widget(widget)
- , imageFormat(QImage::Format_Invalid)
-{
-}
-
-//! [0]
-QList<QVideoFrame::PixelFormat> VideoWidgetSurface::supportedPixelFormats(
- QVideoFrame::HandleType handleType) const
-{
- if (handleType == QVideoFrame::NoHandle) {
- return QList<QVideoFrame::PixelFormat>()
- << QVideoFrame::Format_RGB32
- << QVideoFrame::Format_ARGB32
- << QVideoFrame::Format_ARGB32_Premultiplied
- << QVideoFrame::Format_RGB565
- << QVideoFrame::Format_RGB555;
- }
-
- return QList<QVideoFrame::PixelFormat>();
-}
-//! [0]
-
-//! [2]
-bool VideoWidgetSurface::start(const QVideoSurfaceFormat &format)
-{
- const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
- const QSize size = format.frameSize();
-
- if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) {
- this->imageFormat = imageFormat;
- imageSize = size;
- sourceRect = format.viewport();
-
- QAbstractVideoSurface::start(format);
-
- widget->updateGeometry();
- updateVideoRect();
-
- return true;
- }
-
- return false;
-}
-//! [2]
-
-//! [3]
-void VideoWidgetSurface::stop()
-{
- currentFrame = QVideoFrame();
- targetRect = QRect();
-
- QAbstractVideoSurface::stop();
-
- widget->update();
-}
-//! [3]
-
-//! [4]
-bool VideoWidgetSurface::present(const QVideoFrame &frame)
-{
- if (surfaceFormat().pixelFormat() != frame.pixelFormat()
- || surfaceFormat().frameSize() != frame.size()) {
- setError(IncorrectFormatError);
- stop();
-
- return false;
- }
-
- currentFrame = frame;
- widget->repaint(targetRect);
-
- return true;
-}
-//! [4]
-
-//! [5]
-void VideoWidgetSurface::updateVideoRect()
-{
- QSize size = surfaceFormat().sizeHint();
- size.scale(widget->size().boundedTo(size), Qt::KeepAspectRatio);
-
- targetRect = QRect(QPoint(0, 0), size);
- targetRect.moveCenter(widget->rect().center());
-}
-//! [5]
-
-//! [6]
-void VideoWidgetSurface::paint(QPainter *painter)
-{
- if (currentFrame.map(QVideoFrame::ReadOnly)) {
- const QTransform oldTransform = painter->transform();
-
- if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) {
- painter->scale(1, -1);
- painter->translate(0, -widget->height());
- }
-
- QImage image(
- currentFrame.bits(),
- currentFrame.width(),
- currentFrame.height(),
- currentFrame.bytesPerLine(),
- imageFormat);
-
- painter->drawImage(targetRect, image, sourceRect);
-
- painter->setTransform(oldTransform);
-
- currentFrame.unmap();
- }
-}
-//! [6]
diff --git a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h b/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h
deleted file mode 100644
index 3c0820bc4..000000000
--- a/examples/multimediawidgets/customvideosurface/customvideowidget/videowidgetsurface.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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$
-**
-****************************************************************************/
-
-#ifndef VIDEOWIDGETSURFACE_H
-#define VIDEOWIDGETSURFACE_H
-
-#include <QAbstractVideoSurface>
-#include <QImage>
-#include <QRect>
-#include <QVideoFrame>
-
-//! [0]
-class VideoWidgetSurface : public QAbstractVideoSurface
-{
- Q_OBJECT
-
-public:
- VideoWidgetSurface(QWidget *widget, QObject *parent = 0);
-
- QList<QVideoFrame::PixelFormat> supportedPixelFormats(
- QVideoFrame::HandleType handleType = QVideoFrame::NoHandle) const override;
-
- bool start(const QVideoSurfaceFormat &format) override;
- void stop() override;
-
- bool present(const QVideoFrame &frame) override;
-
- QRect videoRect() const { return targetRect; }
- void updateVideoRect();
-
- void paint(QPainter *painter);
-
-private:
- QWidget *widget;
- QImage::Format imageFormat;
- QRect targetRect;
- QSize imageSize;
- QRect sourceRect;
- QVideoFrame currentFrame;
-};
-//! [0]
-
-#endif