gst-editing-services: ges: Add a maxduration property to TrackFileSource

Thibault Saunier tsaunier at kemper.freedesktop.org
Wed Jan 11 07:04:35 PST 2012


Module: gst-editing-services
Branch: master
Commit: 4acc711e52f566f3b92a63575d0e79cf6c4c1d22
URL:    http://cgit.freedesktop.org/gstreamer/gst-editing-services/commit/?id=4acc711e52f566f3b92a63575d0e79cf6c4c1d22

Author: Thibault Saunier <thibault.saunier at collabora.com>
Date:   Thu Dec 29 13:56:08 2011 +0100

ges: Add a maxduration property to TrackFileSource

API: GESTrackFileSource::maxduration property

---

 ges/ges-timeline-file-source.c |   10 ++++++++++
 ges/ges-timeline.c             |    5 ++++-
 ges/ges-track-filesource.c     |   25 ++++++++++++++++++++++---
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/ges/ges-timeline-file-source.c b/ges/ges-timeline-file-source.c
index 185e358..b706d32 100644
--- a/ges/ges-timeline-file-source.c
+++ b/ges/ges-timeline-file-source.c
@@ -233,6 +233,7 @@ ges_timeline_filesource_set_max_duration (GESTimelineFileSource * self,
     guint64 maxduration)
 {
   GESTimelineObject *object = GES_TIMELINE_OBJECT (self);
+  GList *tmp, *tckobjs;
 
   self->priv->maxduration = maxduration;
   if (object->duration == GST_CLOCK_TIME_NONE || object->duration == 0) {
@@ -240,6 +241,15 @@ ges_timeline_filesource_set_max_duration (GESTimelineFileSource * self,
     g_object_set (self, "duration", self->priv->maxduration - object->inpoint,
         NULL);
   }
+
+  tckobjs = ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (self));
+  for (tmp = tckobjs; tmp; tmp = g_list_next (tmp)) {
+    g_object_set (tmp->data, "max-duration", maxduration, NULL);
+
+    /* We free the list in the same loop */
+    g_object_unref (tmp->data);
+    g_list_free_1 (tmp);
+  }
 }
 
 /**
diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c
index 1ba8508..4579f4a 100644
--- a/ges/ges-timeline.c
+++ b/ges/ges-timeline.c
@@ -579,7 +579,10 @@ discoverer_discovered_cb (GstDiscoverer * discoverer,
       g_object_set (tfs, "is_image", (gboolean) TRUE, NULL);
     }
 
-    else {
+    /* Continue the processing on tfs */
+    add_object_to_tracks (timeline, GES_TIMELINE_OBJECT (tfs));
+
+    if (!is_image) {
       g_object_set (tfs, "max-duration",
           gst_discoverer_info_get_duration (info), NULL);
     }
diff --git a/ges/ges-track-filesource.c b/ges/ges-track-filesource.c
index 85b9cb2..91b6c39 100644
--- a/ges/ges-track-filesource.c
+++ b/ges/ges-track-filesource.c
@@ -34,14 +34,14 @@ G_DEFINE_TYPE (GESTrackFileSource, ges_track_filesource, GES_TYPE_TRACK_SOURCE);
 
 struct _GESTrackFileSourcePrivate
 {
-  /*  Dummy variable */
-  void *nothing;
+  guint64 maxduration;
 };
 
 enum
 {
   PROP_0,
-  PROP_URI
+  PROP_URI,
+  PROP_MAX_DURATION
 };
 
 static void
@@ -54,6 +54,9 @@ ges_track_filesource_get_property (GObject * object, guint property_id,
     case PROP_URI:
       g_value_set_string (value, tfs->uri);
       break;
+    case PROP_MAX_DURATION:
+      g_value_set_uint64 (value, tfs->priv->maxduration);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
   }
@@ -69,6 +72,9 @@ ges_track_filesource_set_property (GObject * object, guint property_id,
     case PROP_URI:
       tfs->uri = g_value_dup_string (value);
       break;
+    case PROP_MAX_DURATION:
+      tfs->priv->maxduration = g_value_get_uint64 (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
   }
@@ -109,6 +115,19 @@ ges_track_filesource_class_init (GESTrackFileSourceClass * klass)
   object_class->dispose = ges_track_filesource_dispose;
 
   /**
+   * GESTrackFileSource:max-duration:
+   *
+   * The maximum duration (in nanoseconds) of the file.
+   *
+   * If not set before adding the object to a layer, it will be discovered
+   * asynchronously. Connect to 'notify::max-duration' to be notified of it.
+   */
+  g_object_class_install_property (object_class, PROP_MAX_DURATION,
+      g_param_spec_uint64 ("max-duration", "Maximum duration",
+          "The duration of the file", 0, G_MAXUINT64, GST_CLOCK_TIME_NONE,
+          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+  /**
    * GESTrackFileSource:uri
    *
    * The location of the file/resource to use.



More information about the gstreamer-commits mailing list