qtvideosink and its variants are elements that provide native video drawing support for Qt surfaces. qtvideosink and qwidgetvideosink do software painting, using QImage and QPainter. qtglvideosink and qtquick2videosink use OpenGL/OpenGLES and support hardware colorspace conversion and color balance.
The API of qtvideosink and qtglvideosink is the same, except that qtglvideosink has an extra "glcontext" property that must be set with the surface's QGLContext pointer as early as possible after construction.
qwidgetvideosink has the same features as qtvideosink, but a different API. In qwidgetvideosink, you can set a QWidget pointer directly to its "widget" property and it will paint in this widget, without any further tampering, while in qtvideosink you need to handle its signals.
qtquick2videosink has a similar concept to qtvideosink, but it uses the new scene-graph architecture for drawing in QtQuick items instead of using QPainter.
All 4 elements require a running Qt event loop and have the inherited limitation from Qt that they must be created, destroyed and have their signals and properties handled from the main (GUI) thread.
When drawing video on QtQuick1 (QML) or QGraphicsView, it is recommended to use qtglvideosink, if possible, and fall back to qtvideosink otherwise. When drawing on QWidgets, it is recommended to embed the platform's hardware accelerated sink, such as xvimagesink on X11, and if this is not possible, use qwidgetvideosink. Finally, when drawing on QtQuick2 (Qt5), the only way is to use qtquick2videosink.
All 4 elements are independent of the QtGStreamer libraries and can be built and used without them. However, QtGStreamer provides helper integration classes that you may find useful.
qtvideosink and qtglvideosink provide two signals, an action signal (a slot in Qt terminology) called “paint” and a normal signal called “update”. “update” is emitted every time the sink needs the surface to be repainted. This is meant to be connected directly to QWidget::update() or QGraphicsItem::update() or something similar. The “paint” slot takes a QPainter pointer and a rectangle (x, y, width, height as qreals) as its arguments and paints the video inside the given rectangle using the given painter. This is meant to be called from the widget’s paint event or the graphics item’s paint() function. All you need to do is to take care of those two signals and qtvideosink/qtglvideosink will do everything else.
qtglvideosink also requires an initialization with the surface's QGLContext pointer. In addition, it is wise to try to make it READY before using it, to verify that the required OpenGL features are supported by the hardware. If this fails, it is sensible to fall back to qtvideosink, which can be used with the same API.
If you are using the QtGStreamer libraries in your applications, you can directly use QGst::Ui::VideoWidget to embed any of the 3 first variants (i.e. except the qtquick2 one) in a QWidget, or QGst::Ui::GraphicsVideoWidget with QGst::Ui::GraphicsVideoSurface to paint on a QGraphicsView.
If you are using QtQuick (either QtQuick1 with Qt4 or Qt5, or QtQuick2 with Qt5), there is also a "VideoItem" element available when you import "QtGStreamer 1.0". See the qmlplayer and qmlplayer2 examples for details.
When QtGStreamer is compiled with Qt5, the first 3 elements are named:
This is done to allow them to be parallel installable to their Qt4 counterparts and to avoid Qt version mixing through gstreamer's plugin loading.