diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-03-02 13:11:36 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-03-16 07:41:44 +0000 |
commit | 5671ab651d9c938a0ff2df3a9c0baef9891e7e23 (patch) | |
tree | 4c5c6fde332af93b3d5f5cb4198df1ee0668434a /src | |
parent | e7702afc9dfa6e69b1b05d68a38248ccc6b6dd87 (diff) |
Move HandleType and MapMode from QAbstractVideoBuffer to QVideoFrame
QAbstractVideoBuffer is a class that is only required inside our
implementation, so we can make it private. This change prepares
for it.
Change-Id: I4ba4542c1eab742f2fc93231e2e5063dbc5d5e94
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
49 files changed, 300 insertions, 302 deletions
diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir index d68049f63..e7dcc3dd6 100644 --- a/src/imports/multimedia/qmldir +++ b/src/imports/multimedia/qmldir @@ -4,3 +4,4 @@ classname QMultimediaDeclarativeModule typeinfo plugins.qmltypes typeinfo plugins.qmltypes Video 5.0 Video.qml + diff --git a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp index eeb24a6a2..85b2072dd 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp @@ -87,7 +87,7 @@ void overview_camera_by_position() // -.- class MyVideoSurface : public QAbstractVideoSurface { - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const { Q_UNUSED(handleType); return QList<QVideoFrame::PixelFormat>(); diff --git a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp index 4acbdc842..a4dc3156d 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp @@ -62,7 +62,7 @@ class MediaExample : public QObject { void AudioRecorder(); void EncoderSettings(); void ImageEncoderSettings(); - + private: // Common naming QVideoWidget *videoWidget; @@ -174,7 +174,7 @@ void MediaExample::MediaPlayer() { public: Surface(QObject *p) : QAbstractVideoSurface(p) { } - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const override + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType) const override { // Make sure that the driver supports this pixel format. return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_YUYV; diff --git a/src/multimedia/doc/snippets/multimedia-snippets/video.cpp b/src/multimedia/doc/snippets/multimedia-snippets/video.cpp index 2e290408f..561a852b5 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/video.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/video.cpp @@ -53,7 +53,7 @@ class MyVideoSurface : public QAbstractVideoSurface { QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const + QVideoFrame::HandleType handleType = QVideoFrame::NoHandle) const { Q_UNUSED(handleType); diff --git a/src/multimedia/platform/android/common/qandroidvideooutput.cpp b/src/multimedia/platform/android/common/qandroidvideooutput.cpp index 0fa6cb84a..5db89639f 100644 --- a/src/multimedia/platform/android/common/qandroidvideooutput.cpp +++ b/src/multimedia/platform/android/common/qandroidvideooutput.cpp @@ -41,6 +41,7 @@ #include "androidsurfacetexture_p.h" #include <QAbstractVideoSurface> +#include <QAbstractVideoBuffer> #include <QVideoSurfaceFormat> #include <qevent.h> #include <qcoreapplication.h> @@ -93,8 +94,8 @@ class AndroidTextureVideoBuffer : public QAbstractVideoBuffer { public: AndroidTextureVideoBuffer(QAndroidTextureVideoOutput *output, const QSize &size) - : QAbstractVideoBuffer(GLTextureHandle) - , m_mapMode(NotMapped) + : QAbstractVideoBuffer(QVideoFrame::GLTextureHandle) + , m_mapMode(QVideoFrame::NotMapped) , m_output(output) , m_size(size) , m_textureUpdated(false) @@ -103,12 +104,12 @@ public: virtual ~AndroidTextureVideoBuffer() {} - MapMode mapMode() const override { return m_mapMode; } + QVideoFrame::MapMode mapMode() const override { return m_mapMode; } - MapData map(MapMode mode) override + MapData map(QVideoFrame::MapMode mode) override { MapData mapData; - if (m_mapMode == NotMapped && mode == ReadOnly && updateFrame()) { + if (m_mapMode == QVideoFrame::NotMapped && mode == QVideoFrame::ReadOnly && updateFrame()) { m_mapMode = mode; m_image = m_output->m_fbo->toImage(); @@ -124,7 +125,7 @@ public: void unmap() override { m_image = QImage(); - m_mapMode = NotMapped; + m_mapMode = QVideoFrame::NotMapped; } QVariant handle() const override @@ -160,7 +161,7 @@ private: return (m_textureUpdated = m_output->renderFrameToFbo()); } - MapMode m_mapMode; + QVideoFrame::MapMode m_mapMode; QAndroidTextureVideoOutput *m_output; QImage m_image; QSize m_size; @@ -331,7 +332,7 @@ void QAndroidTextureVideoOutput::onFrameAvailable() if (!m_surface->isActive()) { QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), - QAbstractVideoBuffer::GLTextureHandle); + QVideoFrame::GLTextureHandle); m_surface->start(format); } diff --git a/src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp b/src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp index ab72ad836..20be56916 100644 --- a/src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp +++ b/src/multimedia/platform/android/mediacapture/qandroidcamerasession.cpp @@ -366,10 +366,10 @@ struct NullSurface : QAbstractVideoSurface { NullSurface(QObject *parent = nullptr) : QAbstractVideoSurface(parent) { } QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const override + QVideoFrame::HandleType type = QVideoFrame::NoHandle) const override { QList<QVideoFrame::PixelFormat> result; - if (type == QAbstractVideoBuffer::NoHandle) + if (type == QVideoFrame::NoHandle) result << QVideoFrame::Format_NV21; return result; diff --git a/src/multimedia/platform/android/mediacapture/qandroidcameravideorenderercontrol.cpp b/src/multimedia/platform/android/mediacapture/qandroidcameravideorenderercontrol.cpp index 47fac4e63..ceafd08cd 100644 --- a/src/multimedia/platform/android/mediacapture/qandroidcameravideorenderercontrol.cpp +++ b/src/multimedia/platform/android/mediacapture/qandroidcameravideorenderercontrol.cpp @@ -255,7 +255,7 @@ void QAndroidCameraVideoRendererControl::setSurface(QAbstractVideoSurface *surfa QAndroidVideoOutput *newOutput = 0; if (m_surface) { - if (!m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty()) { + if (!m_surface->supportedPixelFormats(QVideoFrame::GLTextureHandle).isEmpty()) { if (!m_textureOutput) { m_dataOutput = 0; newOutput = m_textureOutput = new QAndroidTextureVideoOutput(this); diff --git a/src/multimedia/platform/darwin/camera/avfcamerarenderercontrol.mm b/src/multimedia/platform/darwin/camera/avfcamerarenderercontrol.mm index 01ad9c30d..528007c9e 100644 --- a/src/multimedia/platform/darwin/camera/avfcamerarenderercontrol.mm +++ b/src/multimedia/platform/darwin/camera/avfcamerarenderercontrol.mm @@ -60,16 +60,16 @@ class CVImageVideoBuffer : public QAbstractVideoBuffer public: CVImageVideoBuffer(CVImageBufferRef buffer, AVFCameraRendererControl *renderer) #ifndef Q_OS_IOS - : QAbstractVideoBuffer(NoHandle) + : QAbstractVideoBuffer(QVideoFrame::NoHandle) #else : QAbstractVideoBuffer(renderer->supportsTextures() && CVPixelBufferGetPixelFormatType(buffer) == kCVPixelFormatType_32BGRA - ? GLTextureHandle : NoHandle) + ? QVideoFrame::GLTextureHandle : QVideoFrame::NoHandle) , m_texture(nullptr) , m_renderer(renderer) #endif , m_buffer(buffer) - , m_mode(NotMapped) + , m_mode(QVideoFrame::NotMapped) { #ifndef Q_OS_IOS Q_UNUSED(renderer); @@ -87,9 +87,9 @@ public: CVPixelBufferRelease(m_buffer); } - MapMode mapMode() const { return m_mode; } + QVideoFrame::MapMode mapMode() const { return m_mode; } - MapData map(QAbstractVideoBuffer::MapMode mode) + MapData map(QVideoFrame::MapMode mode) { MapData mapData; @@ -105,8 +105,8 @@ public: } // For a bi-planar format we have to set the parameters correctly: - if (mode != QAbstractVideoBuffer::NotMapped && m_mode == QAbstractVideoBuffer::NotMapped) { - CVPixelBufferLockBaseAddress(m_buffer, mode == QAbstractVideoBuffer::ReadOnly + if (mode != QVideoFrame::NotMapped && m_mode == QVideoFrame::NotMapped) { + CVPixelBufferLockBaseAddress(m_buffer, mode == QVideoFrame::ReadOnly ? kCVPixelBufferLock_ReadOnly : 0); @@ -125,10 +125,10 @@ public: return mapData; } - uchar *map(MapMode mode, qsizetype *numBytes, int *bytesPerLine) + uchar *map(QVideoFrame::MapMode mode, qsizetype *numBytes, int *bytesPerLine) { - if (mode != NotMapped && m_mode == NotMapped) { - CVPixelBufferLockBaseAddress(m_buffer, mode == QAbstractVideoBuffer::ReadOnly + if (mode != QVideoFrame::NotMapped && m_mode == QVideoFrame::NotMapped) { + CVPixelBufferLockBaseAddress(m_buffer, mode == QVideoFrame::ReadOnly ? kCVPixelBufferLock_ReadOnly : 0); if (numBytes) @@ -146,11 +146,11 @@ public: void unmap() { - if (m_mode != NotMapped) { - CVPixelBufferUnlockBaseAddress(m_buffer, m_mode == QAbstractVideoBuffer::ReadOnly + if (m_mode != QVideoFrame::NotMapped) { + CVPixelBufferUnlockBaseAddress(m_buffer, m_mode == QVideoFrame::ReadOnly ? kCVPixelBufferLock_ReadOnly : 0); - m_mode = NotMapped; + m_mode = QVideoFrame::NotMapped; } } @@ -204,7 +204,7 @@ private: AVFCameraRendererControl *m_renderer; #endif CVImageBufferRef m_buffer; - MapMode m_mode; + QVideoFrame::MapMode m_mode; }; @@ -296,7 +296,7 @@ void AVFCameraRendererControl::setSurface(QAbstractVideoSurface *surface) if (m_surface != surface) { m_surface = surface; m_supportsTextures = m_surface - ? !m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).isEmpty() + ? !m_surface->supportedPixelFormats(QVideoFrame::GLTextureHandle).isEmpty() : false; Q_EMIT surfaceChanged(surface); } diff --git a/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol.mm b/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol.mm index 456ffff71..42dd0ccff 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol.mm +++ b/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol.mm @@ -61,7 +61,7 @@ QT_USE_NAMESPACE class TextureVideoBuffer : public QAbstractVideoBuffer { public: - TextureVideoBuffer(HandleType type, quint64 tex) + TextureVideoBuffer(QVideoFrame::HandleType type, quint64 tex) : QAbstractVideoBuffer(type) , m_texture(tex) {} @@ -70,8 +70,8 @@ public: { } - MapMode mapMode() const override { return NotMapped; } - MapData map(MapMode /*mode*/) override { return {}; } + QVideoFrame::MapMode mapMode() const override { return QVideoFrame::NotMapped; } + MapData map(QVideoFrame::MapMode /*mode*/) override { return {}; } void unmap() override {} QVariant handle() const override @@ -147,8 +147,8 @@ void AVFVideoRendererControl::setSurface(QAbstractVideoSurface *surface) #endif auto checkHandleType = [this] { - m_enableOpenGL = m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle).contains(QVideoFrame::Format_BGR32); - m_enableMetal = m_surface->supportedPixelFormats(QAbstractVideoBuffer::MTLTextureHandle).contains(QVideoFrame::Format_BGR32); + m_enableOpenGL = m_surface->supportedPixelFormats(QVideoFrame::GLTextureHandle).contains(QVideoFrame::Format_BGR32); + m_enableMetal = m_surface->supportedPixelFormats(QVideoFrame::MTLTextureHandle).contains(QVideoFrame::Format_BGR32); }; checkHandleType(); connect(m_surface, &QAbstractVideoSurface::supportedFormatsChanged, this, checkHandleType); @@ -211,13 +211,13 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts) if (tex == 0) return; - auto buffer = new TextureVideoBuffer(QAbstractVideoBuffer::MTLTextureHandle, tex); + auto buffer = new TextureVideoBuffer(QVideoFrame::MTLTextureHandle, tex); QVideoFrame frame(buffer, m_nativeSize, QVideoFrame::Format_BGR32); if (m_surface->isActive() && m_surface->surfaceFormat().pixelFormat() != frame.pixelFormat()) m_surface->stop(); if (!m_surface->isActive()) { - QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QAbstractVideoBuffer::MTLTextureHandle); + QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QVideoFrame::MTLTextureHandle); #if defined(Q_OS_IOS) || defined(Q_OS_TVOS) format.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); #else @@ -239,7 +239,7 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts) if (tex == 0) return; - QAbstractVideoBuffer *buffer = new TextureVideoBuffer(QAbstractVideoBuffer::GLTextureHandle, tex); + QAbstractVideoBuffer *buffer = new TextureVideoBuffer(QVideoFrame::GLTextureHandle, tex); QVideoFrame frame = QVideoFrame(buffer, m_nativeSize, QVideoFrame::Format_BGR32); if (m_surface && frame.isValid()) { @@ -247,7 +247,7 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts) m_surface->stop(); if (!m_surface->isActive()) { - QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QAbstractVideoBuffer::GLTextureHandle); + QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QVideoFrame::GLTextureHandle); #if defined(Q_OS_IOS) || defined(Q_OS_TVOS) format.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); #else @@ -277,7 +277,7 @@ void AVFVideoRendererControl::updateVideoFrame(const CVTimeStamp &ts) m_surface->stop(); if (!m_surface->isActive()) { - QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QAbstractVideoBuffer::NoHandle); + QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), QVideoFrame::NoHandle); if (!m_surface->start(format)) { qWarning("Failed to activate video surface"); diff --git a/src/multimedia/platform/gstreamer/common/qgstutils.cpp b/src/multimedia/platform/gstreamer/common/qgstutils.cpp index ba61be3d2..1fed48717 100644 --- a/src/multimedia/platform/gstreamer/common/qgstutils.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstutils.cpp @@ -345,7 +345,7 @@ static int indexOfVideoFormat(GstVideoFormat format) } QVideoSurfaceFormat QGstUtils::formatForCaps( - GstCaps *caps, GstVideoInfo *info, QAbstractVideoBuffer::HandleType handleType) + GstCaps *caps, GstVideoInfo *info, QVideoFrame::HandleType handleType) { GstVideoInfo vidInfo; GstVideoInfo *infoPtr = info ? info : &vidInfo; diff --git a/src/multimedia/platform/gstreamer/common/qgstutils_p.h b/src/multimedia/platform/gstreamer/common/qgstutils_p.h index 6d7f83f5e..e2b4ff90e 100644 --- a/src/multimedia/platform/gstreamer/common/qgstutils_p.h +++ b/src/multimedia/platform/gstreamer/common/qgstutils_p.h @@ -83,7 +83,7 @@ namespace QGstUtils { Q_MULTIMEDIA_EXPORT QVideoSurfaceFormat formatForCaps( GstCaps *caps, GstVideoInfo *info = 0, - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle); + QVideoFrame::HandleType handleType = QVideoFrame::NoHandle); Q_MULTIMEDIA_EXPORT GstCaps *capsForFormats(const QList<QVideoFrame::PixelFormat> &formats); void setFrameTimeStamps(QVideoFrame *frame, GstBuffer *buffer); diff --git a/src/multimedia/platform/gstreamer/common/qgstvideobuffer.cpp b/src/multimedia/platform/gstreamer/common/qgstvideobuffer.cpp index 58738ffa0..711472f29 100644 --- a/src/multimedia/platform/gstreamer/common/qgstvideobuffer.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstvideobuffer.cpp @@ -42,7 +42,7 @@ QT_BEGIN_NAMESPACE QGstVideoBuffer::QGstVideoBuffer(GstBuffer *buffer, const GstVideoInfo &info) - : QAbstractVideoBuffer(NoHandle) + : QAbstractVideoBuffer(QVideoFrame::NoHandle) , m_videoInfo(info) , m_buffer(buffer) { @@ -50,7 +50,7 @@ QGstVideoBuffer::QGstVideoBuffer(GstBuffer *buffer, const GstVideoInfo &info) } QGstVideoBuffer::QGstVideoBuffer(GstBuffer *buffer, const GstVideoInfo &info, - QGstVideoBuffer::HandleType handleType, + QVideoFrame::HandleType handleType, const QVariant &handle) : QAbstractVideoBuffer(handleType) , m_videoInfo(info) @@ -68,18 +68,18 @@ QGstVideoBuffer::~QGstVideoBuffer() } -QAbstractVideoBuffer::MapMode QGstVideoBuffer::mapMode() const +QVideoFrame::MapMode QGstVideoBuffer::mapMode() const { return m_mode; } -QAbstractVideoBuffer::MapData QGstVideoBuffer::map(MapMode mode) +QAbstractVideoBuffer::MapData QGstVideoBuffer::map(QVideoFrame::MapMode mode) { - const GstMapFlags flags = GstMapFlags(((mode & ReadOnly) ? GST_MAP_READ : 0) - | ((mode & WriteOnly) ? GST_MAP_WRITE : 0)); + const GstMapFlags flags = GstMapFlags(((mode & QVideoFrame::ReadOnly) ? GST_MAP_READ : 0) + | ((mode & QVideoFrame::WriteOnly) ? GST_MAP_WRITE : 0)); MapData mapData; - if (mode == NotMapped || m_mode != NotMapped) + if (mode == QVideoFrame::NotMapped || m_mode != QVideoFrame::NotMapped) return mapData; if (m_videoInfo.finfo->n_planes == 0) { // Encoded @@ -107,13 +107,13 @@ QAbstractVideoBuffer::MapData QGstVideoBuffer::map(MapMode mode) void QGstVideoBuffer::unmap() { - if (m_mode != NotMapped) { + if (m_mode != QVideoFrame::NotMapped) { if (m_videoInfo.finfo->n_planes == 0) gst_buffer_unmap(m_buffer, &m_frame.map[0]); else gst_video_frame_unmap(&m_frame); } - m_mode = NotMapped; + m_mode = QVideoFrame::NotMapped; } QT_END_NAMESPACE diff --git a/src/multimedia/platform/gstreamer/common/qgstvideobuffer_p.h b/src/multimedia/platform/gstreamer/common/qgstvideobuffer_p.h index 11a217f51..0efa0ae48 100644 --- a/src/multimedia/platform/gstreamer/common/qgstvideobuffer_p.h +++ b/src/multimedia/platform/gstreamer/common/qgstvideobuffer_p.h @@ -65,14 +65,14 @@ class Q_MULTIMEDIA_EXPORT QGstVideoBuffer : public QAbstractVideoBuffer public: QGstVideoBuffer(GstBuffer *buffer, const GstVideoInfo &info); QGstVideoBuffer(GstBuffer *buffer, const GstVideoInfo &info, - HandleType handleType, const QVariant &handle); + QVideoFrame::HandleType handleType, const QVariant &handle); ~QGstVideoBuffer(); GstBuffer *buffer() const { return m_buffer; } - MapMode mapMode() const override; + QVideoFrame::MapMode mapMode() const override; - MapData map(MapMode mode) override; + MapData map(QVideoFrame::MapMode mode) override; void unmap() override; QVariant handle() const override { return m_handle; } @@ -80,7 +80,7 @@ private: GstVideoInfo m_videoInfo; GstVideoFrame m_frame; GstBuffer *m_buffer = nullptr; - MapMode m_mode = NotMapped; + QVideoFrame::MapMode m_mode = QVideoFrame::NotMapped; QVariant m_handle; }; diff --git a/src/multimedia/platform/gstreamer/common/qgstvideorendererplugin_p.h b/src/multimedia/platform/gstreamer/common/qgstvideorendererplugin_p.h index d6f13062e..97420842f 100644 --- a/src/multimedia/platform/gstreamer/common/qgstvideorendererplugin_p.h +++ b/src/multimedia/platform/gstreamer/common/qgstvideorendererplugin_p.h @@ -52,7 +52,6 @@ // #include <private/qtmultimediaglobal_p.h> -#include <qabstractvideobuffer.h> #include <qvideosurfaceformat.h> #include <QtCore/qobject.h> #include <QtCore/qplugin.h> @@ -63,10 +62,6 @@ QT_BEGIN_NAMESPACE class QAbstractVideoSurface; -#ifndef Q_MULTIMEDIA_EXPORT -#error XXX -#endif - class Q_MULTIMEDIA_EXPORT QGstVideoRenderer { public: diff --git a/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp b/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp index 9afd79a80..9751652c9 100644 --- a/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp @@ -85,14 +85,14 @@ GstCaps *QGstDefaultVideoRenderer::getCaps(QAbstractVideoSurface *surface) { #if QT_CONFIG(gstreamer_gl) if (QGstUtils::useOpenGL()) { - m_handleType = QAbstractVideoBuffer::GLTextureHandle; + m_handleType = QVideoFrame::GLTextureHandle; auto formats = surface->supportedPixelFormats(m_handleType); // Even if the surface does not support gl textures, // glupload will be added to the pipeline and GLMemory will be requested. // This will lead to upload data to gl textures // and download it when the buffer will be used within rendering. if (formats.isEmpty()) { - m_handleType = QAbstractVideoBuffer::NoHandle; + m_handleType = QVideoFrame::NoHandle; formats = surface->supportedPixelFormats(m_handleType); } @@ -103,7 +103,7 @@ GstCaps *QGstDefaultVideoRenderer::getCaps(QAbstractVideoSurface *surface) return caps; } #endif - return QGstUtils::capsForFormats(surface->supportedPixelFormats(QAbstractVideoBuffer::NoHandle)); + return QGstUtils::capsForFormats(surface->supportedPixelFormats(QVideoFrame::NoHandle)); } bool QGstDefaultVideoRenderer::start(QAbstractVideoSurface *surface, GstCaps *caps) @@ -127,7 +127,7 @@ bool QGstDefaultVideoRenderer::present(QAbstractVideoSurface *surface, GstBuffer QGstVideoBuffer *videoBuffer = nullptr; #if QT_CONFIG(gstreamer_gl) - if (m_format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { + if (m_format.handleType() == QVideoFrame::GLTextureHandle) { GstGLMemory *glmem = GST_GL_MEMORY_CAST(gst_buffer_peek_memory(buffer, 0)); guint textureId = gst_gl_memory_get_texture_id(glmem); videoBuffer = new QGstVideoBuffer(buffer, m_videoInfo, m_format.handleType(), textureId); @@ -652,7 +652,7 @@ struct NullSurface : QAbstractVideoSurface { NullSurface(QObject *parent = nullptr) : QAbstractVideoSurface(parent) { } - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType) const override + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType) const override { return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB32; } diff --git a/src/multimedia/platform/gstreamer/common/qgstvideorenderersink_p.h b/src/multimedia/platform/gstreamer/common/qgstvideorenderersink_p.h index 0b05bbe83..f330e871f 100644 --- a/src/multimedia/platform/gstreamer/common/qgstvideorenderersink_p.h +++ b/src/multimedia/platform/gstreamer/common/qgstvideorenderersink_p.h @@ -97,7 +97,7 @@ private: QVideoSurfaceFormat m_format; GstVideoInfo m_videoInfo; bool m_flushed = true; - QAbstractVideoBuffer::HandleType m_handleType = QAbstractVideoBuffer::NoHandle; + QVideoFrame::HandleType m_handleType = QVideoFrame::NoHandle; }; class QVideoSurfaceGstDelegate : public QObject diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol.cpp b/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol.cpp index d682c40a3..b44fbe64e 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol.cpp +++ b/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol.cpp @@ -146,13 +146,13 @@ class QnxTextureBuffer : public QAbstractVideoBuffer { public: QnxTextureBuffer(WindowGrabber *windowGrabber) : - QAbstractVideoBuffer(QAbstractVideoBuffer::GLTextureHandle) + QAbstractVideoBuffer(QVideoFrame::GLTextureHandle) { m_windowGrabber = windowGrabber; m_handle = 0; } MapMode mapMode() const { - return QAbstractVideoBuffer::ReadWrite; + return QVideoFrame::ReadWrite; } void unmap() {} MapData map(MapMode mode) override { return {}; } @@ -173,7 +173,7 @@ void MmRendererPlayerVideoRendererControl::updateScene(const QSize &size) if (!m_surface->isActive()) { if (m_windowGrabber->eglImageSupported()) { m_surface->start(QVideoSurfaceFormat(size, QVideoFrame::Format_BGR32, - QAbstractVideoBuffer::GLTextureHandle)); + QVideoFrame::GLTextureHandle)); } else { m_surface->start(QVideoSurfaceFormat(size, QVideoFrame::Format_ARGB32)); } @@ -182,7 +182,7 @@ void MmRendererPlayerVideoRendererControl::updateScene(const QSize &size) m_surface->stop(); if (m_windowGrabber->eglImageSupported()) { m_surface->start(QVideoSurfaceFormat(size, QVideoFrame::Format_BGR32, - QAbstractVideoBuffer::GLTextureHandle)); + QVideoFrame::GLTextureHandle)); } else { m_surface->start(QVideoSurfaceFormat(size, QVideoFrame::Format_ARGB32)); } diff --git a/src/multimedia/platform/windows/evr/evrcustompresenter.cpp b/src/multimedia/platform/windows/evr/evrcustompresenter.cpp index dd6c0021b..ed398675e 100644 --- a/src/multimedia/platform/windows/evr/evrcustompresenter.cpp +++ b/src/multimedia/platform/windows/evr/evrcustompresenter.cpp @@ -1026,12 +1026,12 @@ void EVRCustomPresenter::supportedFormatsChanged() // check if we can render to the surface (compatible formats) if (m_surface) { - QList<QVideoFrame::PixelFormat> formats = m_surface->supportedPixelFormats(QAbstractVideoBuffer::GLTextureHandle); + QList<QVideoFrame::PixelFormat> formats = m_surface->supportedPixelFormats(QVideoFrame::GLTextureHandle); if (m_presentEngine->supportsTextureRendering() && formats.contains(QVideoFrame::Format_RGB32)) { m_presentEngine->setHint(D3DPresentEngine::RenderToTexture, true); m_canRenderToSurface = true; } else { - formats = m_surface->supportedPixelFormats(QAbstractVideoBuffer::NoHandle); + formats = m_surface->supportedPixelFormats(QVideoFrame::NoHandle); for (QVideoFrame::PixelFormat format : qAsConst(formats)) { if (SUCCEEDED(m_presentEngine->checkFormat(qt_evr_D3DFormatFromPixelFormat(format)))) { m_canRenderToSurface = true; diff --git a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp index 8cb6d2593..9d32ce4f0 100644 --- a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp +++ b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp @@ -55,12 +55,12 @@ QT_BEGIN_NAMESPACE class IMFSampleVideoBuffer: public QAbstractVideoBuffer { public: - IMFSampleVideoBuffer(D3DPresentEngine *engine, IMFSample *sample, QAbstractVideoBuffer::HandleType handleType) + IMFSampleVideoBuffer(D3DPresentEngine *engine, IMFSample *sample, QVideoFrame::HandleType handleType) : QAbstractVideoBuffer(handleType) , m_engine(engine) , m_sample(sample) , m_surface(0) - , m_mapMode(NotMapped) + , m_mapMode(QVideoFrame::NotMapped) { if (m_sample) { m_sample->AddRef(); @@ -79,7 +79,7 @@ public: ~IMFSampleVideoBuffer() override { if (m_surface) { - if (m_mapMode != NotMapped) + if (m_mapMode != QVideoFrame::NotMapped) m_surface->UnlockRect(); m_surface->Release(); } @@ -89,21 +89,21 @@ public: QVariant handle() const override; - MapMode mapMode() const override { return m_mapMode; } - MapData map(MapMode mode) override; + QVideoFrame::MapMode mapMode() const override { return m_mapMode; } + MapData map(QVideoFrame::MapMode mode) override; void unmap() override; private: mutable D3DPresentEngine *m_engine; IMFSample *m_sample; IDirect3DSurface9 *m_surface; - MapMode m_mapMode; + QVideoFrame::MapMode m_mapMode; mutable unsigned int m_textureId = 0; }; -IMFSampleVideoBuffer::MapData IMFSampleVideoBuffer::map(MapMode mode) +IMFSampleVideoBuffer::MapData IMFSampleVideoBuffer::map(QVideoFrame::MapMode mode) { - if (!m_surface || m_mapMode != NotMapped) + if (!m_surface || m_mapMode != QVideoFrame::NotMapped) return {}; D3DSURFACE_DESC desc; @@ -111,7 +111,7 @@ IMFSampleVideoBuffer::MapData IMFSampleVideoBuffer::map(MapMode mode) return {}; D3DLOCKED_RECT rect; - if (FAILED(m_surface->LockRect(&rect, NULL, mode == ReadOnly ? D3DLOCK_READONLY : 0))) + if (FAILED(m_surface->LockRect(&rect, NULL, mode == QVideoFrame::ReadOnly ? D3DLOCK_READONLY : 0))) return {}; m_mapMode = mode; @@ -126,10 +126,10 @@ IMFSampleVideoBuffer::MapData IMFSampleVideoBuffer::map(MapMode mode) void IMFSampleVideoBuffer::unmap() { - if (m_mapMode == NotMapped) + if (m_mapMode == QVideoFrame::NotMapped) return; - m_mapMode = NotMapped; + m_mapMode = QVideoFrame::NotMapped; m_surface->UnlockRect(); } @@ -371,8 +371,8 @@ done: m_surfaceFormat = QVideoSurfaceFormat(QSize(width, height), m_useTextureRendering ? QVideoFrame::Format_RGB32 : qt_evr_pixelFormatFromD3DFormat(d3dFormat), - m_useTextureRendering ? QAbstractVideoBuffer::GLTextureHandle - : QAbstractVideoBuffer::NoHandle); + m_useTextureRendering ? QVideoFrame::GLTextureHandle + : QVideoFrame::NoHandle); UINT32 horizontal = 1, vertical = 1; hr = MFGetAttributeRatio(format, MF_MT_PIXEL_ASPECT_RATIO, &horizontal, &vertical); if (SUCCEEDED(hr)) diff --git a/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp b/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp index 7c973f214..1957bf072 100644 --- a/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp +++ b/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp @@ -44,6 +44,7 @@ #include <qabstractvideosurface.h> #include <qvideosurfaceformat.h> +#include <qabstractvideobuffer.h> #include <qtcore/qtimer.h> #include <qtcore/qmutex.h> #include <qtcore/qcoreevent.h> @@ -61,10 +62,10 @@ namespace { public: MediaSampleVideoBuffer(IMFMediaBuffer *buffer, int bytesPerLine) - : QAbstractVideoBuffer(NoHandle) + : QAbstractVideoBuffer(QVideoFrame::NoHandle) , m_buffer(buffer) , m_bytesPerLine(bytesPerLine) - , m_mapMode(NotMapped) + , m_mapMode(QVideoFrame::NotMapped) { buffer->AddRef(); } @@ -74,10 +75,10 @@ namespace m_buffer->Release(); } - MapData map(MapMode mode) override + MapData map(QVideoFrame::MapMode mode) override { MapData mapData; - if (m_mapMode == NotMapped && mode != NotMapped) { + if (m_mapMode == QVideoFrame::NotMapped && mode != QVideoFrame::NotMapped) { BYTE *bytes; DWORD length; HRESULT hr = m_buffer->Lock(&bytes, NULL, &length); @@ -96,13 +97,13 @@ namespace void unmap() override { - if (m_mapMode == NotMapped) + if (m_mapMode == QVideoFrame::NotMapped) return; - m_mapMode = NotMapped; + m_mapMode = QVideoFrame::NotMapped; m_buffer->Unlock(); } - MapMode mapMode() const override + QVideoFrame::MapMode mapMode() const override { return m_mapMode; } @@ -110,7 +111,7 @@ namespace private: IMFMediaBuffer *m_buffer; int m_bytesPerLine; - MapMode m_mapMode; + QVideoFrame::MapMode m_mapMode; }; // Custom interface for handling IMFStreamSink::PlaceMarker calls asynchronously. diff --git a/src/multimedia/video/qabstractvideobuffer.cpp b/src/multimedia/video/qabstractvideobuffer.cpp index a79bae86a..6fe351e8d 100644 --- a/src/multimedia/video/qabstractvideobuffer.cpp +++ b/src/multimedia/video/qabstractvideobuffer.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE */ /*! - \enum QAbstractVideoBuffer::HandleType + \enum QVideoFrame::HandleType Identifies the type of a video buffers handle. @@ -90,7 +90,7 @@ QT_BEGIN_NAMESPACE */ /*! - \enum QAbstractVideoBuffer::MapMode + \enum QVideoFrame::MapMode Enumerates how a video buffer's data is mapped to system memory. @@ -108,7 +108,7 @@ QT_BEGIN_NAMESPACE /*! Constructs an abstract video buffer of the given \a type. */ -QAbstractVideoBuffer::QAbstractVideoBuffer(HandleType type) +QAbstractVideoBuffer::QAbstractVideoBuffer(QVideoFrame::HandleType type) : m_type(type) { } @@ -116,7 +116,7 @@ QAbstractVideoBuffer::QAbstractVideoBuffer(HandleType type) /*! \internal */ -QAbstractVideoBuffer::QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type) +QAbstractVideoBuffer::QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, QVideoFrame::HandleType type) : d_ptr(&dd) , m_type(type) { @@ -149,13 +149,13 @@ void QAbstractVideoBuffer::release() \sa handle() */ -QAbstractVideoBuffer::HandleType QAbstractVideoBuffer::handleType() const +QVideoFrame::HandleType QAbstractVideoBuffer::handleType() const { return m_type; } /*! - \fn QAbstractVideoBuffer::mapMode() const + \fn QVideoFrame::mapMode() const Returns the mode a video buffer is mapped in. @@ -167,9 +167,9 @@ QAbstractVideoBuffer::HandleType QAbstractVideoBuffer::handleType() const Independently maps the planes of a video buffer to memory. The map \a mode indicates whether the contents of the mapped memory should be read from and/or - written to the buffer. If the map mode includes the \c QAbstractVideoBuffer::ReadOnly flag the + written to the buffer. If the map mode includes the \c QVideoFrame::ReadOnly flag the mapped memory will be populated with the content of the buffer when initially mapped. If the map - mode includes the \c QAbstractVideoBuffer::WriteOnly flag the content of the possibly modified + mode includes the \c QVideoFrame::WriteOnly flag the content of the possibly modified mapped memory will be written back to the buffer when unmapped. When access to the data is no longer needed be sure to call the unmap() function to release the @@ -195,7 +195,7 @@ QAbstractVideoBuffer::HandleType QAbstractVideoBuffer::handleType() const Releases the memory mapped by the map() function. - If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the \c QAbstractVideoBuffer::WriteOnly + If the \l {QVideoFrame::MapMode}{MapMode} included the \c QVideoFrame::WriteOnly flag this will write the current content of the mapped memory back to the video frame. \sa map() @@ -219,9 +219,9 @@ QVariant QAbstractVideoBuffer::handle() const Maps the contents of a video buffer to memory. The map \a mode indicates whether the contents of the mapped memory should be read from and/or - written to the buffer. If the map mode includes the \c QAbstractVideoBuffer::ReadOnly flag the + written to the buffer. If the map mode includes the \c QVideoFrame::ReadOnly flag the mapped memory will be populated with the content of the buffer when initially mapped. If the map - mode includes the \c QAbstractVideoBuffer::WriteOnly flag the content of the possibly modified + mode includes the \c QVideoFrame::WriteOnly flag the content of the possibly modified mapped memory will be written back to the buffer when unmapped. When access to the data is no longer needed be sure to call the unmap() function to release the @@ -231,42 +231,20 @@ QVariant QAbstractVideoBuffer::handle() const plane will be returned in \a bytesPerLine, and a pointer to the plane data will be returned in \a data. The accumulative size of the mapped data is returned in \a numBytes. - \sa QAbstractVideoBuffer::map(), QAbstractVideoBuffer::unmap(), QAbstractVideoBuffer::mapMode() + \sa QAbstractVideoBuffer::map(), QAbstractVideoBuffer::unmap(), QVideoFrame::mapMode() */ #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, QAbstractVideoBuffer::HandleType type) -{ - QDebugStateSaver saver(dbg); - dbg.nospace(); - switch (type) { - case QAbstractVideoBuffer::NoHandle: - return dbg << "NoHandle"; - case QAbstractVideoBuffer::GLTextureHandle: - return dbg << "GLTextureHandle"; - case QAbstractVideoBuffer::MTLTextureHandle: - return dbg << "MTLTextureHandle"; - case QAbstractVideoBuffer::XvShmImageHandle: - return dbg << "XvShmImageHandle"; - case QAbstractVideoBuffer::CoreImageHandle: - return dbg << "CoreImageHandle"; - case QAbstractVideoBuffer::QPixmapHandle: - return dbg << "QPixmapHandle"; - default: - return dbg << "UserHandle(" << int(type) << ')'; - } -} - -QDebug operator<<(QDebug dbg, QAbstractVideoBuffer::MapMode mode) +QDebug operator<<(QDebug dbg, QVideoFrame::MapMode mode) { QDebugStateSaver saver(dbg); dbg.nospace(); switch (mode) { - case QAbstractVideoBuffer::ReadOnly: + case QVideoFrame::ReadOnly: return dbg << "ReadOnly"; - case QAbstractVideoBuffer::ReadWrite: + case QVideoFrame::ReadWrite: return dbg << "ReadWrite"; - case QAbstractVideoBuffer::WriteOnly: + case QVideoFrame::WriteOnly: return dbg << "WriteOnly"; default: return dbg << "NotMapped"; diff --git a/src/multimedia/video/qabstractvideobuffer.h b/src/multimedia/video/qabstractvideobuffer.h index d25a06bbf..d8ce72431 100644 --- a/src/multimedia/video/qabstractvideobuffer.h +++ b/src/multimedia/video/qabstractvideobuffer.h @@ -42,7 +42,7 @@ #include <QtMultimedia/qtmultimediaglobal.h> #include <QtMultimedia/qmultimedia.h> - +#include <QtMultimedia/qvideoframe.h> #include <QtCore/qmetatype.h> @@ -56,31 +56,11 @@ class QAbstractVideoBufferPrivate; class Q_MULTIMEDIA_EXPORT QAbstractVideoBuffer { public: - enum HandleType - { - NoHandle, - GLTextureHandle, - MTLTextureHandle, - XvShmImageHandle, - CoreImageHandle, - QPixmapHandle, - EGLImageHandle, - UserHandle = 1000 - }; - - enum MapMode - { - NotMapped = 0x00, - ReadOnly = 0x01, - WriteOnly = 0x02, - ReadWrite = ReadOnly | WriteOnly - }; - - QAbstractVideoBuffer(HandleType type); + QAbstractVideoBuffer(QVideoFrame::HandleType type); virtual ~QAbstractVideoBuffer(); virtual void release(); - HandleType handleType() const; + QVideoFrame::HandleType handleType() const; struct MapData { @@ -90,25 +70,24 @@ public: uchar *data[4] = {}; }; - virtual MapMode mapMode() const = 0; - virtual MapData map(MapMode mode) = 0; + virtual QVideoFrame::MapMode mapMode() const = 0; + virtual MapData map(QVideoFrame::MapMode mode) = 0; virtual void unmap() = 0; virtual QVariant handle() const; protected: - QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, HandleType type); + QAbstractVideoBuffer(QAbstractVideoBufferPrivate &dd, QVideoFrame::HandleType type); QAbstractVideoBufferPrivate *d_ptr = nullptr; // currently unused - HandleType m_type; + QVideoFrame::HandleType m_type; private: Q_DISABLE_COPY(QAbstractVideoBuffer) }; #ifndef QT_NO_DEBUG_STREAM -Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QAbstractVideoBuffer::HandleType); -Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QAbstractVideoBuffer::MapMode); +Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::MapMode); #endif QT_END_NAMESPACE diff --git a/src/multimedia/video/qabstractvideosurface.cpp b/src/multimedia/video/qabstractvideosurface.cpp index aa8dcbd0d..46d5933f4 100644 --- a/src/multimedia/video/qabstractvideosurface.cpp +++ b/src/multimedia/video/qabstractvideosurface.cpp @@ -130,11 +130,11 @@ QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent) QAbstractVideoSurface::~QAbstractVideoSurface() = default; /*! - \fn QAbstractVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const + \fn QAbstractVideoSurface::supportedPixelFormats(QVideoFrame::HandleType type) const Returns a list of pixel formats a video surface can present for a given handle \a type. - The pixel formats returned for the QAbstractVideoBuffer::NoHandle type are valid for any buffer + The pixel formats returned for the QVideoFrame::NoHandle type are valid for any buffer that can be mapped in read-only mode. Types that are first in the list can be assumed to be faster to render. diff --git a/src/multimedia/video/qabstractvideosurface.h b/src/multimedia/video/qabstractvideosurface.h index e0a42c89b..0acd18cd3 100644 --- a/src/multimedia/video/qabstractvideosurface.h +++ b/src/multimedia/video/qabstractvideosurface.h @@ -68,7 +68,7 @@ public: ~QAbstractVideoSurface(); virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle) const = 0; + QVideoFrame::HandleType type = QVideoFrame::NoHandle) const = 0; virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const; virtual QVideoSurfaceFormat nearestFormat(const QVideoSurfaceFormat &format) const; diff --git a/src/multimedia/video/qimagevideobuffer.cpp b/src/multimedia/video/qimagevideobuffer.cpp index 272c31ff6..d6c854f45 100644 --- a/src/multimedia/video/qimagevideobuffer.cpp +++ b/src/multimedia/video/qimagevideobuffer.cpp @@ -55,12 +55,12 @@ QT_BEGIN_NAMESPACE class QImageVideoBufferPrivate : public QAbstractVideoBufferPrivate { public: - QAbstractVideoBuffer::MapMode mapMode = QAbstractVideoBuffer::NotMapped; + QVideoFrame::MapMode mapMode = QVideoFrame::NotMapped; QImage image; }; QImageVideoBuffer::QImageVideoBuffer(const QImage &image) - : QAbstractVideoBuffer(*new QImageVideoBufferPrivate, NoHandle) + : QAbstractVideoBuffer(*new QImageVideoBufferPrivate, QVideoFrame::NoHandle) { Q_D(QImageVideoBuffer); @@ -69,17 +69,17 @@ QImageVideoBuffer::QImageVideoBuffer(const QImage &image) QImageVideoBuffer::~QImageVideoBuffer() = default; -QAbstractVideoBuffer::MapMode QImageVideoBuffer::mapMode() const +QVideoFrame::MapMode QImageVideoBuffer::mapMode() const { return d_func()->mapMode; } -QImageVideoBuffer::MapData QImageVideoBuffer::map(MapMode mode) +QImageVideoBuffer::MapData QImageVideoBuffer::map(QVideoFrame::MapMode mode) { Q_D(QImageVideoBuffer); MapData mapData; - if (d->mapMode == NotMapped && d->image.bits() && mode != NotMapped) { + if (d->mapMode == QVideoFrame::NotMapped && d->image.bits() && mode != QVideoFrame::NotMapped) { d->mapMode = mode; mapData.nBytes = int(d->image.sizeInBytes()); @@ -95,7 +95,7 @@ void QImageVideoBuffer::unmap() { Q_D(QImageVideoBuffer); - d->mapMode = NotMapped; + d->mapMode = QVideoFrame::NotMapped; } QT_END_NAMESPACE diff --git a/src/multimedia/video/qimagevideobuffer_p.h b/src/multimedia/video/qimagevideobuffer_p.h index ba980a3fb..437d8356b 100644 --- a/src/multimedia/video/qimagevideobuffer_p.h +++ b/src/multimedia/video/qimagevideobuffer_p.h @@ -67,9 +67,9 @@ public: QImageVideoBuffer(const QImage &image); ~QImageVideoBuffer(); - MapMode mapMode() const override; + QVideoFrame::MapMode mapMode() const override; - MapData map(MapMode mode) override; + MapData map(QVideoFrame::MapMode mode) override; void unmap() override; }; diff --git a/src/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/video/qmemoryvideobuffer.cpp index 5b04ff51c..8ad0fd119 100644 --- a/src/multimedia/video/qmemoryvideobuffer.cpp +++ b/src/multimedia/video/qmemoryvideobuffer.cpp @@ -48,7 +48,7 @@ class QMemoryVideoBufferPrivate : public QAbstractVideoBufferPrivate { public: int bytesPerLine = 0; - QAbstractVideoBuffer::MapMode mapMode = QAbstractVideoBuffer::NotMapped; + QVideoFrame::MapMode mapMode = QVideoFrame::NotMapped; QByteArray data; }; @@ -65,7 +65,7 @@ public: Constructs a video buffer with an image stride of \a bytesPerLine from a byte \a array. */ QMemoryVideoBuffer::QMemoryVideoBuffer(const QByteArray &array, int bytesPerLine) - : QAbstractVideoBuffer(*new QMemoryVideoBufferPrivate, NoHandle) + : QAbstractVideoBuffer(*new QMemoryVideoBufferPrivate, QVideoFrame::NoHandle) { Q_D(QMemoryVideoBuffer); @@ -81,7 +81,7 @@ QMemoryVideoBuffer::~QMemoryVideoBuffer() = default; /*! \reimp */ -QAbstractVideoBuffer::MapMode QMemoryVideoBuffer::mapMode() const +QVideoFrame::MapMode QMemoryVideoBuffer::mapMode() const { return d_func()->mapMode; } @@ -89,12 +89,12 @@ QAbstractVideoBuffer::MapMode QMemoryVideoBuffer::mapMode() const /*! \reimp */ -QAbstractVideoBuffer::MapData QMemoryVideoBuffer::map(MapMode mode) +QAbstractVideoBuffer::MapData QMemoryVideoBuffer::map(QVideoFrame::MapMode mode) { Q_D(QMemoryVideoBuffer); MapData mapData; - if (d->mapMode == NotMapped && d->data.size() && mode != NotMapped) { + if (d->mapMode == QVideoFrame::NotMapped && d->data.size() && mode != QVideoFrame::NotMapped) { d->mapMode = mode; mapData.nBytes = d->data.size(); @@ -111,7 +111,7 @@ QAbstractVideoBuffer::MapData QMemoryVideoBuffer::map(MapMode mode) */ void QMemoryVideoBuffer::unmap() { - d_func()->mapMode = NotMapped; + d_func()->mapMode = QVideoFrame::NotMapped; } QT_END_NAMESPACE diff --git a/src/multimedia/video/qmemoryvideobuffer_p.h b/src/multimedia/video/qmemoryvideobuffer_p.h index 5251b4979..5f5af9782 100644 --- a/src/multimedia/video/qmemoryvideobuffer_p.h +++ b/src/multimedia/video/qmemoryvideobuffer_p.h @@ -65,9 +65,9 @@ public: QMemoryVideoBuffer(const QByteArray &data, int bytesPerLine); ~QMemoryVideoBuffer(); - MapMode mapMode() const override; + QVideoFrame::MapMode mapMode() const override; - MapData map(MapMode mode) override; + MapData map(QVideoFrame::MapMode mode) override; void unmap() override; }; diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index a92f74512..aab935534 100644 --- a/src/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp @@ -395,9 +395,9 @@ QVideoFrame::PixelFormat QVideoFrame::pixelFormat() const Returns the type of a video frame's handle. */ -QAbstractVideoBuffer::HandleType QVideoFrame::handleType() const +QVideoFrame::HandleType QVideoFrame::handleType() const { - return d->buffer ? d->buffer->handleType() : QAbstractVideoBuffer::NoHandle; + return d->buffer ? d->buffer->handleType() : QVideoFrame::NoHandle; } /*! @@ -427,25 +427,25 @@ int QVideoFrame::height() const /*! Identifies if a video frame's contents are currently mapped to system memory. - This is a convenience function which checks that the \l {QAbstractVideoBuffer::MapMode}{MapMode} - of the frame is not equal to QAbstractVideoBuffer::NotMapped. + This is a convenience function which checks that the \l {QVideoFrame::MapMode}{MapMode} + of the frame is not equal to QVideoFrame::NotMapped. Returns true if the contents of the video frame are mapped to system memory, and false otherwise. - \sa mapMode(), QAbstractVideoBuffer::MapMode + \sa mapMode(), QVideoFrame::MapMode */ bool QVideoFrame::isMapped() const { - return d->buffer != nullptr && d->buffer->mapMode() != QAbstractVideoBuffer::NotMapped; + return d->buffer != nullptr && d->buffer->mapMode() != QVideoFrame::NotMapped; } /*! Identifies if the mapped contents of a video frame will be persisted when the frame is unmapped. - This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} - contains the QAbstractVideoBuffer::WriteOnly flag. + This is a convenience function which checks if the \l {QVideoFrame::MapMode}{MapMode} + contains the QVideoFrame::WriteOnly flag. Returns true if the video frame will be updated when unmapped, and false otherwise. @@ -453,37 +453,37 @@ bool QVideoFrame::isMapped() const Depending on the buffer implementation the changes may be persisted, or worse alter a shared buffer. - \sa mapMode(), QAbstractVideoBuffer::MapMode + \sa mapMode(), QVideoFrame::MapMode */ bool QVideoFrame::isWritable() const { - return d->buffer != nullptr && (d->buffer->mapMode() & QAbstractVideoBuffer::WriteOnly); + return d->buffer != nullptr && (d->buffer->mapMode() & QVideoFrame::WriteOnly); } /*! Identifies if the mapped contents of a video frame were read from the frame when it was mapped. - This is a convenience function which checks if the \l {QAbstractVideoBuffer::MapMode}{MapMode} - contains the QAbstractVideoBuffer::WriteOnly flag. + This is a convenience function which checks if the \l {QVideoFrame::MapMode}{MapMode} + contains the QVideoFrame::WriteOnly flag. Returns true if the contents of the mapped memory were read from the video frame, and false otherwise. - \sa mapMode(), QAbstractVideoBuffer::MapMode + \sa mapMode(), QVideoFrame::MapMode */ bool QVideoFrame::isReadable() const { - return d->buffer != nullptr && (d->buffer->mapMode() & QAbstractVideoBuffer::ReadOnly); + return d->buffer != nullptr && (d->buffer->mapMode() & QVideoFrame::ReadOnly); } /*! Returns the mode a video frame was mapped to system memory in. - \sa map(), QAbstractVideoBuffer::MapMode + \sa map(), QVideoFrame::MapMode */ -QAbstractVideoBuffer::MapMode QVideoFrame::mapMode() const +QVideoFrame::MapMode QVideoFrame::mapMode() const { - return d->buffer != nullptr ? d->buffer->mapMode() : QAbstractVideoBuffer::NotMapped; + return d->buffer != nullptr ? d->buffer->mapMode() : QVideoFrame::NotMapped; } /*! @@ -494,9 +494,9 @@ QAbstractVideoBuffer::MapMode QVideoFrame::mapMode() const copying the contents around, so avoid mapping and unmapping unless required. The map \a mode indicates whether the contents of the mapped memory should be read from and/or - written to the frame. If the map mode includes the \c QAbstractVideoBuffer::ReadOnly flag the + written to the frame. If the map mode includes the \c QVideoFrame::ReadOnly flag the mapped memory will be populated with the content of the video frame when initially mapped. If the map - mode includes the \c QAbstractVideoBuffer::WriteOnly flag the content of the possibly modified + mode includes the \c QVideoFrame::WriteOnly flag the content of the possibly modified mapped memory will be written back to the frame when unmapped. While mapped the contents of a video frame can be accessed directly through the pointer returned @@ -516,20 +516,20 @@ QAbstractVideoBuffer::MapMode QVideoFrame::mapMode() const \sa unmap(), mapMode(), bits() */ -bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) +bool QVideoFrame::map(QVideoFrame::MapMode mode) { QMutexLocker lock(&d->mapMutex); if (!d->buffer) return false; - if (mode == QAbstractVideoBuffer::NotMapped) + if (mode == QVideoFrame::NotMapped) return false; if (d->mappedCount > 0) { //it's allowed to map the video frame multiple times in read only mode - if (d->buffer->mapMode() == QAbstractVideoBuffer::ReadOnly - && mode == QAbstractVideoBuffer::ReadOnly) { + if (d->buffer->mapMode() == QVideoFrame::ReadOnly + && mode == QVideoFrame::ReadOnly) { d->mappedCount++; return true; } @@ -630,7 +630,7 @@ bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) /*! Releases the memory mapped by the map() function. - If the \l {QAbstractVideoBuffer::MapMode}{MapMode} included the QAbstractVideoBuffer::WriteOnly + If the \l {QVideoFrame::MapMode}{MapMode} included the QVideoFrame::WriteOnly flag this will persist the current content of the mapped memory to the video frame. unmap() should not be called if map() function failed. @@ -1053,7 +1053,7 @@ QImage QVideoFrame::image() const QVideoFrame frame = *this; QImage result; - if (!frame.isValid() || !frame.map(QAbstractVideoBuffer::ReadOnly)) + if (!frame.isValid() || !frame.map(QVideoFrame::ReadOnly)) return result; // Formats supported by QImage don't need conversion @@ -1239,6 +1239,28 @@ static QString qFormatTimeStamps(qint64 start, qint64 end) .arg(e_millis, 2, 10, QLatin1Char('0')); } +QDebug operator<<(QDebug dbg, QVideoFrame::HandleType type) +{ + QDebugStateSaver saver(dbg); + dbg.nospace(); + switch (type) { + case QVideoFrame::NoHandle: + return dbg << "NoHandle"; + case QVideoFrame::GLTextureHandle: + return dbg << "GLTextureHandle"; + case QVideoFrame::MTLTextureHandle: + return dbg << "MTLTextureHandle"; + case QVideoFrame::XvShmImageHandle: + return dbg << "XvShmImageHandle"; + case QVideoFrame::CoreImageHandle: + return dbg << "CoreImageHandle"; + case QVideoFrame::QPixmapHandle: + return dbg << "QPixmapHandle"; + default: + return dbg << "UserHandle(" << int(type) << ')'; + } +} + QDebug operator<<(QDebug dbg, const QVideoFrame& f) { QDebugStateSaver saver(dbg); diff --git a/src/multimedia/video/qvideoframe.h b/src/multimedia/video/qvideoframe.h index 5c70c06f5..c240811a4 100644 --- a/src/multimedia/video/qvideoframe.h +++ b/src/multimedia/video/qvideoframe.h @@ -40,17 +40,18 @@ #ifndef QVIDEOFRAME_H #define QVIDEOFRAME_H +#include <QtMultimedia/qtmultimediaglobal.h> + #include <QtCore/qmetatype.h> #include <QtCore/qshareddata.h> -#include <QtGui/qimage.h> -#include <QtMultimedia/qabstractvideobuffer.h> #include <QtCore/qvariant.h> +#include <QtGui/qimage.h> QT_BEGIN_NAMESPACE class QSize; - class QVideoFramePrivate; +class QAbstractVideoBuffer; class Q_MULTIMEDIA_EXPORT QVideoFrame { @@ -102,6 +103,25 @@ public: Format_User = 1000 }; + enum HandleType + { + NoHandle, + GLTextureHandle, + MTLTextureHandle, + XvShmImageHandle, + CoreImageHandle, + QPixmapHandle, + EGLImageHandle + }; + + enum MapMode + { + NotMapped = 0x00, + ReadOnly = 0x01, + WriteOnly = 0x02, + ReadWrite = ReadOnly | WriteOnly + }; + QVideoFrame(); QVideoFrame(QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format); QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format); @@ -118,7 +138,7 @@ public: PixelFormat pixelFormat() const; - QAbstractVideoBuffer::HandleType handleType() const; + QVideoFrame::HandleType handleType() const; QSize size() const; int width() const; @@ -128,9 +148,9 @@ public: bool isReadable() const; bool isWritable() const; - QAbstractVideoBuffer::MapMode mapMode() const; + QVideoFrame::MapMode mapMode() const; - bool map(QAbstractVideoBuffer::MapMode mode); + bool map(QVideoFrame::MapMode mode); void unmap(); int bytesPerLine() const; @@ -168,6 +188,7 @@ Q_DECLARE_METATYPE(QVideoFrame); #ifndef QT_NO_DEBUG_STREAM Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoFrame&); +Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::HandleType); Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::PixelFormat); #endif diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp index 2fba59744..d80389151 100644 --- a/src/multimedia/video/qvideosurfaceformat.cpp +++ b/src/multimedia/video/qvideosurfaceformat.cpp @@ -55,7 +55,7 @@ public: QVideoSurfaceFormatPrivate( const QSize &size, QVideoFrame::PixelFormat format, - QAbstractVideoBuffer::HandleType type) + QVideoFrame::HandleType type) : pixelFormat(format) , handleType(type) , frameSize(size) @@ -94,7 +94,7 @@ public: } QVideoFrame::PixelFormat pixelFormat = QVideoFrame::Format_Invalid; - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle; + QVideoFrame::HandleType handleType = QVideoFrame::NoHandle; QVideoSurfaceFormat::Direction scanLineDirection = QVideoSurfaceFormat::TopToBottom; QSize frameSize; QSize pixelAspectRatio; @@ -186,7 +186,7 @@ QVideoSurfaceFormat::QVideoSurfaceFormat() \a size and pixel \a format. */ QVideoSurfaceFormat::QVideoSurfaceFormat( - const QSize& size, QVideoFrame::PixelFormat format, QAbstractVideoBuffer::HandleType type) + const QSize& size, QVideoFrame::PixelFormat format, QVideoFrame::HandleType type) : d(new QVideoSurfaceFormatPrivate(size, format, type)) { } @@ -243,12 +243,12 @@ QVideoFrame::PixelFormat QVideoSurfaceFormat::pixelFormat() const /*! Returns the type of handle the surface uses to present the frame data. - If the handle type is \c QAbstractVideoBuffer::NoHandle, buffers with any handle type are valid - provided they can be \l {QAbstractVideoBuffer::map()}{mapped} with the - QAbstractVideoBuffer::ReadOnly flag. If the handleType() is not QAbstractVideoBuffer::NoHandle + If the handle type is \c QVideoFrame::NoHandle, buffers with any handle type are valid + provided they can be \l {QVideoFrame::map()}{mapped} with the + QVideoFrame::ReadOnly flag. If the handleType() is not QVideoFrame::NoHandle then the handle type of the buffer must be the same as that of the surface format. */ -QAbstractVideoBuffer::HandleType QVideoSurfaceFormat::handleType() const +QVideoFrame::HandleType QVideoSurfaceFormat::handleType() const { return d->handleType; } diff --git a/src/multimedia/video/qvideosurfaceformat.h b/src/multimedia/video/qvideosurfaceformat.h index 5f264570c..417b53d8f 100644 --- a/src/multimedia/video/qvideosurfaceformat.h +++ b/src/multimedia/video/qvideosurfaceformat.h @@ -80,7 +80,7 @@ public: QVideoSurfaceFormat( const QSize &size, QVideoFrame::PixelFormat pixelFormat, - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle); + QVideoFrame::HandleType handleType = QVideoFrame::NoHandle); QVideoSurfaceFormat(const QVideoSurfaceFormat &format); ~QVideoSurfaceFormat(); @@ -92,7 +92,7 @@ public: bool isValid() const; QVideoFrame::PixelFormat pixelFormat() const; - QAbstractVideoBuffer::HandleType handleType() const; + QVideoFrame::HandleType handleType() const; QSize frameSize() const; void setFrameSize(const QSize &size); diff --git a/src/multimedia/video/qvideosurfaces.cpp b/src/multimedia/video/qvideosurfaces.cpp index 0583133be..1870e6ebf 100644 --- a/src/multimedia/video/qvideosurfaces.cpp +++ b/src/multimedia/video/qvideosurfaces.cpp @@ -57,7 +57,7 @@ QVideoSurfaces::QVideoSurfaces(const QList<QAbstractVideoSurface *> &s, QObject QVideoSurfaces::~QVideoSurfaces() = default; -QList<QVideoFrame::PixelFormat> QVideoSurfaces::supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const +QList<QVideoFrame::PixelFormat> QVideoSurfaces::supportedPixelFormats(QVideoFrame::HandleType type) const { QList<QVideoFrame::PixelFormat> result; QMap<QVideoFrame::PixelFormat, int> formats; diff --git a/src/multimedia/video/qvideosurfaces_p.h b/src/multimedia/video/qvideosurfaces_p.h index 9074ba458..f72bd0565 100644 --- a/src/multimedia/video/qvideosurfaces_p.h +++ b/src/multimedia/video/qvideosurfaces_p.h @@ -62,7 +62,7 @@ public: QVideoSurfaces(const QList<QAbstractVideoSurface *> &surfaces, QObject *parent = nullptr); ~QVideoSurfaces(); - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType type) const override; + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType type) const override; bool start(const QVideoSurfaceFormat &format) override; void stop() override; bool present(const QVideoFrame &frame) override; diff --git a/src/multimediawidgets/qpaintervideosurface.cpp b/src/multimediawidgets/qpaintervideosurface.cpp index 9e6d8fa8a..785980db8 100644 --- a/src/multimediawidgets/qpaintervideosurface.cpp +++ b/src/multimediawidgets/qpaintervideosurface.cpp @@ -71,7 +71,7 @@ public: QVideoSurfaceGenericPainter(); [[nodiscard]] QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const override; + QVideoFrame::HandleType handleType) const override; [[nodiscard]] bool isFormatSupported(const QVideoSurfaceFormat &format) const override; @@ -109,11 +109,11 @@ QVideoSurfaceGenericPainter::QVideoSurfaceGenericPainter() } QList<QVideoFrame::PixelFormat> QVideoSurfaceGenericPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { switch (handleType) { - case QAbstractVideoBuffer::QPixmapHandle: - case QAbstractVideoBuffer::NoHandle: + case QVideoFrame::QPixmapHandle: + case QVideoFrame::NoHandle: return m_imagePixelFormats; default: ; @@ -124,9 +124,9 @@ QList<QVideoFrame::PixelFormat> QVideoSurfaceGenericPainter::supportedPixelForma bool QVideoSurfaceGenericPainter::isFormatSupported(const QVideoSurfaceFormat &format) const { switch (format.handleType()) { - case QAbstractVideoBuffer::QPixmapHandle: + case QVideoFrame::QPixmapHandle: return true; - case QAbstractVideoBuffer::NoHandle: + case QVideoFrame::NoHandle: return m_imagePixelFormats.contains(format.pixelFormat()) && !format.frameSize().isEmpty(); default: @@ -148,8 +148,8 @@ QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::start(const QVideoSurf m_scanLineDirection = format.scanLineDirection(); m_mirrored = format.property("mirrored").toBool(); - const QAbstractVideoBuffer::HandleType t = format.handleType(); - if (t == QAbstractVideoBuffer::NoHandle) { + const QVideoFrame::HandleType t = format.handleType(); + if (t == QVideoFrame::NoHandle) { // bool ok = m_imageFormat != QImage::Format_Invalid && !m_imageSize.isEmpty(); //#ifndef QT_NO_OPENGL // if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) @@ -157,7 +157,7 @@ QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::start(const QVideoSurf //#endif // if (ok) return QAbstractVideoSurface::NoError; - } else if (t == QAbstractVideoBuffer::QPixmapHandle) { + } else if (t == QVideoFrame::QPixmapHandle) { return QAbstractVideoSurface::NoError; } return QAbstractVideoSurface::UnsupportedFormatError; @@ -183,9 +183,9 @@ QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::paint( return QAbstractVideoSurface::NoError; } - if (m_frame.handleType() == QAbstractVideoBuffer::QPixmapHandle) { + if (m_frame.handleType() == QVideoFrame::QPixmapHandle) { painter->drawPixmap(target, m_frame.handle().value<QPixmap>(), source); - } else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { + } else if (m_frame.map(QVideoFrame::ReadOnly)) { QImage image = m_frame.image(); const QTransform oldTransform = painter->transform(); @@ -249,7 +249,7 @@ public: QVideoSurfaceGLPainter(QOpenGLContext *context); ~QVideoSurfaceGLPainter() override; [[nodiscard]] QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const override; + QVideoFrame::HandleType handleType) const override; [[nodiscard]] bool isFormatSupported(const QVideoSurfaceFormat &format) const override; @@ -279,7 +279,7 @@ protected: QVideoFrame m_frame; QOpenGLContext *m_context; - QAbstractVideoBuffer::HandleType m_handleType; + QVideoFrame::HandleType m_handleType; QVideoSurfaceFormat::Direction m_scanLineDirection; bool m_mirrored; QVideoSurfaceFormat::YCbCrColorSpace m_colorSpace; @@ -298,7 +298,7 @@ protected: QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QOpenGLContext *context) : m_context(context) - , m_handleType(QAbstractVideoBuffer::NoHandle) + , m_handleType(QVideoFrame::NoHandle) , m_scanLineDirection(QVideoSurfaceFormat::TopToBottom) , m_mirrored(false) , m_colorSpace(QVideoSurfaceFormat::YCbCr_BT601) @@ -326,13 +326,13 @@ void QVideoSurfaceGLPainter::viewportDestroyed() } QList<QVideoFrame::PixelFormat> QVideoSurfaceGLPainter::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { switch (handleType) { - case QAbstractVideoBuffer::NoHandle: + case QVideoFrame::NoHandle: return m_imagePixelFormats; - case QAbstractVideoBuffer::QPixmapHandle: - case QAbstractVideoBuffer::GLTextureHandle: + case QVideoFrame::QPixmapHandle: + case QVideoFrame::GLTextureHandle: return m_glPixelFormats; default: ; @@ -346,10 +346,10 @@ bool QVideoSurfaceGLPainter::isFormatSupported(const QVideoSurfaceFormat &format return false; switch (format.handleType()) { - case QAbstractVideoBuffer::NoHandle: + case QVideoFrame::NoHandle: return m_imagePixelFormats.contains(format.pixelFormat()); - case QAbstractVideoBuffer::QPixmapHandle: - case QAbstractVideoBuffer::GLTextureHandle: + case QVideoFrame::QPixmapHandle: + case QVideoFrame::GLTextureHandle: return m_glPixelFormats.contains(format.pixelFormat()); default: ; @@ -368,14 +368,14 @@ QAbstractVideoSurface::Error QVideoSurfaceGLPainter::setCurrentFrame(const QVide { m_frame = frame; - if (m_handleType == QAbstractVideoBuffer::GLTextureHandle) { + if (m_handleType == QVideoFrame::GLTextureHandle) { m_textureIds[0] = frame.handle().toInt(); glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { + } else if (m_frame.map(QVideoFrame::ReadOnly)) { for (int i = 0; i < m_textureCount; ++i) { glBindTexture(GL_TEXTURE_2D, m_textureIds[i]); glTexImage2D( @@ -394,7 +394,7 @@ QAbstractVideoSurface::Error QVideoSurfaceGLPainter::setCurrentFrame(const QVide glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } m_frame.unmap(); - } else if (m_handleType != QAbstractVideoBuffer::QPixmapHandle && m_frame.isValid()) { + } else if (m_handleType != QVideoFrame::QPixmapHandle && m_frame.isValid()) { return QAbstractVideoSurface::IncorrectFormatError; } @@ -409,7 +409,7 @@ QAbstractVideoSurface::Error QVideoSurfaceGLPainter::paint( return QAbstractVideoSurface::NoError; } - if (m_frame.handleType() == QAbstractVideoBuffer::QPixmapHandle) { + if (m_frame.handleType() == QVideoFrame::QPixmapHandle) { painter->drawPixmap(target, m_frame.handle().value<QPixmap>(), source); } else if (m_frame.isValid()) { return QAbstractVideoSurface::IncorrectFormatError; @@ -718,7 +718,7 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac const char *program = nullptr; - if (format.handleType() == QAbstractVideoBuffer::NoHandle) { + if (format.handleType() == QVideoFrame::NoHandle) { switch (format.pixelFormat()) { case QVideoFrame::Format_RGB32: initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); @@ -765,7 +765,7 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac default: break; } - } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { + } else if (format.handleType() == QVideoFrame::GLTextureHandle) { switch (format.pixelFormat()) { case QVideoFrame::Format_RGB32: case QVideoFrame::Format_ARGB32: @@ -781,8 +781,8 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac default: break; } - } else if (format.handleType() == QAbstractVideoBuffer::QPixmapHandle) { - m_handleType = QAbstractVideoBuffer::QPixmapHandle; + } else if (format.handleType() == QVideoFrame::QPixmapHandle) { + m_handleType = QVideoFrame::QPixmapHandle; return QAbstractVideoSurface::NoError; } @@ -827,7 +827,7 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac m_frameSize = format.frameSize(); m_colorSpace = format.yCbCrColorSpace(); - if (m_handleType == QAbstractVideoBuffer::NoHandle) + if (m_handleType == QVideoFrame::NoHandle) glGenTextures(m_textureCount, m_textureIds); } } @@ -839,14 +839,14 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac void QVideoSurfaceArbFpPainter::stop() { if (m_context) { - if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) + if (m_handleType != QVideoFrame::GLTextureHandle) glDeleteTextures(m_textureCount, m_textureIds); glDeleteProgramsARB(1, &m_programId); } m_textureCount = 0; m_programId = 0; - m_handleType = QAbstractVideoBuffer::NoHandle; + m_handleType = QVideoFrame::NoHandle; QVideoSurfaceGLPainter::stop(); } @@ -859,8 +859,8 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( return QAbstractVideoSurface::NoError; } - const QAbstractVideoBuffer::HandleType h = m_frame.handleType(); - if (h == QAbstractVideoBuffer::NoHandle || h == QAbstractVideoBuffer::GLTextureHandle) { + const QVideoFrame::HandleType h = m_frame.handleType(); + if (h == QVideoFrame::NoHandle || h == QVideoFrame::GLTextureHandle) { bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); @@ -1093,7 +1093,7 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface const char *fragmentProgram = nullptr; - if (format.handleType() == QAbstractVideoBuffer::NoHandle) { + if (format.handleType() == QVideoFrame::NoHandle) { switch (format.pixelFormat()) { case QVideoFrame::Format_RGB32: initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); @@ -1144,7 +1144,7 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface default: break; } - } else if (format.handleType() == QAbstractVideoBuffer::GLTextureHandle) { + } else if (format.handleType() == QVideoFrame::GLTextureHandle) { switch (format.pixelFormat()) { case QVideoFrame::Format_RGB32: case QVideoFrame::Format_ARGB32: @@ -1160,8 +1160,8 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface default: break; } - } else if (format.handleType() == QAbstractVideoBuffer::QPixmapHandle) { - m_handleType = QAbstractVideoBuffer::QPixmapHandle; + } else if (format.handleType() == QVideoFrame::QPixmapHandle) { + m_handleType = QVideoFrame::QPixmapHandle; return QAbstractVideoSurface::NoError; } @@ -1186,7 +1186,7 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface m_frameSize = format.frameSize(); m_colorSpace = format.yCbCrColorSpace(); - if (m_handleType == QAbstractVideoBuffer::NoHandle) + if (m_handleType == QVideoFrame::NoHandle) glGenTextures(m_textureCount, m_textureIds); } @@ -1196,14 +1196,14 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface void QVideoSurfaceGlslPainter::stop() { if (m_context) { - if (m_handleType != QAbstractVideoBuffer::GLTextureHandle) + if (m_handleType != QVideoFrame::GLTextureHandle) glDeleteTextures(m_textureCount, m_textureIds); } m_program.removeAllShaders(); m_textureCount = 0; - m_handleType = QAbstractVideoBuffer::NoHandle; + m_handleType = QVideoFrame::NoHandle; QVideoSurfaceGLPainter::stop(); } @@ -1216,8 +1216,8 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint( return QAbstractVideoSurface::NoError; } - const QAbstractVideoBuffer::HandleType h = m_frame.handleType(); - if (h == QAbstractVideoBuffer::NoHandle || h == QAbstractVideoBuffer::GLTextureHandle) { + const QVideoFrame::HandleType h = m_frame.handleType(); + if (h == QVideoFrame::NoHandle || h == QVideoFrame::GLTextureHandle) { bool stencilTestEnabled = glIsEnabled(GL_STENCIL_TEST); bool scissorTestEnabled = glIsEnabled(GL_SCISSOR_TEST); @@ -1368,7 +1368,7 @@ QPainterVideoSurface::~QPainterVideoSurface() /*! */ QList<QVideoFrame::PixelFormat> QPainterVideoSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { if (!m_painter) const_cast<QPainterVideoSurface *>(this)->createPainter(); diff --git a/src/multimediawidgets/qpaintervideosurface_p.h b/src/multimediawidgets/qpaintervideosurface_p.h index 582d6944c..018fad36f 100644 --- a/src/multimediawidgets/qpaintervideosurface_p.h +++ b/src/multimediawidgets/qpaintervideosurface_p.h @@ -69,7 +69,7 @@ public: virtual ~QVideoSurfacePainter(); virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const = 0; + QVideoFrame::HandleType handleType) const = 0; virtual bool isFormatSupported(const QVideoSurfaceFormat &format) const = 0; @@ -94,7 +94,7 @@ public: ~QPainterVideoSurface(); QList<QVideoFrame::PixelFormat> supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const override; + QVideoFrame::HandleType handleType = QVideoFrame::NoHandle) const override; bool isFormatSupported(const QVideoSurfaceFormat &format) const override; diff --git a/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp b/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp index 2e6c712e3..b238dff4f 100644 --- a/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp +++ b/src/plugins/videonode/imx6/qsgvivantevideomaterial.cpp @@ -176,7 +176,7 @@ GLuint QSGVivanteVideoMaterial::vivanteMapping(QVideoFrame vF) clearTextures(); } - if (vF.map(QAbstractVideoBuffer::ReadOnly)) { + if (vF.map(QVideoFrame::ReadOnly)) { if (mMappable) { if (!mBitsToTextureMap.contains(vF.bits())) { diff --git a/src/plugins/videonode/imx6/qsgvivantevideonode.h b/src/plugins/videonode/imx6/qsgvivantevideonode.h index 2796f1e44..1d2f3d342 100644 --- a/src/plugins/videonode/imx6/qsgvivantevideonode.h +++ b/src/plugins/videonode/imx6/qsgvivantevideonode.h @@ -51,7 +51,7 @@ public: ~QSGVivanteVideoNode(); QVideoFrame::PixelFormat pixelFormat() const { return mFormat.pixelFormat(); } - QAbstractVideoBuffer::HandleType handleType() const { return QAbstractVideoBuffer::NoHandle; } + QVideoFrame::HandleType handleType() const { return QVideoFrame::NoHandle; } void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags); static const QMap<QVideoFrame::PixelFormat, GLenum>& getVideoFormat2GLFormatMap(); diff --git a/src/plugins/videonode/imx6/qsgvivantevideonodefactory.cpp b/src/plugins/videonode/imx6/qsgvivantevideonodefactory.cpp index 55ed57c10..a4982ad46 100644 --- a/src/plugins/videonode/imx6/qsgvivantevideonodefactory.cpp +++ b/src/plugins/videonode/imx6/qsgvivantevideonodefactory.cpp @@ -42,10 +42,10 @@ #include <QtGui/QGuiApplication> QList<QVideoFrame::PixelFormat> QSGVivanteVideoNodeFactory::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { const bool isWebGl = QGuiApplication::platformName() == QLatin1String("webgl"); - if (!isWebGl && handleType == QAbstractVideoBuffer::NoHandle) + if (!isWebGl && handleType == QVideoFrame::NoHandle) return QSGVivanteVideoNode::getVideoFormat2GLFormatMap().keys(); else return QList<QVideoFrame::PixelFormat>(); diff --git a/src/plugins/videonode/imx6/qsgvivantevideonodefactory.h b/src/plugins/videonode/imx6/qsgvivantevideonodefactory.h index dfb6a0123..6dd068d55 100644 --- a/src/plugins/videonode/imx6/qsgvivantevideonodefactory.h +++ b/src/plugins/videonode/imx6/qsgvivantevideonodefactory.h @@ -50,7 +50,7 @@ public: Q_PLUGIN_METADATA(IID QSGVideoNodeFactoryInterface_iid FILE "imx6.json") Q_INTERFACES(QSGVideoNodeFactoryInterface) - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const; + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const; QSGVideoNode *createNode(const QVideoSurfaceFormat &format); }; #endif // QSGVIDEONODEFACTORY_VIVANTE_H diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp index 5ef318a22..bc5747903 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp @@ -333,7 +333,7 @@ QSGNode *QDeclarativeVideoBackend::updatePaintNode(QSGNode *oldNode, if ((q->flushMode() == QDeclarativeVideoOutput::FirstFrame && !m_frameOnFlush.isValid()) || q->flushMode() == QDeclarativeVideoOutput::LastFrame) { - m_frameOnFlush = m_surfaceFormat.handleType() == QAbstractVideoBuffer::NoHandle + m_frameOnFlush = m_surfaceFormat.handleType() == QVideoFrame::NoHandle ? m_frame : m_frame.image(); } @@ -397,13 +397,13 @@ QSGVideoItemSurface::QSGVideoItemSurface(QDeclarativeVideoBackend *backend, QObj QSGVideoItemSurface::~QSGVideoItemSurface() = default; QList<QVideoFrame::PixelFormat> QSGVideoItemSurface::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { QList<QVideoFrame::PixelFormat> formats; static bool noGLTextures = false; static bool noGLTexturesChecked = false; - if (handleType == QAbstractVideoBuffer::GLTextureHandle) { + if (handleType == QVideoFrame::GLTextureHandle) { if (!noGLTexturesChecked) { noGLTexturesChecked = true; noGLTextures = qEnvironmentVariableIsSet("QT_QUICK_NO_TEXTURE_VIDEOFRAMES"); diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h index 893bc14c7..e15363016 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h @@ -133,7 +133,7 @@ class QSGVideoItemSurface : public QAbstractVideoSurface public: explicit QSGVideoItemSurface(QDeclarativeVideoBackend *backend, QObject *parent = 0); ~QSGVideoItemSurface(); - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const override; + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const override; bool start(const QVideoSurfaceFormat &format) override; void stop() override; bool present(const QVideoFrame &frame) override; diff --git a/src/qtmultimediaquicktools/qsgvideonode_p.h b/src/qtmultimediaquicktools/qsgvideonode_p.h index c094bed1f..75bf1da5b 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_p.h +++ b/src/qtmultimediaquicktools/qsgvideonode_p.h @@ -72,7 +72,7 @@ public: virtual void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) = 0; virtual QVideoFrame::PixelFormat pixelFormat() const = 0; - virtual QAbstractVideoBuffer::HandleType handleType() const = 0; + virtual QVideoFrame::HandleType handleType() const = 0; void setTexturedRectGeometry(const QRectF &boundingRect, const QRectF &textureRect, int orientation); @@ -89,7 +89,7 @@ class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNodeFactoryInterface public: virtual ~QSGVideoNodeFactoryInterface(); - virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const = 0; + virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const = 0; virtual QSGVideoNode *createNode(const QVideoSurfaceFormat &format) = 0; }; @@ -101,7 +101,7 @@ class Q_MULTIMEDIAQUICK_EXPORT QSGVideoNodeFactoryPlugin : public QObject, publi Q_OBJECT Q_INTERFACES(QSGVideoNodeFactoryInterface) public: - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const override = 0; + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const override = 0; QSGVideoNode *createNode(const QVideoSurfaceFormat &format) override = 0; }; diff --git a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp index 72404c427..57101648d 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_rgb.cpp @@ -44,11 +44,11 @@ QT_BEGIN_NAMESPACE QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_RGB::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { QList<QVideoFrame::PixelFormat> pixelFormats; - if (handleType == QAbstractVideoBuffer::NoHandle) { + if (handleType == QVideoFrame::NoHandle) { pixelFormats.append(QVideoFrame::Format_RGB32); pixelFormats.append(QVideoFrame::Format_ARGB32); pixelFormats.append(QVideoFrame::Format_BGR32); @@ -174,7 +174,7 @@ void QSGVideoMaterialRhiShader_RGB::updateSampledImage(RenderState &state, int b format = QRhiTexture::BGRA8; } - if (frame.isValid() && frame.map(QAbstractVideoBuffer::ReadOnly)) { + if (frame.isValid() && frame.map(QVideoFrame::ReadOnly)) { m->m_texture->setData(format, frame.size(), frame.bits(), frame.bytesPerLine() * frame.height()); frame.unmap(); } diff --git a/src/qtmultimediaquicktools/qsgvideonode_rgb_p.h b/src/qtmultimediaquicktools/qsgvideonode_rgb_p.h index 95b74be0b..c17738b0a 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_rgb_p.h +++ b/src/qtmultimediaquicktools/qsgvideonode_rgb_p.h @@ -67,8 +67,8 @@ public: QVideoFrame::PixelFormat pixelFormat() const override { return m_format.pixelFormat(); } - QAbstractVideoBuffer::HandleType handleType() const override { - return QAbstractVideoBuffer::NoHandle; + QVideoFrame::HandleType handleType() const override { + return QVideoFrame::NoHandle; } void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) override; @@ -80,7 +80,7 @@ private: class QSGVideoNodeFactory_RGB : public QSGVideoNodeFactoryInterface { public: - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const override; + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const override; QSGVideoNode *createNode(const QVideoSurfaceFormat &format) override; }; diff --git a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp index 45469125b..58a903065 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_texture.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_texture.cpp @@ -46,19 +46,19 @@ QT_BEGIN_NAMESPACE QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_Texture::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { QList<QVideoFrame::PixelFormat> pixelFormats; - QList<QAbstractVideoBuffer::HandleType> types; + QList<QVideoFrame::HandleType> types; auto rhi = QSGRhiSupport::instance(); auto metalEnabled = rhi->isRhiEnabled() && rhi->rhiBackend() == QRhi::Metal; if (metalEnabled) - types.append(QAbstractVideoBuffer::MTLTextureHandle); + types.append(QVideoFrame::MTLTextureHandle); #if QT_CONFIG(opengl) - types.append(QAbstractVideoBuffer::GLTextureHandle); + types.append(QVideoFrame::GLTextureHandle); #endif if (types.contains(handleType)) { diff --git a/src/qtmultimediaquicktools/qsgvideonode_texture_p.h b/src/qtmultimediaquicktools/qsgvideonode_texture_p.h index d7348473e..7f0b02220 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_texture_p.h +++ b/src/qtmultimediaquicktools/qsgvideonode_texture_p.h @@ -67,7 +67,7 @@ public: QVideoFrame::PixelFormat pixelFormat() const override { return m_format.pixelFormat(); } - QAbstractVideoBuffer::HandleType handleType() const override { + QVideoFrame::HandleType handleType() const override { return m_format.handleType(); } void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) override; @@ -80,7 +80,7 @@ private: class QSGVideoNodeFactory_Texture : public QSGVideoNodeFactoryInterface { public: - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const override; + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const override; QSGVideoNode *createNode(const QVideoSurfaceFormat &format) override; }; diff --git a/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp b/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp index 5979c4c1c..51b02f43b 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp +++ b/src/qtmultimediaquicktools/qsgvideonode_yuv.cpp @@ -44,17 +44,17 @@ QT_BEGIN_NAMESPACE QList<QVideoFrame::PixelFormat> QSGVideoNodeFactory_YUV::supportedPixelFormats( - QAbstractVideoBuffer::HandleType handleType) const + QVideoFrame::HandleType handleType) const { QList<QVideoFrame::PixelFormat> formats; - if (handleType == QAbstractVideoBuffer::NoHandle) { + if (handleType == QVideoFrame::NoHandle) { formats << QVideoFrame::Format_YUV420P << QVideoFrame::Format_YV12 << QVideoFrame::Format_YUV422P << QVideoFrame::Format_NV12 << QVideoFrame::Format_NV21 << QVideoFrame::Format_UYVY << QVideoFrame::Format_YUYV; - } else if (handleType == QAbstractVideoBuffer::GLTextureHandle) { + } else if (handleType == QVideoFrame::GLTextureHandle) { formats << QVideoFrame::Format_NV12 << QVideoFrame::Format_NV21; - } else if (handleType == QAbstractVideoBuffer::MTLTextureHandle) { + } else if (handleType == QVideoFrame::MTLTextureHandle) { formats << QVideoFrame::Format_NV12 << QVideoFrame::Format_NV21; } @@ -269,7 +269,7 @@ void QSGVideoMaterialRhiShader_YUV::updateSampledImage(RenderState &state, int b void QSGVideoMaterialRhiShader_UYVY::mapFrame(QSGVideoMaterial_YUV *m) { - if (!m->m_frame.isValid() || !m->m_frame.map(QAbstractVideoBuffer::ReadOnly)) + if (!m->m_frame.isValid() || !m->m_frame.map(QVideoFrame::ReadOnly)) return; int fw = m->m_frame.width(); @@ -290,7 +290,7 @@ void QSGVideoMaterialRhiShader_UYVY::mapFrame(QSGVideoMaterial_YUV *m) void QSGVideoMaterialRhiShader_YUV_YV::mapFrame(QSGVideoMaterial_YUV *m) { - if (!m->m_frame.isValid() || !m->m_frame.map(QAbstractVideoBuffer::ReadOnly)) + if (!m->m_frame.isValid() || !m->m_frame.map(QVideoFrame::ReadOnly)) return; int y = 0; @@ -318,7 +318,7 @@ void QSGVideoMaterialRhiShader_NV12::mapFrame(QSGVideoMaterial_YUV *m) if (!m->m_frame.isValid()) return; - if (m->m_frame.handleType() == QAbstractVideoBuffer::GLTextureHandle || m->m_frame.handleType() == QAbstractVideoBuffer::MTLTextureHandle) { + if (m->m_frame.handleType() == QVideoFrame::GLTextureHandle || m->m_frame.handleType() == QVideoFrame::MTLTextureHandle) { m->m_planeWidth[0] = m->m_planeWidth[1] = 1; auto textures = m->m_frame.handle().toList(); if (!textures.isEmpty()) { @@ -333,7 +333,7 @@ void QSGVideoMaterialRhiShader_NV12::mapFrame(QSGVideoMaterial_YUV *m) return; } - if (!m->m_frame.map(QAbstractVideoBuffer::ReadOnly)) + if (!m->m_frame.map(QVideoFrame::ReadOnly)) return; int y = 0; diff --git a/src/qtmultimediaquicktools/qsgvideonode_yuv_p.h b/src/qtmultimediaquicktools/qsgvideonode_yuv_p.h index 643f40c71..c8299e919 100644 --- a/src/qtmultimediaquicktools/qsgvideonode_yuv_p.h +++ b/src/qtmultimediaquicktools/qsgvideonode_yuv_p.h @@ -66,8 +66,8 @@ public: QVideoFrame::PixelFormat pixelFormat() const override { return m_format.pixelFormat(); } - QAbstractVideoBuffer::HandleType handleType() const override { - return QAbstractVideoBuffer::NoHandle; + QVideoFrame::HandleType handleType() const override { + return QVideoFrame::NoHandle; } void setCurrentFrame(const QVideoFrame &frame, FrameFlags flags) override; @@ -80,7 +80,7 @@ private: class QSGVideoNodeFactory_YUV : public QSGVideoNodeFactoryInterface { public: - QList<QVideoFrame::PixelFormat> supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const override; + QList<QVideoFrame::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const override; QSGVideoNode *createNode(const QVideoSurfaceFormat &format) override; }; |