Commit bdbfa452 authored by Changbok Chea's avatar Changbok Chea Committed by Sebastian Dröge

appsrc: Add "current-level-bytes" property

https://bugzilla.gnome.org/show_bug.cgi?id=704774
parent ee088c6b
...@@ -159,6 +159,7 @@ enum ...@@ -159,6 +159,7 @@ enum
#define DEFAULT_PROP_MAX_LATENCY -1 #define DEFAULT_PROP_MAX_LATENCY -1
#define DEFAULT_PROP_EMIT_SIGNALS TRUE #define DEFAULT_PROP_EMIT_SIGNALS TRUE
#define DEFAULT_PROP_MIN_PERCENT 0 #define DEFAULT_PROP_MIN_PERCENT 0
#define DEFAULT_PROP_CURRENT_LEVEL_BYTE 0
enum enum
{ {
...@@ -174,6 +175,7 @@ enum ...@@ -174,6 +175,7 @@ enum
PROP_MAX_LATENCY, PROP_MAX_LATENCY,
PROP_EMIT_SIGNALS, PROP_EMIT_SIGNALS,
PROP_MIN_PERCENT, PROP_MIN_PERCENT,
PROP_CURRENT_LEVEL_BYTE,
PROP_LAST PROP_LAST
}; };
...@@ -231,6 +233,7 @@ static gboolean gst_app_src_is_seekable (GstBaseSrc * src); ...@@ -231,6 +233,7 @@ static gboolean gst_app_src_is_seekable (GstBaseSrc * src);
static gboolean gst_app_src_do_get_size (GstBaseSrc * src, guint64 * size); static gboolean gst_app_src_do_get_size (GstBaseSrc * src, guint64 * size);
static gboolean gst_app_src_query (GstBaseSrc * src, GstQuery * query); static gboolean gst_app_src_query (GstBaseSrc * src, GstQuery * query);
static guint64 gst_app_src_get_queued_bytes (GstAppSrc * appsrc);
static GstFlowReturn gst_app_src_push_buffer_action (GstAppSrc * appsrc, static GstFlowReturn gst_app_src_push_buffer_action (GstAppSrc * appsrc,
GstBuffer * buffer); GstBuffer * buffer);
...@@ -379,6 +382,20 @@ gst_app_src_class_init (GstAppSrcClass * klass) ...@@ -379,6 +382,20 @@ gst_app_src_class_init (GstAppSrcClass * klass)
0, 100, DEFAULT_PROP_MIN_PERCENT, 0, 100, DEFAULT_PROP_MIN_PERCENT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstAppSrc::current-level-bytes:
*
* The remained size of appsrc element buffer.
* Make appsrc emit the "push-buffer" signal when data is pushed buffer.
* "current-level-bytes" preperty get this accumulated data size in appsrc buffer.
*/
g_object_class_install_property (gobject_class, PROP_CURRENT_LEVEL_BYTE,
g_param_spec_uint64 ("current-level-bytes", "Current Level Bytes",
"The remained size of appsrc element buffer",
0, G_MAXUINT64, DEFAULT_PROP_CURRENT_LEVEL_BYTE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/** /**
* GstAppSrc::need-data: * GstAppSrc::need-data:
* @appsrc: the appsrc element that emitted the signal * @appsrc: the appsrc element that emitted the signal
...@@ -505,6 +522,7 @@ gst_app_src_init (GstAppSrc * appsrc) ...@@ -505,6 +522,7 @@ gst_app_src_init (GstAppSrc * appsrc)
priv->max_latency = DEFAULT_PROP_MAX_LATENCY; priv->max_latency = DEFAULT_PROP_MAX_LATENCY;
priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS; priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
priv->min_percent = DEFAULT_PROP_MIN_PERCENT; priv->min_percent = DEFAULT_PROP_MIN_PERCENT;
priv->queued_bytes = DEFAULT_PROP_CURRENT_LEVEL_BYTE;
gst_base_src_set_live (GST_BASE_SRC (appsrc), DEFAULT_PROP_IS_LIVE); gst_base_src_set_live (GST_BASE_SRC (appsrc), DEFAULT_PROP_IS_LIVE);
} }
...@@ -677,6 +695,9 @@ gst_app_src_get_property (GObject * object, guint prop_id, GValue * value, ...@@ -677,6 +695,9 @@ gst_app_src_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_MIN_PERCENT: case PROP_MIN_PERCENT:
g_value_set_uint (value, priv->min_percent); g_value_set_uint (value, priv->min_percent);
break; break;
case PROP_CURRENT_LEVEL_BYTE:
g_value_set_uint64 (value, gst_app_src_get_queued_bytes (appsrc));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -1531,6 +1552,33 @@ gst_app_src_push_buffer_action (GstAppSrc * appsrc, GstBuffer * buffer) ...@@ -1531,6 +1552,33 @@ gst_app_src_push_buffer_action (GstAppSrc * appsrc, GstBuffer * buffer)
return gst_app_src_push_buffer_full (appsrc, buffer, FALSE); return gst_app_src_push_buffer_full (appsrc, buffer, FALSE);
} }
/**
* gst_app_src_get_queued_bytes:
* @appsrc: a #GstAppSrc
*
* Get the queued byptes of the buffer
*
* Returns: the size of queued bytes
*
* This is used for the "current-level-byte" property. */
static guint64
gst_app_src_get_queued_bytes (GstAppSrc * appsrc)
{
gint64 size;
GstAppSrcPrivate *priv;
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), -1);
priv = appsrc->priv;
GST_OBJECT_LOCK (appsrc);
size = priv->queued_bytes;
GST_DEBUG_OBJECT (appsrc, "getting queued bytes is %" G_GUINT64_FORMAT, size);
GST_OBJECT_UNLOCK (appsrc);
return size;
}
/** /**
* gst_app_src_end_of_stream: * gst_app_src_end_of_stream:
* @appsrc: a #GstAppSrc * @appsrc: a #GstAppSrc
......
...@@ -14,6 +14,7 @@ EXPORTS ...@@ -14,6 +14,7 @@ EXPORTS
gst_app_sink_set_max_buffers gst_app_sink_set_max_buffers
gst_app_src_end_of_stream gst_app_src_end_of_stream
gst_app_src_get_caps gst_app_src_get_caps
gst_app_src_get_current_level_bytes
gst_app_src_get_emit_signals gst_app_src_get_emit_signals
gst_app_src_get_latency gst_app_src_get_latency
gst_app_src_get_max_bytes gst_app_src_get_max_bytes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment