controller: cleanup interpolation modes

Remove deprecated/unimplemented modes. Turn interpolation mode into a gobject
property. Update docs and examples.
This commit is contained in:
Stefan Sauer 2011-12-19 23:32:57 +01:00
parent 2c7a8b924a
commit 503b739b23
9 changed files with 125 additions and 118 deletions

View file

@ -69,12 +69,12 @@ gst_timed_value_control_invalidate_cache
<SUBSECTION Standard>
GstTimedValueControlSourceClass
GstTimedValueControlSourcePrivate
GST_INTERPOLATION_CONTROL_SOURCE
GST_IS_INTERPOLATION_CONTROL_SOURCE
GST_INTERPOLATION_CONTROL_SOURCE_CLASS
GST_IS_INTERPOLATION_CONTROL_SOURCE_CLASS
GST_INTERPOLATION_CONTROL_SOURCE_GET_CLASS
GST_TYPE_INTERPOLATION_CONTROL_SOURCE
GST_TIMED_VALUE_CONTROL_SOURCE
GST_IS_TIMED_VALUE_CONTROL_SOURCE
GST_TIMED_VALUE_CONTROL_SOURCE_CLASS
GST_IS_TIMED_VALUE_CONTROL_SOURCE_CLASS
GST_TIMED_VALUE_CONTROL_SOURCE_GET_CLASS
GST_TYPE_TIMED_VALUE_CONTROL_SOURCE
<SUBSECTION Private>
gst_timed_value_control_source_get_type
</SECTION>
@ -84,20 +84,21 @@ gst_timed_value_control_source_get_type
<TITLE>GstInterpolationControlSource</TITLE>
<INCLUDE>libs/controller/gstinterpolationcontrolsource.h</INCLUDE>
GstInterpolationControlSource
GstInterpolateMode
GstInterpolationMode
gst_interpolation_control_source_new
gst_interpolation_control_source_set_interpolation_mode
<SUBSECTION Standard>
GstInterpolationControlSourceClass
GstInterpolationControlSourcePrivate
GST_TIMED_VALUE_CONTROL_SOURCE
GST_IS_TIMED_VALUE_CONTROL_SOURCE
GST_TIMED_VALUE_CONTROL_SOURCE_CLASS
GST_IS_TIMED_VALUE_CONTROL_SOURCE_CLASS
GST_TIMED_VALUE_CONTROL_SOURCE_GET_CLASS
GST_TYPE_TIMED_VALUE_CONTROL_SOURCE
GST_INTERPOLATION_CONTROL_SOURCE
GST_IS_INTERPOLATION_CONTROL_SOURCE
GST_INTERPOLATION_CONTROL_SOURCE_CLASS
GST_IS_INTERPOLATION_CONTROL_SOURCE_CLASS
GST_INTERPOLATION_CONTROL_SOURCE_GET_CLASS
GST_TYPE_INTERPOLATION_CONTROL_SOURCE
GST_TYPE_INTERPOLATION_MODE
<SUBSECTION Private>
gst_interpolation_control_source_get_type
gst_interpolation_mode_get_type
</SECTION>
<SECTION>

View file

@ -452,3 +452,8 @@ The 0.11 porting guide
GstTimedValueControlSource baseclass and 2 sub classes:
GstInterpolationControlSource and GstTriggerControlSource. The API for setting
and getting the timestamps is in GstTimedValueControlSource.
gst_interpolation_control_source_set_interpolation_mode() has been removed.
Set the "mode" gobject property on the control-source instead. The possible
enum values have been renamed from GST_INTERPOLATE_XXX to
GST_INTERPOLATION_MODE_XXX.

View file

@ -113,7 +113,7 @@
* <listitem><para>
* create a #GstControlSource.
* csource = gst_interpolation_control_source_new ();
* gst_interpolation_control_source_set_interpolation_mode(csource, mode);
* g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
* </para></listitem>
* <listitem><para>
* Attach the #GstControlSource on the controller to a property.

View file

@ -585,7 +585,6 @@ static GstInterpolateMethod interpolate_cubic = {
GstInterpolateMethod *priv_gst_interpolation_methods[] = {
&interpolate_none,
&interpolate_linear,
&interpolate_cubic,
&interpolate_cubic
};

View file

@ -29,9 +29,8 @@
* control points. It supports several interpolation modes and property types.
*
* To use #GstInterpolationControlSource get a new instance by calling
* gst_interpolation_control_source_new(), bind it to a #GParamSpec, select a interpolation mode with
* gst_interpolation_control_source_set_interpolation_mode() and set some control points by calling
* gst_timed_value_control_source_set().
* gst_interpolation_control_source_new(), bind it to a #GParamSpec and set some
* control points by calling gst_timed_value_control_source_set().
*
* All functions are MT-safe.
*
@ -47,6 +46,31 @@
#define GST_CAT_DEFAULT controller_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
enum
{
PROP_MODE = 1
};
GType
gst_interpolation_mode_get_type (void)
{
static gsize gtype = 0;
static const GEnumValue values[] = {
{GST_INTERPOLATION_MODE_NONE, "GST_INTERPOLATION_MODE_NONE", "none"},
{GST_INTERPOLATION_MODE_LINEAR, "GST_INTERPOLATION_MODE_LINEAR", "linear"},
{GST_INTERPOLATION_MODE_CUBIC, "GST_INTERPOLATION_MODE_CUBIC", "cubic"},
{0, NULL, NULL}
};
if (g_once_init_enter (&gtype)) {
GType tmp = g_enum_register_static ("GstLFOWaveform", values);
g_once_init_leave (&gtype, tmp);
}
return (GType) gtype;
}
#define _do_init \
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "interpolation control source", 0, \
"timeline value interpolating control source")
@ -57,7 +81,7 @@ G_DEFINE_TYPE_WITH_CODE (GstInterpolationControlSource,
struct _GstInterpolationControlSourcePrivate
{
GstInterpolateMode interpolation_mode;
GstInterpolationMode interpolation_mode;
};
/**
@ -73,23 +97,9 @@ gst_interpolation_control_source_new (void)
return g_object_newv (GST_TYPE_INTERPOLATION_CONTROL_SOURCE, 0, NULL);
}
/**
* gst_interpolation_control_source_set_interpolation_mode:
* @self: the #GstInterpolationControlSource object
* @mode: interpolation mode
*
* Sets the given interpolation mode.
*
* <note><para>User interpolation is not yet available and quadratic interpolation
* is deprecated and maps to cubic interpolation.</para></note>
*
* Returns: %TRUE if the interpolation mode could be set, %FALSE otherwise
*/
/* *INDENT-OFF* */
gboolean
gst_interpolation_control_source_set_interpolation_mode (
GstInterpolationControlSource * self, GstInterpolateMode mode)
/* *INDENT-ON* */
static gboolean
gst_interpolation_control_source_set_interpolation_mode
(GstInterpolationControlSource * self, GstInterpolationMode mode)
{
gboolean ret = TRUE;
GstControlSource *csource = GST_CONTROL_SOURCE (self);
@ -100,11 +110,6 @@ gst_interpolation_control_source_set_interpolation_mode (
return FALSE;
}
if (mode == GST_INTERPOLATE_QUADRATIC) {
GST_WARNING ("Quadratic interpolation mode is deprecated, using cubic"
"interpolation mode");
}
GST_TIMED_VALUE_CONTROL_SOURCE_LOCK (self);
switch (gst_timed_value_control_source_get_base_value_type (
(GstTimedValueControlSource *) self)) {
@ -203,17 +208,61 @@ gst_interpolation_control_source_init (GstInterpolationControlSource * self)
self->priv =
G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_INTERPOLATION_CONTROL_SOURCE,
GstInterpolationControlSourcePrivate);
self->priv->interpolation_mode = GST_INTERPOLATE_NONE;
self->priv->interpolation_mode = GST_INTERPOLATION_MODE_NONE;
}
static void
gst_interpolation_control_source_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstInterpolationControlSource *self =
GST_INTERPOLATION_CONTROL_SOURCE (object);
switch (prop_id) {
case PROP_MODE:
gst_interpolation_control_source_set_interpolation_mode (self,
(GstInterpolationMode) g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_interpolation_control_source_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstInterpolationControlSource *self =
GST_INTERPOLATION_CONTROL_SOURCE (object);
switch (prop_id) {
case PROP_MODE:
g_value_set_enum (value, self->priv->interpolation_mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_interpolation_control_source_class_init (GstInterpolationControlSourceClass
* klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstControlSourceClass *csource_class = GST_CONTROL_SOURCE_CLASS (klass);
g_type_class_add_private (klass,
sizeof (GstInterpolationControlSourcePrivate));
gobject_class->set_property = gst_interpolation_control_source_set_property;
gobject_class->get_property = gst_interpolation_control_source_get_property;
csource_class->bind = gst_interpolation_control_source_bind;
g_object_class_install_property (gobject_class, PROP_MODE,
g_param_spec_enum ("mode", "Mode", "Interpolation mode",
GST_TYPE_INTERPOLATION_MODE, GST_INTERPOLATION_MODE_NONE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}

View file

@ -44,26 +44,26 @@ G_BEGIN_DECLS
#define GST_INTERPOLATION_CONTROL_SOURCE_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_INTERPOLATION_CONTROL_SOURCE, GstInterpolationControlSourceClass))
#define GST_TYPE_INTERPOLATION_MODE (gst_interpolation_mode_get_type ())
typedef struct _GstInterpolationControlSource GstInterpolationControlSource;
typedef struct _GstInterpolationControlSourceClass GstInterpolationControlSourceClass;
typedef struct _GstInterpolationControlSourcePrivate GstInterpolationControlSourcePrivate;
/**
* GstInterpolateMode:
* @GST_INTERPOLATE_NONE: steps-like interpolation, default
* @GST_INTERPOLATE_LINEAR: linear interpolation
* @GST_INTERPOLATE_QUADRATIC: square interpolation (deprecated, maps to cubic)
* @GST_INTERPOLATE_CUBIC: cubic interpolation
* GstInterpolationMode:
* @GST_INTERPOLATION_MODE_NONE: steps-like interpolation, default
* @GST_INTERPOLATION_MODE_LINEAR: linear interpolation
* @GST_INTERPOLATION_MODE_CUBIC: cubic interpolation
*
* The various interpolation modes available.
*/
typedef enum
{
GST_INTERPOLATE_NONE,
GST_INTERPOLATE_LINEAR,
GST_INTERPOLATE_QUADRATIC,
GST_INTERPOLATE_CUBIC
} GstInterpolateMode;
GST_INTERPOLATION_MODE_NONE,
GST_INTERPOLATION_MODE_LINEAR,
GST_INTERPOLATION_MODE_CUBIC
} GstInterpolationMode;
/**
* GstInterpolationControlSource:
@ -86,14 +86,12 @@ struct _GstInterpolationControlSourceClass {
};
GType gst_interpolation_control_source_get_type (void);
GType gst_interpolation_mode_get_type (void);
/* Functions */
GstInterpolationControlSource *
gst_interpolation_control_source_new (void);
gboolean gst_interpolation_control_source_set_interpolation_mode
(GstInterpolationControlSource *self,
GstInterpolateMode mode);
G_END_DECLS

View file

@ -114,8 +114,7 @@ main (gint argc, gchar * argv[])
csource = gst_interpolation_control_source_new ();
gst_object_set_control_source (GST_OBJECT (src), "freq",
GST_CONTROL_SOURCE (csource));
gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_LINEAR);
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
g_value_init (&freq, G_TYPE_DOUBLE);

View file

@ -520,8 +520,7 @@ GST_START_TEST (controller_interpolate_none)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_NONE));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL);
fail_unless (gst_timed_value_control_source_get_count (
(GstTimedValueControlSource *) csource) == 0);
@ -574,8 +573,7 @@ GST_START_TEST (controller_interpolate_linear)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_LINEAR));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
/* set control values */
g_value_init (&val_ulong, G_TYPE_ULONG);
@ -621,8 +619,7 @@ GST_START_TEST (controller_interpolate_cubic)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_CUBIC));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL);
/* set control values */
g_value_init (&val_double, G_TYPE_DOUBLE);
@ -683,8 +680,7 @@ GST_START_TEST (controller_interpolate_cubic_too_few_cp)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_CUBIC));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL);
/* set 2 control values */
g_value_init (&val_double, G_TYPE_DOUBLE);
@ -714,33 +710,6 @@ GST_START_TEST (controller_interpolate_cubic_too_few_cp)
GST_END_TEST;
/* make sure we don't crash when someone sets an unsupported interpolation
* mode */
GST_START_TEST (controller_interpolate_unimplemented)
{
GstInterpolationControlSource *csource;
GstElement *elem;
elem = gst_element_factory_make ("testmonosource", "test_source");
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "ulong",
GST_CONTROL_SOURCE (csource)));
/* set completely bogus interpolation mode */
fail_if (gst_interpolation_control_source_set_interpolation_mode (csource,
(GstInterpolateMode) 93871));
g_object_unref (csource);
gst_object_unref (elem);
}
GST_END_TEST;
/* test _unset() */
GST_START_TEST (controller_interpolation_unset)
{
@ -759,8 +728,7 @@ GST_START_TEST (controller_interpolation_unset)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_NONE));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL);
/* set control values */
g_value_init (&val_ulong, G_TYPE_ULONG);
@ -831,8 +799,7 @@ GST_START_TEST (controller_interpolation_unset_all)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_NONE));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL);
/* set control values */
g_value_init (&val_ulong, G_TYPE_ULONG);
@ -885,8 +852,7 @@ GST_START_TEST (controller_interpolation_linear_value_array)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_LINEAR));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
/* set control values */
g_value_init (&val_ulong, G_TYPE_ULONG);
@ -934,8 +900,7 @@ GST_START_TEST (controller_interpolation_linear_invalid_values)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_LINEAR));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
/* set control values */
g_value_init (&val_float, G_TYPE_FLOAT);
@ -993,8 +958,7 @@ GST_START_TEST (controller_interpolation_linear_default_values)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_LINEAR));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
g_value_init (&val_ulong, G_TYPE_ULONG);
@ -1084,10 +1048,8 @@ GST_START_TEST (controller_interpolate_linear_disabled)
GST_CONTROL_SOURCE (csource2)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_LINEAR));
fail_unless (gst_interpolation_control_source_set_interpolation_mode
(csource2, GST_INTERPOLATE_LINEAR));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
g_object_set (csource2, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
/* set control values */
g_value_init (&val_ulong, G_TYPE_ULONG);
@ -1223,8 +1185,7 @@ GST_START_TEST (controller_interpolation_set_from_list)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_LINEAR));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
/* set control value */
tval = g_new0 (GstTimedValue, 1);
@ -1272,8 +1233,7 @@ GST_START_TEST (controller_interpolate_linear_before_ts0)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_LINEAR));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
/* set control values */
g_value_init (&val_ulong, G_TYPE_ULONG);
@ -1325,8 +1285,7 @@ GST_START_TEST (controller_interpolation_cp_count)
GST_CONTROL_SOURCE (csource)));
/* set interpolation mode */
fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
GST_INTERPOLATE_NONE));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL);
fail_unless (gst_timed_value_control_source_get_count (
(GstTimedValueControlSource *) csource) == 0);
@ -1907,7 +1866,6 @@ gst_controller_suite (void)
tcase_add_test (tc, controller_interpolate_linear);
tcase_add_test (tc, controller_interpolate_cubic);
tcase_add_test (tc, controller_interpolate_cubic_too_few_cp);
tcase_add_test (tc, controller_interpolate_unimplemented);
tcase_add_test (tc, controller_interpolation_unset);
tcase_add_test (tc, controller_interpolation_unset_all);
tcase_add_test (tc, controller_interpolation_linear_value_array);

View file

@ -58,10 +58,8 @@ main (gint argc, gchar ** argv)
/* Set interpolation mode */
gst_interpolation_control_source_set_interpolation_mode (csource1,
GST_INTERPOLATE_LINEAR);
gst_interpolation_control_source_set_interpolation_mode (csource2,
GST_INTERPOLATE_LINEAR);
g_object_set (csource1, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
g_object_set (csource2, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
/* set control values */
g_value_init (&vol, G_TYPE_DOUBLE);