diff --git a/docs/libs/ges-docs.sgml b/docs/libs/ges-docs.sgml index 937d19802f..d97b967d9f 100644 --- a/docs/libs/ges-docs.sgml +++ b/docs/libs/ges-docs.sgml @@ -47,6 +47,8 @@ platform as well as Windows. It is released under the GNU Library General Public + + @@ -66,7 +68,8 @@ platform as well as Windows. It is released under the GNU Library General Public Track objects - + + diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index c87eabd8fa..ab53ea1bb7 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -192,20 +192,69 @@ GES_TYPE_OPERATION
-ges-uri-source -GESUriSource -GESUriSource -ges_track_filesource_new +ges-video-source +GESVideoSource +GESVideoSource -GESUriSourceClass -GESUriSourcePrivate -GES_URI_SOURCE -GES_URI_SOURCE_CLASS -GES_URI_SOURCE_GET_CLASS -GES_TYPE_URI_SOURCE -GES_IS_URI_SOURCE -GES_IS_URI_SOURCE_CLASS -ges_track_filesource_get_type +GESVideoSourceClass +GESVideoSourcePrivate +GES_VIDEO_SOURCE +GES_VIDEO_SOURCE_CLASS +GES_VIDEO_SOURCE_GET_CLASS +GES_TYPE_VIDEO_SOURCE +GES_IS_VIDEO_SOURCE +GES_IS_VIDEO_SOURCE_CLASS +ges_video_source_get_type +
+ +
+ges-audio-source +GESAudioSource +GESAudioSource + +GESAudioSourceClass +GESAudioSourcePrivate +GES_AUDIO_SOURCE +GES_AUDIO_SOURCE_CLASS +GES_AUDIO_SOURCE_GET_CLASS +GES_TYPE_AUDIO_SOURCE +GES_IS_AUDIO_SOURCE +GES_IS_AUDIO_SOURCE_CLASS +ges_audio_source_get_type +
+ +
+ges-video-uri-source +GESVideoUriSource +GESVideoUriSource +ges_video_uri_source_new + +GESVideoUriSourceClass +GESVideoUriSourcePrivate +GES_VIDEO_URI_SOURCE +GES_VIDEO_URI_SOURCE_CLASS +GES_VIDEO_URI_SOURCE_GET_CLASS +GES_TYPE_VIDEO_URI_SOURCE +GES_IS_VIDEO_URI_SOURCE +GES_IS_VIDEO_URI_SOURCE_CLASS +ges_video_uri_source_get_type +
+ +
+ges-audio-uri-source +GESAudioUriSource +GESAudioUriSource +ges_audio_uri_source_new + +GESAudioUriSourceClass +GESAudioUriSourcePrivate +GES_AUDIO_URI_SOURCE +GES_AUDIO_URI_SOURCE_CLASS +GES_AUDIO_URI_SOURCE_GET_CLASS +GES_TYPE_AUDIO_URI_SOURCE +GES_IS_AUDIO_URI_SOURCE +GES_IS_AUDIO_URI_SOURCE_CLASS +ges_audio_uri_source_get_type
diff --git a/docs/libs/ges.types b/docs/libs/ges.types index 8977022447..dc024f8e5b 100644 --- a/docs/libs/ges.types +++ b/docs/libs/ges.types @@ -22,7 +22,8 @@ ges_text_overlay_clip_get_type ges_title_clip_get_type ges_audio_test_source_get_type ges_audio_transition_get_type -ges_track_filesource_get_type +ges_video_uri_source_get_type +ges_audio_uri_source_get_type ges_track_get_type ges_image_source_get_type ges_track_element_get_type diff --git a/ges/Makefile.am b/ges/Makefile.am index ab9f8d00e0..0263f1c402 100644 --- a/ges/Makefile.am +++ b/ges/Makefile.am @@ -34,7 +34,10 @@ libges_@GST_API_VERSION@_la_SOURCES = \ ges-track-element.c \ ges-source.c \ ges-operation.c \ - ges-uri-source.c \ + ges-video-source.c \ + ges-audio-source.c \ + ges-video-uri-source.c \ + ges-audio-uri-source.c \ ges-image-source.c \ ges-transition.c \ ges-audio-transition.c \ @@ -100,7 +103,10 @@ libges_@GST_API_VERSION@include_HEADERS = \ ges-track-element.h \ ges-source.h \ ges-operation.h \ - ges-uri-source.h \ + ges-video-source.h \ + ges-audio-source.h \ + ges-video-uri-source.h \ + ges-audio-uri-source.h \ ges-image-source.h \ ges-transition.h \ ges-audio-transition.h \ diff --git a/ges/ges-audio-source.c b/ges/ges-audio-source.c new file mode 100644 index 0000000000..6b0b69ea58 --- /dev/null +++ b/ges/ges-audio-source.c @@ -0,0 +1,109 @@ +/* GStreamer Editing Services + * Copyright (C) 2009 Edward Hervey + * 2009 Nokia Corporation + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/** + * SECTION:ges-audio-source + * @short_description: Base Class for audio sources + */ + +#include "ges-internal.h" +#include "ges/ges-meta-container.h" +#include "ges-track-element.h" +#include "ges-audio-source.h" +#include "ges-layer.h" + +G_DEFINE_TYPE (GESAudioSource, ges_audio_source, GES_TYPE_SOURCE); + +struct _GESAudioSourcePrivate +{ + /* Dummy variable */ + void *nothing; +}; + +static void +_sync_element_to_layer_property_float (GESTrackElement * trksrc, + GstElement * element, const gchar * meta, const gchar * propname) +{ + GESTimelineElement *parent; + GESLayer *layer; + gfloat value; + + parent = ges_timeline_element_get_parent (GES_TIMELINE_ELEMENT (trksrc)); + layer = ges_clip_get_layer (GES_CLIP (parent)); + + gst_object_unref (parent); + + if (layer != NULL) { + + ges_meta_container_get_float (GES_META_CONTAINER (layer), meta, &value); + g_object_set (element, propname, value, NULL); + GST_DEBUG_OBJECT (trksrc, "Setting %s to %f", propname, value); + + } else { + + GST_DEBUG_OBJECT (trksrc, "NOT setting the %s", propname); + } + + gst_object_unref (layer); +} + +static GstElement * +ges_audio_source_create_element (GESTrackElement * trksrc) +{ + GstElement *topbin; + GstElement *sub_element; + GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_GET_CLASS (trksrc); + const gchar *props[] = { "volume", "mute", NULL }; + GstElement *volume; + + if (!source_class->create_source) + return NULL; + + sub_element = source_class->create_source (trksrc); + + GST_DEBUG_OBJECT (trksrc, "Creating a bin sub_element ! volume"); + volume = gst_element_factory_make ("volume", NULL); + topbin = ges_source_create_topbin ("audiosrcbin", sub_element, volume, NULL); + _sync_element_to_layer_property_float (trksrc, volume, GES_META_VOLUME, + "volume"); + ges_track_element_add_children_props (trksrc, volume, NULL, NULL, props); + + return topbin; +} + +static void +ges_audio_source_class_init (GESAudioSourceClass * klass) +{ + GESTrackElementClass *track_class = GES_TRACK_ELEMENT_CLASS (klass); + GESAudioSourceClass *audio_source_class = GES_AUDIO_SOURCE_CLASS (klass); + + g_type_class_add_private (klass, sizeof (GESAudioSourcePrivate)); + + track_class->gnlobject_factorytype = "gnlsource"; + track_class->create_element = ges_audio_source_create_element; + audio_source_class->create_source = NULL; +} + +static void +ges_audio_source_init (GESAudioSource * self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + GES_TYPE_AUDIO_SOURCE, GESAudioSourcePrivate); +} diff --git a/ges/ges-audio-source.h b/ges/ges-audio-source.h new file mode 100644 index 0000000000..8115ab0ebb --- /dev/null +++ b/ges/ges-audio-source.h @@ -0,0 +1,90 @@ +/* GStreamer Editing Services + * Copyright (C) 2009 Edward Hervey + * 2009 Nokia Corporation + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GES_AUDIO_SOURCE +#define _GES_AUDIO_SOURCE + +#include +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define GES_TYPE_AUDIO_SOURCE ges_audio_source_get_type() + +#define GES_AUDIO_SOURCE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_AUDIO_SOURCE, GESAudioSource)) + +#define GES_AUDIO_SOURCE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_AUDIO_SOURCE, GESAudioSourceClass)) + +#define GES_IS_AUDIO_SOURCE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_AUDIO_SOURCE)) + +#define GES_IS_AUDIO_SOURCE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_AUDIO_SOURCE)) + +#define GES_AUDIO_SOURCE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_AUDIO_SOURCE, GESAudioSourceClass)) + +typedef struct _GESAudioSourcePrivate GESAudioSourcePrivate; + +/** + * GESAudioSource: + * + * Base class for audio sources + */ + +struct _GESAudioSource { + /*< private >*/ + GESSource parent; + + GESAudioSourcePrivate *priv; + + /* Padding for API extension */ + gpointer _ges_reserved[GES_PADDING]; +}; + +/** + * GESAudioSourceClass: + * @create_source: method to return the GstElement to put in the source topbin. + * Other elements will be queued, like a volume. + * In the case of a AudioUriSource, for example, the subclass will return a decodebin, + * and we will append a volume. + */ +struct _GESAudioSourceClass { + /*< private >*/ + GESSourceClass parent_class; + + /*< public >*/ + GstElement* (*create_source) (GESTrackElement * object); + + /*< private >*/ + /* Padding for API extension */ + gpointer _ges_reserved[GES_PADDING]; +}; + +GType ges_audio_source_get_type (void); + +G_END_DECLS + +#endif /* _GES_AUDIO_SOURCE */ diff --git a/ges/ges-audio-test-source.c b/ges/ges-audio-test-source.c index b2c918ece4..bff83d0d9c 100644 --- a/ges/ges-audio-test-source.c +++ b/ges/ges-audio-test-source.c @@ -31,7 +31,8 @@ #include "ges-track-element.h" #include "ges-audio-test-source.h" -G_DEFINE_TYPE (GESAudioTestSource, ges_audio_test_source, GES_TYPE_SOURCE); +G_DEFINE_TYPE (GESAudioTestSource, ges_audio_test_source, + GES_TYPE_AUDIO_SOURCE); #define DEFAULT_VOLUME 1.0 struct _GESAudioTestSourcePrivate @@ -57,7 +58,7 @@ static void ges_audio_test_source_class_init (GESAudioTestSourceClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GESSourceClass *source_class = GES_SOURCE_CLASS (klass); + GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_CLASS (klass); g_type_class_add_private (klass, sizeof (GESAudioTestSourcePrivate)); diff --git a/ges/ges-audio-test-source.h b/ges/ges-audio-test-source.h index b17101b719..3ecab1da1d 100644 --- a/ges/ges-audio-test-source.h +++ b/ges/ges-audio-test-source.h @@ -23,7 +23,7 @@ #include #include -#include +#include G_BEGIN_DECLS @@ -53,7 +53,7 @@ typedef struct _GESAudioTestSourcePrivate GESAudioTestSourcePrivate; */ struct _GESAudioTestSource { - GESSource parent; + GESAudioSource parent; /*< private >*/ GESAudioTestSourcePrivate *priv; @@ -64,7 +64,7 @@ struct _GESAudioTestSource { struct _GESAudioTestSourceClass { /*< private >*/ - GESSourceClass parent_class; + GESAudioSourceClass parent_class; /* Padding for API extension */ gpointer _ges_reserved[GES_PADDING]; diff --git a/ges/ges-uri-source.c b/ges/ges-audio-uri-source.c similarity index 67% rename from ges/ges-uri-source.c rename to ges/ges-audio-uri-source.c index 671b7d844a..f02da64a89 100644 --- a/ges/ges-uri-source.c +++ b/ges/ges-audio-uri-source.c @@ -19,21 +19,18 @@ */ /** - * SECTION:ges-uri-source - * @short_description: outputs a single media stream from a given file - * - * Outputs a single media stream from a given file. The stream chosen depends on - * the type of the track which contains the object. + * SECTION:ges-audio-uri-source + * @short_description: outputs a single audio stream from a given file */ #include "ges-utils.h" #include "ges-internal.h" #include "ges-track-element.h" -#include "ges-uri-source.h" +#include "ges-audio-uri-source.h" #include "ges-uri-asset.h" #include "ges-extractable.h" -struct _GESUriSourcePrivate +struct _GESAudioUriSourcePrivate { void *nothing; }; @@ -46,13 +43,13 @@ enum /* GESSource VMethod */ static GstElement * -ges_uri_source_create_source (GESTrackElement * trksrc) +ges_audio_uri_source_create_source (GESTrackElement * trksrc) { - GESUriSource *self; + GESAudioUriSource *self; GESTrack *track; GstElement *decodebin; - self = (GESUriSource *) trksrc; + self = (GESAudioUriSource *) trksrc; track = ges_track_element_get_track (trksrc); @@ -94,8 +91,8 @@ ges_extractable_interface_init (GESExtractableInterface * iface) iface->set_asset = extractable_set_asset; } -G_DEFINE_TYPE_WITH_CODE (GESUriSource, ges_track_filesource, - GES_TYPE_SOURCE, +G_DEFINE_TYPE_WITH_CODE (GESAudioUriSource, ges_audio_uri_source, + GES_TYPE_AUDIO_SOURCE, G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE, ges_extractable_interface_init)); @@ -103,10 +100,10 @@ G_DEFINE_TYPE_WITH_CODE (GESUriSource, ges_track_filesource, /* GObject VMethods */ static void -ges_track_filesource_get_property (GObject * object, guint property_id, +ges_audio_uri_source_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { - GESUriSource *uriclip = GES_URI_SOURCE (object); + GESAudioUriSource *uriclip = GES_AUDIO_URI_SOURCE (object); switch (property_id) { case PROP_URI: @@ -118,10 +115,10 @@ ges_track_filesource_get_property (GObject * object, guint property_id, } static void -ges_track_filesource_set_property (GObject * object, guint property_id, +ges_audio_uri_source_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) { - GESUriSource *uriclip = GES_URI_SOURCE (object); + GESAudioUriSource *uriclip = GES_AUDIO_URI_SOURCE (object); switch (property_id) { case PROP_URI: @@ -137,30 +134,30 @@ ges_track_filesource_set_property (GObject * object, guint property_id, } static void -ges_track_filesource_dispose (GObject * object) +ges_audio_uri_source_dispose (GObject * object) { - GESUriSource *uriclip = GES_URI_SOURCE (object); + GESAudioUriSource *uriclip = GES_AUDIO_URI_SOURCE (object); if (uriclip->uri) g_free (uriclip->uri); - G_OBJECT_CLASS (ges_track_filesource_parent_class)->dispose (object); + G_OBJECT_CLASS (ges_audio_uri_source_parent_class)->dispose (object); } static void -ges_track_filesource_class_init (GESUriSourceClass * klass) +ges_audio_uri_source_class_init (GESAudioUriSourceClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GESSourceClass *source_class = GES_SOURCE_CLASS (klass); + GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_CLASS (klass); - g_type_class_add_private (klass, sizeof (GESUriSourcePrivate)); + g_type_class_add_private (klass, sizeof (GESAudioUriSourcePrivate)); - object_class->get_property = ges_track_filesource_get_property; - object_class->set_property = ges_track_filesource_set_property; - object_class->dispose = ges_track_filesource_dispose; + object_class->get_property = ges_audio_uri_source_get_property; + object_class->set_property = ges_audio_uri_source_set_property; + object_class->dispose = ges_audio_uri_source_dispose; /** - * GESUriSource:uri: + * GESAudioUriSource:uri: * * The location of the file/resource to use. */ @@ -168,27 +165,27 @@ ges_track_filesource_class_init (GESUriSourceClass * klass) g_param_spec_string ("uri", "URI", "uri of the resource", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - source_class->create_source = ges_uri_source_create_source; + source_class->create_source = ges_audio_uri_source_create_source; } static void -ges_track_filesource_init (GESUriSource * self) +ges_audio_uri_source_init (GESAudioUriSource * self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - GES_TYPE_URI_SOURCE, GESUriSourcePrivate); + GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourcePrivate); } /** - * ges_track_filesource_new: + * ges_audio_uri_source_new: * @uri: the URI the source should control * - * Creates a new #GESUriSource for the provided @uri. + * Creates a new #GESAudioUriSource for the provided @uri. * - * Returns: The newly created #GESUriSource, or %NULL if there was an + * Returns: The newly created #GESAudioUriSource, or %NULL if there was an * error. */ -GESUriSource * -ges_track_filesource_new (gchar * uri) +GESAudioUriSource * +ges_audio_uri_source_new (gchar * uri) { - return g_object_new (GES_TYPE_URI_SOURCE, "uri", uri, NULL); + return g_object_new (GES_TYPE_AUDIO_URI_SOURCE, "uri", uri, NULL); } diff --git a/ges/ges-uri-source.h b/ges/ges-audio-uri-source.h similarity index 51% rename from ges/ges-uri-source.h rename to ges/ges-audio-uri-source.h index 1401684d91..a010217d70 100644 --- a/ges/ges-uri-source.h +++ b/ges/ges-audio-uri-source.h @@ -18,62 +18,62 @@ * Boston, MA 02110-1301, USA. */ -#ifndef _GES_URI_SOURCE -#define _GES_URI_SOURCE +#ifndef _GES_AUDIO_URI_SOURCE +#define _GES_AUDIO_URI_SOURCE #include #include -#include +#include G_BEGIN_DECLS -#define GES_TYPE_URI_SOURCE ges_track_filesource_get_type() +#define GES_TYPE_AUDIO_URI_SOURCE ges_audio_uri_source_get_type() -#define GES_URI_SOURCE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_URI_SOURCE, GESUriSource)) +#define GES_AUDIO_URI_SOURCE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSource)) -#define GES_URI_SOURCE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_URI_SOURCE, GESUriSourceClass)) +#define GES_AUDIO_URI_SOURCE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourceClass)) -#define GES_IS_URI_SOURCE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_URI_SOURCE)) +#define GES_IS_AUDIO_URI_SOURCE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_AUDIO_URI_SOURCE)) -#define GES_IS_URI_SOURCE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_URI_SOURCE)) +#define GES_IS_AUDIO_URI_SOURCE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_AUDIO_URI_SOURCE)) -#define GES_URI_SOURCE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_URI_SOURCE, GESUriSourceClass)) +#define GES_AUDIO_URI_SOURCE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourceClass)) -typedef struct _GESUriSourcePrivate GESUriSourcePrivate; +typedef struct _GESAudioUriSourcePrivate GESAudioUriSourcePrivate; /** - * GESUriSource: + * GESAudioUriSource: */ -struct _GESUriSource { +struct _GESAudioUriSource { /*< private >*/ - GESSource parent; + GESAudioSource parent; gchar *uri; - GESUriSourcePrivate *priv; + GESAudioUriSourcePrivate *priv; /* Padding for API extension */ gpointer _ges_reserved[GES_PADDING]; }; -struct _GESUriSourceClass { +struct _GESAudioUriSourceClass { /*< private >*/ - GESSourceClass parent_class; + GESAudioSourceClass parent_class; /* Padding for API extension */ gpointer _ges_reserved[GES_PADDING]; }; -GType ges_track_filesource_get_type (void); +GType ges_audio_uri_source_get_type (void); -GESUriSource* ges_track_filesource_new (gchar *uri); +GESAudioUriSource* ges_audio_uri_source_new (gchar *uri); G_END_DECLS -#endif /* _GES_URI_SOURCE */ +#endif /* _GES_AUDIO_URI_SOURCE */ diff --git a/ges/ges-image-source.c b/ges/ges-image-source.c index f2089f39a0..7d8cb4a566 100644 --- a/ges/ges-image-source.c +++ b/ges/ges-image-source.c @@ -32,7 +32,7 @@ #include "ges-track-element.h" #include "ges-image-source.h" -G_DEFINE_TYPE (GESImageSource, ges_image_source, GES_TYPE_SOURCE); +G_DEFINE_TYPE (GESImageSource, ges_image_source, GES_TYPE_VIDEO_SOURCE); struct _GESImageSourcePrivate { @@ -150,7 +150,7 @@ static void ges_image_source_class_init (GESImageSourceClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GESSourceClass *source_class = GES_SOURCE_CLASS (klass); + GESVideoSourceClass *source_class = GES_VIDEO_SOURCE_CLASS (klass); g_type_class_add_private (klass, sizeof (GESImageSourcePrivate)); diff --git a/ges/ges-image-source.h b/ges/ges-image-source.h index 9f4909650d..5633143617 100644 --- a/ges/ges-image-source.h +++ b/ges/ges-image-source.h @@ -23,7 +23,7 @@ #include #include -#include +#include G_BEGIN_DECLS @@ -51,7 +51,7 @@ typedef struct _GESImageSourcePrivate GESImageSourcePrivate; */ struct _GESImageSource { /*< private >*/ - GESSource parent; + GESVideoSource parent; gchar *uri; @@ -62,7 +62,7 @@ struct _GESImageSource { }; struct _GESImageSourceClass { - GESSourceClass parent_class; + GESVideoSourceClass parent_class; /* Padding for API extension */ gpointer _ges_reserved[GES_PADDING]; diff --git a/ges/ges-source.c b/ges/ges-source.c index 4e6b1195cb..52627ddf50 100644 --- a/ges/ges-source.c +++ b/ges/ges-source.c @@ -119,134 +119,15 @@ ges_source_create_topbin (const gchar * bin_name, GstElement * sub_element, ...) return bin; } -static void -_sync_element_to_layer_property_float (GESTrackElement * trksrc, - GstElement * element, const gchar * meta, const gchar * propname) -{ - GESTimelineElement *parent; - GESLayer *layer; - gfloat value; - - parent = ges_timeline_element_get_parent (GES_TIMELINE_ELEMENT (trksrc)); - layer = ges_clip_get_layer (GES_CLIP (parent)); - - gst_object_unref (parent); - - if (layer != NULL) { - - ges_meta_container_get_float (GES_META_CONTAINER (layer), meta, &value); - g_object_set (element, propname, value, NULL); - GST_DEBUG_OBJECT (trksrc, "Setting %s to %f", propname, value); - - } else { - - GST_DEBUG_OBJECT (trksrc, "NOT setting the %s", propname); - } - - gst_object_unref (layer); -} - -static void -update_z_order_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED, - GESSource * self) -{ - GESLayer *layer = ges_clip_get_layer (clip); - - if (layer == NULL) - return; - - /* 10000 is the max value of zorder on videomixerpad, hardcoded */ - - g_object_set (self->priv->positionner, "zorder", - 10000 - ges_layer_get_priority (layer), NULL); - - gst_object_unref (layer); -} - -static GstElement * -ges_source_create_element (GESTrackElement * trksrc) -{ - GstElement *topbin; - GstElement *sub_element; - GESSourceClass *source_class = GES_SOURCE_GET_CLASS (trksrc); - GESTrack *track; - GESSource *self; - - if (!source_class->create_source) - return NULL; - - sub_element = source_class->create_source (trksrc); - - track = ges_track_element_get_track (trksrc); - - self = (GESSource *) trksrc; - - switch (track->type) { - case GES_TRACK_TYPE_AUDIO: - { - const gchar *props[] = { "volume", "mute", NULL }; - GstElement *volume; - - GST_DEBUG_OBJECT (trksrc, "Creating a bin sub_element ! volume"); - - volume = gst_element_factory_make ("volume", NULL); - - topbin = - ges_source_create_topbin ("audiosrcbin", sub_element, volume, NULL); - - _sync_element_to_layer_property_float (trksrc, volume, GES_META_VOLUME, - "volume"); - ges_track_element_add_children_props (trksrc, volume, NULL, NULL, props); - break; - } - case GES_TRACK_TYPE_VIDEO: - { - GstElement *positionner; - const gchar *props[] = { "alpha", "posx", "posy", NULL }; - GESTimelineElement *parent; - - /* That positionner will add metadata to buffers according to its - properties, acting like a proxy for our smart-mixer dynamic pads. */ - positionner = - gst_element_factory_make ("framepositionner", "frame_tagger"); - - ges_track_element_add_children_props (trksrc, positionner, NULL, NULL, - props); - topbin = - ges_source_create_topbin ("videosrcbin", sub_element, positionner, - NULL); - parent = ges_timeline_element_get_parent (GES_TIMELINE_ELEMENT (trksrc)); - if (parent) { - self->priv->positionner = GST_FRAME_POSITIONNER (positionner); - g_signal_connect (parent, "notify::layer", - (GCallback) update_z_order_cb, trksrc); - update_z_order_cb (GES_CLIP (parent), NULL, self); - gst_object_unref (parent); - } else { - GST_WARNING ("No parent timeline element, SHOULD NOT HAPPEN"); - } - break; - } - default: - topbin = - ges_source_create_topbin ("a-questionable-name", sub_element, NULL); - break; - } - - return topbin; -} - static void ges_source_class_init (GESSourceClass * klass) { GESTrackElementClass *track_class = GES_TRACK_ELEMENT_CLASS (klass); - GESSourceClass *source_class = GES_SOURCE_CLASS (klass); g_type_class_add_private (klass, sizeof (GESSourcePrivate)); track_class->gnlobject_factorytype = "gnlsource"; - track_class->create_element = ges_source_create_element; - source_class->create_source = NULL; + track_class->create_element = NULL; } static void @@ -254,5 +135,4 @@ ges_source_init (GESSource * self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GES_TYPE_SOURCE, GESSourcePrivate); - self->priv->positionner = NULL; } diff --git a/ges/ges-source.h b/ges/ges-source.h index 73339c2658..6a39568462 100644 --- a/ges/ges-source.h +++ b/ges/ges-source.h @@ -74,7 +74,6 @@ struct _GESSourceClass { /*< private >*/ /* Padding for API extension */ - GstElement* (*create_source) (GESTrackElement * object); gpointer _ges_reserved[GES_PADDING]; }; diff --git a/ges/ges-title-source.c b/ges/ges-title-source.c index 1fd8ac8a53..ef0def57b3 100644 --- a/ges/ges-title-source.c +++ b/ges/ges-title-source.c @@ -29,7 +29,7 @@ #include "ges-title-source.h" #include "ges-video-test-source.h" -G_DEFINE_TYPE (GESTitleSource, ges_title_source, GES_TYPE_SOURCE); +G_DEFINE_TYPE (GESTitleSource, ges_title_source, GES_TYPE_VIDEO_SOURCE); struct _GESTitleSourcePrivate { @@ -64,7 +64,7 @@ static void ges_title_source_class_init (GESTitleSourceClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - GESSourceClass *source_class = GES_SOURCE_CLASS (klass); + GESVideoSourceClass *source_class = GES_VIDEO_SOURCE_CLASS (klass); g_type_class_add_private (klass, sizeof (GESTitleSourcePrivate)); diff --git a/ges/ges-title-source.h b/ges/ges-title-source.h index ae457bbdcd..4848a460ce 100644 --- a/ges/ges-title-source.h +++ b/ges/ges-title-source.h @@ -23,7 +23,7 @@ #include #include -#include +#include G_BEGIN_DECLS @@ -51,7 +51,7 @@ typedef struct _GESTitleSourcePrivate GESTitleSourcePrivate; * */ struct _GESTitleSource { - GESSource parent; + GESVideoSource parent; /*< private >*/ GESTitleSourcePrivate *priv; @@ -66,7 +66,7 @@ struct _GESTitleSource { */ struct _GESTitleSourceClass { - GESSourceClass parent_class; + GESVideoSourceClass parent_class; /*< private >*/ diff --git a/ges/ges-types.h b/ges/ges-types.h index 76bc9bbc1f..41bad0a4f3 100644 --- a/ges/ges-types.h +++ b/ges/ges-types.h @@ -104,8 +104,17 @@ typedef struct _GESBaseEffectClass GESBaseEffectClass; typedef struct _GESEffect GESEffect; typedef struct _GESEffectClass GESEffectClass; -typedef struct _GESUriSource GESUriSource; -typedef struct _GESUriSourceClass GESUriSourceClass; +typedef struct _GESVideoSource GESVideoSource; +typedef struct _GESVideoSourceClass GESVideoSourceClass; + +typedef struct _GESAudioSource GESAudioSource; +typedef struct _GESAudioSourceClass GESAudioSourceClass; + +typedef struct _GESVideoUriSource GESVideoUriSource; +typedef struct _GESVideoUriSourceClass GESVideoUriSourceClass; + +typedef struct _GESAudioUriSource GESAudioUriSource; +typedef struct _GESAudioUriSourceClass GESAudioUriSourceClass; typedef struct _GESImageSource GESImageSource; typedef struct _GESImageSourceClass GESImageSourceClass; diff --git a/ges/ges-uri-asset.c b/ges/ges-uri-asset.c index 4365fac616..3ec5c63eb4 100644 --- a/ges/ges-uri-asset.c +++ b/ges/ges-uri-asset.c @@ -238,8 +238,12 @@ _create_uri_source_asset (GESUriClipAsset * asset, stream_id = g_strdup_printf ("%i", GPOINTER_TO_INT (sinfo)); } - tck_filesource_asset = ges_asset_request (GES_TYPE_URI_SOURCE, - stream_id, NULL); + if (type == GES_TRACK_TYPE_VIDEO) + tck_filesource_asset = ges_asset_request (GES_TYPE_VIDEO_URI_SOURCE, + stream_id, NULL); + else + tck_filesource_asset = ges_asset_request (GES_TYPE_AUDIO_URI_SOURCE, + stream_id, NULL); g_free (stream_id); priv_tckasset = GES_URI_SOURCE_ASSET (tck_filesource_asset)->priv; @@ -547,9 +551,13 @@ _extract (GESAsset * asset, GError ** error) priv->sinfo)) trackelement = GES_TRACK_ELEMENT (ges_image_source_new (g_strdup (priv->uri))); + else if (GST_IS_DISCOVERER_VIDEO_INFO (priv->sinfo)) + trackelement = + GES_TRACK_ELEMENT (ges_video_uri_source_new (g_strdup (priv->uri))); else trackelement = - GES_TRACK_ELEMENT (ges_track_filesource_new (g_strdup (priv->uri))); + GES_TRACK_ELEMENT (ges_audio_uri_source_new (g_strdup (priv->uri))); + ges_track_element_set_track_type (trackelement, ges_track_element_asset_get_track_type (GES_TRACK_ELEMENT_ASSET (asset))); diff --git a/ges/ges-uri-clip.c b/ges/ges-uri-clip.c index d44cfbc43e..77d75a55dc 100644 --- a/ges/ges-uri-clip.c +++ b/ges/ges-uri-clip.c @@ -29,7 +29,8 @@ #include "ges-internal.h" #include "ges-uri-clip.h" #include "ges-source-clip.h" -#include "ges-uri-source.h" +#include "ges-video-uri-source.h" +#include "ges-audio-uri-source.h" #include "ges-uri-asset.h" #include "ges-track-element-asset.h" #include "ges-extractable.h" @@ -424,7 +425,7 @@ static GESTrackElement * ges_uri_clip_create_track_element (GESClip * clip, GESTrackType type) { GESUriClipPrivate *priv = GES_URI_CLIP (clip)->priv; - GESTrackElement *res; + GESTrackElement *res = NULL; if (priv->is_image) { if (type != GES_TRACK_TYPE_VIDEO) { @@ -439,7 +440,10 @@ ges_uri_clip_create_track_element (GESClip * clip, GESTrackType type) GST_DEBUG ("Creating a GESUriSource"); /* FIXME : Implement properly ! */ - res = (GESTrackElement *) ges_track_filesource_new (priv->uri); + if (type == GES_TRACK_TYPE_VIDEO) + res = (GESTrackElement *) ges_video_uri_source_new (priv->uri); + else if (type == GES_TRACK_TYPE_AUDIO) + res = (GESTrackElement *) ges_audio_uri_source_new (priv->uri); /* If mute and track is audio, deactivate the track element */ if (type == GES_TRACK_TYPE_AUDIO && priv->mute) diff --git a/ges/ges-video-source.c b/ges/ges-video-source.c new file mode 100644 index 0000000000..cfdac94cd2 --- /dev/null +++ b/ges/ges-video-source.c @@ -0,0 +1,115 @@ +/* GStreamer Editing Services + * Copyright (C) 2009 Edward Hervey + * 2009 Nokia Corporation + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/** + * SECTION:ges-video-source + * @short_description: Base Class for video sources + */ + +#include "ges-internal.h" +#include "ges/ges-meta-container.h" +#include "ges-track-element.h" +#include "ges-video-source.h" +#include "ges-layer.h" +#include "gstframepositionner.h" + +G_DEFINE_TYPE (GESVideoSource, ges_video_source, GES_TYPE_SOURCE); + +struct _GESVideoSourcePrivate +{ + GstFramePositionner *positionner; +}; + +static void +update_z_order_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED, + GESVideoSource * self) +{ + GESLayer *layer = ges_clip_get_layer (clip); + + if (layer == NULL) + return; + + /* 10000 is the max value of zorder on videomixerpad, hardcoded */ + + g_object_set (self->priv->positionner, "zorder", + 10000 - ges_layer_get_priority (layer), NULL); + + gst_object_unref (layer); +} + +static GstElement * +ges_video_source_create_element (GESTrackElement * trksrc) +{ + GstElement *topbin; + GstElement *sub_element; + GESVideoSourceClass *source_class = GES_VIDEO_SOURCE_GET_CLASS (trksrc); + GESVideoSource *self; + GstElement *positionner; + const gchar *props[] = { "alpha", "posx", "posy", NULL }; + GESTimelineElement *parent; + + if (!source_class->create_source) + return NULL; + + sub_element = source_class->create_source (trksrc); + + self = (GESVideoSource *) trksrc; + + /* That positionner will add metadata to buffers according to its + properties, acting like a proxy for our smart-mixer dynamic pads. */ + positionner = gst_element_factory_make ("framepositionner", "frame_tagger"); + + ges_track_element_add_children_props (trksrc, positionner, NULL, NULL, props); + topbin = + ges_source_create_topbin ("videosrcbin", sub_element, positionner, NULL); + parent = ges_timeline_element_get_parent (GES_TIMELINE_ELEMENT (trksrc)); + if (parent) { + self->priv->positionner = GST_FRAME_POSITIONNER (positionner); + g_signal_connect (parent, "notify::layer", + (GCallback) update_z_order_cb, trksrc); + update_z_order_cb (GES_CLIP (parent), NULL, self); + gst_object_unref (parent); + } else { + GST_ERROR ("No parent timeline element, SHOULD NOT HAPPEN"); + } + + return topbin; +} + +static void +ges_video_source_class_init (GESVideoSourceClass * klass) +{ + GESTrackElementClass *track_class = GES_TRACK_ELEMENT_CLASS (klass); + GESVideoSourceClass *video_source_class = GES_VIDEO_SOURCE_CLASS (klass); + + g_type_class_add_private (klass, sizeof (GESVideoSourcePrivate)); + + track_class->gnlobject_factorytype = "gnlsource"; + track_class->create_element = ges_video_source_create_element; + video_source_class->create_source = NULL; +} + +static void +ges_video_source_init (GESVideoSource * self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + GES_TYPE_VIDEO_SOURCE, GESVideoSourcePrivate); + self->priv->positionner = NULL; +} diff --git a/ges/ges-video-source.h b/ges/ges-video-source.h new file mode 100644 index 0000000000..0e1bd44227 --- /dev/null +++ b/ges/ges-video-source.h @@ -0,0 +1,90 @@ +/* GStreamer Editing Services + * Copyright (C) 2009 Edward Hervey + * 2009 Nokia Corporation + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GES_VIDEO_SOURCE +#define _GES_VIDEO_SOURCE + +#include +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define GES_TYPE_VIDEO_SOURCE ges_video_source_get_type() + +#define GES_VIDEO_SOURCE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_VIDEO_SOURCE, GESVideoSource)) + +#define GES_VIDEO_SOURCE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_VIDEO_SOURCE, GESVideoSourceClass)) + +#define GES_IS_VIDEO_SOURCE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_VIDEO_SOURCE)) + +#define GES_IS_VIDEO_SOURCE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_VIDEO_SOURCE)) + +#define GES_VIDEO_SOURCE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_VIDEO_SOURCE, GESVideoSourceClass)) + +typedef struct _GESVideoSourcePrivate GESVideoSourcePrivate; + +/** + * GESVideoSource: + * + * Base class for video sources + */ + +struct _GESVideoSource { + /*< private >*/ + GESSource parent; + + GESVideoSourcePrivate *priv; + + /* Padding for API extension */ + gpointer _ges_reserved[GES_PADDING]; +}; + +/** + * GESVideoSourceClass: + * @create_source: method to return the GstElement to put in the source topbin. + * Other elements will be queued, like a videoscale. + * In the case of a VideoUriSource, for example, the subclass will return a decodebin, + * and we will append a videoscale. + */ +struct _GESVideoSourceClass { + /*< private >*/ + GESSourceClass parent_class; + + /*< public >*/ + GstElement* (*create_source) (GESTrackElement * object); + + /*< private >*/ + /* Padding for API extension */ + gpointer _ges_reserved[GES_PADDING]; +}; + +GType ges_video_source_get_type (void); + +G_END_DECLS + +#endif /* _GES_VIDEO_SOURCE */ diff --git a/ges/ges-video-test-source.c b/ges/ges-video-test-source.c index b7405c1fb2..77a111e18e 100644 --- a/ges/ges-video-test-source.c +++ b/ges/ges-video-test-source.c @@ -27,7 +27,8 @@ #include "ges-track-element.h" #include "ges-video-test-source.h" -G_DEFINE_TYPE (GESVideoTestSource, ges_video_test_source, GES_TYPE_SOURCE); +G_DEFINE_TYPE (GESVideoTestSource, ges_video_test_source, + GES_TYPE_VIDEO_SOURCE); #define DEFAULT_VPATTERN GES_VIDEO_TEST_PATTERN_SMPTE @@ -41,7 +42,7 @@ static GstElement *ges_video_test_source_create_source (GESTrackElement * self); static void ges_video_test_source_class_init (GESVideoTestSourceClass * klass) { - GESSourceClass *source_class = GES_SOURCE_CLASS (klass); + GESVideoSourceClass *source_class = GES_VIDEO_SOURCE_CLASS (klass); g_type_class_add_private (klass, sizeof (GESVideoTestSourcePrivate)); @@ -74,7 +75,7 @@ ges_video_test_source_create_source (GESTrackElement * self) ges_track_element_add_children_props (self, testsrc, NULL, NULL, props); - return create_bin ("videotestsrc", testsrc, capsfilter, NULL); + return ges_source_create_topbin ("videotestsrc", testsrc, capsfilter, NULL); } /** diff --git a/ges/ges-video-test-source.h b/ges/ges-video-test-source.h index ecfa870fb8..b6245c4d5c 100644 --- a/ges/ges-video-test-source.h +++ b/ges/ges-video-test-source.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include G_BEGIN_DECLS @@ -52,7 +52,7 @@ typedef struct _GESVideoTestSourcePrivate GESVideoTestSourcePrivate; */ struct _GESVideoTestSource { /*< private >*/ - GESSource parent; + GESVideoSource parent; GESVideoTestSourcePrivate *priv; @@ -61,7 +61,7 @@ struct _GESVideoTestSource { }; struct _GESVideoTestSourceClass { - GESSourceClass parent_class; + GESVideoSourceClass parent_class; /* Padding for API extension */ gpointer _ges_reserved[GES_PADDING]; diff --git a/ges/ges-video-uri-source.c b/ges/ges-video-uri-source.c new file mode 100644 index 0000000000..0acd7f96ac --- /dev/null +++ b/ges/ges-video-uri-source.c @@ -0,0 +1,191 @@ +/* GStreamer Editing Services + * Copyright (C) 2009 Edward Hervey + * 2009 Nokia Corporation + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/** + * SECTION:ges-video-uri-source + * @short_description: outputs a single video stream from a given file + */ + +#include "ges-utils.h" +#include "ges-internal.h" +#include "ges-track-element.h" +#include "ges-video-uri-source.h" +#include "ges-uri-asset.h" +#include "ges-extractable.h" + +struct _GESVideoUriSourcePrivate +{ + void *nothing; +}; + +enum +{ + PROP_0, + PROP_URI +}; + +/* GESSource VMethod */ +static GstElement * +ges_video_uri_source_create_source (GESTrackElement * trksrc) +{ + GESVideoUriSource *self; + GESTrack *track; + GstElement *decodebin; + + self = (GESVideoUriSource *) trksrc; + + track = ges_track_element_get_track (trksrc); + + decodebin = gst_element_factory_make ("uridecodebin", NULL); + + g_object_set (decodebin, "caps", ges_track_get_caps (track), + "expose-all-streams", FALSE, "uri", self->uri, NULL); + + return decodebin; +} + +/* Extractable interface implementation */ + +static gchar * +ges_extractable_check_id (GType type, const gchar * id, GError ** error) +{ + return g_strdup (id); +} + +static void +extractable_set_asset (GESExtractable * self, GESAsset * asset) +{ + /* FIXME That should go into #GESTrackElement, but + * some work is needed to make sure it works properly */ + + if (ges_track_element_get_track_type (GES_TRACK_ELEMENT (self)) == + GES_TRACK_TYPE_UNKNOWN) { + ges_track_element_set_track_type (GES_TRACK_ELEMENT (self), + ges_track_element_asset_get_track_type (GES_TRACK_ELEMENT_ASSET + (asset))); + } +} + +static void +ges_extractable_interface_init (GESExtractableInterface * iface) +{ + iface->asset_type = GES_TYPE_URI_SOURCE_ASSET; + iface->check_id = ges_extractable_check_id; + iface->set_asset = extractable_set_asset; +} + +G_DEFINE_TYPE_WITH_CODE (GESVideoUriSource, ges_video_uri_source, + GES_TYPE_VIDEO_SOURCE, + G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE, + ges_extractable_interface_init)); + + +/* GObject VMethods */ + +static void +ges_video_uri_source_get_property (GObject * object, guint property_id, + GValue * value, GParamSpec * pspec) +{ + GESVideoUriSource *uriclip = GES_VIDEO_URI_SOURCE (object); + + switch (property_id) { + case PROP_URI: + g_value_set_string (value, uriclip->uri); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +ges_video_uri_source_set_property (GObject * object, guint property_id, + const GValue * value, GParamSpec * pspec) +{ + GESVideoUriSource *uriclip = GES_VIDEO_URI_SOURCE (object); + + switch (property_id) { + case PROP_URI: + if (uriclip->uri) { + GST_WARNING_OBJECT (object, "Uri already set to %s", uriclip->uri); + return; + } + uriclip->uri = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +ges_video_uri_source_dispose (GObject * object) +{ + GESVideoUriSource *uriclip = GES_VIDEO_URI_SOURCE (object); + + if (uriclip->uri) + g_free (uriclip->uri); + + G_OBJECT_CLASS (ges_video_uri_source_parent_class)->dispose (object); +} + +static void +ges_video_uri_source_class_init (GESVideoUriSourceClass * klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GESVideoSourceClass *source_class = GES_VIDEO_SOURCE_CLASS (klass); + + g_type_class_add_private (klass, sizeof (GESVideoUriSourcePrivate)); + + object_class->get_property = ges_video_uri_source_get_property; + object_class->set_property = ges_video_uri_source_set_property; + object_class->dispose = ges_video_uri_source_dispose; + + /** + * GESVideoUriSource:uri: + * + * The location of the file/resource to use. + */ + g_object_class_install_property (object_class, PROP_URI, + g_param_spec_string ("uri", "URI", "uri of the resource", + NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + source_class->create_source = ges_video_uri_source_create_source; +} + +static void +ges_video_uri_source_init (GESVideoUriSource * self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + GES_TYPE_VIDEO_URI_SOURCE, GESVideoUriSourcePrivate); +} + +/** + * ges_video_uri_source_new: + * @uri: the URI the source should control + * + * Creates a new #GESVideoUriSource for the provided @uri. + * + * Returns: The newly created #GESVideoUriSource, or %NULL if there was an + * error. + */ +GESVideoUriSource * +ges_video_uri_source_new (gchar * uri) +{ + return g_object_new (GES_TYPE_VIDEO_URI_SOURCE, "uri", uri, NULL); +} diff --git a/ges/ges-video-uri-source.h b/ges/ges-video-uri-source.h new file mode 100644 index 0000000000..7fb5862219 --- /dev/null +++ b/ges/ges-video-uri-source.h @@ -0,0 +1,79 @@ +/* GStreamer Editing Services + * Copyright (C) 2009 Edward Hervey + * 2009 Nokia Corporation + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _GES_VIDEO_URI_SOURCE +#define _GES_VIDEO_URI_SOURCE + +#include +#include +#include + +G_BEGIN_DECLS + +#define GES_TYPE_VIDEO_URI_SOURCE ges_video_uri_source_get_type() + +#define GES_VIDEO_URI_SOURCE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_VIDEO_URI_SOURCE, GESVideoUriSource)) + +#define GES_VIDEO_URI_SOURCE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_VIDEO_URI_SOURCE, GESVideoUriSourceClass)) + +#define GES_IS_VIDEO_URI_SOURCE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_VIDEO_URI_SOURCE)) + +#define GES_IS_VIDEO_URI_SOURCE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_VIDEO_URI_SOURCE)) + +#define GES_VIDEO_URI_SOURCE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_VIDEO_URI_SOURCE, GESVideoUriSourceClass)) + +typedef struct _GESVideoUriSourcePrivate GESVideoUriSourcePrivate; + +/** + * GESVideoUriSource: + */ +struct _GESVideoUriSource { + /*< private >*/ + GESVideoSource parent; + + gchar *uri; + + GESVideoUriSourcePrivate *priv; + + /* Padding for API extension */ + gpointer _ges_reserved[GES_PADDING]; +}; + +struct _GESVideoUriSourceClass { + /*< private >*/ + GESVideoSourceClass parent_class; + + /* Padding for API extension */ + gpointer _ges_reserved[GES_PADDING]; +}; + +GType ges_video_uri_source_get_type (void); + +GESVideoUriSource* ges_video_uri_source_new (gchar *uri); + +G_END_DECLS + +#endif /* _GES_VIDEO_URI_SOURCE */ + diff --git a/ges/ges.h b/ges/ges.h index b1cee92854..1868248da8 100644 --- a/ges/ges.h +++ b/ges/ges.h @@ -60,7 +60,8 @@ #include #include -#include +#include +#include #include #include #include diff --git a/tests/check/ges/uriclip.c b/tests/check/ges/uriclip.c index 0c77748d29..09dfb4ed80 100644 --- a/tests/check/ges/uriclip.c +++ b/tests/check/ges/uriclip.c @@ -68,7 +68,8 @@ asset_created_cb (GObject * source, GAsyncResult * res, gpointer udata) GList *trackelements = ges_track_get_elements (GES_TRACK (tmp->data)); assert_equals_int (g_list_length (trackelements), 1); - fail_unless (GES_IS_URI_SOURCE (trackelements->data)); + fail_unless (GES_IS_VIDEO_URI_SOURCE (trackelements->data) + || GES_IS_AUDIO_URI_SOURCE (trackelements->data)); g_list_free_full (trackelements, gst_object_unref); } g_list_free_full (tracks, gst_object_unref);