📄 gstcontroller.c
字号:
g_mutex_unlock (self->lock); } return res;}/** * gst_controller_remove_properties: * @self: the controller object from which some properties should be removed * @...: %NULL terminated list of property names that should be removed * * Removes the given object properties from the controller * * Returns: %FALSE if one of the given property isn't handled by the controller, %TRUE otherwise */gbooleangst_controller_remove_properties (GstController * self, ...){ gboolean res; va_list var_args; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); va_start (var_args, self); res = gst_controller_remove_properties_valist (self, var_args); va_end (var_args); return res;}/** * gst_controller_set_property_disabled: * @self: the #GstController which should be disabled * @property_name: property to disable * @disabled: boolean that specifies whether to disable the controller * or not. * * This function is used to disable the #GstController on a property for * some time, i.e. gst_controller_sync_values() will do nothing for the * property. * * Since: 0.10.14 */voidgst_controller_set_property_disabled (GstController * self, gchar * property_name, gboolean disabled){ GstControlledProperty *prop; g_return_if_fail (GST_IS_CONTROLLER (self)); g_return_if_fail (property_name); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { prop->disabled = disabled; } g_mutex_unlock (self->lock);}/** * gst_controller_set_disabled: * @self: the #GstController which should be disabled * @disabled: boolean that specifies whether to disable the controller * or not. * * This function is used to disable all properties of the #GstController * for some time, i.e. gst_controller_sync_values() will do nothing. * * Since: 0.10.14 */voidgst_controller_set_disabled (GstController * self, gboolean disabled){ GList *node; GstControlledProperty *prop; g_return_if_fail (GST_IS_CONTROLLER (self)); g_mutex_lock (self->lock); for (node = self->properties; node; node = node->next) { prop = node->data; prop->disabled = disabled; } g_mutex_unlock (self->lock);}/** * gst_controller_set_control_source: * @self: the controller object * @property_name: name of the property for which the #GstControlSource should be set * @csource: the #GstControlSource that should be used for the property * * Sets the #GstControlSource for @property_name. If there already was a #GstControlSource * for this property it will be unreferenced. * * Returns: %FALSE if the given property isn't handled by the controller or the new #GstControlSource * couldn't be bound to the property, %TRUE if everything worked as expected. * * Since: 0.10.14 */gbooleangst_controller_set_control_source (GstController * self, gchar * property_name, GstControlSource * csource){ GstControlledProperty *prop; gboolean ret = FALSE; g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { GstControlSource *old = prop->csource; if (csource && (ret = gst_control_source_bind (csource, prop->pspec))) { g_object_ref (csource); prop->csource = csource; } else if (!csource) { ret = TRUE; prop->csource = NULL; } if (ret && old) g_object_unref (old); } g_mutex_unlock (self->lock); return ret;}/** * gst_controller_get_control_source: * @self: the controller object * @property_name: name of the property for which the #GstControlSource should be get * * Gets the corresponding #GstControlSource for the property. This should be unreferenced * again after use. * * Returns: the #GstControlSource for @property_name or NULL if the property is not * controlled by this controller or no #GstControlSource was assigned yet. * * Since: 0.10.14 */GstControlSource *gst_controller_get_control_source (GstController * self, gchar * property_name){ GstControlledProperty *prop; GstControlSource *ret = NULL; g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { ret = prop->csource; } g_mutex_unlock (self->lock); if (ret) g_object_ref (ret); return ret;}/** * gst_controller_get: * @self: the controller object which handles the properties * @property_name: the name of the property to get * @timestamp: the time the control-change should be read from * * Gets the value for the given controller-handled property at the requested * time. * * Returns: the GValue of the property at the given time, or %NULL if the property isn't handled by the controller */GValue *gst_controller_get (GstController * self, gchar * property_name, GstClockTime timestamp){ GstControlledProperty *prop; GValue *val = NULL; g_return_val_if_fail (GST_IS_CONTROLLER (self), NULL); g_return_val_if_fail (property_name, NULL); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), NULL); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, property_name))) { val = g_new0 (GValue, 1); g_value_init (val, G_PARAM_SPEC_VALUE_TYPE (prop->pspec)); if (prop->csource) { gboolean res; /* get current value via control source */ res = gst_control_source_get_value (prop->csource, timestamp, val); if (!res) { g_free (val); val = FALSE; } } else { g_object_get_property (self->object, prop->name, val); } } g_mutex_unlock (self->lock); return val;}/** * gst_controller_suggest_next_sync: * @self: the controller that handles the values * * Returns a suggestion for timestamps where buffers should be split * to get best controller results. * * Returns: Returns the suggested timestamp or %GST_CLOCK_TIME_NONE * if no control-rate was set. * * Since: 0.10.13 */GstClockTimegst_controller_suggest_next_sync (GstController * self){ GstClockTime ret; g_return_val_if_fail (GST_IS_CONTROLLER (self), GST_CLOCK_TIME_NONE); g_return_val_if_fail (self->priv->control_rate != GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE); g_mutex_lock (self->lock); /* TODO: Implement more logic, depending on interpolation mode * and control points */ ret = self->priv->last_sync + self->priv->control_rate; g_mutex_unlock (self->lock); return ret;}/** * gst_controller_sync_values: * @self: the controller that handles the values * @timestamp: the time that should be processed * * Sets the properties of the element, according to the controller that (maybe) * handles them and for the given timestamp. * * Returns: %TRUE if the controller values could be applied to the object * properties, %FALSE otherwise */gbooleangst_controller_sync_values (GstController * self, GstClockTime timestamp){ GstControlledProperty *prop; GList *node; gboolean ret = FALSE; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); GST_LOG ("sync_values"); g_mutex_lock (self->lock); /* go over the controlled properties of the controller */ for (node = self->properties; node; node = g_list_next (node)) { GValue value = { 0, }; prop = node->data; GST_DEBUG (" property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp); if (!prop->csource || prop->disabled) continue; g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec)); ret = gst_control_source_get_value (prop->csource, timestamp, &value); if (ret) { g_object_set_property (self->object, prop->name, &value); g_value_unset (&value); } } self->priv->last_sync = timestamp; g_mutex_unlock (self->lock); return ret;}/** * gst_controller_get_value_arrays: * @self: the controller that handles the values * @timestamp: the time that should be processed * @value_arrays: list to return the control-values in * * Function to be able to get an array of values for one or more given element * properties. * * All fields of the %GstValueArray in the list must be filled correctly. * Especially the GstValueArray->values arrays must be big enough to keep * the requested amount of values. * * The types of the values in the array are the same as the property's type. * * <note><para>This doesn't modify the controlled GObject properties!</para></note> * * Returns: %TRUE if the given array(s) could be filled, %FALSE otherwise */gbooleangst_controller_get_value_arrays (GstController * self, GstClockTime timestamp, GSList * value_arrays){ gboolean res = TRUE; GSList *node; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); g_return_val_if_fail (value_arrays, FALSE); for (node = value_arrays; (res && node); node = g_slist_next (node)) { res = gst_controller_get_value_array (self, timestamp, node->data); } return (res);}/** * gst_controller_get_value_array: * @self: the controller that handles the values * @timestamp: the time that should be processed * @value_array: array to put control-values in * * Function to be able to get an array of values for one element property. * * All fields of @value_array must be filled correctly. Especially the * @value_array->values array must be big enough to keep the requested amount * of values. * * The type of the values in the array is the same as the property's type. * * <note><para>This doesn't modify the controlled GObject property!</para></note> * * Returns: %TRUE if the given array could be filled, %FALSE otherwise */gbooleangst_controller_get_value_array (GstController * self, GstClockTime timestamp, GstValueArray * value_array){ gboolean res = FALSE; GstControlledProperty *prop; g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); g_return_val_if_fail (value_array, FALSE); g_return_val_if_fail (value_array->property_name, FALSE); g_return_val_if_fail (value_array->values, FALSE); g_mutex_lock (self->lock); if ((prop = gst_controller_find_controlled_property (self, value_array->property_name))) { /* get current value_array via control source */ if (!prop->csource) goto out; res = gst_control_source_get_value_array (prop->csource, timestamp, value_array); }out: g_mutex_unlock (self->lock); return res;}/* gobject handling */static void_gst_controller_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec){ GstController *self = GST_CONTROLLER (object); switch (property_id) { case PROP_CONTROL_RATE:{ /* FIXME: don't change if element is playing, controller works for GObject so this wont work GstState c_state, p_state; GstStateChangeReturn ret; ret = gst_element_get_state (self->object, &c_state, &p_state, 0); if ((ret == GST_STATE_CHANGE_SUCCESS && (c_state == GST_STATE_NULL || c_state == GST_STATE_READY)) || (ret == GST_STATE_CHANGE_ASYNC && (p_state == GST_STATE_NULL || p_state == GST_STATE_READY))) { */ g_value_set_uint64 (value, self->priv->control_rate); /* } else { GST_WARNING ("Changing the control rate is only allowed if the elemnt" " is in NULL or READY"); } */ } break; default:{ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } break; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -