aggregator: Add gst_aggregator_push_src_event()

This ensures that any pending events are pushed before pushing the new event.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7542>
This commit is contained in:
Sebastian Dröge 2024-09-18 16:09:13 +03:00
parent 075a81b44f
commit 37ef85f268
3 changed files with 56 additions and 0 deletions

View file

@ -1551,6 +1551,28 @@ control aggregating parameters for a given set of input samples.</doc>
</parameter>
</parameters>
</method>
<method name="push_src_event" c:identifier="gst_aggregator_push_src_event" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gstreamer/libs/gst/base/gstaggregator.c">This method will push the provided event downstream. If needed, mandatory
events such as stream-start, caps, and segment events will be sent before
pushing the event.
This API does not allow pushing stream-start, caps, segment and EOS events.
Specific API like gst_aggregator_set_src_caps() should be used for these.</doc>
<source-position filename="../subprojects/gstreamer/libs/gst/base/gstaggregator.h"/>
<return-value transfer-ownership="none">
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="aggregator" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/libs/gst/base/gstaggregator.c">The #GstAggregator</doc>
<type name="Aggregator" c:type="GstAggregator*"/>
</instance-parameter>
<parameter name="event" transfer-ownership="full">
<doc xml:space="preserve" filename="../subprojects/gstreamer/libs/gst/base/gstaggregator.c">the #GstEvent to push.</doc>
<type name="Gst.Event" c:type="GstEvent*"/>
</parameter>
</parameters>
</method>
<method name="selected_samples" c:identifier="gst_aggregator_selected_samples" version="1.18">
<doc xml:space="preserve" filename="../subprojects/gstreamer/libs/gst/base/gstaggregator.c">Subclasses should call this when they have prepared the
buffers they will aggregate for each of their sink pads, but

View file

@ -786,6 +786,36 @@ gst_aggregator_finish_buffer_list (GstAggregator * aggregator,
return klass->finish_buffer_list (aggregator, bufferlist);
}
/**
* gst_aggregator_push_src_event:
* @aggregator: The #GstAggregator
* @event: (transfer full): the #GstEvent to push.
*
* This method will push the provided event downstream. If needed, mandatory
* events such as stream-start, caps, and segment events will be sent before
* pushing the event.
*
* This API does not allow pushing stream-start, caps, segment and EOS events.
* Specific API like gst_aggregator_set_src_caps() should be used for these.
*
* Since: 1.26
*/
gboolean
gst_aggregator_push_src_event (GstAggregator * aggregator, GstEvent * event)
{
g_return_val_if_fail (GST_EVENT_IS_DOWNSTREAM (event), FALSE);
g_return_val_if_fail (GST_EVENT_TYPE (event) != GST_EVENT_STREAM_START &&
GST_EVENT_TYPE (event) != GST_EVENT_CAPS &&
GST_EVENT_TYPE (event) != GST_EVENT_SEGMENT &&
GST_EVENT_TYPE (event) != GST_EVENT_EOS, FALSE);
if (GST_EVENT_IS_SERIALIZED (event)) {
gst_aggregator_push_mandatory_events (aggregator, FALSE);
}
return gst_pad_push_event (aggregator->srcpad, event);
}
static void
gst_aggregator_push_eos (GstAggregator * self)
{

View file

@ -383,6 +383,10 @@ GST_BASE_API
GstFlowReturn gst_aggregator_finish_buffer_list (GstAggregator * aggregator,
GstBufferList * bufferlist);
GST_BASE_API
gboolean gst_aggregator_push_src_event (GstAggregator * aggregator,
GstEvent * event);
GST_BASE_API
void gst_aggregator_set_src_caps (GstAggregator * self,
GstCaps * caps);