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
This commit is contained in:
Thibault Saunier 2012-12-21 18:51:26 -03:00
parent 6dfae640a2
commit 27c36046fa
12 changed files with 286 additions and 84 deletions

View file

@ -101,6 +101,7 @@ platform as well as Windows. It is released under the GNU Library General Public
<chapter>
<title>Assets</title>
<xi:include href="xml/ges-asset-timeline-object.xml"/>
<xi:include href="xml/ges-asset-file-source.xml"/>
<xi:include href="xml/ges-asset-track-file-source.xml"/>
<xi:include href="xml/ges-project.xml"/>

View file

@ -925,7 +925,6 @@ GES_META_FORMATTER_VERSION
GES_META_FORMATTER_RANK
GES_META_DESCRIPTION
GES_META_TIMELINE_OBJECT_SUPPORTED_FORMATS
<SUBSECTION Standard>
GESMetaContainerInterface
@ -976,13 +975,28 @@ GES_ASSET_GET_CLASS
ges_asset_get_type
</SECTION>
<SECTION>
<FILE>ges-asset-timeline-object</FILE>
<TITLE>GESAssetTimelineObject</TITLE>
GESAssetTimelineObject
ges_asset_timeline_object_get_type
ges_asset_timeline_object_set_supported_formats
ges_asset_timeline_object_get_supported_formats
<SUBSECTION Standard>
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
</SECTION>
<SECTION>
<FILE>ges-asset-file-source</FILE>
<TITLE>GESAssetFileSource</TITLE>
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

View file

@ -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 \

View file

@ -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);
@ -385,28 +364,6 @@ ges_asset_filesource_get_duration (GESAssetFileSource * self)
return self->priv->duration;
}
/**
* 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

View file

@ -25,6 +25,7 @@
#include <gio/gio.h>
#include <ges/ges-types.h>
#include <ges/ges-asset.h>
#include <ges/ges-asset-timeline-object.h>
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;
/* <private> */
GESAssetFileSourcePrivate *priv;
@ -56,7 +57,7 @@ struct _GESAssetFileSource
struct _GESAssetFileSourceClass
{
GESAssetClass parent_class;
GESAssetTimelineObjectClass parent_class;
/* <private> */
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,

View file

@ -0,0 +1,187 @@
/**
* Gstreamer Editing Services
*
* Copyright (C) <2011> Thibault Saunier <thibault.saunier@collabora.com>
*
* 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;
}

View file

@ -0,0 +1,64 @@
/* GStreamer Editing Services
*
* Copyright (C) 2012 Thibault Saunier <thibault.saunier@collabora.com>
* Copyright (C) 2012 Volodymyr Rudyi <vladimir.rudoy@gmail.com>
*
* 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 <glib-object.h>
#include <ges/ges-types.h>
#include <ges/ges-asset.h>
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;
/* <private> */
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 */

View file

@ -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;

View file

@ -211,6 +211,8 @@ extractable_get_parameters_from_id (const gchar * id, guint * n_params)
g_value_init (&params[0].value, G_TYPE_STRING);
g_value_set_string (&params[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)));

View file

@ -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)
{
}
/**

View file

@ -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;

View file

@ -46,6 +46,7 @@
#include <ges/ges-timeline-file-source.h>
#include <ges/ges-screenshot.h>
#include <ges/ges-asset.h>
#include <ges/ges-asset-timeline-object.h>
#include <ges/ges-asset-file-source.h>
#include <ges/ges-project.h>
#include <ges/ges-extractable.h>