pbutils: Missing plugin messages can contain the stream-id

In order to help users and applications, allow setting the stream-id for which
there is a missing plugin.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6886>
This commit is contained in:
Edward Hervey 2024-05-21 10:53:50 +02:00 committed by GStreamer Marge Bot
parent 96cf3d7063
commit c987eaa427
4 changed files with 84 additions and 0 deletions

View file

@ -4763,6 +4763,37 @@ installation mechanisms using one of the two above-mentioned functions.</doc>
</parameter> </parameter>
</parameters> </parameters>
</function> </function>
<function name="missing_plugin_message_get_stream_id" c:identifier="gst_missing_plugin_message_get_stream_id" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c">Get the stream-id of the stream for which an element is missing.</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.h"/>
<return-value transfer-ownership="none" nullable="1">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c">The stream-id or %NULL if none is specified.</doc>
<type name="utf8" c:type="const gchar*"/>
</return-value>
<parameters>
<parameter name="msg" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c">A missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT</doc>
<type name="Gst.Message" c:type="GstMessage*"/>
</parameter>
</parameters>
</function>
<function name="missing_plugin_message_set_stream_id" c:identifier="gst_missing_plugin_message_set_stream_id" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c">Set the stream-id of the stream for which an element is missing.</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.h"/>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="msg" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c">A missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT</doc>
<type name="Gst.Message" c:type="GstMessage*"/>
</parameter>
<parameter name="stream_id" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c">The stream id for which an element is missing</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
</parameters>
</function>
<function name="missing_uri_sink_installer_detail_new" c:identifier="gst_missing_uri_sink_installer_detail_new"> <function name="missing_uri_sink_installer_detail_new" c:identifier="gst_missing_uri_sink_installer_detail_new">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c">Returns an opaque string containing all the details about the missing <doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/missing-plugins.c">Returns an opaque string containing all the details about the missing
element to be passed to an external installer called via element to be passed to an external installer called via

View file

@ -518,6 +518,49 @@ error:
} }
} }
/**
* gst_missing_plugin_message_set_stream_id:
* @msg: A missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT
* @stream_id: The stream id for which an element is missing
*
* Set the stream-id of the stream for which an element is missing.
*
* Since: 1.26
*/
void
gst_missing_plugin_message_set_stream_id (GstMessage * msg,
const gchar * stream_id)
{
const GstStructure *structure;
g_return_if_fail (gst_is_missing_plugin_message (msg));
structure = gst_message_get_structure (msg);
gst_structure_set ((GstStructure *) structure, "stream-id", G_TYPE_STRING,
stream_id, NULL);
}
/**
* gst_missing_plugin_message_get_stream_id:
* @msg: A missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT
*
* Get the stream-id of the stream for which an element is missing.
*
* Since: 1.26
*
* Returns: (nullable): The stream-id or %NULL if none is specified.
*/
const gchar *
gst_missing_plugin_message_get_stream_id (GstMessage * msg)
{
const GstStructure *structure;
g_return_val_if_fail (gst_is_missing_plugin_message (msg), NULL);
structure = gst_message_get_structure (msg);
return gst_structure_get_string (structure, "stream-id");
}
/** /**
* gst_missing_plugin_message_get_description: * gst_missing_plugin_message_get_description:
* @msg: a missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT * @msg: a missing-plugin #GstMessage of type #GST_MESSAGE_ELEMENT

View file

@ -49,6 +49,13 @@ GST_PBUTILS_API
GstMessage * gst_missing_encoder_message_new (GstElement * element, GstMessage * gst_missing_encoder_message_new (GstElement * element,
const GstCaps * encode_caps); const GstCaps * encode_caps);
GST_PBUTILS_API
void gst_missing_plugin_message_set_stream_id(GstMessage *msg,
const gchar *stream_id);
GST_PBUTILS_API
const gchar *gst_missing_plugin_message_get_stream_id (GstMessage *msg);
/* /*
* functions for use by applications when dealing with missing-plugin messages * functions for use by applications when dealing with missing-plugin messages
*/ */

View file

@ -199,6 +199,7 @@ GST_START_TEST (test_pb_utils_post_missing_messages)
msg = gst_missing_decoder_message_new (pipeline, caps); msg = gst_missing_decoder_message_new (pipeline, caps);
fail_unless (msg != NULL); fail_unless (msg != NULL);
fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT); fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
gst_missing_plugin_message_set_stream_id (msg, "teststreamid");
fail_unless (gst_message_get_structure (msg) != NULL); fail_unless (gst_message_get_structure (msg) != NULL);
s = gst_message_get_structure (msg); s = gst_message_get_structure (msg);
fail_unless (gst_structure_has_name (s, "missing-plugin")); fail_unless (gst_structure_has_name (s, "missing-plugin"));
@ -207,6 +208,8 @@ GST_START_TEST (test_pb_utils_post_missing_messages)
fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS)); fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
fail_unless (gst_structure_has_field_typed (s, "name", G_TYPE_STRING)); fail_unless (gst_structure_has_field_typed (s, "name", G_TYPE_STRING));
fail_unless (gst_structure_get_string (s, "name") != NULL); fail_unless (gst_structure_get_string (s, "name") != NULL);
fail_unless_equals_string (gst_missing_plugin_message_get_stream_id (msg),
"teststreamid");
missing_msg_check_getters (msg); missing_msg_check_getters (msg);
gst_message_unref (msg); gst_message_unref (msg);