Rename QtMultimediaKit to QtMultimedia.
There are a few legacy bits left in place so it passes CI, and then qt5.git etc can be updated. Change-Id: I6b082e50e6958c72fdabc2974992e16d90dafa3a Reviewed-on: http://codereview.qt-project.org/5368 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
55bc4f2b46
commit
03f22bcdaf
68
src/multimediawidgets/multimediawidgets.pro
Normal file
68
src/multimediawidgets/multimediawidgets.pro
Normal file
@@ -0,0 +1,68 @@
|
||||
load(qt_module)
|
||||
|
||||
# distinct from QtMultimedia
|
||||
TARGET = QtMultimediaWidgets
|
||||
QPRO_PWD = $$PWD
|
||||
QT = core gui multimedia-private widgets
|
||||
|
||||
CONFIG += module no_private_qt_headers_warning
|
||||
MODULE_PRI += ../../modules/qt_multimediawidgets.pri
|
||||
|
||||
contains(QT_CONFIG, opengl) | contains(QT_CONFIG, opengles2) {
|
||||
QT += opengl
|
||||
} else {
|
||||
DEFINES += QT_NO_OPENGL
|
||||
}
|
||||
|
||||
!static:DEFINES += QT_MAKEDLL
|
||||
DEFINES += QT_BUILD_MULTIMEDIAWIDGETS_LIB
|
||||
|
||||
load(qt_module_config)
|
||||
|
||||
PRIVATE_HEADERS += \
|
||||
qvideowidget_p.h \
|
||||
qpaintervideosurface_p.h \
|
||||
|
||||
PUBLIC_HEADERS += \
|
||||
qtmultimediawidgetdefs.h \
|
||||
qtmultimediawidgetsversion.h \
|
||||
qcameraviewfinder.h \
|
||||
qgraphicsvideoitem.h \
|
||||
qvideowidgetcontrol.h \
|
||||
qvideowidget.h \
|
||||
qvideowindowcontrol.h
|
||||
|
||||
SOURCES += \
|
||||
qcameraviewfinder.cpp \
|
||||
qpaintervideosurface.cpp \
|
||||
qvideowidgetcontrol.cpp \
|
||||
qvideowidget.cpp \
|
||||
qvideowindowcontrol.cpp \
|
||||
|
||||
mac:!qpa {
|
||||
!simulator {
|
||||
PRIVATE_HEADERS += qpaintervideosurface_mac_p.h
|
||||
OBJECTIVE_SOURCES += qpaintervideosurface_mac.mm
|
||||
}
|
||||
LIBS += -framework AppKit -framework QuartzCore -framework QTKit
|
||||
}
|
||||
|
||||
maemo6 {
|
||||
isEqual(QT_ARCH,armv6) {
|
||||
PRIVATE_HEADERS += qeglimagetexturesurface_p.h
|
||||
SOURCES += qeglimagetexturesurface.cpp
|
||||
|
||||
SOURCES += qgraphicsvideoitem_maemo6.cpp
|
||||
|
||||
LIBS += -lX11
|
||||
} else {
|
||||
SOURCES += qgraphicsvideoitem.cpp
|
||||
}
|
||||
}
|
||||
|
||||
!maemo* {
|
||||
SOURCES += qgraphicsvideoitem.cpp
|
||||
}
|
||||
|
||||
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
|
||||
|
||||
113
src/multimediawidgets/qcameraviewfinder.cpp
Normal file
113
src/multimediawidgets/qcameraviewfinder.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <private/qmediaobject_p.h>
|
||||
|
||||
#include <qcamera.h>
|
||||
#include <qcameraviewfinder.h>
|
||||
#include <qvideowidget_p.h>
|
||||
#include <qvideodevicecontrol.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QCameraViewfinder
|
||||
|
||||
|
||||
\brief The QCameraViewfinder class provides a camera viewfinder widget.
|
||||
|
||||
\inmodule QtMultimedia
|
||||
\ingroup camera
|
||||
\since 1.1
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/camera.cpp Camera
|
||||
|
||||
*/
|
||||
|
||||
class QCameraViewfinderPrivate : public QVideoWidgetPrivate
|
||||
{
|
||||
Q_DECLARE_NON_CONST_PUBLIC(QCameraViewfinder)
|
||||
public:
|
||||
QCameraViewfinderPrivate():
|
||||
QVideoWidgetPrivate()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
Constructs a new camera viewfinder widget.
|
||||
|
||||
The \a parent is passed to QVideoWidget.
|
||||
*/
|
||||
|
||||
QCameraViewfinder::QCameraViewfinder(QWidget *parent)
|
||||
:QVideoWidget(*new QCameraViewfinderPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a camera viewfinder widget.
|
||||
*/
|
||||
QCameraViewfinder::~QCameraViewfinder()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
\since 1.1
|
||||
*/
|
||||
QMediaObject *QCameraViewfinder::mediaObject() const
|
||||
{
|
||||
return QVideoWidget::mediaObject();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
\since 1.1
|
||||
*/
|
||||
bool QCameraViewfinder::setMediaObject(QMediaObject *object)
|
||||
{
|
||||
return QVideoWidget::setMediaObject(object);
|
||||
}
|
||||
|
||||
#include "moc_qcameraviewfinder.cpp"
|
||||
90
src/multimediawidgets/qcameraviewfinder.h
Normal file
90
src/multimediawidgets/qcameraviewfinder.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QCAMERAVIEWFINDER_H
|
||||
#define QCAMERAVIEWFINDER_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <QtCore/qsize.h>
|
||||
#include <QtCore/qpoint.h>
|
||||
#include <QtCore/qrect.h>
|
||||
|
||||
#include <qmediacontrol.h>
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qvideowidget.h>
|
||||
|
||||
#include <qmediaserviceprovider.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QCamera;
|
||||
|
||||
class QCameraViewfinderPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QCameraViewfinder : public QVideoWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QCameraViewfinder(QWidget *parent = 0);
|
||||
~QCameraViewfinder();
|
||||
|
||||
QMediaObject *mediaObject() const;
|
||||
|
||||
protected:
|
||||
bool setMediaObject(QMediaObject *object);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QCameraViewfinder)
|
||||
Q_DECLARE_PRIVATE(QCameraViewfinder)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif // QCAMERA_H
|
||||
554
src/multimediawidgets/qeglimagetexturesurface.cpp
Normal file
554
src/multimediawidgets/qeglimagetexturesurface.cpp
Normal file
@@ -0,0 +1,554 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qeglimagetexturesurface_p.h>
|
||||
#include <qpaintervideosurface_p.h>
|
||||
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtGui/qpainter.h>
|
||||
#include <QtWidgets/qx11info_x11.h>
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
//#define DEBUG_OMAPFB_SURFACE
|
||||
|
||||
const QAbstractVideoBuffer::HandleType EGLImageTextureHandle =
|
||||
QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle+3434);
|
||||
|
||||
/*!
|
||||
\class QOmapFbVideoSurface
|
||||
\internal
|
||||
\since 1.2
|
||||
*/
|
||||
|
||||
/*!
|
||||
*/
|
||||
QEglImageTextureSurface::QEglImageTextureSurface(QObject *parent)
|
||||
: QAbstractVideoSurface(parent)
|
||||
, m_context(0)
|
||||
, m_program(0)
|
||||
, m_pixelFormat(QVideoFrame::Format_Invalid)
|
||||
, m_ready(false)
|
||||
, m_colorKey(49,0,49)
|
||||
, m_fallbackSurface(0)
|
||||
, m_fallbackSurfaceActive(false)
|
||||
{
|
||||
m_fallbackSurface = new QPainterVideoSurface(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
QEglImageTextureSurface::~QEglImageTextureSurface()
|
||||
{
|
||||
if (isActive())
|
||||
stop();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
QList<QVideoFrame::PixelFormat> QEglImageTextureSurface::supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType) const
|
||||
{
|
||||
#ifdef DEBUG_OMAPFB_SURFACE
|
||||
qDebug() << Q_FUNC_INFO << handleType;
|
||||
#endif
|
||||
|
||||
if (handleType == EGLImageTextureHandle) {
|
||||
return QList<QVideoFrame::PixelFormat>()
|
||||
<< QVideoFrame::Format_RGB32
|
||||
<< QVideoFrame::Format_ARGB32;
|
||||
}
|
||||
|
||||
return m_fallbackSurface->supportedPixelFormats(handleType);
|
||||
}
|
||||
|
||||
const char *qt_glsl_eglTextureVertexShaderProgram =
|
||||
"attribute highp vec4 vertexCoordArray;\n"
|
||||
"attribute mediump vec2 textureCoordArray;\n"
|
||||
"uniform highp mat4 positionMatrix;\n"
|
||||
"varying mediump vec2 textureCoord;\n"
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
" gl_Position = positionMatrix * vertexCoordArray;\n"
|
||||
" textureCoord = textureCoordArray;\n"
|
||||
"}";
|
||||
|
||||
static const char* qt_glsl_eglTextureShaderProgram =
|
||||
"#extension GL_OES_EGL_image_external: enable\n"
|
||||
"\n"
|
||||
"uniform samplerExternalOES texRgb;\n"
|
||||
"varying mediump vec2 textureCoord;\n"
|
||||
"\n"
|
||||
"void main (void)\n"
|
||||
"{\n"
|
||||
" gl_FragColor = texture2D(texRgb, textureCoord);\n"
|
||||
"}";
|
||||
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
bool QEglImageTextureSurface::start(const QVideoSurfaceFormat &format)
|
||||
{
|
||||
#ifdef DEBUG_OMAPFB_SURFACE
|
||||
qDebug() << Q_FUNC_INFO << format;
|
||||
#endif
|
||||
|
||||
m_fallbackSurfaceActive = false;
|
||||
if (format.handleType() != EGLImageTextureHandle) {
|
||||
qWarning() << Q_FUNC_INFO << "Non EGLImageTextureHandle based format requested, fallback to QPainterVideoSurface";
|
||||
connect(m_fallbackSurface, SIGNAL(activeChanged(bool)),
|
||||
this, SIGNAL(activeChanged(bool)));
|
||||
connect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
|
||||
this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
|
||||
connect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()),
|
||||
this, SIGNAL(supportedFormatsChanged()));
|
||||
connect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)),
|
||||
this, SIGNAL(nativeResolutionChanged(QSize)));
|
||||
connect(m_fallbackSurface, SIGNAL(frameChanged()),
|
||||
this, SIGNAL(frameChanged()));
|
||||
|
||||
if (m_fallbackSurface->start(format)) {
|
||||
m_fallbackSurfaceActive = true;
|
||||
QAbstractVideoSurface::start(format);
|
||||
} else {
|
||||
qWarning() << Q_FUNC_INFO << "failed to start video surface:" << m_fallbackSurface->error();
|
||||
setError(m_fallbackSurface->error());
|
||||
|
||||
disconnect(m_fallbackSurface, SIGNAL(activeChanged(bool)),
|
||||
this, SIGNAL(activeChanged(bool)));
|
||||
disconnect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
|
||||
this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
|
||||
disconnect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()),
|
||||
this, SIGNAL(supportedFormatsChanged()));
|
||||
disconnect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)),
|
||||
this, SIGNAL(nativeResolutionChanged(QSize)));
|
||||
disconnect(m_fallbackSurface, SIGNAL(frameChanged()),
|
||||
this, SIGNAL(frameChanged()));
|
||||
}
|
||||
|
||||
return m_fallbackSurfaceActive;
|
||||
}
|
||||
|
||||
QAbstractVideoSurface::Error error = NoError;
|
||||
|
||||
if (isActive())
|
||||
stop();
|
||||
|
||||
if (format.frameSize().isEmpty()) {
|
||||
setError(UnsupportedFormatError);
|
||||
} else if (m_context) {
|
||||
m_context->makeCurrent();
|
||||
m_program = new QGLShaderProgram(m_context, this);
|
||||
|
||||
if (!m_program->addShaderFromSourceCode(QGLShader::Vertex, qt_glsl_eglTextureVertexShaderProgram)) {
|
||||
qWarning("QOmapFbVideoSurface: Vertex shader compile error %s",
|
||||
qPrintable(m_program->log()));
|
||||
error = ResourceError;
|
||||
}
|
||||
|
||||
if (error == NoError
|
||||
&& !m_program->addShaderFromSourceCode(QGLShader::Fragment, qt_glsl_eglTextureShaderProgram)) {
|
||||
qWarning("QOmapFbVideoSurface: Vertex shader compile error %s",
|
||||
qPrintable(m_program->log()));
|
||||
error = QAbstractVideoSurface::ResourceError;
|
||||
}
|
||||
|
||||
if (error == NoError) {
|
||||
m_program->bindAttributeLocation("textureCoordArray", 1);
|
||||
if(!m_program->link()) {
|
||||
qWarning("QOmapFbVideoSurface: Shader link error %s", qPrintable(m_program->log()));
|
||||
m_program->removeAllShaders();
|
||||
error = QAbstractVideoSurface::ResourceError;
|
||||
}
|
||||
}
|
||||
|
||||
if (error != QAbstractVideoSurface::NoError) {
|
||||
delete m_program;
|
||||
m_program = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (error == QAbstractVideoSurface::NoError) {
|
||||
m_scanLineDirection = format.scanLineDirection();
|
||||
m_frameSize = format.frameSize();
|
||||
m_pixelFormat = format.pixelFormat();
|
||||
m_frameSize = format.frameSize();
|
||||
m_sourceRect = format.viewport();
|
||||
m_ready = true;
|
||||
|
||||
return QAbstractVideoSurface::start(format);
|
||||
}
|
||||
|
||||
QAbstractVideoSurface::stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
void QEglImageTextureSurface::stop()
|
||||
{
|
||||
#ifdef DEBUG_OMAPFB_SURFACE
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
#endif
|
||||
|
||||
if (m_fallbackSurfaceActive) {
|
||||
m_fallbackSurface->stop();
|
||||
m_fallbackSurfaceActive = false;
|
||||
|
||||
disconnect(m_fallbackSurface, SIGNAL(activeChanged(bool)),
|
||||
this, SIGNAL(activeChanged(bool)));
|
||||
disconnect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
|
||||
this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
|
||||
disconnect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()),
|
||||
this, SIGNAL(supportedFormatsChanged()));
|
||||
disconnect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)),
|
||||
this, SIGNAL(nativeResolutionChanged(QSize)));
|
||||
disconnect(m_fallbackSurface, SIGNAL(frameChanged()),
|
||||
this, SIGNAL(frameChanged()));
|
||||
|
||||
m_ready = false;
|
||||
QAbstractVideoSurface::stop();
|
||||
}
|
||||
|
||||
if (isActive()) {
|
||||
if (m_context)
|
||||
m_context->makeCurrent();
|
||||
m_frame = QVideoFrame();
|
||||
|
||||
m_program->removeAllShaders();
|
||||
delete m_program;
|
||||
m_program = 0;
|
||||
m_ready = false;
|
||||
|
||||
QAbstractVideoSurface::stop();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
bool QEglImageTextureSurface::present(const QVideoFrame &frame)
|
||||
{
|
||||
if (m_fallbackSurfaceActive) {
|
||||
if (m_fallbackSurface->present(frame)) {
|
||||
return true;
|
||||
} else {
|
||||
setError(m_fallbackSurface->error());
|
||||
stop();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_ready) {
|
||||
if (!isActive())
|
||||
setError(StoppedError);
|
||||
else
|
||||
m_frame = frame;
|
||||
} else if (frame.isValid()
|
||||
&& (frame.pixelFormat() != m_pixelFormat || frame.size() != m_frameSize)) {
|
||||
setError(IncorrectFormatError);
|
||||
qWarning() << "Received frame of incorrect format, stopping the surface";
|
||||
|
||||
stop();
|
||||
} else {
|
||||
if (m_context)
|
||||
m_context->makeCurrent();
|
||||
m_frame = frame;
|
||||
m_ready = false;
|
||||
emit frameChanged();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
int QEglImageTextureSurface::brightness() const
|
||||
{
|
||||
return m_fallbackSurface->brightness();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
void QEglImageTextureSurface::setBrightness(int brightness)
|
||||
{
|
||||
m_fallbackSurface->setBrightness(brightness);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
int QEglImageTextureSurface::contrast() const
|
||||
{
|
||||
return m_fallbackSurface->contrast();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
void QEglImageTextureSurface::setContrast(int contrast)
|
||||
{
|
||||
m_fallbackSurface->setContrast(contrast);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
int QEglImageTextureSurface::hue() const
|
||||
{
|
||||
return m_fallbackSurface->hue();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
void QEglImageTextureSurface::setHue(int hue)
|
||||
{
|
||||
m_fallbackSurface->setHue(hue);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
int QEglImageTextureSurface::saturation() const
|
||||
{
|
||||
return m_fallbackSurface->saturation();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
void QEglImageTextureSurface::setSaturation(int saturation)
|
||||
{
|
||||
m_fallbackSurface->setSaturation(saturation);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
bool QEglImageTextureSurface::isReady() const
|
||||
{
|
||||
return m_fallbackSurfaceActive ? m_fallbackSurface->isReady() : m_ready;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
void QEglImageTextureSurface::setReady(bool ready)
|
||||
{
|
||||
m_ready = ready;
|
||||
if (m_fallbackSurfaceActive)
|
||||
m_fallbackSurface->setReady(ready);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
void QEglImageTextureSurface::paint(QPainter *painter, const QRectF &target, const QRectF &sourceRect)
|
||||
{
|
||||
if (m_fallbackSurfaceActive) {
|
||||
m_fallbackSurface->paint(painter, target, sourceRect);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isActive() || !m_frame.isValid()) {
|
||||
painter->fillRect(target, QBrush(Qt::black));
|
||||
} else {
|
||||
const QRectF source(
|
||||
m_sourceRect.x() + m_sourceRect.width() * sourceRect.x(),
|
||||
m_sourceRect.y() + m_sourceRect.height() * sourceRect.y(),
|
||||
m_sourceRect.width() * sourceRect.width(),
|
||||
m_sourceRect.height() * sourceRect.height());
|
||||
|
||||
bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST);
|
||||
bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST);
|
||||
|
||||
painter->beginNativePainting();
|
||||
|
||||
if (stencilTestEnabled)
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
if (scissorTestEnabled)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
const int width = QGLContext::currentContext()->device()->width();
|
||||
const int height = QGLContext::currentContext()->device()->height();
|
||||
|
||||
const QTransform transform = painter->deviceTransform();
|
||||
|
||||
const GLfloat wfactor = 2.0 / width;
|
||||
const GLfloat hfactor = -2.0 / height;
|
||||
|
||||
const GLfloat positionMatrix[4][4] =
|
||||
{
|
||||
{
|
||||
/*(0,0)*/ GLfloat(wfactor * transform.m11() - transform.m13()),
|
||||
/*(0,1)*/ GLfloat(hfactor * transform.m12() + transform.m13()),
|
||||
/*(0,2)*/ 0.0,
|
||||
/*(0,3)*/ GLfloat(transform.m13())
|
||||
}, {
|
||||
/*(1,0)*/ GLfloat(wfactor * transform.m21() - transform.m23()),
|
||||
/*(1,1)*/ GLfloat(hfactor * transform.m22() + transform.m23()),
|
||||
/*(1,2)*/ 0.0,
|
||||
/*(1,3)*/ GLfloat(transform.m23())
|
||||
}, {
|
||||
/*(2,0)*/ 0.0,
|
||||
/*(2,1)*/ 0.0,
|
||||
/*(2,2)*/ -1.0,
|
||||
/*(2,3)*/ 0.0
|
||||
}, {
|
||||
/*(3,0)*/ GLfloat(wfactor * transform.dx() - transform.m33()),
|
||||
/*(3,1)*/ GLfloat(hfactor * transform.dy() + transform.m33()),
|
||||
/*(3,2)*/ 0.0,
|
||||
/*(3,3)*/ GLfloat(transform.m33())
|
||||
}
|
||||
};
|
||||
|
||||
const GLfloat vTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom
|
||||
? target.top()
|
||||
: target.bottom() + 1;
|
||||
const GLfloat vBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom
|
||||
? target.bottom() + 1
|
||||
: target.top();
|
||||
|
||||
|
||||
const GLfloat vertexCoordArray[] =
|
||||
{
|
||||
GLfloat(target.left()) , GLfloat(vBottom),
|
||||
GLfloat(target.right() + 1), GLfloat(vBottom),
|
||||
GLfloat(target.left()) , GLfloat(vTop),
|
||||
GLfloat(target.right() + 1), GLfloat(vTop)
|
||||
};
|
||||
|
||||
const GLfloat txLeft = source.left() / m_frameSize.width();
|
||||
const GLfloat txRight = source.right() / m_frameSize.width();
|
||||
const GLfloat txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom
|
||||
? source.top() / m_frameSize.height()
|
||||
: source.bottom() / m_frameSize.height();
|
||||
const GLfloat txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom
|
||||
? source.bottom() / m_frameSize.height()
|
||||
: source.top() / m_frameSize.height();
|
||||
|
||||
const GLfloat textureCoordArray[] =
|
||||
{
|
||||
txLeft , txBottom,
|
||||
txRight, txBottom,
|
||||
txLeft , txTop,
|
||||
txRight, txTop
|
||||
};
|
||||
|
||||
m_program->bind();
|
||||
|
||||
m_program->enableAttributeArray("vertexCoordArray");
|
||||
m_program->enableAttributeArray("textureCoordArray");
|
||||
m_program->setAttributeArray("vertexCoordArray", vertexCoordArray, 2);
|
||||
m_program->setAttributeArray("textureCoordArray", textureCoordArray, 2);
|
||||
m_program->setUniformValue("positionMatrix", positionMatrix);
|
||||
m_program->setUniformValue("texRgb", 0);
|
||||
|
||||
//map() binds the external texture
|
||||
m_frame.map(QAbstractVideoBuffer::ReadOnly);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
//it's necessary to unbind the external texture
|
||||
m_frame.unmap();
|
||||
|
||||
m_program->release();
|
||||
|
||||
painter->endNativePainting();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QOmapFbVideoSurface::frameChanged()
|
||||
\since 1.2
|
||||
*/
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
const QGLContext *QEglImageTextureSurface::glContext() const
|
||||
{
|
||||
return m_context;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 1.2
|
||||
*/
|
||||
void QEglImageTextureSurface::setGLContext(QGLContext *context)
|
||||
{
|
||||
if (m_context == context)
|
||||
return;
|
||||
|
||||
stop();
|
||||
|
||||
m_context = context;
|
||||
|
||||
m_fallbackSurface->setGLContext(context);
|
||||
if (m_fallbackSurface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) {
|
||||
m_fallbackSurface->setShaderType(QPainterVideoSurface::GlslShader);
|
||||
} else {
|
||||
m_fallbackSurface->setShaderType(QPainterVideoSurface::FragmentProgramShader);
|
||||
}
|
||||
|
||||
emit supportedFormatsChanged();
|
||||
}
|
||||
|
||||
void QEglImageTextureSurface::viewportDestroyed()
|
||||
{
|
||||
m_context = 0;
|
||||
m_fallbackSurface->viewportDestroyed();
|
||||
|
||||
setError(ResourceError);
|
||||
stop();
|
||||
}
|
||||
|
||||
#include "moc_qeglimagetexturesurface_p.cpp"
|
||||
QT_END_NAMESPACE
|
||||
150
src/multimediawidgets/qeglimagetexturesurface_p.h
Normal file
150
src/multimediawidgets/qeglimagetexturesurface_p.h
Normal file
@@ -0,0 +1,150 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QEGLIMAGETEXTURESURFACE_P_H
|
||||
#define QEGLIMAGETEXTURESURFACE_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <qtmultimediawidgetdefs.h>
|
||||
#include <QtCore/qsize.h>
|
||||
#include <QtGui/qimage.h>
|
||||
#include <QtGui/qmatrix4x4.h>
|
||||
#include <QtGui/qpaintengine.h>
|
||||
|
||||
#include <QtOpenGL/qglshaderprogram.h>
|
||||
|
||||
#include <qabstractvideosurface.h>
|
||||
#include <qvideosurfaceformat.h>
|
||||
#include <qvideoframe.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
class QGLContext;
|
||||
class QGLShaderProgram;
|
||||
class QPainterVideoSurface;
|
||||
|
||||
class QEglImageTextureSurface : public QAbstractVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QEglImageTextureSurface(QObject *parent = 0);
|
||||
~QEglImageTextureSurface();
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
|
||||
|
||||
bool start(const QVideoSurfaceFormat &format);
|
||||
void stop();
|
||||
|
||||
bool present(const QVideoFrame &frame);
|
||||
|
||||
int brightness() const;
|
||||
void setBrightness(int brightness);
|
||||
|
||||
int contrast() const;
|
||||
void setContrast(int contrast);
|
||||
|
||||
int hue() const;
|
||||
void setHue(int hue);
|
||||
|
||||
int saturation() const;
|
||||
void setSaturation(int saturation);
|
||||
|
||||
bool isReady() const;
|
||||
void setReady(bool ready);
|
||||
|
||||
void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1));
|
||||
|
||||
const QGLContext *glContext() const;
|
||||
void setGLContext(QGLContext *context);
|
||||
|
||||
bool isOverlayEnabled() const;
|
||||
void setOverlayEnabled(bool enabled);
|
||||
|
||||
QRect displayRect() const;
|
||||
void setDisplayRect(const QRect &rect);
|
||||
|
||||
public Q_SLOTS:
|
||||
void viewportDestroyed();
|
||||
|
||||
Q_SIGNALS:
|
||||
void frameChanged();
|
||||
|
||||
private:
|
||||
QGLContext *m_context;
|
||||
QGLShaderProgram *m_program;
|
||||
|
||||
QVideoFrame m_frame;
|
||||
|
||||
QVideoFrame::PixelFormat m_pixelFormat;
|
||||
QVideoSurfaceFormat::Direction m_scanLineDirection;
|
||||
QSize m_frameSize;
|
||||
QRect m_sourceRect;
|
||||
bool m_ready;
|
||||
|
||||
QRect m_viewport;
|
||||
QRect m_displayRect;
|
||||
QColor m_colorKey;
|
||||
|
||||
QPainterVideoSurface *m_fallbackSurface;
|
||||
bool m_fallbackSurfaceActive;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif
|
||||
432
src/multimediawidgets/qgraphicsvideoitem.cpp
Normal file
432
src/multimediawidgets/qgraphicsvideoitem.cpp
Normal file
@@ -0,0 +1,432 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qgraphicsvideoitem.h"
|
||||
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qpaintervideosurface_p.h>
|
||||
#include <qvideorenderercontrol.h>
|
||||
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
|
||||
#include <QtOpenGL/qgl.h>
|
||||
#endif
|
||||
|
||||
Q_DECLARE_METATYPE(QVideoSurfaceFormat)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGraphicsVideoItemPrivate
|
||||
{
|
||||
public:
|
||||
QGraphicsVideoItemPrivate()
|
||||
: q_ptr(0)
|
||||
, surface(0)
|
||||
, mediaObject(0)
|
||||
, service(0)
|
||||
, rendererControl(0)
|
||||
, aspectRatioMode(Qt::KeepAspectRatio)
|
||||
, updatePaintDevice(true)
|
||||
, rect(0.0, 0.0, 320, 240)
|
||||
{
|
||||
}
|
||||
|
||||
QGraphicsVideoItem *q_ptr;
|
||||
|
||||
QPainterVideoSurface *surface;
|
||||
QPointer<QMediaObject> mediaObject;
|
||||
QMediaService *service;
|
||||
QVideoRendererControl *rendererControl;
|
||||
Qt::AspectRatioMode aspectRatioMode;
|
||||
bool updatePaintDevice;
|
||||
QRectF rect;
|
||||
QRectF boundingRect;
|
||||
QRectF sourceRect;
|
||||
QSizeF nativeSize;
|
||||
|
||||
void clearService();
|
||||
void updateRects();
|
||||
|
||||
void _q_present();
|
||||
void _q_formatChanged(const QVideoSurfaceFormat &format);
|
||||
void _q_updateNativeSize();
|
||||
void _q_serviceDestroyed();
|
||||
};
|
||||
|
||||
void QGraphicsVideoItemPrivate::clearService()
|
||||
{
|
||||
if (rendererControl) {
|
||||
surface->stop();
|
||||
rendererControl->setSurface(0);
|
||||
service->releaseControl(rendererControl);
|
||||
rendererControl = 0;
|
||||
}
|
||||
if (service) {
|
||||
QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed()));
|
||||
service = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QGraphicsVideoItemPrivate::updateRects()
|
||||
{
|
||||
q_ptr->prepareGeometryChange();
|
||||
|
||||
if (nativeSize.isEmpty()) {
|
||||
//this is necessary for item to receive the
|
||||
//first paint event and configure video surface.
|
||||
boundingRect = rect;
|
||||
} else if (aspectRatioMode == Qt::IgnoreAspectRatio) {
|
||||
boundingRect = rect;
|
||||
sourceRect = QRectF(0, 0, 1, 1);
|
||||
} else if (aspectRatioMode == Qt::KeepAspectRatio) {
|
||||
QSizeF size = nativeSize;
|
||||
size.scale(rect.size(), Qt::KeepAspectRatio);
|
||||
|
||||
boundingRect = QRectF(0, 0, size.width(), size.height());
|
||||
boundingRect.moveCenter(rect.center());
|
||||
|
||||
sourceRect = QRectF(0, 0, 1, 1);
|
||||
} else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) {
|
||||
boundingRect = rect;
|
||||
|
||||
QSizeF size = rect.size();
|
||||
size.scale(nativeSize, Qt::KeepAspectRatio);
|
||||
|
||||
sourceRect = QRectF(
|
||||
0, 0, size.width() / nativeSize.width(), size.height() / nativeSize.height());
|
||||
sourceRect.moveCenter(QPointF(0.5, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
void QGraphicsVideoItemPrivate::_q_present()
|
||||
{
|
||||
if (q_ptr->isObscured()) {
|
||||
q_ptr->update(boundingRect);
|
||||
surface->setReady(true);
|
||||
} else {
|
||||
q_ptr->update(boundingRect);
|
||||
}
|
||||
}
|
||||
|
||||
void QGraphicsVideoItemPrivate::_q_updateNativeSize()
|
||||
{
|
||||
const QSize &size = surface->surfaceFormat().sizeHint();
|
||||
if (nativeSize != size) {
|
||||
nativeSize = size;
|
||||
|
||||
updateRects();
|
||||
emit q_ptr->nativeSizeChanged(nativeSize);
|
||||
}
|
||||
}
|
||||
|
||||
void QGraphicsVideoItemPrivate::_q_serviceDestroyed()
|
||||
{
|
||||
rendererControl = 0;
|
||||
service = 0;
|
||||
|
||||
surface->stop();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\class QGraphicsVideoItem
|
||||
|
||||
\brief The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject.
|
||||
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
Attaching a QGraphicsVideoItem to a QMediaObject allows it to display
|
||||
the video or image output of that media object. A QGraphicsVideoItem
|
||||
is attached to a media object by passing a pointer to the QMediaObject
|
||||
to the setMediaObject() function.
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/video.cpp Video graphics item
|
||||
|
||||
\bold {Note}: Only a single display output can be attached to a media
|
||||
object at one time.
|
||||
|
||||
\sa QMediaObject, QMediaPlayer, QVideoWidget
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a graphics item that displays video.
|
||||
|
||||
The \a parent is passed to QGraphicsItem.
|
||||
*/
|
||||
QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent)
|
||||
: QGraphicsObject(parent)
|
||||
, d_ptr(new QGraphicsVideoItemPrivate)
|
||||
{
|
||||
d_ptr->q_ptr = this;
|
||||
d_ptr->surface = new QPainterVideoSurface;
|
||||
|
||||
qRegisterMetaType<QVideoSurfaceFormat>();
|
||||
|
||||
connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present()));
|
||||
connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
|
||||
this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a video graphics item.
|
||||
*/
|
||||
QGraphicsVideoItem::~QGraphicsVideoItem()
|
||||
{
|
||||
if (d_ptr->rendererControl) {
|
||||
d_ptr->rendererControl->setSurface(0);
|
||||
d_ptr->service->releaseControl(d_ptr->rendererControl);
|
||||
}
|
||||
|
||||
delete d_ptr->surface;
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::mediaObject
|
||||
\brief the media object which provides the video displayed by a graphics
|
||||
item.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaObject *QGraphicsVideoItem::mediaObject() const
|
||||
{
|
||||
return d_func()->mediaObject;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 1.0
|
||||
*/
|
||||
bool QGraphicsVideoItem::setMediaObject(QMediaObject *object)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
if (object == d->mediaObject)
|
||||
return true;
|
||||
|
||||
d->clearService();
|
||||
|
||||
d->mediaObject = object;
|
||||
|
||||
if (d->mediaObject) {
|
||||
d->service = d->mediaObject->service();
|
||||
|
||||
if (d->service) {
|
||||
QMediaControl *control = d->service->requestControl(QVideoRendererControl_iid);
|
||||
if (control) {
|
||||
d->rendererControl = qobject_cast<QVideoRendererControl *>(control);
|
||||
|
||||
if (d->rendererControl) {
|
||||
//don't set the surface untill the item is painted
|
||||
//at least once and the surface is configured
|
||||
if (!d->updatePaintDevice)
|
||||
d->rendererControl->setSurface(d->surface);
|
||||
else
|
||||
update(boundingRect());
|
||||
|
||||
connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed()));
|
||||
|
||||
return true;
|
||||
}
|
||||
if (control)
|
||||
d->service->releaseControl(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d->mediaObject = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::aspectRatioMode
|
||||
\brief how a video is scaled to fit the graphics item's size.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode() const
|
||||
{
|
||||
return d_func()->aspectRatioMode;
|
||||
}
|
||||
|
||||
void QGraphicsVideoItem::setAspectRatioMode(Qt::AspectRatioMode mode)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
d->aspectRatioMode = mode;
|
||||
d->updateRects();
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::offset
|
||||
\brief the video item's offset.
|
||||
|
||||
QGraphicsVideoItem will draw video using the offset for its top left
|
||||
corner.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QPointF QGraphicsVideoItem::offset() const
|
||||
{
|
||||
return d_func()->rect.topLeft();
|
||||
}
|
||||
|
||||
void QGraphicsVideoItem::setOffset(const QPointF &offset)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
d->rect.moveTo(offset);
|
||||
d->updateRects();
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::size
|
||||
\brief the video item's size.
|
||||
|
||||
QGraphicsVideoItem will draw video scaled to fit size according to its
|
||||
fillMode.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QSizeF QGraphicsVideoItem::size() const
|
||||
{
|
||||
return d_func()->rect.size();
|
||||
}
|
||||
|
||||
void QGraphicsVideoItem::setSize(const QSizeF &size)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
d->rect.setSize(size.isValid() ? size : QSizeF(0, 0));
|
||||
d->updateRects();
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::nativeSize
|
||||
\brief the native size of the video.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QSizeF QGraphicsVideoItem::nativeSize() const
|
||||
{
|
||||
return d_func()->nativeSize;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size)
|
||||
|
||||
Signals that the native \a size of the video has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
\since 1.0
|
||||
*/
|
||||
QRectF QGraphicsVideoItem::boundingRect() const
|
||||
{
|
||||
return d_func()->boundingRect;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
\since 1.0
|
||||
*/
|
||||
void QGraphicsVideoItem::paint(
|
||||
QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
if (d->surface && d->updatePaintDevice) {
|
||||
d->updatePaintDevice = false;
|
||||
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
|
||||
if (widget)
|
||||
connect(widget, SIGNAL(destroyed()), d->surface, SLOT(viewportDestroyed()));
|
||||
|
||||
d->surface->setGLContext(const_cast<QGLContext *>(QGLContext::currentContext()));
|
||||
if (d->surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) {
|
||||
d->surface->setShaderType(QPainterVideoSurface::GlslShader);
|
||||
} else {
|
||||
d->surface->setShaderType(QPainterVideoSurface::FragmentProgramShader);
|
||||
}
|
||||
#endif
|
||||
if (d->rendererControl && d->rendererControl->surface() != d->surface)
|
||||
d->rendererControl->setSurface(d->surface);
|
||||
}
|
||||
|
||||
if (d->surface && d->surface->isActive()) {
|
||||
d->surface->paint(painter, d->boundingRect, d->sourceRect);
|
||||
d->surface->setReady(true);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
|
||||
\internal
|
||||
\since 1.0
|
||||
*/
|
||||
QVariant QGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 1.0
|
||||
*/
|
||||
void QGraphicsVideoItem::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
QGraphicsObject::timerEvent(event);
|
||||
}
|
||||
|
||||
#include "moc_qgraphicsvideoitem.cpp"
|
||||
QT_END_NAMESPACE
|
||||
115
src/multimediawidgets/qgraphicsvideoitem.h
Normal file
115
src/multimediawidgets/qgraphicsvideoitem.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QGRAPHICSVIDEOITEM_H
|
||||
#define QGRAPHICSVIDEOITEM_H
|
||||
|
||||
#include <QtWidgets/qgraphicsitem.h>
|
||||
|
||||
#include <qvideowidget.h>
|
||||
#include <qmediabindableinterface.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
class QVideoSurfaceFormat;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGraphicsVideoItemPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QGraphicsVideoItem : public QGraphicsObject, public QMediaBindableInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaBindableInterface)
|
||||
Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject)
|
||||
Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)
|
||||
Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
|
||||
Q_PROPERTY(QSizeF size READ size WRITE setSize)
|
||||
Q_PROPERTY(QSizeF nativeSize READ nativeSize NOTIFY nativeSizeChanged)
|
||||
public:
|
||||
QGraphicsVideoItem(QGraphicsItem *parent = 0);
|
||||
~QGraphicsVideoItem();
|
||||
|
||||
QMediaObject *mediaObject() const;
|
||||
|
||||
Qt::AspectRatioMode aspectRatioMode() const;
|
||||
void setAspectRatioMode(Qt::AspectRatioMode mode);
|
||||
|
||||
QPointF offset() const;
|
||||
void setOffset(const QPointF &offset);
|
||||
|
||||
QSizeF size() const;
|
||||
void setSize(const QSizeF &size);
|
||||
|
||||
QSizeF nativeSize() const;
|
||||
|
||||
QRectF boundingRect() const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
Q_SIGNALS:
|
||||
void nativeSizeChanged(const QSizeF &size);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event);
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
|
||||
bool setMediaObject(QMediaObject *object);
|
||||
|
||||
QGraphicsVideoItemPrivate *d_ptr;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QGraphicsVideoItem)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_present())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateNativeSize())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed())
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif
|
||||
498
src/multimediawidgets/qgraphicsvideoitem_maemo6.cpp
Normal file
498
src/multimediawidgets/qgraphicsvideoitem_maemo6.cpp
Normal file
@@ -0,0 +1,498 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qgraphicsvideoitem.h"
|
||||
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/qbasictimer.h>
|
||||
|
||||
#include <QtWidgets/qgraphicsscene.h>
|
||||
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qpaintervideosurface_p.h>
|
||||
#include <qeglimagetexturesurface_p.h>
|
||||
#include <qvideorenderercontrol.h>
|
||||
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
|
||||
#include <QtOpenGL/qgl.h>
|
||||
#endif
|
||||
|
||||
//#define ENABLE_OVERLAY
|
||||
|
||||
namespace
|
||||
{
|
||||
//XInitThreads is necessary for gltexturesink element.
|
||||
//To ensure it's called before main() it's better to link to
|
||||
//libQtMultimedia.so directly, not when QML multimedia plugin is loaded.
|
||||
class InitThreads
|
||||
{
|
||||
public:
|
||||
InitThreads()
|
||||
{
|
||||
XInitThreads();
|
||||
}
|
||||
} _initThreads;
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(QVideoSurfaceFormat)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGraphicsVideoItemPrivate
|
||||
{
|
||||
public:
|
||||
QGraphicsVideoItemPrivate()
|
||||
: q_ptr(0)
|
||||
, surface(0)
|
||||
, mediaObject(0)
|
||||
, service(0)
|
||||
, rendererControl(0)
|
||||
, aspectRatioMode(Qt::KeepAspectRatio)
|
||||
, updatePaintDevice(true)
|
||||
, rect(0.0, 0.0, 320, 240)
|
||||
{
|
||||
}
|
||||
|
||||
QGraphicsVideoItem *q_ptr;
|
||||
|
||||
QEglImageTextureSurface *surface;
|
||||
QPointer<QMediaObject> mediaObject;
|
||||
QMediaService *service;
|
||||
QVideoRendererControl *rendererControl;
|
||||
Qt::AspectRatioMode aspectRatioMode;
|
||||
bool updatePaintDevice;
|
||||
QRectF rect;
|
||||
QRectF boundingRect;
|
||||
QRectF sourceRect;
|
||||
QSizeF nativeSize;
|
||||
|
||||
void clearService();
|
||||
void updateRects();
|
||||
|
||||
void _q_present();
|
||||
void _q_formatChanged(const QVideoSurfaceFormat &format);
|
||||
void _q_updateNativeSize();
|
||||
void _q_serviceDestroyed();
|
||||
};
|
||||
|
||||
void QGraphicsVideoItemPrivate::clearService()
|
||||
{
|
||||
if (rendererControl) {
|
||||
surface->stop();
|
||||
rendererControl->setSurface(0);
|
||||
service->releaseControl(rendererControl);
|
||||
rendererControl = 0;
|
||||
}
|
||||
if (service) {
|
||||
QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed()));
|
||||
service = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void QGraphicsVideoItemPrivate::updateRects()
|
||||
{
|
||||
q_ptr->prepareGeometryChange();
|
||||
|
||||
if (nativeSize.isEmpty()) {
|
||||
//this is necessary for item to receive the
|
||||
//first paint event and configure video surface.
|
||||
boundingRect = rect;
|
||||
} else if (aspectRatioMode == Qt::IgnoreAspectRatio) {
|
||||
boundingRect = rect;
|
||||
sourceRect = QRectF(0, 0, 1, 1);
|
||||
} else if (aspectRatioMode == Qt::KeepAspectRatio) {
|
||||
QSizeF size = nativeSize;
|
||||
size.scale(rect.size(), Qt::KeepAspectRatio);
|
||||
|
||||
boundingRect = QRectF(0, 0, size.width(), size.height());
|
||||
boundingRect.moveCenter(rect.center());
|
||||
|
||||
sourceRect = QRectF(0, 0, 1, 1);
|
||||
} else if (aspectRatioMode == Qt::KeepAspectRatioByExpanding) {
|
||||
boundingRect = rect;
|
||||
|
||||
QSizeF size = rect.size();
|
||||
size.scale(nativeSize, Qt::KeepAspectRatio);
|
||||
|
||||
sourceRect = QRectF(
|
||||
0, 0, size.width() / nativeSize.width(), size.height() / nativeSize.height());
|
||||
sourceRect.moveCenter(QPointF(0.5, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
void QGraphicsVideoItemPrivate::_q_present()
|
||||
{
|
||||
if (q_ptr->isObscured()) {
|
||||
q_ptr->update(boundingRect);
|
||||
surface->setReady(true);
|
||||
} else {
|
||||
q_ptr->update(boundingRect);
|
||||
}
|
||||
}
|
||||
|
||||
void QGraphicsVideoItemPrivate::_q_updateNativeSize()
|
||||
{
|
||||
QSize size = surface->surfaceFormat().sizeHint();
|
||||
if (size.isEmpty())
|
||||
size = rendererControl->property("nativeSize").toSize();
|
||||
|
||||
if (nativeSize != size) {
|
||||
nativeSize = size;
|
||||
|
||||
updateRects();
|
||||
emit q_ptr->nativeSizeChanged(nativeSize);
|
||||
}
|
||||
}
|
||||
|
||||
void QGraphicsVideoItemPrivate::_q_serviceDestroyed()
|
||||
{
|
||||
rendererControl = 0;
|
||||
service = 0;
|
||||
|
||||
surface->stop();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\class QGraphicsVideoItem
|
||||
|
||||
\brief The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject.
|
||||
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
|
||||
Attaching a QGraphicsVideoItem to a QMediaObject allows it to display
|
||||
the video or image output of that media object. A QGraphicsVideoItem
|
||||
is attached to a media object by passing a pointer to the QMediaObject
|
||||
to the setMediaObject() function.
|
||||
|
||||
\code
|
||||
player = new QMediaPlayer(this);
|
||||
|
||||
QGraphicsVideoItem *item = new QGraphicsVideoItem;
|
||||
player->setVideoOutput(item);
|
||||
graphicsView->scene()->addItem(item);
|
||||
graphicsView->show();
|
||||
|
||||
player->setMedia(video);
|
||||
player->play();
|
||||
\endcode
|
||||
|
||||
\bold {Note}: Only a single display output can be attached to a media
|
||||
object at one time.
|
||||
|
||||
\sa QMediaObject, QMediaPlayer, QVideoWidget
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a graphics item that displays video.
|
||||
|
||||
The \a parent is passed to QGraphicsItem.
|
||||
*/
|
||||
QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent)
|
||||
: QGraphicsObject(parent)
|
||||
, d_ptr(new QGraphicsVideoItemPrivate)
|
||||
{
|
||||
d_ptr->q_ptr = this;
|
||||
d_ptr->surface = new QEglImageTextureSurface(this);
|
||||
|
||||
qRegisterMetaType<QVideoSurfaceFormat>();
|
||||
|
||||
connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present()));
|
||||
connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
|
||||
this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a video graphics item.
|
||||
*/
|
||||
QGraphicsVideoItem::~QGraphicsVideoItem()
|
||||
{
|
||||
if (d_ptr->rendererControl) {
|
||||
d_ptr->rendererControl->setSurface(0);
|
||||
d_ptr->service->releaseControl(d_ptr->rendererControl);
|
||||
}
|
||||
|
||||
delete d_ptr->surface;
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::mediaObject
|
||||
\brief the media object which provides the video displayed by a graphics
|
||||
item.
|
||||
*/
|
||||
|
||||
QMediaObject *QGraphicsVideoItem::mediaObject() const
|
||||
{
|
||||
return d_func()->mediaObject;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
bool QGraphicsVideoItem::setMediaObject(QMediaObject *object)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
if (object == d->mediaObject)
|
||||
return true;
|
||||
|
||||
d->clearService();
|
||||
|
||||
d->mediaObject = object;
|
||||
|
||||
if (d->mediaObject) {
|
||||
d->service = d->mediaObject->service();
|
||||
|
||||
if (d->service) {
|
||||
QMediaControl *control = d->service->requestControl(QVideoRendererControl_iid);
|
||||
if (control) {
|
||||
d->rendererControl = qobject_cast<QVideoRendererControl *>(control);
|
||||
|
||||
if (d->rendererControl) {
|
||||
connect(d->rendererControl, SIGNAL(nativeSizeChanged()),
|
||||
this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection);
|
||||
d->_q_updateNativeSize();
|
||||
//don't set the surface untill the item is painted
|
||||
//at least once and the surface is configured
|
||||
if (!d->updatePaintDevice)
|
||||
d->rendererControl->setSurface(d->surface);
|
||||
else
|
||||
update(boundingRect());
|
||||
|
||||
connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed()));
|
||||
|
||||
return true;
|
||||
}
|
||||
if (control)
|
||||
d->service->releaseControl(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d->mediaObject = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::aspectRatioMode
|
||||
\brief how a video is scaled to fit the graphics item's size.
|
||||
*/
|
||||
|
||||
Qt::AspectRatioMode QGraphicsVideoItem::aspectRatioMode() const
|
||||
{
|
||||
return d_func()->aspectRatioMode;
|
||||
}
|
||||
|
||||
void QGraphicsVideoItem::setAspectRatioMode(Qt::AspectRatioMode mode)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
d->aspectRatioMode = mode;
|
||||
d->updateRects();
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::offset
|
||||
\brief the video item's offset.
|
||||
|
||||
QGraphicsVideoItem will draw video using the offset for its top left
|
||||
corner.
|
||||
*/
|
||||
|
||||
QPointF QGraphicsVideoItem::offset() const
|
||||
{
|
||||
return d_func()->rect.topLeft();
|
||||
}
|
||||
|
||||
void QGraphicsVideoItem::setOffset(const QPointF &offset)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
d->rect.moveTo(offset);
|
||||
d->updateRects();
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::size
|
||||
\brief the video item's size.
|
||||
|
||||
QGraphicsVideoItem will draw video scaled to fit size according to its
|
||||
fillMode.
|
||||
*/
|
||||
|
||||
QSizeF QGraphicsVideoItem::size() const
|
||||
{
|
||||
return d_func()->rect.size();
|
||||
}
|
||||
|
||||
void QGraphicsVideoItem::setSize(const QSizeF &size)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
d->rect.setSize(size.isValid() ? size : QSizeF(0, 0));
|
||||
d->updateRects();
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QGraphicsVideoItem::nativeSize
|
||||
\brief the native size of the video.
|
||||
*/
|
||||
|
||||
QSizeF QGraphicsVideoItem::nativeSize() const
|
||||
{
|
||||
return d_func()->nativeSize;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size)
|
||||
|
||||
Signals that the native \a size of the video has changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QRectF QGraphicsVideoItem::boundingRect() const
|
||||
{
|
||||
return d_func()->boundingRect;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void QGraphicsVideoItem::paint(
|
||||
QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_D(QGraphicsVideoItem);
|
||||
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
if (d->surface && d->rendererControl && d->updatePaintDevice) {
|
||||
d->updatePaintDevice = false;
|
||||
|
||||
if (widget)
|
||||
d->rendererControl->setProperty("winId", qulonglong(widget->winId()));
|
||||
|
||||
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
|
||||
if (widget)
|
||||
connect(widget, SIGNAL(destroyed()), d->surface, SLOT(viewportDestroyed()));
|
||||
|
||||
d->surface->setGLContext(const_cast<QGLContext *>(QGLContext::currentContext()));
|
||||
#endif
|
||||
if (d->rendererControl->surface() != d->surface)
|
||||
d->rendererControl->setSurface(d->surface);
|
||||
}
|
||||
|
||||
|
||||
//overlay doesn't work reliably
|
||||
|
||||
//check if the item is obscured:
|
||||
#ifdef ENABLE_OVERLAY
|
||||
if (!isObscured()) {
|
||||
bool obscured = false;
|
||||
|
||||
if (scene()) {
|
||||
foreach (QGraphicsItem *item,
|
||||
scene()->items(mapToScene(boundingRect()), Qt::IntersectsItemBoundingRect) ) {
|
||||
if (item->flags() & QGraphicsItem::ItemHasNoContents)
|
||||
continue;
|
||||
|
||||
if (item == this)
|
||||
break;
|
||||
|
||||
if (collidesWithItem(item)) {
|
||||
obscured = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d->rendererControl->setProperty("overlayEnabled", !obscured);
|
||||
}
|
||||
|
||||
if (d->rendererControl->property("overlayEnabled").toBool()) {
|
||||
QTransform transform = painter->combinedTransform();
|
||||
QRect overlayRect = transform.mapRect(d->boundingRect).toRect();
|
||||
|
||||
d->rendererControl->setProperty("overlayGeometry", overlayRect);
|
||||
QMetaObject::invokeMethod(d->rendererControl, "repaintOverlay");
|
||||
|
||||
painter->fillRect(d->boundingRect,
|
||||
d->rendererControl->property("colorKey").value<QColor>());
|
||||
} else
|
||||
#endif //ENABLE_OVERLAY
|
||||
{
|
||||
if (d->surface && d->surface->isActive()) {
|
||||
d->surface->paint(painter, d->boundingRect, d->sourceRect);
|
||||
d->surface->setReady(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
|
||||
\internal
|
||||
*/
|
||||
QVariant QGraphicsVideoItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QGraphicsVideoItem::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
QGraphicsObject::timerEvent(event);
|
||||
}
|
||||
|
||||
#include "moc_qgraphicsvideoitem.cpp"
|
||||
QT_END_NAMESPACE
|
||||
1728
src/multimediawidgets/qpaintervideosurface.cpp
Normal file
1728
src/multimediawidgets/qpaintervideosurface.cpp
Normal file
File diff suppressed because it is too large
Load Diff
285
src/multimediawidgets/qpaintervideosurface_mac.mm
Normal file
285
src/multimediawidgets/qpaintervideosurface_mac.mm
Normal file
@@ -0,0 +1,285 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include <QuartzCore/CIContext.h>
|
||||
#include <CGLCurrent.h>
|
||||
#include <OpenGL/gl.h>
|
||||
|
||||
#include "qpaintervideosurface_mac_p.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
||||
#include <qmath.h>
|
||||
|
||||
#include <qpainter.h>
|
||||
#include <qvariant.h>
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern CGContextRef qt_mac_cg_context(const QPaintDevice *pdev); //qpaintdevice_mac.cpp
|
||||
|
||||
QVideoSurfaceCoreGraphicsPainter::QVideoSurfaceCoreGraphicsPainter(bool glSupported)
|
||||
: ciContext(0)
|
||||
, m_imageFormat(QImage::Format_Invalid)
|
||||
, m_scanLineDirection(QVideoSurfaceFormat::TopToBottom)
|
||||
{
|
||||
//qDebug() << "QVideoSurfaceCoreGraphicsPainter, GL supported:" << glSupported;
|
||||
ciContext = 0;
|
||||
m_imagePixelFormats
|
||||
<< QVideoFrame::Format_RGB32
|
||||
<< QVideoFrame::Format_ARGB32
|
||||
<< QVideoFrame::Format_ARGB32_Premultiplied
|
||||
<< QVideoFrame::Format_RGB24
|
||||
<< QVideoFrame::Format_RGB565
|
||||
<< QVideoFrame::Format_RGB555
|
||||
<< QVideoFrame::Format_ARGB8565_Premultiplied;
|
||||
|
||||
m_supportedHandles
|
||||
<< QAbstractVideoBuffer::NoHandle
|
||||
<< QAbstractVideoBuffer::CoreImageHandle;
|
||||
|
||||
if (glSupported)
|
||||
m_supportedHandles << QAbstractVideoBuffer::GLTextureHandle;
|
||||
}
|
||||
|
||||
QVideoSurfaceCoreGraphicsPainter::~QVideoSurfaceCoreGraphicsPainter()
|
||||
{
|
||||
[(CIContext*)ciContext release];
|
||||
}
|
||||
|
||||
QList<QVideoFrame::PixelFormat> QVideoSurfaceCoreGraphicsPainter::supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType) const
|
||||
{
|
||||
return m_supportedHandles.contains(handleType)
|
||||
? m_imagePixelFormats
|
||||
: QList<QVideoFrame::PixelFormat>();
|
||||
}
|
||||
|
||||
bool QVideoSurfaceCoreGraphicsPainter::isFormatSupported(
|
||||
const QVideoSurfaceFormat &format, QVideoSurfaceFormat *) const
|
||||
{
|
||||
return m_supportedHandles.contains(format.handleType())
|
||||
&& m_imagePixelFormats.contains(format.pixelFormat())
|
||||
&& !format.frameSize().isEmpty();
|
||||
}
|
||||
|
||||
QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::start(const QVideoSurfaceFormat &format)
|
||||
{
|
||||
m_frame = QVideoFrame();
|
||||
m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
|
||||
m_imageSize = format.frameSize();
|
||||
m_scanLineDirection = format.scanLineDirection();
|
||||
|
||||
return m_supportedHandles.contains(format.handleType())
|
||||
&& m_imageFormat != QImage::Format_Invalid
|
||||
&& !m_imageSize.isEmpty()
|
||||
? QAbstractVideoSurface::NoError
|
||||
: QAbstractVideoSurface::UnsupportedFormatError;
|
||||
}
|
||||
|
||||
void QVideoSurfaceCoreGraphicsPainter::stop()
|
||||
{
|
||||
m_frame = QVideoFrame();
|
||||
}
|
||||
|
||||
QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::setCurrentFrame(const QVideoFrame &frame)
|
||||
{
|
||||
m_frame = frame;
|
||||
|
||||
return QAbstractVideoSurface::NoError;
|
||||
}
|
||||
|
||||
QAbstractVideoSurface::Error QVideoSurfaceCoreGraphicsPainter::paint(
|
||||
const QRectF &target, QPainter *painter, const QRectF &source)
|
||||
{
|
||||
if (m_frame.handleType() == QAbstractVideoBuffer::CoreImageHandle) {
|
||||
if (painter->paintEngine()->type() == QPaintEngine::CoreGraphics ) {
|
||||
|
||||
CIImage *img = (CIImage*)(m_frame.handle().value<void*>());
|
||||
|
||||
if (img) {
|
||||
CGContextRef cgContext = qt_mac_cg_context(painter->device());
|
||||
|
||||
if (cgContext) {
|
||||
painter->beginNativePainting();
|
||||
|
||||
CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height());
|
||||
CGRect dRect = CGRectMake(target.x(), target.y(), target.width(), target.height());
|
||||
|
||||
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img];
|
||||
|
||||
if (m_scanLineDirection == QVideoSurfaceFormat::TopToBottom) {
|
||||
CGContextSaveGState( cgContext );
|
||||
CGContextTranslateCTM(cgContext, 0, dRect.origin.y + CGRectGetMaxY(dRect));
|
||||
CGContextScaleCTM(cgContext, 1, -1);
|
||||
|
||||
CGContextDrawImage(cgContext, dRect, [bitmap CGImage]);
|
||||
|
||||
CGContextRestoreGState(cgContext);
|
||||
} else {
|
||||
CGContextDrawImage(cgContext, dRect, [bitmap CGImage]);
|
||||
}
|
||||
|
||||
[bitmap release];
|
||||
|
||||
painter->endNativePainting();
|
||||
|
||||
return QAbstractVideoSurface::NoError;
|
||||
}
|
||||
}
|
||||
} else if (painter->paintEngine()->type() == QPaintEngine::OpenGL2 ||
|
||||
painter->paintEngine()->type() == QPaintEngine::OpenGL) {
|
||||
CIImage *img = (CIImage*)(m_frame.handle().value<void*>());
|
||||
|
||||
if (img) {
|
||||
CGLContextObj cglContext = CGLGetCurrentContext();
|
||||
|
||||
if (cglContext) {
|
||||
|
||||
if (!ciContext) {
|
||||
CGLContextObj cglContext = CGLGetCurrentContext();
|
||||
NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat];
|
||||
CGLPixelFormatObj cglPixelFormat = static_cast<CGLPixelFormatObj>([nsglPixelFormat CGLPixelFormatObj]);
|
||||
|
||||
ciContext = [CIContext contextWithCGLContext:cglContext
|
||||
pixelFormat:cglPixelFormat
|
||||
options:nil];
|
||||
|
||||
[(CIContext*)ciContext retain];
|
||||
}
|
||||
|
||||
CGRect sRect = CGRectMake(source.x(), source.y(), source.width(), source.height());
|
||||
CGRect dRect = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom ?
|
||||
CGRectMake(target.x(), target.y()+target.height(), target.width(), -target.height()) :
|
||||
CGRectMake(target.x(), target.y(), target.width(), target.height());
|
||||
|
||||
|
||||
painter->beginNativePainting();
|
||||
|
||||
[(CIContext*)ciContext drawImage:img inRect:dRect fromRect:sRect];
|
||||
|
||||
painter->endNativePainting();
|
||||
|
||||
return QAbstractVideoSurface::NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_frame.handleType() == QAbstractVideoBuffer::GLTextureHandle &&
|
||||
(painter->paintEngine()->type() == QPaintEngine::OpenGL2 ||
|
||||
painter->paintEngine()->type() == QPaintEngine::OpenGL)) {
|
||||
|
||||
painter->beginNativePainting();
|
||||
GLuint texture = m_frame.handle().toUInt();
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
const float txLeft = source.left() / m_frame.width();
|
||||
const float txRight = source.right() / m_frame.width();
|
||||
const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom
|
||||
? source.top() / m_frame.height()
|
||||
: source.bottom() / m_frame.height();
|
||||
const float txBottom = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom
|
||||
? source.bottom() / m_frame.height()
|
||||
: source.top() / m_frame.height();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
QRectF rect = target;
|
||||
glTexCoord2f(txLeft, txBottom);
|
||||
glVertex2f(rect.topLeft().x(), rect.topLeft().y());
|
||||
glTexCoord2f(txRight, txBottom);
|
||||
glVertex2f(rect.topRight().x() + 1, rect.topRight().y());
|
||||
glTexCoord2f(txRight, txTop);
|
||||
glVertex2f(rect.bottomRight().x() + 1, rect.bottomRight().y() + 1);
|
||||
glTexCoord2f(txLeft, txTop);
|
||||
glVertex2f(rect.bottomLeft().x(), rect.bottomLeft().y() + 1);
|
||||
glEnd();
|
||||
painter->endNativePainting();
|
||||
|
||||
return QAbstractVideoSurface::NoError;
|
||||
}
|
||||
|
||||
//fallback case, software rendering
|
||||
if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) {
|
||||
QImage image(
|
||||
m_frame.bits(),
|
||||
m_imageSize.width(),
|
||||
m_imageSize.height(),
|
||||
m_frame.bytesPerLine(),
|
||||
m_imageFormat);
|
||||
|
||||
if (m_scanLineDirection == QVideoSurfaceFormat::BottomToTop) {
|
||||
const QTransform oldTransform = painter->transform();
|
||||
|
||||
painter->scale(1, -1);
|
||||
painter->translate(0, -target.bottom());
|
||||
painter->drawImage(
|
||||
QRectF(target.x(), 0, target.width(), target.height()), image, source);
|
||||
painter->setTransform(oldTransform);
|
||||
} else {
|
||||
painter->drawImage(target, image, source);
|
||||
}
|
||||
|
||||
m_frame.unmap();
|
||||
} else if (m_frame.isValid()) {
|
||||
return QAbstractVideoSurface::IncorrectFormatError;
|
||||
} else {
|
||||
painter->fillRect(target, Qt::black);
|
||||
}
|
||||
|
||||
return QAbstractVideoSurface::NoError;
|
||||
}
|
||||
|
||||
void QVideoSurfaceCoreGraphicsPainter::updateColors(int, int, int, int)
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
103
src/multimediawidgets/qpaintervideosurface_mac_p.h
Normal file
103
src/multimediawidgets/qpaintervideosurface_mac_p.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPAINTERVIDEOSURFACE_MAC_P_H
|
||||
#define QPAINTERVIDEOSURFACE_MAC_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qpaintervideosurface_p.h"
|
||||
#include <qvideosurfaceformat.h>
|
||||
#include <qvideoframe.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QVideoSurfaceCoreGraphicsPainter : public QVideoSurfacePainter
|
||||
{
|
||||
public:
|
||||
QVideoSurfaceCoreGraphicsPainter(bool glSupported);
|
||||
~QVideoSurfaceCoreGraphicsPainter();
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType) const;
|
||||
|
||||
bool isFormatSupported(
|
||||
const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const;
|
||||
|
||||
QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format);
|
||||
void stop();
|
||||
|
||||
QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame);
|
||||
|
||||
QAbstractVideoSurface::Error paint(
|
||||
const QRectF &target, QPainter *painter, const QRectF &source);
|
||||
|
||||
void updateColors(int brightness, int contrast, int hue, int saturation);
|
||||
|
||||
private:
|
||||
void* ciContext;
|
||||
QList<QVideoFrame::PixelFormat> m_imagePixelFormats;
|
||||
QVideoFrame m_frame;
|
||||
QSize m_imageSize;
|
||||
QImage::Format m_imageFormat;
|
||||
QVector<QAbstractVideoBuffer::HandleType> m_supportedHandles;
|
||||
QVideoSurfaceFormat::Direction m_scanLineDirection;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
191
src/multimediawidgets/qpaintervideosurface_p.h
Normal file
191
src/multimediawidgets/qpaintervideosurface_p.h
Normal file
@@ -0,0 +1,191 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPAINTERVIDEOSURFACE_P_H
|
||||
#define QPAINTERVIDEOSURFACE_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <qtmultimediawidgetdefs.h>
|
||||
#include <QtCore/qsize.h>
|
||||
#include <QtGui/qimage.h>
|
||||
#include <QtGui/qmatrix4x4.h>
|
||||
#include <QtGui/qpaintengine.h>
|
||||
#include <qabstractvideosurface.h>
|
||||
#include <qvideoframe.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
class QGLContext;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QVideoSurfacePainter
|
||||
{
|
||||
public:
|
||||
virtual ~QVideoSurfacePainter();
|
||||
|
||||
virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType) const = 0;
|
||||
|
||||
virtual bool isFormatSupported(
|
||||
const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const = 0;
|
||||
|
||||
virtual QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
virtual QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame) = 0;
|
||||
|
||||
virtual QAbstractVideoSurface::Error paint(
|
||||
const QRectF &target, QPainter *painter, const QRectF &source) = 0;
|
||||
|
||||
virtual void updateColors(int brightness, int contrast, int hue, int saturation) = 0;
|
||||
virtual void viewportDestroyed() {}
|
||||
};
|
||||
|
||||
|
||||
class Q_AUTOTEST_EXPORT QPainterVideoSurface : public QAbstractVideoSurface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QPainterVideoSurface(QObject *parent = 0);
|
||||
~QPainterVideoSurface();
|
||||
|
||||
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
|
||||
QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const;
|
||||
|
||||
bool isFormatSupported(
|
||||
const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar = 0) const;
|
||||
|
||||
bool start(const QVideoSurfaceFormat &format);
|
||||
void stop();
|
||||
|
||||
bool present(const QVideoFrame &frame);
|
||||
|
||||
int brightness() const;
|
||||
void setBrightness(int brightness);
|
||||
|
||||
int contrast() const;
|
||||
void setContrast(int contrast);
|
||||
|
||||
int hue() const;
|
||||
void setHue(int hue);
|
||||
|
||||
int saturation() const;
|
||||
void setSaturation(int saturation);
|
||||
|
||||
bool isReady() const;
|
||||
void setReady(bool ready);
|
||||
|
||||
void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1));
|
||||
|
||||
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
|
||||
const QGLContext *glContext() const;
|
||||
void setGLContext(QGLContext *context);
|
||||
|
||||
enum ShaderType
|
||||
{
|
||||
NoShaders = 0x00,
|
||||
FragmentProgramShader = 0x01,
|
||||
GlslShader = 0x02
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(ShaderTypes, ShaderType)
|
||||
|
||||
ShaderTypes supportedShaderTypes() const;
|
||||
|
||||
ShaderType shaderType() const;
|
||||
void setShaderType(ShaderType type);
|
||||
#endif
|
||||
|
||||
public Q_SLOTS:
|
||||
void viewportDestroyed();
|
||||
|
||||
Q_SIGNALS:
|
||||
void frameChanged();
|
||||
|
||||
private:
|
||||
void createPainter();
|
||||
|
||||
QVideoSurfacePainter *m_painter;
|
||||
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
|
||||
QGLContext *m_glContext;
|
||||
ShaderTypes m_shaderTypes;
|
||||
ShaderType m_shaderType;
|
||||
#endif
|
||||
int m_brightness;
|
||||
int m_contrast;
|
||||
int m_hue;
|
||||
int m_saturation;
|
||||
|
||||
QVideoFrame::PixelFormat m_pixelFormat;
|
||||
QSize m_frameSize;
|
||||
QRect m_sourceRect;
|
||||
bool m_colorsDirty;
|
||||
bool m_ready;
|
||||
};
|
||||
|
||||
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QPainterVideoSurface::ShaderTypes)
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif
|
||||
89
src/multimediawidgets/qtmultimediawidgetdefs.h
Normal file
89
src/multimediawidgets/qtmultimediawidgetdefs.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#ifndef QTMULTIMEDIAWIDGETS_P_H
|
||||
#define QTMULTIMEDIAWIDGETS_P_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
# if defined(QT_NODLL)
|
||||
# undef QT_MAKEDLL
|
||||
# undef QT_DLL
|
||||
# elif defined(QT_MAKEDLL)
|
||||
# if defined(QT_DLL)
|
||||
# undef QT_DLL
|
||||
# endif
|
||||
# if defined(QT_BUILD_MULTIMEDIA_LIB)
|
||||
# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# elif defined(QT_DLL) /* use a Qt DLL library */
|
||||
# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(Q_MULTIMEDIAWIDGETS_EXPORT)
|
||||
# if defined(QT_SHARED)
|
||||
# define Q_MULTIMEDIAWIDGETS_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define Q_MULTIMEDIAWIDGETS_EXPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMULTIMEDIAWIDGETS_P_H
|
||||
|
||||
1043
src/multimediawidgets/qvideowidget.cpp
Normal file
1043
src/multimediawidgets/qvideowidget.cpp
Normal file
File diff suppressed because it is too large
Load Diff
139
src/multimediawidgets/qvideowidget.h
Normal file
139
src/multimediawidgets/qvideowidget.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QVIDEOWIDGET_H
|
||||
#define QVIDEOWIDGET_H
|
||||
|
||||
#include <QtWidgets/qwidget.h>
|
||||
|
||||
#include <qtmultimediawidgetdefs.h>
|
||||
#include <qmediabindableinterface.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QMediaObject;
|
||||
|
||||
class QVideoWidgetPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QVideoWidget : public QWidget, public QMediaBindableInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaBindableInterface)
|
||||
Q_PROPERTY(QMediaObject* mediaObject READ mediaObject WRITE setMediaObject)
|
||||
Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
|
||||
Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)
|
||||
Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
|
||||
Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged)
|
||||
Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged)
|
||||
Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
|
||||
|
||||
public:
|
||||
QVideoWidget(QWidget *parent = 0);
|
||||
~QVideoWidget();
|
||||
|
||||
QMediaObject *mediaObject() const;
|
||||
|
||||
#ifdef Q_QDOC
|
||||
bool isFullScreen() const;
|
||||
#endif
|
||||
|
||||
Qt::AspectRatioMode aspectRatioMode() const;
|
||||
|
||||
int brightness() const;
|
||||
int contrast() const;
|
||||
int hue() const;
|
||||
int saturation() const;
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setFullScreen(bool fullScreen);
|
||||
void setAspectRatioMode(Qt::AspectRatioMode mode);
|
||||
void setBrightness(int brightness);
|
||||
void setContrast(int contrast);
|
||||
void setHue(int hue);
|
||||
void setSaturation(int saturation);
|
||||
|
||||
Q_SIGNALS:
|
||||
void fullScreenChanged(bool fullScreen);
|
||||
void brightnessChanged(int brightness);
|
||||
void contrastChanged(int contrast);
|
||||
void hueChanged(int hue);
|
||||
void saturationChanged(int saturation);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
void showEvent(QShowEvent *event);
|
||||
void hideEvent(QHideEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void moveEvent(QMoveEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
bool setMediaObject(QMediaObject *object);
|
||||
|
||||
#if defined(Q_WS_WIN)
|
||||
bool winEvent(MSG *message, long *result);
|
||||
#endif
|
||||
|
||||
QVideoWidget(QVideoWidgetPrivate &dd, QWidget *parent);
|
||||
QVideoWidgetPrivate *d_ptr;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QVideoWidget)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_brightnessChanged(int))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_contrastChanged(int))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_hueChanged(int))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_saturationChanged(int))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_fullScreenChanged(bool))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_dimensionsChanged())
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif
|
||||
290
src/multimediawidgets/qvideowidget_p.h
Normal file
290
src/multimediawidgets/qvideowidget_p.h
Normal file
@@ -0,0 +1,290 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QVIDEOWIDGET_P_H
|
||||
#define QVIDEOWIDGET_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <qtmultimediawidgetdefs.h>
|
||||
#include "qvideowidget.h"
|
||||
|
||||
#ifndef QT_NO_OPENGL
|
||||
#include <QGLWidget>
|
||||
#endif
|
||||
|
||||
#include "qpaintervideosurface_p.h"
|
||||
|
||||
#include <QtCore/qpointer.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QMediaService;
|
||||
|
||||
class QVideoWidgetControlInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QVideoWidgetControlInterface() {}
|
||||
|
||||
virtual void setBrightness(int brightness) = 0;
|
||||
virtual void setContrast(int contrast) = 0;
|
||||
virtual void setHue(int hue) = 0;
|
||||
virtual void setSaturation(int saturation) = 0;
|
||||
|
||||
virtual void setFullScreen(bool fullScreen) = 0;
|
||||
|
||||
virtual Qt::AspectRatioMode aspectRatioMode() const = 0;
|
||||
virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0;
|
||||
};
|
||||
|
||||
class QVideoWidgetBackend : public QObject, public QVideoWidgetControlInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual QSize sizeHint() const = 0;
|
||||
|
||||
virtual void showEvent() = 0;
|
||||
virtual void hideEvent(QHideEvent *event) = 0;
|
||||
virtual void resizeEvent(QResizeEvent *event) = 0;
|
||||
virtual void moveEvent(QMoveEvent *event) = 0;
|
||||
virtual void paintEvent(QPaintEvent *event) = 0;
|
||||
};
|
||||
|
||||
class QVideoWidgetControl;
|
||||
|
||||
class QVideoWidgetControlBackend : public QObject, public QVideoWidgetControlInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QVideoWidgetControlBackend(QMediaService *service, QVideoWidgetControl *control, QWidget *widget);
|
||||
|
||||
void releaseControl();
|
||||
|
||||
void setBrightness(int brightness);
|
||||
void setContrast(int contrast);
|
||||
void setHue(int hue);
|
||||
void setSaturation(int saturation);
|
||||
|
||||
void setFullScreen(bool fullScreen);
|
||||
|
||||
Qt::AspectRatioMode aspectRatioMode() const;
|
||||
void setAspectRatioMode(Qt::AspectRatioMode mode);
|
||||
|
||||
private:
|
||||
QMediaService *m_service;
|
||||
QVideoWidgetControl *m_widgetControl;
|
||||
};
|
||||
|
||||
|
||||
class QVideoRendererControl;
|
||||
|
||||
class QRendererVideoWidgetBackend : public QVideoWidgetBackend
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QRendererVideoWidgetBackend(QMediaService *service, QVideoRendererControl *control, QWidget *widget);
|
||||
~QRendererVideoWidgetBackend();
|
||||
|
||||
void releaseControl();
|
||||
void clearSurface();
|
||||
|
||||
void setBrightness(int brightness);
|
||||
void setContrast(int contrast);
|
||||
void setHue(int hue);
|
||||
void setSaturation(int saturation);
|
||||
|
||||
void setFullScreen(bool fullScreen);
|
||||
|
||||
Qt::AspectRatioMode aspectRatioMode() const;
|
||||
void setAspectRatioMode(Qt::AspectRatioMode mode);
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
void showEvent();
|
||||
void hideEvent(QHideEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void moveEvent(QMoveEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
Q_SIGNALS:
|
||||
void fullScreenChanged(bool fullScreen);
|
||||
void brightnessChanged(int brightness);
|
||||
void contrastChanged(int contrast);
|
||||
void hueChanged(int hue);
|
||||
void saturationChanged(int saturation);
|
||||
|
||||
private Q_SLOTS:
|
||||
void formatChanged(const QVideoSurfaceFormat &format);
|
||||
void frameChanged();
|
||||
|
||||
private:
|
||||
void updateRects();
|
||||
|
||||
QMediaService *m_service;
|
||||
QVideoRendererControl *m_rendererControl;
|
||||
QWidget *m_widget;
|
||||
QPainterVideoSurface *m_surface;
|
||||
Qt::AspectRatioMode m_aspectRatioMode;
|
||||
QRect m_boundingRect;
|
||||
QRectF m_sourceRect;
|
||||
QSize m_nativeSize;
|
||||
bool m_updatePaintDevice;
|
||||
};
|
||||
|
||||
class QVideoWindowControl;
|
||||
|
||||
class QWindowVideoWidgetBackend : public QVideoWidgetBackend
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWindowVideoWidgetBackend(QMediaService *service, QVideoWindowControl *control, QWidget *widget);
|
||||
~QWindowVideoWidgetBackend();
|
||||
|
||||
void releaseControl();
|
||||
|
||||
void setBrightness(int brightness);
|
||||
void setContrast(int contrast);
|
||||
void setHue(int hue);
|
||||
void setSaturation(int saturation);
|
||||
|
||||
void setFullScreen(bool fullScreen);
|
||||
|
||||
Qt::AspectRatioMode aspectRatioMode() const;
|
||||
void setAspectRatioMode(Qt::AspectRatioMode mode);
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
void showEvent();
|
||||
void hideEvent(QHideEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
void moveEvent(QMoveEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
#if defined(Q_WS_WIN)
|
||||
bool winEvent(MSG *message, long *result);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QMediaService *m_service;
|
||||
QVideoWindowControl *m_windowControl;
|
||||
QWidget *m_widget;
|
||||
Qt::AspectRatioMode m_aspectRatioMode;
|
||||
QSize m_pixelAspectRatio;
|
||||
};
|
||||
|
||||
class QMediaService;
|
||||
class QVideoOutputControl;
|
||||
|
||||
class QVideoWidgetPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QVideoWidget)
|
||||
public:
|
||||
QVideoWidgetPrivate()
|
||||
: q_ptr(0)
|
||||
, mediaObject(0)
|
||||
, service(0)
|
||||
, widgetBackend(0)
|
||||
, windowBackend(0)
|
||||
, rendererBackend(0)
|
||||
, currentControl(0)
|
||||
, currentBackend(0)
|
||||
, brightness(0)
|
||||
, contrast(0)
|
||||
, hue(0)
|
||||
, saturation(0)
|
||||
, aspectRatioMode(Qt::KeepAspectRatio)
|
||||
, nonFullScreenFlags(0)
|
||||
, wasFullScreen(false)
|
||||
{
|
||||
}
|
||||
|
||||
QVideoWidget *q_ptr;
|
||||
QPointer<QMediaObject> mediaObject;
|
||||
QMediaService *service;
|
||||
QVideoWidgetControlBackend *widgetBackend;
|
||||
QWindowVideoWidgetBackend *windowBackend;
|
||||
QRendererVideoWidgetBackend *rendererBackend;
|
||||
QVideoWidgetControlInterface *currentControl;
|
||||
QVideoWidgetBackend *currentBackend;
|
||||
int brightness;
|
||||
int contrast;
|
||||
int hue;
|
||||
int saturation;
|
||||
Qt::AspectRatioMode aspectRatioMode;
|
||||
Qt::WindowFlags nonFullScreenFlags;
|
||||
bool wasFullScreen;
|
||||
|
||||
bool createWidgetBackend();
|
||||
bool createWindowBackend();
|
||||
bool createRendererBackend();
|
||||
|
||||
void setCurrentControl(QVideoWidgetControlInterface *control);
|
||||
void clearService();
|
||||
|
||||
void _q_serviceDestroyed();
|
||||
void _q_brightnessChanged(int brightness);
|
||||
void _q_contrastChanged(int contrast);
|
||||
void _q_hueChanged(int hue);
|
||||
void _q_saturationChanged(int saturation);
|
||||
void _q_fullScreenChanged(bool fullScreen);
|
||||
void _q_dimensionsChanged();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif
|
||||
245
src/multimediawidgets/qvideowidgetcontrol.cpp
Normal file
245
src/multimediawidgets/qvideowidgetcontrol.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qvideowidgetcontrol.h"
|
||||
#include "private/qmediacontrol_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QVideoWidgetControl
|
||||
|
||||
|
||||
\brief The QVideoWidgetControl class provides a media control which
|
||||
implements a video widget.
|
||||
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia-serv
|
||||
\since 1.0
|
||||
|
||||
The videoWidget() property of QVideoWidgetControl provides a pointer to a
|
||||
video widget implemented by the control's media service. This widget is
|
||||
owned by the media service and so care should be taken not to delete it.
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/video.cpp Video widget control
|
||||
|
||||
QVideoWidgetControl is one of number of possible video output controls.
|
||||
|
||||
The interface name of QVideoWidgetControl is \c com.nokia.Qt.QVideoWidgetControl/1.0 as
|
||||
defined in QVideoWidgetControl_iid.
|
||||
|
||||
\sa QMediaService::requestControl(), QVideoWidget
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro QVideoWidgetControl_iid
|
||||
|
||||
\c com.nokia.Qt.QVideoWidgetControl/1.0
|
||||
|
||||
Defines the interface name of the QVideoWidgetControl class.
|
||||
|
||||
\relates QVideoWidgetControl
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a new video widget control with the given \a parent.
|
||||
*/
|
||||
QVideoWidgetControl::QVideoWidgetControl(QObject *parent)
|
||||
:QMediaControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a video widget control.
|
||||
*/
|
||||
QVideoWidgetControl::~QVideoWidgetControl()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::isFullScreen() const
|
||||
|
||||
Returns true if the video is shown using the complete screen.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::setFullScreen(bool fullScreen)
|
||||
|
||||
Sets whether a video widget is in \a fullScreen mode.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::fullScreenChanged(bool fullScreen)
|
||||
|
||||
Signals that the \a fullScreen state of a video widget has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::aspectRatioMode() const
|
||||
|
||||
Returns how video is scaled to fit the widget with respect to its aspect ratio.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::setAspectRatioMode(Qt::AspectRatioMode mode)
|
||||
|
||||
Sets the aspect ratio \a mode which determines how video is scaled to the fit the widget with
|
||||
respect to its aspect ratio.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::brightness() const
|
||||
|
||||
Returns the brightness adjustment applied to a video.
|
||||
|
||||
Valid brightness values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::setBrightness(int brightness)
|
||||
|
||||
Sets a \a brightness adjustment for a video.
|
||||
|
||||
Valid brightness values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::brightnessChanged(int brightness)
|
||||
|
||||
Signals that a video widget's \a brightness adjustment has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::contrast() const
|
||||
|
||||
Returns the contrast adjustment applied to a video.
|
||||
|
||||
Valid contrast values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::setContrast(int contrast)
|
||||
|
||||
Sets the contrast adjustment for a video widget to \a contrast.
|
||||
|
||||
Valid contrast values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::contrastChanged(int contrast)
|
||||
|
||||
Signals that a video widget's \a contrast adjustment has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::hue() const
|
||||
|
||||
Returns the hue adjustment applied to a video widget.
|
||||
|
||||
Value hue values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::setHue(int hue)
|
||||
|
||||
Sets a \a hue adjustment for a video widget.
|
||||
|
||||
Valid hue values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::hueChanged(int hue)
|
||||
|
||||
Signals that a video widget's \a hue adjustment has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::saturation() const
|
||||
|
||||
Returns the saturation adjustment applied to a video widget.
|
||||
|
||||
Value saturation values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::setSaturation(int saturation)
|
||||
|
||||
Sets a \a saturation adjustment for a video widget.
|
||||
|
||||
Valid saturation values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::saturationChanged(int saturation)
|
||||
|
||||
Signals that a video widget's \a saturation adjustment has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWidgetControl::videoWidget()
|
||||
|
||||
Returns the QWidget.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
#include "moc_qvideowidgetcontrol.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
105
src/multimediawidgets/qvideowidgetcontrol.h
Normal file
105
src/multimediawidgets/qvideowidgetcontrol.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QVIDEOWIDGETCONTROL_H
|
||||
#define QVIDEOWIDGETCONTROL_H
|
||||
|
||||
#include "qvideowidget.h"
|
||||
#include "qmediacontrol.h"
|
||||
|
||||
#include <QtWidgets/qwidget.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QVideoWidgetControlPrivate;
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QVideoWidgetControl : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~QVideoWidgetControl();
|
||||
|
||||
virtual QWidget *videoWidget() = 0;
|
||||
|
||||
virtual Qt::AspectRatioMode aspectRatioMode() const = 0;
|
||||
virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0;
|
||||
|
||||
virtual bool isFullScreen() const = 0;
|
||||
virtual void setFullScreen(bool fullScreen) = 0;
|
||||
|
||||
virtual int brightness() const = 0;
|
||||
virtual void setBrightness(int brightness) = 0;
|
||||
|
||||
virtual int contrast() const = 0;
|
||||
virtual void setContrast(int contrast) = 0;
|
||||
|
||||
virtual int hue() const = 0;
|
||||
virtual void setHue(int hue) = 0;
|
||||
|
||||
virtual int saturation() const = 0;
|
||||
virtual void setSaturation(int saturation) = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void fullScreenChanged(bool fullScreen);
|
||||
void brightnessChanged(int brightness);
|
||||
void contrastChanged(int contrast);
|
||||
void hueChanged(int hue);
|
||||
void saturationChanged(int saturation);
|
||||
|
||||
protected:
|
||||
QVideoWidgetControl(QObject *parent = 0);
|
||||
};
|
||||
|
||||
#define QVideoWidgetControl_iid "com.nokia.Qt.QVideoWidgetControl/1.0"
|
||||
Q_MEDIA_DECLARE_CONTROL(QVideoWidgetControl, QVideoWidgetControl_iid)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif
|
||||
284
src/multimediawidgets/qvideowindowcontrol.cpp
Normal file
284
src/multimediawidgets/qvideowindowcontrol.cpp
Normal file
@@ -0,0 +1,284 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qvideowindowcontrol.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QVideoWindowControl
|
||||
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia-serv
|
||||
\brief The QVideoWindowControl class provides a media control for rendering video to a window.
|
||||
\since 1.0
|
||||
|
||||
|
||||
The winId() property QVideoWindowControl allows a platform specific window
|
||||
ID to be set as the video render target of a QMediaService. The
|
||||
displayRect() property is used to set the region of the window the video
|
||||
should be rendered to, and the aspectRatioMode() property indicates how the
|
||||
video should be scaled to fit the displayRect().
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/video.cpp Video window control
|
||||
|
||||
QVideoWindowControl is one of a number of possible video output controls.
|
||||
|
||||
The interface name of QVideoWindowControl is \c com.nokia.Qt.QVideoWindowControl/1.0 as
|
||||
defined in QVideoWindowControl_iid.
|
||||
|
||||
\sa QMediaService::requestControl(), QVideoWidget
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro QVideoWindowControl_iid
|
||||
|
||||
\c com.nokia.Qt.QVideoWindowControl/1.0
|
||||
|
||||
Defines the interface name of the QVideoWindowControl class.
|
||||
|
||||
\relates QVideoWindowControl
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a new video window control with the given \a parent.
|
||||
*/
|
||||
QVideoWindowControl::QVideoWindowControl(QObject *parent)
|
||||
: QMediaControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a video window control.
|
||||
*/
|
||||
QVideoWindowControl::~QVideoWindowControl()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::winId() const
|
||||
|
||||
Returns the ID of the window a video overlay end point renders to.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::setWinId(WId id)
|
||||
|
||||
Sets the \a id of the window a video overlay end point renders to.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::displayRect() const
|
||||
Returns the sub-rect of a window where video is displayed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::setDisplayRect(const QRect &rect)
|
||||
Sets the sub-\a rect of a window where video is displayed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::isFullScreen() const
|
||||
|
||||
Identifies if a video overlay is a fullScreen overlay.
|
||||
|
||||
Returns true if the video overlay is fullScreen, and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::setFullScreen(bool fullScreen)
|
||||
|
||||
Sets whether a video overlay is a \a fullScreen overlay.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::fullScreenChanged(bool fullScreen)
|
||||
|
||||
Signals that the \a fullScreen state of a video overlay has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::repaint()
|
||||
|
||||
Repaints the last frame.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::nativeSize() const
|
||||
|
||||
Returns a suggested size for the video display based on the resolution and aspect ratio of the
|
||||
video.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::nativeSizeChanged()
|
||||
|
||||
Signals that the native dimensions of the video have changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::aspectRatioMode() const
|
||||
|
||||
Returns how video is scaled to fit the display region with respect to its aspect ratio.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
|
||||
|
||||
Sets the aspect ratio \a mode which determines how video is scaled to the fit the display region
|
||||
with respect to its aspect ratio.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::brightness() const
|
||||
|
||||
Returns the brightness adjustment applied to a video overlay.
|
||||
|
||||
Valid brightness values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::setBrightness(int brightness)
|
||||
|
||||
Sets a \a brightness adjustment for a video overlay.
|
||||
|
||||
Valid brightness values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::brightnessChanged(int brightness)
|
||||
|
||||
Signals that a video overlay's \a brightness adjustment has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::contrast() const
|
||||
|
||||
Returns the contrast adjustment applied to a video overlay.
|
||||
|
||||
Valid contrast values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::setContrast(int contrast)
|
||||
|
||||
Sets the \a contrast adjustment for a video overlay.
|
||||
|
||||
Valid contrast values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::contrastChanged(int contrast)
|
||||
|
||||
Signals that a video overlay's \a contrast adjustment has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::hue() const
|
||||
|
||||
Returns the hue adjustment applied to a video overlay.
|
||||
|
||||
Value hue values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::setHue(int hue)
|
||||
|
||||
Sets a \a hue adjustment for a video overlay.
|
||||
|
||||
Valid hue values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::hueChanged(int hue)
|
||||
|
||||
Signals that a video overlay's \a hue adjustment has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::saturation() const
|
||||
|
||||
Returns the saturation adjustment applied to a video overlay.
|
||||
|
||||
Value saturation values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::setSaturation(int saturation)
|
||||
Sets a \a saturation adjustment for a video overlay.
|
||||
|
||||
Valid saturation values range between -100 and 100, the default is 0.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVideoWindowControl::saturationChanged(int saturation)
|
||||
|
||||
Signals that a video overlay's \a saturation adjustment has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
#include "moc_qvideowindowcontrol.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
112
src/multimediawidgets/qvideowindowcontrol.h
Normal file
112
src/multimediawidgets/qvideowindowcontrol.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt 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 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QVIDEOWINDOWCONTROL_H
|
||||
#define QVIDEOWINDOWCONTROL_H
|
||||
|
||||
#include "qmediacontrol.h"
|
||||
#include "qvideowidget.h"
|
||||
|
||||
#include <QtWidgets/qwidget.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QVideoWindowControl : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
~QVideoWindowControl();
|
||||
|
||||
virtual WId winId() const = 0;
|
||||
virtual void setWinId(WId id) = 0;
|
||||
|
||||
virtual QRect displayRect() const = 0;
|
||||
virtual void setDisplayRect(const QRect &rect) = 0;
|
||||
|
||||
virtual bool isFullScreen() const = 0;
|
||||
virtual void setFullScreen(bool fullScreen) = 0;
|
||||
|
||||
virtual void repaint() = 0;
|
||||
|
||||
virtual QSize nativeSize() const = 0;
|
||||
|
||||
virtual Qt::AspectRatioMode aspectRatioMode() const = 0;
|
||||
virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0;
|
||||
|
||||
virtual int brightness() const = 0;
|
||||
virtual void setBrightness(int brightness) = 0;
|
||||
|
||||
virtual int contrast() const = 0;
|
||||
virtual void setContrast(int contrast) = 0;
|
||||
|
||||
virtual int hue() const = 0;
|
||||
virtual void setHue(int hue) = 0;
|
||||
|
||||
virtual int saturation() const = 0;
|
||||
virtual void setSaturation(int saturation) = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void fullScreenChanged(bool fullScreen);
|
||||
void brightnessChanged(int brightness);
|
||||
void contrastChanged(int contrast);
|
||||
void hueChanged(int hue);
|
||||
void saturationChanged(int saturation);
|
||||
void nativeSizeChanged();
|
||||
|
||||
protected:
|
||||
QVideoWindowControl(QObject *parent = 0);
|
||||
};
|
||||
|
||||
#define QVideoWindowControl_iid "com.nokia.Qt.QVideoWindowControl/1.0"
|
||||
Q_MEDIA_DECLARE_CONTROL(QVideoWindowControl, QVideoWindowControl_iid)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user