From 6386247cc49eff063443f6e296a0b40c800771cf Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 1 Dec 2011 00:18:30 -0300 Subject: [PATCH] ges: Move supported formats from filesource to timelineobject This is usefull by any subclass of GESTimelineObject + Bind it in python + Fix the keyfile formatter tests API: ges_timeline_object_set_supported_formats API: ges_timeline_object_get_supported_formats --- bindings/python/ges.defs | 15 +++++++++ docs/libs/ges-sections.txt | 2 ++ ges/ges-timeline-file-source.c | 29 +++-------------- ges/ges-timeline-object.c | 58 +++++++++++++++++++++++++++++++++ ges/ges-timeline-object.h | 8 +++++ tests/check/ges/save_and_load.c | 4 +++ 6 files changed, 91 insertions(+), 25 deletions(-) diff --git a/bindings/python/ges.defs b/bindings/python/ges.defs index c6c2701355..0e64af33a8 100644 --- a/bindings/python/ges.defs +++ b/bindings/python/ges.defs @@ -674,6 +674,15 @@ ) ) +(define-method set_supported_formats + (of-object "GESTimelineObject") + (c-name "ges_timeline_object_set_supported_formats") + (return-type "none") + (parameters + '("GESTrackType" "supportedformats") + ) +) + (define-method set_is_image (of-object "GESTimelineFileSource") (c-name "ges_timeline_filesource_set_is_image") @@ -707,6 +716,12 @@ (return-type "const-gchar*") ) +(define-method get_supported_formats + (of-object "GESTimelineObject") + (c-name "ges_timeline_object_get_supported_formats") + (return-type "GESTrackType") +) + (define-method get_supported_formats (of-object "GESTimelineFileSource") (c-name "ges_timeline_filesource_get_supported_formats") diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index 3b11320f92..f6e74b472e 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -301,6 +301,8 @@ ges_timeline_object_get_top_effects ges_timeline_object_get_top_effect_position ges_timeline_object_move_to_layer ges_timeline_object_set_top_effect_priority +ges_timeline_object_set_supported_formats +ges_timeline_object_get_supported_formats GES_TIMELINE_OBJECT_DURATION GES_TIMELINE_OBJECT_INPOINT diff --git a/ges/ges-timeline-file-source.c b/ges/ges-timeline-file-source.c index b7b28f1912..e78d791958 100644 --- a/ges/ges-timeline-file-source.c +++ b/ges/ges-timeline-file-source.c @@ -44,10 +44,6 @@ struct _GESTimelineFileSourcePrivate gboolean is_image; guint64 maxduration; - - /* The formats supported by this filesource - * TODO : Could maybe be moved to a parent class */ - GESTrackType supportedformats; }; enum @@ -56,7 +52,6 @@ enum PROP_URI, PROP_MAX_DURATION, PROP_MUTE, - PROP_SUPPORTED_FORMATS, PROP_IS_IMAGE, }; @@ -81,9 +76,6 @@ ges_timeline_filesource_get_property (GObject * object, guint property_id, case PROP_MAX_DURATION: g_value_set_uint64 (value, priv->maxduration); break; - case PROP_SUPPORTED_FORMATS: - g_value_set_flags (value, priv->supportedformats); - break; case PROP_IS_IMAGE: g_value_set_boolean (value, priv->is_image); break; @@ -109,10 +101,6 @@ ges_timeline_filesource_set_property (GObject * object, guint property_id, ges_timeline_filesource_set_max_duration (tfs, g_value_get_uint64 (value)); break; - case PROP_SUPPORTED_FORMATS: - ges_timeline_filesource_set_supported_formats (tfs, - g_value_get_flags (value)); - break; case PROP_IS_IMAGE: ges_timeline_filesource_set_is_image (tfs, g_value_get_boolean (value)); break; @@ -175,16 +163,6 @@ ges_timeline_filesource_class_init (GESTimelineFileSourceClass * klass) g_param_spec_boolean ("mute", "Mute", "Mute audio track", FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - /** - * GESTimelineFileSource:supported-formats: - * - * The formats supported by the filesource. - */ - g_object_class_install_property (object_class, PROP_SUPPORTED_FORMATS, - g_param_spec_flags ("supported-formats", "Supported formats", - "Formats supported by the file", GES_TYPE_TRACK_TYPE, - GES_TRACK_TYPE_UNKNOWN, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - /** * GESTimelineFileSource:is-image: * @@ -276,7 +254,8 @@ void ges_timeline_filesource_set_supported_formats (GESTimelineFileSource * self, GESTrackType supportedformats) { - self->priv->supportedformats = supportedformats; + ges_timeline_object_set_supported_formats (GES_TIMELINE_OBJECT (self), + supportedformats); } /** @@ -360,7 +339,7 @@ ges_timeline_filesource_get_uri (GESTimelineFileSource * self) GESTrackType ges_timeline_filesource_get_supported_formats (GESTimelineFileSource * self) { - return self->priv->supportedformats; + return ges_timeline_object_get_supported_formats (GES_TIMELINE_OBJECT (self)); } static GESTrackObject * @@ -370,7 +349,7 @@ ges_timeline_filesource_create_track_object (GESTimelineObject * obj, GESTimelineFileSourcePrivate *priv = GES_TIMELINE_FILE_SOURCE (obj)->priv; GESTrackObject *res; - if (!(priv->supportedformats & track->type)) { + if (!(ges_timeline_object_get_supported_formats (obj) & track->type)) { GST_DEBUG ("We don't support this track format"); return NULL; } diff --git a/ges/ges-timeline-object.c b/ges/ges-timeline-object.c index 27de6c64da..9ab8df32f0 100644 --- a/ges/ges-timeline-object.c +++ b/ges/ges-timeline-object.c @@ -124,6 +124,9 @@ struct _GESTimelineObjectPrivate GList *mappings; guint nb_effects; + + /* The formats supported by this TimelineObject */ + GESTrackType supportedformats; }; enum @@ -135,6 +138,7 @@ enum PROP_PRIORITY, PROP_HEIGHT, PROP_LAYER, + PROP_SUPPORTED_FORMATS, PROP_LAST }; @@ -165,6 +169,9 @@ ges_timeline_object_get_property (GObject * object, guint property_id, case PROP_LAYER: g_value_set_object (value, tobj->priv->layer); break; + case PROP_SUPPORTED_FORMATS: + g_value_set_flags (value, tobj->priv->supportedformats); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -192,6 +199,10 @@ ges_timeline_object_set_property (GObject * object, guint property_id, ges_timeline_object_set_priority_internal (tobj, g_value_get_uint (value)); break; + case PROP_SUPPORTED_FORMATS: + ges_timeline_object_set_supported_formats (tobj, + g_value_get_flags (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -268,6 +279,21 @@ ges_timeline_object_class_init (GESTimelineObjectClass * klass) g_object_class_install_property (object_class, PROP_HEIGHT, properties[PROP_HEIGHT]); + /** + * GESTimelineObject:supported-formats: + * + * The formats supported by the object. + * + * Since: 0.10.XX + */ + properties[PROP_SUPPORTED_FORMATS] = g_param_spec_flags ("supported-formats", + "Supported formats", "Formats supported by the file", + GES_TYPE_TRACK_TYPE, GES_TRACK_TYPE_UNKNOWN, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + + g_object_class_install_property (object_class, PROP_SUPPORTED_FORMATS, + properties[PROP_SUPPORTED_FORMATS]); + /** * GESTimelineObject:layer * @@ -1173,6 +1199,38 @@ update_height (GESTimelineObject * object) } } +/** + * ges_timeline_object_set_supported_formats: + * @self: the #GESTimelineObject to set supported formats on + * @supportedformats: the #GESTrackType defining formats supported by @self + * + * Sets the formats supported by the file. + * + * Since: 0.10.XX + */ +void +ges_timeline_object_set_supported_formats (GESTimelineObject * self, + GESTrackType supportedformats) +{ + self->priv->supportedformats = supportedformats; +} + +/** + * ges_timeline_object_get_supported_formats: + * @self: the #GESTimelineObject + * + * Get the formats supported by @self. + * + * Returns: The formats supported by @self. + * + * Since: 0.10.XX + */ +GESTrackType +ges_timeline_object_get_supported_formats (GESTimelineObject * self) +{ + return self->priv->supportedformats; +} + /* * PROPERTY NOTIFICATIONS FROM TRACK OBJECTS */ diff --git a/ges/ges-timeline-object.h b/ges/ges-timeline-object.h index 2f02017c2a..3213ff70f9 100644 --- a/ges/ges-timeline-object.h +++ b/ges/ges-timeline-object.h @@ -24,6 +24,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -282,6 +283,13 @@ ges_timeline_object_set_top_effect_priority (GESTimelineObject *object, GESTrackEffect *effect, guint newpriority); +GESTrackType +ges_timeline_object_get_supported_formats (GESTimelineObject * self); + +void +ges_timeline_object_set_supported_formats (GESTimelineObject * self, + GESTrackType supportedformats); + G_END_DECLS #endif /* _GES_TIMELINE_OBJECT */ diff --git a/tests/check/ges/save_and_load.c b/tests/check/ges/save_and_load.c index b17642924f..4cd5f99f1e 100644 --- a/tests/check/ges/save_and_load.c +++ b/tests/check/ges/save_and_load.c @@ -119,6 +119,7 @@ GST_START_TEST (test_keyfile_save) KEY ("Object0", "in-point", "0"); KEY ("Object0", "duration", "2000000000"); KEY ("Object0", "priority", "2"); + KEY ("Object0", "supported-formats", "GES_TRACK_TYPE_UNKNOWN"); KEY ("Object0", "mute", "false"); KEY ("Object0", "vpattern", "100% Black"); KEY ("Object0", "freq", "440"); @@ -138,6 +139,7 @@ GST_START_TEST (test_keyfile_save) KEY ("Object1", "in-point", "0"); KEY ("Object1", "duration", "500000000"); KEY ("Object1", "priority", "1"); + KEY ("Object1", "supported-formats", "GES_TRACK_TYPE_UNKNOWN"); KEY ("Object1", "vtype", "A bar moves from left to right"); COMPARE; @@ -152,6 +154,7 @@ GST_START_TEST (test_keyfile_save) KEY ("Object2", "in-point", "0"); KEY ("Object2", "duration", "2000000000"); KEY ("Object2", "priority", "3"); + KEY ("Object2", "supported-formats", "GES_TRACK_TYPE_UNKNOWN"); KEY ("Object2", "mute", "false"); KEY ("Object2", "vpattern", "100% Black"); KEY ("Object2", "freq", "440"); @@ -182,6 +185,7 @@ GST_START_TEST (test_keyfile_save) KEY ("Object3", "in-point", "0"); KEY ("Object3", "duration", "1000000000"); KEY ("Object3", "priority", "0"); + KEY ("Object3", "supported-formats", "GES_TRACK_TYPE_UNKNOWN"); KEY ("Object3", "mute", "false"); KEY ("Object3", "text", "\"the\\\\ quick\\\\ brown\\\\ fox\""); KEY ("Object3", "font-desc", "\"Serif\\\\ 36\"");