MORE HACKING

This commit is contained in:
Edward Hervey 2009-08-06 11:23:01 +02:00
parent d1b2ae1733
commit 534f9594c3
11 changed files with 469 additions and 52 deletions

143
docs/scenarios Normal file
View file

@ -0,0 +1,143 @@
SCENARIOS
* Adding a TimelineObject to a TimelineLayer
--------------------------------------------
* Create a Timeline
* Create a Track
* Add the track to the Timeline (==> ges_timeline_add_track (track);)
The Timeline adds the Track to itself (i.e. gst_bin_add())
'track-added' is emitted
* Create a TimelineLayer
* Add the TimelineLayer to the Timeline (ges_timeline_add_layer (layer);)
The Timeline takes a reference on the layer and stores it
The Timeline tells the TimelineLayer that it now belongs to the given Timeline (weak reference)
==> ges_timeline_layer_set_timeline ();
'layer-added' is emitted
* Create a TimelineObject
* Add the TimelineObject to the TimelineLayer (ges_timeline_layer_add_object (object);)
The TimelineLayer takes a reference on the TimelineObject and stores it
The timelineLayer tells the TimelineObject that it now belongs to the given layer (weak reference)
==> ges_timeline_object_set_layer ();
'object-added' is emitted by TimelineLayer
The Timeline requests a new TrackObject from the new TimelineObject for each Track
==> ges_timeline_object_create_track_object (track)
The TimelineObject calls the 'create_track_object' virtual method with the given track
Example implementation
Create a GESTrackSource
(GESTimelineObject is a constructor property of track objects)
A GESTrackObject CAN NOT EXIST WITHOUT A GESTimelineObject !
The Timeline adds the newly created TrackObject to the Track
==> ges_track_add_object (track, trackobject);
Set the track on the TrackObject
==> ges_track_object_set_track (track)
The GESTrackObject can create the GnlObject
Methods
-------
[ GESTimeline ]
* gboolean
ges_timeline_add_track (GESTimeline * timeline, GESTrack * track);
* The Timeline adds the track to itself (gst_bin_add ()) # reference implicitely taken
* The Timeline adds the track to its list of tracked tracks
* The Timeline sets the Timeline on the track
=> ges_track_set_timeline (GESTrack * track, GESTimeline * timeline);
Just sets the timeline field of the track.
* emits 'track-added'
* gboolean
ges_timeline_add_layer (GESTimeline * timeline, GESTimelineLayer * layer);
* The Timeline takes a reference on the layer and stores it
* The Timeline tells the Layer that it now belongs to the given Timeline
=> ges_timeline_layer_set_timeline (GESTimelineLayer * layer, GESTimeline * timeline);
Just sets the timeline field of the layer.
* Connect to the layer's 'object-added' signal
* emits 'layer-added'
* GESTimeline's
callback for GESTimelineLayer::object-added (GESTimelineLayer * layer, GESTimelineObject * object);
* For each GESTrack in the Timeline:
* The timeline requests a new TrackObject for the new TimelineObject for each Track
trackobj = ges_timeline_object_create_track_object (timelineobj, track);
* The timeline adds the newly created TrackObject to the track
ges_track_add_object (track, trackobj);
[ GESTimelineLayer ]
* gboolean
ges_timeline_layer_add_object (GESTimelineLayer * layer, GESTimelineObject * object);
* The TimelineLayer takes a reference on the TimelineObject and stores it
* The TimelineLayer tells the TmielineObject it now belongs to the given Layer
=> ges_timeline_object_set_layer (GESTimelineObject * object, GESTimelineLayer * layer);
Just sets the layer field of the timeline object.
* emits 'object-added'
[ GESTimelineObject ]
* GESTrackObject *
ges_timeline_object_create_track_object (GESTimelineObject * object, GESTrack * track);
* The TimelineObject calls the 'create_track_object' virtual method
* The TimelineObject sets the TimelineObject on the new TrackObject
=> ges_track_object_set_timeline_object (track_object, timeline_object);
Just sets the timeline-object field of the TrackObject
* Return the newly created GESTrackObject
* Virtual-method for GESTimelineObject::create_track_object (GESTimelineObject * object, GESTrack * track);
* Create a track object of the proper type
Ex (for a source) :
return ges_track_source_new();
* gboolean
ges_timeline_object_fill_track_object (GESTimelineObject *tlo, GESTrackObject *tro, GstElement *gnlobj);
* up to the implementation :)
[ GESTrack ]
* gboolean
ges_track_add_object (GESTrack * track, GESTrackObject * object);
* Set the track on the track_object
ges_track_object_set_track (object, track);
* Add the GnlObject of the TrackObject to the composition
gst_bin_add (track->composition, object->gnlobject);
[ GESTrackObject ]
* gboolean
ges_track_object_set_track (GESTrackObject * object, GESTrack * track);
* Set the track field of the TrackObject
* if no GnlObject is available yet:
* Call the 'create_gnl_object' virtual method
* Virtual-method for GESTrackObject::create_gnl_object
* Create a GnlObject of the proper type
Ex : gnlobject = gst_element_factory_make("gnlsource", NULL);
* Ask the TimelineObject to fill in the GnlObject
=> ges_timeline_object_fill_track_object (GESTimelineObject * tlo, GESTrackObject * tro, GstElement * gnlobj);

View file

@ -3,7 +3,8 @@ lib_LTLIBRARIES = libges-@GST_MAJORMINOR@.la
CLEANFILES = $(BUILT_SOURCES)
libges_@GST_MAJORMINOR@_la_SOURCES = \
libges_@GST_MAJORMINOR@_la_SOURCES = \
ges.c \
ges-simple-timeline-layer.c \
ges-timeline.c \
ges-timeline-layer.c \
@ -14,8 +15,9 @@ libges_@GST_MAJORMINOR@_la_SOURCES = \
ges-track.c \
ges-track-object.c
libges_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/ges/
libges_@GST_MAJORMINOR@include_HEADERS = \
libges_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/ges/
libges_@GST_MAJORMINOR@include_HEADERS = \
ges.h \
ges-simple-timeline-layer.h \
ges-timeline.h \
ges-timeline-layer.h \

View file

@ -57,6 +57,11 @@ GType ges_simple_timeline_layer_get_type (void);
GESSimpleTimelineLayer* ges_simple_timeline_layer_new (void);
gboolean
ges_simple_timeline_layer_add_object (GESSimpleTimelineLayer *layer, GESTimelineObject *object, gint position);
ges_simple_timeline_layer_remove_object (GESSimpleTimelineLayer *layer, GESTimelineObject *object);
ges_simple_timeline_layer_move_object (GESSimpleTimelineLayer *layer, GESTimelineObject, gint newposition);
G_END_DECLS
#endif /* _GES_SIMPLE_TIMELINE_LAYER */

View file

@ -93,3 +93,27 @@ ges_timeline_object_new (void)
{
return g_object_new (GES_TYPE_TIMELINE_OBJECT, NULL);
}
/**
* ges_timeline_object_create_track_object:
* @object: The origin #GESTimelineObject
* @track: The #GESTrack to create a #GESTrackObject for.
*
* Creates a #GESTrackObject for the provided @track.
*
* Returns: A #GESTrackObject. Returns NULL if the #GESTrackObject could not
* be created.
*/
GESTrackObject *
ges_timeline_object_create_track_object (GESTimelineObject * object,
GESTrack * track)
{
/* FIXME : IMPLEMENT */
/* implemented by subclasses */
/* Keep track of the created TrackObject(s) */
return NULL;
}

View file

@ -46,6 +46,14 @@ typedef struct _GESTimelineObjectClass GESTimelineObjectClass;
struct _GESTimelineObject {
GObject parent;
/* start, inpoint, duration and fullduration are in nanoseconds */
guint64 start; /* position (in time) of the object in the layer */
guint64 inpoint; /* in-point */
guint64 duration; /* duration of the object used in the layer */
guint32 priority; /* priority of the object in the layer (0:top priority) */
guint64 fullduration; /* Full usable duration of the object (-1: no duration) */
};
struct _GESTimelineObjectClass {
@ -56,6 +64,9 @@ GType ges_timeline_object_get_type (void);
GESTimelineObject* ges_timeline_object_new (void);
GESTrackObject * ges_timeline_object_create_track_object (GESTimelineObject * object,
GESTrack * track);
G_END_DECLS
#endif /* _GES_TIMELINE_OBJECT */

View file

@ -22,8 +22,8 @@
#include <glib-object.h>
#include <gst/gst.h>
#include <ges-timeline-layer.h>
#include <ges-track.h>
#include <ges/ges-timeline-layer.h>
#include <ges/ges-track.h>
G_BEGIN_DECLS

View file

@ -19,9 +19,33 @@
#include "ges-track-object.h"
G_DEFINE_TYPE (GESTrackObject, ges_track_object, G_TYPE_OBJECT)
static GQuark _start_quark;
static GQuark _inpoint_quark;
static GQuark _duration_quark;
static GQuark _priority_quark;
#define _do_init \
{ \
gint i; \
\
_start_quark = g_quark_from_static_string ("start"); \
_inpoint_quark = g_quark_from_static_string ("inpoint"); \
_duration_quark = g_quark_from_static_string ("duration"); \
_priority_quark = g_quark_from_static_string ("priority"); \
}
G_DEFINE_TYPE_WITH_CODE (GESTrackObject, ges_track_object, G_TYPE_OBJECT,
_do_init)
#define GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GES_TYPE_TRACK_OBJECT, GESTrackObjectPrivate))
enum
{
PROP_0,
PROP_START,
PROP_INPOINT,
PROP_DURATION,
PROP_PRIORITY,
}
typedef struct _GESTrackObjectPrivate GESTrackObjectPrivate;
struct _GESTrackObjectPrivate
@ -31,56 +55,163 @@ G_DEFINE_TYPE (GESTrackObject, ges_track_object, G_TYPE_OBJECT)
static void
ges_track_object_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
GValue * value, GParamSpec * pspec)
{
GESTrackObject *tobj = GES_TRACK_OBJECT (object);
static void
ges_track_object_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
switch (property_id) {
case PROP_START:
g_value_set_uint64 (value, tobj->start);
break;
case PROP_INPOINT:
g_value_set_uint64 (value, tobj->inpoint);
break;
case PROP_DURATION:
g_value_set_uint64 (value, tobj->duration);
break;
case PROP_PRIORITY:
g_value_set_uint (value, tobj->priority);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
ges_track_object_dispose (GObject * object)
{
G_OBJECT_CLASS (ges_track_object_parent_class)->dispose (object);
}
static void
ges_track_object_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
GESTrackObject *tobj = GES_TRACK_OBJECT (object);
static void
ges_track_object_finalize (GObject * object)
{
G_OBJECT_CLASS (ges_track_object_parent_class)->finalize (object);
}
switch (property_id) {
case PROP_START:
ges_track_object_set_start_internal (tobj,
g_value_get_uint64 (value));
break;
case PROP_INPOINT:
ges_track_object_set_inpoint_internal (tobj,
g_value_get_uint64 (value));
break;
case PROP_DURATION:
ges_track_object_set_duration_internal (tobj,
g_value_get_uint64 (value));
break;
case PROP_PRIORITY:
ges_track_object_set_priority_internal (tobj,
g_value_get_uint (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
ges_track_object_class_init (GESTrackObjectClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
static void ges_track_object_dispose (GObject * object)
{
G_OBJECT_CLASS (ges_track_object_parent_class)->dispose (object);
}
g_type_class_add_private (klass, sizeof (GESTrackObjectPrivate));
static void ges_track_object_finalize (GObject * object)
{
G_OBJECT_CLASS (ges_track_object_parent_class)->finalize (object);
}
object_class->get_property = ges_track_object_get_property;
object_class->set_property = ges_track_object_set_property;
object_class->dispose = ges_track_object_dispose;
object_class->finalize = ges_track_object_finalize;
}
static void ges_track_object_class_init (GESTrackObjectClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
static void
ges_track_object_init (GESTrackObject * self)
{
}
g_type_class_add_private (klass, sizeof (GESTrackObjectPrivate));
GESTrackObject *
ges_track_object_new (void)
{
return g_object_new (GES_TYPE_TRACK_OBJECT, NULL);
}
object_class->get_property = ges_track_object_get_property;
object_class->set_property = ges_track_object_set_property;
object_class->dispose = ges_track_object_dispose;
object_class->finalize = ges_track_object_finalize;
g_object_class_install_property (object_class, PROP_START,
g_param_spec_uint64 ("start", "Start",
"The position in the container", 0, G_MAXUINT64, 0,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_INPOINT,
g_param_spec_uint64 ("inpoint", "In-point", "The in-point", 0,
G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_DURATION,
g_param_spec_uint64 ("duration", "Duration", "The duration to use",
0, G_MAXUINT64, 0, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_PRIORITY,
g_param_spec_uint ("priority", "Priority",
"The priority of the object", 0, G_MAXUINT, 0,
G_PARAM_READWRITE));
}
static void ges_track_object_init (GESTrackObject * self)
{
}
GESTrackObject *ges_track_object_new (GESTimelineObject * timelineobj,
GESTrack * track)
{
GESTrackObject *obj;
obj = g_object_new (GES_TYPE_TRACK_OBJECT, NULL);
/* Set the timeline object and track */
obj->timelineobj = timelineobj;
obj->track = track;
/* Create the associated GnlObject */
ges_track_object_create_gnl_object (obj);
}
gboolean
ges_track_object_set_start_internal (GESTrackObject * object,
guint64 start) {
g_return_val_if_fail (object->gnlobject, FALSE);
if (G_UNLIKELY (start == object->start))
return FALSE;
g_object_set (object->gnlobject, "start", start, NULL);
return TRUE;
};
gboolean
ges_track_object_set_inpoint_internal (GESTrackObject * object,
guint64 inpoint) {
guint64 dur;
g_return_val_if_fail (object->gnlobject, FALSE);
if (G_UNLIKELY (inpoint == object->inpoint))
return FALSE;
/* Calculate new media-start/duration/media-duration */
dur = object->inpoint - inpoint + object->duration;
g_object_set (object->gnlobject, "media-start", inpoint, "duration", dur,
"media-duration", dur, NULL);
return TRUE;
}
gboolean
ges_track_object_set_duration_internal (GESTrackObject * object,
guint64 duration) {
g_return_val_if_fail (object->gnlobject, FALSE);
if (G_UNLIKELY (duration == object->duration))
return FALSE;
g_object_set (object->gnlobject, "duration", duration, "media-duration",
duration, NULL);
return TRUE;
}
gboolean
ges_track_object_set_priority_internal (GESTrackObject * object,
guint32 priority) {
g_return_val_if_fail (object->gnlobject, FALSE);
if (G_UNLIKELY (priority == object->priority))
return FALSE;
g_object_set (object->gnlobject, "priority", priority, NULL);
return TRUE;
}

View file

@ -46,15 +46,40 @@ typedef struct _GESTrackObjectClass GESTrackObjectClass;
struct _GESTrackObject {
GObject parent;
GESTimelineObject *timelineobj; /* The associated timeline object */
GESTrack *track; /* The associated Track */
/* Cached values of the gnlobject properties */
guint64 start; /* position (in time) of the object in the layer */
guint64 inpoint; /* in-point */
guint64 duration; /* duration of the object used in the layer */
guint32 priority; /* priority of the object in the layer (0:top priority) */
GstElement *gnlobject; /* The associated GnlObject */
};
struct _GESTrackObjectClass {
GObjectClass parent_class;
/* signal callbacks */
void (*changed) (GESTrackObject * object);
/* virtual methods */
gboolean (*create_gnl_object) (GESTrackObject * object);
};
GType ges_track_object_get_type (void);
GESTrackObject* ges_track_object_new (void);
GESTrackObject* ges_track_object_new (GESTimelineObject *timelineobj, GESTrack *track);
gboolean ges_track_object_create_gnl_object (GESTrackObject * object);
/* Private methods for GESTimelineObject's usage only */
gboolean ges_track_object_set_start_internal (GESTrackObject * object, guint64 start);
gboolean ges_track_object_set_inpoint_internal (GESTrackObject * object, guint64 inpoint);
gboolean ges_track_object_set_duration_internal (GESTrackObject * object, guint64 duration);
gboolean ges_track_object_set_priority_internal (GESTrackObject * object, guint32 priority);
G_END_DECLS

View file

@ -48,6 +48,8 @@ typedef struct _GESTrackClass GESTrackClass;
struct _GESTrack {
GstBin parent;
GnlComposition * composition; /* The composition associated with this track */
};
struct _GESTrackClass {

30
src/ges.c Normal file
View file

@ -0,0 +1,30 @@
/* GStreamer Editing Services
* Copyright (C) 2009 Edward Hervey <bilboed@bilboed.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.
*/
#include <ges/ges.h>
GST_DEBUG_CATEGORY (ges_debug);
void
ges_init (void)
{
/* initialize debugging category */
GST_DEBUG_CATEGORY_INIT (ges_debug, "ges", GST_DEBUG_FG_YELLOW,
"GStreamer Editing Services");
}

44
src/ges.h Normal file
View file

@ -0,0 +1,44 @@
/* GStreamer Editing Services
* Copyright (C) 2009 Edward Hervey <bilboed@bilboed.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_H__
#define __GES_H__
#include <glib.h>
#include <gst/gst.h>
#include <ges/ges-simple-timeline-layer.h>
#include <ges/ges-timeline.h>
#include <ges/ges-timeline-layer.h>
#include <ges/ges-timeline-object.h>
#include <ges/ges-timeline-pipeline.h>
#include <ges/ges-timeline-source.h>
#include <ges/ges-timeline-transition.h>
#include <ges/ges-track.h>
GST_DEBUG_CATEGORY_EXTERN (ges_debug);
#define GST_CAT_DEFAULT ges_debug
G_BEGIN_DECLS
void ges_init (void);
G_END_DECLS
#endif /* __GES_H__ */