Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QAbstractVideoBuffer Class Referenceabstract

The QAbstractVideoBuffer class is an abstraction for video data. \inmodule QtMultimedia. More...

#include <qabstractvideobuffer_p.h>

+ Inheritance diagram for QAbstractVideoBuffer:
+ Collaboration diagram for QAbstractVideoBuffer:

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.
 
QRhirhi () 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< QVideoFrameTexturesmapTextures (QRhi *)
 
virtual quint64 textureHandle (QRhi *, int) const
 Returns a texture handle to the data buffer.
 
virtual QMatrix4x4 externalTextureMatrix () const
 
virtual QByteArray underlyingByteArray (int) const
 

Protected Attributes

QVideoFrame::HandleType m_type
 
QRhim_rhi = nullptr
 

Detailed Description

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.

See also
QVideoFrame

Definition at line 41 of file qabstractvideobuffer_p.h.

Constructor & Destructor Documentation

◆ QAbstractVideoBuffer()

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.

◆ ~QAbstractVideoBuffer()

QAbstractVideoBuffer::~QAbstractVideoBuffer ( )
virtual

Destroys an abstract video buffer.

Definition at line 89 of file qabstractvideobuffer.cpp.

Member Function Documentation

◆ externalTextureMatrix()

virtual QMatrix4x4 QAbstractVideoBuffer::externalTextureMatrix ( ) const
inlinevirtual

Definition at line 65 of file qabstractvideobuffer_p.h.

◆ handleType()

QVideoFrame::HandleType QAbstractVideoBuffer::handleType ( ) const

Returns the type of a video buffer's handle.

See also
handle()

Definition at line 98 of file qabstractvideobuffer.cpp.

References m_type.

◆ map()

uchar * QAbstractVideoBuffer::map ( QVideoFrame::MapMode mode)
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.

Since
5.4

Implemented in AVFVideoBuffer, QImageVideoBuffer, QMemoryVideoBuffer, AndroidTextureVideoBuffer, QCGImageVideoBuffer, QD3D11TextureVideoBuffer, QFFmpegVideoBuffer, QOpenGLVideoBuffer, QGstVideoBuffer, QQnxCameraFrameBuffer, ImageFromVideoFrameHelper, QnxTextureBuffer, and QnxRasterBuffer.

◆ mapMode()

◆ mapTextures()

virtual std::unique_ptr< QVideoFrameTextures > QAbstractVideoBuffer::mapTextures ( QRhi * )
inlinevirtual

◆ rhi()

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(), ImageFromVideoFrameHelper::mapTextures(), and QFFmpegVideoBuffer::textureHandle().

+ Here is the caller graph for this function:

◆ textureHandle()

quint64 QAbstractVideoBuffer::textureHandle ( QRhi * rhi,
int plane ) const
inlinevirtual

Returns a texture handle to the data buffer.

See also
handleType()

Reimplemented in AVFVideoBuffer, QOpenGLVideoBuffer, QnxTextureBuffer, and QFFmpegVideoBuffer.

Definition at line 63 of file qabstractvideobuffer_p.h.

◆ underlyingByteArray()

virtual QByteArray QAbstractVideoBuffer::underlyingByteArray ( int ) const
inlinevirtual

Reimplemented in QMemoryVideoBuffer.

Definition at line 67 of file qabstractvideobuffer_p.h.

◆ unmap()

QAbstractVideoBuffer::unmap ( )
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.

See also
map()

Implemented in AVFVideoBuffer, QImageVideoBuffer, QMemoryVideoBuffer, AndroidTextureVideoBuffer, ImageFromVideoFrameHelper, QCGImageVideoBuffer, QD3D11TextureVideoBuffer, QFFmpegVideoBuffer, QOpenGLVideoBuffer, QGstVideoBuffer, QQnxCameraFrameBuffer, QnxTextureBuffer, and QnxRasterBuffer.

Member Data Documentation

◆ m_rhi

QRhi* QAbstractVideoBuffer::m_rhi = nullptr
protected

Definition at line 70 of file qabstractvideobuffer_p.h.

Referenced by rhi(), and AVFVideoBuffer::textureHandle().

◆ m_type

QVideoFrame::HandleType QAbstractVideoBuffer::m_type
protected

The documentation for this class was generated from the following files: