mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
appsrc: use macros for getters/setters
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5321>
This commit is contained in:
parent
60591960c3
commit
5b252a1511
1 changed files with 62 additions and 126 deletions
|
@ -1967,6 +1967,46 @@ gst_app_src_get_stream_type (GstAppSrc * appsrc)
|
||||||
return stream_type;
|
return stream_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GST_APP_SRC_SET_PROPERTY(prop_name, value, ...) \
|
||||||
|
G_STMT_START { \
|
||||||
|
GstAppSrcPrivate *priv; \
|
||||||
|
\
|
||||||
|
g_return_if_fail (GST_IS_APP_SRC (appsrc)); \
|
||||||
|
\
|
||||||
|
priv = appsrc->priv; \
|
||||||
|
\
|
||||||
|
g_mutex_lock (&priv->mutex); \
|
||||||
|
\
|
||||||
|
if (value != priv->prop_name) { \
|
||||||
|
GST_DEBUG_OBJECT (appsrc, __VA_ARGS__); \
|
||||||
|
priv->prop_name = value; \
|
||||||
|
/* signal the change */ \
|
||||||
|
g_cond_broadcast (&priv->cond); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
g_mutex_unlock (&priv->mutex); \
|
||||||
|
\
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
#define GST_APP_SRC_GET_PROPERTY(type, prop_name, fallback, ...) \
|
||||||
|
G_STMT_START { \
|
||||||
|
type result; \
|
||||||
|
GstAppSrcPrivate *priv; \
|
||||||
|
\
|
||||||
|
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), fallback); \
|
||||||
|
\
|
||||||
|
priv = appsrc->priv; \
|
||||||
|
\
|
||||||
|
g_mutex_lock (&priv->mutex); \
|
||||||
|
\
|
||||||
|
result = priv->prop_name; \
|
||||||
|
GST_DEBUG_OBJECT (appsrc, __VA_ARGS__); \
|
||||||
|
\
|
||||||
|
g_mutex_unlock (&priv->mutex); \
|
||||||
|
\
|
||||||
|
return result; \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_app_src_set_max_bytes:
|
* gst_app_src_set_max_bytes:
|
||||||
* @appsrc: a #GstAppSrc
|
* @appsrc: a #GstAppSrc
|
||||||
|
@ -1979,20 +2019,8 @@ gst_app_src_get_stream_type (GstAppSrc * appsrc)
|
||||||
void
|
void
|
||||||
gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
|
gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
|
||||||
{
|
{
|
||||||
GstAppSrcPrivate *priv;
|
GST_APP_SRC_SET_PROPERTY (max_bytes, max,
|
||||||
|
"setting max-bytes to %" G_GUINT64_FORMAT, max);
|
||||||
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
g_mutex_lock (&priv->mutex);
|
|
||||||
if (max != priv->max_bytes) {
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "setting max-bytes to %" G_GUINT64_FORMAT, max);
|
|
||||||
priv->max_bytes = max;
|
|
||||||
/* signal the change */
|
|
||||||
g_cond_broadcast (&priv->cond);
|
|
||||||
}
|
|
||||||
g_mutex_unlock (&priv->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2006,19 +2034,8 @@ gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
|
||||||
guint64
|
guint64
|
||||||
gst_app_src_get_max_bytes (GstAppSrc * appsrc)
|
gst_app_src_get_max_bytes (GstAppSrc * appsrc)
|
||||||
{
|
{
|
||||||
guint64 result;
|
GST_APP_SRC_GET_PROPERTY (guint64, max_bytes, 0,
|
||||||
GstAppSrcPrivate *priv;
|
"getting max-bytes of %" G_GUINT64_FORMAT, result);
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), 0);
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
g_mutex_lock (&priv->mutex);
|
|
||||||
result = priv->max_bytes;
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "getting max-bytes of %" G_GUINT64_FORMAT, result);
|
|
||||||
g_mutex_unlock (&priv->mutex);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2034,20 +2051,8 @@ gst_app_src_get_max_bytes (GstAppSrc * appsrc)
|
||||||
guint64
|
guint64
|
||||||
gst_app_src_get_current_level_bytes (GstAppSrc * appsrc)
|
gst_app_src_get_current_level_bytes (GstAppSrc * appsrc)
|
||||||
{
|
{
|
||||||
guint64 queued;
|
GST_APP_SRC_GET_PROPERTY (guint64, queue_status_info.queued_bytes, -1,
|
||||||
GstAppSrcPrivate *priv;
|
"current level bytes is %" G_GUINT64_FORMAT, result);
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), -1);
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
|
||||||
queued = priv->queue_status_info.queued_bytes;
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "current level bytes is %" G_GUINT64_FORMAT,
|
|
||||||
queued);
|
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
|
||||||
|
|
||||||
return queued;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2064,20 +2069,8 @@ gst_app_src_get_current_level_bytes (GstAppSrc * appsrc)
|
||||||
void
|
void
|
||||||
gst_app_src_set_max_buffers (GstAppSrc * appsrc, guint64 max)
|
gst_app_src_set_max_buffers (GstAppSrc * appsrc, guint64 max)
|
||||||
{
|
{
|
||||||
GstAppSrcPrivate *priv;
|
GST_APP_SRC_SET_PROPERTY (max_buffers, max,
|
||||||
|
"setting max-buffers to %" G_GUINT64_FORMAT, max);
|
||||||
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
g_mutex_lock (&priv->mutex);
|
|
||||||
if (max != priv->max_buffers) {
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "setting max-buffers to %" G_GUINT64_FORMAT, max);
|
|
||||||
priv->max_buffers = max;
|
|
||||||
/* signal the change */
|
|
||||||
g_cond_broadcast (&priv->cond);
|
|
||||||
}
|
|
||||||
g_mutex_unlock (&priv->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2093,20 +2086,8 @@ gst_app_src_set_max_buffers (GstAppSrc * appsrc, guint64 max)
|
||||||
guint64
|
guint64
|
||||||
gst_app_src_get_max_buffers (GstAppSrc * appsrc)
|
gst_app_src_get_max_buffers (GstAppSrc * appsrc)
|
||||||
{
|
{
|
||||||
guint64 result;
|
GST_APP_SRC_GET_PROPERTY (guint64, max_buffers, 0,
|
||||||
GstAppSrcPrivate *priv;
|
"getting max-buffers of %" G_GUINT64_FORMAT, result);
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), 0);
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
g_mutex_lock (&priv->mutex);
|
|
||||||
result = priv->max_buffers;
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "getting max-buffers of %" G_GUINT64_FORMAT,
|
|
||||||
result);
|
|
||||||
g_mutex_unlock (&priv->mutex);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2122,20 +2103,8 @@ gst_app_src_get_max_buffers (GstAppSrc * appsrc)
|
||||||
guint64
|
guint64
|
||||||
gst_app_src_get_current_level_buffers (GstAppSrc * appsrc)
|
gst_app_src_get_current_level_buffers (GstAppSrc * appsrc)
|
||||||
{
|
{
|
||||||
guint64 queued;
|
GST_APP_SRC_GET_PROPERTY (guint64, queue_status_info.queued_buffers, -1,
|
||||||
GstAppSrcPrivate *priv;
|
"current level buffers is %" G_GUINT64_FORMAT, result);
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), -1);
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
|
||||||
queued = priv->queue_status_info.queued_buffers;
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "current level buffers is %" G_GUINT64_FORMAT,
|
|
||||||
queued);
|
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
|
||||||
|
|
||||||
return queued;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2152,21 +2121,8 @@ gst_app_src_get_current_level_buffers (GstAppSrc * appsrc)
|
||||||
void
|
void
|
||||||
gst_app_src_set_max_time (GstAppSrc * appsrc, GstClockTime max)
|
gst_app_src_set_max_time (GstAppSrc * appsrc, GstClockTime max)
|
||||||
{
|
{
|
||||||
GstAppSrcPrivate *priv;
|
GST_APP_SRC_SET_PROPERTY (max_time, max,
|
||||||
|
"setting max-time to %" GST_TIME_FORMAT, GST_TIME_ARGS (max));
|
||||||
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
g_mutex_lock (&priv->mutex);
|
|
||||||
if (max != priv->max_time) {
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "setting max-time to %" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (max));
|
|
||||||
priv->max_time = max;
|
|
||||||
/* signal the change */
|
|
||||||
g_cond_broadcast (&priv->cond);
|
|
||||||
}
|
|
||||||
g_mutex_unlock (&priv->mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2182,20 +2138,8 @@ gst_app_src_set_max_time (GstAppSrc * appsrc, GstClockTime max)
|
||||||
GstClockTime
|
GstClockTime
|
||||||
gst_app_src_get_max_time (GstAppSrc * appsrc)
|
gst_app_src_get_max_time (GstAppSrc * appsrc)
|
||||||
{
|
{
|
||||||
GstClockTime result;
|
GST_APP_SRC_GET_PROPERTY (GstClockTime, max_time, 0,
|
||||||
GstAppSrcPrivate *priv;
|
"getting max-time of %" GST_TIME_FORMAT, GST_TIME_ARGS (result));
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), 0);
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
g_mutex_lock (&priv->mutex);
|
|
||||||
result = priv->max_time;
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "getting max-time of %" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (result));
|
|
||||||
g_mutex_unlock (&priv->mutex);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2211,22 +2155,14 @@ gst_app_src_get_max_time (GstAppSrc * appsrc)
|
||||||
GstClockTime
|
GstClockTime
|
||||||
gst_app_src_get_current_level_time (GstAppSrc * appsrc)
|
gst_app_src_get_current_level_time (GstAppSrc * appsrc)
|
||||||
{
|
{
|
||||||
gint64 queued;
|
GST_APP_SRC_GET_PROPERTY (GstClockTime, queue_status_info.queued_time,
|
||||||
GstAppSrcPrivate *priv;
|
GST_CLOCK_TIME_NONE, "current level time is %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (result));
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), GST_CLOCK_TIME_NONE);
|
|
||||||
|
|
||||||
priv = appsrc->priv;
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
|
||||||
queued = priv->queue_status_info.queued_time;
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "current level time is %" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (queued));
|
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
|
||||||
|
|
||||||
return queued;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef GST_APP_SRC_SET_PROPERTY
|
||||||
|
#undef GST_APP_SRC_GET_PROPERTY
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min,
|
gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min,
|
||||||
gboolean do_max, guint64 max)
|
gboolean do_max, guint64 max)
|
||||||
|
|
Loading…
Reference in a new issue