bufferMerge

class bufferMerge : public kotekan::Stage

Merges frames from many buffers into one buffer.

Merges the frames in order in a round-robin pattern. This means the frame arrival rate must be the same for all input buffers.

If this stage is the only comsumer of the input buffers then the operation is zero-copy, it just swaps the frames. However if there is more than one comsumer on the input buffer then it does a full memcpy of the frame.

Buffers

  • in_bufs Array of input buffers to merge frames from. This is a named array of input buffers in the format:

    • internal_name_0: buffer_name_0

    • internal_name_1: buffer_name_1

    Or it can be provided without internal names:
    • buffer_name_0

    • buffer_name_1

    The use of internal names is only needed if a subclass of this function requires internal names to select frame.
    • Format: any, but all must be the same type.

    • Metadata: any, but all must be the same type.

  • out_buf Buffer to get all the frames from the in_bufs

    • Format: Matches the input buffers

    • Metadata: Matches the input buffers

Author

Andre Renard

Warning

The sizes of the frames must be the same in all buffers, and the metadata types and underlying pools must also be the same.

Param timeout:

Double. Default -1.0 Timeout in seconds for waiting for a frame on any of the input buffers. Set to a negative number for no timeout.

Subclassed by bufferSwitch

Public Functions

bufferMerge(kotekan::Config &config, const std::string &unique_name, kotekan::bufferContainer &buffer_container)

Constructor.

~bufferMerge() = default

Destructor.

virtual bool select_frame(const std::string &internal_name, Buffer *in_buf, uint32_t frame_id)

This function can be overridden to implement different selection methods. By default it just accepts everything.

Parameters:
  • internal_name – The name given in the config to the buffer (not the buffer name)

  • in_buf – The buffer pointers

  • frame_id – The frame_id for the current frame to accept or reject.

Returns:

true if the frame should be swapped into the out_buf, false if it should be dropped.

virtual void main_thread() override

Thread for merging the frames.