📄 controller.c
字号:
GST_END_TEST;/* tests for an element with several controlled params */GST_START_TEST (controller_new_okay2){ GstController *ctrl, *ctrl2, *ctrl3; GstElement *elem; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */ ctrl = gst_controller_new (G_OBJECT (elem), "ulong", "double", "float", NULL); fail_unless (ctrl != NULL, NULL); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1); ctrl2 = gst_controller_new (G_OBJECT (elem), "boolean", NULL); fail_unless (ctrl2 != NULL, NULL); fail_unless (ctrl2 == ctrl, NULL); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2); /* trying to control the same properties again should correctly * increase the refcount of the object returned as well */ ctrl3 = gst_controller_new (G_OBJECT (elem), "ulong", "double", "float", NULL); fail_unless (ctrl3 != NULL, NULL); fail_unless (ctrl3 == ctrl, NULL); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 3); g_object_unref (ctrl); g_object_unref (ctrl2); g_object_unref (ctrl3); gst_object_unref (elem);}GST_END_TEST;/* controlling several params should return the same controller */GST_START_TEST (controller_new_okay3){ GstController *ctrl1, *ctrl2, *ctrl3; GstElement *elem; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */ ctrl1 = gst_controller_new (G_OBJECT (elem), "ulong", NULL); fail_unless (ctrl1 != NULL, NULL); /* that property should exist and should be controllable */ ctrl2 = gst_controller_new (G_OBJECT (elem), "double", NULL); fail_unless (ctrl2 != NULL, NULL); fail_unless (ctrl1 == ctrl2, NULL); /* that property should exist and should be controllable */ ctrl3 = gst_controller_new (G_OBJECT (elem), "float", NULL); fail_unless (ctrl3 != NULL, NULL); fail_unless (ctrl1 == ctrl3, NULL); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl1)->ref_count); fail_unless_equals_int (G_OBJECT (ctrl1)->ref_count, 3); g_object_unref (ctrl1); g_object_unref (ctrl2); g_object_unref (ctrl3); gst_object_unref (elem);}GST_END_TEST;/* controlling a params twice should be handled */GST_START_TEST (controller_param_twice){ GstController *ctrl; GstElement *elem; gboolean res; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */ ctrl = gst_controller_new (G_OBJECT (elem), "ulong", "ulong", NULL); fail_unless (ctrl != NULL, NULL); /* it should have been added at least once, let remove it */ res = gst_controller_remove_properties (ctrl, "ulong", NULL); fail_unless (res, NULL); /* removing it agian should not work */ res = gst_controller_remove_properties (ctrl, "ulong", NULL); fail_unless (!res, NULL); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); g_object_unref (ctrl); gst_object_unref (elem);}GST_END_TEST;/* tests if we cleanup properly */GST_START_TEST (controller_finalize){ GstController *ctrl; GstElement *elem; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */ ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); fail_unless (ctrl != NULL, NULL); /* free the controller */ g_object_unref (ctrl); /* object shouldn't have a controller anymore */ ctrl = gst_object_get_controller (G_OBJECT (elem)); fail_unless (ctrl == NULL, NULL); gst_object_unref (elem);}GST_END_TEST;/* tests if we cleanup properly */GST_START_TEST (controller_controlsource_refcounts){ GstController *ctrl; GstElement *elem; GstControlSource *csource, *test_csource; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */ ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); fail_unless (ctrl != NULL, NULL); csource = (GstControlSource *) gst_interpolation_control_source_new (); fail_unless (csource != NULL, NULL); fail_unless_equals_int (G_OBJECT (csource)->ref_count, 1); fail_unless (gst_controller_set_control_source (ctrl, "ulong", csource)); fail_unless_equals_int (G_OBJECT (csource)->ref_count, 2); g_object_unref (G_OBJECT (csource)); test_csource = gst_controller_get_control_source (ctrl, "ulong"); fail_unless (test_csource != NULL, NULL); fail_unless (test_csource == csource); fail_unless_equals_int (G_OBJECT (csource)->ref_count, 2); g_object_unref (csource); /* free the controller */ g_object_unref (ctrl); /* object shouldn't have a controller anymore */ ctrl = gst_object_get_controller (G_OBJECT (elem)); fail_unless (ctrl == NULL, NULL); gst_object_unref (elem);}GST_END_TEST;/* test timed value handling without interpolation */GST_START_TEST (controller_interpolate_none){ GstController *ctrl; GstInterpolationControlSource *csource; GstElement *elem; gboolean res; GValue val_ulong = { 0, }; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */ ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); fail_unless (ctrl != NULL, NULL); /* Get interpolation control source */ csource = gst_interpolation_control_source_new (); fail_unless (csource != NULL); fail_unless (gst_controller_set_control_source (ctrl, "ulong", GST_CONTROL_SOURCE (csource))); /* set interpolation mode */ fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource, GST_INTERPOLATE_NONE)); fail_unless (gst_interpolation_control_source_get_count (csource) == 0); /* set control values */ g_value_init (&val_ulong, G_TYPE_ULONG); g_value_set_ulong (&val_ulong, 0); res = gst_interpolation_control_source_set (csource, 0 * GST_SECOND, &val_ulong); fail_unless (res, NULL); fail_unless (gst_interpolation_control_source_get_count (csource) == 1); g_value_set_ulong (&val_ulong, 100); res = gst_interpolation_control_source_set (csource, 2 * GST_SECOND, &val_ulong); fail_unless (res, NULL); fail_unless (gst_interpolation_control_source_get_count (csource) == 2); g_object_unref (G_OBJECT (csource)); /* now pull in values for some timestamps */ gst_controller_sync_values (ctrl, 0 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);; gst_controller_sync_values (ctrl, 1 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);; gst_controller_sync_values (ctrl, 2 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);; GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); g_object_unref (ctrl); gst_object_unref (elem);}GST_END_TEST;/* test timed value handling in trigger mode */GST_START_TEST (controller_interpolate_trigger){ GstController *ctrl; GstInterpolationControlSource *csource; GstElement *elem; gboolean res; GValue val_ulong = { 0, }; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */ ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); fail_unless (ctrl != NULL, NULL); /* Get interpolation control source */ csource = gst_interpolation_control_source_new (); fail_unless (csource != NULL); fail_unless (gst_controller_set_control_source (ctrl, "ulong", GST_CONTROL_SOURCE (csource))); /* set interpolation mode */ fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource, GST_INTERPOLATE_TRIGGER)); g_value_init (&val_ulong, G_TYPE_ULONG); fail_if (gst_control_source_get_value (GST_CONTROL_SOURCE (csource), 0 * GST_SECOND, &val_ulong)); /* set control values */ g_value_set_ulong (&val_ulong, 50); res = gst_interpolation_control_source_set (csource, 0 * GST_SECOND, &val_ulong); fail_unless (res, NULL); g_value_set_ulong (&val_ulong, 100); res = gst_interpolation_control_source_set (csource, 2 * GST_SECOND, &val_ulong); fail_unless (res, NULL); /* now pull in values for some timestamps */ fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource), 0 * GST_SECOND, &val_ulong)); gst_controller_sync_values (ctrl, 0 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);; fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource), 1 * GST_SECOND, &val_ulong)); gst_controller_sync_values (ctrl, 1 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);; fail_unless (gst_control_source_get_value (GST_CONTROL_SOURCE (csource), 2 * GST_SECOND, &val_ulong)); gst_controller_sync_values (ctrl, 2 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);; GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); g_object_unref (G_OBJECT (csource)); g_object_unref (ctrl); gst_object_unref (elem);}GST_END_TEST;/* test timed value handling with linear interpolation */GST_START_TEST (controller_interpolate_linear){ GstController *ctrl; GstInterpolationControlSource *csource; GstElement *elem; gboolean res; GValue val_ulong = { 0, }; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */ ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); fail_unless (ctrl != NULL, NULL); /* Get interpolation control source */ csource = gst_interpolation_control_source_new (); fail_unless (csource != NULL); fail_unless (gst_controller_set_control_source (ctrl, "ulong", GST_CONTROL_SOURCE (csource))); /* set interpolation mode */ fail_unless (gst_interpolation_control_source_set_interpolation_mode (csource, GST_INTERPOLATE_LINEAR)); /* set control values */ g_value_init (&val_ulong, G_TYPE_ULONG); g_value_set_ulong (&val_ulong, 0); res = gst_interpolation_control_source_set (csource, 0 * GST_SECOND, &val_ulong); fail_unless (res, NULL); g_value_set_ulong (&val_ulong, 100); res = gst_interpolation_control_source_set (csource, 2 * GST_SECOND, &val_ulong); fail_unless (res, NULL); g_object_unref (G_OBJECT (csource)); /* now pull in values for some timestamps */ gst_controller_sync_values (ctrl, 0 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 0);; gst_controller_sync_values (ctrl, 1 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 50);; gst_controller_sync_values (ctrl, 2 * GST_SECOND); fail_unless_equals_int (GST_TEST_MONO_SOURCE (elem)->val_ulong, 100);; GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); g_object_unref (ctrl); gst_object_unref (elem);}GST_END_TEST;/* test timed value handling with cubic interpolation */GST_START_TEST (controller_interpolate_cubic){ GstController *ctrl; GstInterpolationControlSource *csource; GstElement *elem; gboolean res; GValue val_double = { 0, }; gst_controller_init (NULL, NULL); elem = gst_element_factory_make ("testmonosource", "test_source"); /* that property should exist and should be controllable */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -