VART-X  0.3.0
vart::VideoFrame Class Reference

This module simplifies the management of video frame memory and provides APIs for mapping and unmapping frame data to user space to read and write. The VideoFrame class offers flexibility for applications to encapsulate their own memory into the VideoFrame class. In such instances, the application bears the responsibility for deallocating the frame memory. More...

#include <vart_videoframe.hpp>

Public Member Functions

 VideoFrame (VideoFrameImplType type, size_t size, uint8_t mbank_idx, VideoInfo &vinfo, std::shared_ptr< Device > device)
 VideoFrame() - Constructor for creating video frame instance using implementation specific method based on input 'type'. More...
 
 VideoFrame (VideoFrameImplType type, std::vector< uint8_t * > &data_vec, VideoInfo &vinfo, std::shared_ptr< Device > device)
 VideoFrame() - Constructor for creating video frame instance using input data pointers. More...
 
 VideoFrame (VideoFrameImplType type, uint8_t mbank_idx, std::vector< xrt::bo * > &bo_vec, VideoInfo &vinfo, std::shared_ptr< Device > device)
 VideoFrame() - Constructor for creating video frame instance using input XRT Buffer object(BO) More...
 
 VideoFrame (VideoFrameImplType type, int dma_buf_fd, VideoInfo &vinfo, std::shared_ptr< Device > device)
 VideoFrame() - Constructor to create VideoFrame from a dma-buf fd. More...
 
 ~VideoFrame ()=default
 
const VideoFrameMapInfomap (DataMapFlags map_flags)
 map() - Maps video frame data to user space More...
 
void unmap ()
 unmap() - Unmaps video frame data from user space More...
 
const VideoInfoget_video_info () const
 get_video_info() - Retrieves the video frame information from video frame. More...
 
std::shared_ptr< Deviceget_device_handle () const
 get_device_handle() - Retrieves the device handle associated with the current frame More...
 
const std::shared_ptr< VideoFrameImplBase > & get_pimpl_handle () const
 get_pimpl_handle() - Retrieves pointer to implementation class. More...
 
int export_buffer () const
 export_buffer() - Export the video frame buffer as a dma-buf file descriptor. More...
 

Detailed Description

This module simplifies the management of video frame memory and provides APIs for mapping and unmapping frame data to user space to read and write. The VideoFrame class offers flexibility for applications to encapsulate their own memory into the VideoFrame class. In such instances, the application bears the responsibility for deallocating the frame memory.

See also
VideoFrameImplBase

Constructor & Destructor Documentation

◆ VideoFrame() [1/4]

vart::VideoFrame::VideoFrame ( VideoFrameImplType  type,
size_t  size,
uint8_t  mbank_idx,
VideoInfo vinfo,
std::shared_ptr< Device device 
)

VideoFrame() - Constructor for creating video frame instance using implementation specific method based on input 'type'.

Parameters
[in]typeEnum class to specify which type of memory allocation method to use
[in]sizeSize of the buffer
[in]mbank_idxMemory bank index on which memory needs to be allocated
[in]vinfoVideoInfo instance which contains video frame specific information
[in]deviceDevice handle. Must be non-null. See vart::Device for more details.

◆ VideoFrame() [2/4]

vart::VideoFrame::VideoFrame ( VideoFrameImplType  type,
std::vector< uint8_t * > &  data_vec,
VideoInfo vinfo,
std::shared_ptr< Device device 
)

VideoFrame() - Constructor for creating video frame instance using input data pointers.

Parameters
[in]typeEnum class to specify which type of memory allocation method to use
[in]data_vecVector of user allocated buffer pointers
[in]vinfoVideoInfo instance which contains video frame specific information
[in]deviceDevice handle to be used by implementation. Must be non-null. See vart::Device for more details.
Note
type must be VideoFrameImplType::NON_CMA. Any other type will throw a std::runtime_error.

◆ VideoFrame() [3/4]

vart::VideoFrame::VideoFrame ( VideoFrameImplType  type,
uint8_t  mbank_idx,
std::vector< xrt::bo * > &  bo_vec,
VideoInfo vinfo,
std::shared_ptr< Device device 
)

VideoFrame() - Constructor for creating video frame instance using input XRT Buffer object(BO)

Parameters
[in]typeEnum class to specify which type of memory allocation method to use
[in]mbank_idxMemory bank index on which memory was allocated
[in]bo_vecVector of XRT BOs allocated by user
[in]vinfoVideoInfo instance which contains video frame specific information
[in]deviceDevice handle to be used by implementation. Must be non-null. See vart::Device for more details.
Note
type must be VideoFrameImplType::XRT. Any other type will throw a std::runtime_error.

◆ VideoFrame() [4/4]

vart::VideoFrame::VideoFrame ( VideoFrameImplType  type,
int  dma_buf_fd,
VideoInfo vinfo,
std::shared_ptr< Device device 
)

VideoFrame() - Constructor to create VideoFrame from a dma-buf fd.

Parameters
[in]typeVideoFrame implementation type (e.g. VideoFrameImplType::XRT)
[in]dma_buf_fdDMA-BUF file descriptor for the entire frame. Must be CMA-backed.
[in]vinfoVideo format, dimensions, and plane layout.
[in]deviceDevice handle to be used by implementation. Must be non-null. See vart::Device for more details.
Note
type must be VideoFrameImplType::XRT (CMA-backed). Any other type, or an invalid/negative dma_buf_fd, will throw a std::runtime_error.

◆ ~VideoFrame()

vart::VideoFrame::~VideoFrame ( )
default

Member Function Documentation

◆ export_buffer()

int vart::VideoFrame::export_buffer ( ) const

export_buffer() - Export the video frame buffer as a dma-buf file descriptor.

Exports the underlying XRT buffer object (BO) backing the entire frame as a dma-buf file descriptor. Only frames backed by a single BO are supported; frames constructed from per-plane BOs (multi-BO) are not exportable.

Returns
Returns a file descriptor (int) representing the dma-buf on success (>= 0), or -1 on failure (non-CMA allocation or invalid state).
Note
Throws std::runtime_error if the frame is backed by multiple BOs (e.g. constructed via the bo_vec constructor with more than one BO).

◆ get_device_handle()

std::shared_ptr<Device> vart::VideoFrame::get_device_handle ( ) const

get_device_handle() - Retrieves the device handle associated with the current frame

Returns
Returns the device handle associated with this frame.

◆ get_pimpl_handle()

const std::shared_ptr<VideoFrameImplBase>& vart::VideoFrame::get_pimpl_handle ( ) const

get_pimpl_handle() - Retrieves pointer to implementation class.

Returns
Returns a constant reference of pointer to implementation class.

◆ get_video_info()

const VideoInfo& vart::VideoFrame::get_video_info ( ) const

get_video_info() - Retrieves the video frame information from video frame.

Returns
Returns information related to video frame

◆ map()

const VideoFrameMapInfo& vart::VideoFrame::map ( DataMapFlags  map_flags)

map() - Maps video frame data to user space

Parameters
[in]map_flagsFlag used to indicate mode of memory mapping
Returns
Returns information containing user space data pointer(s) and its corresponding video frame information.
Note
Only VideoFrame instances allocated with VideoFrameImplType::XRT (CMA-backed memory) can be mapped. Calling map() on a NON_CMA frame will throw a std::runtime_error.

◆ unmap()

void vart::VideoFrame::unmap ( )

unmap() - Unmaps video frame data from user space

Note
Throws std::runtime_error if called without a prior successful call to map().

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