mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
discoverer: query seekability
Besides the duration we can also query the seekability of a stream. Use the new API in the gst-discoverer tool. API: gst_discoverer_info_get_seekable
This commit is contained in:
parent
da70200ea5
commit
4e8956c9f1
6 changed files with 49 additions and 8 deletions
|
@ -897,6 +897,17 @@ gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
|
|||
|
||||
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
|
||||
|
|
|
@ -105,6 +105,9 @@ struct _GstDiscovererPrivate
|
|||
GMainContext *ctx;
|
||||
guint sourceid;
|
||||
guint timeoutid;
|
||||
|
||||
/* reusable queries */
|
||||
GstQuery *seeking_query;
|
||||
};
|
||||
|
||||
#define DISCO_LOCK(dc) g_mutex_lock (dc->priv->lock);
|
||||
|
@ -242,6 +245,7 @@ static void
|
|||
gst_discoverer_init (GstDiscoverer * dc)
|
||||
{
|
||||
GstElement *tmp;
|
||||
GstFormat format = GST_FORMAT_TIME;
|
||||
|
||||
dc->priv = G_TYPE_INSTANCE_GET_PRIVATE (dc, GST_TYPE_DISCOVERER,
|
||||
GstDiscovererPrivate);
|
||||
|
@ -284,6 +288,9 @@ gst_discoverer_init (GstDiscoverer * dc)
|
|||
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
|
||||
|
@ -322,6 +329,11 @@ gst_discoverer_dispose (GObject * obj)
|
|||
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
|
||||
|
@ -859,18 +871,31 @@ discoverer_collect (GstDiscoverer * dc)
|
|||
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)
|
||||
|
@ -894,8 +919,8 @@ discoverer_collect (GstDiscoverer * dc)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -179,6 +179,7 @@ GstDiscovererResult gst_discoverer_info_get_result(const GstDiscovererInfo
|
|||
GstDiscovererStreamInfo* gst_discoverer_info_get_stream_info(GstDiscovererInfo* info);
|
||||
GList* gst_discoverer_info_get_stream_list(GstDiscovererInfo* info);
|
||||
GstClockTime gst_discoverer_info_get_duration(const GstDiscovererInfo* info);
|
||||
gboolean gst_discoverer_info_get_seekable(const GstDiscovererInfo* info);
|
||||
const GstStructure* gst_discoverer_info_get_misc(const GstDiscovererInfo* info);
|
||||
const GstTagList* gst_discoverer_info_get_tags(const GstDiscovererInfo* info);
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ struct _GstDiscovererInfo {
|
|||
GstClockTime duration;
|
||||
GstStructure *misc;
|
||||
GstTagList *tags;
|
||||
gboolean seekable;
|
||||
};
|
||||
|
||||
/* missing-plugins.c */
|
||||
|
|
|
@ -241,10 +241,12 @@ print_topology (GstDiscovererStreamInfo * info, gint depth)
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -296,8 +298,8 @@ print_info (GstDiscovererInfo * info, GError * err)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ EXPORTS
|
|||
gst_discoverer_info_get_duration
|
||||
gst_discoverer_info_get_misc
|
||||
gst_discoverer_info_get_result
|
||||
gst_discoverer_info_get_seekable
|
||||
gst_discoverer_info_get_stream_info
|
||||
gst_discoverer_info_get_stream_list
|
||||
gst_discoverer_info_get_streams
|
||||
|
|
Loading…
Reference in a new issue