DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
/**
+ * gst_discoverer_info_get_seekable:
+ * @info: a #GstDiscovererInfo
+ *
+ * Returns: the wheter the URI is seekable.
+ *
+ * Since: 0.10.32
+ */
+
+DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
+
+/**
* gst_discoverer_info_get_misc:
* @info: a #GstDiscovererInfo
*
GMainContext *ctx;
guint sourceid;
guint timeoutid;
+
+ /* reusable queries */
+ GstQuery *seeking_query;
};
#define DISCO_LOCK(dc) g_mutex_lock (dc->priv->lock);
gst_discoverer_init (GstDiscoverer * dc)
{
GstElement *tmp;
+ GstFormat format = GST_FORMAT_TIME;
dc->priv = G_TYPE_INSTANCE_GET_PRIVATE (dc, GST_TYPE_DISCOVERER,
GstDiscovererPrivate);
tmp = gst_element_factory_make ("decodebin2", NULL);
dc->priv->decodebin2_type = G_OBJECT_TYPE (tmp);
gst_object_unref (tmp);
+
+ /* create queries */
+ dc->priv->seeking_query = gst_query_new_seeking (format);
}
static void
g_mutex_free (dc->priv->lock);
dc->priv->lock = NULL;
}
+
+ if (dc->priv->seeking_query) {
+ gst_query_unref (dc->priv->seeking_query);
+ dc->priv->seeking_query = NULL;
+ }
}
static void
if (dc->priv->streams) {
/* FIXME : Make this querying optional */
if (TRUE) {
+ GstElement *pipeline = (GstElement *) dc->priv->pipeline;
GstFormat format = GST_FORMAT_TIME;
gint64 dur;
GST_DEBUG ("Attempting to query duration");
- if (gst_element_query_duration ((GstElement *) dc->priv->pipeline,
- &format, &dur)) {
+ if (gst_element_query_duration (pipeline, &format, &dur)) {
if (format == GST_FORMAT_TIME) {
GST_DEBUG ("Got duration %" GST_TIME_FORMAT, GST_TIME_ARGS (dur));
dc->priv->current_info->duration = (guint64) dur;
}
}
+
+ if (dc->priv->seeking_query) {
+ if (gst_element_query (pipeline, dc->priv->seeking_query)) {
+ gboolean seekable;
+
+ gst_query_parse_seeking (dc->priv->seeking_query, &format,
+ &seekable, NULL, NULL);
+ if (format == GST_FORMAT_TIME) {
+ GST_DEBUG ("Got seekable %d", seekable);
+ dc->priv->current_info->seekable = seekable;
+ }
+ }
+ }
}
if (dc->priv->current_topology)
gst_caps_get_structure (dc->priv->current_info->stream_info->caps, 0);
if (g_str_has_prefix (gst_structure_get_name (st), "image/"))
- ((GstDiscovererVideoInfo *) dc->priv->current_info->
- stream_info)->is_image = TRUE;
+ ((GstDiscovererVideoInfo *) dc->priv->current_info->stream_info)->
+ is_image = TRUE;
}
}
}
static void
-print_duration (GstDiscovererInfo * info, gint tab)
+print_properties (GstDiscovererInfo * info, gint tab)
{
- g_print ("%*s%" GST_TIME_FORMAT "\n", tab + 1, " ",
+ g_print ("%*sDuration: %" GST_TIME_FORMAT "\n", tab + 1, " ",
GST_TIME_ARGS (gst_discoverer_info_get_duration (info)));
+ g_print ("%*sSeekable: %s\n", tab + 1, " ",
+ (gst_discoverer_info_get_seekable (info) ? "yes" : "no"));
}
static void
if ((sinfo = gst_discoverer_info_get_stream_info (info))) {
g_print ("\nTopology:\n");
print_topology (sinfo, 1);
- g_print ("\nDuration:\n");
- print_duration (info, 1);
+ g_print ("\nProperties:\n");
+ print_properties (info, 1);
gst_discoverer_stream_info_unref (sinfo);
}