timeline: Implement the GESExtractable interface

This commit is contained in:
Thibault Saunier 2012-09-23 02:11:46 +02:00
parent 543ab28228
commit dbab748bfc

View file

@ -37,6 +37,7 @@
*/
#include "ges-internal.h"
#include "ges-project.h"
#include "ges-timeline.h"
#include "ges-track.h"
#include "ges-timeline-layer.h"
@ -45,8 +46,12 @@
typedef struct _MoveContext MoveContext;
static inline void init_movecontext (MoveContext * mv_ctx);
static void ges_extractable_interface_init (GESExtractableInterface * iface);
G_DEFINE_TYPE_WITH_CODE (GESTimeline, ges_timeline, GST_TYPE_BIN,
G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
ges_extractable_interface_init));
G_DEFINE_TYPE (GESTimeline, ges_timeline, GST_TYPE_BIN);
GST_DEBUG_CATEGORY_STATIC (ges_timeline_debug);
#undef GST_CAT_DEFAULT
@ -160,7 +165,6 @@ enum
TRACK_REMOVED,
LAYER_ADDED,
LAYER_REMOVED,
DISCOVERY_ERROR,
SNAPING_STARTED,
SNAPING_ENDED,
LAST_SIGNAL
@ -172,6 +176,43 @@ static guint ges_timeline_signals[LAST_SIGNAL] = { 0 };
static gint custom_find_track (TrackPrivate * tr_priv, GESTrack * track);
static guint nb_assets = 0;
/* GESExtractable implementation */
static gchar *
extractable_check_id (GType type, const gchar * id)
{
gchar *res;
if (id == NULL)
res = g_strdup_printf ("%s-%i", "project", nb_assets);
else
res = g_strdup (id);
nb_assets++;
return res;
}
static gchar *
extractable_get_id (GESExtractable * self)
{
GESAsset *asset;
if (!(asset = ges_extractable_get_asset (self)))
return NULL;
return g_strdup (ges_asset_get_id (asset));
}
static void
ges_extractable_interface_init (GESExtractableInterface * iface)
{
iface->asset_type = GES_TYPE_PROJECT;
iface->check_id = (GESExtractableCheckId) extractable_check_id;
iface->get_id = extractable_get_id;
}
/* Internal methods */
static gboolean
ges_timeline_enable_update_internal (GESTimeline * timeline, gboolean enabled)
@ -279,6 +320,9 @@ ges_timeline_class_init (GESTimelineClass * klass)
g_type_class_add_private (klass, sizeof (GESTimelinePrivate));
GST_DEBUG_CATEGORY_INIT (ges_timeline_debug, "gestimeline",
GST_DEBUG_FG_YELLOW, "ges timeline");
parent_class = g_type_class_peek_parent (klass);
object_class->get_property = ges_timeline_get_property;
@ -382,19 +426,6 @@ ges_timeline_class_init (GESTimelineClass * klass)
NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
GES_TYPE_TIMELINE_LAYER);
/**
* GESTimeline::discovery-error:
* @timeline: the #GESTimeline
* @formatter: the #GESFormatter
* @source: The #GESTimelineFileSource that could not be discovered properly
* @error: (type GLib.Error): #GError, which will be non-NULL if an error
* occurred during discovery
*/
ges_timeline_signals[DISCOVERY_ERROR] =
g_signal_new ("discovery-error", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
G_TYPE_NONE, 2, GES_TYPE_TIMELINE_FILE_SOURCE, G_TYPE_ERROR);
/**
* GESTimeline::track-objects-snapping:
* @timeline: the #GESTimeline
@ -435,9 +466,6 @@ ges_timeline_init (GESTimeline * self)
{
GESTimelinePrivate *priv = self->priv;
GST_DEBUG_CATEGORY_INIT (ges_timeline_debug, "gestimeline",
GST_DEBUG_FG_YELLOW, "ges timeline");
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_TIMELINE, GESTimelinePrivate);