From 8c9676fb0bb145704b7e8bdaf7832c03f14b47de Mon Sep 17 00:00:00 2001 From: VaL Doroshchuk Date: Tue, 22 Oct 2019 14:29:44 +0200 Subject: Expose video surfaces in rendering components * Currently QVideoWidget, QGraphicsVideoItem and QML Video Output tightly depend on QMediaPlayer, QMediaService etc. Since QMediaService is deprecated and will be removed from Qt6, its usage must be removed from rendering components. * Also it is a part of a task to make all components independent, e.g. without dependencies to another components, like the media player, or video producer. These video consumer components should be reusable without QMediaPlayer too, which today is not possible, and should have responsibility for a single part of the functionality. * It is a part of a task to allow users to decide how to render video, using either video surface or native windows. Introducing QVideoWidget::videoSurface() QGraphicsVideoItem::videoSurface() QDeclarativeVideoOutput::videoSurface() that create a surface, if necessary, and returns the underlying video surface which provides a possibility to render video frames without knowledge of any services and controls. Can be used like: QMediaPlayer->setVideoOutput(QVideoWidget->videoSurface()); or QMediaPlayer->setVideoOutput(QGraphicsVideoItem->videoSurface()); This allows QMediaPlayer to get video frames from a backend, without using QVideoWidget/QGraphicsVideoItem, and to present these frames to provided surface. Moreover, now it is possible to render video frames without QMediaPlayer: QVideoSurfaceFormat format(img.size(), QVideoFrame::Format_ARGB32); videoWidget->videoSurface()->start(format); videoWidget->videoSurface()->present(img); [ChangeLog] Introduced videoSurface property to QVideoWidget, QGraphicsVideoItem and QDeclarativeVideoOutput. Task-number: QTBUG-80431 Change-Id: I49641750537160832e29c297279e72b8288e974c Reviewed-by: Paul Wicking --- src/multimediawidgets/qgraphicsvideoitem.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/multimediawidgets/qgraphicsvideoitem.cpp') diff --git a/src/multimediawidgets/qgraphicsvideoitem.cpp b/src/multimediawidgets/qgraphicsvideoitem.cpp index 2db8987fb..fae1f9048 100644 --- a/src/multimediawidgets/qgraphicsvideoitem.cpp +++ b/src/multimediawidgets/qgraphicsvideoitem.cpp @@ -231,6 +231,22 @@ QMediaObject *QGraphicsVideoItem::mediaObject() const return d_func()->mediaObject; } +/*! + \since 5.15 + \property QGraphicsVideoItem::videoSurface + \brief Returns the underlying video surface that can render video frames + to the current item. + This property is never \c nullptr. + Example of how to render video frames to QGraphicsVideoItem: + \snippet multimedia-snippets/video.cpp GraphicsVideoItem Surface + \sa QMediaPlayer::setVideoOutput +*/ + +QAbstractVideoSurface *QGraphicsVideoItem::videoSurface() const +{ + return d_func()->surface; +} + /*! \internal */ -- cgit v1.2.3