summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-10-22 14:29:44 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-01-05 16:05:47 +0100
commit8c9676fb0bb145704b7e8bdaf7832c03f14b47de (patch)
tree427519b54a43ab063531c9a7d3d1f8181e9ca0de /src/multimedia
parente530c303d8d9164888f8d6e1a935b81cda8bf426 (diff)
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 <paul.wicking@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/doc/snippets/multimedia-snippets/video.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/video.cpp b/src/multimedia/doc/snippets/multimedia-snippets/video.cpp
index 3c14f7009..46327e3d6 100644
--- a/src/multimedia/doc/snippets/multimedia-snippets/video.cpp
+++ b/src/multimedia/doc/snippets/multimedia-snippets/video.cpp
@@ -117,6 +117,7 @@ public:
void VideoWidget();
void VideoWindowControl();
void VideoWidgetControl();
+ void VideoSurface();
private:
// Common naming
@@ -163,6 +164,28 @@ void VideoExample::VideoWidget()
//! [Setting surface in player]
}
+void VideoExample::VideoSurface()
+{
+ //! [Widget Surface]
+ QImage img = QImage("images/qt-logo.png").convertToFormat(QImage::Format_ARGB32);
+ QVideoSurfaceFormat format(img.size(), QVideoFrame::Format_ARGB32);
+ videoWidget = new QVideoWidget;
+ videoWidget->videoSurface()->start(format);
+ videoWidget->videoSurface()->present(img);
+ videoWidget->show();
+ //! [Widget Surface]
+
+ //! [GraphicsVideoItem Surface]
+ QGraphicsVideoItem *item = new QGraphicsVideoItem;
+ graphicsView->scene()->addItem(item);
+ graphicsView->show();
+ QImage img = QImage("images/qt-logo.png").convertToFormat(QImage::Format_ARGB32);
+ QVideoSurfaceFormat format(img.size(), QVideoFrame::Format_ARGB32);
+ item->videoSurface()->start(format);
+ item->videoSurface()->present(img);
+ //! [GraphicsVideoItem Surface]
+}
+
void VideoExample::VideoWidgetControl()
{
//! [Video widget control]