video_sink_open video_sink_close navigation bar

Table of Contents

video_sink_write

Write a frame to the video sink.

Description

The video_sink_write function writes an image frame to the video sink. The length in elements must be specified, particularly for the IMAGE_FORMAT_COMPRESSED image format, for which data is not a constant size. Note that the length is not in bytes, but in elements based on the image data type.

Prototype

t_error
video_sink_write(t_video_sink sink, const void * image_data, size_t image_data_length);
    

Parameters

t_video_sink sink

The handle to the video sink returned by video_sink_open.

const void * image_data

A pointer to a buffer large enough to store the image data in the format and data type specified in the video_sink_open function that created the video sink.

size_t image_data_length

The length of the image_data array in elements, not in bytes. The data type for each element was specified in the video_sink_open function.

Return value

The return value is 0 if the image is written successfully. Otherwise a negative error code is returned. Error codes are defined in quanser_errors.h. A suitable error message may be retrieved using msg_get_error_message.

Error codes

QERR_INVALID_ARGUMENT

One of the arguments is invalid.

QERR_OUT_OF_MEMORY

There is not enough memory to complete the operation.

Requirements

Include Files

Libraries

quanser_video.h

quanser_media.lib;quanser_communications.lib;quanser_runtime.lib;quanser_common.lib

Examples

t_video_sink sink;
t_error result = video_sink_open("C:\my_video.mp4", 30.0, 2000000, 640, 480, VIDEO_OUTPUT_FORMAT_H264, IMAGE_FORMAT_COL_MAJOR_PLANAR_RGB, IMAGE_DATA_TYPE_UINT8, &sink);
if (result >= 0) {
        ...
        result = video_sink_write(sink, image, image_length);
        ...
        video_sink_close(sink);
} else {
    TCHAR message[512];
    msg_get_error_message(NULL, result, message, sizeof(message));
    _tprintf(_T("Failed to open video sink. %s (error %d)\n"), message, -result);
}
    

See Also

 

navigation bar