QVideoSink Class
The QVideoSink class represents a generic sink for video data. More...
Header: | #include <QVideoSink> |
CMake: | find_package(Qt6 COMPONENTS Multimedia REQUIRED) target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
qmake: | QT += multimedia |
Inherits: | QObject |
Public Functions
QVideoSink(QObject *parent = nullptr) | |
virtual | ~QVideoSink() |
bool | isFullScreen() const |
WId | nativeWindowId() const |
void | paint(QPainter *painter, const QVideoFrame &f) |
void | setFullScreen(bool fullscreen) |
void | setNativeWindowId(WId id) |
QSize | videoSize() const |
Detailed Description
The QVideoSink class can be used to retrieve video data on a frame by frame basis from Qt Multimedia.
QVideoSink can operate in two modes. In the first mode, it can render the video stream to a native window of the underlying windowing system. In the other mode, it will provide individual video frames to the application developer through the newVideoFrame() signal.
The video frame can then be used to read out the data of those frames and handle them further. When using QPainter, the QVideoFrame can be drawing using the paint() method in QVideoSink.
QVideoFrame objects can consume a significant amount of memory or system resources and should thus not be held for longer than required by the application.
See also QMediaPlayer and QMediaCaptureSession.
Member Function Documentation
QVideoSink::QVideoSink(QObject *parent = nullptr)
Constructs a new QVideoSink object with parent.
[virtual]
QVideoSink::~QVideoSink()
Destroys the object.
bool QVideoSink::isFullScreen() const
Returns true when rendering full screen.
WId QVideoSink::nativeWindowId() const
Returns the native window id that the sink is currently rendering to.
See also setNativeWindowId().
void QVideoSink::paint(QPainter *painter, const QVideoFrame &f)
Use a QPainter to render the QVideoFrame f. Rendering will usually happen in without hardware acceleration when using this method.
void QVideoSink::setFullScreen(bool fullscreen)
Render the video full screen. This is often more resource efficient than rendering to only parts of the screen.
The newVideoFrame() signal will never get emitted when rendering full screen.
See also isFullScreen().
void QVideoSink::setNativeWindowId(WId id)
Tells QVideoSink to render directly to the native window id. This is usually more resource efficient than rendering individual video frames.
The newVideoFrame() signal will never get emitted in this mode.
Setting id to 0 will stop rendering to a native window.
See also nativeWindowId().
QSize QVideoSink::videoSize() const
Returns the size of the video currently being played back. If no video is being played, this method returns an invalid size.