static void gst_interpolation_control_source_init (GstInterpolationControlSource * self) { self->priv = gst_interpolation_control_source_get_instance_private (self); gst_interpolation_control_source_set_interpolation_mode (self, GST_INTERPOLATION_MODE_NONE); }
static void gst_interpolation_control_source_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstInterpolationControlSource *self = GST_INTERPOLATION_CONTROL_SOURCE (object); switch (prop_id) { case PROP_MODE: gst_interpolation_control_source_set_interpolation_mode (self, (GstInterpolationMode) g_value_get_enum (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/* * 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 gboolean gst_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); }
gint main (gint argc, gchar ** argv) { gint res = 1; GstElement *src, *sink; GstElement *bin; GstController *ctrl; GstInterpolationControlSource *csource1, *csource2; GstClock *clock; GstClockID clock_id; GstClockReturn wait_ret; GValue vol = { 0, }; gst_init (&argc, &argv); gst_controller_init (&argc, &argv); /* build pipeline */ bin = gst_pipeline_new ("pipeline"); clock = gst_pipeline_get_clock (GST_PIPELINE (bin)); src = gst_element_factory_make ("audiotestsrc", "gen_audio"); if (!src) { GST_WARNING ("need audiotestsrc from gst-plugins-base"); goto Error; } sink = gst_element_factory_make ("autoaudiosink", "play_audio"); if (!sink) { GST_WARNING ("need autoaudiosink from gst-plugins-base"); goto Error; } gst_bin_add_many (GST_BIN (bin), src, sink, NULL); if (!gst_element_link (src, sink)) { GST_WARNING ("can't link elements"); goto Error; } /* square wave g_object_set (G_OBJECT(src), "wave", 1, NULL); */ /* add a controller to the source */ if (!(ctrl = gst_controller_new (G_OBJECT (src), "freq", "volume", NULL))) { GST_WARNING ("can't control source element"); goto Error; } csource1 = gst_interpolation_control_source_new (); csource2 = gst_interpolation_control_source_new (); gst_controller_set_control_source (ctrl, "volume", GST_CONTROL_SOURCE (csource1)); gst_controller_set_control_source (ctrl, "freq", GST_CONTROL_SOURCE (csource2)); /* Set interpolation mode */ gst_interpolation_control_source_set_interpolation_mode (csource1, GST_INTERPOLATE_LINEAR); gst_interpolation_control_source_set_interpolation_mode (csource2, GST_INTERPOLATE_LINEAR); /* set control values */ g_value_init (&vol, G_TYPE_DOUBLE); g_value_set_double (&vol, 0.0); gst_interpolation_control_source_set (csource1, 0 * GST_SECOND, &vol); g_value_set_double (&vol, 1.0); gst_interpolation_control_source_set (csource1, 5 * GST_SECOND, &vol); g_object_unref (csource1); g_value_set_double (&vol, 220.0); gst_interpolation_control_source_set (csource2, 0 * GST_SECOND, &vol); g_value_set_double (&vol, 3520.0); gst_interpolation_control_source_set (csource2, 3 * GST_SECOND, &vol); g_value_set_double (&vol, 440.0); gst_interpolation_control_source_set (csource2, 6 * GST_SECOND, &vol); g_object_unref (csource2); clock_id = gst_clock_new_single_shot_id (clock, gst_clock_get_time (clock) + (7 * GST_SECOND)); /* run for 7 seconds */ if (gst_element_set_state (bin, GST_STATE_PLAYING)) { if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) { GST_WARNING ("clock_id_wait returned: %d", wait_ret); } gst_element_set_state (bin, GST_STATE_NULL); } /* cleanup */ g_object_unref (G_OBJECT (ctrl)); gst_clock_id_unref (clock_id); gst_object_unref (G_OBJECT (clock)); gst_object_unref (G_OBJECT (bin)); res = 0; Error: return (res); }
static GstElement * ges_track_video_transition_create_element (GESTrackObject * object) { GstElement *topbin, *iconva, *iconvb, *oconv; GObject *target = NULL; const gchar *propname = NULL; GstElement *mixer = NULL; GstPad *sinka_target, *sinkb_target, *src_target, *sinka, *sinkb, *src; GstController *controller; GstInterpolationControlSource *control_source; GESTrackVideoTransition *self; GESTrackVideoTransitionPrivate *priv; self = GES_TRACK_VIDEO_TRANSITION (object); priv = self->priv; GST_LOG ("creating a video bin"); topbin = gst_bin_new ("transition-bin"); iconva = gst_element_factory_make ("ffmpegcolorspace", "tr-csp-a"); iconvb = gst_element_factory_make ("ffmpegcolorspace", "tr-csp-b"); oconv = gst_element_factory_make ("ffmpegcolorspace", "tr-csp-output"); gst_bin_add_many (GST_BIN (topbin), iconva, iconvb, oconv, NULL); /* Prefer videomixer2 to videomixer */ mixer = gst_element_factory_make ("videomixer2", NULL); if (mixer == NULL) mixer = gst_element_factory_make ("videomixer", NULL); g_object_set (G_OBJECT (mixer), "background", 1, NULL); gst_bin_add (GST_BIN (topbin), mixer); if (priv->type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) { priv->sinka = (GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconva, mixer, priv->type, NULL); priv->sinkb = (GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconvb, mixer, priv->type, &priv->smpte); target = (GObject *) priv->smpte; propname = "position"; priv->start_value = 1.0; priv->end_value = 0.0; } else { priv->sinka = (GstPad *) link_element_to_mixer (iconva, mixer); priv->sinkb = (GstPad *) link_element_to_mixer (iconvb, mixer); target = (GObject *) priv->sinkb; propname = "alpha"; priv->start_value = 0.0; priv->end_value = 1.0; } priv->mixer = gst_object_ref (mixer); fast_element_link (mixer, oconv); sinka_target = gst_element_get_static_pad (iconva, "sink"); sinkb_target = gst_element_get_static_pad (iconvb, "sink"); src_target = gst_element_get_static_pad (oconv, "src"); sinka = gst_ghost_pad_new ("sinka", sinka_target); sinkb = gst_ghost_pad_new ("sinkb", sinkb_target); src = gst_ghost_pad_new ("src", src_target); gst_element_add_pad (topbin, src); gst_element_add_pad (topbin, sinka); gst_element_add_pad (topbin, sinkb); gst_object_unref (sinka_target); gst_object_unref (sinkb_target); gst_object_unref (src_target); /* set up interpolation */ g_object_set (target, propname, (gfloat) 0.0, NULL); controller = gst_object_control_properties (target, propname, NULL); control_source = gst_interpolation_control_source_new (); gst_controller_set_control_source (controller, propname, GST_CONTROL_SOURCE (control_source)); gst_interpolation_control_source_set_interpolation_mode (control_source, GST_INTERPOLATE_LINEAR); priv->controller = controller; priv->control_source = control_source; return topbin; }
static gboolean gst_interpolation_control_source_bind (GstControlSource * source, GParamSpec * pspec) { GType type, base; GstInterpolationControlSource *self = GST_INTERPOLATION_CONTROL_SOURCE (source); gboolean ret = TRUE; /* get the fundamental base type */ self->priv->type = base = type = G_PARAM_SPEC_VALUE_TYPE (pspec); while ((type = g_type_parent (type))) base = type; self->priv->base = base; /* restore type */ type = self->priv->type; if (!gst_interpolation_control_source_set_interpolation_mode (self, self->priv->interpolation_mode)) return FALSE; switch (base) { case G_TYPE_INT:{ GParamSpecInt *tpspec = G_PARAM_SPEC_INT (pspec); g_value_init (&self->priv->default_value, type); g_value_set_int (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_int (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_int (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_UINT:{ GParamSpecUInt *tpspec = G_PARAM_SPEC_UINT (pspec); g_value_init (&self->priv->default_value, type); g_value_set_uint (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_uint (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_uint (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_LONG:{ GParamSpecLong *tpspec = G_PARAM_SPEC_LONG (pspec); g_value_init (&self->priv->default_value, type); g_value_set_long (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_long (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_long (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_ULONG:{ GParamSpecULong *tpspec = G_PARAM_SPEC_ULONG (pspec); g_value_init (&self->priv->default_value, type); g_value_set_ulong (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_ulong (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_ulong (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_INT64:{ GParamSpecInt64 *tpspec = G_PARAM_SPEC_INT64 (pspec); g_value_init (&self->priv->default_value, type); g_value_set_int64 (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_int64 (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_int64 (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_UINT64:{ GParamSpecUInt64 *tpspec = G_PARAM_SPEC_UINT64 (pspec); g_value_init (&self->priv->default_value, type); g_value_set_uint64 (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_uint64 (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_uint64 (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_FLOAT:{ GParamSpecFloat *tpspec = G_PARAM_SPEC_FLOAT (pspec); g_value_init (&self->priv->default_value, type); g_value_set_float (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_float (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_float (&self->priv->maximum_value, tpspec->maximum); 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; }