📄 gstinterpolationcontrolsource.c
字号:
break; } case G_TYPE_DOUBLE:{ GParamSpecDouble *tpspec = G_PARAM_SPEC_DOUBLE (pspec); g_value_init (&self->priv->default_value, type); g_value_set_double (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_double (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_double (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_BOOLEAN:{ GParamSpecBoolean *tpspec = G_PARAM_SPEC_BOOLEAN (pspec); g_value_init (&self->priv->default_value, type); g_value_set_boolean (&self->priv->default_value, tpspec->default_value); break; } case G_TYPE_ENUM:{ GParamSpecEnum *tpspec = G_PARAM_SPEC_ENUM (pspec); g_value_init (&self->priv->default_value, type); g_value_set_enum (&self->priv->default_value, tpspec->default_value); break; } case G_TYPE_STRING:{ GParamSpecString *tpspec = G_PARAM_SPEC_STRING (pspec); g_value_init (&self->priv->default_value, type); g_value_set_string (&self->priv->default_value, tpspec->default_value); break; } default: GST_WARNING ("incomplete implementation for paramspec type '%s'", G_PARAM_SPEC_TYPE_NAME (pspec)); ret = FALSE; break; } if (ret) { self->priv->valid_cache = FALSE; self->priv->nvalues = 0; } else { gst_interpolation_control_source_reset (self); } return ret;}/* * gst_control_point_compare: * @p1: a pointer to a #GstControlPoint * @p2: a pointer to a #GstControlPoint * * Compare function for g_list operations that operates on two #GstControlPoint * parameters. */static gintgst_control_point_compare (gconstpointer p1, gconstpointer p2){ GstClockTime ct1 = ((GstControlPoint *) p1)->timestamp; GstClockTime ct2 = ((GstControlPoint *) p2)->timestamp; return ((ct1 < ct2) ? -1 : ((ct1 == ct2) ? 0 : 1));}/* * gst_control_point_find: * @p1: a pointer to a #GstControlPoint * @p2: a pointer to a #GstClockTime * * Compare function for g_list operations that operates on a #GstControlPoint and * a #GstClockTime. */static gintgst_control_point_find (gconstpointer p1, gconstpointer p2){ GstClockTime ct1 = ((GstControlPoint *) p1)->timestamp; GstClockTime ct2 = *(GstClockTime *) p2; return ((ct1 < ct2) ? -1 : ((ct1 == ct2) ? 0 : 1));}static voidgst_interpolation_control_source_set_internal (GstInterpolationControlSource * self, GstClockTime timestamp, GValue * value){ GstControlPoint *cp; GList *node; /* check if a control point for the timestamp already exists */ if ((node = g_list_find_custom (self->priv->values, ×tamp, gst_control_point_find))) { cp = node->data; g_value_reset (&cp->value); g_value_copy (value, &cp->value); } else { /* create a new GstControlPoint */ cp = g_new0 (GstControlPoint, 1); cp->timestamp = timestamp; g_value_init (&cp->value, self->priv->type); g_value_copy (value, &cp->value); /* and sort it into the prop->values list */ self->priv->values = g_list_insert_sorted (self->priv->values, cp, gst_control_point_compare); self->priv->nvalues++; } self->priv->valid_cache = FALSE;}/** * gst_interpolation_control_source_set: * @self: the #GstInterpolationControlSource object * @timestamp: the time the control-change is scheduled for * @value: the control-value * * Set the value of given controller-handled property at a certain time. * * Returns: FALSE if the values couldn't be set, TRUE otherwise. */gbooleangst_interpolation_control_source_set (GstInterpolationControlSource * self, GstClockTime timestamp, GValue * value){ g_return_val_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); g_return_val_if_fail (G_IS_VALUE (value), FALSE); g_return_val_if_fail (G_VALUE_TYPE (value) == self->priv->type, FALSE); g_mutex_lock (self->lock); gst_interpolation_control_source_set_internal (self, timestamp, value); g_mutex_unlock (self->lock); return TRUE;}/** * gst_interpolation_control_source_set_from_list: * @self: the #GstInterpolationControlSource object * @timedvalues: a list with #GstTimedValue items * * Sets multiple timed values at once. * * Returns: FALSE if the values couldn't be set, TRUE otherwise. */gbooleangst_interpolation_control_source_set_from_list (GstInterpolationControlSource * self, GSList * timedvalues){ GSList *node; GstTimedValue *tv; gboolean res = FALSE; g_return_val_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self), FALSE); for (node = timedvalues; node; node = g_slist_next (node)) { tv = node->data; if (!GST_CLOCK_TIME_IS_VALID (tv->timestamp)) { GST_WARNING ("GstTimedValued with invalid timestamp passed to %s", GST_FUNCTION); } else if (!G_IS_VALUE (&tv->value)) { GST_WARNING ("GstTimedValued with invalid value passed to %s", GST_FUNCTION); } else if (G_VALUE_TYPE (&tv->value) != self->priv->type) { GST_WARNING ("incompatible value type for property"); } else { g_mutex_lock (self->lock); gst_interpolation_control_source_set_internal (self, tv->timestamp, &tv->value); g_mutex_unlock (self->lock); res = TRUE; } } return res;}/** * gst_interpolation_control_source_unset: * @self: the #GstInterpolationControlSource object * @timestamp: the time the control-change should be removed from * * Used to remove the value of given controller-handled property at a certain * time. * * Returns: FALSE if the value couldn't be unset (i.e. not found, TRUE otherwise. */gbooleangst_interpolation_control_source_unset (GstInterpolationControlSource * self, GstClockTime timestamp){ GList *node; gboolean res = FALSE; g_return_val_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self), FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); g_mutex_lock (self->lock); /* check if a control point for the timestamp exists */ if ((node = g_list_find_custom (self->priv->values, ×tamp, gst_control_point_find))) { GstControlPoint *cp = node->data; if (cp->timestamp == 0) { /* Restore the default node */ g_value_reset (&cp->value); g_value_copy (&self->priv->default_value, &cp->value); } else { if (node == self->priv->last_requested_value) self->priv->last_requested_value = NULL; gst_control_point_free (node->data); /* free GstControlPoint */ self->priv->values = g_list_delete_link (self->priv->values, node); self->priv->nvalues--; } self->priv->valid_cache = FALSE; res = TRUE; } g_mutex_unlock (self->lock); return res;}/** * gst_interpolation_control_source_unset_all: * @self: the #GstInterpolationControlSource object * * Used to remove all time-stamped values of given controller-handled property * */voidgst_interpolation_control_source_unset_all (GstInterpolationControlSource * self){ g_return_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self)); g_mutex_lock (self->lock); /* free GstControlPoint structures */ g_list_foreach (self->priv->values, (GFunc) gst_control_point_free, NULL); g_list_free (self->priv->values); self->priv->last_requested_value = NULL; self->priv->values = NULL; self->priv->nvalues = 0; self->priv->valid_cache = FALSE; g_mutex_unlock (self->lock);}/** * gst_interpolation_control_source_get_all: * @self: the #GstInterpolationControlSource to get the list from * * Returns a read-only copy of the list of #GstTimedValue for the given property. * Free the list after done with it. * * Returns: a copy of the list, or %NULL if the property isn't handled by the controller */GList *gst_interpolation_control_source_get_all (GstInterpolationControlSource * self){ GList *res = NULL; g_return_val_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self), NULL); g_mutex_lock (self->lock); if (self->priv->values) res = g_list_copy (self->priv->values); g_mutex_unlock (self->lock); return res;}/** * gst_interpolation_control_source_get_count: * @self: the #GstInterpolationControlSource to get the number of values from * * Returns the number of control points that are set. * * Returns: the number of control points that are set. * */gintgst_interpolation_control_source_get_count (GstInterpolationControlSource * self){ g_return_val_if_fail (GST_IS_INTERPOLATION_CONTROL_SOURCE (self), 0); return self->priv->nvalues;}static voidgst_interpolation_control_source_init (GstInterpolationControlSource * self){ self->lock = g_mutex_new (); self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_INTERPOLATION_CONTROL_SOURCE, GstInterpolationControlSourcePrivate); self->priv->interpolation_mode = GST_INTERPOLATE_NONE;}static voidgst_interpolation_control_source_finalize (GObject * obj){ GstInterpolationControlSource *self = GST_INTERPOLATION_CONTROL_SOURCE (obj); g_mutex_lock (self->lock); gst_interpolation_control_source_reset (self); g_mutex_unlock (self->lock); g_mutex_free (self->lock); G_OBJECT_CLASS (parent_class)->finalize (obj);}static voidgst_interpolation_control_source_dispose (GObject * obj){ G_OBJECT_CLASS (parent_class)->dispose (obj);}static voidgst_interpolation_control_source_class_init (GstInterpolationControlSourceClass * klass){ GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstControlSourceClass *csource_class = GST_CONTROL_SOURCE_CLASS (klass); parent_class = g_type_class_peek_parent (klass); g_type_class_add_private (klass, sizeof (GstInterpolationControlSourcePrivate)); gobject_class->finalize = gst_interpolation_control_source_finalize; gobject_class->dispose = gst_interpolation_control_source_dispose; csource_class->bind = gst_interpolation_control_source_bind;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -