![]() |
Qt 6.x
The Qt SDK
|
The QAbstractVideoBuffer class is an abstraction for video data. \inmodule QtMultimedia. More...
#include <qabstractvideobuffer_p.h>
Classes | |
struct | MapData |
Public Member Functions | |
QAbstractVideoBuffer (QVideoFrame::HandleType type, QRhi *rhi=nullptr) | |
Constructs an abstract video buffer of the given type. | |
virtual | ~QAbstractVideoBuffer () |
Destroys an abstract video buffer. | |
QVideoFrame::HandleType | handleType () const |
Returns the type of a video buffer's handle. | |
QRhi * | rhi () const |
Returns the QRhi instance. | |
virtual QVideoFrame::MapMode | mapMode () const =0 |
virtual MapData | map (QVideoFrame::MapMode mode)=0 |
Independently maps the planes of a video buffer to memory. | |
virtual void | unmap ()=0 |
Releases the memory mapped by the map() function. | |
virtual std::unique_ptr< QVideoFrameTextures > | mapTextures (QRhi *) |
virtual quint64 | textureHandle (int) const |
Returns a texture handle to the data buffer. | |
virtual QMatrix4x4 | externalTextureMatrix () const |
Protected Attributes | |
QVideoFrame::HandleType | m_type |
QRhi * | m_rhi = nullptr |
The QAbstractVideoBuffer class is an abstraction for video data. \inmodule QtMultimedia.
The QVideoFrame class makes use of a QAbstractVideoBuffer internally to reference a buffer of video data. Quite often video data buffers may reside in video memory rather than system memory, and this class provides an abstraction of the location.
In addition, creating a subclass of QAbstractVideoBuffer will allow you to construct video frames from preallocated or static buffers. This caters for cases where the QVideoFrame constructors taking a QByteArray or a QImage do not suffice. This may be necessary when implementing a new hardware accelerated video system, for example.
The contents of a buffer can be accessed by mapping the buffer to memory using the map() function, which returns a pointer to memory containing the contents of the video buffer. The memory returned by map() is released by calling the unmap() function.
The handle() of a buffer may also be used to manipulate its contents using type specific APIs. The type of a buffer's handle is given by the handleType() function.
Definition at line 41 of file qabstractvideobuffer_p.h.
QAbstractVideoBuffer::QAbstractVideoBuffer | ( | QVideoFrame::HandleType | type, |
QRhi * | rhi = nullptr |
||
) |
Constructs an abstract video buffer of the given type.
Definition at line 80 of file qabstractvideobuffer.cpp.
|
virtual |
Destroys an abstract video buffer.
Definition at line 89 of file qabstractvideobuffer.cpp.
|
inlinevirtual |
Definition at line 65 of file qabstractvideobuffer_p.h.
QVideoFrame::HandleType QAbstractVideoBuffer::handleType | ( | ) | const |
Returns the type of a video buffer's handle.
Definition at line 98 of file qabstractvideobuffer.cpp.
References m_type.
Referenced by QVideoFrame::handleType().
|
pure virtual |
Independently maps the planes of a video buffer to memory.
The map mode indicates whether the contents of the mapped memory should be read from and/or written to the buffer. If the map mode includes the QVideoFrame::ReadOnly
flag the mapped memory will be populated with the content of the buffer when initially mapped. If the map mode includes the QVideoFrame::WriteOnly
flag the content of the possibly modified mapped memory will be written back to the buffer when unmapped.
When access to the data is no longer needed be sure to call the unmap() function to release the mapped memory and possibly update the buffer contents.
Returns the number of planes in the mapped video data. For each plane the line stride of that plane will be returned in bytesPerLine, and a pointer to the plane data will be returned in data. The accumulative size of the mapped data is returned in numBytes.
Not all buffer implementations will map more than the first plane, if this returns a single plane for a planar format the additional planes will have to be calculated from the line stride of the first plane and the frame height. Mapping a buffer with QVideoFrame will do this for you.
To implement this function create a derivative of QAbstractPlanarVideoBuffer and implement its map function instance instead.
Implemented in AVFVideoBuffer, QMemoryVideoBuffer, AndroidTextureVideoBuffer, QCGImageVideoBuffer, QD3D11TextureVideoBuffer, QFFmpegVideoBuffer, QUwpTextureVideoBuffer, QT_BEGIN_NAMESPACE::QImageVideoBuffer, QV4L2VideoBuffer, QGstVideoBuffer, QQnxCameraFrameBuffer, QT_BEGIN_NAMESPACE::MediaSampleVideoBuffer, ImageFromVideoFrameHelper, QnxTextureBuffer, and QnxRasterBuffer.
Referenced by QVideoFrame::map().
|
pure virtual |
Implemented in AVFVideoBuffer, QMemoryVideoBuffer, AndroidTextureVideoBuffer, ImageFromVideoFrameHelper, QCGImageVideoBuffer, QD3D11TextureVideoBuffer, QFFmpegVideoBuffer, QUwpTextureVideoBuffer, QT_BEGIN_NAMESPACE::QImageVideoBuffer, QV4L2VideoBuffer, QGstVideoBuffer, QQnxCameraFrameBuffer, QnxTextureBuffer, QnxRasterBuffer, and QT_BEGIN_NAMESPACE::MediaSampleVideoBuffer.
Referenced by QVideoFrame::isMapped(), QVideoFrame::isReadable(), QVideoFrame::isWritable(), QVideoFrame::map(), and QVideoFrame::mapMode().
|
inlinevirtual |
Reimplemented in QFFmpegVideoBuffer, QGstVideoBuffer, AndroidTextureVideoBuffer, and ImageFromVideoFrameHelper.
Definition at line 62 of file qabstractvideobuffer_p.h.
Referenced by QVideoTextureHelper::createTextures().
QRhi * QAbstractVideoBuffer::rhi | ( | ) | const |
Returns the QRhi instance.
Definition at line 106 of file qabstractvideobuffer.cpp.
References m_rhi.
Referenced by QGstVideoBuffer::mapTextures(), AndroidTextureVideoBuffer::mapTextures(), and ImageFromVideoFrameHelper::mapTextures().
|
inlinevirtual |
Returns a texture handle to the data buffer.
Reimplemented in AVFVideoBuffer, QFFmpegVideoBuffer, and QnxTextureBuffer.
Definition at line 63 of file qabstractvideobuffer_p.h.
|
pure virtual |
Releases the memory mapped by the map() function.
If the \l {QVideoFrame::MapMode}{MapMode} included the QVideoFrame::WriteOnly
flag this will write the current content of the mapped memory back to the video frame.
Implemented in AVFVideoBuffer, QMemoryVideoBuffer, AndroidTextureVideoBuffer, ImageFromVideoFrameHelper, QCGImageVideoBuffer, QD3D11TextureVideoBuffer, QFFmpegVideoBuffer, QUwpTextureVideoBuffer, QT_BEGIN_NAMESPACE::QImageVideoBuffer, QV4L2VideoBuffer, QGstVideoBuffer, QQnxCameraFrameBuffer, QnxTextureBuffer, QnxRasterBuffer, and QT_BEGIN_NAMESPACE::MediaSampleVideoBuffer.
Referenced by QVideoFrame::unmap().
Definition at line 68 of file qabstractvideobuffer_p.h.
Referenced by rhi(), and AVFVideoBuffer::textureHandle().
|
protected |
Definition at line 67 of file qabstractvideobuffer_p.h.
Referenced by handleType(), and QFFmpegVideoBuffer::setTextureConverter().