diff --git a/python/pyproject.toml b/python/pyproject.toml new file mode 100644 index 000000000..5f5b2a626 --- /dev/null +++ b/python/pyproject.toml @@ -0,0 +1,36 @@ +# Specify the build system requirements. +[build-system] +requires = ["sip >=5.3, <7", "PyQt-builder >=1.9, <2"] +build-backend = "sipbuild.api" + +# Specify the PEP 566 metadata for the project. +[tool.sip.metadata] +name = "PyQtAV" +version = "1.12.0" +summary = "Python bindings for the QtAV" +home-page = "" +author = "" +author-email = "" +license = "LGPL" + +# Specify a PyQt-based project. +[tool.sip] +project-factory = "pyqtbuild:PyQtProject" + +# Configure the project. +[tool.sip.project] +tag-prefix = "QtAV" +sip-include-dirs = [PYQT_BINDINGS_DIR] + +# Define and configure each set of bindings. +[tool.sip.bindings.QtAV] +qmake-QT = ["widgets"] +include-dirs = [INCLUDE_DIRS] +libraries = [QTAV_LIB] +library-dirs = [LIB_DIRS] + +[tool.sip.bindings.QtAVWidgets] +qmake-QT = ["widgets", "opengl", "openglwidgets"] +include-dirs = [INCLUDE_DIRS] +libraries = [QTAV_LIB, QTAV_WIDGETS_LIB] +library-dirs = [LIB_DIRS] diff --git a/python/sip/QtAV/VideoFormat.sip b/python/sip/QtAV/VideoFormat.sip index 3d2515cd3..394f09e19 100644 --- a/python/sip/QtAV/VideoFormat.sip +++ b/python/sip/QtAV/VideoFormat.sip @@ -104,7 +104,6 @@ public: static QImage::Format imageFormatFromPixelFormat(PixelFormat format); static PixelFormat pixelFormatFromFFmpeg(int ff); //AVPixelFormat static int pixelFormatToFFmpeg(PixelFormat fmt); - static QVector pixelFormatsFFmpeg(); VideoFormat(PixelFormat format = Format_Invalid); VideoFormat(int formatFF /Constrained/); diff --git a/python/sip/QtAVWidgets/GLWidgetRenderer2.sip b/python/sip/QtAVWidgets/GLWidgetRenderer2.sip deleted file mode 100644 index 81bebe5e6..000000000 --- a/python/sip/QtAVWidgets/GLWidgetRenderer2.sip +++ /dev/null @@ -1,64 +0,0 @@ -namespace QtAV -{ - -class GLWidgetRenderer2 : public QGLWidget, public QtAV::OpenGLRendererBase -{ -%TypeHeaderCode -#include -%End - -public: - void setBrightness(qreal brightness); - qreal brightness(); - void setContrast(qreal contrast); - qreal contrast(); - void setHue(qreal hue); - qreal hue(); - void setSaturation(qreal saturation); - qreal saturation(); - void setBackgroundColor(QColor color); - QColor backgroundColor(); - - QRectF regionOfInterest(); - void setRegionOfInterest(QRectF region); - qreal sourceAspectRatio(); - qreal outAspectRatio(); - void setOutAspectRatio(qreal ratio); - OutAspectRatioMode outAspectRatioMode(); - void setOutAspectRatioMode(OutAspectRatioMode mode); - - int orientation(); - void setOrientation(int orientation); - QRect videoRect(); - QSize videoFrameSize(); - -public: - GLWidgetRenderer2(QWidget* parent /TransferThis/ = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0); - virtual VideoRendererId id(); - virtual QWidget* widget(); - -signals: - void sourceAspectRatioChanged(qreal value) final; - void regionOfInterestChanged(); - void outAspectRatioChanged(); - void outAspectRatioModeChanged(); - void brightnessChanged(qreal value); - void contrastChanged(qreal); - void hueChanged(qreal); - void saturationChanged(qreal); - void orientationChanged(); - void videoRectChanged(); - void videoFrameSizeChanged(); - void backgroundColorChanged(); - -protected: - virtual void initializeGL(); - virtual void paintGL(); - virtual void resizeGL(int w, int h); - virtual void resizeEvent(QResizeEvent *); // not virtual in QGLWidget (Qt<5.5) - virtual void showEvent(QShowEvent *); - -}; -typedef GLWidgetRenderer2 VideoRendererGLWidget2; - -}; diff --git a/python/sip/QtAVWidgets/GraphicsItemRenderer.sip b/python/sip/QtAVWidgets/GraphicsItemRenderer.sip index fbc520f52..75348448b 100644 --- a/python/sip/QtAVWidgets/GraphicsItemRenderer.sip +++ b/python/sip/QtAVWidgets/GraphicsItemRenderer.sip @@ -34,7 +34,7 @@ public: public: GraphicsItemRenderer(QGraphicsItem* parent /TransferThis/ = 0); - virtual VideoRendererId id(); + VideoRendererId id(); bool isSupported(VideoFormat::PixelFormat pixfmt); diff --git a/python/sip/QtAVWidgets/OpenGLWidgetRenderer.sip b/python/sip/QtAVWidgets/OpenGLWidgetRenderer.sip index 38844862d..9edb5e8b7 100644 --- a/python/sip/QtAVWidgets/OpenGLWidgetRenderer.sip +++ b/python/sip/QtAVWidgets/OpenGLWidgetRenderer.sip @@ -33,8 +33,8 @@ public: QSize videoFrameSize(); public: - explicit OpenGLWidgetRenderer(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0); - virtual VideoRendererId id(); + explicit OpenGLWidgetRenderer(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = Qt::WindowFlags()); + VideoRendererId id() const; virtual QWidget* widget(); signals: diff --git a/python/sip/QtAVWidgets/QtAVWidgetsmod.sip b/python/sip/QtAVWidgets/QtAVWidgetsmod.sip index 0df00da0c..f42fa3781 100644 --- a/python/sip/QtAVWidgets/QtAVWidgetsmod.sip +++ b/python/sip/QtAVWidgets/QtAVWidgetsmod.sip @@ -3,6 +3,7 @@ %Import QtGui/QtGuimod.sip %Import QtWidgets/QtWidgetsmod.sip %Import QtOpenGL/QtOpenGLmod.sip +%Import QtOpenGLWidgets/QtOpenGLWidgetsmod.sip %Import QtAV/QtAVmod.sip %Timeline {QtAVWidgets_1_11_0 QtAVWidgets_1_12_0} @@ -35,7 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA %Include global.sip %If (FULL_QTWIDGETS_API) -%Include GLWidgetRenderer2.sip %Include GraphicsItemRenderer.sip // NOTE: We don't expose QOpenGLWidget because it is present in Qt >= 5.4.0 %Include OpenGLWidgetRenderer.sip diff --git a/python/sip/QtAVWidgets/WidgetRenderer.sip b/python/sip/QtAVWidgets/WidgetRenderer.sip index 5f2561b93..96740a0f0 100644 --- a/python/sip/QtAVWidgets/WidgetRenderer.sip +++ b/python/sip/QtAVWidgets/WidgetRenderer.sip @@ -23,8 +23,8 @@ public: QSize videoFrameSize(); public: - WidgetRenderer(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0); - virtual VideoRendererId id(); + WidgetRenderer(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = Qt::WindowFlags()); + VideoRendererId id(); virtual QWidget* widget(); signals: diff --git a/src/AVError.cpp b/src/AVError.cpp index 5f7b3fe37..a83d0a6d1 100644 --- a/src/AVError.cpp +++ b/src/AVError.cpp @@ -20,6 +20,7 @@ ******************************************************************************/ #include "QtAV/AVError.h" #include "QtAV/private/AVCompat.h" +#include #ifndef QT_NO_DEBUG_STREAM #include #endif diff --git a/src/codec/video/VideoDecoderDXVA.cpp b/src/codec/video/VideoDecoderDXVA.cpp index 64b12f33d..c8722127a 100644 --- a/src/codec/video/VideoDecoderDXVA.cpp +++ b/src/codec/video/VideoDecoderDXVA.cpp @@ -29,7 +29,6 @@ //#include "QtAV/private/mkid.h" #include "utils/Logger.h" #include "directx/SurfaceInteropD3D9.h" -#include #define DX_LOG_COMPONENT "DXVA2" #include "utils/DirectXHelper.h" @@ -98,7 +97,7 @@ class VideoDecoderDXVAPrivate Q_DECL_FINAL: public VideoDecoderD3DPrivate VideoDecoderD3DPrivate() { // d3d9+gl interop may not work on optimus moble platforms, 0-copy is enabled only for egl interop - if (d3d9::InteropResource::isSupported(d3d9::InteropEGL) && QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + if (d3d9::InteropResource::isSupported(d3d9::InteropEGL)) copy_mode = VideoDecoderFFmpegHW::ZeroCopy; hd3d9_dll = 0; @@ -269,9 +268,9 @@ bool VideoDecoderDXVAPrivate::createDevice() return false; } vendor = QString::fromLatin1(DXHelper::vendorName(d3dai.VendorId)); - description = QString().sprintf("DXVA2 (%.*s, vendor %lu(%s), device %lu, revision %lu)", - sizeof(d3dai.Description), d3dai.Description, - d3dai.VendorId, qPrintable(vendor), d3dai.DeviceId, d3dai.Revision); + description = QString().asprintf("DXVA2 (%.*s, vendor %lu(%s), device %lu, revision %lu)", + sizeof(d3dai.Description), d3dai.Description, + d3dai.VendorId, qPrintable(vendor), d3dai.DeviceId, d3dai.Revision); //if (copy_uswc) // copy_uswc = vendor.toLower() == "intel"; diff --git a/src/cuda/cuda_api.cpp b/src/cuda/cuda_api.cpp index c37d25e2d..32dce6774 100644 --- a/src/cuda/cuda_api.cpp +++ b/src/cuda/cuda_api.cpp @@ -108,7 +108,7 @@ class cuda_api::context { QLibrary cuda_dll; QLibrary cuvid_dll; - typedef struct { + typedef struct cuda_api { typedef CUresult CUDAAPI tcuGetErrorName(CUresult error, const char **pStr); tcuGetErrorName* cuGetErrorName; typedef CUresult CUDAAPI tcuGetErrorString(CUresult error, const char **pStr); diff --git a/src/filter/X11FilterContext.cpp b/src/filter/X11FilterContext.cpp index 849d1fb08..8e3d84d36 100644 --- a/src/filter/X11FilterContext.cpp +++ b/src/filter/X11FilterContext.cpp @@ -182,7 +182,7 @@ void X11FilterContext::drawPlainText(const QPointF &pos, const QString &text) this->plain = true; QFontMetrics fm(font); - text_q = QImage(fm.width(text), fm.height(), QImage::Format_ARGB32); + text_q = QImage(fm.horizontalAdvance(text), fm.height(), QImage::Format_ARGB32); text_q.fill(0); painter->begin(&text_q); painter->translate(0, 0); diff --git a/src/libQtAV.pro b/src/libQtAV.pro index c6cbcc374..eaf2419db 100644 --- a/src/libQtAV.pro +++ b/src/libQtAV.pro @@ -3,7 +3,7 @@ MODULE_INCNAME = QtAV # for mac framework. also used in install_sdk.pro TARGET = QtAV QT += core gui #CONFIG *= ltcg -greaterThan(QT_MAJOR_VERSION, 5): QT += opengl +greaterThan(QT_MAJOR_VERSION, 5): QT += opengl openglwidgets greaterThan(QT_MAJOR_VERSION, 4) { contains(QT_CONFIG, opengl) { CONFIG *= config_opengl diff --git a/src/opengl/gl_api.cpp b/src/opengl/gl_api.cpp index 9caeba8b4..1ddd21f87 100644 --- a/src/opengl/gl_api.cpp +++ b/src/opengl/gl_api.cpp @@ -32,7 +32,8 @@ void* GetProcAddress_Qt(const char *name) void* p = (void*)QOpenGLContext::currentContext()->getProcAddress(QByteArray((const char*)name)); if (!p) { #if defined(Q_OS_WIN) && defined(QT_OPENGL_DYNAMIC) - HMODULE handle = (HMODULE)QOpenGLContext::openGLModuleHandle(); + using namespace QNativeInterface; + HMODULE handle = QWGLContext::openGLModuleHandle(); if (handle) p = (void*)GetProcAddress(handle, name); #endif diff --git a/src/output/OutputSet.h b/src/output/OutputSet.h index b410d6161..0fc614d3d 100644 --- a/src/output/OutputSet.h +++ b/src/output/OutputSet.h @@ -22,6 +22,8 @@ #ifndef QTAV_OUTPUTSET_H #define QTAV_OUTPUTSET_H +#include + #include #include #include diff --git a/src/output/audio/AudioOutputDSound.cpp b/src/output/audio/AudioOutputDSound.cpp index 227fba991..1b7905699 100644 --- a/src/output/audio/AudioOutputDSound.cpp +++ b/src/output/audio/AudioOutputDSound.cpp @@ -193,6 +193,12 @@ bool AudioOutputDSound::close() available = false; destroy(); CloseHandle(notify_event); // FIXME: is it ok if thread is still waiting? + + // Wait for the PositionWatcher thread to stop. + while (watcher.isRunning()) { + watcher.wait(500); + } + return true; } diff --git a/src/output/video/QPainterRenderer.cpp b/src/output/video/QPainterRenderer.cpp index 656a921a7..18f9d405b 100644 --- a/src/output/video/QPainterRenderer.cpp +++ b/src/output/video/QPainterRenderer.cpp @@ -85,8 +85,7 @@ void QPainterRenderer::drawBackground() d.painter->fillRect(QRect(QPoint(), rendererSize()), backgroundColor()); d.painter->restore(); #else - const QVector bg(bgRegion.rects()); - foreach (const QRect& r, bg) { + foreach (const QRect& r, bgRegion) { d.painter->fillRect(r, backgroundColor()); } #endif diff --git a/src/utils/BlockingQueue.h b/src/utils/BlockingQueue.h index f729e8da3..ea906c9df 100644 --- a/src/utils/BlockingQueue.h +++ b/src/utils/BlockingQueue.h @@ -23,6 +23,8 @@ #ifndef QTAV_BLOCKINGQUEUE_H #define QTAV_BLOCKINGQUEUE_H +#include + #include #include #include diff --git a/tools/templates/vo.h b/tools/templates/vo.h index 85d687039..6378f20cd 100644 --- a/tools/templates/vo.h +++ b/tools/templates/vo.h @@ -13,7 +13,7 @@ class Q_AV_EXPORT %CLASS% : public QWidget, public VideoRenderer Q_OBJECT DPTR_DECLARE_PRIVATE(%CLASS%) public: - %CLASS%(QWidget* parent = 0, Qt::WindowFlags f = 0); + %CLASS%(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); virtual ~%CLASS%(); /* WA_PaintOnScreen: To render outside of Qt's paint system, e.g. If you require diff --git a/widgets/Direct2DRenderer.cpp b/widgets/Direct2DRenderer.cpp index 9e63febb4..7841a97a2 100644 --- a/widgets/Direct2DRenderer.cpp +++ b/widgets/Direct2DRenderer.cpp @@ -55,7 +55,7 @@ class Direct2DRenderer : public QWidget, public VideoRenderer Q_OBJECT DPTR_DECLARE_PRIVATE(Direct2DRenderer) public: - Direct2DRenderer(QWidget* parent = 0, Qt::WindowFlags f = 0); + Direct2DRenderer(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); VideoRendererId id() const Q_DECL_OVERRIDE; bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE; diff --git a/widgets/GDIRenderer.cpp b/widgets/GDIRenderer.cpp index af20c869f..c3f9db32e 100644 --- a/widgets/GDIRenderer.cpp +++ b/widgets/GDIRenderer.cpp @@ -41,7 +41,7 @@ class GDIRenderer : public QWidget, public VideoRenderer Q_OBJECT DPTR_DECLARE_PRIVATE(GDIRenderer) public: - GDIRenderer(QWidget* parent = 0, Qt::WindowFlags f = 0); //offscreen? + GDIRenderer(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); //offscreen? VideoRendererId id() const Q_DECL_OVERRIDE; bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE; /* WA_PaintOnScreen: To render outside of Qt's paint system, e.g. If you require @@ -238,8 +238,7 @@ void GDIRenderer::drawBackground() //HDC hdc = d.device_context; Graphics g(d.device_context); SolidBrush brush(Color(bc.alpha(), bc.red(), bc.green(), bc.blue())); //argb - const QVector bg(bgRegion.rects()); - foreach (const QRect& r, bg) { + foreach (const QRect& r, bgRegion) { g.FillRectangle(&brush, r.x(), r.y(), r.width(), r.height()); } } diff --git a/widgets/QtAVWidgets/GLWidgetRenderer.h b/widgets/QtAVWidgets/GLWidgetRenderer.h index 20dcd55a0..a1d11e468 100644 --- a/widgets/QtAVWidgets/GLWidgetRenderer.h +++ b/widgets/QtAVWidgets/GLWidgetRenderer.h @@ -41,7 +41,7 @@ class Q_AVWIDGETS_EXPORT GLWidgetRenderer : public QGLWidget, public VideoRender Q_OBJECT DPTR_DECLARE_PRIVATE(GLWidgetRenderer) public: - GLWidgetRenderer(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0); + GLWidgetRenderer(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags()); virtual VideoRendererId id() const; virtual bool isSupported(VideoFormat::PixelFormat pixfmt) const; virtual QWidget* widget() { return this; } diff --git a/widgets/QtAVWidgets/GLWidgetRenderer2.h b/widgets/QtAVWidgets/GLWidgetRenderer2.h index 037a7cc53..ccda2637f 100644 --- a/widgets/QtAVWidgets/GLWidgetRenderer2.h +++ b/widgets/QtAVWidgets/GLWidgetRenderer2.h @@ -56,7 +56,7 @@ class Q_AVWIDGETS_EXPORT GLWidgetRenderer2 : public QGLWidget, public OpenGLRend Q_PROPERTY(QSize videoFrameSize READ videoFrameSize NOTIFY videoFrameSizeChanged) Q_ENUMS(Quality) public: - GLWidgetRenderer2(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0); + GLWidgetRenderer2(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = Qt::WindowFlags()); virtual VideoRendererId id() const Q_DECL_OVERRIDE; virtual QWidget* widget() Q_DECL_OVERRIDE { return this; } Q_SIGNALS: diff --git a/widgets/QtAVWidgets/OpenGLWidgetRenderer.h b/widgets/QtAVWidgets/OpenGLWidgetRenderer.h index dffc65548..6620762d2 100644 --- a/widgets/QtAVWidgets/OpenGLWidgetRenderer.h +++ b/widgets/QtAVWidgets/OpenGLWidgetRenderer.h @@ -24,7 +24,7 @@ #include #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -#include +#include #else #include #endif //QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) diff --git a/widgets/QtAVWidgets/QOpenGLWidget.h b/widgets/QtAVWidgets/QOpenGLWidget.h index e6364120b..ab16e3c79 100644 --- a/widgets/QtAVWidgets/QOpenGLWidget.h +++ b/widgets/QtAVWidgets/QOpenGLWidget.h @@ -42,7 +42,7 @@ class Q_AVWIDGETS_EXPORT QOpenGLWidget : public QWidget Q_OBJECT Q_DISABLE_COPY(QOpenGLWidget) public: - explicit QOpenGLWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); + explicit QOpenGLWidget(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); virtual ~QOpenGLWidget(); void setFormat(const QSurfaceFormat &format); QSurfaceFormat format() const; diff --git a/widgets/X11Renderer.cpp b/widgets/X11Renderer.cpp index 91c952fb9..6b914fa4b 100644 --- a/widgets/X11Renderer.cpp +++ b/widgets/X11Renderer.cpp @@ -47,7 +47,7 @@ class X11Renderer: public QWidget, public VideoRenderer Q_OBJECT DPTR_DECLARE_PRIVATE(X11Renderer) public: - X11Renderer(QWidget* parent = 0, Qt::WindowFlags f = 0); + X11Renderer(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); VideoRendererId id() const Q_DECL_OVERRIDE; bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE; @@ -441,8 +441,7 @@ void X11Renderer::drawBackground() // TODO: fill once each resize? mpv // TODO: set color //XSetBackground(d.display, d.gc, BlackPixel(d.display, DefaultScreen(d.display))); - const QVector bg(bgRegion.rects()); - foreach (const QRect& r, bg) { + foreach (const QRect& r, bgRegion) { XFillRectangle(d.display, winId(), d.gc, r.x(), r.y(), r.width(), r.height()); } XFlush(d.display); // apply the color diff --git a/widgets/XVRenderer.cpp b/widgets/XVRenderer.cpp index 9ae64eb4e..ef414049a 100644 --- a/widgets/XVRenderer.cpp +++ b/widgets/XVRenderer.cpp @@ -50,7 +50,7 @@ class XVRenderer: public QWidget, public VideoRenderer Q_OBJECT DPTR_DECLARE_PRIVATE(XVRenderer) public: - XVRenderer(QWidget* parent = 0, Qt::WindowFlags f = 0); + XVRenderer(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags()); virtual VideoRendererId id() const Q_DECL_OVERRIDE; virtual bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE; @@ -492,8 +492,7 @@ void XVRenderer::drawBackground() return; DPTR_D(XVRenderer); // TODO: set color - const QVector bg(bgRegion.rects()); - foreach (const QRect& r, bg) { + foreach (const QRect& r, bgRegion) { XFillRectangle(d.display, winId(), d.gc, r.x(), r.y(), r.width(), r.height()); } XFlush(d.display);