ges: Use assets to instantiate track elements/group

And deprecate all GESTrackElement constructors, but the GESEffect one.
Those should **never** be created by users and should become internal
in the future.

Stop having docstring for the constructors that were internal.
This commit is contained in:
Thibault Saunier 2020-03-24 22:23:16 -03:00
parent cec1dd3302
commit ffc11daa40
15 changed files with 86 additions and 39 deletions

View file

@ -182,6 +182,7 @@ ges_audio_source_class_init (GESAudioSourceClass * klass)
gobject_class->dispose = ges_audio_source_dispose;
track_class->nleobject_factorytype = "nlesource";
track_class->create_element = ges_audio_source_create_element;
track_class->ABI.abi.default_track_type = GES_TRACK_TYPE_AUDIO;
audio_source_class->create_source = NULL;
}

View file

@ -199,16 +199,18 @@ ges_audio_test_source_get_volume (GESAudioTestSource * self)
return g_value_get_double (&val);
}
/**
* ges_audio_test_source_new:
*
* Creates a new #GESAudioTestSource.
/* Creates a new #GESAudioTestSource.
*
* Returns: (transfer floating) (nullable): The newly created #GESAudioTestSource.
*/
GESAudioTestSource *
ges_audio_test_source_new (void)
{
return g_object_new (GES_TYPE_AUDIO_TEST_SOURCE, "track-type",
GES_TRACK_TYPE_AUDIO, NULL);
GESAudioTestSource *res;
GESAsset *asset = ges_asset_request (GES_TYPE_AUDIO_TEST_SOURCE, NULL, NULL);
res = GES_AUDIO_TEST_SOURCE (ges_asset_extract (asset, NULL));
gst_object_unref (asset);
return res;
}

View file

@ -90,6 +90,7 @@ ges_audio_transition_class_init (GESAudioTransitionClass * klass)
object_class->finalize = ges_audio_transition_finalize;
toclass->create_element = ges_audio_transition_create_element;
toclass->ABI.abi.default_track_type = GES_TRACK_TYPE_AUDIO;
}
@ -289,10 +290,18 @@ ges_audio_transition_duration_changed (GESTrackElement * track_element,
* Creates a new #GESAudioTransition.
*
* Returns: (transfer floating): The newly created #GESAudioTransition.
*
* Deprecated: 1.18: This should never be called by applications as this will
* be created by clips.
*/
GESAudioTransition *
ges_audio_transition_new (void)
{
return g_object_new (GES_TYPE_AUDIO_TRANSITION, "track-type",
GES_TRACK_TYPE_AUDIO, NULL);
GESAudioTransition *res;
GESAsset *asset = ges_asset_request (GES_TYPE_AUDIO_TRANSITION, NULL, NULL);
res = GES_AUDIO_TRANSITION (ges_asset_extract (asset, NULL));
gst_object_unref (asset);
return res;
}

View file

@ -51,7 +51,7 @@ struct _GESAudioTransitionClass {
gpointer _ges_reserved[GES_PADDING];
};
GES_API
GES_DEPRECATED
GESAudioTransition* ges_audio_transition_new (void);
G_END_DECLS

View file

@ -242,11 +242,8 @@ _create_track_element (GESClip * self, GESTrackType type)
bin_description = effect->priv->audio_bin_description;
}
if (bin_description) {
/* FIXME Work with a GESAsset here! */
return g_object_new (GES_TYPE_EFFECT, "bin-description",
bin_description, "track-type", type, NULL);
}
if (bin_description)
return GES_TRACK_ELEMENT (ges_effect_new (bin_description));
GST_WARNING ("Effect doesn't handle this track type");
return NULL;

View file

@ -879,5 +879,11 @@ ges_group_init (GESGroup * self)
GESGroup *
ges_group_new (void)
{
return g_object_new (GES_TYPE_GROUP, NULL);
GESGroup *res;
GESAsset *asset = ges_asset_request (GES_TYPE_GROUP, NULL, NULL);
res = GES_GROUP (ges_asset_extract (asset, NULL));
gst_object_unref (asset);
return res;
}

View file

@ -69,14 +69,15 @@ static void
ges_text_overlay_class_init (GESTextOverlayClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GESTrackElementClass *bg_class = GES_TRACK_ELEMENT_CLASS (klass);
GESTrackElementClass *track_element_class = GES_TRACK_ELEMENT_CLASS (klass);
object_class->get_property = ges_text_overlay_get_property;
object_class->set_property = ges_text_overlay_set_property;
object_class->dispose = ges_text_overlay_dispose;
object_class->finalize = ges_text_overlay_finalize;
bg_class->create_element = ges_text_overlay_create_element;
track_element_class->create_element = ges_text_overlay_create_element;
track_element_class->ABI.abi.default_track_type = GES_TRACK_TYPE_VIDEO;
}
static void
@ -429,10 +430,18 @@ ges_text_overlay_get_ypos (GESTextOverlay * self)
*
* Returns: (transfer floating) (nullable): The newly created #GESTextOverlay or
* %NULL if something went wrong.
*
* Deprecated: 1.18: This should never be called by applications as this will
* be created by clips.
*/
GESTextOverlay *
ges_text_overlay_new (void)
{
return g_object_new (GES_TYPE_TEXT_OVERLAY, "track-type",
GES_TRACK_TYPE_VIDEO, NULL);
GESTextOverlay *res;
GESAsset *asset = ges_asset_request (GES_TYPE_TEXT_OVERLAY, NULL, NULL);
res = GES_TEXT_OVERLAY (ges_asset_extract (asset, NULL));
gst_object_unref (asset);
return res;
}

View file

@ -77,7 +77,7 @@ GES_API
void ges_text_overlay_set_ypos (GESTextOverlay * self,
gdouble position);
GES_API
GES_DEPRECATED
GESTextOverlay *ges_text_overlay_new (void);
GES_API

View file

@ -407,7 +407,7 @@ ges_title_source_set_ypos (GESTitleSource * self, gdouble position)
* Get the text currently set on the @source.
*
* Returns: (transfer full): The text currently set on the @source.
*
*
* Deprecated: 1.16: Use ges_timeline_element_get_child_property instead
* (this actually returns a newly allocated string)
*/
@ -430,7 +430,7 @@ ges_title_source_get_text (GESTitleSource * source)
*
* Returns: (transfer full): The pango font description used by this
* @source.
*
*
* Deprecated: 1.16: Use ges_timeline_element_get_child_property instead
* (this actually returns a newly allocated string)
*/
@ -559,8 +559,7 @@ ges_title_source_get_ypos (GESTitleSource * source)
return ypos;
}
/**
* ges_title_source_new:
/* ges_title_source_new:
*
* Creates a new #GESTitleSource.
*
@ -570,6 +569,11 @@ ges_title_source_get_ypos (GESTitleSource * source)
GESTitleSource *
ges_title_source_new (void)
{
return g_object_new (GES_TYPE_TITLE_SOURCE, "track-type",
GES_TRACK_TYPE_VIDEO, NULL);
GESTitleSource *res;
GESAsset *asset = ges_asset_request (GES_TYPE_TITLE_SOURCE, NULL, NULL);
res = GES_TITLE_SOURCE (ges_asset_extract (asset, NULL));
gst_object_unref (asset);
return res;
}

View file

@ -313,8 +313,11 @@ ges_track_element_constructed (GObject * gobject)
/* set the default has-internal-source */
ges_track_element_set_has_internal_source (GES_TRACK_ELEMENT (gobject),
GES_TRACK_ELEMENT_CLASS_DEFAULT_HAS_INTERNAL_SOURCE
(GES_TRACK_ELEMENT_GET_CLASS (gobject)));
GES_TRACK_ELEMENT_CLASS_DEFAULT_HAS_INTERNAL_SOURCE (class));
if (object->priv->track_type == GES_TRACK_TYPE_UNKNOWN)
ges_track_element_set_track_type (GES_TRACK_ELEMENT (gobject),
class->ABI.abi.default_track_type);
G_OBJECT_CLASS (ges_track_element_parent_class)->constructed (gobject);
}
@ -454,6 +457,7 @@ ges_track_element_class_init (GESTrackElementClass * klass)
klass->create_gnl_object = ges_track_element_create_gnl_object_func;
klass->lookup_child = _lookup_child;
klass->ABI.abi.default_track_type = GES_TRACK_TYPE_UNKNOWN;
}
static void

View file

@ -81,6 +81,8 @@ struct _GESTrackElement {
* @default_has_internal_source: What the default
* #GESTrackElement:has-internal-source value should be for new elements
* from this class.
* @default_track_type: What the default #GESTrackElement:track-type value
* should be for new elements from this class.
*/
struct _GESTrackElementClass {
/*< private >*/
@ -106,12 +108,12 @@ struct _GESTrackElementClass {
const gchar *prop_name,
GstElement **element,
GParamSpec **pspec);
/*< private >*/
/* Padding for API extension */
/*< protected >*/
union {
gpointer _ges_reserved[GES_PADDING_LARGE];
struct {
gboolean default_has_internal_source;
GESTrackType default_track_type;
} abi;
} ABI;
};

View file

@ -240,6 +240,8 @@ ges_video_source_class_init (GESVideoSourceClass * klass)
track_element_class->nleobject_factorytype = "nlesource";
track_element_class->create_element = ges_video_source_create_element;
track_element_class->ABI.abi.default_track_type = GES_TRACK_TYPE_VIDEO;
video_source_class->create_source = NULL;
}

View file

@ -438,8 +438,7 @@ ges_video_test_source_get_pattern (GESVideoTestSource * source)
return g_value_get_enum (&val);
}
/**
* ges_video_test_source_new:
/* ges_video_test_source_new:
*
* Creates a new #GESVideoTestSource.
*
@ -449,6 +448,11 @@ ges_video_test_source_get_pattern (GESVideoTestSource * source)
GESVideoTestSource *
ges_video_test_source_new (void)
{
return g_object_new (GES_TYPE_VIDEO_TEST_SOURCE, "track-type",
GES_TRACK_TYPE_VIDEO, NULL);
GESVideoTestSource *res;
GESAsset *asset = ges_asset_request (GES_TYPE_VIDEO_TEST_SOURCE, NULL, NULL);
res = GES_VIDEO_TEST_SOURCE (ges_asset_extract (asset, NULL));
gst_object_unref (asset);
return res;
}

View file

@ -139,6 +139,7 @@ ges_video_transition_class_init (GESVideoTransitionClass * klass)
GObjectClass *object_class;
GESTrackElementClass *toclass;
GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
GESTrackElementClass *track_element_class = GES_TRACK_ELEMENT_CLASS (klass);
object_class = G_OBJECT_CLASS (klass);
@ -147,6 +148,8 @@ ges_video_transition_class_init (GESVideoTransitionClass * klass)
object_class->dispose = ges_video_transition_dispose;
object_class->finalize = ges_video_transition_finalize;
track_element_class->ABI.abi.default_track_type = GES_TRACK_TYPE_VIDEO;
/**
* GESVideoTransition:border:
*
@ -672,8 +675,7 @@ ges_video_transition_get_transition_type (GESVideoTransition * trans)
return trans->priv->type;
}
/**
* ges_video_transition_new:
/* ges_video_transition_new:
*
* Creates a new #GESVideoTransition.
*
@ -683,6 +685,11 @@ ges_video_transition_get_transition_type (GESVideoTransition * trans)
GESVideoTransition *
ges_video_transition_new (void)
{
return g_object_new (GES_TYPE_VIDEO_TRANSITION, "track-type",
GES_TRACK_TYPE_VIDEO, NULL);
GESVideoTransition *res;
GESAsset *asset = ges_asset_request (GES_TYPE_VIDEO_TRANSITION, NULL, NULL);
res = GES_VIDEO_TRANSITION (ges_asset_extract (asset, NULL));
gst_object_unref (asset);
return res;
}

View file

@ -58,7 +58,7 @@ struct _GESVideoTransitionClass {
gpointer _ges_reserved[GES_PADDING];
};
GES_API
GES_DEPRECATED
GESVideoTransition* ges_video_transition_new (void);
GES_API