appsink: Add current-level-buffers, bytes and time properties

appsrc (and queue and others) already have the same properties so let's
add them here for consistency too.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8824>
This commit is contained in:
Sebastian Dröge 2025-04-11 14:28:36 +03:00 committed by GStreamer Marge Bot
parent 55e9e3cb13
commit ed75968ff5
3 changed files with 167 additions and 0 deletions

View File

@ -323,6 +323,48 @@ condition.</doc>
</instance-parameter>
</parameters>
</method>
<method name="get_current_level_buffers" c:identifier="gst_app_sink_get_current_level_buffers" glib:get-property="current-level-buffers" version="1.28">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">Get the number of currently queued buffers inside @appsink.</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">The number of currently queued buffers.</doc>
<type name="guint64" c:type="guint64"/>
</return-value>
<parameters>
<instance-parameter name="appsink" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">a #GstAppSink</doc>
<type name="AppSink" c:type="GstAppSink*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_current_level_bytes" c:identifier="gst_app_sink_get_current_level_bytes" glib:get-property="current-level-bytes" version="1.28">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">Get the number of currently queued bytes inside @appsink.</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">The number of currently queued bytes.</doc>
<type name="guint64" c:type="guint64"/>
</return-value>
<parameters>
<instance-parameter name="appsink" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">a #GstAppSink</doc>
<type name="AppSink" c:type="GstAppSink*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_current_level_time" c:identifier="gst_app_sink_get_current_level_time" glib:get-property="current-level-time" version="1.28">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">Get the amount of currently queued time inside @appsink.</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">The amount of currently queued time.</doc>
<type name="Gst.ClockTime" c:type="GstClockTime"/>
</return-value>
<parameters>
<instance-parameter name="appsink" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">a #GstAppSink</doc>
<type name="AppSink" c:type="GstAppSink*"/>
</instance-parameter>
</parameters>
</method>
<method name="get_drop" c:identifier="gst_app_sink_get_drop" glib:get-property="drop">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">Check if @appsink will drop old buffers when the maximum amount of queued
data is reached (meaning max buffers, time or bytes limit, whichever is hit first).</doc>
@ -817,6 +859,18 @@ condition.</doc>
<property name="caps" writable="1" transfer-ownership="none" setter="set_caps" getter="get_caps">
<type name="Gst.Caps"/>
</property>
<property name="current-level-buffers" version="1.28" transfer-ownership="none" getter="get_current_level_buffers" default-value="0">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">The number of currently queued buffers inside appsink.</doc>
<type name="guint64" c:type="guint64"/>
</property>
<property name="current-level-bytes" version="1.28" transfer-ownership="none" getter="get_current_level_bytes" default-value="0">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">The number of currently queued bytes inside appsink.</doc>
<type name="guint64" c:type="guint64"/>
</property>
<property name="current-level-time" version="1.28" transfer-ownership="none" getter="get_current_level_time" default-value="0">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/app/gstappsink.c">The amount of currently queued time inside appsink.</doc>
<type name="guint64" c:type="guint64"/>
</property>
<property name="drop" writable="1" transfer-ownership="none" setter="set_drop" getter="get_drop" default-value="FALSE">
<type name="gboolean" c:type="gboolean"/>
</property>

View File

@ -170,6 +170,9 @@ enum
#define DEFAULT_PROP_DROP FALSE
#define DEFAULT_PROP_WAIT_ON_EOS TRUE
#define DEFAULT_PROP_BUFFER_LIST FALSE
#define DEFAULT_PROP_CURRENT_LEVEL_BYTES 0
#define DEFAULT_PROP_CURRENT_LEVEL_BUFFERS 0
#define DEFAULT_PROP_CURRENT_LEVEL_TIME 0
enum
{
@ -183,6 +186,9 @@ enum
PROP_BUFFER_LIST,
PROP_MAX_TIME,
PROP_MAX_BYTES,
PROP_CURRENT_LEVEL_BYTES,
PROP_CURRENT_LEVEL_BUFFERS,
PROP_CURRENT_LEVEL_TIME,
PROP_LAST
};
@ -324,6 +330,45 @@ gst_app_sink_class_init (GstAppSinkClass * klass)
DEFAULT_PROP_WAIT_ON_EOS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstAppSink:current-level-bytes:
*
* The number of currently queued bytes inside appsink.
*
* Since: 1.28
*/
g_object_class_install_property (gobject_class, PROP_CURRENT_LEVEL_BYTES,
g_param_spec_uint64 ("current-level-bytes", "Current Level Bytes",
"The number of currently queued bytes",
0, G_MAXUINT64, DEFAULT_PROP_CURRENT_LEVEL_BYTES,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstAppSink:current-level-buffers:
*
* The number of currently queued buffers inside appsink.
*
* Since: 1.28
*/
g_object_class_install_property (gobject_class, PROP_CURRENT_LEVEL_BUFFERS,
g_param_spec_uint64 ("current-level-buffers", "Current Level Buffers",
"The number of currently queued buffers",
0, G_MAXUINT64, DEFAULT_PROP_CURRENT_LEVEL_BUFFERS,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstAppSink:current-level-time:
*
* The amount of currently queued time inside appsink.
*
* Since: 1.28
*/
g_object_class_install_property (gobject_class, PROP_CURRENT_LEVEL_TIME,
g_param_spec_uint64 ("current-level-time", "Current Level Time",
"The amount of currently queued time",
0, G_MAXUINT64, DEFAULT_PROP_CURRENT_LEVEL_TIME,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstAppSink::eos:
* @appsink: the appsink element that emitted the signal
@ -755,6 +800,17 @@ gst_app_sink_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_WAIT_ON_EOS:
g_value_set_boolean (value, gst_app_sink_get_wait_on_eos (appsink));
break;
case PROP_CURRENT_LEVEL_BYTES:
g_value_set_uint64 (value,
gst_app_sink_get_current_level_bytes (appsink));
break;
case PROP_CURRENT_LEVEL_BUFFERS:
g_value_set_uint64 (value,
gst_app_sink_get_current_level_buffers (appsink));
break;
case PROP_CURRENT_LEVEL_TIME:
g_value_set_uint64 (value, gst_app_sink_get_current_level_time (appsink));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1613,6 +1669,54 @@ gst_app_sink_get_max_bytes (GstAppSink * appsink)
GST_APP_SINK_GET_PROPERTY (max_bytes);
}
/**
* gst_app_sink_get_current_level_bytes:
* @appsink: a #GstAppSink
*
* Get the number of currently queued bytes inside @appsink.
*
* Returns: The number of currently queued bytes.
*
* Since: 1.28
*/
guint64
gst_app_sink_get_current_level_bytes (GstAppSink * appsink)
{
GST_APP_SINK_GET_PROPERTY (queue_status_info.queued_bytes);
}
/**
* gst_app_sink_get_current_level_buffers:
* @appsink: a #GstAppSink
*
* Get the number of currently queued buffers inside @appsink.
*
* Returns: The number of currently queued buffers.
*
* Since: 1.28
*/
guint64
gst_app_sink_get_current_level_buffers (GstAppSink * appsink)
{
GST_APP_SINK_GET_PROPERTY (queue_status_info.queued_buffers);
}
/**
* gst_app_sink_get_current_level_time:
* @appsink: a #GstAppSink
*
* Get the amount of currently queued time inside @appsink.
*
* Returns: The amount of currently queued time.
*
* Since: 1.28
*/
GstClockTime
gst_app_sink_get_current_level_time (GstAppSink * appsink)
{
GST_APP_SINK_GET_PROPERTY (queue_status_info.queued_time);
}
#undef GST_APP_SINK_GET_PROPERTY
#undef GST_APP_SINK_SET_PROPERTY

View File

@ -163,6 +163,15 @@ void gst_app_sink_set_max_bytes (GstAppSink *appsink, guint64 max);
GST_APP_API
guint64 gst_app_sink_get_max_bytes (GstAppSink *appsink);
GST_APP_API
guint64 gst_app_sink_get_current_level_bytes (GstAppSink * appsink);
GST_APP_API
guint64 gst_app_sink_get_current_level_buffers (GstAppSink * appsink);
GST_APP_API
GstClockTime gst_app_sink_get_current_level_time (GstAppSink * appsink);
GST_APP_API
void gst_app_sink_set_drop (GstAppSink *appsink, gboolean drop);