Fix X11 and QPA compilation problems
The X11 buffer pool was using outdated APIs, and as the 'qpa' configuration value is being removed, it caused the X11 code to be pulled in, and therefore cause compilation failures. Change-Id: I5fdaed854c6525716fccca44b5fbd0b850880cb9 Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
53
config.tests/xvideo/main.cpp
Normal file
53
config.tests/xvideo/main.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
** All rights reserved.
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Multimedia module 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 <X11/Xlib.h>
|
||||||
|
#include <X11/extensions/Xv.h>
|
||||||
|
#include <X11/extensions/Xvlib.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
unsigned int count = 0;
|
||||||
|
XvAdaptorInfo *adaptors = 0;
|
||||||
|
XvQueryAdaptors(0, 0, &count, &adaptors);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
16
config.tests/xvideo/xvideo.pro
Normal file
16
config.tests/xvideo/xvideo.pro
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
TEMPLATE = app
|
||||||
|
DEPENDPATH += .
|
||||||
|
INCLUDEPATH += .
|
||||||
|
|
||||||
|
requires(unix)
|
||||||
|
|
||||||
|
# Input
|
||||||
|
SOURCES += main.cpp
|
||||||
|
|
||||||
|
CONFIG += link_pkgconfig
|
||||||
|
|
||||||
|
PKGCONFIG += \
|
||||||
|
x11 \
|
||||||
|
xext \
|
||||||
|
xv
|
||||||
|
|
||||||
@@ -43,7 +43,6 @@ PRIVATE_HEADERS += \
|
|||||||
qgstvideobuffer_p.h \
|
qgstvideobuffer_p.h \
|
||||||
qvideosurfacegstsink_p.h \
|
qvideosurfacegstsink_p.h \
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
qgstbufferpoolinterface.cpp \
|
qgstbufferpoolinterface.cpp \
|
||||||
qgstreamerbushelper.cpp \
|
qgstreamerbushelper.cpp \
|
||||||
@@ -52,13 +51,14 @@ SOURCES += \
|
|||||||
qgstvideobuffer.cpp \
|
qgstvideobuffer.cpp \
|
||||||
qvideosurfacegstsink.cpp \
|
qvideosurfacegstsink.cpp \
|
||||||
|
|
||||||
!win32:!contains(QT_CONFIG,embedded):!mac:!simulator:!contains(QT_CONFIG, qpa) {
|
contains(config_test_xvideo, yes) {
|
||||||
|
DEFINES += HAVE_XVIDEO
|
||||||
|
|
||||||
LIBS += -lXv -lX11 -lXext
|
LIBS += -lXv -lX11 -lXext
|
||||||
|
|
||||||
PRIVATE_HEADERS += \
|
PRIVATE_HEADERS += \
|
||||||
qgstxvimagebuffer_p.h \
|
qgstxvimagebuffer_p.h \
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
qgstxvimagebuffer.cpp \
|
qgstxvimagebuffer.cpp \
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,14 +42,14 @@
|
|||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtCore/qthread.h>
|
#include <QtCore/qthread.h>
|
||||||
#include <QtCore/qvariant.h>
|
#include <QtCore/qvariant.h>
|
||||||
#include <QtWidgets/qx11info_x11.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
|
#include <QtGui/qwindow.h>
|
||||||
|
#include <QtGui/qplatformnativeinterface_qpa.h>
|
||||||
|
|
||||||
#include "qgstxvimagebuffer_p.h"
|
#include "qgstxvimagebuffer_p.h"
|
||||||
#include "qvideosurfacegstsink_p.h"
|
#include "qvideosurfacegstsink_p.h"
|
||||||
#include "qgstvideobuffer_p.h"
|
#include "qgstvideobuffer_p.h"
|
||||||
|
|
||||||
#ifndef QT_NO_XVIDEO
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
GstBufferClass *QGstXvImageBuffer::parent_class = NULL;
|
GstBufferClass *QGstXvImageBuffer::parent_class = NULL;
|
||||||
@@ -182,6 +182,11 @@ QAbstractVideoBuffer *QGstXvImageBufferPool::prepareVideoBuffer(GstBuffer *buffe
|
|||||||
return new QGstVideoBuffer(buffer, bytesPerLine, QAbstractVideoBuffer::XvShmImageHandle, handle);
|
return new QGstVideoBuffer(buffer, bytesPerLine, QAbstractVideoBuffer::XvShmImageHandle, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList QGstXvImageBufferPool::keys() const
|
||||||
|
{
|
||||||
|
return QStringList() << QGstBufferPoolPluginKey;
|
||||||
|
}
|
||||||
|
|
||||||
void QGstXvImageBufferPool::queuedAlloc()
|
void QGstXvImageBufferPool::queuedAlloc()
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&m_poolMutex);
|
QMutexLocker lock(&m_poolMutex);
|
||||||
@@ -194,7 +199,7 @@ void QGstXvImageBufferPool::doAlloc()
|
|||||||
//should be always called from the main thread with m_poolMutex locked
|
//should be always called from the main thread with m_poolMutex locked
|
||||||
//Q_ASSERT(QThread::currentThread() == thread());
|
//Q_ASSERT(QThread::currentThread() == thread());
|
||||||
|
|
||||||
XSync(QX11Info::display(), false);
|
XSync(display(), false);
|
||||||
|
|
||||||
QGstXvImageBuffer *xvBuffer = (QGstXvImageBuffer *)gst_mini_object_new(QGstXvImageBuffer::get_type());
|
QGstXvImageBuffer *xvBuffer = (QGstXvImageBuffer *)gst_mini_object_new(QGstXvImageBuffer::get_type());
|
||||||
|
|
||||||
@@ -202,7 +207,7 @@ void QGstXvImageBufferPool::doAlloc()
|
|||||||
int xvFormatId = m_format.property("xvFormatId").toInt();
|
int xvFormatId = m_format.property("xvFormatId").toInt();
|
||||||
|
|
||||||
xvBuffer->xvImage = XvShmCreateImage(
|
xvBuffer->xvImage = XvShmCreateImage(
|
||||||
QX11Info::display(),
|
display(),
|
||||||
portId,
|
portId,
|
||||||
xvFormatId,
|
xvFormatId,
|
||||||
0,
|
0,
|
||||||
@@ -216,18 +221,18 @@ void QGstXvImageBufferPool::doAlloc()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSync(QX11Info::display(), false);
|
XSync(display(), false);
|
||||||
|
|
||||||
xvBuffer->shmInfo.shmid = shmget(IPC_PRIVATE, xvBuffer->xvImage->data_size, IPC_CREAT | 0777);
|
xvBuffer->shmInfo.shmid = shmget(IPC_PRIVATE, xvBuffer->xvImage->data_size, IPC_CREAT | 0777);
|
||||||
xvBuffer->shmInfo.shmaddr = xvBuffer->xvImage->data = (char*)shmat(xvBuffer->shmInfo.shmid, 0, 0);
|
xvBuffer->shmInfo.shmaddr = xvBuffer->xvImage->data = (char*)shmat(xvBuffer->shmInfo.shmid, 0, 0);
|
||||||
xvBuffer->shmInfo.readOnly = False;
|
xvBuffer->shmInfo.readOnly = False;
|
||||||
|
|
||||||
if (!XShmAttach(QX11Info::display(), &xvBuffer->shmInfo)) {
|
if (!XShmAttach(display(), &xvBuffer->shmInfo)) {
|
||||||
qWarning() << "QGstXvImageBufferPool: XShmAttach failed";
|
qWarning() << "QGstXvImageBufferPool: XShmAttach failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSync(QX11Info::display(), false);
|
XSync(display(), false);
|
||||||
|
|
||||||
shmctl (xvBuffer->shmInfo.shmid, IPC_RMID, NULL);
|
shmctl (xvBuffer->shmInfo.shmid, IPC_RMID, NULL);
|
||||||
|
|
||||||
@@ -240,7 +245,7 @@ void QGstXvImageBufferPool::doAlloc()
|
|||||||
m_allBuffers.append(xvBuffer);
|
m_allBuffers.append(xvBuffer);
|
||||||
m_pool.append(xvBuffer);
|
m_pool.append(xvBuffer);
|
||||||
|
|
||||||
XSync(QX11Info::display(), false);
|
XSync(display(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -269,12 +274,12 @@ void QGstXvImageBufferPool::queuedDestroy()
|
|||||||
{
|
{
|
||||||
QMutexLocker lock(&m_destroyMutex);
|
QMutexLocker lock(&m_destroyMutex);
|
||||||
|
|
||||||
XSync(QX11Info::display(), false);
|
XSync(display(), false);
|
||||||
|
|
||||||
foreach(XvShmImage xvImage, m_imagesToDestroy) {
|
foreach(XvShmImage xvImage, m_imagesToDestroy) {
|
||||||
if (xvImage.shmInfo.shmaddr != ((void *) -1)) {
|
if (xvImage.shmInfo.shmaddr != ((void *) -1)) {
|
||||||
XShmDetach(QX11Info::display(), &xvImage.shmInfo);
|
XShmDetach(display(), &xvImage.shmInfo);
|
||||||
XSync(QX11Info::display(), false);
|
XSync(display(), false);
|
||||||
|
|
||||||
shmdt(xvImage.shmInfo.shmaddr);
|
shmdt(xvImage.shmInfo.shmaddr);
|
||||||
}
|
}
|
||||||
@@ -285,7 +290,7 @@ void QGstXvImageBufferPool::queuedDestroy()
|
|||||||
|
|
||||||
m_imagesToDestroy.clear();
|
m_imagesToDestroy.clear();
|
||||||
|
|
||||||
XSync(QX11Info::display(), false);
|
XSync(display(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGstXvImageBufferPool::recycleBuffer(QGstXvImageBuffer *xvBuffer)
|
void QGstXvImageBufferPool::recycleBuffer(QGstXvImageBuffer *xvBuffer)
|
||||||
@@ -309,7 +314,13 @@ void QGstXvImageBufferPool::destroyBuffer(QGstXvImageBuffer *xvBuffer)
|
|||||||
QMetaObject::invokeMethod(this, "queuedDestroy", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "queuedDestroy", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Display *QGstXvImageBufferPool::display() const
|
||||||
|
{
|
||||||
|
QWindow *window = QGuiApplication::topLevelWindows().first();
|
||||||
|
Display *display = static_cast<Display *>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("Display", window));
|
||||||
|
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif //QT_NO_XVIDEO
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,7 @@
|
|||||||
#include <private/qmediapluginloader_p.h>
|
#include <private/qmediapluginloader_p.h>
|
||||||
#include "qgstvideobuffer_p.h"
|
#include "qgstvideobuffer_p.h"
|
||||||
|
|
||||||
#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
|
#if defined(HAVE_XVIDEO)
|
||||||
#include <QtWidgets/qx11info_x11.h>
|
|
||||||
#include "qgstxvimagebuffer_p.h"
|
#include "qgstxvimagebuffer_p.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ QVideoSurfaceGstDelegate::QVideoSurfaceGstDelegate(
|
|||||||
m_pools.append(plugin);
|
m_pools.append(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
|
#ifdef HAVE_XVIDEO
|
||||||
m_pools.append(new QGstXvImageBufferPool());
|
m_pools.append(new QGstXvImageBufferPool());
|
||||||
#endif
|
#endif
|
||||||
updateSupportedFormats();
|
updateSupportedFormats();
|
||||||
|
|||||||
@@ -59,8 +59,6 @@
|
|||||||
#include <QtCore/qwaitcondition.h>
|
#include <QtCore/qwaitcondition.h>
|
||||||
#include <QtCore/qqueue.h>
|
#include <QtCore/qqueue.h>
|
||||||
|
|
||||||
#ifndef QT_NO_XVIDEO
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
@@ -69,10 +67,11 @@
|
|||||||
#include <X11/extensions/Xv.h>
|
#include <X11/extensions/Xv.h>
|
||||||
#include <X11/extensions/Xvlib.h>
|
#include <X11/extensions/Xvlib.h>
|
||||||
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include "qgstbufferpoolinterface_p.h"
|
#include "qgstbufferpoolinterface_p.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QGstXvImageBufferPool;
|
class QGstXvImageBufferPool;
|
||||||
|
|
||||||
struct QGstXvImageBuffer {
|
struct QGstXvImageBuffer {
|
||||||
@@ -93,6 +92,7 @@ Q_DECLARE_METATYPE(XvImage*)
|
|||||||
|
|
||||||
class QGstXvImageBufferPool : public QObject, public QGstBufferPoolInterface {
|
class QGstXvImageBufferPool : public QObject, public QGstBufferPoolInterface {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_INTERFACES(QGstBufferPoolInterface)
|
||||||
friend class QGstXvImageBuffer;
|
friend class QGstXvImageBuffer;
|
||||||
public:
|
public:
|
||||||
QGstXvImageBufferPool(QObject *parent = 0);
|
QGstXvImageBufferPool(QObject *parent = 0);
|
||||||
@@ -107,6 +107,8 @@ public:
|
|||||||
QAbstractVideoBuffer::HandleType handleType() const;
|
QAbstractVideoBuffer::HandleType handleType() const;
|
||||||
QAbstractVideoBuffer *prepareVideoBuffer(GstBuffer *buffer, int bytesPerLine);
|
QAbstractVideoBuffer *prepareVideoBuffer(GstBuffer *buffer, int bytesPerLine);
|
||||||
|
|
||||||
|
virtual QStringList keys() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void queuedAlloc();
|
void queuedAlloc();
|
||||||
void queuedDestroy();
|
void queuedDestroy();
|
||||||
@@ -119,6 +121,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void doAlloc();
|
void doAlloc();
|
||||||
|
|
||||||
|
Display *display() const;
|
||||||
|
|
||||||
struct XvShmImage {
|
struct XvShmImage {
|
||||||
XvImage *xvImage;
|
XvImage *xvImage;
|
||||||
XShmSegmentInfo shmInfo;
|
XShmSegmentInfo shmInfo;
|
||||||
@@ -136,6 +140,6 @@ private:
|
|||||||
Qt::HANDLE m_threadId;
|
Qt::HANDLE m_threadId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //QT_NO_XVIDEO
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QAbstractVideoSurface;
|
class QAbstractVideoSurface;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
|
#ifdef HAVE_XVIDEO
|
||||||
class QGstXvImageBuffer;
|
class QGstXvImageBuffer;
|
||||||
class QGstXvImageBufferPool;
|
class QGstXvImageBufferPool;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ CameraBinService::CameraBinService(const QString &service, QObject *parent):
|
|||||||
m_videoRenderer = new QGstreamerVideoRenderer(this);
|
m_videoRenderer = new QGstreamerVideoRenderer(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
|
#ifdef HAVE_XVIDEO
|
||||||
|
|
||||||
#ifdef Q_WS_MAEMO_6
|
#ifdef Q_WS_MAEMO_6
|
||||||
m_videoWindow = new QGstreamerVideoWindow(this, "omapxvsink");
|
m_videoWindow = new QGstreamerVideoWindow(this, "omapxvsink");
|
||||||
|
|||||||
@@ -68,7 +68,9 @@ SOURCES += \
|
|||||||
gstvideoconnector.c \
|
gstvideoconnector.c \
|
||||||
|
|
||||||
|
|
||||||
!win32:!contains(QT_CONFIG,embedded):!mac:!simulator:!contains(QT_CONFIG, qpa) {
|
contains(config_test_xvideo, yes) {
|
||||||
|
DEFINES += HAVE_XVIDEO
|
||||||
|
|
||||||
LIBS += -lXv -lX11 -lXext
|
LIBS += -lXv -lX11 -lXext
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ QGstreamerCaptureService::QGstreamerCaptureService(const QString &service, QObje
|
|||||||
|
|
||||||
m_videoRenderer = new QGstreamerVideoRenderer(this);
|
m_videoRenderer = new QGstreamerVideoRenderer(this);
|
||||||
|
|
||||||
#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
|
#ifdef HAVE_XVIDEO
|
||||||
m_videoWindow = new QGstreamerVideoOverlay(this);
|
m_videoWindow = new QGstreamerVideoOverlay(this);
|
||||||
m_videoWidgetControl = new QGstreamerVideoWidgetControl(this);
|
m_videoWidgetControl = new QGstreamerVideoWidgetControl(this);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent):
|
|||||||
m_videoRenderer = new QGstreamerVideoRenderer(this);
|
m_videoRenderer = new QGstreamerVideoRenderer(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
|
#ifdef HAVE_XVIDEO
|
||||||
|
|
||||||
#ifdef Q_WS_MAEMO_6
|
#ifdef Q_WS_MAEMO_6
|
||||||
m_videoWindow = new QGstreamerVideoWindow(this, "omapxvsink");
|
m_videoWindow = new QGstreamerVideoWindow(this, "omapxvsink");
|
||||||
|
|||||||
@@ -44,9 +44,7 @@
|
|||||||
|
|
||||||
#include <qvideosurfaceformat.h>
|
#include <qvideosurfaceformat.h>
|
||||||
|
|
||||||
#include <private/qx11videosurface_p.h>
|
#include <qx11videosurface.h>
|
||||||
|
|
||||||
#ifndef QT_NO_XVIDEO
|
|
||||||
|
|
||||||
QGstreamerVideoOverlay::QGstreamerVideoOverlay(QObject *parent)
|
QGstreamerVideoOverlay::QGstreamerVideoOverlay(QObject *parent)
|
||||||
: QVideoWindowControl(parent)
|
: QVideoWindowControl(parent)
|
||||||
@@ -228,5 +226,3 @@ void QGstreamerVideoOverlay::setScaledDisplayRect()
|
|||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //QT_NO_XVIDEO
|
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ class QAbstractVideoSurface;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
class QX11VideoSurface;
|
class QX11VideoSurface;
|
||||||
|
|
||||||
#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QGstreamerVideoOverlay : public QVideoWindowControl, public QGstreamerVideoRendererInterface
|
class QGstreamerVideoOverlay : public QVideoWindowControl, public QGstreamerVideoRendererInterface
|
||||||
@@ -116,6 +114,4 @@ private:
|
|||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif //QT_NO_XVIDEO
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -48,9 +48,6 @@
|
|||||||
#include <gst/interfaces/xoverlay.h>
|
#include <gst/interfaces/xoverlay.h>
|
||||||
#include <gst/interfaces/propertyprobe.h>
|
#include <gst/interfaces/propertyprobe.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef QT_NO_XVIDEO
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QGstreamerVideoWindow is similar to QGstreamerVideoOverlay,
|
QGstreamerVideoWindow is similar to QGstreamerVideoOverlay,
|
||||||
but uses xvimagesink like gstreamer element instead of QX11VideoSurface.
|
but uses xvimagesink like gstreamer element instead of QX11VideoSurface.
|
||||||
@@ -347,5 +344,3 @@ GstElement *QGstreamerVideoWindow::videoSink()
|
|||||||
{
|
{
|
||||||
return m_videoSink;
|
return m_videoSink;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //QT_NO_XVIDEO
|
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ class QAbstractVideoSurface;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
class QX11VideoSurface;
|
class QX11VideoSurface;
|
||||||
|
|
||||||
#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO)
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QGstreamerVideoWindow : public QVideoWindowControl,
|
class QGstreamerVideoWindow : public QVideoWindowControl,
|
||||||
@@ -131,6 +129,4 @@ private:
|
|||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif //QT_NO_XVIDEO
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -41,11 +41,10 @@
|
|||||||
|
|
||||||
#include <QtCore/qvariant.h>
|
#include <QtCore/qvariant.h>
|
||||||
#include <QtCore/qdebug.h>
|
#include <QtCore/qdebug.h>
|
||||||
#include <QtWidgets/qx11info_x11.h>
|
#include <QtGui/qguiapplication.h>
|
||||||
|
#include <QtGui/qplatformnativeinterface_qpa.h>
|
||||||
#include <qvideosurfaceformat.h>
|
#include <qvideosurfaceformat.h>
|
||||||
|
|
||||||
#ifndef QT_NO_XVIDEO
|
|
||||||
|
|
||||||
#include "qx11videosurface.h"
|
#include "qx11videosurface.h"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(XvImage*);
|
Q_DECLARE_METATYPE(XvImage*);
|
||||||
@@ -149,10 +148,10 @@ QX11VideoSurface::QX11VideoSurface(QObject *parent)
|
|||||||
QX11VideoSurface::~QX11VideoSurface()
|
QX11VideoSurface::~QX11VideoSurface()
|
||||||
{
|
{
|
||||||
if (m_gc)
|
if (m_gc)
|
||||||
XFreeGC(QX11Info::display(), m_gc);
|
XFreeGC(display(), m_gc);
|
||||||
|
|
||||||
if (m_portId != 0)
|
if (m_portId != 0)
|
||||||
XvUngrabPort(QX11Info::display(), m_portId, 0);
|
XvUngrabPort(display(), m_portId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WId QX11VideoSurface::winId() const
|
WId QX11VideoSurface::winId() const
|
||||||
@@ -171,12 +170,12 @@ void QX11VideoSurface::setWinId(WId id)
|
|||||||
XFree(m_image);
|
XFree(m_image);
|
||||||
|
|
||||||
if (m_gc) {
|
if (m_gc) {
|
||||||
XFreeGC(QX11Info::display(), m_gc);
|
XFreeGC(display(), m_gc);
|
||||||
m_gc = 0;
|
m_gc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_portId != 0)
|
if (m_portId != 0)
|
||||||
XvUngrabPort(QX11Info::display(), m_portId, 0);
|
XvUngrabPort(display(), m_portId, 0);
|
||||||
|
|
||||||
m_supportedPixelFormats.clear();
|
m_supportedPixelFormats.clear();
|
||||||
m_formatIds.clear();
|
m_formatIds.clear();
|
||||||
@@ -186,7 +185,7 @@ void QX11VideoSurface::setWinId(WId id)
|
|||||||
if (m_winId && findPort()) {
|
if (m_winId && findPort()) {
|
||||||
querySupportedFormats();
|
querySupportedFormats();
|
||||||
|
|
||||||
m_gc = XCreateGC(QX11Info::display(), m_winId, 0, 0);
|
m_gc = XCreateGC(display(), m_winId, 0, 0);
|
||||||
|
|
||||||
if (m_image) {
|
if (m_image) {
|
||||||
m_image = 0;
|
m_image = 0;
|
||||||
@@ -271,13 +270,13 @@ void QX11VideoSurface::setSaturation(int saturation)
|
|||||||
int QX11VideoSurface::getAttribute(const char *attribute, int minimum, int maximum) const
|
int QX11VideoSurface::getAttribute(const char *attribute, int minimum, int maximum) const
|
||||||
{
|
{
|
||||||
if (m_portId != 0) {
|
if (m_portId != 0) {
|
||||||
Display *display = QX11Info::display();
|
Display *disp = display();
|
||||||
|
|
||||||
Atom atom = XInternAtom(display, attribute, True);
|
Atom atom = XInternAtom(disp, attribute, True);
|
||||||
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
XvGetPortAttribute(display, m_portId, atom, &value);
|
XvGetPortAttribute(disp, m_portId, atom, &value);
|
||||||
|
|
||||||
return redistribute(value, minimum, maximum, -100, 100);
|
return redistribute(value, minimum, maximum, -100, 100);
|
||||||
} else {
|
} else {
|
||||||
@@ -288,12 +287,12 @@ int QX11VideoSurface::getAttribute(const char *attribute, int minimum, int maxim
|
|||||||
void QX11VideoSurface::setAttribute(const char *attribute, int value, int minimum, int maximum)
|
void QX11VideoSurface::setAttribute(const char *attribute, int value, int minimum, int maximum)
|
||||||
{
|
{
|
||||||
if (m_portId != 0) {
|
if (m_portId != 0) {
|
||||||
Display *display = QX11Info::display();
|
Display *disp = display();
|
||||||
|
|
||||||
Atom atom = XInternAtom(display, attribute, True);
|
Atom atom = XInternAtom(disp, attribute, True);
|
||||||
|
|
||||||
XvSetPortAttribute(
|
XvSetPortAttribute(
|
||||||
display, m_portId, atom, redistribute(value, -100, 100, minimum, maximum));
|
disp, m_portId, atom, redistribute(value, -100, 100, minimum, maximum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +329,7 @@ bool QX11VideoSurface::start(const QVideoSurfaceFormat &format)
|
|||||||
setError(UnsupportedFormatError);
|
setError(UnsupportedFormatError);
|
||||||
} else {
|
} else {
|
||||||
XvImage *image = XvCreateImage(
|
XvImage *image = XvCreateImage(
|
||||||
QX11Info::display(),
|
display(),
|
||||||
m_portId,
|
m_portId,
|
||||||
xvFormatId,
|
xvFormatId,
|
||||||
0,
|
0,
|
||||||
@@ -403,7 +402,7 @@ bool QX11VideoSurface::present(const QVideoFrame &frame)
|
|||||||
|
|
||||||
//qDebug() << "copy frame";
|
//qDebug() << "copy frame";
|
||||||
XvPutImage(
|
XvPutImage(
|
||||||
QX11Info::display(),
|
display(),
|
||||||
m_portId,
|
m_portId,
|
||||||
m_winId,
|
m_winId,
|
||||||
m_gc,
|
m_gc,
|
||||||
@@ -424,7 +423,7 @@ bool QX11VideoSurface::present(const QVideoFrame &frame)
|
|||||||
//qDebug() << "render directly";
|
//qDebug() << "render directly";
|
||||||
if (img)
|
if (img)
|
||||||
XvShmPutImage(
|
XvShmPutImage(
|
||||||
QX11Info::display(),
|
display(),
|
||||||
m_portId,
|
m_portId,
|
||||||
m_winId,
|
m_winId,
|
||||||
m_gc,
|
m_gc,
|
||||||
@@ -450,19 +449,27 @@ bool QX11VideoSurface::present(const QVideoFrame &frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Display *QX11VideoSurface::display() const
|
||||||
|
{
|
||||||
|
QWindow *window = QGuiApplication::focusWindow();
|
||||||
|
Display *display = (Display *)QGuiApplication::platformNativeInterface()->nativeResourceForWindow("Display", window);
|
||||||
|
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
bool QX11VideoSurface::findPort()
|
bool QX11VideoSurface::findPort()
|
||||||
{
|
{
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
XvAdaptorInfo *adaptors = 0;
|
XvAdaptorInfo *adaptors = 0;
|
||||||
bool portFound = false;
|
bool portFound = false;
|
||||||
|
|
||||||
if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) {
|
if (XvQueryAdaptors(display(), m_winId, &count, &adaptors) == Success) {
|
||||||
for (unsigned int i = 0; i < count && !portFound; ++i) {
|
for (unsigned int i = 0; i < count && !portFound; ++i) {
|
||||||
if (adaptors[i].type & XvImageMask) {
|
if (adaptors[i].type & XvImageMask) {
|
||||||
m_portId = adaptors[i].base_id;
|
m_portId = adaptors[i].base_id;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId)
|
for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId)
|
||||||
portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success;
|
portFound = XvGrabPort(display(), m_portId, 0) == Success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XvFreeAdaptorInfo(adaptors);
|
XvFreeAdaptorInfo(adaptors);
|
||||||
@@ -475,7 +482,7 @@ void QX11VideoSurface::querySupportedFormats()
|
|||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (XvImageFormatValues *imageFormats = XvListImageFormats(
|
if (XvImageFormatValues *imageFormats = XvListImageFormats(
|
||||||
QX11Info::display(), m_portId, &count)) {
|
display(), m_portId, &count)) {
|
||||||
const int rgbCount = sizeof(qt_xvRgbLookup) / sizeof(XvFormatRgb);
|
const int rgbCount = sizeof(qt_xvRgbLookup) / sizeof(XvFormatRgb);
|
||||||
const int yuvCount = sizeof(qt_xvYuvLookup) / sizeof(XvFormatYuv);
|
const int yuvCount = sizeof(qt_xvYuvLookup) / sizeof(XvFormatYuv);
|
||||||
|
|
||||||
@@ -509,7 +516,7 @@ void QX11VideoSurface::querySupportedFormats()
|
|||||||
m_hueRange = qMakePair(0, 0);
|
m_hueRange = qMakePair(0, 0);
|
||||||
m_saturationRange = qMakePair(0, 0);
|
m_saturationRange = qMakePair(0, 0);
|
||||||
|
|
||||||
if (XvAttribute *attributes = XvQueryPortAttributes(QX11Info::display(), m_portId, &count)) {
|
if (XvAttribute *attributes = XvQueryPortAttributes(display(), m_portId, &count)) {
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
if (qstrcmp(attributes[i].name, "XV_BRIGHTNESS") == 0)
|
if (qstrcmp(attributes[i].name, "XV_BRIGHTNESS") == 0)
|
||||||
m_brightnessRange = qMakePair(attributes[i].min_value, attributes[i].max_value);
|
m_brightnessRange = qMakePair(attributes[i].min_value, attributes[i].max_value);
|
||||||
@@ -525,5 +532,3 @@ void QX11VideoSurface::querySupportedFormats()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //QT_NO_XVIDEO
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,6 @@
|
|||||||
#include <QtWidgets/qwidget.h>
|
#include <QtWidgets/qwidget.h>
|
||||||
#include <qabstractvideosurface.h>
|
#include <qabstractvideosurface.h>
|
||||||
|
|
||||||
#ifndef QT_NO_XVIDEO
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/extensions/Xv.h>
|
#include <X11/extensions/Xv.h>
|
||||||
#include <X11/extensions/Xvlib.h>
|
#include <X11/extensions/Xvlib.h>
|
||||||
@@ -90,6 +88,8 @@ public:
|
|||||||
bool present(const QVideoFrame &frame);
|
bool present(const QVideoFrame &frame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Display *display() const;
|
||||||
|
|
||||||
WId m_winId;
|
WId m_winId;
|
||||||
XvPortID m_portId;
|
XvPortID m_portId;
|
||||||
GC m_gc;
|
GC m_gc;
|
||||||
@@ -114,6 +114,4 @@ private:
|
|||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif //QT_NO_XVIDEO
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -50,4 +50,5 @@
|
|||||||
"gstreamer_appsrc" => {},
|
"gstreamer_appsrc" => {},
|
||||||
"pulseaudio" => {},
|
"pulseaudio" => {},
|
||||||
"resourcepolicy" => {},
|
"resourcepolicy" => {},
|
||||||
|
"xvideo" => {},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user