GES: Add GESVideoSource and GESAudioSource base classes
authorSimon Corsin <simoncorsin@gmail.com>
Tue, 9 Jul 2013 13:31:15 +0000 (15:31 +0200)
committerThibault Saunier <thibault.saunier@collabora.com>
Wed, 4 Sep 2013 00:22:32 +0000 (20:22 -0400)
  + Update documentation.
  + Implements subclasses audio-uri-source and video-uri-source

29 files changed:
docs/libs/ges-docs.sgml
docs/libs/ges-sections.txt
docs/libs/ges.types
ges/Makefile.am
ges/ges-audio-source.c [new file with mode: 0644]
ges/ges-audio-source.h [new file with mode: 0644]
ges/ges-audio-test-source.c
ges/ges-audio-test-source.h
ges/ges-audio-uri-source.c [new file with mode: 0644]
ges/ges-audio-uri-source.h [new file with mode: 0644]
ges/ges-image-source.c
ges/ges-image-source.h
ges/ges-source.c
ges/ges-source.h
ges/ges-title-source.c
ges/ges-title-source.h
ges/ges-types.h
ges/ges-uri-asset.c
ges/ges-uri-clip.c
ges/ges-uri-source.c [deleted file]
ges/ges-uri-source.h [deleted file]
ges/ges-video-source.c [new file with mode: 0644]
ges/ges-video-source.h [new file with mode: 0644]
ges/ges-video-test-source.c
ges/ges-video-test-source.h
ges/ges-video-uri-source.c [new file with mode: 0644]
ges/ges-video-uri-source.h [new file with mode: 0644]
ges/ges.h
tests/check/ges/uriclip.c

index 937d19802ffc621fea54385248eae9cac373e647..d97b967d9f13aced92febf6038e6c4d4345c5662 100644 (file)
@@ -47,6 +47,8 @@ platform as well as Windows. It is released under the GNU Library General Public
     <xi:include href="xml/ges-track.xml"/>
     <xi:include href="xml/ges-track-element.xml"/>
     <xi:include href="xml/ges-source.xml"/>
+    <xi:include href="xml/ges-video-source.xml"/>
+    <xi:include href="xml/ges-audio-source.xml"/>
     <xi:include href="xml/ges-base-effect.xml"/>
     <xi:include href="xml/ges-operation.xml"/>
     <xi:include href="xml/ges-base-transition-clip.xml"/>
@@ -66,7 +68,8 @@ platform as well as Windows. It is released under the GNU Library General Public
 
   <chapter>
     <title>Track objects</title>
-    <xi:include href="xml/ges-uri-source.xml"/>
+    <xi:include href="xml/ges-audio-uri-source.xml"/>
+    <xi:include href="xml/ges-video-uri-source.xml"/>
     <xi:include href="xml/ges-title-source.xml"/>
     <xi:include href="xml/ges-audio-test-source.xml"/>
     <xi:include href="xml/ges-video-test-source.xml"/>
index c87eabd8facfa01285bb1a76148e7ebda64af95b..ab53ea1bb7e36453a530b963eec9fd310c088eee 100644 (file)
@@ -192,20 +192,69 @@ GES_TYPE_OPERATION
 </SECTION>
 
 <SECTION>
-<FILE>ges-uri-source</FILE>
-<TITLE>GESUriSource</TITLE>
-GESUriSource
-ges_track_filesource_new
+<FILE>ges-video-source</FILE>
+<TITLE>GESVideoSource</TITLE>
+GESVideoSource
 <SUBSECTION Standard>
-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
+</SECTION>
+
+<SECTION>
+<FILE>ges-audio-source</FILE>
+<TITLE>GESAudioSource</TITLE>
+GESAudioSource
+<SUBSECTION Standard>
+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
+</SECTION>
+
+<SECTION>
+<FILE>ges-video-uri-source</FILE>
+<TITLE>GESVideoUriSource</TITLE>
+GESVideoUriSource
+ges_video_uri_source_new
+<SUBSECTION Standard>
+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
+</SECTION>
+
+<SECTION>
+<FILE>ges-audio-uri-source</FILE>
+<TITLE>GESAudioUriSource</TITLE>
+GESAudioUriSource
+ges_audio_uri_source_new
+<SUBSECTION Standard>
+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
 </SECTION>
 
 <SECTION>
index 89770224474237efb275cd664bf7bc981b78ebaa..dc024f8e5be3dc02b92a755ceeda4be399cacf9c 100644 (file)
@@ -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
index ab9f8d00e094aece09c81d6037d4977ccd3b3707..0263f1c4028cd1c4f5fc4089b921c480711e1973 100644 (file)
@@ -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 (file)
index 0000000..6b0b69e
--- /dev/null
@@ -0,0 +1,109 @@
+/* GStreamer Editing Services
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ *               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 (file)
index 0000000..8115ab0
--- /dev/null
@@ -0,0 +1,90 @@
+/* GStreamer Editing Services
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ *               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 <glib-object.h>
+#include <gst/gst.h>
+#include <ges/ges-types.h>
+#include <ges/ges-track-element.h>
+#include <ges/ges-source.h>
+
+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 */
index b2c918ece47310a00806c1a83f7b3acc682d7793..bff83d0d9c002c726d131aea16c9d83711ffbd11 100644 (file)
@@ -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));
 
index b17101b7196a81118c6e664d59206f989c930bc6..3ecab1da1d3f77c7b9f96f5be0a5f04e665e6fe4 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <glib-object.h>
 #include <ges/ges-types.h>
-#include <ges/ges-source.h>
+#include <ges/ges-audio-source.h>
 
 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-audio-uri-source.c b/ges/ges-audio-uri-source.c
new file mode 100644 (file)
index 0000000..f02da64
--- /dev/null
@@ -0,0 +1,191 @@
+/* GStreamer Editing Services
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ *               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-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-audio-uri-source.h"
+#include "ges-uri-asset.h"
+#include "ges-extractable.h"
+
+struct _GESAudioUriSourcePrivate
+{
+  void *nothing;
+};
+
+enum
+{
+  PROP_0,
+  PROP_URI
+};
+
+/* GESSource VMethod */
+static GstElement *
+ges_audio_uri_source_create_source (GESTrackElement * trksrc)
+{
+  GESAudioUriSource *self;
+  GESTrack *track;
+  GstElement *decodebin;
+
+  self = (GESAudioUriSource *) 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 (GESAudioUriSource, ges_audio_uri_source,
+    GES_TYPE_AUDIO_SOURCE,
+    G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
+        ges_extractable_interface_init));
+
+
+/* GObject VMethods */
+
+static void
+ges_audio_uri_source_get_property (GObject * object, guint property_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GESAudioUriSource *uriclip = GES_AUDIO_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_audio_uri_source_set_property (GObject * object, guint property_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GESAudioUriSource *uriclip = GES_AUDIO_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_audio_uri_source_dispose (GObject * object)
+{
+  GESAudioUriSource *uriclip = GES_AUDIO_URI_SOURCE (object);
+
+  if (uriclip->uri)
+    g_free (uriclip->uri);
+
+  G_OBJECT_CLASS (ges_audio_uri_source_parent_class)->dispose (object);
+}
+
+static void
+ges_audio_uri_source_class_init (GESAudioUriSourceClass * klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (GESAudioUriSourcePrivate));
+
+  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;
+
+  /**
+   * GESAudioUriSource: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_audio_uri_source_create_source;
+}
+
+static void
+ges_audio_uri_source_init (GESAudioUriSource * self)
+{
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+      GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourcePrivate);
+}
+
+/**
+ * ges_audio_uri_source_new:
+ * @uri: the URI the source should control
+ *
+ * Creates a new #GESAudioUriSource for the provided @uri.
+ *
+ * Returns: The newly created #GESAudioUriSource, or %NULL if there was an
+ * error.
+ */
+GESAudioUriSource *
+ges_audio_uri_source_new (gchar * uri)
+{
+  return g_object_new (GES_TYPE_AUDIO_URI_SOURCE, "uri", uri, NULL);
+}
diff --git a/ges/ges-audio-uri-source.h b/ges/ges-audio-uri-source.h
new file mode 100644 (file)
index 0000000..a010217
--- /dev/null
@@ -0,0 +1,79 @@
+/* GStreamer Editing Services
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ *               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_URI_SOURCE
+#define _GES_AUDIO_URI_SOURCE
+
+#include <glib-object.h>
+#include <ges/ges-types.h>
+#include <ges/ges-audio-source.h>
+
+G_BEGIN_DECLS
+
+#define GES_TYPE_AUDIO_URI_SOURCE ges_audio_uri_source_get_type()
+
+#define GES_AUDIO_URI_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSource))
+
+#define GES_AUDIO_URI_SOURCE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourceClass))
+
+#define GES_IS_AUDIO_URI_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_AUDIO_URI_SOURCE))
+
+#define GES_IS_AUDIO_URI_SOURCE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_AUDIO_URI_SOURCE))
+
+#define GES_AUDIO_URI_SOURCE_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourceClass))
+
+typedef struct _GESAudioUriSourcePrivate GESAudioUriSourcePrivate;
+
+/**
+ * GESAudioUriSource:
+ */
+struct _GESAudioUriSource {
+  /*< private >*/
+  GESAudioSource parent;
+
+  gchar *uri;
+
+  GESAudioUriSourcePrivate *priv;
+
+  /* Padding for API extension */
+  gpointer _ges_reserved[GES_PADDING];
+};
+
+struct _GESAudioUriSourceClass {
+  /*< private >*/
+  GESAudioSourceClass parent_class;
+
+  /* Padding for API extension */
+  gpointer _ges_reserved[GES_PADDING];
+};
+
+GType ges_audio_uri_source_get_type (void);
+
+GESAudioUriSource* ges_audio_uri_source_new (gchar *uri);
+
+G_END_DECLS
+
+#endif /* _GES_AUDIO_URI_SOURCE */
+
index f2089f39a04de589bc62ab6c4e258f532a4984a5..7d8cb4a566d7739edf39004b9b73fd0445a53a7c 100644 (file)
@@ -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));
 
index 9f4909650d650cda50373598937698fc6cd161a3..5633143617dfeb39de1150c60545935542d6d81b 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <glib-object.h>
 #include <ges/ges-types.h>
-#include <ges/ges-source.h>
+#include <ges/ges-video-source.h>
 
 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];
index 4e6b1195cb3bbd0125497a9ca4c20770c5f221e8..52627ddf507f233959d1d34c3ed368fc45498093 100644 (file)
@@ -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;
 }
index 73339c26581ea0a697065069fb65424448e59704..6a3956846262197bd9c3e0806e6b19c889149f32 100644 (file)
@@ -74,7 +74,6 @@ struct _GESSourceClass {
 
   /*< private >*/
   /* Padding for API extension */
-  GstElement*  (*create_source)           (GESTrackElement * object);
   gpointer _ges_reserved[GES_PADDING];
 };
 
index 1fd8ac8a5383449e055c477d184e4b80ef60dc38..ef0def57b30e5ff2e570a62c7ba49e3fedf239ef 100644 (file)
@@ -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));
 
index ae457bbdcd2f8dc506ee660d4353f156c71ea2e6..4848a460ce6d162dc645bf0f88e4363f04b0d959 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <glib-object.h>
 #include <ges/ges-types.h>
-#include <ges/ges-source.h>
+#include <ges/ges-video-source.h>
 
 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 >*/
 
index 76bc9bbc1f0946403773e6e3e481407167a961d2..41bad0a4f363e042b4d7516ee3c395aefbafdd9f 100644 (file)
@@ -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;
index 4365fac616a2510cf476bf11c7fbba5619268c92..3ec5c63eb42b326eec729115491fdb2c136bfbe5 100644 (file)
@@ -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)));
 
index d44cfbc43ef8428d3bcf399ad7b5606cdde95e89..77d75a55dc9d06aa4df9f9a00bf70eb88dfefdbd 100644 (file)
@@ -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-uri-source.c b/ges/ges-uri-source.c
deleted file mode 100644 (file)
index 671b7d8..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/* GStreamer Editing Services
- * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
- *               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-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.
- */
-
-#include "ges-utils.h"
-#include "ges-internal.h"
-#include "ges-track-element.h"
-#include "ges-uri-source.h"
-#include "ges-uri-asset.h"
-#include "ges-extractable.h"
-
-struct _GESUriSourcePrivate
-{
-  void *nothing;
-};
-
-enum
-{
-  PROP_0,
-  PROP_URI
-};
-
-/* GESSource VMethod */
-static GstElement *
-ges_uri_source_create_source (GESTrackElement * trksrc)
-{
-  GESUriSource *self;
-  GESTrack *track;
-  GstElement *decodebin;
-
-  self = (GESUriSource *) 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 (GESUriSource, ges_track_filesource,
-    GES_TYPE_SOURCE,
-    G_IMPLEMENT_INTERFACE (GES_TYPE_EXTRACTABLE,
-        ges_extractable_interface_init));
-
-
-/* GObject VMethods */
-
-static void
-ges_track_filesource_get_property (GObject * object, guint property_id,
-    GValue * value, GParamSpec * pspec)
-{
-  GESUriSource *uriclip = GES_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_track_filesource_set_property (GObject * object, guint property_id,
-    const GValue * value, GParamSpec * pspec)
-{
-  GESUriSource *uriclip = GES_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_track_filesource_dispose (GObject * object)
-{
-  GESUriSource *uriclip = GES_URI_SOURCE (object);
-
-  if (uriclip->uri)
-    g_free (uriclip->uri);
-
-  G_OBJECT_CLASS (ges_track_filesource_parent_class)->dispose (object);
-}
-
-static void
-ges_track_filesource_class_init (GESUriSourceClass * klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  GESSourceClass *source_class = GES_SOURCE_CLASS (klass);
-
-  g_type_class_add_private (klass, sizeof (GESUriSourcePrivate));
-
-  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;
-
-  /**
-   * GESUriSource: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_uri_source_create_source;
-}
-
-static void
-ges_track_filesource_init (GESUriSource * self)
-{
-  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
-      GES_TYPE_URI_SOURCE, GESUriSourcePrivate);
-}
-
-/**
- * ges_track_filesource_new:
- * @uri: the URI the source should control
- *
- * Creates a new #GESUriSource for the provided @uri.
- *
- * Returns: The newly created #GESUriSource, or %NULL if there was an
- * error.
- */
-GESUriSource *
-ges_track_filesource_new (gchar * uri)
-{
-  return g_object_new (GES_TYPE_URI_SOURCE, "uri", uri, NULL);
-}
diff --git a/ges/ges-uri-source.h b/ges/ges-uri-source.h
deleted file mode 100644 (file)
index 1401684..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* GStreamer Editing Services
- * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
- *               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_URI_SOURCE
-#define _GES_URI_SOURCE
-
-#include <glib-object.h>
-#include <ges/ges-types.h>
-#include <ges/ges-source.h>
-
-G_BEGIN_DECLS
-
-#define GES_TYPE_URI_SOURCE ges_track_filesource_get_type()
-
-#define GES_URI_SOURCE(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_URI_SOURCE, GESUriSource))
-
-#define GES_URI_SOURCE_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_URI_SOURCE, GESUriSourceClass))
-
-#define GES_IS_URI_SOURCE(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_URI_SOURCE))
-
-#define GES_IS_URI_SOURCE_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_URI_SOURCE))
-
-#define GES_URI_SOURCE_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_URI_SOURCE, GESUriSourceClass))
-
-typedef struct _GESUriSourcePrivate GESUriSourcePrivate;
-
-/**
- * GESUriSource:
- */
-struct _GESUriSource {
-  /*< private >*/
-  GESSource parent;
-
-  gchar *uri;
-
-  GESUriSourcePrivate *priv;
-
-  /* Padding for API extension */
-  gpointer _ges_reserved[GES_PADDING];
-};
-
-struct _GESUriSourceClass {
-  /*< private >*/
-  GESSourceClass parent_class;
-
-  /* Padding for API extension */
-  gpointer _ges_reserved[GES_PADDING];
-};
-
-GType ges_track_filesource_get_type (void);
-
-GESUriSource* ges_track_filesource_new (gchar *uri);
-
-G_END_DECLS
-
-#endif /* _GES_URI_SOURCE */
-
diff --git a/ges/ges-video-source.c b/ges/ges-video-source.c
new file mode 100644 (file)
index 0000000..cfdac94
--- /dev/null
@@ -0,0 +1,115 @@
+/* GStreamer Editing Services
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ *               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 (file)
index 0000000..0e1bd44
--- /dev/null
@@ -0,0 +1,90 @@
+/* GStreamer Editing Services
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ *               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 <glib-object.h>
+#include <gst/gst.h>
+#include <ges/ges-types.h>
+#include <ges/ges-track-element.h>
+#include <ges/ges-source.h>
+
+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 */
index b7405c1fb28f60b9fbfcc00372255eb72d3fb359..77a111e18ea5d2151c58fcce6dccf6689551ee00 100644 (file)
@@ -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);
 }
 
 /**
index ecfa870fb829f08a7bf1982434ec39cd35e2e225..b6245c4d5c81583f3db7c845a587d697769f81ae 100644 (file)
@@ -24,7 +24,7 @@
 #include <glib-object.h>
 #include <ges/ges-enums.h>
 #include <ges/ges-types.h>
-#include <ges/ges-source.h>
+#include <ges/ges-video-source.h>
 
 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 (file)
index 0000000..0acd7f9
--- /dev/null
@@ -0,0 +1,191 @@
+/* GStreamer Editing Services
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ *               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 (file)
index 0000000..7fb5862
--- /dev/null
@@ -0,0 +1,79 @@
+/* GStreamer Editing Services
+ * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
+ *               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 <glib-object.h>
+#include <ges/ges-types.h>
+#include <ges/ges-video-source.h>
+
+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 */
+
index b1cee92854f5cac875ee836ba6474126be3d27fa..1868248da8a5b7ef3bb0a227182878b5a6a4572f 100644 (file)
--- a/ges/ges.h
+++ b/ges/ges.h
@@ -60,7 +60,8 @@
 #include <ges/ges-source.h>
 #include <ges/ges-operation.h>
 
-#include <ges/ges-uri-source.h>
+#include <ges/ges-video-uri-source.h>
+#include <ges/ges-audio-uri-source.h>
 #include <ges/ges-image-source.h>
 #include <ges/ges-video-test-source.h>
 #include <ges/ges-audio-test-source.h>
index 0c77748d296a80d46590b00fd291c93433b5a9a0..09dfb4ed80bedeb453ddf1d11fada752772da3ab 100644 (file)
@@ -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);