ges: Use GESAsset in clip contructors when possible

This commit is contained in:
Thibault Saunier 2013-03-03 11:50:10 -03:00
parent fceb80dda3
commit eaf30dd4c5
6 changed files with 56 additions and 27 deletions

View file

@ -82,8 +82,8 @@ extractable_get_parameters_from_id (const gchar * id, guint * n_params)
GUINT_TO_POINTER (g_ascii_strtoll (func_udata[1], NULL, 10)));
params[2].name = "supported-formats";
g_value_init (&params[2].value, G_TYPE_ENUM);
g_value_set_enum (&params[2].value, GES_TRACK_TYPE_CUSTOM);
g_value_init (&params[2].value, GES_TYPE_TRACK_TYPE);
g_value_set_flags (&params[2].value, GES_TRACK_TYPE_CUSTOM);
g_strfreev (func_udata);
@ -232,11 +232,10 @@ ges_custom_source_clip_new (GESFillTrackElementUserFunc func,
gpointer user_data)
{
GESCustomSourceClip *src;
GESAsset *asset = ges_asset_custom_source_clip_new (func, user_data);
src = g_object_new (GES_TYPE_CUSTOM_SOURCE_CLIP, "supported-formats",
GES_TRACK_TYPE_CUSTOM, NULL);
src->priv->filltrackelementfunc = func;
src->priv->user_data = user_data;
src = GES_CUSTOM_SOURCE_CLIP (ges_asset_extract (asset, NULL));
gst_object_unref (asset);
return src;
}

View file

@ -190,6 +190,7 @@ GESEffectClip *
ges_effect_clip_new (const gchar * video_bin_description,
const gchar * audio_bin_description)
{
/* FIXME Handle GESAsset! */
return g_object_new (GES_TYPE_EFFECT_CLIP,
"video-bin-description", video_bin_description,
"audio-bin-description", audio_bin_description, NULL);

View file

@ -363,8 +363,13 @@ ges_test_clip_create_track_element (GESClip * clip, GESTrackType type)
GESTestClip *
ges_test_clip_new (void)
{
/* FIXME : Check for validity/existence of URI */
return g_object_new (GES_TYPE_TEST_CLIP, NULL);
GESTestClip *new_clip;
GESAsset *asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
new_clip = GES_TEST_CLIP (ges_asset_extract (asset, NULL));
g_object_unref (asset);
return new_clip;
}
/**
@ -389,8 +394,8 @@ ges_test_clip_new_for_nick (gchar * nick)
value = g_enum_get_value_by_nick (klass, nick);
if (value) {
ret = g_object_new (GES_TYPE_TEST_CLIP, "vpattern",
(gint) value->value, NULL);
ret = ges_test_clip_new ();
ges_test_clip_set_vpattern (ret, value->value);
}
g_type_class_unref (klass);

View file

@ -602,6 +602,11 @@ ges_text_overlay_clip_create_track_element (GESClip * clip, GESTrackType type)
GESTextOverlayClip *
ges_text_overlay_clip_new (void)
{
/* FIXME : Check for validity/existence of URI */
return g_object_new (GES_TYPE_OVERLAY_TEXT_CLIP, NULL);
GESTextOverlayClip *new_clip;
GESAsset *asset = ges_asset_request (GES_TYPE_OVERLAY_TEXT_CLIP, NULL, NULL);
new_clip = GES_OVERLAY_TEXT_CLIP (ges_asset_extract (asset, NULL));
g_object_unref (asset);
return new_clip;
}

View file

@ -655,6 +655,11 @@ ges_title_clip_create_track_element (GESClip * clip, GESTrackType type)
GESTitleClip *
ges_title_clip_new (void)
{
/* FIXME : Check for validity/existence of URI */
return g_object_new (GES_TYPE_TITLE_CLIP, NULL);
GESTitleClip *new_clip;
GESAsset *asset = ges_asset_request (GES_TYPE_TITLE_CLIP, NULL, NULL);
new_clip = GES_TITLE_CLIP (ges_asset_extract (asset, NULL));
g_object_unref (asset);
return new_clip;
}

View file

@ -342,7 +342,27 @@ _create_track_element (GESClip * clip, GESTrackType type)
GESTransitionClip *
ges_transition_clip_new (GESVideoStandardTransitionType vtype)
{
return g_object_new (GES_TYPE_TRANSITION_CLIP, "vtype", (gint) vtype, NULL);
GEnumValue *value;
GEnumClass *klass;
GESTransitionClip *ret = NULL;
klass =
G_ENUM_CLASS (g_type_class_ref (GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE));
if (!klass) {
GST_ERROR ("Could not find the StandarTransitionType enum class");
return NULL;
}
value = g_enum_get_value (klass, vtype);
if (!value) {
GST_ERROR ("Could not find enum value for %i", vtype);
return NULL;
}
ret = ges_transition_clip_new_for_nick (((gchar *) value->value_nick));
g_type_class_unref (klass);
return ret;
}
/**
@ -358,21 +378,15 @@ ges_transition_clip_new (GESVideoStandardTransitionType vtype)
GESTransitionClip *
ges_transition_clip_new_for_nick (gchar * nick)
{
GEnumValue *value;
GEnumClass *klass;
GESTransitionClip *ret = NULL;
GESAsset *asset = ges_asset_request (GES_TYPE_TRANSITION_CLIP, nick, NULL);
klass =
G_ENUM_CLASS (g_type_class_ref (GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE));
if (!klass)
return NULL;
if (asset != NULL) {
ret = GES_TRANSITION_CLIP (ges_asset_extract (asset, NULL));
value = g_enum_get_value_by_nick (klass, nick);
if (value) {
ret = g_object_new (GES_TYPE_TRANSITION_CLIP, "vtype",
(gint) value->value, NULL);
}
gst_object_unref (asset);
} else
GST_WARNING ("No asset found for nick: %s", nick);
g_type_class_unref (klass);
return ret;
}