liveadder: Make latency property be a uint in millisecs

This restores roughly the same behaviour as the old liveadder element.
Except that the latency now also includes the output-buffer-duration.

https://bugzilla.gnome.org/show_bug.cgi?id=757050
This commit is contained in:
Olivier Crête 2015-10-26 19:58:04 -04:00
parent 45081ef6f1
commit 7161795a44

View file

@ -791,18 +791,86 @@ static GType gst_live_adder_get_type (void);
G_DEFINE_TYPE (GstLiveAdder, gst_live_adder, GST_TYPE_AUDIO_MIXER);
enum
{
LIVEADDER_PROP_LATENCY = 1
};
static void
gst_live_adder_init (GstLiveAdder * self)
{
/* FIXME: old live adder had latency as uint property */
g_object_set (self, "latency", (guint64) 30 * GST_MSECOND, NULL);
}
static void
gst_live_adder_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
switch (prop_id) {
case LIVEADDER_PROP_LATENCY:
{
GParamSpec *parent_spec =
g_object_class_find_property (G_OBJECT_CLASS
(gst_live_adder_parent_class), "latency");
GObjectClass *pspec_class = g_type_class_peek (parent_spec->owner_type);
GValue v = { 0 };
g_value_init (&v, G_TYPE_INT64);
g_value_set_int64 (&v, g_value_get_uint (value) * GST_MSECOND);
G_OBJECT_CLASS (pspec_class)->set_property (object,
parent_spec->param_id, &v, parent_spec);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_live_adder_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
switch (prop_id) {
case LIVEADDER_PROP_LATENCY:
{
GParamSpec *parent_spec =
g_object_class_find_property (G_OBJECT_CLASS
(gst_live_adder_parent_class), "latency");
GObjectClass *pspec_class = g_type_class_peek (parent_spec->owner_type);
GValue v = { 0 };
g_value_init (&v, G_TYPE_INT64);
G_OBJECT_CLASS (pspec_class)->get_property (object,
parent_spec->param_id, &v, parent_spec);
g_value_set_uint (value, g_value_get_int64 (&v) / GST_MSECOND);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_live_adder_class_init (GstLiveAdderClass * klass)
{
}
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property = gst_live_adder_set_property;
gobject_class->get_property = gst_live_adder_get_property;
g_object_class_install_property (gobject_class, LIVEADDER_PROP_LATENCY,
g_param_spec_uint ("latency", "Buffer latency",
"Additional latency in live mode to allow upstream "
"to take longer to produce buffers for the current "
"position (in milliseconds)", 0, G_MAXUINT,
30, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
}
static gboolean
plugin_init (GstPlugin * plugin)