discoverer: Set number to stream infos

The idea is that we can reference to streams using this unique number,
within the context of that discoverer info. That number should always
be usable to reference the streams for a specific stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/897>
This commit is contained in:
Thibault Saunier 2021-02-09 19:56:49 -03:00 committed by GStreamer Marge Bot
parent 879526b2e2
commit 95c1f67d69
5 changed files with 36 additions and 5 deletions

View file

@ -50,7 +50,7 @@ G_DEFINE_TYPE (GstDiscovererStreamInfo, gst_discoverer_stream_info,
static void
gst_discoverer_stream_info_init (GstDiscovererStreamInfo * info)
{
/* Nothing needs initialization */
info->stream_number = -1;
}
static void
@ -143,6 +143,8 @@ gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
if (stream_map)
g_hash_table_insert (stream_map, info, ret);
ret->stream_number = info->stream_number;
return ret;
}
@ -718,6 +720,23 @@ gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
}
#endif
/**
* gst_discoverer_stream_info_get_stream_number:
* @info: a #GstDiscovererStreamInfo
*
* Returns: the stream number, -1 if no index could be determined. This property
* acts as a unique identifier as a 'int' for the stream.
*
* Since: 1.20
*/
gint
gst_discoverer_stream_info_get_stream_number (GstDiscovererStreamInfo * info)
{
g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), -1);
return info->stream_number;
}
/* GstDiscovererContainerInfo */
/**

View file

@ -1284,6 +1284,7 @@ parse_stream_topology (GstDiscoverer * dc, const GstStructure * topology,
}
if (add_to_list) {
res->stream_number = dc->priv->current_info->stream_count++;
dc->priv->current_info->stream_list =
g_list_append (dc->priv->current_info->stream_list, res);
} else {
@ -1476,9 +1477,13 @@ discoverer_collect (GstDiscoverer * dc)
else
dc->priv->current_info->live = TRUE;
if (dc->priv->current_topology)
if (dc->priv->current_topology) {
dc->priv->current_info->stream_count = 1;
dc->priv->current_info->stream_info = parse_stream_topology (dc,
dc->priv->current_topology, NULL);
if (dc->priv->current_info->stream_info)
dc->priv->current_info->stream_info->stream_number = 0;
}
/*
* Images need some special handling. They do not have a duration, have
@ -2385,8 +2390,9 @@ _parse_discovery (GVariant * variant, GstDiscovererInfo * info)
_parse_common_stream_info (sinfo, g_variant_get_child_value (common, 0),
info);
if (!GST_IS_DISCOVERER_CONTAINER_INFO (sinfo))
if (!GST_IS_DISCOVERER_CONTAINER_INFO (sinfo)) {
info->stream_list = g_list_append (info->stream_list, sinfo);
}
if (!info->stream_info) {
info->stream_info = sinfo;

View file

@ -84,6 +84,9 @@ const GstStructure* gst_discoverer_stream_info_get_misc(GstDiscovererStream
GST_PBUTILS_API
const gchar * gst_discoverer_stream_info_get_stream_type_nick(GstDiscovererStreamInfo* info);
GST_PBUTILS_API
gint gst_discoverer_stream_info_get_stream_number(GstDiscovererStreamInfo *info);
/**
* GstDiscovererContainerInfo:
*

View file

@ -31,6 +31,7 @@ struct _GstDiscovererStreamInfo {
GstToc *toc;
gchar *stream_id;
GstStructure *misc;
gint stream_number;
};
struct _GstDiscovererContainerInfo {
@ -97,6 +98,8 @@ struct _GstDiscovererInfo {
gboolean seekable;
GPtrArray *missing_elements_details;
gint stream_count;
gchar *cachefile;
gpointer from_cache;
};

View file

@ -367,9 +367,9 @@ print_stream_info (GstDiscovererStreamInfo * info, void *depth)
gst_caps_unref (caps);
}
g_print ("%*s%s: %s\n", 2 * GPOINTER_TO_INT (depth), " ",
g_print ("%*s%s #%d: %s\n", 2 * GPOINTER_TO_INT (depth), " ",
gst_discoverer_stream_info_get_stream_type_nick (info),
GST_STR_NULL (desc));
gst_discoverer_stream_info_get_stream_number (info), GST_STR_NULL (desc));
if (desc) {
g_free (desc);