Refer to GstAggregator
Key Components
-
GstVideoAggregator:
- This is the main class that extends
GstAggregator
to handle video streams. It provides a framework for subclasses to implement specific video aggregation logic. - It manages input pads (
GstVideoAggregatorPad
) and processes video frames from these pads.
- This is the main class that extends
-
GstVideoAggregatorPad:
- A specialized pad class used by
GstVideoAggregator
to manage video input streams. It handles buffering, event processing, and synchronization specific to video data.
- A specialized pad class used by
-
Conversion and Preparation:
- The
gst_video_aggregator_convert_pad_prepare_frame
function is responsible for preparing video frames for aggregation. It checks if conversion is needed and performs it if necessary. - The
gst_video_aggregator_convert_pad_clean_frame
function cleans up after a frame has been processed, ensuring that resources are properly released.
- The
-
Format Negotiation:
- The
gst_video_aggregator_find_best_format
function determines the best video format to use based on the capabilities of downstream elements and the input pads. - The
gst_video_aggregator_default_fixate_src_caps
function finalizes the capabilities of the output pad, ensuring they are compatible with downstream elements.
- The
-
Aggregation Logic:
- The
gst_video_aggregator_do_aggregate
function is the core of the aggregation process. It prepares frames, aggregates them, and produces an output buffer. - The
gst_video_aggregator_aggregate
function handles the overall aggregation process, including handling timeouts and managing the segment position.
- The
-
Quality of Service (QoS):
- The
gst_video_aggregator_do_qos
function performs QoS calculations to determine if a frame should be processed or dropped based on timing constraints.
- The
-
Synchronization and Timing:
- The
sync_pad_values
function synchronizes pad properties with the stream time. - The
gst_video_aggregator_advance_on_timeout
function advances the segment position when a timeout occurs, ensuring that the aggregator continues processing frames.
- The
Detailed Explanation
-
Frame Preparation and Conversion:
- The
gst_video_aggregator_convert_pad_prepare_frame
function checks if the input frame needs conversion based on the current configuration. If conversion is needed, it creates a newGstVideoConverter
and converts the frame to the desired format. The converted frame is then mapped and prepared for aggregation.
- The
-
Format Negotiation:
- The
gst_video_aggregator_find_best_format
function iterates over the input pads to find the best video format that is supported by both the input pads and the downstream elements. It considers factors like alpha channel support and resolution to determine the optimal format.
- The
-
Aggregation Process:
- The
gst_video_aggregator_do_aggregate
function is responsible for the actual aggregation of video frames. It prepares the frames, calls the subclass’saggregate_frames
method to combine them, and then cleans up the frames. This function ensures that the output buffer is correctly timestamped and synchronized with the stream time.
- The
-
Quality of Service (QoS):
- The
gst_video_aggregator_do_qos
function calculates the jitter between the current timestamp and the latest QoS observation. If the jitter is positive, it indicates that the frame is late, and the function may decide to drop the frame to maintain synchronization.
- The
-
Synchronization and Timing:
- The
sync_pad_values
function updates the properties of each pad to match the current stream time, ensuring that all pads are synchronized. - The
gst_video_aggregator_advance_on_timeout
function advances the segment position when a timeout occurs, allowing the aggregator to continue processing frames even if some input pads are not ready.
- The
GstAggregator
and GstVideoAggregator
GstAggregator
-
General Purpose:
GstAggregator
is a base class for creating elements that aggregate multiple input streams into a single output stream. It is designed to be flexible and can be used for various types of data, not limited to video. -
Subclassing: It provides a framework for subclasses to implement specific aggregation logic. Subclasses are expected to implement the
aggregate
method, which is called when all input pads have data ready to be processed. -
Buffer Management: It manages buffers on each pad, allowing subclasses to peek at or pop buffers for processing. It ensures that buffers are synchronized across all input pads before aggregation.
-
Event and Query Handling: The aggregator handles various GStreamer events and queries to manage the flow of data and control messages through the pipeline.
-
Use Cases: It can be used to create mixers, muxers, or any element that needs to combine multiple input streams, such as audio mixers or data multiplexers.
GstVideoAggregator
-
Video-Specific:
GstVideoAggregator
is a specialized subclass ofGstAggregator
specifically designed for handling video streams. It extends the functionality ofGstAggregator
to include video-specific processing. -
Video Frame Handling: It provides additional methods and structures for handling video frames, such as
GstVideoFrame
. It includes functionality for mapping, converting, and preparing video frames for aggregation. -
Color Space Conversion: It includes built-in support for color space conversion, allowing it to handle different video formats and convert them as needed.
-
Z-Order Configuration: It allows configuration of the z-order for each input stream, which determines the stacking order of video frames when they are combined.
-
Format Negotiation: It includes logic for negotiating video formats with downstream elements, ensuring compatibility and optimal performance.