* Boston, MA 02111-1307, USA.
*/
+/**
+ * SECTION:ges-timeline-filesource
+ * @short_description:
+ */
+
#include "ges-internal.h"
#include "ges-timeline-file-source.h"
#include "ges-timeline-source.h"
{
PROP_0,
PROP_URI,
- PROP_MUTE
+ PROP_MAX_DURATION,
+ PROP_MUTE,
+ PROP_SUPPORTED_FORMATS
};
static void
ges_tl_filesource_set_mute (GESTimelineFileSource * self, gboolean mute);
+static void
+ges_tl_filesource_set_max_duration (GESTimelineFileSource * self,
+ guint64 maxduration);
static GESTrackObject
* ges_tl_filesource_create_track_object (GESTimelineObject * obj,
case PROP_MUTE:
g_value_set_boolean (value, tfs->mute);
break;
+ case PROP_MAX_DURATION:
+ g_value_set_uint64 (value, tfs->maxduration);
+ break;
+ case PROP_SUPPORTED_FORMATS:
+ g_value_set_flags (value, tfs->supportedformats);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
case PROP_MUTE:
ges_tl_filesource_set_mute (tfs, g_value_get_boolean (value));
break;
+ case PROP_MAX_DURATION:
+ ges_tl_filesource_set_max_duration (tfs, g_value_get_uint64 (value));
+ break;
+ case PROP_SUPPORTED_FORMATS:
+ tfs->supportedformats = g_value_get_flags (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
/**
- * GESTimelineFileSource:uri
+ * GESTimelineFileSource:uri:
*
* The location of the file/resource to use.
*/
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
- * GESTimelineFileSource:mute
+ * GESTimelineFileSource: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));
+
+ /**
+ * GESTimelineFileSource:mute:
*
* Whether the sound will be played or not.
*/
g_param_spec_boolean ("mute", "Mute", "Mute audio track",
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ /**
+ * GESTimelineFileSource:supported-formats:
+ *
+ * Whether the sound will be played or not.
+ */
+ g_object_class_install_property (object_class, PROP_SUPPORTED_FORMATS,
+ g_param_spec_flags ("supported-formats", "Supported formats",
+ "Formats supported by the file", GES_TYPE_TRACK_TYPE,
+ GES_TRACK_TYPE_UNKNOWN, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
timobj_class->create_track_object = ges_tl_filesource_create_track_object;
timobj_class->need_fill_track = FALSE;
}
static void
ges_tl_filesource_init (GESTimelineFileSource * self)
{
+ /* Setting the duration to -1 by default. */
+ GES_TIMELINE_OBJECT (self)->duration = GST_CLOCK_TIME_NONE;
}
static void
}
}
+static void
+ges_tl_filesource_set_max_duration (GESTimelineFileSource * self,
+ guint64 maxduration)
+{
+ GESTimelineObject *object = GES_TIMELINE_OBJECT (self);
+
+ self->maxduration = maxduration;
+ if (object->duration == GST_CLOCK_TIME_NONE || object->duration == 0) {
+ /* If we don't have a valid duration, use the max duration */
+ g_object_set (self, "duration", self->maxduration - object->inpoint, NULL);
+ }
+}
+
static GESTrackObject *
ges_tl_filesource_create_track_object (GESTimelineObject * obj,
GESTrack * track)
GESTimelineFileSource *tfs = (GESTimelineFileSource *) obj;
GESTrackObject *res;
+ if (!(tfs->supportedformats & track->type)) {
+ GST_DEBUG ("We don't support this track format");
+ return NULL;
+ }
+
GST_DEBUG ("Creating a GESTrackFileSource");
/* FIXME : Implement properly ! */
fail_unless (g_ascii_strcasecmp (uri, TEST_URI) == 0);
g_free (uri);
+ /* Make sure no track object is created for an incompatible
+ * track. */
+ trackobject =
+ ges_timeline_object_create_track_object (GES_TIMELINE_OBJECT (source),
+ track);
+ fail_unless (trackobject == NULL);
+
+ /* Make sure the track object is created for a compatible track. */
+ g_object_set (source, "supported-formats", GES_TRACK_TYPE_CUSTOM, NULL);
trackobject =
ges_timeline_object_create_track_object (GES_TIMELINE_OBJECT (source),
track);
/* Set some properties */
g_object_set (object, "start", (guint64) 42, "duration", (guint64) 51,
- "in-point", (guint64) 12, NULL);
+ "in-point", (guint64) 12, "supported-formats", GES_TRACK_TYPE_AUDIO,
+ NULL);
assert_equals_uint64 (GES_TIMELINE_OBJECT_START (object), 42);
assert_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (object), 51);
assert_equals_uint64 (GES_TIMELINE_OBJECT_INPOINT (object), 12);