📄 gstcontroller.c
字号:
}/* sets the given properties for this object */static void_gst_controller_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec){ GstController *self = GST_CONTROLLER (object); switch (property_id) { case PROP_CONTROL_RATE:{ self->priv->control_rate = g_value_get_uint64 (value); } break; default:{ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } break; }}static void_gst_controller_dispose (GObject * object){ GstController *self = GST_CONTROLLER (object); if (self->object != NULL) { g_mutex_lock (self->lock); /* free list of properties */ if (self->properties) { GList *node; for (node = self->properties; node; node = g_list_next (node)) { GstControlledProperty *prop = node->data; gst_controlled_property_free (prop); } g_list_free (self->properties); self->properties = NULL; } /* remove controller from object's qdata list */ g_object_set_qdata (self->object, __gst_controller_key, NULL); g_object_unref (self->object); self->object = NULL; g_mutex_unlock (self->lock); } if (G_OBJECT_CLASS (parent_class)->dispose) (G_OBJECT_CLASS (parent_class)->dispose) (object);}static void_gst_controller_finalize (GObject * object){ GstController *self = GST_CONTROLLER (object); g_mutex_free (self->lock); if (G_OBJECT_CLASS (parent_class)->finalize) (G_OBJECT_CLASS (parent_class)->finalize) (object);}static void_gst_controller_init (GTypeInstance * instance, gpointer g_class){ GstController *self = GST_CONTROLLER (instance); self->lock = g_mutex_new (); self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_CONTROLLER, GstControllerPrivate); self->priv->last_sync = GST_CLOCK_TIME_NONE; self->priv->control_rate = 100 * GST_MSECOND;}static void_gst_controller_class_init (GstControllerClass * klass){ GObjectClass *gobject_class = G_OBJECT_CLASS (klass); parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (GstControllerPrivate)); gobject_class->set_property = _gst_controller_set_property; gobject_class->get_property = _gst_controller_get_property; gobject_class->dispose = _gst_controller_dispose; gobject_class->finalize = _gst_controller_finalize; __gst_controller_key = g_quark_from_string ("gst::controller"); /* register properties */ g_object_class_install_property (gobject_class, PROP_CONTROL_RATE, g_param_spec_uint64 ("control-rate", "control rate", "Controlled properties will be updated at least every control-rate nanoseconds", 1, G_MAXUINT, 100 * GST_MSECOND, G_PARAM_READWRITE)); /* register signals */ /* set defaults for overridable methods */}GTypegst_controller_get_type (){ static GType type = 0; if (type == 0) { static const GTypeInfo info = { sizeof (GstControllerClass), NULL, /* base_init */ NULL, /* base_finalize */ (GClassInitFunc) _gst_controller_class_init, /* class_init */ NULL, /* class_finalize */ NULL, /* class_data */ sizeof (GstController), 0, /* n_preallocs */ (GInstanceInitFunc) _gst_controller_init, /* instance_init */ NULL /* value_table */ }; type = g_type_register_static (G_TYPE_OBJECT, "GstController", &info, 0); } return type;}/* FIXME: backward compatibility functions *//* * gst_controlled_property_set_interpolation_mode: * @self: the controlled property object to change * @mode: the new interpolation mode * * Sets the given Interpolation mode for the controlled property and activates * the respective interpolation hooks. * * Deprecated: Use #GstControlSource, for example #GstInterpolationControlSource * directly. * * Returns: %TRUE for success */static gbooleangst_controlled_property_set_interpolation_mode (GstControlledProperty * self, GstInterpolateMode mode){ GstInterpolationControlSource *icsource; /* FIXME: backward compat, add GstInterpolationControlSource */ if (!self->csource) gst_controlled_property_add_interpolation_control_source (self); g_return_val_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self->csource), FALSE); icsource = GST_INTERPOLATION_CONTROL_SOURCE (self->csource); return gst_interpolation_control_source_set_interpolation_mode (icsource, mode);}/** * gst_controller_set: * @self: the controller object which handles the properties * @property_name: the name of the property to set * @timestamp: the time the control-change is schedules for * @value: the control-value * * Set the value of given controller-handled property at a certain time. * * Deprecated: Use #GstControlSource, for example #GstInterpolationControlSource * directly. * * Returns: FALSE if the values couldn't be set (ex : properties not handled by controller), TRUE otherwise */#ifndef GST_REMOVE_DEPRECATEDgbooleangst_controller_set (GstController * self, gchar * property_name, GstClockTime timestamp, GValue * value){ gboolean res = FALSE; GstControlledProperty *prop; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); g_return_val_if_fail (property_name, FALSE); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { /* FIXME: backward compat, add GstInterpolationControlSource */ if (!prop->csource) gst_controlled_property_add_interpolation_control_source (prop); if (!GST_IS_INTERPOLATION_CONTROL_SOURCE (prop->csource)) goto out; res = gst_interpolation_control_source_set (GST_INTERPOLATION_CONTROL_SOURCE (prop->csource), timestamp, value); }out: g_mutex_unlock (self->lock); return res;}#endif/** * gst_controller_set_from_list: * @self: the controller object which handles the properties * @property_name: the name of the property to set * @timedvalues: a list with #GstTimedValue items * * Sets multiple timed values at once. * * Deprecated: Use #GstControlSource, for example #GstInterpolationControlSource * directly. * * Returns: %FALSE if the values couldn't be set (ex : properties not handled by controller), %TRUE otherwise */#ifndef GST_REMOVE_DEPRECATEDgbooleangst_controller_set_from_list (GstController * self, gchar * property_name, GSList * timedvalues){ gboolean res = FALSE; GstControlledProperty *prop; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); g_return_val_if_fail (property_name, FALSE); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { /* FIXME: backward compat, add GstInterpolationControlSource */ if (!prop->csource) gst_controlled_property_add_interpolation_control_source (prop); if (!GST_IS_INTERPOLATION_CONTROL_SOURCE (prop->csource)) goto out; res = gst_interpolation_control_source_set_from_list (GST_INTERPOLATION_CONTROL_SOURCE (prop->csource), timedvalues); }out: g_mutex_unlock (self->lock); return res;}#endif/** * gst_controller_unset: * @self: the controller object which handles the properties * @property_name: the name of the property to unset * @timestamp: the time the control-change should be removed from * * Used to remove the value of given controller-handled property at a certain * time. * * Deprecated: Use #GstControlSource, for example #GstInterpolationControlSource * directly. * * Returns: %FALSE if the values couldn't be unset (ex : properties not handled by controller), %TRUE otherwise */#ifndef GST_REMOVE_DEPRECATEDgbooleangst_controller_unset (GstController * self, gchar * property_name, GstClockTime timestamp){ gboolean res = FALSE; GstControlledProperty *prop; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); g_return_val_if_fail (property_name, FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { if (!prop->csource || !GST_IS_INTERPOLATION_CONTROL_SOURCE (prop->csource)) goto out; res = gst_interpolation_control_source_unset (GST_INTERPOLATION_CONTROL_SOURCE (prop->csource), timestamp); }out: g_mutex_unlock (self->lock); return res;}#endif/** * gst_controller_unset_all: * @self: the controller object which handles the properties * @property_name: the name of the property to unset * * Used to remove all time-stamped values of given controller-handled property * * Deprecated: Use #GstControlSource, for example #GstInterpolationControlSource * directly. * * Returns: %FALSE if the values couldn't be unset (ex : properties not handled * by controller), %TRUE otherwise * Since: 0.10.5 */#ifndef GST_REMOVE_DEPRECATEDgbooleangst_controller_unset_all (GstController * self, gchar * property_name){ GstControlledProperty *prop; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); g_return_val_if_fail (property_name, FALSE); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { if (!prop->csource || !GST_IS_INTERPOLATION_CONTROL_SOURCE (prop->csource)) goto out; gst_interpolation_control_source_unset_all (GST_INTERPOLATION_CONTROL_SOURCE (prop->csource)); }out: g_mutex_unlock (self->lock); return TRUE;}#endif/** * gst_controller_get_all: * @self: the controller to get the list from * @property_name: the name of the property to get the list for * * Returns a read-only copy of the list of #GstTimedValue for the given property. * Free the list after done with it. * * <note><para>This doesn't modify the controlled GObject property!</para></note> * * Deprecated: Use #GstControlSource, for example #GstInterpolationControlSource * directly. * * Returns: a copy of the list, or %NULL if the property isn't handled by the controller */#ifndef GST_REMOVE_DEPRECATEDconst GList *gst_controller_get_all (GstController * self, gchar * property_name){ const GList *res = NULL; GstControlledProperty *prop; g_return_val_if_fail (GST_IS_CONTROLLER (self), NULL); g_return_val_if_fail (property_name, NULL); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { if (!prop->csource || !GST_IS_INTERPOLATION_CONTROL_SOURCE (prop->csource)) goto out; res = gst_interpolation_control_source_get_all (GST_INTERPOLATION_CONTROL_SOURCE (prop->csource)); }out: g_mutex_unlock (self->lock); return res;}#endif/** * gst_controller_set_interpolation_mode: * @self: the controller object * @property_name: the name of the property for which to change the interpolation * @mode: interpolation mode * * Sets the given interpolation mode on the given property. * * <note><para>User interpolation is not yet available and quadratic interpolation * is deprecated and maps to cubic interpolation.</para></note> * * Deprecated: Use #GstControlSource, for example #GstInterpolationControlSource * directly. * * Returns: %TRUE if the property is handled by the controller, %FALSE otherwise */#ifndef GST_REMOVE_DEPRECATEDgbooleangst_controller_set_interpolation_mode (GstController * self, gchar * property_name, GstInterpolateMode mode){ gboolean res = FALSE; GstControlledProperty *prop; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); g_return_val_if_fail (property_name, FALSE); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { res = gst_controlled_property_set_interpolation_mode (prop, mode); } g_mutex_unlock (self->lock); return res;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -