⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controller.c

📁 GStreamer是一个开源的多媒体框架库。利用它
💻 C
📖 第 1 页 / 共 3 页
字号:
GST_END_TEST;/* tests for an element with controlled params */GST_START_TEST (controller_new_okay1){  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);  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);  g_object_unref (ctrl);  gst_object_unref (elem);}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 (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 (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 (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 (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;/* test timed value handling without interpolation */GST_START_TEST (controller_interpolate_none){  GstController *ctrl;  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);  /* set interpolation mode */  gst_controller_set_interpolation_mode (ctrl, "ulong", GST_INTERPOLATE_NONE);  /* set control values */  g_value_init (&val_ulong, G_TYPE_ULONG);  g_value_set_ulong (&val_ulong, 0);  res = gst_controller_set (ctrl, "ulong", 0 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  g_value_set_ulong (&val_ulong, 100);  res = gst_controller_set (ctrl, "ulong", 2 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  /* now pull in values for some timestamps */  gst_controller_sync_values (ctrl, 0 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);  gst_controller_sync_values (ctrl, 1 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);  gst_controller_sync_values (ctrl, 2 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);  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;  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);  /* set interpolation mode */  gst_controller_set_interpolation_mode (ctrl, "ulong",      GST_INTERPOLATE_TRIGGER);  /* set control values */  g_value_init (&val_ulong, G_TYPE_ULONG);  g_value_set_ulong (&val_ulong, 50);  res = gst_controller_set (ctrl, "ulong", 0 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  g_value_set_ulong (&val_ulong, 100);  res = gst_controller_set (ctrl, "ulong", 2 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  /* now pull in values for some timestamps */  gst_controller_sync_values (ctrl, 0 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);  GST_TEST_MONO_SOURCE (elem)->val_ulong = 0;  gst_controller_sync_values (ctrl, 1 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);  gst_controller_sync_values (ctrl, 2 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);  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 linear interpolation */GST_START_TEST (controller_interpolate_linear){  GstController *ctrl;  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);  /* set interpolation mode */  gst_controller_set_interpolation_mode (ctrl, "ulong", GST_INTERPOLATE_LINEAR);  /* set control values */  g_value_init (&val_ulong, G_TYPE_ULONG);  g_value_set_ulong (&val_ulong, 0);  res = gst_controller_set (ctrl, "ulong", 0 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  g_value_set_ulong (&val_ulong, 100);  res = gst_controller_set (ctrl, "ulong", 2 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  /* now pull in values for some timestamps */  gst_controller_sync_values (ctrl, 0 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 0, NULL);  gst_controller_sync_values (ctrl, 1 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 50, NULL);  gst_controller_sync_values (ctrl, 2 * GST_SECOND);  fail_unless (GST_TEST_MONO_SOURCE (elem)->val_ulong == 100, NULL);  GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);  g_object_unref (ctrl);  gst_object_unref (elem);}GST_END_TEST;/* make sure we don't crash when someone sets an unsupported interpolation * mode */GST_START_TEST (controller_interpolate_unimplemented){  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);  /* set unsupported interpolation mode */  gst_controller_set_interpolation_mode (ctrl, "ulong", GST_INTERPOLATE_CUBIC);  /* set another unsupported interpolation mode */  gst_controller_set_interpolation_mode (ctrl, "ulong",      GST_INTERPOLATE_QUADRATIC);  /* set completely bogus interpolation mode */  gst_controller_set_interpolation_mode (ctrl, "ulong",      (GstInterpolateMode) 93871);  g_object_unref (ctrl);  gst_object_unref (elem);}GST_END_TEST;/* test _unset() */GST_START_TEST (controller_unset){  GstController *ctrl;  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);  /* set interpolation mode */  gst_controller_set_interpolation_mode (ctrl, "ulong", GST_INTERPOLATE_NONE);  /* set control values */  g_value_init (&val_ulong, G_TYPE_ULONG);  g_value_set_ulong (&val_ulong, 0);  res = gst_controller_set (ctrl, "ulong", 0 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  g_value_set_ulong (&val_ulong, 100);  res = gst_controller_set (ctrl, "ulong", 1 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  g_value_set_ulong (&val_ulong, 50);  res = gst_controller_set (ctrl, "ulong", 2 * GST_SECOND, &val_ulong);  fail_unless (res, NULL);  /* verify values */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -