GST_LOG ("done updating controller");
}
+static void
+ges_track_transition_update_acontroller (GESTrackTransition * self,
+ GstElement * gnlobj)
+{
+ GST_LOG ("updating controller: gnlobj (%p) acontroller(%p) bcontroller(%p)",
+ self->a_acontroller, self->a_bcontroller);
+
+ if (!gnlobj)
+ return;
+
+ if (!(self->a_acontroller) || !(self->a_bcontroller))
+ return;
+
+ GST_LOG ("getting properties");
+ guint64 duration;
+ g_object_get (G_OBJECT (gnlobj), "duration", (guint64 *) & duration, NULL);
+
+ GST_INFO ("duration: %lud\n", duration);
+
+ GValue zero = { 0, };
+ GValue one = { 0, };
+ g_value_init (&zero, G_TYPE_DOUBLE);
+ g_value_init (&one, G_TYPE_DOUBLE);
+ g_value_set_double (&zero, 0.0);
+ g_value_set_double (&one, 1.0);
+
+ GST_LOG ("setting values on controller");
+
+ g_assert (GST_IS_CONTROLLER (self->a_acontroller));
+ g_assert (GST_IS_CONTROL_SOURCE (self->a_acontrol_source));
+
+ g_assert (GST_IS_CONTROLLER (self->a_bcontroller));
+ g_assert (GST_IS_CONTROL_SOURCE (self->a_bcontrol_source));
+
+ gst_interpolation_control_source_unset_all (self->a_acontrol_source);
+ gst_interpolation_control_source_set (self->a_acontrol_source, 0, &one);
+ gst_interpolation_control_source_set (self->a_acontrol_source,
+ duration, &zero);
+
+ gst_interpolation_control_source_unset_all (self->a_bcontrol_source);
+ gst_interpolation_control_source_set (self->a_bcontrol_source, 0, &zero);
+ gst_interpolation_control_source_set (self->a_bcontrol_source,
+ duration, &one);
+
+ GST_LOG ("done updating controller");
+}
+
static void
gnlobject_duration_cb (GstElement * gnlobject, GParamSpec * arg
G_GNUC_UNUSED, GESTrackTransition * self)
{
- ges_track_transition_update_vcontroller (self, gnlobject);
+ GESTrackType type = ((GESTrackObject *) self)->track->type;
+ GST_LOG ("got duration changed signal");
+
+ if (type == GES_TRACK_TYPE_VIDEO)
+ ges_track_transition_update_vcontroller (self, gnlobject);
+ else if (type == GES_TRACK_TYPE_AUDIO) {
+ GST_LOG ("transition is an audio transition");
+ ges_track_transition_update_acontroller (self, gnlobject);
+ }
}
static void
return G_OBJECT (smptealpha);
}
+static GObject *
+link_element_to_mixer_with_volume (GstBin * bin, GstElement * element,
+ GstElement * mixer)
+{
+ GstElement *volume = gst_element_factory_make ("volume", NULL);
+ gst_bin_add (bin, volume);
+
+ gst_element_link_many (element, volume, mixer, NULL);
+
+ return G_OBJECT (volume);
+}
+
static GstElement *
create_video_bin (GESTrackTransition * self)
{
+ GST_LOG ("creating a video bin");
+
GstElement *topbin = gst_bin_new ("transition-bin");
GstElement *iconva = gst_element_factory_make ("ffmpegcolorspace",
"tr-csp-a");
return topbin;
}
+static GstElement *
+create_audio_bin (GESTrackTransition * self)
+{
+ GST_LOG ("creating an audio bin");
+
+ GstElement *topbin = gst_bin_new ("transition-bin");
+ GstElement *iconva = gst_element_factory_make ("audioconvert",
+ "tr-aconv-a");
+ GstElement *iconvb = gst_element_factory_make ("audioconvert",
+ "tr-aconv-b");
+ GstElement *oconv = gst_element_factory_make ("audioconvert",
+ "tr-aconv-output");
+
+ gst_bin_add_many (GST_BIN (topbin), iconva, iconvb, oconv, NULL);
+
+ GObject *atarget, *btarget = NULL;
+ gchar *propname = "volume";
+ GstElement *mixer = NULL;
+
+ mixer = gst_element_factory_make ("adder", NULL);
+ gst_bin_add (GST_BIN (topbin), mixer);
+
+ atarget = link_element_to_mixer_with_volume (GST_BIN (topbin), iconva, mixer);
+ btarget = link_element_to_mixer_with_volume (GST_BIN (topbin), iconvb, mixer);
+
+ g_assert (atarget && btarget);
+
+ gst_element_link (mixer, oconv);
+
+ GstPad *sinka_target = gst_element_get_static_pad (iconva, "sink");
+ GstPad *sinkb_target = gst_element_get_static_pad (iconvb, "sink");
+ GstPad *src_target = gst_element_get_static_pad (oconv, "src");
+
+ GstPad *sinka = gst_ghost_pad_new ("sinka", sinka_target);
+ GstPad *sinkb = gst_ghost_pad_new ("sinkb", sinkb_target);
+ GstPad *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);
+
+ /* set up interpolation */
+
+ //g_object_set(atarget, propname, (gdouble) 0, NULL);
+ //g_object_set(btarget, propname, (gdouble) 0, NULL);
+
+ GstController *acontroller, *bcontroller;
+
+ acontroller = gst_object_control_properties (atarget, propname, NULL);
+ bcontroller = gst_object_control_properties (btarget, propname, NULL);
+
+ g_assert (acontroller && bcontroller);
+
+ GstInterpolationControlSource *acontrol_source, *bcontrol_source;
+
+ acontrol_source = gst_interpolation_control_source_new ();
+ gst_controller_set_control_source (acontroller,
+ propname, GST_CONTROL_SOURCE (acontrol_source));
+ gst_interpolation_control_source_set_interpolation_mode (acontrol_source,
+ GST_INTERPOLATE_LINEAR);
+
+ bcontrol_source = gst_interpolation_control_source_new ();
+ gst_controller_set_control_source (bcontroller,
+ propname, GST_CONTROL_SOURCE (bcontrol_source));
+ gst_interpolation_control_source_set_interpolation_mode (bcontrol_source,
+ GST_INTERPOLATE_LINEAR);
+
+ self->a_acontroller = acontroller;
+ self->a_bcontroller = bcontroller;
+ self->a_acontrol_source = acontrol_source;
+ self->a_bcontrol_source = bcontrol_source;
+
+ GST_LOG ("controllers created, updating");
+
+ ges_track_transition_update_acontroller (self,
+ ((GESTrackObject *) self)->gnlobject);
+
+ return topbin;
+}
+
static gboolean
ges_track_transition_create_gnl_object (GESTrackObject * object)
{
return TRUE;
}
+ else if ((object->track->type) == GES_TRACK_TYPE_AUDIO) {
+ gst_bin_add (GST_BIN (object->gnlobject), create_audio_bin (self));
+ return TRUE;
+ }
+
return FALSE;
-}
+}
static void
ges_track_transition_class_init (GESTrackTransitionClass * klass)