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; gobject_class->dispose = ges_audio_source_dispose;
track_class->nleobject_factorytype = "nlesource"; track_class->nleobject_factorytype = "nlesource";
track_class->create_element = ges_audio_source_create_element; 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; 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); return g_value_get_double (&val);
} }
/** /* Creates a new #GESAudioTestSource.
* ges_audio_test_source_new:
*
* Creates a new #GESAudioTestSource.
* *
* Returns: (transfer floating) (nullable): The newly created #GESAudioTestSource. * Returns: (transfer floating) (nullable): The newly created #GESAudioTestSource.
*/ */
GESAudioTestSource * GESAudioTestSource *
ges_audio_test_source_new (void) ges_audio_test_source_new (void)
{ {
return g_object_new (GES_TYPE_AUDIO_TEST_SOURCE, "track-type", GESAudioTestSource *res;
GES_TRACK_TYPE_AUDIO, NULL); 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; object_class->finalize = ges_audio_transition_finalize;
toclass->create_element = ges_audio_transition_create_element; 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. * Creates a new #GESAudioTransition.
* *
* Returns: (transfer floating): The newly created #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 * GESAudioTransition *
ges_audio_transition_new (void) ges_audio_transition_new (void)
{ {
return g_object_new (GES_TYPE_AUDIO_TRANSITION, "track-type", GESAudioTransition *res;
GES_TRACK_TYPE_AUDIO, NULL); 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]; gpointer _ges_reserved[GES_PADDING];
}; };
GES_API GES_DEPRECATED
GESAudioTransition* ges_audio_transition_new (void); GESAudioTransition* ges_audio_transition_new (void);
G_END_DECLS G_END_DECLS

View file

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

View file

@ -879,5 +879,11 @@ ges_group_init (GESGroup * self)
GESGroup * GESGroup *
ges_group_new (void) 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) ges_text_overlay_class_init (GESTextOverlayClass * klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (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->get_property = ges_text_overlay_get_property;
object_class->set_property = ges_text_overlay_set_property; object_class->set_property = ges_text_overlay_set_property;
object_class->dispose = ges_text_overlay_dispose; object_class->dispose = ges_text_overlay_dispose;
object_class->finalize = ges_text_overlay_finalize; 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 static void
@ -429,10 +430,18 @@ ges_text_overlay_get_ypos (GESTextOverlay * self)
* *
* Returns: (transfer floating) (nullable): The newly created #GESTextOverlay or * Returns: (transfer floating) (nullable): The newly created #GESTextOverlay or
* %NULL if something went wrong. * %NULL if something went wrong.
*
* Deprecated: 1.18: This should never be called by applications as this will
* be created by clips.
*/ */
GESTextOverlay * GESTextOverlay *
ges_text_overlay_new (void) ges_text_overlay_new (void)
{ {
return g_object_new (GES_TYPE_TEXT_OVERLAY, "track-type", GESTextOverlay *res;
GES_TRACK_TYPE_VIDEO, NULL); 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, void ges_text_overlay_set_ypos (GESTextOverlay * self,
gdouble position); gdouble position);
GES_API GES_DEPRECATED
GESTextOverlay *ges_text_overlay_new (void); GESTextOverlay *ges_text_overlay_new (void);
GES_API GES_API

View file

@ -559,8 +559,7 @@ ges_title_source_get_ypos (GESTitleSource * source)
return ypos; return ypos;
} }
/** /* ges_title_source_new:
* ges_title_source_new:
* *
* Creates a new #GESTitleSource. * Creates a new #GESTitleSource.
* *
@ -570,6 +569,11 @@ ges_title_source_get_ypos (GESTitleSource * source)
GESTitleSource * GESTitleSource *
ges_title_source_new (void) ges_title_source_new (void)
{ {
return g_object_new (GES_TYPE_TITLE_SOURCE, "track-type", GESTitleSource *res;
GES_TRACK_TYPE_VIDEO, NULL); 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 */ /* set the default has-internal-source */
ges_track_element_set_has_internal_source (GES_TRACK_ELEMENT (gobject), ges_track_element_set_has_internal_source (GES_TRACK_ELEMENT (gobject),
GES_TRACK_ELEMENT_CLASS_DEFAULT_HAS_INTERNAL_SOURCE GES_TRACK_ELEMENT_CLASS_DEFAULT_HAS_INTERNAL_SOURCE (class));
(GES_TRACK_ELEMENT_GET_CLASS (gobject)));
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); 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->create_gnl_object = ges_track_element_create_gnl_object_func;
klass->lookup_child = _lookup_child; klass->lookup_child = _lookup_child;
klass->ABI.abi.default_track_type = GES_TRACK_TYPE_UNKNOWN;
} }
static void static void

View file

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

View file

@ -240,6 +240,8 @@ ges_video_source_class_init (GESVideoSourceClass * klass)
track_element_class->nleobject_factorytype = "nlesource"; track_element_class->nleobject_factorytype = "nlesource";
track_element_class->create_element = ges_video_source_create_element; 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; 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); return g_value_get_enum (&val);
} }
/** /* ges_video_test_source_new:
* ges_video_test_source_new:
* *
* Creates a new #GESVideoTestSource. * Creates a new #GESVideoTestSource.
* *
@ -449,6 +448,11 @@ ges_video_test_source_get_pattern (GESVideoTestSource * source)
GESVideoTestSource * GESVideoTestSource *
ges_video_test_source_new (void) ges_video_test_source_new (void)
{ {
return g_object_new (GES_TYPE_VIDEO_TEST_SOURCE, "track-type", GESVideoTestSource *res;
GES_TRACK_TYPE_VIDEO, NULL); 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; GObjectClass *object_class;
GESTrackElementClass *toclass; GESTrackElementClass *toclass;
GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass); GESTimelineElementClass *element_class = GES_TIMELINE_ELEMENT_CLASS (klass);
GESTrackElementClass *track_element_class = GES_TRACK_ELEMENT_CLASS (klass);
object_class = G_OBJECT_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->dispose = ges_video_transition_dispose;
object_class->finalize = ges_video_transition_finalize; object_class->finalize = ges_video_transition_finalize;
track_element_class->ABI.abi.default_track_type = GES_TRACK_TYPE_VIDEO;
/** /**
* GESVideoTransition:border: * GESVideoTransition:border:
* *
@ -672,8 +675,7 @@ ges_video_transition_get_transition_type (GESVideoTransition * trans)
return trans->priv->type; return trans->priv->type;
} }
/** /* ges_video_transition_new:
* ges_video_transition_new:
* *
* Creates a new #GESVideoTransition. * Creates a new #GESVideoTransition.
* *
@ -683,6 +685,11 @@ ges_video_transition_get_transition_type (GESVideoTransition * trans)
GESVideoTransition * GESVideoTransition *
ges_video_transition_new (void) ges_video_transition_new (void)
{ {
return g_object_new (GES_TYPE_VIDEO_TRANSITION, "track-type", GESVideoTransition *res;
GES_TRACK_TYPE_VIDEO, NULL); 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]; gpointer _ges_reserved[GES_PADDING];
}; };
GES_API GES_DEPRECATED
GESVideoTransition* ges_video_transition_new (void); GESVideoTransition* ges_video_transition_new (void);
GES_API GES_API