mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
discoverer: Add support for getting the stream-id
https://bugzilla.gnome.org/show_bug.cgi?id=654830
This commit is contained in:
parent
e223e313b6
commit
15ee41dfc9
7 changed files with 74 additions and 1 deletions
|
@ -2388,6 +2388,7 @@ gst_discoverer_stream_info_get_next
|
|||
gst_discoverer_stream_info_get_previous
|
||||
gst_discoverer_stream_info_get_tags
|
||||
gst_discoverer_stream_info_get_toc
|
||||
gst_discoverer_stream_info_get_stream_id
|
||||
gst_discoverer_stream_info_ref
|
||||
gst_discoverer_stream_info_unref
|
||||
gst_discoverer_stream_info_list_free
|
||||
|
|
|
@ -70,6 +70,8 @@ gst_discoverer_stream_info_finalize (GObject * object)
|
|||
if (info->toc)
|
||||
gst_toc_unref (info->toc);
|
||||
|
||||
g_free (info->stream_id);
|
||||
|
||||
if (info->misc)
|
||||
gst_structure_free (info->misc);
|
||||
}
|
||||
|
@ -132,6 +134,9 @@ gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
|
|||
if (info->toc)
|
||||
ret->toc = gst_toc_ref (info->toc);
|
||||
|
||||
if (info->stream_id)
|
||||
ret->stream_id = g_strdup (info->stream_id);
|
||||
|
||||
if (info->misc)
|
||||
ret->misc = gst_structure_copy (info->misc);
|
||||
|
||||
|
@ -663,6 +668,21 @@ gst_discoverer_stream_info_get_toc (GstDiscovererStreamInfo * info)
|
|||
return info->toc;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_discoverer_stream_info_get_stream_id:
|
||||
* @info: a #GstDiscovererStreamInfo
|
||||
*
|
||||
* Returns: (transfer none): the stream ID of this stream. If you wish to
|
||||
* use the stream ID after the life-time of @info you will need to copy it.
|
||||
*/
|
||||
const gchar *
|
||||
gst_discoverer_stream_info_get_stream_id (GstDiscovererStreamInfo * info)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
|
||||
|
||||
return info->stream_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_discoverer_stream_info_get_misc:
|
||||
* @info: a #GstDiscovererStreamInfo
|
||||
|
|
|
@ -54,6 +54,7 @@ GST_DEBUG_CATEGORY_STATIC (discoverer_debug);
|
|||
static GQuark _CAPS_QUARK;
|
||||
static GQuark _TAGS_QUARK;
|
||||
static GQuark _TOC_QUARK;
|
||||
static GQuark _STREAM_ID_QUARK;
|
||||
static GQuark _MISSING_PLUGIN_QUARK;
|
||||
static GQuark _STREAM_TOPOLOGY_QUARK;
|
||||
static GQuark _TOPOLOGY_PAD_QUARK;
|
||||
|
@ -67,6 +68,7 @@ typedef struct
|
|||
GstElement *sink;
|
||||
GstTagList *tags;
|
||||
GstToc *toc;
|
||||
gchar *stream_id;
|
||||
} PrivateStream;
|
||||
|
||||
struct _GstDiscovererPrivate
|
||||
|
@ -134,7 +136,8 @@ _do_init (void)
|
|||
|
||||
_CAPS_QUARK = g_quark_from_static_string ("caps");
|
||||
_TAGS_QUARK = g_quark_from_static_string ("tags");
|
||||
_TOC_QUARK = g_quark_from_static_string ("toc");
|
||||
_TOC_QUARK = g_quark_from_static_string ("stream-id");
|
||||
_STREAM_ID_QUARK = g_quark_from_static_string ("toc");
|
||||
_MISSING_PLUGIN_QUARK = g_quark_from_static_string ("missing-plugin");
|
||||
_STREAM_TOPOLOGY_QUARK = g_quark_from_static_string ("stream-topology");
|
||||
_TOPOLOGY_PAD_QUARK = g_quark_from_static_string ("pad");
|
||||
|
@ -503,6 +506,15 @@ _event_probe (GstPad * pad, GstPadProbeInfo * info, PrivateStream * ps)
|
|||
DISCO_UNLOCK (ps->dc);
|
||||
break;
|
||||
}
|
||||
case GST_EVENT_STREAM_START:{
|
||||
const gchar *stream_id;
|
||||
|
||||
gst_event_parse_stream_start (event, &stream_id);
|
||||
|
||||
g_free (ps->stream_id);
|
||||
ps->stream_id = stream_id ? g_strdup (stream_id) : NULL;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -691,6 +703,7 @@ uridecodebin_pad_removed_cb (GstElement * uridecodebin, GstPad * pad,
|
|||
if (ps->toc) {
|
||||
gst_toc_unref (ps->toc);
|
||||
}
|
||||
g_free (ps->stream_id);
|
||||
|
||||
g_slice_free (PrivateStream, ps);
|
||||
|
||||
|
@ -725,6 +738,9 @@ collect_stream_information (GstDiscoverer * dc, PrivateStream * ps, guint idx)
|
|||
gst_structure_id_set (st, _TAGS_QUARK, GST_TYPE_TAG_LIST, ps->tags, NULL);
|
||||
if (ps->toc)
|
||||
gst_structure_id_set (st, _TOC_QUARK, GST_TYPE_TOC, ps->toc, NULL);
|
||||
if (ps->stream_id)
|
||||
gst_structure_id_set (st, _STREAM_ID_QUARK, G_TYPE_STRING, ps->stream_id,
|
||||
NULL);
|
||||
|
||||
return st;
|
||||
}
|
||||
|
@ -758,6 +774,7 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
|
|||
GstTagList *tags_st;
|
||||
GstToc *toc_st;
|
||||
const gchar *name;
|
||||
gchar *stream_id;
|
||||
int tmp;
|
||||
guint utmp;
|
||||
|
||||
|
@ -822,6 +839,12 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
|
|||
info->parent.toc = toc_st;
|
||||
}
|
||||
|
||||
if (gst_structure_id_has_field (st, _STREAM_ID_QUARK)) {
|
||||
gst_structure_id_get (st, _STREAM_ID_QUARK, G_TYPE_STRING, &stream_id,
|
||||
NULL);
|
||||
info->parent.stream_id = stream_id;
|
||||
}
|
||||
|
||||
if (!info->language && ((GstDiscovererStreamInfo *) info)->tags) {
|
||||
gchar *language;
|
||||
if (gst_tag_list_get_string (((GstDiscovererStreamInfo *) info)->tags,
|
||||
|
@ -881,6 +904,12 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
|
|||
info->parent.toc = toc_st;
|
||||
}
|
||||
|
||||
if (gst_structure_id_has_field (st, _STREAM_ID_QUARK)) {
|
||||
gst_structure_id_get (st, _STREAM_ID_QUARK, G_TYPE_STRING, &stream_id,
|
||||
NULL);
|
||||
info->parent.stream_id = stream_id;
|
||||
}
|
||||
|
||||
gst_caps_unref (caps);
|
||||
return (GstDiscovererStreamInfo *) info;
|
||||
|
||||
|
@ -914,6 +943,12 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
|
|||
info->parent.toc = toc_st;
|
||||
}
|
||||
|
||||
if (gst_structure_id_has_field (st, _STREAM_ID_QUARK)) {
|
||||
gst_structure_id_get (st, _STREAM_ID_QUARK, G_TYPE_STRING, &stream_id,
|
||||
NULL);
|
||||
info->parent.stream_id = stream_id;
|
||||
}
|
||||
|
||||
if (!info->language && ((GstDiscovererStreamInfo *) info)->tags) {
|
||||
gchar *language;
|
||||
if (gst_tag_list_get_string (((GstDiscovererStreamInfo *) info)->tags,
|
||||
|
@ -946,6 +981,11 @@ collect_information (GstDiscoverer * dc, const GstStructure * st,
|
|||
info->toc = toc_st;
|
||||
}
|
||||
|
||||
if (gst_structure_id_get (st, _STREAM_ID_QUARK, G_TYPE_STRING, &stream_id,
|
||||
NULL)) {
|
||||
info->stream_id = stream_id;
|
||||
}
|
||||
|
||||
gst_caps_unref (caps);
|
||||
return info;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ GstDiscovererStreamInfo* gst_discoverer_stream_info_get_next(GstDiscovererStream
|
|||
GstCaps* gst_discoverer_stream_info_get_caps(GstDiscovererStreamInfo* info);
|
||||
const GstTagList* gst_discoverer_stream_info_get_tags(GstDiscovererStreamInfo* info);
|
||||
const GstToc* gst_discoverer_stream_info_get_toc(GstDiscovererStreamInfo* info);
|
||||
const gchar* gst_discoverer_stream_info_get_stream_id(GstDiscovererStreamInfo* info);
|
||||
const GstStructure* gst_discoverer_stream_info_get_misc(GstDiscovererStreamInfo* info);
|
||||
const gchar * gst_discoverer_stream_info_get_stream_type_nick(GstDiscovererStreamInfo* info);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ struct _GstDiscovererStreamInfo {
|
|||
GstCaps *caps;
|
||||
GstTagList *tags;
|
||||
GstToc *toc;
|
||||
gchar *stream_id;
|
||||
GstStructure *misc;
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
|
|
|
@ -83,6 +83,9 @@ gst_stream_audio_information_to_string (GstDiscovererStreamInfo * info,
|
|||
my_g_string_append_printf (s, depth, " None\n");
|
||||
}
|
||||
|
||||
my_g_string_append_printf (s, depth, "Stream ID: %s\n",
|
||||
gst_discoverer_stream_info_get_stream_id (info));
|
||||
|
||||
audio_info = (GstDiscovererAudioInfo *) info;
|
||||
ctmp = gst_discoverer_audio_info_get_language (audio_info);
|
||||
my_g_string_append_printf (s, depth, "Language: %s\n",
|
||||
|
@ -147,6 +150,9 @@ gst_stream_video_information_to_string (GstDiscovererStreamInfo * info,
|
|||
my_g_string_append_printf (s, depth, " None\n");
|
||||
}
|
||||
|
||||
my_g_string_append_printf (s, depth, "Stream ID: %s\n",
|
||||
gst_discoverer_stream_info_get_stream_id (info));
|
||||
|
||||
video_info = (GstDiscovererVideoInfo *) info;
|
||||
my_g_string_append_printf (s, depth, "Width: %u\n",
|
||||
gst_discoverer_video_info_get_width (video_info));
|
||||
|
@ -218,6 +224,9 @@ gst_stream_subtitle_information_to_string (GstDiscovererStreamInfo * info,
|
|||
my_g_string_append_printf (s, depth, " None\n");
|
||||
}
|
||||
|
||||
my_g_string_append_printf (s, depth, "Stream ID: %s\n",
|
||||
gst_discoverer_stream_info_get_stream_id (info));
|
||||
|
||||
subtitle_info = (GstDiscovererSubtitleInfo *) info;
|
||||
ctmp = gst_discoverer_subtitle_info_get_language (subtitle_info);
|
||||
my_g_string_append_printf (s, depth, "Language: %s\n",
|
||||
|
|
|
@ -46,6 +46,7 @@ EXPORTS
|
|||
gst_discoverer_stream_info_get_misc
|
||||
gst_discoverer_stream_info_get_next
|
||||
gst_discoverer_stream_info_get_previous
|
||||
gst_discoverer_stream_info_get_stream_id
|
||||
gst_discoverer_stream_info_get_stream_type_nick
|
||||
gst_discoverer_stream_info_get_tags
|
||||
gst_discoverer_stream_info_get_toc
|
||||
|
|
Loading…
Reference in a new issue