From 27c36046fa80d4b4d918e783bc41d39f9f412ed4 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 21 Dec 2012 18:51:26 -0300 Subject: [PATCH] Implement a GESAssetTimelineObject class + Make GESAssetFileSource a subclass of it + Remove ges_asset_filesource_get_supported_type as it is now in GESAssetTimelineObject + Remove the GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS as it is useless now --- docs/libs/ges-docs.sgml | 1 + docs/libs/ges-sections.txt | 18 +++- ges/Makefile.am | 2 + ges/ges-asset-file-source.c | 49 +---------- ges/ges-asset-file-source.h | 6 +- ges/ges-asset-timeline-object.c | 187 ++++++++++++++++++++++++++++++++++++++++ ges/ges-asset-timeline-object.h | 64 ++++++++++++++ ges/ges-meta-container.h | 7 -- ges/ges-timeline-file-source.c | 6 +- ges/ges-timeline-object.c | 26 +----- ges/ges-types.h | 3 + ges/ges.h | 1 + 12 files changed, 286 insertions(+), 84 deletions(-) create mode 100644 ges/ges-asset-timeline-object.c create mode 100644 ges/ges-asset-timeline-object.h diff --git a/docs/libs/ges-docs.sgml b/docs/libs/ges-docs.sgml index 537ee82..ef94a44 100644 --- a/docs/libs/ges-docs.sgml +++ b/docs/libs/ges-docs.sgml @@ -101,6 +101,7 @@ platform as well as Windows. It is released under the GNU Library General Public Assets + diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index 7ee6fe6..6d9ae09 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -925,7 +925,6 @@ GES_META_FORMATTER_VERSION GES_META_FORMATTER_RANK GES_META_DESCRIPTION -GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS GESMetaContainerInterface @@ -977,12 +976,27 @@ ges_asset_get_type
+ges-asset-timeline-object +GESAssetTimelineObject +GESAssetTimelineObject +ges_asset_timeline_object_get_type +ges_asset_timeline_object_set_supported_formats +ges_asset_timeline_object_get_supported_formats + +GESAssetTimelineObjectPrivate +GES_ASSET_TIMELINE_OBJECT +GES_ASSET_TIMELINE_OBJECT_CLASS +GES_IS_ASSET_TIMELINE_OBJECT +GES_IS_ASSET_TIMELINE_OBJECT_CLASS +GES_ASSET_TIMELINE_OBJECT_GET_CLASS +
+ +
ges-asset-file-source GESAssetFileSource GESAssetFileSource ges_asset_filesource_get_type ges_asset_filesource_get_duration -ges_asset_filesource_get_supported_types ges_asset_filesource_is_image ges_asset_filesource_get_info ges_asset_filesource_new diff --git a/ges/Makefile.am b/ges/Makefile.am index 6ad6ddb..0aca602 100644 --- a/ges/Makefile.am +++ b/ges/Makefile.am @@ -49,6 +49,7 @@ libges_@GST_API_VERSION@_la_SOURCES = \ ges-pitivi-formatter.c \ ges-asset.c \ ges-asset-file-source.c \ + ges-asset-timeline-object.c \ ges-extractable.c \ ges-project.c \ ges-base-xml-formatter.c \ @@ -99,6 +100,7 @@ libges_@GST_API_VERSION@include_HEADERS = \ ges-pitivi-formatter.h \ ges-asset.h \ ges-asset-file-source.h \ + ges-asset-timeline-object.h \ ges-extractable.h \ ges-project.h \ ges-base-xml-formatter.h \ diff --git a/ges/ges-asset-file-source.c b/ges/ges-asset-file-source.c index 1185be0..fe86102 100644 --- a/ges/ges-asset-file-source.c +++ b/ges/ges-asset-file-source.c @@ -40,7 +40,7 @@ initable_iface_init (GInitableIface * initable_iface) } G_DEFINE_TYPE_WITH_CODE (GESAssetFileSource, ges_asset_filesource, - GES_TYPE_ASSET, + GES_TYPE_ASSET_TIMELINE_OBJECT, G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, initable_iface_init)); /* TODO: We should monitor files here, and add some way of reporting changes @@ -124,26 +124,6 @@ _start_loading (GESAsset * asset, GError ** error) return GES_ASSET_LOADING_ERROR; } - -static GESExtractable * -ges_asset_filesource_extract (GESAsset * self, GError ** error) -{ - const gchar *uri = ges_asset_get_id (self); - GESTrackType supportedformats; - - GESTimelineFileSource *tfs = ges_timeline_filesource_new ((gchar *) uri); - - GST_DEBUG_OBJECT (self, "Extracting filesource with uri %s", uri); - - ges_meta_container_get_uint (GES_META_CONTAINER (self), - GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS, &supportedformats); - - ges_timeline_object_set_supported_formats (GES_TIMELINE_OBJECT (tfs), - supportedformats); - - return GES_EXTRACTABLE (tfs); -} - static gboolean _request_id_update (GESAsset * self, gchar ** proposed_new_id, GError * error) { @@ -204,7 +184,6 @@ ges_asset_filesource_class_init (GESAssetFileSourceClass * klass) GES_ASSET_CLASS (klass)->request_id_update = _request_id_update; GES_ASSET_CLASS (klass)->inform_proxy = _asset_proxied; - GES_ASSET_CLASS (klass)->extract = ges_asset_filesource_extract; /** * GESAssetFileSource:duration: @@ -310,8 +289,8 @@ ges_asset_filesource_set_info (GESAssetFileSource * self, gst_discoverer_stream_info_get_stream_id (sinf)); _create_track_file_source_asset (self, sinf, type); } - ges_meta_container_set_uint (GES_META_CONTAINER (self), - GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS, supportedformats); + ges_asset_timeline_object_set_supported_formats (GES_ASSET_TIMELINE_OBJECT + (self), supportedformats); if (stream_list) gst_discoverer_stream_info_list_free (stream_list); @@ -386,28 +365,6 @@ ges_asset_filesource_get_duration (GESAssetFileSource * self) } /** - * ges_asset_filesource_get_supported_types: - * @self: a #GESAssetFileSource - * - * Gets track types the file as - * - * Returns: The track types on which @self will create TrackObject when added to - * a layer - */ -GESTrackType -ges_asset_filesource_get_supported_types (GESAssetFileSource * self) -{ - GESTrackType supportedformats; - - g_return_val_if_fail (GES_IS_ASSET_FILESOURCE (self), GES_TRACK_TYPE_UNKNOWN); - - ges_meta_container_get_uint (GES_META_CONTAINER (self), - GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS, &supportedformats); - - return supportedformats; -} - -/** * ges_asset_filesource_is_image: * @self: a #indent: Standard input:311: Error:Unexpected end of file GESAssetFileSource diff --git a/ges/ges-asset-file-source.h b/ges/ges-asset-file-source.h index 3f6d04f..756106b 100644 --- a/ges/ges-asset-file-source.h +++ b/ges/ges-asset-file-source.h @@ -25,6 +25,7 @@ #include #include #include +#include G_BEGIN_DECLS #define GES_TYPE_ASSET_FILESOURCE ges_asset_filesource_get_type() @@ -45,7 +46,7 @@ GType ges_asset_filesource_get_type (void); struct _GESAssetFileSource { - GESAsset parent; + GESAssetTimelineObject parent; /* */ GESAssetFileSourcePrivate *priv; @@ -56,7 +57,7 @@ struct _GESAssetFileSource struct _GESAssetFileSourceClass { - GESAssetClass parent_class; + GESAssetTimelineObjectClass parent_class; /* */ GstDiscoverer *discoverer; @@ -66,7 +67,6 @@ struct _GESAssetFileSourceClass GstDiscovererInfo *ges_asset_filesource_get_info (const GESAssetFileSource * self); GstClockTime ges_asset_filesource_get_duration (GESAssetFileSource *self); -GESTrackType ges_asset_filesource_get_supported_types (GESAssetFileSource *self); gboolean ges_asset_filesource_is_image (GESAssetFileSource *self); void ges_asset_filesource_new (const gchar *uri, GCancellable *cancellable, diff --git a/ges/ges-asset-timeline-object.c b/ges/ges-asset-timeline-object.c new file mode 100644 index 0000000..635766d --- /dev/null +++ b/ges/ges-asset-timeline-object.c @@ -0,0 +1,187 @@ +/** + * Gstreamer Editing Services + * + * Copyright (C) <2011> Thibault Saunier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +/** + * SECTION: ges-asset-timeline-object + * @short_description: A #GESAsset subclass specialized in #GESTimelineObject extraction + * + * The #GESAssetFileSource is a special #GESAsset specilized in #GESTimelineObject. + * it is mostly used to get information about the #GESTrackType-s the objects extracted + * from it can potentialy create #GESTrackObject for. + */ + +#include "ges-asset-timeline-object.h" + +G_DEFINE_TYPE (GESAssetTimelineObject, ges_asset_timeline_object, + GES_TYPE_ASSET); +#define GES_ASSET_TIMELINE_OBJECT_GET_PRIVATE(o)\ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), GES_TYPE_ASSET_TIMELINE_OBJECT, \ + GESAssetTimelineObjectPrivate)) + +#define parent_class ges_asset_timeline_object_parent_class + +struct _GESAssetTimelineObjectPrivate +{ + GESTrackType supportedformats; +}; + + +enum +{ + PROP_0, + PROP_SUPPORTED_FORMATS, + PROP_LAST +}; + +static GParamSpec *properties[PROP_LAST]; + +/*********************************************** + * * + * GObject vmetods implemenation * + * * + ***********************************************/ +static void +_dispose (GObject * object) +{ +} + +static void +_finalize (GObject * object) +{ +} + +static void +_get_property (GObject * object, guint property_id, + GValue * value, GParamSpec * pspec) +{ + GESAssetTimelineObjectPrivate *priv = + GES_ASSET_TIMELINE_OBJECT (object)->priv; + switch (property_id) { + case PROP_SUPPORTED_FORMATS: + g_value_set_flags (value, priv->supportedformats); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +_set_property (GObject * object, guint property_id, + const GValue * value, GParamSpec * pspec) +{ + GESAssetTimelineObjectPrivate *priv = + GES_ASSET_TIMELINE_OBJECT (object)->priv; + + switch (property_id) { + case PROP_SUPPORTED_FORMATS: + priv->supportedformats = g_value_get_flags (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +ges_asset_timeline_object_init (GESAssetTimelineObject * self) +{ + self->priv = GES_ASSET_TIMELINE_OBJECT_GET_PRIVATE (self); +} + +static void +_constructed (GObject * object) +{ + GType extractable_type = ges_asset_get_extractable_type (GES_ASSET (object)); + GObjectClass *class = g_type_class_ref (extractable_type); + GParamSpecFlags *pspec; + + pspec = G_PARAM_SPEC_FLAGS (g_object_class_find_property (class, + "supported-formats")); + + GES_ASSET_TIMELINE_OBJECT (object)->priv->supportedformats = + pspec->default_value; + g_type_class_unref (class); + + G_OBJECT_CLASS (parent_class)->constructed (object); +} + +static void +ges_asset_timeline_object_class_init (GESAssetTimelineObjectClass * self_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (self_class); + + g_type_class_add_private (self_class, sizeof (GESAssetTimelineObjectPrivate)); + object_class->constructed = _constructed; + object_class->dispose = _dispose; + object_class->finalize = _finalize; + object_class->get_property = _get_property; + object_class->set_property = _set_property; + + /** + * GESAssetTimelineObject:supported-formats: + * + * The formats supported by the asset. + */ + properties[PROP_SUPPORTED_FORMATS] = g_param_spec_flags ("supported-formats", + "Supported formats", "Formats supported by the file", + GES_TYPE_TRACK_TYPE, GES_TRACK_TYPE_AUDIO | GES_TRACK_TYPE_VIDEO, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + + g_object_class_install_property (object_class, PROP_SUPPORTED_FORMATS, + properties[PROP_SUPPORTED_FORMATS]); +} + +/*********************************************** + * * + * Public methods * + * * + ***********************************************/ +/** + * ges_asset_timeline_object_set_supported_formats: + * @self: a #GESAssetTimelineObject + * @supportedformats: The track types supported by the GESAssetTimelineObject + * + * Sets track types for which objects extracted from @self can create #GESTrackObject + */ +void +ges_asset_timeline_object_set_supported_formats (GESAssetTimelineObject * self, + GESTrackType supportedformats) +{ + g_return_if_fail (GES_IS_ASSET_TIMELINE_OBJECT (self)); + + self->priv->supportedformats = supportedformats; +} + +/** + * ges_asset_timeline_object_get_supported_formats: + * @self: a #GESAssetTimelineObject + * + * Gets track types for which objects extracted from @self can create #GESTrackObject + * + * Returns: The track types on which @self will create TrackObject when added to + * a layer + */ +GESTrackType +ges_asset_timeline_object_get_supported_formats (GESAssetTimelineObject * self) +{ + g_return_val_if_fail (GES_IS_ASSET_TIMELINE_OBJECT (self), + GES_TRACK_TYPE_UNKNOWN); + + return self->priv->supportedformats; +} diff --git a/ges/ges-asset-timeline-object.h b/ges/ges-asset-timeline-object.h new file mode 100644 index 0000000..78e21b8 --- /dev/null +++ b/ges/ges-asset-timeline-object.h @@ -0,0 +1,64 @@ +/* GStreamer Editing Services + * + * Copyright (C) 2012 Thibault Saunier + * Copyright (C) 2012 Volodymyr Rudyi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#ifndef GES_ASSET_TIMELINE_OBJECT_H +#define GES_ASSET_TIMELINE_OBJECT_H + +#include +#include +#include + +G_BEGIN_DECLS + +#define GES_TYPE_ASSET_TIMELINE_OBJECT (ges_asset_timeline_object_get_type ()) +#define GES_ASSET_TIMELINE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_ASSET_TIMELINE_OBJECT, GESAssetTimelineObject)) +#define GES_ASSET_TIMELINE_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_ASSET_TIMELINE_OBJECT, GESAssetTimelineObjectClass)) +#define GES_IS_ASSET_TIMELINE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_ASSET_TIMELINE_OBJECT)) +#define GES_IS_ASSET_TIMELINE_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_ASSET_TIMELINE_OBJECT)) +#define GES_ASSET_TIMELINE_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_ASSET_TIMELINE_OBJECT, GESAssetTimelineObjectClass)) + +typedef struct _GESAssetTimelineObjectPrivate GESAssetTimelineObjectPrivate; + +struct _GESAssetTimelineObject +{ + GESAsset parent; + + /* */ + GESAssetTimelineObjectPrivate *priv; + + gpointer _ges_reserved[GES_PADDING]; +}; + +struct _GESAssetTimelineObjectClass +{ + GESAssetClass parent; + + gpointer _ges_reserved[GES_PADDING]; +}; + +GType ges_asset_timeline_object_get_type (void); +void ges_asset_timeline_object_set_supported_formats (GESAssetTimelineObject *self, + GESTrackType supportedformats); +GESTrackType ges_asset_timeline_object_get_supported_formats (GESAssetTimelineObject *self); + +G_END_DECLS +#endif /* _GES_ASSET_TIMELINE_OBJECT_H */ diff --git a/ges/ges-meta-container.h b/ges/ges-meta-container.h index 4c26821..d900fc6 100644 --- a/ges/ges-meta-container.h +++ b/ges/ges-meta-container.h @@ -84,13 +84,6 @@ G_BEGIN_DECLS */ #define GES_META_FORMATTER_RANK "rank" -/** - * GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS: - * - * The GESTrackType on which a GESTimelineObject can create GESTrackObjects - */ -#define GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS "supported-formats" - typedef struct _GESMetaContainer GESMetaContainer; typedef struct _GESMetaContainerInterface GESMetaContainerInterface; diff --git a/ges/ges-timeline-file-source.c b/ges/ges-timeline-file-source.c index afc990a..156e51e 100644 --- a/ges/ges-timeline-file-source.c +++ b/ges/ges-timeline-file-source.c @@ -211,6 +211,8 @@ extractable_get_parameters_from_id (const gchar * id, guint * n_params) g_value_init (¶ms[0].value, G_TYPE_STRING); g_value_set_string (¶ms[0].value, id); + *n_params = 1; + return params; } @@ -238,8 +240,10 @@ extractable_set_asset (GESExtractable * self, GESAsset * asset) if (ges_timeline_object_get_supported_formats (tlobj) == GES_TRACK_TYPE_UNKNOWN) { + ges_timeline_object_set_supported_formats (tlobj, - ges_asset_filesource_get_supported_types (filesource_asset)); + ges_asset_timeline_object_get_supported_formats + (GES_ASSET_TIMELINE_OBJECT (filesource_asset))); } ges_timeline_filesource_set_uri (tfs, g_strdup (ges_asset_get_id (asset))); diff --git a/ges/ges-timeline-object.c b/ges/ges-timeline-object.c index b910dc8..5a1d3da 100644 --- a/ges/ges-timeline-object.c +++ b/ges/ges-timeline-object.c @@ -80,14 +80,11 @@ static GESTimelineObject *ges_timeline_object_copy (GESTimelineObject * object, gboolean * deep); static void ges_extractable_interface_init (GESExtractableInterface * iface); -static void ges_meta_container_interface_init (GESMetaContainerInterface * - iface); G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GESTimelineObject, ges_timeline_object, G_TYPE_INITIALLY_UNOWNED, G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE, ges_extractable_interface_init) - G_IMPLEMENT_INTERFACE (GES_TYPE_META_CONTAINER, - ges_meta_container_interface_init)); + G_IMPLEMENT_INTERFACE (GES_TYPE_META_CONTAINER, NULL)); /* Mapping of relationship between a TimelineObject and the TrackObjects * it controls @@ -425,31 +422,10 @@ extractable_set_asset (GESExtractable * extractable, GESAsset * asset) GES_TIMELINE_OBJECT (extractable)->asset = asset; } -static gboolean -_register_metas (GESExtractableInterface * iface, GObjectClass * class, - GESAsset * asset) -{ - GESMetaContainer *container = GES_META_CONTAINER (asset); - GParamSpecEnum *pspec = - (GParamSpecEnum *) g_object_class_find_property (class, - "supported-formats"); - - ges_meta_container_set_uint (container, - GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS, pspec->default_value); - - return TRUE; -} - static void ges_extractable_interface_init (GESExtractableInterface * iface) { iface->set_asset = extractable_set_asset; - iface->register_metas = _register_metas; -} - -static void -ges_meta_container_interface_init (GESMetaContainerInterface * iface) -{ } /** diff --git a/ges/ges-types.h b/ges/ges-types.h index 98cb1da..e27b203 100644 --- a/ges/ges-types.h +++ b/ges/ges-types.h @@ -140,6 +140,9 @@ typedef struct _GESPitiviFormatterClass GESPitiviFormatterClass; typedef struct _GESAsset GESAsset; typedef struct _GESAssetClass GESAssetClass; +typedef struct _GESAssetTimelineObject GESAssetTimelineObject; +typedef struct _GESAssetTimelineObjectClass GESAssetTimelineObjectClass; + typedef struct _GESAssetFileSource GESAssetFileSource; typedef struct _GESAssetFileSourceClass GESAssetFileSourceClass; diff --git a/ges/ges.h b/ges/ges.h index 82c48f4..d6861f1 100644 --- a/ges/ges.h +++ b/ges/ges.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include -- 2.7.4