push struct fields down to VideoTransition

This commit is contained in:
Brandon Lewis 2010-06-18 16:22:21 +02:00 committed by Edward Hervey
parent fa98f4cc09
commit e4c7d0bbcd
5 changed files with 103 additions and 95 deletions

View file

@ -61,7 +61,8 @@ ges_timeline_transition_update_vtype_internal (GESTimelineObject * self,
to = (GESTrackObject *) tr; to = (GESTrackObject *) tr;
if ((to->track) && (to->track->type == GES_TRACK_TYPE_VIDEO)) { if ((to->track) && (to->track->type == GES_TRACK_TYPE_VIDEO)) {
ges_track_transition_set_vtype (tr, value); ges_track_video_transition_set_type ((GESTrackVideoTransition *) tr,
value);
} }
} }
} }
@ -153,7 +154,7 @@ ges_tl_transition_create_track_object (GESTimelineObject * obj,
if (track->type == GES_TRACK_TYPE_VIDEO) { if (track->type == GES_TRACK_TYPE_VIDEO) {
res = GES_TRACK_OBJECT (ges_track_video_transition_new ()); res = GES_TRACK_OBJECT (ges_track_video_transition_new ());
ges_track_transition_set_vtype (GES_TRACK_TRANSITION (res), ges_track_video_transition_set_type ((GESTrackVideoTransition *) res,
transition->vtype); transition->vtype);
} }
@ -162,7 +163,7 @@ ges_tl_transition_create_track_object (GESTimelineObject * obj,
} }
else { else {
res = GES_TRACK_OBJECT (ges_track_transition_new (transition->vtype)); res = GES_TRACK_OBJECT (ges_track_transition_new ());
} }
return res; return res;

View file

@ -80,32 +80,6 @@ ges_track_transition_set_property (GObject * object, guint property_id,
static void static void
ges_track_transition_dispose (GObject * object) ges_track_transition_dispose (GObject * object)
{ {
GESTrackTransition *self = GES_TRACK_TRANSITION (object);
GST_DEBUG ("disposing");
GST_LOG ("mixer: %p smpte: %p sinka: %p sinkb: %p",
self->vmixer, self->vsmpte, self->sinka, self->sinkb);
if (self->vcontroller) {
g_object_unref (self->vcontroller);
self->vcontroller = NULL;
if (self->vcontrol_source)
gst_object_unref (self->vcontrol_source);
self->vcontrol_source = NULL;
}
if (self->vmixer && self->sinka && self->sinkb) {
GST_DEBUG ("releasing request pads for vmixer");
gst_element_release_request_pad (self->vmixer, self->sinka);
gst_element_release_request_pad (self->vmixer, self->sinkb);
gst_object_unref (self->vmixer);
gst_object_unref (self->sinka);
gst_object_unref (self->sinkb);
self->vmixer = NULL;
self->sinka = NULL;
self->sinkb = NULL;
}
G_OBJECT_CLASS (ges_track_transition_parent_class)->dispose (object); G_OBJECT_CLASS (ges_track_transition_parent_class)->dispose (object);
} }
@ -173,36 +147,12 @@ ges_track_transition_class_init (GESTrackTransitionClass * klass)
static void static void
ges_track_transition_init (GESTrackTransition * self) ges_track_transition_init (GESTrackTransition * self)
{ {
self->vcontroller = NULL;
self->vcontrol_source = NULL;
self->vsmpte = NULL;
self->vmixer = NULL;
self->sinka = NULL;
self->sinkb = NULL;
self->vtype = 0;
self->vstart_value = 0.0;
self->vend_value = 0.0;
}
void
ges_track_transition_set_vtype (GESTrackTransition * self, gint vtype)
{
if (((vtype == VTYPE_CROSSFADE) && (self->vtype != VTYPE_CROSSFADE)) ||
((vtype != VTYPE_CROSSFADE) && (self->vtype = VTYPE_CROSSFADE))) {
GST_WARNING
("Changing between 'crossfade' and other types is not supported\n");
}
self->vtype = vtype;
if (self->vsmpte && (vtype != VTYPE_CROSSFADE))
g_object_set (self->vsmpte, "type", (gint) vtype, NULL);
} }
GESTrackTransition * GESTrackTransition *
ges_track_transition_new (gint value) ges_track_transition_new (void)
{ {
GESTrackTransition *ret = g_object_new (GES_TYPE_TRACK_TRANSITION, NULL); GESTrackTransition *ret = g_object_new (GES_TYPE_TRACK_TRANSITION, NULL);
ret->vtype = value;
return ret; return ret;
} }

View file

@ -65,25 +65,6 @@ struct _GESTrackTransition
GESTrackObject parent; GESTrackObject parent;
/*< public >*/ /*< public >*/
/* given to to smpte alpha element */
gint vtype;
/*< private >*/
/* these enable video interpolation */
GstController *vcontroller;
GstInterpolationControlSource *vcontrol_source;
/* so we can support changing between wipes */
GstElement *vsmpte;
GstElement *vmixer;
GstPad *sinka;
GstPad *sinkb;
/* these will be different depending on whether smptealpha or alpha element
* is used */
gdouble vstart_value;
gdouble vend_value;
}; };
/** /**
@ -102,8 +83,7 @@ struct _GESTrackTransitionClass {
GType ges_track_transition_get_type (void); GType ges_track_transition_get_type (void);
GESTrackTransition *ges_track_transition_new (gint value); GESTrackTransition *ges_track_transition_new (void);
void ges_track_transition_set_vtype(GESTrackTransition *tr, gint vtype);
G_END_DECLS G_END_DECLS

View file

@ -81,11 +81,46 @@ ges_track_video_transition_class_init (GESTrackVideoTransitionClass * klass)
static void static void
ges_track_video_transition_init (GESTrackVideoTransition * self) ges_track_video_transition_init (GESTrackVideoTransition * self)
{ {
self->controller = NULL;
self->control_source = NULL;
self->smpte = NULL;
self->mixer = NULL;
self->sinka = NULL;
self->sinkb = NULL;
self->type = 0;
self->start_value = 0.0;
self->end_value = 0.0;
} }
static void static void
ges_track_video_transition_dispose (GObject * object) ges_track_video_transition_dispose (GObject * object)
{ {
GESTrackVideoTransition *self = GES_TRACK_VIDEO_TRANSITION (object);
GST_DEBUG ("disposing");
GST_LOG ("mixer: %p smpte: %p sinka: %p sinkb: %p",
self->mixer, self->smpte, self->sinka, self->sinkb);
if (self->controller) {
g_object_unref (self->controller);
self->controller = NULL;
if (self->control_source)
gst_object_unref (self->control_source);
self->control_source = NULL;
}
if (self->mixer && self->sinka && self->sinkb) {
GST_DEBUG ("releasing request pads for mixer");
gst_element_release_request_pad (self->mixer, self->sinka);
gst_element_release_request_pad (self->mixer, self->sinkb);
gst_object_unref (self->mixer);
gst_object_unref (self->sinka);
gst_object_unref (self->sinkb);
self->mixer = NULL;
self->sinka = NULL;
self->sinkb = NULL;
}
G_OBJECT_CLASS (ges_track_video_transition_parent_class)->dispose (object); G_OBJECT_CLASS (ges_track_video_transition_parent_class)->dispose (object);
} }
@ -116,7 +151,7 @@ ges_track_video_transition_set_property (GObject * object,
} }
static GstElement * static GstElement *
ges_track_video_transition_create_element (GESTrackTransition * self, ges_track_video_transition_create_element (GESTrackTransition * object,
GESTrack * unused) GESTrack * unused)
{ {
GstElement *topbin, *iconva, *iconvb, *oconv; GstElement *topbin, *iconva, *iconvb, *oconv;
@ -126,6 +161,9 @@ ges_track_video_transition_create_element (GESTrackTransition * self,
GstPad *sinka_target, *sinkb_target, *src_target, *sinka, *sinkb, *src; GstPad *sinka_target, *sinkb_target, *src_target, *sinka, *sinkb, *src;
GstController *controller; GstController *controller;
GstInterpolationControlSource *control_source; GstInterpolationControlSource *control_source;
GESTrackVideoTransition *self;
self = GES_TRACK_VIDEO_TRANSITION (object);
GST_LOG ("creating a video bin"); GST_LOG ("creating a video bin");
@ -139,22 +177,22 @@ ges_track_video_transition_create_element (GESTrackTransition * self,
g_object_set (G_OBJECT (mixer), "background", 1, NULL); g_object_set (G_OBJECT (mixer), "background", 1, NULL);
gst_bin_add (GST_BIN (topbin), mixer); gst_bin_add (GST_BIN (topbin), mixer);
if (self->vtype != VTYPE_CROSSFADE) { if (self->type != VTYPE_CROSSFADE) {
link_element_to_mixer_with_smpte (GST_BIN (topbin), iconva, mixer, link_element_to_mixer_with_smpte (GST_BIN (topbin), iconva, mixer,
self->vtype, NULL); self->type, NULL);
target = link_element_to_mixer_with_smpte (GST_BIN (topbin), iconvb, target = link_element_to_mixer_with_smpte (GST_BIN (topbin), iconvb,
mixer, self->vtype, &self->vsmpte); mixer, self->type, &self->smpte);
propname = "position"; propname = "position";
self->vstart_value = 1.0; self->start_value = 1.0;
self->vend_value = 0.0; self->end_value = 0.0;
} else { } else {
self->sinka = (GstPad *) link_element_to_mixer (iconva, mixer); self->sinka = (GstPad *) link_element_to_mixer (iconva, mixer);
self->sinkb = (GstPad *) link_element_to_mixer (iconvb, mixer); self->sinkb = (GstPad *) link_element_to_mixer (iconvb, mixer);
target = (GObject *) self->sinkb; target = (GObject *) self->sinkb;
self->vmixer = gst_object_ref (mixer); self->mixer = gst_object_ref (mixer);
propname = "alpha"; propname = "alpha";
self->vstart_value = 0.0; self->start_value = 0.0;
self->vend_value = 1.0; self->end_value = 1.0;
} }
gst_element_link (mixer, oconv); gst_element_link (mixer, oconv);
@ -187,8 +225,8 @@ ges_track_video_transition_create_element (GESTrackTransition * self,
gst_interpolation_control_source_set_interpolation_mode (control_source, gst_interpolation_control_source_set_interpolation_mode (control_source,
GST_INTERPOLATE_LINEAR); GST_INTERPOLATE_LINEAR);
self->vcontroller = controller; self->controller = controller;
self->vcontrol_source = control_source; self->control_source = control_source;
return topbin; return topbin;
} }
@ -228,19 +266,20 @@ link_element_to_mixer_with_smpte (GstBin * bin, GstElement * element,
} }
static void static void
ges_track_video_transition_duration_changed (GESTrackTransition * self, ges_track_video_transition_duration_changed (GESTrackTransition * object,
GstElement * gnlobj) GstElement * gnlobj)
{ {
GValue start_value = { 0, }; GValue start_value = { 0, };
GValue end_value = { 0, }; GValue end_value = { 0, };
guint64 duration; guint64 duration;
GESTrackVideoTransition *self = GES_TRACK_VIDEO_TRANSITION (object);
GST_LOG ("updating controller"); GST_LOG ("updating controller");
if (!gnlobj) if (!gnlobj)
return; return;
if (!(self->vcontroller)) if (!(self->controller))
return; return;
GST_LOG ("getting properties"); GST_LOG ("getting properties");
@ -249,22 +288,36 @@ ges_track_video_transition_duration_changed (GESTrackTransition * self,
GST_INFO ("duration: %d\n", duration); GST_INFO ("duration: %d\n", duration);
g_value_init (&start_value, G_TYPE_DOUBLE); g_value_init (&start_value, G_TYPE_DOUBLE);
g_value_init (&end_value, G_TYPE_DOUBLE); g_value_init (&end_value, G_TYPE_DOUBLE);
g_value_set_double (&start_value, self->vstart_value); g_value_set_double (&start_value, self->start_value);
g_value_set_double (&end_value, self->vend_value); g_value_set_double (&end_value, self->end_value);
GST_LOG ("setting values on controller"); GST_LOG ("setting values on controller");
g_assert (GST_IS_CONTROLLER (self->vcontroller)); g_assert (GST_IS_CONTROLLER (self->controller));
g_assert (GST_IS_CONTROL_SOURCE (self->vcontrol_source)); g_assert (GST_IS_CONTROL_SOURCE (self->control_source));
gst_interpolation_control_source_unset_all (self->vcontrol_source); gst_interpolation_control_source_unset_all (self->control_source);
gst_interpolation_control_source_set (self->vcontrol_source, 0, &start_value); gst_interpolation_control_source_set (self->control_source, 0, &start_value);
gst_interpolation_control_source_set (self->vcontrol_source, gst_interpolation_control_source_set (self->control_source,
duration, &end_value); duration, &end_value);
GST_LOG ("done updating controller"); GST_LOG ("done updating controller");
} }
void
ges_track_video_transition_set_type (GESTrackVideoTransition * self, gint type)
{
if (((type == VTYPE_CROSSFADE) && (self->type != VTYPE_CROSSFADE)) ||
((type != VTYPE_CROSSFADE) && (self->type = VTYPE_CROSSFADE))) {
GST_WARNING
("Changing between 'crossfade' and other types is not supported\n");
}
self->type = type;
if (self->smpte && (type != VTYPE_CROSSFADE))
g_object_set (self->smpte, "type", (gint) type, NULL);
}
GESTrackVideoTransition * GESTrackVideoTransition *
ges_track_video_transition_new (void) ges_track_video_transition_new (void)
{ {

View file

@ -53,6 +53,27 @@ G_BEGIN_DECLS
struct _GESTrackVideoTransition { struct _GESTrackVideoTransition {
GESTrackTransition parent; GESTrackTransition parent;
/*< public >*/
/* given to to smpte alpha element */
gint type;
/*< private >*/
/* these enable video interpolation */
GstController *controller;
GstInterpolationControlSource *control_source;
/* so we can support changing between wipes */
GstElement *smpte;
GstElement *mixer;
GstPad *sinka;
GstPad *sinkb;
/* these will be different depending on whether smptealpha or alpha element
* is used */
gdouble start_value;
gdouble end_value;
/*< public >*/ /*< public >*/
}; };
@ -70,6 +91,9 @@ struct _GESTrackVideoTransitionClass {
GType ges_track_video_transition_get_type (void); GType ges_track_video_transition_get_type (void);
void
ges_track_video_transition_set_type (GESTrackVideoTransition * self, gint type);
GESTrackVideoTransition* ges_track_video_transition_new (void); GESTrackVideoTransition* ges_track_video_transition_new (void);
G_END_DECLS G_END_DECLS