mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 16:51:10 +00:00
TrackVideoTransition: Move private variable to instance private
Also add/fixup methods to get/set the transition type and document them.
This commit is contained in:
parent
c8dc8973b0
commit
58afc44fd7
5 changed files with 116 additions and 83 deletions
|
@ -198,7 +198,8 @@ GES_TYPE_TRACK_AUDIO_TRANSITION
|
||||||
<TITLE>GESTrackVideoTransition</TITLE>
|
<TITLE>GESTrackVideoTransition</TITLE>
|
||||||
GESTrackVideoTransition
|
GESTrackVideoTransition
|
||||||
ges_track_video_transition_new
|
ges_track_video_transition_new
|
||||||
ges_track_video_transition_set_type
|
ges_track_video_transition_set_transition_type
|
||||||
|
ges_track_video_transition_get_transition_type
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GESTrackVideoTransitionClass
|
GESTrackVideoTransitionClass
|
||||||
GESTrackVideoTransitionPrivate
|
GESTrackVideoTransitionPrivate
|
||||||
|
|
|
@ -71,7 +71,7 @@ ges_timeline_standard_transition_update_vtype_internal (GESTimelineObject *
|
||||||
GESTrackVideoTransition *obj;
|
GESTrackVideoTransition *obj;
|
||||||
if (GES_IS_TRACK_VIDEO_TRANSITION (tmp->data)) {
|
if (GES_IS_TRACK_VIDEO_TRANSITION (tmp->data)) {
|
||||||
obj = (GESTrackVideoTransition *) tmp->data;
|
obj = (GESTrackVideoTransition *) tmp->data;
|
||||||
if (!ges_track_video_transition_set_type (obj, value))
|
if (!ges_track_video_transition_set_transition_type (obj, value))
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,8 +168,8 @@ 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_video_transition_set_type ((GESTrackVideoTransition *) res,
|
ges_track_video_transition_set_transition_type ((GESTrackVideoTransition *)
|
||||||
transition->vtype);
|
res, transition->vtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (track->type == GES_TRACK_TYPE_AUDIO) {
|
else if (track->type == GES_TRACK_TYPE_AUDIO) {
|
||||||
|
|
|
@ -31,8 +31,22 @@ G_DEFINE_TYPE (GESTrackVideoTransition, ges_track_video_transition,
|
||||||
|
|
||||||
struct _GESTrackVideoTransitionPrivate
|
struct _GESTrackVideoTransitionPrivate
|
||||||
{
|
{
|
||||||
/* Dummy variable */
|
GESVideoStandardTransitionType type;
|
||||||
void *nothing;
|
|
||||||
|
/* 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -92,48 +106,49 @@ ges_track_video_transition_init (GESTrackVideoTransition * self)
|
||||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||||
GES_TYPE_TRACK_VIDEO_TRANSITION, GESTrackVideoTransitionPrivate);
|
GES_TYPE_TRACK_VIDEO_TRANSITION, GESTrackVideoTransitionPrivate);
|
||||||
|
|
||||||
self->controller = NULL;
|
self->priv->controller = NULL;
|
||||||
self->control_source = NULL;
|
self->priv->control_source = NULL;
|
||||||
self->smpte = NULL;
|
self->priv->smpte = NULL;
|
||||||
self->mixer = NULL;
|
self->priv->mixer = NULL;
|
||||||
self->sinka = NULL;
|
self->priv->sinka = NULL;
|
||||||
self->sinkb = NULL;
|
self->priv->sinkb = NULL;
|
||||||
self->type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
|
self->priv->type = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
|
||||||
self->start_value = 0.0;
|
self->priv->start_value = 0.0;
|
||||||
self->end_value = 0.0;
|
self->priv->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);
|
GESTrackVideoTransition *self = GES_TRACK_VIDEO_TRANSITION (object);
|
||||||
|
GESTrackVideoTransitionPrivate *priv = self->priv;
|
||||||
|
|
||||||
GST_DEBUG ("disposing");
|
GST_DEBUG ("disposing");
|
||||||
GST_LOG ("mixer: %p smpte: %p sinka: %p sinkb: %p",
|
GST_LOG ("mixer: %p smpte: %p sinka: %p sinkb: %p",
|
||||||
self->mixer, self->smpte, self->sinka, self->sinkb);
|
priv->mixer, priv->smpte, priv->sinka, priv->sinkb);
|
||||||
|
|
||||||
if (self->controller) {
|
if (priv->controller) {
|
||||||
g_object_unref (self->controller);
|
g_object_unref (priv->controller);
|
||||||
self->controller = NULL;
|
priv->controller = NULL;
|
||||||
if (self->control_source)
|
if (priv->control_source)
|
||||||
gst_object_unref (self->control_source);
|
gst_object_unref (priv->control_source);
|
||||||
self->control_source = NULL;
|
priv->control_source = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->sinka && self->sinkb) {
|
if (priv->sinka && priv->sinkb) {
|
||||||
GST_DEBUG ("releasing request pads for mixer");
|
GST_DEBUG ("releasing request pads for mixer");
|
||||||
gst_element_release_request_pad (self->mixer, self->sinka);
|
gst_element_release_request_pad (priv->mixer, priv->sinka);
|
||||||
gst_element_release_request_pad (self->mixer, self->sinkb);
|
gst_element_release_request_pad (priv->mixer, priv->sinkb);
|
||||||
gst_object_unref (self->sinka);
|
gst_object_unref (priv->sinka);
|
||||||
gst_object_unref (self->sinkb);
|
gst_object_unref (priv->sinkb);
|
||||||
self->sinka = NULL;
|
priv->sinka = NULL;
|
||||||
self->sinkb = NULL;
|
priv->sinkb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->mixer) {
|
if (priv->mixer) {
|
||||||
GST_LOG ("unrefing mixer");
|
GST_LOG ("unrefing mixer");
|
||||||
gst_object_unref (self->mixer);
|
gst_object_unref (priv->mixer);
|
||||||
self->mixer = NULL;
|
priv->mixer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (ges_track_video_transition_parent_class)->dispose (object);
|
G_OBJECT_CLASS (ges_track_video_transition_parent_class)->dispose (object);
|
||||||
|
@ -176,8 +191,10 @@ ges_track_video_transition_create_element (GESTrackObject * object)
|
||||||
GstController *controller;
|
GstController *controller;
|
||||||
GstInterpolationControlSource *control_source;
|
GstInterpolationControlSource *control_source;
|
||||||
GESTrackVideoTransition *self;
|
GESTrackVideoTransition *self;
|
||||||
|
GESTrackVideoTransitionPrivate *priv;
|
||||||
|
|
||||||
self = GES_TRACK_VIDEO_TRANSITION (object);
|
self = GES_TRACK_VIDEO_TRANSITION (object);
|
||||||
|
priv = self->priv;
|
||||||
|
|
||||||
GST_LOG ("creating a video bin");
|
GST_LOG ("creating a video bin");
|
||||||
|
|
||||||
|
@ -194,27 +211,27 @@ ges_track_video_transition_create_element (GESTrackObject * object)
|
||||||
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->type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
|
if (priv->type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) {
|
||||||
self->sinka =
|
priv->sinka =
|
||||||
(GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconva,
|
(GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconva,
|
||||||
mixer, self->type, NULL);
|
mixer, priv->type, NULL);
|
||||||
self->sinkb =
|
priv->sinkb =
|
||||||
(GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconvb,
|
(GstPad *) link_element_to_mixer_with_smpte (GST_BIN (topbin), iconvb,
|
||||||
mixer, self->type, &self->smpte);
|
mixer, priv->type, &priv->smpte);
|
||||||
target = (GObject *) self->smpte;
|
target = (GObject *) priv->smpte;
|
||||||
propname = "position";
|
propname = "position";
|
||||||
self->start_value = 1.0;
|
priv->start_value = 1.0;
|
||||||
self->end_value = 0.0;
|
priv->end_value = 0.0;
|
||||||
} else {
|
} else {
|
||||||
self->sinka = (GstPad *) link_element_to_mixer (iconva, mixer);
|
priv->sinka = (GstPad *) link_element_to_mixer (iconva, mixer);
|
||||||
self->sinkb = (GstPad *) link_element_to_mixer (iconvb, mixer);
|
priv->sinkb = (GstPad *) link_element_to_mixer (iconvb, mixer);
|
||||||
target = (GObject *) self->sinkb;
|
target = (GObject *) priv->sinkb;
|
||||||
propname = "alpha";
|
propname = "alpha";
|
||||||
self->start_value = 0.0;
|
priv->start_value = 0.0;
|
||||||
self->end_value = 1.0;
|
priv->end_value = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->mixer = gst_object_ref (mixer);
|
priv->mixer = gst_object_ref (mixer);
|
||||||
|
|
||||||
fast_element_link (mixer, oconv);
|
fast_element_link (mixer, oconv);
|
||||||
|
|
||||||
|
@ -246,8 +263,8 @@ ges_track_video_transition_create_element (GESTrackObject * object)
|
||||||
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->controller = controller;
|
priv->controller = controller;
|
||||||
self->control_source = control_source;
|
priv->control_source = control_source;
|
||||||
|
|
||||||
return topbin;
|
return topbin;
|
||||||
}
|
}
|
||||||
|
@ -298,48 +315,72 @@ ges_track_video_transition_duration_changed (GESTrackObject * object,
|
||||||
GValue end_value = { 0, };
|
GValue end_value = { 0, };
|
||||||
GstElement *gnlobj = ges_track_object_get_gnlobject (object);
|
GstElement *gnlobj = ges_track_object_get_gnlobject (object);
|
||||||
GESTrackVideoTransition *self = GES_TRACK_VIDEO_TRANSITION (object);
|
GESTrackVideoTransition *self = GES_TRACK_VIDEO_TRANSITION (object);
|
||||||
|
GESTrackVideoTransitionPrivate *priv = self->priv;
|
||||||
|
|
||||||
GST_LOG ("updating controller");
|
GST_LOG ("updating controller");
|
||||||
|
|
||||||
if (G_UNLIKELY (!gnlobj || !self->control_source))
|
if (G_UNLIKELY (!gnlobj || !priv->control_source))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GST_INFO ("duration: %" G_GUINT64_FORMAT, duration);
|
GST_INFO ("duration: %" G_GUINT64_FORMAT, 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->start_value);
|
g_value_set_double (&start_value, priv->start_value);
|
||||||
g_value_set_double (&end_value, self->end_value);
|
g_value_set_double (&end_value, priv->end_value);
|
||||||
|
|
||||||
GST_LOG ("setting values on controller");
|
GST_LOG ("setting values on controller");
|
||||||
|
|
||||||
gst_interpolation_control_source_unset_all (self->control_source);
|
gst_interpolation_control_source_unset_all (priv->control_source);
|
||||||
gst_interpolation_control_source_set (self->control_source, 0, &start_value);
|
gst_interpolation_control_source_set (priv->control_source, 0, &start_value);
|
||||||
gst_interpolation_control_source_set (self->control_source,
|
gst_interpolation_control_source_set (priv->control_source,
|
||||||
duration, &end_value);
|
duration, &end_value);
|
||||||
|
|
||||||
GST_LOG ("done updating controller");
|
GST_LOG ("done updating controller");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_video_transition_set_transition_type:
|
||||||
|
* @self: a #GESTrackVideoTransition
|
||||||
|
* @type: a #GESVideoStandardTransitionType
|
||||||
|
*
|
||||||
|
* Sets the transition being used to @type.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the transition type was properly changed, else %FALSE.
|
||||||
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
ges_track_video_transition_set_type (GESTrackVideoTransition * self,
|
ges_track_video_transition_set_transition_type (GESTrackVideoTransition * self,
|
||||||
GESVideoStandardTransitionType type)
|
GESVideoStandardTransitionType type)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("%p %d => %d", self, self->type, type);
|
GESTrackVideoTransitionPrivate *priv = self->priv;
|
||||||
|
|
||||||
if (self->type && (self->type != type) &&
|
GST_DEBUG ("%p %d => %d", self, priv->type, type);
|
||||||
|
|
||||||
|
if (priv->type && (priv->type != type) &&
|
||||||
((type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) ||
|
((type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE) ||
|
||||||
(self->type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE))) {
|
(priv->type == GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE))) {
|
||||||
GST_WARNING
|
GST_WARNING
|
||||||
("Changing between 'crossfade' and other types is not supported");
|
("Changing between 'crossfade' and other types is not supported");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->type = type;
|
priv->type = type;
|
||||||
if (self->smpte && (type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE))
|
if (priv->smpte && (type != GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE))
|
||||||
g_object_set (self->smpte, "type", (gint) type, NULL);
|
g_object_set (priv->smpte, "type", (gint) type, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_video_transition_get_transition_type:
|
||||||
|
* @trans: a #GESTrackVideoTransition
|
||||||
|
*
|
||||||
|
* Returns: The transition type used by @trans.
|
||||||
|
*/
|
||||||
|
GESVideoStandardTransitionType
|
||||||
|
ges_track_video_transition_get_transition_type (GESTrackVideoTransition * trans)
|
||||||
|
{
|
||||||
|
return trans->priv->type;
|
||||||
|
}
|
||||||
|
|
||||||
GESTrackVideoTransition *
|
GESTrackVideoTransition *
|
||||||
ges_track_video_transition_new (void)
|
ges_track_video_transition_new (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,22 +54,6 @@ struct _GESTrackVideoTransition {
|
||||||
GESTrackTransition parent;
|
GESTrackTransition parent;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GESVideoStandardTransitionType type;
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
GESTrackVideoTransitionPrivate *priv;
|
GESTrackVideoTransitionPrivate *priv;
|
||||||
|
|
||||||
|
@ -93,8 +77,11 @@ struct _GESTrackVideoTransitionClass {
|
||||||
|
|
||||||
GType ges_track_video_transition_get_type (void);
|
GType ges_track_video_transition_get_type (void);
|
||||||
|
|
||||||
gboolean ges_track_video_transition_set_type (GESTrackVideoTransition * self,
|
gboolean
|
||||||
|
ges_track_video_transition_set_transition_type (GESTrackVideoTransition * self,
|
||||||
GESVideoStandardTransitionType type);
|
GESVideoStandardTransitionType type);
|
||||||
|
GESVideoStandardTransitionType
|
||||||
|
ges_track_video_transition_get_transition_type (GESTrackVideoTransition * trans);
|
||||||
|
|
||||||
GESTrackVideoTransition* ges_track_video_transition_new (void);
|
GESTrackVideoTransition* ges_track_video_transition_new (void);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ GST_START_TEST (test_transition_basic)
|
||||||
track);
|
track);
|
||||||
|
|
||||||
fail_unless (trackobject != NULL);
|
fail_unless (trackobject != NULL);
|
||||||
fail_unless (GES_TRACK_VIDEO_TRANSITION (trackobject)->type == 1);
|
fail_unless (ges_track_video_transition_get_transition_type
|
||||||
|
(GES_TRACK_VIDEO_TRANSITION (trackobject)) == 1);
|
||||||
|
|
||||||
fail_unless (ges_timeline_object_release_track_object (GES_TIMELINE_OBJECT
|
fail_unless (ges_timeline_object_release_track_object (GES_TIMELINE_OBJECT
|
||||||
(tr2), trackobject) == TRUE);
|
(tr2), trackobject) == TRUE);
|
||||||
|
@ -134,7 +135,8 @@ GST_START_TEST (test_transition_properties)
|
||||||
NULL);
|
NULL);
|
||||||
assert_equals_int (GES_TIMELINE_STANDARD_TRANSITION (object)->vtype,
|
assert_equals_int (GES_TIMELINE_STANDARD_TRANSITION (object)->vtype,
|
||||||
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
||||||
assert_equals_int (GES_TRACK_VIDEO_TRANSITION (trackobject)->type,
|
assert_equals_int (ges_track_video_transition_get_transition_type
|
||||||
|
(GES_TRACK_VIDEO_TRANSITION (trackobject)),
|
||||||
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
||||||
|
|
||||||
/* Check that changing from crossfade to anything else fails (it should
|
/* Check that changing from crossfade to anything else fails (it should
|
||||||
|
@ -144,7 +146,8 @@ GST_START_TEST (test_transition_properties)
|
||||||
/* FIXME : This should succeed */
|
/* FIXME : This should succeed */
|
||||||
assert_equals_int (GES_TIMELINE_STANDARD_TRANSITION (object)->vtype,
|
assert_equals_int (GES_TIMELINE_STANDARD_TRANSITION (object)->vtype,
|
||||||
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
||||||
assert_equals_int (GES_TRACK_VIDEO_TRANSITION (trackobject)->type,
|
assert_equals_int (ges_track_video_transition_get_transition_type
|
||||||
|
(GES_TRACK_VIDEO_TRANSITION (trackobject)),
|
||||||
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
||||||
|
|
||||||
GST_DEBUG ("Releasing track object");
|
GST_DEBUG ("Releasing track object");
|
||||||
|
@ -160,7 +163,8 @@ GST_START_TEST (test_transition_properties)
|
||||||
/* The new track object should have taken the previously set transition
|
/* The new track object should have taken the previously set transition
|
||||||
* type (in this case 1) */
|
* type (in this case 1) */
|
||||||
GST_DEBUG ("Setting to vtype:1");
|
GST_DEBUG ("Setting to vtype:1");
|
||||||
assert_equals_int (GES_TRACK_VIDEO_TRANSITION (trackobject)->type, 1);
|
assert_equals_int (ges_track_video_transition_get_transition_type
|
||||||
|
(GES_TRACK_VIDEO_TRANSITION (trackobject)), 1);
|
||||||
assert_equals_int (GES_TIMELINE_STANDARD_TRANSITION (object)->vtype, 1);
|
assert_equals_int (GES_TIMELINE_STANDARD_TRANSITION (object)->vtype, 1);
|
||||||
|
|
||||||
ges_timeline_object_release_track_object (object, trackobject);
|
ges_timeline_object_release_track_object (object, trackobject);
|
||||||
|
|
Loading…
Reference in a new issue