ges: Add a maxduration property to TrackFileSource
authorThibault Saunier <thibault.saunier@collabora.com>
Thu, 29 Dec 2011 12:56:08 +0000 (13:56 +0100)
committerThibault Saunier <thibault.saunier@collabora.com>
Wed, 11 Jan 2012 14:56:17 +0000 (11:56 -0300)
API: GESTrackFileSource::maxduration property

ges/ges-timeline-file-source.c
ges/ges-timeline.c
ges/ges-track-filesource.c

index 185e358..b706d32 100644 (file)
@@ -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);
+  }
 }
 
 /**
index 1ba8508..4579f4a 100644 (file)
@@ -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);
     }
index 85b9cb2..91b6c39 100644 (file)
@@ -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.