+2008-12-20 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+
+ * docs/gst/gstreamer-sections.txt:
+ * gst/gstquark.c:
+ * gst/gstquark.h:
+ * gst/gstquery.c: (gst_query_new_uri), (gst_query_set_uri),
+ (gst_query_parse_uri):
+ * gst/gstquery.h:
+ API: Add URI query type. This is useful to query the URI
+ of a sink/source element and can be used by demuxers that
+ need to get data from other files.
+ This query should go upstream by default.
+ Fixes bug #562949.
+ * plugins/elements/gstfdsink.c: (gst_fd_sink_query):
+ * plugins/elements/gstfdsrc.c: (gst_fd_src_class_init),
+ (gst_fd_src_query):
+ * plugins/elements/gstfilesink.c: (gst_file_sink_query):
+ * plugins/elements/gstfilesrc.c: (gst_file_src_class_init),
+ (gst_file_src_query):
+ Implement URI query.
+
2008-12-19 Alessandro Decina <alessandro.decina@collabora.co.uk>
* gst/gstghostpad.c:
gst_query_set_buffering_range
gst_query_parse_buffering_range
+gst_query_new_uri
+gst_query_parse_uri
+gst_query_set_uri
<SUBSECTION Standard>
GstQueryClass
GST_QUERY
"max-latency", "busy", "type", "owner", "update", "applied-rate",
"start", "stop", "minsize", "maxsize", "async", "proportion",
"diff", "timestamp", "flags", "cur-type", "cur", "stop-type",
- "latency"
+ "latency", "uri"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
GST_QUARK_CUR = 48,
GST_QUARK_STOP_TYPE = 49,
GST_QUARK_LATENCY = 50,
+ GST_QUARK_URI = 51,
- GST_QUARK_MAX = 51
+ GST_QUARK_MAX = 52
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
#include "gstvalue.h"
#include "gstenumtypes.h"
#include "gstquark.h"
+#include "gsturi.h"
GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
#define GST_CAT_DEFAULT gst_query_debug
{GST_QUERY_FORMATS, "formats", "Supported formats for conversion", 0},
{GST_QUERY_BUFFERING, "buffering", "Buffering status", 0},
{GST_QUERY_CUSTOM, "custom", "Custom query", 0},
+ {GST_QUERY_URI, "uri", "URI of the source or sink", 0},
{0, NULL, NULL, 0}
};
g_value_get_int64 (gst_structure_id_get_value (structure,
GST_QUARK (ESTIMATED_TOTAL)));
}
+
+/**
+ * gst_query_new_uri:
+ *
+ * Constructs a new query URI query object. Use gst_query_unref()
+ * when done with it. An URI query is used to query the current URI
+ * that is used by the source or sink.
+ *
+ * Returns: A #GstQuery
+ *
+ * Since: 0.10.22
+ */
+GstQuery *
+gst_query_new_uri (void)
+{
+ GstQuery *query;
+ GstStructure *structure;
+
+ structure = gst_structure_empty_new ("GstQueryURI");
+ gst_structure_id_set (structure, GST_QUARK (URI), G_TYPE_STRING, NULL, NULL);
+
+ query = gst_query_new (GST_QUERY_URI, structure);
+
+ return query;
+}
+
+/**
+ * gst_query_set_uri:
+ * @query: a #GstQuery with query type GST_QUERY_URI
+ * @uri: the URI to set
+ *
+ * Answer a URI query by setting the requested URI.
+ *
+ * Since: 0.10.22
+ */
+void
+gst_query_set_uri (GstQuery * query, const gchar * uri)
+{
+ GstStructure *structure;
+
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_URI);
+ g_return_if_fail (gst_uri_is_valid (uri));
+
+ structure = gst_query_get_structure (query);
+ gst_structure_id_set (structure, GST_QUARK (URI), G_TYPE_STRING, uri, NULL);
+}
+
+/**
+ * gst_query_parse_uri:
+ * @query: a #GstQuery
+ * @uri: the storage for the current URI (may be NULL)
+ *
+ * Parse an URI query, writing the URI into @uri as a newly
+ * allocated string, if the respective parameters are non-NULL.
+ * Free the string with g_free() after usage.
+ *
+ * Since: 0.10.22
+ */
+void
+gst_query_parse_uri (GstQuery * query, gchar ** uri)
+{
+ GstStructure *structure;
+
+ g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_URI);
+
+ structure = gst_query_get_structure (query);
+ if (uri)
+ *uri = g_value_dup_string (gst_structure_id_get_value (structure,
+ GST_QUARK (URI)));
+}
* 0.10.20.
* @GST_QUERY_CUSTOM: a custom application or element defined query. Since
* 0.10.22.
+ * @GST_QUERY_URI: query the URI of the source or sink. Since 0.10.22.
*
* Standard predefined Query types
*/
GST_QUERY_CONVERT,
GST_QUERY_FORMATS,
GST_QUERY_BUFFERING,
- GST_QUERY_CUSTOM
+ GST_QUERY_CUSTOM,
+ GST_QUERY_URI
} GstQueryType;
/**
void gst_query_parse_buffering_range (GstQuery *query, GstFormat *format,
gint64 *start, gint64 *stop,
gint64 *estimated_total);
+/* URI query */
+GstQuery * gst_query_new_uri (void);
+void gst_query_parse_uri (GstQuery *query, gchar **uri);
+void gst_query_set_uri (GstQuery *query, const gchar *uri);
G_END_DECLS
gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
return TRUE;
+ case GST_QUERY_URI:
+ gst_query_set_uri (query, fdsink->uri);
+ return TRUE;
+
default:
return gst_pad_query_default (pad, query);
}
{
return GST_URI_SINK;
}
+
static gchar **
gst_fd_sink_uri_get_protocols (void)
{
return protocols;
}
+
static const gchar *
gst_fd_sink_uri_get_uri (GstURIHandler * handler)
{
static gboolean gst_fd_src_is_seekable (GstBaseSrc * bsrc);
static gboolean gst_fd_src_get_size (GstBaseSrc * src, guint64 * size);
static gboolean gst_fd_src_do_seek (GstBaseSrc * src, GstSegment * segment);
+static gboolean gst_fd_src_query (GstBaseSrc * src, GstQuery * query);
static GstFlowReturn gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf);
gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_fd_src_is_seekable);
gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_fd_src_get_size);
gstbasesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_fd_src_do_seek);
+ gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_fd_src_query);
gstpush_src_class->create = GST_DEBUG_FUNCPTR (gst_fd_src_create);
}
}
static gboolean
+gst_fd_src_query (GstBaseSrc * basesrc, GstQuery * query)
+{
+ gboolean ret = FALSE;
+ GstFdSrc *src = GST_FD_SRC (basesrc);
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_URI:
+ gst_query_set_uri (query, src->uri);
+ ret = TRUE;
+ break;
+ default:
+ ret = FALSE;
+ break;
+ }
+
+ if (!ret)
+ ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
+
+ return ret;
+}
+
+static gboolean
gst_fd_src_is_seekable (GstBaseSrc * bsrc)
{
GstFdSrc *src = GST_FD_SRC (bsrc);
return FALSE;
}
}
+
static void
gst_file_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
return TRUE;
+ case GST_QUERY_URI:
+ gst_query_set_uri (query, self->uri);
+ return TRUE;
+
default:
return gst_pad_query_default (pad, query);
}
{
return GST_URI_SINK;
}
+
static gchar **
gst_file_sink_uri_get_protocols (void)
{
return protocols;
}
+
static const gchar *
gst_file_sink_uri_get_uri (GstURIHandler * handler)
{
static gboolean gst_file_src_get_size (GstBaseSrc * src, guint64 * size);
static GstFlowReturn gst_file_src_create (GstBaseSrc * src, guint64 offset,
guint length, GstBuffer ** buffer);
+static gboolean gst_file_src_query (GstBaseSrc * src, GstQuery * query);
static void gst_file_src_uri_handler_init (gpointer g_iface,
gpointer iface_data);
gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_file_src_is_seekable);
gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_file_src_get_size);
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_file_src_create);
+ gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_file_src_query);
if (sizeof (off_t) < 8) {
GST_LOG ("No large file support, sizeof (off_t) = %" G_GSIZE_FORMAT "!",
}
static gboolean
+gst_file_src_query (GstBaseSrc * basesrc, GstQuery * query)
+{
+ gboolean ret = FALSE;
+ GstFileSrc *src = GST_FILE_SRC (basesrc);
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_URI:
+ gst_query_set_uri (query, src->uri);
+ ret = TRUE;
+ break;
+ default:
+ ret = FALSE;
+ break;
+ }
+
+ if (!ret)
+ ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
+
+ return ret;
+}
+
+static gboolean
gst_file_src_is_seekable (GstBaseSrc * basesrc)
{
GstFileSrc *src = GST_FILE_SRC (basesrc);