3 * unit test for the controller library
5 * Copyright (C) <2005> Stefan Kost <ensonic at users dot sf dot net>
6 * Copyright (C) <2006-2007> Sebastian Dröge <slomo@circular-chaos.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 #include <gst/check/gstcheck.h>
29 #include <gst/controller/gstcontroller.h>
30 #include <gst/controller/gstcontrolsource.h>
31 #include <gst/controller/gstinterpolationcontrolsource.h>
32 #include <gst/controller/gstlfocontrolsource.h>
34 /* LOCAL TEST ELEMENT */
48 #define GST_TYPE_TEST_MONO_SOURCE (gst_test_mono_source_get_type ())
49 #define GST_TEST_MONO_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSource))
50 #define GST_TEST_MONO_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSourceClass))
51 #define GST_IS_TEST_MONO_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TEST_MONO_SOURCE))
52 #define GST_IS_TEST_MONO_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TEST_MONO_SOURCE))
53 #define GST_TEST_MONO_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSourceClass))
55 typedef struct _GstTestMonoSource GstTestMonoSource;
56 typedef struct _GstTestMonoSourceClass GstTestMonoSourceClass;
58 struct _GstTestMonoSource
66 struct _GstTestMonoSourceClass
68 GstElementClass parent_class;
71 static GType gst_test_mono_source_get_type (void);
74 gst_test_mono_source_get_property (GObject * object,
75 guint property_id, GValue * value, GParamSpec * pspec)
77 GstTestMonoSource *self = GST_TEST_MONO_SOURCE (object);
79 switch (property_id) {
81 g_value_set_ulong (value, self->val_ulong);
84 g_value_set_float (value, self->val_float);
87 g_value_set_double (value, self->val_double);
90 g_value_set_boolean (value, self->val_boolean);
93 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
99 gst_test_mono_source_set_property (GObject * object,
100 guint property_id, const GValue * value, GParamSpec * pspec)
102 GstTestMonoSource *self = GST_TEST_MONO_SOURCE (object);
104 switch (property_id) {
106 self->val_ulong = g_value_get_ulong (value);
109 self->val_float = g_value_get_float (value);
112 self->val_double = g_value_get_double (value);
115 self->val_boolean = g_value_get_boolean (value);
117 case ARG_CONSTRUCTONLY:
120 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
126 gst_test_mono_source_class_init (GstTestMonoSourceClass * klass)
128 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
130 gobject_class->set_property = gst_test_mono_source_set_property;
131 gobject_class->get_property = gst_test_mono_source_get_property;
133 g_object_class_install_property (gobject_class, ARG_ULONG,
134 g_param_spec_ulong ("ulong",
136 "ulong number parameter for the test_mono_source",
137 0, G_MAXULONG, 0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
139 g_object_class_install_property (gobject_class, ARG_FLOAT,
140 g_param_spec_float ("float",
142 "float number parameter for the test_mono_source",
143 0.0, 100.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
145 g_object_class_install_property (gobject_class, ARG_DOUBLE,
146 g_param_spec_double ("double",
148 "double number parameter for the test_mono_source",
149 0.0, 100.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
151 g_object_class_install_property (gobject_class, ARG_BOOLEAN,
152 g_param_spec_boolean ("boolean",
154 "boolean parameter for the test_mono_source",
155 FALSE, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
157 g_object_class_install_property (gobject_class, ARG_READONLY,
158 g_param_spec_ulong ("readonly",
160 "readonly parameter for the test_mono_source",
161 0, G_MAXULONG, 0, G_PARAM_READABLE | GST_PARAM_CONTROLLABLE));
163 g_object_class_install_property (gobject_class, ARG_STATIC,
164 g_param_spec_ulong ("static",
166 "static parameter for the test_mono_source",
167 0, G_MAXULONG, 0, G_PARAM_READWRITE));
169 g_object_class_install_property (gobject_class, ARG_CONSTRUCTONLY,
170 g_param_spec_ulong ("construct-only",
171 "construct-only prop",
172 "construct-only parameter for the test_mono_source",
173 0, G_MAXULONG, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
177 gst_test_mono_source_base_init (GstTestMonoSourceClass * klass)
179 static const GstElementDetails details = {
180 "Monophonic source for unit tests",
181 "Source/Audio/MonoSource",
183 "Stefan Kost <ensonic@users.sf.net>"
185 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
187 gst_element_class_set_details (element_class, &details);
191 gst_test_mono_source_get_type (void)
193 static GType type = 0;
196 static const GTypeInfo info = {
197 (guint16) sizeof (GstTestMonoSourceClass),
198 (GBaseInitFunc) gst_test_mono_source_base_init, // base_init
199 NULL, // base_finalize
200 (GClassInitFunc) gst_test_mono_source_class_init, // class_init
201 NULL, // class_finalize
203 (guint16) sizeof (GstTestMonoSource),
205 NULL, // instance_init
209 g_type_register_static (GST_TYPE_ELEMENT, "GstTestMonoSource", &info,
215 /* so we don't have to paste the gst_element_register into 50 places below */
217 local_gst_controller_init (int *argc, char ***argv)
219 fail_unless (gst_controller_init (argc, argv));
221 fail_unless (gst_element_register (NULL, "testmonosource", GST_RANK_NONE,
222 GST_TYPE_TEST_MONO_SOURCE));
227 #define gst_controller_init(a,b) local_gst_controller_init(a,b)
230 /* double init should not harm */
231 GST_START_TEST (controller_init)
233 gst_controller_init (NULL, NULL);
234 gst_controller_init (NULL, NULL);
235 gst_controller_init (NULL, NULL);
236 gst_controller_init (NULL, NULL);
241 /* tests for an element with no controlled params */
242 GST_START_TEST (controller_new_fail1)
247 gst_controller_init (NULL, NULL);
249 elem = gst_element_factory_make ("fakesrc", "test_source");
251 /* that property should not exist */
252 ctrl = gst_controller_new (G_OBJECT (elem), "_schrompf_", NULL);
253 fail_unless (ctrl == NULL, NULL);
255 gst_object_unref (elem);
260 /* tests for an element with controlled params, but none given */
261 GST_START_TEST (controller_new_fail2)
266 gst_controller_init (NULL, NULL);
268 elem = gst_element_factory_make ("testmonosource", "test_source");
270 /* no property given */
271 ctrl = gst_controller_new (G_OBJECT (elem), NULL);
272 fail_unless (ctrl == NULL, NULL);
274 gst_object_unref (elem);
279 /* tests for readonly params */
280 GST_START_TEST (controller_new_fail3)
285 gst_controller_init (NULL, NULL);
287 elem = gst_element_factory_make ("testmonosource", "test_source");
289 /* that property should exist and but is readonly */
290 ASSERT_CRITICAL (ctrl =
291 gst_controller_new (G_OBJECT (elem), "readonly", NULL));
292 fail_unless (ctrl == NULL, NULL);
294 gst_object_unref (elem);
299 /* tests for static params */
300 GST_START_TEST (controller_new_fail4)
305 gst_controller_init (NULL, NULL);
307 elem = gst_element_factory_make ("testmonosource", "test_source");
309 /* that property should exist and but is not controlable */
310 ASSERT_CRITICAL (ctrl = gst_controller_new (G_OBJECT (elem), "static", NULL));
311 fail_unless (ctrl == NULL, NULL);
313 gst_object_unref (elem);
318 /* tests for static params */
319 GST_START_TEST (controller_new_fail5)
324 gst_controller_init (NULL, NULL);
326 elem = gst_element_factory_make ("testmonosource", "test_source");
328 /* that property should exist and but is construct-only */
329 ASSERT_CRITICAL (ctrl =
330 gst_controller_new (G_OBJECT (elem), "construct-only", NULL));
331 fail_unless (ctrl == NULL, NULL);
333 gst_object_unref (elem);
339 /* tests for an element with controlled params */
340 GST_START_TEST (controller_new_okay1)
345 gst_controller_init (NULL, NULL);
347 elem = gst_element_factory_make ("testmonosource", "test_source");
349 /* that property should exist and should be controllable */
350 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
351 fail_unless (ctrl != NULL, NULL);
353 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
354 g_object_unref (ctrl);
355 gst_object_unref (elem);
360 /* tests for an element with several controlled params */
361 GST_START_TEST (controller_new_okay2)
363 GstController *ctrl, *ctrl2, *ctrl3;
366 gst_controller_init (NULL, NULL);
368 elem = gst_element_factory_make ("testmonosource", "test_source");
370 /* that property should exist and should be controllable */
371 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", "double", "float", NULL);
372 fail_unless (ctrl != NULL, NULL);
374 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
375 fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
377 ctrl2 = gst_controller_new (G_OBJECT (elem), "boolean", NULL);
378 fail_unless (ctrl2 != NULL, NULL);
379 fail_unless (ctrl2 == ctrl, NULL);
381 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
382 fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
384 /* trying to control the same properties again should correctly
385 * increase the refcount of the object returned as well */
387 gst_controller_new (G_OBJECT (elem), "ulong", "double", "float", NULL);
388 fail_unless (ctrl3 != NULL, NULL);
389 fail_unless (ctrl3 == ctrl, NULL);
391 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
392 fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 3);
394 g_object_unref (ctrl);
395 g_object_unref (ctrl2);
396 g_object_unref (ctrl3);
397 gst_object_unref (elem);
402 /* controlling several params should return the same controller */
403 GST_START_TEST (controller_new_okay3)
405 GstController *ctrl1, *ctrl2, *ctrl3;
408 gst_controller_init (NULL, NULL);
410 elem = gst_element_factory_make ("testmonosource", "test_source");
412 /* that property should exist and should be controllable */
413 ctrl1 = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
414 fail_unless (ctrl1 != NULL, NULL);
416 /* that property should exist and should be controllable */
417 ctrl2 = gst_controller_new (G_OBJECT (elem), "double", NULL);
418 fail_unless (ctrl2 != NULL, NULL);
419 fail_unless (ctrl1 == ctrl2, NULL);
421 /* that property should exist and should be controllable */
422 ctrl3 = gst_controller_new (G_OBJECT (elem), "float", NULL);
423 fail_unless (ctrl3 != NULL, NULL);
424 fail_unless (ctrl1 == ctrl3, NULL);
426 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl1)->ref_count);
427 fail_unless_equals_int (G_OBJECT (ctrl1)->ref_count, 3);
428 g_object_unref (ctrl1);
429 g_object_unref (ctrl2);
430 g_object_unref (ctrl3);
431 gst_object_unref (elem);
436 /* controlling a params twice should be handled */
437 GST_START_TEST (controller_param_twice)
443 gst_controller_init (NULL, NULL);
445 elem = gst_element_factory_make ("testmonosource", "test_source");
447 /* that property should exist and should be controllable */
448 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", "ulong", NULL);
449 fail_unless (ctrl != NULL, NULL);
451 /* it should have been added at least once, let remove it */
452 res = gst_controller_remove_properties (ctrl, "ulong", NULL);
453 fail_unless (res, NULL);
455 /* removing it agian should not work */
456 res = gst_controller_remove_properties (ctrl, "ulong", NULL);
457 fail_unless (!res, NULL);
459 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
460 g_object_unref (ctrl);
461 gst_object_unref (elem);
466 /* tests if we cleanup properly */
467 GST_START_TEST (controller_finalize)
472 gst_controller_init (NULL, NULL);
474 elem = gst_element_factory_make ("testmonosource", "test_source");
476 /* that property should exist and should be controllable */
477 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
478 fail_unless (ctrl != NULL, NULL);
480 /* free the controller */
481 g_object_unref (ctrl);
483 /* object shouldn't have a controller anymore */
484 ctrl = gst_object_get_controller (G_OBJECT (elem));
485 fail_unless (ctrl == NULL, NULL);
487 gst_object_unref (elem);
492 /* tests if we cleanup properly */
493 GST_START_TEST (controller_controlsource_refcounts)
497 GstControlSource *csource, *test_csource;
499 gst_controller_init (NULL, NULL);
501 elem = gst_element_factory_make ("testmonosource", "test_source");
503 /* that property should exist and should be controllable */
504 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
505 fail_unless (ctrl != NULL, NULL);
507 csource = (GstControlSource *) gst_interpolation_control_source_new ();
508 fail_unless (csource != NULL, NULL);
510 fail_unless_equals_int (G_OBJECT (csource)->ref_count, 1);
511 fail_unless (gst_controller_set_control_source (ctrl, "ulong", csource));
512 fail_unless_equals_int (G_OBJECT (csource)->ref_count, 2);
514 g_object_unref (G_OBJECT (csource));
516 test_csource = gst_controller_get_control_source (ctrl, "ulong");
517 fail_unless (test_csource != NULL, NULL);
518 fail_unless (test_csource == csource);
519 fail_unless_equals_int (G_OBJECT (csource)->ref_count, 2);
520 g_object_unref (csource);
522 /* free the controller */
523 g_object_unref (ctrl);
525 /* object shouldn't have a controller anymore */
526 ctrl = gst_object_get_controller (G_OBJECT (elem));
527 fail_unless (ctrl == NULL, NULL);
529 gst_object_unref (elem);
534 /* test timed value handling without interpolation */
535 GST_START_TEST (controller_interpolate_none)
538 GstInterpolationControlSource *csource;
541 GValue val_ulong = { 0, };
543 gst_controller_init (NULL, NULL);
545 elem = gst_element_factory_make ("testmonosource", "test_source");
547 /* that property should exist and should be controllable */
548 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
549 fail_unless (ctrl != NULL, NULL);
551 /* Get interpolation control source */
552 csource = gst_interpolation_control_source_new ();
554 fail_unless (csource != NULL);
555 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
556 GST_CONTROL_SOURCE (csource)));
558 /* set interpolation mode */
559 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
560 GST_INTERPOLATE_NONE));
562 fail_unless (gst_interpolation_control_source_get_count (csource) == 0);
564 /* set control values */
565 g_value_init (&val_ulong, G_TYPE_ULONG);
566 g_value_set_ulong (&val_ulong, 0);
568 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
570 fail_unless (res, NULL);
571 fail_unless (gst_interpolation_control_source_get_count (csource) == 1);
572 g_value_set_ulong (&val_ulong, 100);
574 gst_interpolation_control_source_set (csource, 2 * GST_SECOND,
576 fail_unless (res, NULL);
577 fail_unless (gst_interpolation_control_source_get_count (csource) == 2);
579 g_object_unref (G_OBJECT (csource));
581 /* now pull in values for some timestamps */
582 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
583 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
584 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
585 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
586 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
587 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
589 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
590 g_object_unref (ctrl);
591 gst_object_unref (elem);
596 /* test timed value handling in trigger mode */
597 GST_START_TEST (controller_interpolate_trigger)
600 GstInterpolationControlSource *csource;
603 GValue val_ulong = { 0, };
605 gst_controller_init (NULL, NULL);
607 elem = gst_element_factory_make ("testmonosource", "test_source");
609 /* that property should exist and should be controllable */
610 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
611 fail_unless (ctrl != NULL, NULL);
613 /* Get interpolation control source */
614 csource = gst_interpolation_control_source_new ();
616 fail_unless (csource != NULL);
617 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
618 GST_CONTROL_SOURCE (csource)));
620 /* set interpolation mode */
621 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
622 GST_INTERPOLATE_TRIGGER));
624 g_value_init (&val_ulong, G_TYPE_ULONG);
625 fail_if (gst_control_source_get_value (GST_CONTROL_SOURCE (csource),
626 0 * GST_SECOND, &val_ulong));
628 /* set control values */
629 g_value_set_ulong (&val_ulong, 50);
631 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
633 fail_unless (res, NULL);
634 g_value_set_ulong (&val_ulong, 100);
636 gst_interpolation_control_source_set (csource, 2 * GST_SECOND,
638 fail_unless (res, NULL);
641 /* now pull in values for some timestamps */
642 fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource),
643 0 * GST_SECOND, &val_ulong));
644 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
645 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
646 fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource),
647 1 * GST_SECOND, &val_ulong));
648 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
649 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
650 fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource),
651 2 * GST_SECOND, &val_ulong));
652 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
653 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
655 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
656 g_object_unref (G_OBJECT (csource));
657 g_object_unref (ctrl);
658 gst_object_unref (elem);
663 /* test timed value handling with linear interpolation */
664 GST_START_TEST (controller_interpolate_linear)
667 GstInterpolationControlSource *csource;
670 GValue val_ulong = { 0, };
672 gst_controller_init (NULL, NULL);
674 elem = gst_element_factory_make ("testmonosource", "test_source");
676 /* that property should exist and should be controllable */
677 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
678 fail_unless (ctrl != NULL, NULL);
680 /* Get interpolation control source */
681 csource = gst_interpolation_control_source_new ();
683 fail_unless (csource != NULL);
684 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
685 GST_CONTROL_SOURCE (csource)));
687 /* set interpolation mode */
688 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
689 GST_INTERPOLATE_LINEAR));
691 /* set control values */
692 g_value_init (&val_ulong, G_TYPE_ULONG);
693 g_value_set_ulong (&val_ulong, 0);
695 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
697 fail_unless (res, NULL);
698 g_value_set_ulong (&val_ulong, 100);
700 gst_interpolation_control_source_set (csource, 2 * GST_SECOND,
702 fail_unless (res, NULL);
704 g_object_unref (G_OBJECT (csource));
706 /* now pull in values for some timestamps */
707 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
708 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
709 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
710 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
711 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
712 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
714 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
715 g_object_unref (ctrl);
716 gst_object_unref (elem);
721 /* test timed value handling with cubic interpolation */
722 GST_START_TEST (controller_interpolate_cubic)
725 GstInterpolationControlSource *csource;
728 GValue val_double = { 0, };
730 gst_controller_init (NULL, NULL);
732 elem = gst_element_factory_make ("testmonosource", "test_source");
734 /* that property should exist and should be controllable */
735 ctrl = gst_controller_new (G_OBJECT (elem), "double", NULL);
736 fail_unless (ctrl != NULL, NULL);
738 /* Get interpolation control source */
739 csource = gst_interpolation_control_source_new ();
741 fail_unless (csource != NULL);
742 fail_unless (gst_controller_set_control_source (ctrl, "double",
743 GST_CONTROL_SOURCE (csource)));
745 /* set interpolation mode */
746 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
747 GST_INTERPOLATE_CUBIC));
749 /* set control values */
750 g_value_init (&val_double, G_TYPE_DOUBLE);
751 g_value_set_double (&val_double, 0.0);
753 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
755 fail_unless (res, NULL);
756 g_value_set_double (&val_double, 5.0);
758 gst_interpolation_control_source_set (csource, 1 * GST_SECOND,
760 fail_unless (res, NULL);
761 g_value_set_double (&val_double, 2.0);
763 gst_interpolation_control_source_set (csource, 2 * GST_SECOND,
765 fail_unless (res, NULL);
766 g_value_set_double (&val_double, 8.0);
768 gst_interpolation_control_source_set (csource, 4 * GST_SECOND,
770 fail_unless (res, NULL);
772 g_object_unref (G_OBJECT (csource));
774 /* now pull in values for some timestamps */
775 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
776 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 0.0);
777 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
778 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 5.0);
779 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
780 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 2.0);
781 gst_controller_sync_values (ctrl, 3 * GST_SECOND);
782 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double > 2.0 &&
783 GST_TEST_MONO_SOURCE (elem)->val_double < 8.0, NULL);
784 gst_controller_sync_values (ctrl, 4 * GST_SECOND);
785 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 8.0);
786 gst_controller_sync_values (ctrl, 5 * GST_SECOND);
787 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_double, 8.0);
789 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
790 g_object_unref (ctrl);
791 gst_object_unref (elem);
796 /* make sure we don't crash when someone sets an unsupported interpolation
798 GST_START_TEST (controller_interpolate_unimplemented)
801 GstInterpolationControlSource *csource;
804 gst_controller_init (NULL, NULL);
806 elem = gst_element_factory_make ("testmonosource", "test_source");
808 /* that property should exist and should be controllable */
809 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
810 fail_unless (ctrl != NULL, NULL);
812 /* Get interpolation control source */
813 csource = gst_interpolation_control_source_new ();
815 fail_unless (csource != NULL);
816 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
817 GST_CONTROL_SOURCE (csource)));
819 /* set completely bogus interpolation mode */
820 fail_if (gst_interpolation_control_source_set_interpolation_mode (csource,
821 (GstInterpolateMode) 93871));
823 g_object_unref (G_OBJECT (csource));
825 g_object_unref (ctrl);
826 gst_object_unref (elem);
832 GST_START_TEST (controller_interpolation_unset)
835 GstInterpolationControlSource *csource;
838 GValue val_ulong = { 0, };
840 gst_controller_init (NULL, NULL);
842 elem = gst_element_factory_make ("testmonosource", "test_source");
844 /* that property should exist and should be controllable */
845 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
846 fail_unless (ctrl != NULL, NULL);
848 /* Get interpolation control source */
849 csource = gst_interpolation_control_source_new ();
851 fail_unless (csource != NULL);
852 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
853 GST_CONTROL_SOURCE (csource)));
855 /* set interpolation mode */
856 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
857 GST_INTERPOLATE_NONE));
859 /* set control values */
860 g_value_init (&val_ulong, G_TYPE_ULONG);
861 g_value_set_ulong (&val_ulong, 0);
863 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
865 fail_unless (res, NULL);
866 g_value_set_ulong (&val_ulong, 100);
868 gst_interpolation_control_source_set (csource, 1 * GST_SECOND,
870 fail_unless (res, NULL);
871 g_value_set_ulong (&val_ulong, 50);
873 gst_interpolation_control_source_set (csource, 2 * GST_SECOND,
875 fail_unless (res, NULL);
878 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
879 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
880 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
881 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
882 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
883 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
886 res = gst_interpolation_control_source_unset (csource, 1 * GST_SECOND);
887 fail_unless (res, NULL);
889 g_object_unref (csource);
891 /* verify value again */
892 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
893 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
894 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
895 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
897 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
898 g_object_unref (ctrl);
899 gst_object_unref (elem);
904 /* test _unset_all() */
905 GST_START_TEST (controller_interpolation_unset_all)
908 GstInterpolationControlSource *csource;
911 GValue val_ulong = { 0, };
913 gst_controller_init (NULL, NULL);
915 elem = gst_element_factory_make ("testmonosource", "test_source");
917 /* that property should exist and should be controllable */
918 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
919 fail_unless (ctrl != NULL, NULL);
921 /* Get interpolation control source */
922 csource = gst_interpolation_control_source_new ();
924 fail_unless (csource != NULL);
925 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
926 GST_CONTROL_SOURCE (csource)));
928 /* set interpolation mode */
929 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
930 GST_INTERPOLATE_NONE));
932 /* set control values */
933 g_value_init (&val_ulong, G_TYPE_ULONG);
934 g_value_set_ulong (&val_ulong, 0);
936 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
938 fail_unless (res, NULL);
939 g_value_set_ulong (&val_ulong, 100);
941 gst_interpolation_control_source_set (csource, 1 * GST_SECOND,
943 fail_unless (res, NULL);
946 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
947 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
948 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
949 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
952 gst_interpolation_control_source_unset_all (csource);
954 g_object_unref (csource);
956 /* verify value again */
957 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
958 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
960 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
961 g_object_unref (ctrl);
962 gst_object_unref (elem);
967 /* test retrieval of an array of values with get_value_array() */
968 GST_START_TEST (controller_interpolation_linear_value_array)
971 GstInterpolationControlSource *csource;
974 GValue val_ulong = { 0, };
975 GstValueArray values = { NULL, };
977 gst_controller_init (NULL, NULL);
979 elem = gst_element_factory_make ("testmonosource", "test_source");
981 /* that property should exist and should be controllable */
982 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
983 fail_unless (ctrl != NULL, NULL);
985 /* Get interpolation control source */
986 csource = gst_interpolation_control_source_new ();
988 fail_unless (csource != NULL);
989 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
990 GST_CONTROL_SOURCE (csource)));
992 /* set interpolation mode */
993 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
994 GST_INTERPOLATE_LINEAR));
996 /* set control values */
997 g_value_init (&val_ulong, G_TYPE_ULONG);
998 g_value_set_ulong (&val_ulong, 0);
1000 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
1002 fail_unless (res, NULL);
1003 g_value_set_ulong (&val_ulong, 100);
1005 gst_interpolation_control_source_set (csource, 2 * GST_SECOND,
1007 fail_unless (res, NULL);
1009 /* now pull in values for some timestamps */
1010 values.property_name = "ulong";
1011 values.nbsamples = 3;
1012 values.sample_interval = GST_SECOND;
1013 values.values = (gpointer) g_new (gulong, 3);
1015 fail_unless (gst_control_source_get_value_array (GST_CONTROL_SOURCE (csource),
1017 fail_unless_equals_int (((gulong *) values.values)[0], 0);
1018 fail_unless_equals_int (((gulong *) values.values)[1], 50);
1019 fail_unless_equals_int (((gulong *) values.values)[2], 100);
1021 g_object_unref (csource);
1023 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1024 g_free (values.values);
1025 g_object_unref (ctrl);
1026 gst_object_unref (elem);
1031 /* test if values below minimum and above maximum are clipped */
1032 GST_START_TEST (controller_interpolation_linear_invalid_values)
1034 GstController *ctrl;
1035 GstInterpolationControlSource *csource;
1038 GValue val_float = { 0, };
1040 gst_controller_init (NULL, NULL);
1042 elem = gst_element_factory_make ("testmonosource", "test_source");
1044 /* that property should exist and should be controllable */
1045 ctrl = gst_controller_new (G_OBJECT (elem), "float", NULL);
1046 fail_unless (ctrl != NULL, NULL);
1048 /* Get interpolation control source */
1049 csource = gst_interpolation_control_source_new ();
1051 fail_unless (csource != NULL);
1052 fail_unless (gst_controller_set_control_source (ctrl, "float",
1053 GST_CONTROL_SOURCE (csource)));
1055 /* set interpolation mode */
1056 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
1057 GST_INTERPOLATE_LINEAR));
1059 /* set control values */
1060 g_value_init (&val_float, G_TYPE_FLOAT);
1061 g_value_set_float (&val_float, 200.0);
1063 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
1065 fail_unless (res, NULL);
1066 g_value_set_float (&val_float, -200.0);
1068 gst_interpolation_control_source_set (csource, 4 * GST_SECOND,
1070 fail_unless (res, NULL);
1072 g_object_unref (csource);
1074 /* now pull in values for some timestamps and see if clipping works */
1076 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1077 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 100.0);
1079 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1080 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 100.0);
1082 gst_controller_sync_values (ctrl, 1 * GST_SECOND + 500 * GST_MSECOND);
1083 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 50.0);
1085 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1086 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
1088 gst_controller_sync_values (ctrl, 3 * GST_SECOND);
1089 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
1091 gst_controller_sync_values (ctrl, 4 * GST_SECOND);
1092 fail_unless_equals_float (GST_TEST_MONO_SOURCE (elem)->val_float, 0.0);
1094 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1095 g_object_unref (ctrl);
1096 gst_object_unref (elem);
1101 GST_START_TEST (controller_interpolation_linear_default_values)
1103 GstController *ctrl;
1104 GstInterpolationControlSource *csource;
1107 GValue val_ulong = { 0, };
1109 gst_controller_init (NULL, NULL);
1111 elem = gst_element_factory_make ("testmonosource", "test_source");
1113 /* that property should exist and should be controllable */
1114 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1115 fail_unless (ctrl != NULL, NULL);
1117 /* Get interpolation control source */
1118 csource = gst_interpolation_control_source_new ();
1120 fail_unless (csource != NULL);
1121 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1122 GST_CONTROL_SOURCE (csource)));
1124 /* set interpolation mode */
1125 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
1126 GST_INTERPOLATE_LINEAR));
1128 /* Should fail if no value was set yet */
1129 g_value_init (&val_ulong, G_TYPE_ULONG);
1130 fail_if (gst_control_source_get_value (GST_CONTROL_SOURCE (csource),
1131 0 * GST_SECOND, &val_ulong));
1133 /* set control values */
1134 g_value_set_ulong (&val_ulong, 0);
1136 gst_interpolation_control_source_set (csource, 1 * GST_SECOND,
1138 fail_unless (res, NULL);
1139 g_value_set_ulong (&val_ulong, 100);
1141 gst_interpolation_control_source_set (csource, 3 * GST_SECOND,
1143 fail_unless (res, NULL);
1145 /* now pull in values for some timestamps */
1146 /* should give the value of the first control point for timestamps before it */
1147 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1148 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1149 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1150 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1151 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1152 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1153 gst_controller_sync_values (ctrl, 3 * GST_SECOND);
1154 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1156 /* set control values */
1157 g_value_set_ulong (&val_ulong, 0);
1159 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
1161 fail_unless (res, NULL);
1162 g_value_set_ulong (&val_ulong, 100);
1164 gst_interpolation_control_source_set (csource, 2 * GST_SECOND,
1166 fail_unless (res, NULL);
1168 /* unset the old ones */
1169 res = gst_interpolation_control_source_unset (csource, 1 * GST_SECOND);
1170 fail_unless (res, NULL);
1171 res = gst_interpolation_control_source_unset (csource, 3 * GST_SECOND);
1172 fail_unless (res, NULL);
1174 /* now pull in values for some timestamps */
1175 /* should now give our value for timestamp 0 */
1176 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1177 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1178 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1179 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1180 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1181 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1183 g_object_unref (G_OBJECT (csource));
1185 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1186 g_object_unref (ctrl);
1187 gst_object_unref (elem);
1192 /* test gst_controller_set_disabled() with linear interpolation */
1193 GST_START_TEST (controller_interpolate_linear_disabled)
1195 GstController *ctrl;
1196 GstInterpolationControlSource *csource, *csource2;
1199 GValue val_ulong = { 0, }
1203 gst_controller_init (NULL, NULL);
1205 elem = gst_element_factory_make ("testmonosource", "test_source");
1207 /* that property should exist and should be controllable */
1208 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", "double", NULL);
1209 fail_unless (ctrl != NULL, NULL);
1211 /* Get interpolation control source */
1212 csource = gst_interpolation_control_source_new ();
1213 csource2 = gst_interpolation_control_source_new ();
1215 fail_unless (csource != NULL);
1216 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1217 GST_CONTROL_SOURCE (csource)));
1218 fail_unless (csource2 != NULL);
1219 fail_unless (gst_controller_set_control_source (ctrl, "double",
1220 GST_CONTROL_SOURCE (csource2)));
1222 /* set interpolation mode */
1223 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
1224 GST_INTERPOLATE_LINEAR));
1225 fail_unless (gst_interpolation_control_source_set_interpolation_mode
1226 (csource2, GST_INTERPOLATE_LINEAR));
1228 /* set control values */
1229 g_value_init (&val_ulong, G_TYPE_ULONG);
1230 g_value_set_ulong (&val_ulong, 0);
1232 gst_interpolation_control_source_set (csource, 0 * GST_SECOND,
1234 fail_unless (res, NULL);
1235 g_value_set_ulong (&val_ulong, 100);
1237 gst_interpolation_control_source_set (csource, 2 * GST_SECOND,
1239 fail_unless (res, NULL);
1241 g_object_unref (G_OBJECT (csource));
1243 /* set control values */
1244 g_value_init (&val_double, G_TYPE_DOUBLE);
1245 g_value_set_double (&val_double, 2.0);
1247 gst_interpolation_control_source_set (csource2, 0 * GST_SECOND,
1249 fail_unless (res, NULL);
1250 g_value_set_double (&val_double, 4.0);
1252 gst_interpolation_control_source_set (csource2, 2 * GST_SECOND,
1254 fail_unless (res, NULL);
1256 g_object_unref (G_OBJECT (csource2));
1258 /* now pull in values for some timestamps */
1259 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1260 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1261 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
1262 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1263 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1264 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 3.0, NULL);
1265 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1266 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1267 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 4.0, NULL);
1269 /* now pull in values for some timestamps, prop double disabled */
1270 GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
1271 GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
1272 gst_controller_set_property_disabled (ctrl, "double", TRUE);
1273 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1274 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1275 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
1276 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1277 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1278 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
1279 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1280 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1281 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
1283 /* now pull in values for some timestamps, after enabling double again */
1284 GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
1285 GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
1286 gst_controller_set_property_disabled (ctrl, "double", FALSE);
1287 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1288 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1289 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
1290 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1291 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1292 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 3.0, NULL);
1293 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1294 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1295 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 4.0, NULL);
1297 /* now pull in values for some timestamps, after disabling all props */
1298 GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
1299 GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
1300 gst_controller_set_disabled (ctrl, TRUE);
1301 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1302 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1303 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
1304 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1305 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1306 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
1307 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1308 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1309 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 0.0, NULL);
1311 /* now pull in values for some timestamps, enabling double again */
1312 GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
1313 GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
1314 gst_controller_set_property_disabled (ctrl, "double", FALSE);
1315 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1316 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1317 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
1318 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1319 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1320 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 3.0, NULL);
1321 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1322 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1323 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 4.0, NULL);
1325 /* now pull in values for some timestamps, enabling all */
1326 GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;
1327 GST_TEST_MONO_SOURCE (elem)->val_double = 0.0;
1328 gst_controller_set_disabled (ctrl, FALSE);
1329 gst_controller_sync_values (ctrl, 0 * GST_SECOND);
1330 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1331 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 2.0, NULL);
1332 gst_controller_sync_values (ctrl, 1 * GST_SECOND);
1333 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1334 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 3.0, NULL);
1335 gst_controller_sync_values (ctrl, 2 * GST_SECOND);
1336 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1337 fail_unless (GST_TEST_MONO_SOURCE (elem)->val_double == 4.0, NULL);
1339 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1340 g_object_unref (ctrl);
1341 gst_object_unref (elem);
1347 GST_START_TEST (controller_interpolation_set_from_list)
1349 GstController *ctrl;
1350 GstInterpolationControlSource *csource;
1351 GstTimedValue *tval;
1353 GSList *list = NULL;
1355 gst_controller_init (NULL, NULL);
1357 /* test that an invalid timestamp throws a warning of some sort */
1358 elem = gst_element_factory_make ("testmonosource", "test_source");
1360 /* that property should exist and should be controllable */
1361 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1362 fail_unless (ctrl != NULL, NULL);
1364 /* Get interpolation control source */
1365 csource = gst_interpolation_control_source_new ();
1367 fail_unless (csource != NULL);
1368 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1369 GST_CONTROL_SOURCE (csource)));
1371 /* set interpolation mode */
1372 fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource,
1373 GST_INTERPOLATE_LINEAR));
1375 /* set control value */
1376 tval = g_new0 (GstTimedValue, 1);
1377 tval->timestamp = GST_CLOCK_TIME_NONE;
1378 g_value_init (&tval->value, G_TYPE_ULONG);
1379 g_value_set_ulong (&tval->value, 0);
1381 list = g_slist_append (list, tval);
1383 fail_if (gst_interpolation_control_source_set_from_list (csource, list));
1385 /* try again with a valid stamp, should work now */
1386 tval->timestamp = 0;
1387 fail_unless (gst_interpolation_control_source_set_from_list (csource, list));
1389 g_object_unref (csource);
1391 /* allocated GstTimedValue now belongs to the controller, but list not */
1392 g_value_unset (&tval->value);
1394 g_slist_free (list);
1395 g_object_unref (ctrl);
1396 gst_object_unref (elem);
1401 /* test lfo control source with sine waveform */
1402 GST_START_TEST (controller_lfo_sine)
1404 GstController *ctrl;
1405 GstLFOControlSource *csource;
1411 gst_controller_init (NULL, NULL);
1413 elem = gst_element_factory_make ("testmonosource", "test_source");
1415 /* that property should exist and should be controllable */
1416 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1417 fail_unless (ctrl != NULL, NULL);
1419 /* Get interpolation control source */
1420 csource = gst_lfo_control_source_new ();
1422 fail_unless (csource != NULL);
1423 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1424 GST_CONTROL_SOURCE (csource)));
1426 /* set amplitude and offset values */
1427 g_value_init (&, G_TYPE_ULONG);
1428 g_value_init (&off, G_TYPE_ULONG);
1429 g_value_set_ulong (&, 100);
1430 g_value_set_ulong (&off, 100);
1432 /* set waveform mode */
1433 g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SINE,
1434 "frequency", 1.0, "timeshift", (GstClockTime) 0,
1435 "amplitude", &, "offset", &off, NULL);
1437 g_object_unref (G_OBJECT (csource));
1439 /* now pull in values for some timestamps */
1440 gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
1441 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1442 gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
1443 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1444 gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
1445 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1446 gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
1447 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1448 gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
1449 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1450 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1451 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1452 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1453 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1454 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1455 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1456 gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
1457 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1458 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1459 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1460 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1461 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1462 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1463 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1465 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1466 g_object_unref (ctrl);
1467 gst_object_unref (elem);
1472 /* test lfo control source with sine waveform and timeshift */
1473 GST_START_TEST (controller_lfo_sine_timeshift)
1475 GstController *ctrl;
1476 GstLFOControlSource *csource;
1482 gst_controller_init (NULL, NULL);
1484 elem = gst_element_factory_make ("testmonosource", "test_source");
1486 /* that property should exist and should be controllable */
1487 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1488 fail_unless (ctrl != NULL, NULL);
1490 /* Get interpolation control source */
1491 csource = gst_lfo_control_source_new ();
1493 fail_unless (csource != NULL);
1494 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1495 GST_CONTROL_SOURCE (csource)));
1497 /* set amplitude and offset values */
1498 g_value_init (&, G_TYPE_ULONG);
1499 g_value_init (&off, G_TYPE_ULONG);
1500 g_value_set_ulong (&, 100);
1501 g_value_set_ulong (&off, 100);
1503 /* set waveform mode */
1504 g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SINE,
1505 "frequency", 1.0, "timeshift", 250 * GST_MSECOND,
1506 "amplitude", &, "offset", &off, NULL);
1508 g_object_unref (G_OBJECT (csource));
1510 /* now pull in values for some timestamps */
1511 gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
1512 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1513 gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
1514 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1515 gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
1516 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1517 gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
1518 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1519 gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
1520 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1521 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1522 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1523 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1524 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1525 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1526 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1527 gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
1528 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1529 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1530 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1531 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1532 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1533 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1534 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1536 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1537 g_object_unref (ctrl);
1538 gst_object_unref (elem);
1544 /* test lfo control source with square waveform */
1545 GST_START_TEST (controller_lfo_square)
1547 GstController *ctrl;
1548 GstLFOControlSource *csource;
1554 gst_controller_init (NULL, NULL);
1556 elem = gst_element_factory_make ("testmonosource", "test_source");
1558 /* that property should exist and should be controllable */
1559 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1560 fail_unless (ctrl != NULL, NULL);
1562 /* Get interpolation control source */
1563 csource = gst_lfo_control_source_new ();
1565 fail_unless (csource != NULL);
1566 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1567 GST_CONTROL_SOURCE (csource)));
1569 /* set amplitude and offset values */
1570 g_value_init (&, G_TYPE_ULONG);
1571 g_value_init (&off, G_TYPE_ULONG);
1572 g_value_set_ulong (&, 100);
1573 g_value_set_ulong (&off, 100);
1575 /* set waveform mode */
1576 g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SQUARE,
1577 "frequency", 1.0, "timeshift", (GstClockTime) 0,
1578 "amplitude", &, "offset", &off, NULL);
1580 g_object_unref (G_OBJECT (csource));
1582 /* now pull in values for some timestamps */
1583 gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
1584 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1585 gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
1586 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1587 gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
1588 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1589 gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
1590 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1591 gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
1592 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1593 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1594 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1595 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1596 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1597 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1598 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1599 gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
1600 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1601 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1602 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1603 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1604 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1605 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1606 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1608 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1609 g_object_unref (ctrl);
1610 gst_object_unref (elem);
1615 /* test lfo control source with saw waveform */
1616 GST_START_TEST (controller_lfo_saw)
1618 GstController *ctrl;
1619 GstLFOControlSource *csource;
1625 gst_controller_init (NULL, NULL);
1627 elem = gst_element_factory_make ("testmonosource", "test_source");
1629 /* that property should exist and should be controllable */
1630 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1631 fail_unless (ctrl != NULL, NULL);
1633 /* Get interpolation control source */
1634 csource = gst_lfo_control_source_new ();
1636 fail_unless (csource != NULL);
1637 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1638 GST_CONTROL_SOURCE (csource)));
1640 /* set amplitude and offset values */
1641 g_value_init (&, G_TYPE_ULONG);
1642 g_value_init (&off, G_TYPE_ULONG);
1643 g_value_set_ulong (&, 100);
1644 g_value_set_ulong (&off, 100);
1646 /* set waveform mode */
1647 g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SAW,
1648 "frequency", 1.0, "timeshift", (GstClockTime) 0,
1649 "amplitude", &, "offset", &off, NULL);
1651 g_object_unref (G_OBJECT (csource));
1653 /* now pull in values for some timestamps */
1654 gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
1655 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1656 gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
1657 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);;
1658 gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
1659 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1660 gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
1661 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1662 gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
1663 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1664 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1665 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);;
1666 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1667 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1668 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1669 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1670 gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
1671 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1672 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1673 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);;
1674 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1675 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1676 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1677 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1679 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1680 g_object_unref (ctrl);
1681 gst_object_unref (elem);
1686 /* test lfo control source with reverse saw waveform */
1687 GST_START_TEST (controller_lfo_rsaw)
1689 GstController *ctrl;
1690 GstLFOControlSource *csource;
1696 gst_controller_init (NULL, NULL);
1698 elem = gst_element_factory_make ("testmonosource", "test_source");
1700 /* that property should exist and should be controllable */
1701 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1702 fail_unless (ctrl != NULL, NULL);
1704 /* Get interpolation control source */
1705 csource = gst_lfo_control_source_new ();
1707 fail_unless (csource != NULL);
1708 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1709 GST_CONTROL_SOURCE (csource)));
1711 /* set amplitude and offset values */
1712 g_value_init (&, G_TYPE_ULONG);
1713 g_value_init (&off, G_TYPE_ULONG);
1714 g_value_set_ulong (&, 100);
1715 g_value_set_ulong (&off, 100);
1717 /* set waveform mode */
1718 g_object_set (csource, "waveform", GST_LFO_WAVEFORM_REVERSE_SAW,
1719 "frequency", 1.0, "timeshift", (GstClockTime) 0,
1720 "amplitude", &, "offset", &off, NULL);
1722 g_object_unref (G_OBJECT (csource));
1724 /* now pull in values for some timestamps */
1725 gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
1726 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1727 gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
1728 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1729 gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
1730 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1731 gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
1732 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);;
1733 gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
1734 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1735 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1736 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1737 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1738 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1739 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1740 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);;
1741 gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
1742 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1743 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1744 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);;
1745 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1746 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1747 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1748 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 150);;
1750 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1751 g_object_unref (ctrl);
1752 gst_object_unref (elem);
1757 /* test lfo control source with saw waveform */
1758 GST_START_TEST (controller_lfo_triangle)
1760 GstController *ctrl;
1761 GstLFOControlSource *csource;
1767 gst_controller_init (NULL, NULL);
1769 elem = gst_element_factory_make ("testmonosource", "test_source");
1771 /* that property should exist and should be controllable */
1772 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1773 fail_unless (ctrl != NULL, NULL);
1775 /* Get interpolation control source */
1776 csource = gst_lfo_control_source_new ();
1778 fail_unless (csource != NULL);
1779 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1780 GST_CONTROL_SOURCE (csource)));
1782 /* set amplitude and offset values */
1783 g_value_init (&, G_TYPE_ULONG);
1784 g_value_init (&off, G_TYPE_ULONG);
1785 g_value_set_ulong (&, 100);
1786 g_value_set_ulong (&off, 100);
1788 /* set waveform mode */
1789 g_object_set (csource, "waveform", GST_LFO_WAVEFORM_TRIANGLE,
1790 "frequency", 1.0, "timeshift", (GstClockTime) 0,
1791 "amplitude", &, "offset", &off, NULL);
1793 g_object_unref (G_OBJECT (csource));
1795 /* now pull in values for some timestamps */
1796 gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
1797 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1798 gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
1799 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1800 gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
1801 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1802 gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
1803 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1804 gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
1805 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1806 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1807 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1808 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1809 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1810 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1811 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1812 gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
1813 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1814 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1815 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 200);;
1816 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1817 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);;
1818 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1819 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1821 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1822 g_object_unref (ctrl);
1823 gst_object_unref (elem);
1828 /* test lfo control source with nothing set */
1829 GST_START_TEST (controller_lfo_none)
1831 GstController *ctrl;
1832 GstLFOControlSource *csource;
1835 gst_controller_init (NULL, NULL);
1837 elem = gst_element_factory_make ("testmonosource", "test_source");
1839 /* that property should exist and should be controllable */
1840 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1841 fail_unless (ctrl != NULL, NULL);
1843 /* Get interpolation control source */
1844 csource = gst_lfo_control_source_new ();
1846 fail_unless (csource != NULL);
1847 fail_unless (gst_controller_set_control_source (ctrl, "ulong",
1848 GST_CONTROL_SOURCE (csource)));
1850 g_object_unref (G_OBJECT (csource));
1852 /* now pull in values for some timestamps */
1853 gst_controller_sync_values (ctrl, 0 * GST_MSECOND);
1854 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1855 gst_controller_sync_values (ctrl, 250 * GST_MSECOND);
1856 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1857 gst_controller_sync_values (ctrl, 500 * GST_MSECOND);
1858 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1859 gst_controller_sync_values (ctrl, 750 * GST_MSECOND);
1860 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1861 gst_controller_sync_values (ctrl, 1000 * GST_MSECOND);
1862 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1863 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1864 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1865 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1866 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1867 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1868 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1869 gst_controller_sync_values (ctrl, 2000 * GST_MSECOND);
1870 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1871 gst_controller_sync_values (ctrl, 1250 * GST_MSECOND);
1872 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1873 gst_controller_sync_values (ctrl, 1500 * GST_MSECOND);
1874 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1875 gst_controller_sync_values (ctrl, 1750 * GST_MSECOND);
1876 fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);;
1878 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1879 g_object_unref (ctrl);
1880 gst_object_unref (elem);
1885 /* tests if we can run helper methods against any GObject */
1886 GST_START_TEST (controller_helper_any_gobject)
1891 gst_controller_init (NULL, NULL);
1893 elem = gst_element_factory_make ("bin", "test_elem");
1895 /* that element is not controllable */
1896 res = gst_object_sync_values (G_OBJECT (elem), 0LL);
1897 fail_unless (res == FALSE, NULL);
1899 gst_object_unref (elem);
1904 GST_START_TEST (controller_refcount_new_list)
1906 GstController *ctrl, *ctrl2;
1910 gst_controller_init (NULL, NULL);
1912 /* that property should exist and should be controllable */
1913 elem = gst_element_factory_make ("testmonosource", "test_source");
1914 list = g_list_append (NULL, "ulong");
1915 ctrl = gst_controller_new_list (G_OBJECT (elem), list);
1916 fail_unless (ctrl != NULL, NULL);
1917 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1918 fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
1920 g_object_unref (ctrl);
1921 gst_object_unref (elem);
1923 /* try the same property twice, make sure the refcount is still 1 */
1924 elem = gst_element_factory_make ("testmonosource", "test_source");
1925 list = g_list_append (NULL, "ulong");
1926 list = g_list_append (list, "ulong");
1927 ctrl = gst_controller_new_list (G_OBJECT (elem), list);
1928 fail_unless (ctrl != NULL, NULL);
1929 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1930 fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
1932 g_object_unref (ctrl);
1933 gst_object_unref (elem);
1935 /* try two properties, make sure the refcount is still 1 */
1936 elem = gst_element_factory_make ("testmonosource", "test_source");
1937 list = g_list_append (NULL, "ulong");
1938 list = g_list_append (list, "boolean");
1939 ctrl = gst_controller_new_list (G_OBJECT (elem), list);
1940 fail_unless (ctrl != NULL, NULL);
1941 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1942 fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
1944 g_object_unref (ctrl);
1945 gst_object_unref (elem);
1947 /* try _new_list with existing controller */
1948 elem = gst_element_factory_make ("testmonosource", "test_source");
1949 ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1950 fail_unless (ctrl != NULL, NULL);
1951 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1952 list = g_list_append (NULL, "ulong");
1953 ctrl2 = gst_controller_new_list (G_OBJECT (elem), list);
1954 fail_unless (ctrl2 != NULL, NULL);
1955 fail_unless (ctrl == ctrl2, NULL);
1956 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1957 fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
1959 g_object_unref (ctrl);
1960 g_object_unref (ctrl2);
1961 gst_object_unref (elem);
1963 /* try _new_list first and then _new */
1964 elem = gst_element_factory_make ("testmonosource", "test_source");
1965 list = g_list_append (NULL, "ulong");
1966 ctrl = gst_controller_new_list (G_OBJECT (elem), list);
1967 fail_unless (ctrl != NULL, NULL);
1968 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1969 ctrl2 = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
1970 fail_unless (ctrl2 != NULL, NULL);
1971 fail_unless (ctrl == ctrl2, NULL);
1972 GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
1973 fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
1975 g_object_unref (ctrl);
1976 g_object_unref (ctrl2);
1977 gst_object_unref (elem);
1983 gst_controller_suite (void)
1985 Suite *s = suite_create ("Controller");
1986 TCase *tc = tcase_create ("general");
1988 suite_add_tcase (s, tc);
1989 tcase_add_test (tc, controller_init);
1990 tcase_add_test (tc, controller_refcount_new_list);
1991 tcase_add_test (tc, controller_new_fail1);
1992 tcase_add_test (tc, controller_new_fail2);
1993 tcase_add_test (tc, controller_new_fail3);
1994 tcase_add_test (tc, controller_new_fail4);
1995 tcase_add_test (tc, controller_new_fail5);
1996 tcase_add_test (tc, controller_new_okay1);
1997 tcase_add_test (tc, controller_new_okay2);
1998 tcase_add_test (tc, controller_new_okay3);
1999 tcase_add_test (tc, controller_param_twice);
2000 tcase_add_test (tc, controller_finalize);
2001 tcase_add_test (tc, controller_controlsource_refcounts);
2002 tcase_add_test (tc, controller_interpolate_none);
2003 tcase_add_test (tc, controller_interpolate_trigger);
2004 tcase_add_test (tc, controller_interpolate_linear);
2005 tcase_add_test (tc, controller_interpolate_cubic);
2006 tcase_add_test (tc, controller_interpolate_unimplemented);
2007 tcase_add_test (tc, controller_interpolation_unset);
2008 tcase_add_test (tc, controller_interpolation_unset_all);
2009 tcase_add_test (tc, controller_interpolation_linear_value_array);
2010 tcase_add_test (tc, controller_interpolation_linear_invalid_values);
2011 tcase_add_test (tc, controller_interpolation_linear_default_values);
2012 tcase_add_test (tc, controller_interpolate_linear_disabled);
2013 tcase_add_test (tc, controller_interpolation_set_from_list);
2014 tcase_add_test (tc, controller_lfo_sine);
2015 tcase_add_test (tc, controller_lfo_sine_timeshift);
2016 tcase_add_test (tc, controller_lfo_square);
2017 tcase_add_test (tc, controller_lfo_saw);
2018 tcase_add_test (tc, controller_lfo_rsaw);
2019 tcase_add_test (tc, controller_lfo_triangle);
2020 tcase_add_test (tc, controller_lfo_none);
2021 tcase_add_test (tc, controller_helper_any_gobject);
2026 GST_CHECK_MAIN (gst_controller);