diff options
42 files changed, 76 insertions, 882 deletions
diff --git a/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc b/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc index f820a38b4..be1572a12 100644 --- a/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc +++ b/examples/multimediawidgets/videographicsitem/doc/src/videographicsitem.qdoc @@ -32,7 +32,7 @@ \brief Streaming video on a graphics scene. \e{Video Graphics Item} demonstrates how to implement a QGraphicsItem that - displays video on a graphics scene using QAbstractVideoSurface. + displays video on a graphics scene using QVideoSink. \image video-videographicsitem.png diff --git a/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc b/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc index a766243b6..fd96744a6 100644 --- a/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc +++ b/examples/multimediawidgets/videowidget/doc/src/videowidget.qdoc @@ -32,7 +32,7 @@ \brief Implementing a video player widget. \e{Video Widget} demonstrates how to implement a video widget using - QAbstractVideoSurface. + QVideoSink. \image video-videowidget.png diff --git a/src/imports/multimedia/plugins.qmltypes b/src/imports/multimedia/plugins.qmltypes index 1f43a4a64..8074e380d 100644 --- a/src/imports/multimedia/plugins.qmltypes +++ b/src/imports/multimedia/plugins.qmltypes @@ -288,24 +288,6 @@ Module { Property { name: "active"; type: "bool" } } Component { - name: "QAbstractVideoSurface" - prototype: "QObject" - Property { name: "nativeResolution"; type: "QSize"; isReadonly: true } - Signal { - name: "activeChanged" - Parameter { name: "active"; type: "bool" } - } - Signal { - name: "surfaceFormatChanged" - Parameter { name: "format"; type: "QVideoSurfaceFormat" } - } - Signal { name: "supportedFormatsChanged" } - Signal { - name: "nativeResolutionChanged" - Parameter { name: "resolution"; type: "QSize" } - } - } - Component { name: "QCamera" prototype: "QObject" Enum { diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt index 068513994..569ea7b13 100644 --- a/src/multimedia/CMakeLists.txt +++ b/src/multimedia/CMakeLists.txt @@ -61,7 +61,6 @@ qt_internal_add_module(Multimedia recording/qmediarecorder.cpp recording/qmediarecorder.h recording/qmediarecorder_p.h video/qabstractvideobuffer.cpp video/qabstractvideobuffer_p.h video/qabstractvideofilter.cpp video/qabstractvideofilter.h - video/qabstractvideosurface.cpp video/qabstractvideosurface.h video/qimagevideobuffer.cpp video/qimagevideobuffer_p.h video/qmemoryvideobuffer.cpp video/qmemoryvideobuffer_p.h video/qvideoframe.cpp video/qvideoframe.h @@ -69,7 +68,6 @@ qt_internal_add_module(Multimedia video/qvideoframeconversionhelper.cpp video/qvideoframeconversionhelper_p.h video/qvideooutputorientationhandler.cpp video/qvideooutputorientationhandler_p.h video/qvideosurfaceformat.cpp video/qvideosurfaceformat.h - video/qvideosurfaces.cpp video/qvideosurfaces_p.h INCLUDE_DIRECTORIES audio camera diff --git a/src/multimedia/camera/qcamera.h b/src/multimedia/camera/qcamera.h index 63003ecf4..8a01b2423 100644 --- a/src/multimedia/camera/qcamera.h +++ b/src/multimedia/camera/qcamera.h @@ -58,7 +58,6 @@ QT_BEGIN_NAMESPACE -class QAbstractVideoSurface; class QCameraInfo; class QPlatformMediaCaptureSession; class QMediaCaptureSession; diff --git a/src/multimedia/camera/qcameraimagecapture.cpp b/src/multimedia/camera/qcameraimagecapture.cpp index 7569a35dc..80ce85259 100644 --- a/src/multimedia/camera/qcameraimagecapture.cpp +++ b/src/multimedia/camera/qcameraimagecapture.cpp @@ -356,9 +356,8 @@ int QCameraImageCapture::captureToBuffer() /*! \fn QCameraImageCapture::imageCaptured(int id, const QImage &preview); - Signal emitted when QAbstractVideoSurface is used as a viewfinder and - the frame with request \a id was captured, but not processed and saved yet. - Frame \a preview can be displayed to user. + Signal emitted when the frame with request \a id was captured, but not + processed and saved yet. Frame \a preview can be displayed to user. */ /*! diff --git a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp index 7f72e2e21..2299ba81a 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/camera.cpp @@ -44,7 +44,7 @@ #include "qmediarecorder.h" #include "qcameraimagecapture.h" #include "qcameraimageprocessing.h" -#include "qabstractvideosurface.h" +#include "qvideosink.h" #include <QtGui/qscreen.h> #include <QtGui/qguiapplication.h> #include <QtGui/qimage.h> @@ -85,30 +85,16 @@ void overview_camera_by_position() } // -.- -class MyVideoSurface : public QAbstractVideoSurface -{ - QList<QVideoSurfaceFormat::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType handleType) const - { - Q_UNUSED(handleType); - return QList<QVideoSurfaceFormat::PixelFormat>(); - } - bool present(const QVideoFrame &frame) - { - Q_UNUSED(frame); - return true; - } -}; - void overview_surface() { - MyVideoSurface *mySurface; + QVideoSink *mySink; //! [Camera overview surface] camera = new QCamera; - mySurface = new MyVideoSurface; - camera->setViewfinder(mySurface); + mySink = new QVideoSink; + camera->setViewfinder(mySink); camera->start(); - // MyVideoSurface::present(..) will be called with viewfinder frames + // MyVideoSurface::newVideoFrame(..) will be called with video frames //! [Camera overview surface] } diff --git a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp index d4832bfa9..9c270bdcc 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/media.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/media.cpp @@ -51,7 +51,7 @@ #include "qcamera.h" #include "qcameraviewfinder.h" #include "qaudiorecorder.h" -#include <QAbstractVideoSurface> +#include <QVideoSink> class MediaExample : public QObject { Q_OBJECT @@ -170,22 +170,8 @@ void MediaExample::MediaPlayer() //! [Pipeline] //! [Pipeline Surface] - class Surface : public QAbstractVideoSurface - { - public: - Surface(QObject *p) : QAbstractVideoSurface(p) { } - QList<QVideoSurfaceFormat::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType) const override - { - // Make sure that the driver supports this pixel format. - return QList<QVideoSurfaceFormat::PixelFormat>() << QVideoSurfaceFormat::Format_YUYV; - } - - // Video frames are handled here. - bool present(const QVideoFrame &) override { return true; } - }; - player = new QMediaPlayer; - player->setVideoOutput(new Surface(player)); + player->setVideoOutput(new QVideoSink(player)); player->setMedia(QUrl("gst-pipeline: videotestsrc ! qtvideosink")); player->play(); //! [Pipeline Surface] diff --git a/src/multimedia/doc/snippets/multimedia-snippets/video.cpp b/src/multimedia/doc/snippets/multimedia-snippets/video.cpp index 1b877ba0b..83f1fd26d 100644 --- a/src/multimedia/doc/snippets/multimedia-snippets/video.cpp +++ b/src/multimedia/doc/snippets/multimedia-snippets/video.cpp @@ -40,7 +40,7 @@ /* Video related snippets */ #include "qvideorenderercontrol.h" #include "qmediaplayer.h" -#include "qabstractvideosurface.h" +#include "qvideosink.h" #include "qvideowindowcontrol.h" #include "qgraphicsvideoitem.h" #include "qmediaplaylist.h" @@ -49,45 +49,18 @@ #include <QFormLayout> #include <QGraphicsView> -//! [Derived Surface] -class MyVideoSurface : public QAbstractVideoSurface -{ - QList<QVideoSurfaceFormat::PixelFormat> supportedPixelFormats( - QVideoFrame::HandleType handleType = QVideoFrame::NoHandle) const - { - Q_UNUSED(handleType); - - // Return the formats you will support - return QList<QVideoSurfaceFormat::PixelFormat>() << QVideoSurfaceFormat::Format_RGB565; - } - - bool present(const QVideoFrame &frame) - { - Q_UNUSED(frame); - // Handle the frame and do your processing - - return true; - } -}; -//! [Derived Surface] - //! [Video producer] class MyVideoProducer : public QObject { Q_OBJECT - Q_PROPERTY(QAbstractVideoSurface *videoSurface READ videoSurface WRITE setVideoSurface) + Q_PROPERTY(QVideoSink *videoSink READ videoSink WRITE setVideoSink) public: - QAbstractVideoSurface* videoSurface() const { return m_surface; } + QVideoSink* videoSink() const { return m_sink; } - void setVideoSurface(QAbstractVideoSurface *surface) + void setVideoSink(QVideoSink *sink) { - if (m_surface != surface && m_surface && m_surface->isActive()) { - m_surface->stop(); - } - m_surface = surface; - if (m_surface) - m_surface->start(m_format); + m_sink = sink; } // ... @@ -95,13 +68,12 @@ public: public slots: void onNewVideoContentReceived(const QVideoFrame &frame) { - if (m_surface) - m_surface->present(frame); + if (m_sink) + m_sink->newVideoFrame(frame); } private: - QAbstractVideoSurface *m_surface; - QVideoSurfaceFormat m_format; + QVideoSink *m_sink; }; //! [Video producer] @@ -122,7 +94,7 @@ private: QVideoWidget *videoWidget; QWidget *widget; QFormLayout *layout; - QAbstractVideoSurface *myVideoSurface; + QVideoSink *myVideoSink; QMediaPlayer *player; QMediaContent video; QGraphicsView *graphicsView; @@ -148,7 +120,7 @@ void VideoExample::VideoWidget() player->stop(); //! [Setting surface in player] - player->setVideoOutput(myVideoSurface); + player->setVideoOutput(myVideoSink); //! [Setting surface in player] } @@ -168,22 +140,10 @@ void VideoExample::VideoSurface() graphicsView->scene()->addItem(item); graphicsView->show(); QImage img = QImage("images/qt-logo.png").convertToFormat(QImage::Format_ARGB32); - QVideoSurfaceFormat format(img.size(), QVideoSurfaceFormat::Format_ARGB32); - item->videoSurface()->start(format); - item->videoSurface()->present(img); + item->videoSink()->newVideoFrame(QVideoFrame(img)); //! [GraphicsVideoItem Surface] } -void VideoExample::VideoWindowControl() -{ - //! [Video window control] - QVideoWindowControl *windowControl = mediaService->requestControl<QVideoWindowControl *>(); - windowControl->setWinId(widget->winId()); - windowControl->setDisplayRect(widget->rect()); - windowControl->setAspectRatioMode(Qt::KeepAspectRatio); - //! [Video window control] -} - void VideoExample::VideoGraphicsItem() { //! [Video graphics item] diff --git a/src/multimedia/doc/src/cameraoverview.qdoc b/src/multimedia/doc/src/cameraoverview.qdoc index c3edf8119..6ae14c015 100644 --- a/src/multimedia/doc/src/cameraoverview.qdoc +++ b/src/multimedia/doc/src/cameraoverview.qdoc @@ -177,9 +177,9 @@ is useful for QGraphicsView. \snippet multimedia-snippets/camera.cpp Camera overview viewfinder For advanced usage (like processing viewfinder frames as they come, to detect -objects or patterns), you can also derive from \l QAbstractVideoSurface and -set that as the viewfinder for the QCamera object. In this case you will -need to render the viewfinder image yourself. +objects or patterns), you can also use your own QVideoSink and set that as the viewfinder +for the QCamera object. In this case you will need to render the viewfinder image yourself +by processing the data received from the newVideoFrame() signal. \snippet multimedia-snippets/camera.cpp Camera overview surface diff --git a/src/multimedia/doc/src/multimedia.qdoc b/src/multimedia/doc/src/multimedia.qdoc index dcf394c87..f0272c4b1 100644 --- a/src/multimedia/doc/src/multimedia.qdoc +++ b/src/multimedia/doc/src/multimedia.qdoc @@ -115,7 +115,7 @@ For some quick recipes, look at the overviews above and consult this table: \li Video Processing \li \l {QML Video Example}{qmlvideofx} \li \l {MediaPlayer}, \l VideoOutput - \li QMediaPlayer, QAbstractVideoSurface, QVideoFrame + \li QMediaPlayer, QVideoFrame \row \li Accessing camera viewfinder \li \l {Camera Example}{camera}, @@ -126,7 +126,7 @@ For some quick recipes, look at the overviews above and consult this table: \li Viewfinder processing \li \li \l Camera, \l VideoOutput - \li QCamera, QAbstractVideoSurface, QVideoFrame + \li QCamera, QVideoFrame \row \li Capturing photos \li \l {Camera Example}{camera}, diff --git a/src/multimedia/doc/src/qtmultimedia-index.qdoc b/src/multimedia/doc/src/qtmultimedia-index.qdoc index 13c686978..d2d39a5aa 100644 --- a/src/multimedia/doc/src/qtmultimedia-index.qdoc +++ b/src/multimedia/doc/src/qtmultimedia-index.qdoc @@ -129,8 +129,8 @@ \li QMediaPlaylist \li List of media to be played. \row - \li QAbstractVideoSurface - \li Base class for video presentation. + \li QVideoSink + \li Class for video presentation. \endtable \section1 Licenses and Attributions diff --git a/src/multimedia/doc/src/videooverview.qdoc b/src/multimedia/doc/src/videooverview.qdoc index 1811e4991..725c8873f 100644 --- a/src/multimedia/doc/src/videooverview.qdoc +++ b/src/multimedia/doc/src/videooverview.qdoc @@ -73,7 +73,7 @@ to display video in a special way that is otherwise unsupported. The \l QVideoFrame class encapsulates a video frame and allows the contents to be mapped into system memory for manipulation or -processing, while deriving a class from \l QAbstractVideoSurface +processing. Using your own QVideoSink allows you to receive these frames from \l QMediaPlayer and \l QCamera. diff --git a/src/multimedia/platform/android/mediaplayer/qandroidmediaplayervideorenderercontrol.cpp b/src/multimedia/platform/android/mediaplayer/qandroidmediaplayervideorenderercontrol.cpp index 1699e9495..6c4ba1b46 100644 --- a/src/multimedia/platform/android/mediaplayer/qandroidmediaplayervideorenderercontrol.cpp +++ b/src/multimedia/platform/android/mediaplayer/qandroidmediaplayervideorenderercontrol.cpp @@ -41,7 +41,6 @@ #include "qandroidmediaplayercontrol_p.h" #include "private/qandroidvideooutput_p.h" -#include <qabstractvideosurface.h> QT_BEGIN_NAMESPACE diff --git a/src/multimedia/platform/darwin/camera/avfcamera.mm b/src/multimedia/platform/darwin/camera/avfcamera.mm index 2acf529f5..e9a8bd475 100644 --- a/src/multimedia/platform/darwin/camera/avfcamera.mm +++ b/src/multimedia/platform/darwin/camera/avfcamera.mm @@ -46,7 +46,6 @@ #include "avfcameraexposure_p.h" #include "avfcamerafocus_p.h" #include "avfcameraimageprocessing_p.h" -#include "qabstractvideosurface.h" QT_USE_NAMESPACE diff --git a/src/multimedia/platform/darwin/camera/avfcamerarenderer.mm b/src/multimedia/platform/darwin/camera/avfcamerarenderer.mm index 429ca1e81..459dce5ca 100644 --- a/src/multimedia/platform/darwin/camera/avfcamerarenderer.mm +++ b/src/multimedia/platform/darwin/camera/avfcamerarenderer.mm @@ -52,7 +52,6 @@ #include <QtGui/qopengl.h> #endif -#include <QtMultimedia/qabstractvideosurface.h> #include <private/qabstractvideobuffer_p.h> #include <QtMultimedia/qvideosurfaceformat.h> diff --git a/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer.mm b/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer.mm index 6899bdd9e..fb341ffca 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer.mm +++ b/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer.mm @@ -39,7 +39,6 @@ #include "avfvideoframerenderer_p.h" -#include <QtMultimedia/qabstractvideosurface.h> #include <QtOpenGL/QOpenGLFramebufferObject> #include <QtGui/QWindow> #include <QOpenGLShaderProgram> diff --git a/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer_ios.mm b/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer_ios.mm index 38929001f..7f61249a1 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer_ios.mm +++ b/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer_ios.mm @@ -39,7 +39,6 @@ #include "private/avfvideoframerenderer_ios_p.h" -#include <QtMultimedia/qabstractvideosurface.h> #include <QtOpenGL/QOpenGLFramebufferObject> #include <QtOpenGL/QOpenGLShaderProgram> #include <QtGui/QOffscreenSurface> @@ -52,14 +51,8 @@ #import <AVFoundation/AVFoundation.h> QT_USE_NAMESPACE -AVFVideoFrameRenderer::AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent) +AVFVideoFrameRenderer::AVFVideoFrameRenderer(QObject *parent) : QObject(parent) - , m_glContext(nullptr) - , m_offscreenSurface(nullptr) - , m_surface(surface) - , m_textureCache(nullptr) - , m_videoOutput(nullptr) - , m_isContextShared(true) { } @@ -261,9 +254,9 @@ void AVFVideoFrameRenderer::initRenderer() if (!m_glContext) { //Create OpenGL context and set share context from surface QOpenGLContext *shareContext = nullptr; - if (m_surface) { - shareContext = qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>()); - } +// if (m_surface) { +// shareContext = qobject_cast<QOpenGLContext*>(m_surface->property("GLContext").value<QObject*>()); +// } m_glContext = new QOpenGLContext(); if (shareContext) { diff --git a/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer_ios_p.h b/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer_ios_p.h index b69e33ceb..0d816282b 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer_ios_p.h +++ b/src/multimedia/platform/darwin/mediaplayer/avfvideoframerenderer_ios_p.h @@ -68,7 +68,6 @@ class QOpenGLContext; class QOpenGLFramebufferObject; class QOpenGLShaderProgram; class QOffscreenSurface; -class QAbstractVideoSurface; typedef struct __CVBuffer *CVBufferRef; typedef CVBufferRef CVImageBufferRef; @@ -100,7 +99,7 @@ typedef CVOpenGLTextureRef CVOGLTextureRef; class AVFVideoFrameRenderer : public QObject { public: - AVFVideoFrameRenderer(QAbstractVideoSurface *surface, QObject *parent = nullptr); + AVFVideoFrameRenderer(QObject *parent = nullptr); virtual ~AVFVideoFrameRenderer(); @@ -115,12 +114,11 @@ private: CVPixelBufferRef copyPixelBufferFromLayer(AVPlayerLayer *layer, size_t& width, size_t& height); CVOGLTextureRef createCacheTextureFromLayer(AVPlayerLayer *layer, size_t& width, size_t& height); - QOpenGLContext *m_glContext; - QOffscreenSurface *m_offscreenSurface; - QAbstractVideoSurface *m_surface; - CVOGLTextureCacheRef m_textureCache; - AVPlayerItemVideoOutput* m_videoOutput; - bool m_isContextShared; + QOpenGLContext *m_glContext = nullptr; + QOffscreenSurface *m_offscreenSurface = nullptr; + CVOGLTextureCacheRef m_textureCache = nullptr; + AVPlayerItemVideoOutput* m_videoOutput = nil; + bool m_isContextShared = true; id<MTLDevice> m_metalDevice = nil; CVMetalTextureCacheRef m_metalTextureCache = nil; diff --git a/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol.mm b/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol.mm index da5f56875..75e687b81 100644 --- a/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol.mm +++ b/src/multimedia/platform/darwin/mediaplayer/avfvideorenderercontrol.mm @@ -47,7 +47,6 @@ #endif #include <private/qabstractvideobuffer_p.h> -#include <QtMultimedia/qabstractvideosurface.h> #include <QtMultimedia/qvideosurfaceformat.h> #include <private/qimagevideobuffer_p.h> diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol.cpp b/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol.cpp index 5862765b8..8399c6ea5 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol.cpp +++ b/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol.cpp @@ -66,18 +66,18 @@ MmRendererPlayerVideoRendererControl::~MmRendererPlayerVideoRendererControl() detachDisplay(); } -QAbstractVideoSurface *MmRendererPlayerVideoRendererControl::surface() const +QVideoSink *MmRendererPlayerVideoRendererControl::sink() const { - return m_surface; + return m_sink; } -void MmRendererPlayerVideoRendererControl::setSurface(QAbstractVideoSurface *surface) +void MmRendererPlayerVideoRendererControl::setSink(QVideoSink *surface) { - m_surface = QPointer<QAbstractVideoSurface>(surface); + m_sink = QPointer<QAbstractVideoSurface>(surface); if (QOpenGLContext::currentContext()) m_windowGrabber->checkForEglImageExtension(); - else if (m_surface) - m_surface->setProperty("_q_GLThreadCallback", QVariant::fromValue<QObject*>(this)); + else if (m_sink) + m_sink->setProperty("_q_GLThreadCallback", QVariant::fromValue<QObject*>(this)); } void MmRendererPlayerVideoRendererControl::attachDisplay(mmr_context_t *context) @@ -122,8 +122,8 @@ void MmRendererPlayerVideoRendererControl::detachDisplay() { m_windowGrabber->stop(); - if (m_surface) - m_surface->stop(); + if (m_sink) + m_sink->stop(); if (m_context && m_videoId != -1) mmr_output_detach(m_context, m_videoId); @@ -169,34 +169,15 @@ private: void MmRendererPlayerVideoRendererControl::updateScene(const QSize &size) { - if (m_surface) { - if (!m_surface->isActive()) { - if (m_windowGrabber->eglImageSupported()) { - m_surface->start(QVideoSurfaceFormat(size, QVideoSurfaceFormat::Format_BGR32, - QVideoFrame::GLTextureHandle)); - } else { - m_surface->start(QVideoSurfaceFormat(size, QVideoSurfaceFormat::Format_ARGB32)); - } - } else { - if (m_surface->surfaceFormat().frameSize() != size) { - m_surface->stop(); - if (m_windowGrabber->eglImageSupported()) { - m_surface->start(QVideoSurfaceFormat(size, QVideoSurfaceFormat::Format_BGR32, - QVideoFrame::GLTextureHandle)); - } else { - m_surface->start(QVideoSurfaceFormat(size, QVideoSurfaceFormat::Format_ARGB32)); - } - } - } - + if (m_sink) { // Depending on the support of EGL images on the current platform we either pass a texture // handle or a copy of the image data if (m_windowGrabber->eglImageSupported()) { QnxTextureBuffer *textBuffer = new QnxTextureBuffer(m_windowGrabber); - QVideoFrame actualFrame(textBuffer, size, QVideoSurfaceFormat::Format_BGR32); - m_surface->present(actualFrame); + QVideoFrame actualFrame(textBuffer, QVideoSurfaceFormat(size, QVideoSurfaceFormat::Format_BGR32)); + m_sink->newVideoFrame(actualFrame); } else { - m_surface->present(m_windowGrabber->getNextImage().copy()); + m_sink->newVideoFrame(m_windowGrabber->getNextImage().copy()); } } } diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol_p.h b/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol_p.h index ac5fd08f1..3c529e0b4 100644 --- a/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol_p.h +++ b/src/multimedia/platform/qnx/mediaplayer/mmrendererplayervideorenderercontrol_p.h @@ -51,7 +51,6 @@ // #include <QPointer> -#include <qabstractvideosurface.h> #include <qobject.h> typedef struct mmr_context mmr_context_t; @@ -59,6 +58,7 @@ typedef struct mmr_context mmr_context_t; QT_BEGIN_NAMESPACE class WindowGrabber; +class QVideoSink; class MmRendererPlayerVideoRendererControl : public QObject { @@ -67,8 +67,8 @@ public: explicit MmRendererPlayerVideoRendererControl(QObject *parent = 0); ~MmRendererPlayerVideoRendererControl(); - QAbstractVideoSurface *surface() const override; - void setSurface(QAbstractVideoSurface *surface) override; + QVideoSink *sink() const; + void setSink(QVideoSink *sink); // Called by media control void attachDisplay(mmr_context_t *context); @@ -82,7 +82,7 @@ private Q_SLOTS: void updateScene(const QSize &size); private: - QPointer<QAbstractVideoSurface> m_surface; + QPointer<QVideoSink> m_sink; WindowGrabber* m_windowGrabber; mmr_context_t *m_context; diff --git a/src/multimedia/platform/qplatformmediaplayer_p.h b/src/multimedia/platform/qplatformmediaplayer_p.h index 14babf462..1a7c4d65a 100644 --- a/src/multimedia/platform/qplatformmediaplayer_p.h +++ b/src/multimedia/platform/qplatformmediaplayer_p.h @@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE class QMediaStreamsControl; -class QAbstractVideoSurface; class Q_MULTIMEDIA_EXPORT QPlatformMediaPlayer { @@ -115,8 +114,7 @@ public: virtual QMediaMetaData metaData() const { return {}; } - virtual void setVideoSurface(QAbstractVideoSurface *) {} - virtual void setVideoSink(QVideoSink */*sink*/) {} + virtual void setVideoSink(QVideoSink */*sink*/) = 0; // media streams enum TrackType { VideoStream, AudioStream, SubtitleStream, NTrackTypes }; diff --git a/src/multimedia/platform/windows/evr/evrcustompresenter.cpp b/src/multimedia/platform/windows/evr/evrcustompresenter.cpp index c43382ed6..894f0b1be 100644 --- a/src/multimedia/platform/windows/evr/evrcustompresenter.cpp +++ b/src/multimedia/platform/windows/evr/evrcustompresenter.cpp @@ -45,7 +45,6 @@ #include <QtCore/qmutex.h> #include <QtCore/qvarlengtharray.h> #include <QtCore/qrect.h> -#include <qabstractvideosurface.h> #include <qthread.h> #include <qcoreapplication.h> #include <qmath.h> diff --git a/src/multimedia/platform/windows/evr/evrcustompresenter_p.h b/src/multimedia/platform/windows/evr/evrcustompresenter_p.h index 70a27d6a8..33efff89c 100644 --- a/src/multimedia/platform/windows/evr/evrcustompresenter_p.h +++ b/src/multimedia/platform/windows/evr/evrcustompresenter_p.h @@ -65,8 +65,6 @@ QT_BEGIN_NAMESPACE class EVRCustomPresenter; class D3DPresentEngine; -class QAbstractVideoSurface; - template<class T> class AsyncCallback : public IMFAsyncCallback { diff --git a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp index 39d202fe0..b7f96d42a 100644 --- a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp +++ b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp @@ -42,7 +42,6 @@ #include "evrhelpers_p.h" #include <private/qabstractvideobuffer_p.h> -#include <QAbstractVideoSurface> #include <qvideoframe.h> #include <QDebug> #include <qthread.h> diff --git a/src/multimedia/platform/windows/evr/evrd3dpresentengine_p.h b/src/multimedia/platform/windows/evr/evrd3dpresentengine_p.h index 8d5f91c8f..2c1ab8f83 100644 --- a/src/multimedia/platform/windows/evr/evrd3dpresentengine_p.h +++ b/src/multimedia/platform/windows/evr/evrd3dpresentengine_p.h @@ -71,8 +71,6 @@ static const GUID MFSamplePresenter_SampleCounter = QT_BEGIN_NAMESPACE -class QAbstractVideoSurface; - #ifdef MAYBE_ANGLE class OpenGLResources; diff --git a/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp b/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp index b9ea1dbb1..51b655f1b 100644 --- a/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp +++ b/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp @@ -840,7 +840,7 @@ namespace mediaType->Release(); continue; } - // QAbstractVideoSurface::supportedPixelFormats() returns formats in descending + // #### QAbstractVideoSurface::supportedPixelFormats() returns formats in descending // order of preference, while IMFMediaTypeHandler is supposed to return supported // formats in ascending order of preference. We need to reverse the list. m_pixelFormats.prepend(format); diff --git a/src/multimedia/playback/qmediaplayer.cpp b/src/multimedia/playback/qmediaplayer.cpp index 084cf9f47..be46703af 100644 --- a/src/multimedia/playback/qmediaplayer.cpp +++ b/src/multimedia/playback/qmediaplayer.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qmediaplayer_p.h" -#include "qvideosurfaces_p.h" #include <private/qplatformmediaintegration_p.h> diff --git a/src/multimedia/video/qabstractvideosurface.cpp b/src/multimedia/video/qabstractvideosurface.cpp deleted file mode 100644 index 74347ce27..000000000 --- a/src/multimedia/video/qabstractvideosurface.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//TESTED_COMPONENT=src/multimedia - -#include "qabstractvideosurface.h" - -#include "qvideosurfaceformat.h" - -#include <QtCore/qvariant.h> -#include <QDebug> - -QT_BEGIN_NAMESPACE - -class QAbstractVideoSurfacePrivate { -public: - QVideoSurfaceFormat surfaceFormat; - QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError; - QSize nativeResolution; - bool active = false; -}; - -/*! - \class QAbstractVideoSurface - \brief The QAbstractVideoSurface class is a base class for video presentation surfaces. - \inmodule QtMultimedia - - \ingroup multimedia - \ingroup multimedia_video - - The QAbstractVideoSurface class defines the standard interface that video producers use to - inter-operate with video presentation surfaces. You can subclass this interface to receive - video frames from sources like \l {QMediaPlayer}{decoded media} or \l {QCamera}{cameras} to - perform your own processing. - - A video surface presents a continuous stream of identically formatted QVideoFrame instances, where the format - of each frame is compatible with a stream format supplied when starting a presentation. Each frame - may have timestamp information that can be used by the surface to decide when to display that - frame. - - A list of pixel formats a surface can present is given by the supportedPixelFormats() function, - and the isFormatSupported() function will test if a video surface format is supported. If a - format is not supported the nearestFormat() function may be able to suggest a similar format. - For example, if a surface supports fixed set of resolutions it may suggest the smallest - supported resolution that contains the proposed resolution. - - The start() function takes a supported format and enables a video surface. Once started a - surface will begin displaying the frames it receives in the present() function. Surfaces may - hold a reference to the buffer of a presented video frame until a new frame is presented or - streaming is stopped. In addition, a video surface may hold a reference to a video frame - until the \l {QVideoFrame::endTime()}{end timestamp} has passed. The stop() function will - disable a surface and release any video buffers it holds references to. - - \section2 Implementing a subclass of QAbstractVideoSurface - - When implementing a subclass of this interface, there are only a handful of functions to - implement, broken down into two classes: - - \list - \li Format related - \li Presentation related - \endlist - - For format related functionality, you just have to describe the pixel formats that you - support (and the nearestFormat() function). For presentation related functionality, you - have to implement the present() function, and the start() and stop() functions. - - \note You must call the base class implementation of start() and stop() in your implementation. -*/ - -/*! - \enum QAbstractVideoSurface::Error - This enum describes the errors that may be returned by the error() function. - - \value NoError No error occurred. - \value UnsupportedFormatError A video format was not supported. - \value IncorrectFormatError A video frame was not compatible with the format of the surface. - \value StoppedError The surface has not been started. - \value ResourceError The surface could not allocate some resource. -*/ - -/*! - Constructs a video surface with the given \a parent. -*/ -QAbstractVideoSurface::QAbstractVideoSurface(QObject *parent) - : QObject(parent), - d_ptr(new QAbstractVideoSurfacePrivate) -{ -} - -/*! - Destroys a video surface. -*/ -QAbstractVideoSurface::~QAbstractVideoSurface() = default; - -/*! - \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 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. -*/ - -/*! - Tests a video surface \a format to determine if a surface can accept it. - - Returns true if the format is supported by the surface, and false otherwise. -*/ -bool QAbstractVideoSurface::isFormatSupported(const QVideoSurfaceFormat &format) const -{ - return supportedPixelFormats(QVideoFrame::NoHandle).contains(format.pixelFormat()); -} - -/*! - \fn QAbstractVideoSurface::supportedFormatsChanged() - - Signals that the set of formats supported by a video surface has changed. - - \sa supportedPixelFormats(), isFormatSupported() -*/ - -/*! - Returns the format of a video surface. -*/ -QVideoSurfaceFormat QAbstractVideoSurface::surfaceFormat() const -{ - Q_D(const QAbstractVideoSurface); - return d->surfaceFormat; -} - -/*! - \fn QAbstractVideoSurface::surfaceFormatChanged(const QVideoSurfaceFormat &format) - - Signals that the configured \a format of a video surface has changed. - - \sa surfaceFormat(), start() -*/ - -/*! - Starts a video surface presenting \a format frames. - - Returns true if the surface was started, and false if an error occurred. - - \note You must call the base class implementation of start() at the end of your implementation. - \sa isActive(), stop() -*/ -bool QAbstractVideoSurface::start(const QVideoSurfaceFormat &format) -{ - Q_D(QAbstractVideoSurface); - bool wasActive = d->active; - - d->active = true; - d->surfaceFormat = format; - d->error = NoError; - - emit surfaceFormatChanged(format); - - if (!wasActive) - emit activeChanged(true); - - return true; -} - -/*! - Stops a video surface presenting frames and releases any resources acquired in start(). - - \note You must call the base class implementation of stop() at the start of your implementation. - \sa isActive(), start() -*/ -void QAbstractVideoSurface::stop() -{ - Q_D(QAbstractVideoSurface); - if (d->active) { - d->surfaceFormat = QVideoSurfaceFormat(); - d->active = false; - - emit activeChanged(false); - emit surfaceFormatChanged(surfaceFormat()); - } -} - -/*! - Indicates whether a video surface has been started. - - Returns true if the surface has been started, and false otherwise. -*/ -bool QAbstractVideoSurface::isActive() const -{ - Q_D(const QAbstractVideoSurface); - return d->active; -} - -/*! - \fn QAbstractVideoSurface::activeChanged(bool active) - - Signals that the \a active state of a video surface has changed. - - \sa isActive(), start(), stop() -*/ - -/*! - \fn QAbstractVideoSurface::present(const QVideoFrame &frame) - - Presents a video \a frame. - - Returns true if the frame was presented, and false if an error occurred. - - Not all surfaces will block until the presentation of a frame has completed. Calling present() - on a non-blocking surface may fail if called before the presentation of a previous frame has - completed. In such cases the surface may not return to a ready state until it has had an - opportunity to process events. - - If present() fails for any other reason the surface should immediately enter the stopped state - and an error() value will be set. - - A video surface must be in the started state for present() to succeed, and the format of the - video frame must be compatible with the current video surface format. - - \sa error() -*/ - -/*! - Returns the last error that occurred. - - If a surface fails to start(), or stops unexpectedly this function can be called to discover - what error occurred. -*/ - -QAbstractVideoSurface::Error QAbstractVideoSurface::error() const -{ - Q_D(const QAbstractVideoSurface); - return d->error; -} - -/*! - Sets the value of error() to \a error. - - This can be called by implementors of this interface to communicate - what the most recent error was. -*/ -void QAbstractVideoSurface::setError(Error error) -{ - Q_D(QAbstractVideoSurface); - d->error = error; -} - -/*! - \property QAbstractVideoSurface::nativeResolution - - The native resolution of video surface. - This is the resolution of video frames the surface - can render with optimal quality and/or performance. - - The native resolution is not always known and can be changed during playback. - */ -QSize QAbstractVideoSurface::nativeResolution() const -{ - Q_D(const QAbstractVideoSurface); - return d->nativeResolution; -} - -/*! - Set the video surface native \a resolution. - - This function can be called by implementors of this interface to specify - to frame producers what the native resolution of this surface is. - */ -void QAbstractVideoSurface::setNativeResolution(const QSize &resolution) -{ - Q_D(QAbstractVideoSurface); - - if (d->nativeResolution != resolution) { - d->nativeResolution = resolution; - - emit nativeResolutionChanged(resolution); - } -} -/*! - \fn QAbstractVideoSurface::nativeResolutionChanged(const QSize &resolution); - - Signals the native \a resolution of video surface has changed. -*/ - -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QAbstractVideoSurface::Error& error) -{ - QDebugStateSaver saver(dbg); - dbg.nospace(); - switch (error) { - case QAbstractVideoSurface::UnsupportedFormatError: - dbg << "UnsupportedFormatError"; - break; - case QAbstractVideoSurface::IncorrectFormatError: - dbg << "IncorrectFormatError"; - break; - case QAbstractVideoSurface::StoppedError: - dbg << "StoppedError"; - break; - case QAbstractVideoSurface::ResourceError: - dbg << "ResourceError"; - break; - default: - dbg << "NoError"; - break; - } - return dbg; -} -#endif - - -QT_END_NAMESPACE - -#include "moc_qabstractvideosurface.cpp" - diff --git a/src/multimedia/video/qabstractvideosurface.h b/src/multimedia/video/qabstractvideosurface.h deleted file mode 100644 index a437d7565..000000000 --- a/src/multimedia/video/qabstractvideosurface.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTVIDEOSURFACE_H -#define QABSTRACTVIDEOSURFACE_H - -#include <QtCore/qobject.h> -#include <QtMultimedia/qvideoframe.h> - -QT_BEGIN_NAMESPACE - -class QRectF; -class QVideoSurfaceFormat; - -class QAbstractVideoSurfacePrivate; - -class Q_MULTIMEDIA_EXPORT QAbstractVideoSurface : public QObject -{ - Q_OBJECT - Q_PROPERTY(QSize nativeResolution READ nativeResolution NOTIFY nativeResolutionChanged) -public: - enum Error - { - NoError, - UnsupportedFormatError, - IncorrectFormatError, - StoppedError, - ResourceError - }; - - explicit QAbstractVideoSurface(QObject *parent = nullptr); - ~QAbstractVideoSurface(); - - virtual QList<QVideoSurfaceFormat::PixelFormat> supportedPixelFormats( - QVideoFrame::HandleType type = QVideoFrame::NoHandle) const = 0; - bool isFormatSupported(const QVideoSurfaceFormat &format) const; - - QVideoSurfaceFormat surfaceFormat() const; - - QSize nativeResolution() const; - - virtual bool start(const QVideoSurfaceFormat &format); - virtual void stop(); - - bool isActive() const; - - virtual bool present(const QVideoFrame &frame) = 0; - - Error error() const; - -Q_SIGNALS: - void activeChanged(bool active); - void surfaceFormatChanged(const QVideoSurfaceFormat &format); - void supportedFormatsChanged(); - void nativeResolutionChanged(const QSize &resolution); - -protected: - void setError(Error error); - void setNativeResolution(const QSize &resolution); - -private: - Q_DECLARE_PRIVATE(QAbstractVideoSurface) - QScopedPointer<QAbstractVideoSurfacePrivate> d_ptr; -}; - -#ifndef QT_NO_DEBUG_STREAM -Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QAbstractVideoSurface::Error &); -#endif - -QT_END_NAMESPACE - -#endif diff --git a/src/multimedia/video/qvideosurfaces.cpp b/src/multimedia/video/qvideosurfaces.cpp deleted file mode 100644 index b3e07fb26..000000000 --- a/src/multimedia/video/qvideosurfaces.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qvideosurfaces_p.h" - -QT_BEGIN_NAMESPACE - -QVideoSurfaces::QVideoSurfaces(const QList<QAbstractVideoSurface *> &s, QObject *parent) - : QAbstractVideoSurface(parent), m_surfaces(s) -{ - for (auto a : s) { - connect(a, &QAbstractVideoSurface::supportedFormatsChanged, this, [this, a] { - auto context = property("GLContext").value<QObject *>(); - if (!context) - setProperty("GLContext", a->property("GLContext")); - - emit supportedFormatsChanged(); - }); - } -} - -QVideoSurfaces::~QVideoSurfaces() = default; - -QList<QVideoSurfaceFormat::PixelFormat> QVideoSurfaces::supportedPixelFormats(QVideoFrame::HandleType type) const -{ - QList<QVideoSurfaceFormat::PixelFormat> result; - QMap<QVideoSurfaceFormat::PixelFormat, int> formats; - for (auto &s : m_surfaces) { - for (auto &p : s->supportedPixelFormats(type)) { - if (++formats[p] == m_surfaces.size()) - result << p; - } - } - - return result; -} - -bool QVideoSurfaces::start(const QVideoSurfaceFormat &format) -{ - bool result = true; - for (auto &s : m_surfaces) - result &= s->start(format); - - return result && QAbstractVideoSurface::start(format); -} - -void QVideoSurfaces::stop() -{ - for (auto &s : m_surfaces) - s->stop(); - - QAbstractVideoSurface::stop(); -} - -bool QVideoSurfaces::present(const QVideoFrame &frame) -{ - bool result = true; - for (auto &s : m_surfaces) - result &= s->present(frame); - - return result; -} - -QT_END_NAMESPACE diff --git a/src/multimedia/video/qvideosurfaces_p.h b/src/multimedia/video/qvideosurfaces_p.h deleted file mode 100644 index 4d9a8a9df..000000000 --- a/src/multimedia/video/qvideosurfaces_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QVIDEOSURFACES_P_H -#define QVIDEOSURFACES_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QAbstractVideoSurface> -#include <QList> - -QT_BEGIN_NAMESPACE - -class QVideoSurfaces : public QAbstractVideoSurface -{ -public: - QVideoSurfaces(const QList<QAbstractVideoSurface *> &surfaces, QObject *parent = nullptr); - ~QVideoSurfaces(); - - QList<QVideoSurfaceFormat::PixelFormat> supportedPixelFormats(QVideoFrame::HandleType type) const override; - bool start(const QVideoSurfaceFormat &format) override; - void stop() override; - bool present(const QVideoFrame &frame) override; - -private: - QList<QAbstractVideoSurface *> m_surfaces; - Q_DISABLE_COPY(QVideoSurfaces) -}; - -QT_END_NAMESPACE - -#endif // QVIDEOSURFACES_P_H diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_p.h b/src/qtmultimediaquicktools/qdeclarativevideooutput_p.h index 264744520..93bb8177e 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_p.h +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_p.h @@ -60,8 +60,6 @@ #include <private/qtmultimediaquickdefs_p.h> -Q_MOC_INCLUDE("QtMultimedia/qabstractvideosurface.h") - QT_BEGIN_NAMESPACE class QDeclarativeVideoBackend; diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h index 874b237ca..68c73f0c6 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render_p.h @@ -59,7 +59,6 @@ #include <private/qsgvideonode_texture_p.h> #include <QtCore/qmutex.h> -#include <QtMultimedia/qabstractvideosurface.h> QT_BEGIN_NAMESPACE diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp index f5226ffc6..70d893277 100644 --- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp @@ -32,7 +32,6 @@ #include <QtGui/QImageReader> #include <QDebug> -#include <qabstractvideosurface.h> #include <private/qplatformcamera_p.h> #include <private/qplatformcameraexposure_p.h> #include <private/qplatformcamerafocus_p.h> diff --git a/tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp b/tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp index 667194f41..23ee22d7c 100644 --- a/tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp +++ b/tests/auto/integration/qdeclarativevideooutput/tst_qdeclarativevideooutput.cpp @@ -33,17 +33,17 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QQuickView> +#include <QVideoSink> #include "private/qdeclarativevideooutput_p.h" -#include <qabstractvideosurface.h> #include <qobject.h> #include <qvideosurfaceformat.h> class SurfaceHolder : public QObject { Q_OBJECT - Q_PROPERTY(QAbstractVideoSurface *videoSurface READ videoSurface WRITE setVideoSurface) + Q_PROPERTY(QVideoSink *videoSurface READ videoSurface WRITE setVideoSurface) public: SurfaceHolder(QObject *parent) : QObject(parent) @@ -51,36 +51,30 @@ public: { } - [[nodiscard]] QAbstractVideoSurface *videoSurface() const + [[nodiscard]] QVideoSink *videoSurface() const { return m_surface; } - void setVideoSurface(QAbstractVideoSurface *surface) + void setVideoSurface(QVideoSink *surface) { - if (m_surface != surface && m_surface && m_surface->isActive()) { - m_surface->stop(); - } m_surface = surface; } void presentDummyFrame(const QSize &size); private: - QAbstractVideoSurface *m_surface; + QVideoSink *m_surface; }; // Starts the surface and puts a frame void SurfaceHolder::presentDummyFrame(const QSize &size) { - if (m_surface && m_surface->supportedPixelFormats().count() > 0) { - QVideoSurfaceFormat::PixelFormat pixelFormat = m_surface->supportedPixelFormats().value(0); - QVideoSurfaceFormat format(size, pixelFormat); - QVideoFrame frame(size.width() * size.height() * 4, size.width() * 4, QVideoSurfaceFormat(size, pixelFormat)); + if (m_surface) { + QVideoSurfaceFormat format(size, QVideoSurfaceFormat::Format_ARGB32_Premultiplied); + QVideoFrame frame(size.width() * size.height() * 4, size.width() * 4, format); - if (!m_surface->isActive()) - m_surface->start(format); - m_surface->present(frame); + m_surface->newVideoFrame(frame); // Have to spin an event loop or two for the surfaceFormatChanged() signal qApp->processEvents(); @@ -266,41 +260,23 @@ void tst_QDeclarativeVideoOutput::surfaceSource() SurfaceHolder holder(this); - QCOMPARE(holder.videoSurface(), static_cast<QAbstractVideoSurface*>(nullptr)); + QCOMPARE(holder.videoSurface(), static_cast<QVideoSink *>(nullptr)); videoOutput->setProperty("source", QVariant::fromValue(static_cast<QObject*>(&holder))); QVERIFY(holder.videoSurface() != nullptr); - // Now we could do things with the surface.. - const QList<QVideoSurfaceFormat::PixelFormat> formats = holder.videoSurface()->supportedPixelFormats(); - QVERIFY(formats.count() > 0); - - // See if we can start and stop each pixel format (..) - for (QVideoSurfaceFormat::PixelFormat format : formats) { - QVideoSurfaceFormat surfaceFormat(QSize(200,100), format); - QVERIFY(holder.videoSurface()->isFormatSupported(surfaceFormat)); // This does kind of depend on node factories - - QVERIFY(holder.videoSurface()->start(surfaceFormat)); - QVERIFY(holder.videoSurface()->surfaceFormat() == surfaceFormat); - QVERIFY(holder.videoSurface()->isActive()); - - holder.videoSurface()->stop(); - - QVERIFY(!holder.videoSurface()->isActive()); - } - delete videoOutput; // This should clear the surface - QCOMPARE(holder.videoSurface(), static_cast<QAbstractVideoSurface*>(nullptr)); + QCOMPARE(holder.videoSurface(), static_cast<QVideoSink *>(nullptr)); // Also, creating two sources, setting them in order, and destroying the first // should not zero holder.videoSurface() videoOutput = component.create(); videoOutput->setProperty("source", QVariant::fromValue(static_cast<QObject*>(&holder))); - QAbstractVideoSurface *surface = holder.videoSurface(); + QVideoSink *surface = holder.videoSurface(); QVERIFY(holder.videoSurface()); QObject *videoOutput2 = component.create(); @@ -320,7 +296,7 @@ void tst_QDeclarativeVideoOutput::surfaceSource() SurfaceHolder holder2(this); videoOutput2->setProperty("source", QVariant::fromValue(static_cast<QObject*>(&holder2))); - QCOMPARE(holder.videoSurface(), static_cast<QAbstractVideoSurface*>(nullptr)); + QCOMPARE(holder.videoSurface(), static_cast<QVideoSink*>(nullptr)); QVERIFY(holder2.videoSurface() != nullptr); // Finally a combination - set the same source to two things, then assign a new source @@ -358,17 +334,12 @@ void tst_QDeclarativeVideoOutput::paintSurface() auto videoOutput = qobject_cast<QDeclarativeVideoOutput *>(window.rootObject()); QVERIFY(videoOutput); - auto surface = videoOutput->property("videoSurface").value<QAbstractVideoSurface *>(); + auto surface = videoOutput->property("videoSurface").value<QVideoSink *>(); QVERIFY(surface); - QVERIFY(!surface->isActive()); videoOutput->setSize(QSize(2, 2)); - QVideoSurfaceFormat format(QSize(2, 2), QVideoSurfaceFormat::Format_RGB32); - QVERIFY(surface->isFormatSupported(format)); - QVERIFY(surface->start(format)); - QVERIFY(surface->isActive()); QImage img(rgb32ImageData, 2, 2, 8, QImage::Format_RGB32); - QVERIFY(surface->present(img)); + surface->newVideoFrame(img); } void tst_QDeclarativeVideoOutput::sourceRect() diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index 8fd6cf19c..a99687f22 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -28,12 +28,12 @@ #include <QtTest/QtTest> #include <QDebug> -#include <qabstractvideosurface.h> #include "qmediaplayer.h" #include <qmediaplaylist.h> #include <qmediametadata.h> #include <qaudiobuffer.h> #include <qvideosink.h> +#include <qvideoframe.h> #include "../shared/mediafileselector.h" //TESTED_COMPONENT=src/multimedia @@ -120,7 +120,6 @@ public: private: bool m_storeFrames; - QList<QVideoSurfaceFormat::PixelFormat> m_supported; }; void tst_QMediaPlayerBackend::init() diff --git a/tests/auto/unit/mockbackend/mockcameracontrol.h b/tests/auto/unit/mockbackend/mockcameracontrol.h index 7ca6ece88..f5aca2675 100644 --- a/tests/auto/unit/mockbackend/mockcameracontrol.h +++ b/tests/auto/unit/mockbackend/mockcameracontrol.h @@ -77,8 +77,6 @@ public: m_camera = camera; } - void setVideoSurface(QAbstractVideoSurface *) {} - bool m_active = false; QCamera::Status m_status; QCameraInfo m_camera; diff --git a/tests/auto/unit/mockbackend/mockmediaplayer.h b/tests/auto/unit/mockbackend/mockmediaplayer.h index 049932082..495e668ad 100644 --- a/tests/auto/unit/mockbackend/mockmediaplayer.h +++ b/tests/auto/unit/mockbackend/mockmediaplayer.h @@ -148,6 +148,8 @@ public: << QStringLiteral("customRole2"); } + void setVideoSink(QVideoSink *) {} + void emitError(QMediaPlayer::Error err, const QString &errorString) { emit error(err, errorString); diff --git a/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp b/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp index cd00a634d..9cc815e3e 100644 --- a/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp +++ b/tests/auto/unit/multimediawidgets/qcamerawidgets/tst_qcamerawidgets.cpp @@ -31,7 +31,6 @@ #include <QtTest/QtTest> #include <QDebug> -#include <qabstractvideosurface.h> #include <private/qplatformcamera_p.h> #include <private/qplatformcameraexposure_p.h> #include <private/qplatformcamerafocus_p.h> diff --git a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp index aff23c11e..7cf9a9b00 100644 --- a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp +++ b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp @@ -37,7 +37,6 @@ #include "qmediaservice.h" #include <private/qpaintervideosurface_p.h> -#include <qabstractvideosurface.h> #include <qvideosurfaceformat.h> #include <QtWidgets/qapplication.h> |