VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::zerocopy Namespace Reference

Functions

struct VLINK_EXPORT_AND_ALIGNED (8) CameraFrame final

Function Documentation

◆ VLINK_EXPORT_AND_ALIGNED()

struct vlink::zerocopy::VLINK_EXPORT_AND_ALIGNED ( 8 )
final

Pixel/codec encoding format of the image payload.

Values 1-12 describe uncompressed planar/packed formats. Values 101-103 describe compressed codec formats. Pass to set_format() and read via format().

< Unknown or uninitialised format.

< Planar YUV 4:2:0 (I420).

< Planar YUV 4:2:2.

< Planar YUV 4:4:4.

< Semi-planar YUV 4:2:0 (Y + interleaved UV).

< Semi-planar YUV 4:2:0 (Y + interleaved VU).

< Packed YUYV 4:2:2.

< Packed YVYU 4:2:2.

< Packed UYVY 4:2:2.

< Packed VYUY 4:2:2.

< Packed 24-bit BGR (3 bytes/pixel).

< Packed 24-bit RGB (3 bytes/pixel).

< Planar 24-bit RGB (separate R, G, B planes).

< JPEG compressed image.

< H.264 / AVC compressed video frame.

< H.265 / HEVC compressed video frame.

Video stream frame type for compressed formats.

Relevant when format() is kFormatH264 or kFormatH265. Set via set_stream(); read via stream().

< Unknown stream type.

< I-frame (intra-coded, key frame).

< P-frame (predicted from previous frame).

< B-frame (bi-directionally predicted).

Default constructor.

Verifies via static_assert that the struct is exactly 80 bytes on 64-bit platforms. 32-bit architectures emit a compile-time warning.

Destructor – frees the owned pixel buffer if is_owner() is true.

Copy constructor – performs a deep copy of target.

Parameters
targetSource frame to copy.

Move constructor – transfers ownership from target.

After the call target is empty and does not own any buffer.

Parameters
targetSource frame to move from.

Copy-assignment operator – deep-copies target.

Parameters
targetSource frame to copy. Self-assignment is a no-op.
Returns
Reference to *this.

Move-assignment operator – transfers ownership from target.

Parameters
targetSource frame to move. Self-assignment is a no-op.
Returns
Reference to *this.

Deserialises a CameraFrame from a Bytes wire buffer.

Validates the magic-number envelope, copies the struct header, and sets the pixel data pointer to reference memory inside bytes (zero-copy). is_owner() will be false after a successful call; bytes must outlive this CameraFrame.

Parameters
bytesBuffer produced by operator>>.
Returns
true on success, false if the buffer fails validation or the total size is inconsistent.

Serialises this CameraFrame into a Bytes wire buffer.

Writes the magic-number envelope, struct fields, and pixel payload into bytes, resizing it if necessary.

Parameters
bytesOutput buffer (reallocated automatically if needed).
Returns
Always true.

Checks whether bytes contains a valid CameraFrame wire buffer.

Verifies minimum size and both magic-number sentinels.

Parameters
bytesBuffer to validate.
Returns
true if the sentinels match and the size is sufficient.

Returns the total serialised byte count for this frame.

Equals: sizeof(magic_begin) + sizeof(CameraFrame) + size() + sizeof(magic_end)

Returns
Total bytes written by operator>>.

Returns true when the pixel buffer is present and non-empty.

Returns
true if data() is non-null and size() > 0.

Borrows the pixel buffer from target without copying.

Sets metadata and data pointer to match target; is_owner() becomes false. Any previously owned buffer is freed first.

Parameters
targetSource frame to borrow from.
Returns
false if target == *this, otherwise true.

Deep-copies the pixel buffer from target.

If *this already owns a same-size buffer the data is copied in-place; otherwise a new buffer is allocated.

Parameters
targetSource frame to copy.
Returns
false if target == *this, otherwise true.

Transfers ownership from target to *this.

After the call target is empty. Self-move is a no-op.

Parameters
targetSource frame to move from.
Returns
false if target == *this, otherwise true.

Allocates an owned pixel buffer of size bytes.

Frees any existing owned buffer before allocating the new one. Buffer content is uninitialised after the call.

Parameters
sizeNumber of bytes to allocate. Must be non-zero.
Returns
false if size is zero, otherwise true.

Releases all resources and zeroes all fields including header.

Borrows an external raw pixel pointer without copying.

Sets the internal data pointer to data with is_owner() == false. The caller is responsible for the buffer lifetime.

Parameters
dataNon-null pointer to pixel data.
sizeSize of the buffer in bytes.
Returns
false on invalid arguments or if the pointer is unchanged.

Deep-copies pixel data from a raw pointer.

Allocates or reuses an owned buffer and copies size bytes from data.

Parameters
dataSource pixel data pointer. Must be non-null.
sizeNumber of bytes to copy. Must be non-zero.
Returns
false on invalid arguments, otherwise true.

Alias for deep_copy(uint8_t*, size_t).

Parameters
dataSource pointer.
sizeNumber of bytes.
Returns
Result of the underlying deep_copy call.

Returns the camera channel (sensor index).

Returns
Channel number set by set_channel().

Returns the image width in pixels.

Returns
Width set by set_width().

Returns the image height in pixels.

Returns
Height set by set_height().

Returns the capture frequency in Hz.

Returns
Frequency set by set_freq().

Returns the pixel/codec encoding format.

Returns
Format value set by set_format().

Returns the video stream frame type.

Returns
Stream value set by set_stream().

Returns a read-only pointer to the pixel data buffer.

Returns
Pointer to pixel bytes, or nullptr if the frame is empty.

Returns the pixel buffer size in bytes.

Returns
Number of payload bytes, or 0 if empty.

Returns true if this object owns its pixel buffer.

An owned buffer is freed in the destructor. Borrowed buffers (created by shallow_copy or operator<<) are not freed.

Returns
true when memory ownership is held.

Sets the camera channel (sensor index).

Parameters
channelChannel identifier.

Sets the image width in pixels.

Parameters
widthPixel width of the image.

Sets the image height in pixels.

Parameters
heightPixel height of the image.

Sets the capture frequency in Hz.

Parameters
freqCapture rate in frames per second.

Sets the pixel/codec encoding format.

Parameters
formatOne of the Format enum values.

Sets the video stream frame type.

Parameters
streamOne of the Stream enum values.

Gets the reserved field.

Returns
Reference to the reserved field.

< Sequencing and timestamp metadata for this frame.

Internal

< Frame identifier; semantics defined by the producing sensor.

< Monotonically increasing sequence number, wraps at UINT32_MAX.

< Reserved for future use; must be zero.

< Measurement timestamp in nanoseconds since epoch.

< Publish timestamp in nanoseconds since epoch.

Default constructor.

Verifies via static_assert that the struct is exactly 40 bytes on 64-bit platforms (the check is omitted on 32-bit architectures).

Default constructor.

Verifies via static_assert that the struct is exactly 80 bytes on 64-bit platforms.

Destructor – frees the owned tail buffer if is_owner() is true.

Copy constructor – deep-copies target.

Parameters
targetSource to copy.

Move constructor – transfers ownership from target.

After the call target is empty and does not own any buffer.

Parameters
targetSource to move from.

Copy-assignment operator.

Parameters
targetSource to copy. Self-assignment is a no-op.
Returns
Reference to *this.

Move-assignment operator.

Parameters
targetSource to move. Self-assignment is a no-op.
Returns
Reference to *this.

Deserialises a ProxyData from a Bytes wire buffer.

Validates magic-number sentinels and the internal region layout (positions and sizes must be contiguous and sum to size_). The tail buffer pointer references memory inside bytes (zero-copy); bytes must outlive this ProxyData.

Parameters
bytesBuffer produced by operator>>.
Returns
true on success; false on magic-number mismatch, size inconsistency, or invalid region layout.

Serialises this ProxyData into a Bytes wire buffer.

Writes the magic-number envelope, the struct fields, and the tail payload into bytes, resizing it as needed.

Parameters
bytesOutput buffer (reallocated automatically if necessary).
Returns
Always true.

Returns the proxy control identifier.

Returns
Value set by set_control_id().

Returns the proxy operation mode.

Returns
Value set by set_mode().

Returns the message timestamp in microseconds.

Returns
Value set by set_timestamp().

Returns the message sequence number.

Returns
Value set by set_seq().

Returns the coarse schema family carried with this payload.

Returns
Numeric SchemaType value stored by set_schema().

Returns a shallow Bytes view of the raw message payload.

The returned Bytes points into the internal tail buffer without copying. It must not outlive this ProxyData.

Returns
Shallow Bytes of the raw payload, or empty if not set.

Returns the topic URL as a string_view.

Points into the internal tail buffer. Lifetime is tied to this object.

Returns
View of the URL string, or empty if not set.

Returns the serialisation type string as a string_view.

For example "demo.proto.PointCloud" or "demo.fbs.CameraFrame". Points into the internal tail buffer.

Returns
View of the serialisation type string, or empty if not set.

Returns the source hostname as a string_view.

Optional field; empty if not provided to create(). Points into the internal tail buffer.

Returns
View of the hostname string, or empty if not set.

Sets the proxy control identifier.

Parameters
control_idControl identifier value.

Sets the proxy operation mode.

Parameters
modeMode value.

Sets the message timestamp in microseconds.

Parameters
timestampTimestamp value (microseconds since epoch).

Sets the message sequence number.

Parameters
seqSequence number.

Sets the coarse schema family associated with the payload.

Parameters
schemaNumeric SchemaType value.

Checks whether bytes contains a valid ProxyData wire buffer.

Verifies minimum buffer size and both magic-number sentinels.

Parameters
bytesBuffer to validate.
Returns
true if magic numbers match and size is sufficient.

Returns the total serialised byte count for this ProxyData.

Equals: sizeof(magic_begin) + sizeof(ProxyData) + size() + sizeof(magic_end)

Returns
Total bytes written by operator>>.

Returns true when all internal region positions and sizes are consistent.

Checks that raw, url, ser, and hostname regions are contiguous and that their combined size equals the tail buffer size. Also requires a non-null data pointer and non-zero total size.

Returns
true when the object holds valid, usable data.

Borrows the tail buffer from target without copying.

Sets metadata and pointer to match target; is_owner() becomes false. Any previously owned buffer is freed.

Parameters
targetSource to borrow from.
Returns
false if target == *this, otherwise true.

Deep-copies the tail buffer from target.

Allocates a new buffer of the same size and copies the payload. If *this already owns a same-size buffer the data is copied in-place.

Parameters
targetSource to copy.
Returns
false if target == *this, otherwise true.

Transfers ownership from target to *this.

After the call target is empty.

Parameters
targetSource to move from.
Returns
false if target == *this, otherwise true.

Constructs the envelope by packing all fields into a single allocation.

Allocates a buffer of size raw.size() + url.size() + ser.size() + hostname.size() and copies each region in order. Any previously owned buffer is freed first.

Parameters
rawRaw serialised message payload.
urlTopic URL string (e.g., "dds://my/topic").
serSerialisation type (e.g., "demo.proto.PointCloud").
schemaCoarse schema family, typically a SchemaType value.
hostnameOptional source hostname; empty if not provided.

Releases all resources and resets all fields to zero.

Returns the total tail buffer size in bytes.

Equals the sum of the raw payload, URL, serialisation type, and hostname sizes.

Returns
Total variable-length buffer size, or 0 if empty.

Returns true if this object owns its tail buffer.

Owned buffers are freed in the destructor. Borrowed buffers (from shallow_copy or operator<<) are not freed.

Returns
true when memory ownership is held.

Internal

Default constructor.

Verifies via static_assert that the struct is exactly 64 bytes on 64-bit platforms. 32-bit architectures emit a compile-time warning.

Destructor.

Frees the owned data buffer if is_owner() is true.

Copy constructor.

Performs a deep copy of target, allocating a new buffer and copying the payload.

Parameters
targetSource to copy from.

Move constructor.

Transfers ownership from target. After the call target is empty and no longer owns any buffer.

Parameters
targetSource to move from.

Copy-assignment operator.

Deep-copies target into *this. Self-assignment is a no-op.

Parameters
targetSource to copy from.
Returns
Reference to *this.

Move-assignment operator.

Transfers ownership from target into *this. Self-assignment is a no-op. After the call target is empty.

Parameters
targetSource to move from.
Returns
Reference to *this.

Deserialises a RawData from a Bytes wire buffer.

Validates the magic-number envelope, then memcpy's the struct fields from the buffer. The internal data pointer is set to point directly into bytes (zero-copy, is_owner() == false). The caller must ensure bytes outlives this RawData.

Parameters
bytesSerialised buffer produced by operator>>.
Returns
true on success, false if the buffer is invalid or the total size does not match get_serialized_size().

Serialises this RawData into a Bytes wire buffer.

Writes the magic-number envelope, the struct fields, and the payload into bytes. If bytes is the wrong size it is reallocated automatically.

Parameters
bytesOutput buffer (resized if necessary).
Returns
Always true.

Checks whether bytes contains a valid RawData wire format.

Verifies that the buffer is large enough and that both the begin and end magic numbers match the expected constants.

Parameters
bytesBuffer to check.
Returns
true if the magic numbers are present and the minimum size constraint is satisfied.

Returns the total serialised byte count for this RawData.

Computed as:

sizeof(magic_begin) + sizeof(RawData) + size() + sizeof(magic_end)
Generic zero-copy raw-byte data container with Header metadata.
Returns
Total number of bytes that operator>> will write.

Returns true if the data pointer is non-null and the size is non-zero.

Returns
true when there is a valid payload available.

Borrows (shallow-copies) the payload from another RawData.

Sets the internal pointer to the same buffer as target without copying data. is_owner() becomes false. The source must outlive this object. Any previously owned buffer is freed first.

Parameters
targetSource to borrow from.
Returns
false if target == *this, otherwise true.

Deep-copies the payload from another RawData.

Allocates a new buffer and copies the payload from target. If *this already owns a buffer of the same size, the data is copied in-place without reallocation.

Parameters
targetSource to copy from.
Returns
false if target == *this, otherwise true.

Transfers ownership from another RawData.

Equivalent to a move operation implemented as a member function. After the call target is empty and is_owner() on target is false.

Parameters
targetSource to move from.
Returns
false if target == *this, otherwise true.

Allocates an owned buffer of size bytes.

Any previously owned buffer is freed before the new allocation. The new buffer content is uninitialised.

Parameters
sizeNumber of bytes to allocate. Must be non-zero.
Returns
false if size is zero, otherwise true.

Releases all resources and resets all fields to zero.

Frees the owned buffer if is_owner() is true. The Header is also zeroed.

Borrows a raw pointer without copying.

Sets the internal pointer to data without allocating. Any previously owned buffer is freed. The caller is responsible for the lifetime of data.

Parameters
dataPointer to the data to borrow. Must be non-null.
sizeSize of the data in bytes. Must be non-zero.
Returns
false if data is null, size is zero, or data already equals the current internal pointer.

Copies data from a raw pointer into an owned buffer.

If *this already owns a buffer of the same size the data is copied in-place; otherwise a new buffer is allocated first via create().

Parameters
dataSource data pointer. Must be non-null.
sizeNumber of bytes to copy. Must be non-zero.
Returns
false on invalid arguments, otherwise true.

Alias for deep_copy(uint8_t*, size_t).

Parameters
dataSource data pointer.
sizeNumber of bytes.
Returns
Result of the underlying deep_copy call.

Returns a mutable reference to the 16-bit user-reserved field.

This field travels through serialisation and can be used by the application for flags or minor sub-type identification without extending the struct.

Returns
Mutable reference to reserved_buf_.

Returns a read-only pointer to the payload bytes.

Returns
Pointer to the payload, or nullptr if the object is empty.

Returns the payload size in bytes.

Returns
Number of payload bytes, or 0 if the object is empty.

Returns true if this object owns its data buffer.

An owned buffer is freed in the destructor. Non-owned buffers (created by shallow_copy or operator<<) are never freed.

Returns
true when memory ownership is held.

< Sequencing and timestamp metadata for this data packet.

Internal