encoding-profile: Make (de)serialization functions public

This is more convenient and cheaper than going through the `g_value_convert()`
hoops

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6712>
This commit is contained in:
Edward Hervey 2024-04-23 07:23:30 +02:00 committed by GStreamer Marge Bot
parent b3c9f598aa
commit ad8c42ba06
3 changed files with 82 additions and 8 deletions

View file

@ -1733,6 +1733,23 @@ subtitles), are currently ignored.</doc>
</parameter>
</parameters>
</function>
<function name="from_string" c:identifier="gst_encoding_profile_from_string" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c">Converts a string in the "encoding profile serialization format" into a
GstEncodingProfile. Refer to the encoding-profile documentation for details
on the format.</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.h"/>
<return-value transfer-ownership="full">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c">A newly created GstEncodingProfile or NULL if the
input string is not a valid encoding profile serialization format.</doc>
<type name="EncodingProfile" c:type="GstEncodingProfile*"/>
</return-value>
<parameters>
<parameter name="string" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c">The string to convert into a GstEncodingProfile.</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
</parameters>
</function>
<method name="copy" c:identifier="gst_encoding_profile_copy" version="1.12">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c">Makes a deep copy of @self</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.h"/>
@ -2175,6 +2192,22 @@ single segment before the encoder, #FALSE otherwise.</doc>
</parameter>
</parameters>
</method>
<method name="to_string" c:identifier="gst_encoding_profile_to_string" version="1.26">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c">Converts a GstEncodingProfile to a string in the "Encoding Profile
serialization format".</doc>
<source-position filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.h"/>
<return-value transfer-ownership="full">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c">A string representation of the GstEncodingProfile,
or NULL if the input is invalid.</doc>
<type name="utf8" c:type="gchar*"/>
</return-value>
<parameters>
<instance-parameter name="profile" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c">The GstEncodingProfile to convert.</doc>
<type name="EncodingProfile" c:type="GstEncodingProfile*"/>
</instance-parameter>
</parameters>
</method>
<property name="element-properties" version="1.20" writable="1" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c">A #GstStructure defining the properties to be set to the element
the profile represents.

View file

@ -2068,8 +2068,21 @@ error:
goto done;
}
static GstEncodingProfile *
profile_from_string (const gchar * string)
/**
* gst_encoding_profile_from_string:
* @string: The string to convert into a GstEncodingProfile.
*
* Converts a string in the "encoding profile serialization format" into a
* GstEncodingProfile. Refer to the encoding-profile documentation for details
* on the format.
*
* Since: 1.26
*
* Returns: (transfer full): A newly created GstEncodingProfile or NULL if the
* input string is not a valid encoding profile serialization format.
*/
GstEncodingProfile *
gst_encoding_profile_from_string (const gchar * string)
{
GstEncodingProfile *profile;
gchar *filename_end;
@ -2117,7 +2130,7 @@ string_to_profile_transform (const GValue * src_value, GValue * dest_value)
profilename = g_value_get_string (src_value);
profile = profile_from_string (profilename);
profile = gst_encoding_profile_from_string (profilename);
if (profile)
g_value_take_object (dest_value, (GObject *) profile);
@ -2156,23 +2169,45 @@ serialize_profile (GString * res, GstEncodingProfile * profile)
}
}
static gchar *
gst_encoding_profile_serialize_valfunc (GValue * value)
/**
* gst_encoding_profile_to_string:
* @profile: (transfer none): The GstEncodingProfile to convert.
*
* Converts a GstEncodingProfile to a string in the "Encoding Profile
* serialization format".
*
* Since: 1.26
*
* Returns: (transfer full): A string representation of the GstEncodingProfile,
* or NULL if the input is invalid.
*/
gchar *
gst_encoding_profile_to_string (GstEncodingProfile * profile)
{
GString *res = g_string_new (NULL);
GstEncodingProfile *profile = g_value_get_object (value);
GString *res;
g_return_val_if_fail (profile != NULL, NULL);
res = g_string_new (NULL);
serialize_profile (res, profile);
return g_string_free (res, FALSE);
}
static gchar *
gst_encoding_profile_serialize_valfunc (GValue * value)
{
GstEncodingProfile *profile = g_value_get_object (value);
return gst_encoding_profile_to_string (profile);
}
static gboolean
gst_encoding_profile_deserialize_valfunc (GValue * value, const gchar * s)
{
GstEncodingProfile *profile;
profile = profile_from_string (s);
profile = gst_encoding_profile_from_string (s);
if (profile) {
g_value_take_object (value, (GObject *) profile);

View file

@ -266,6 +266,12 @@ GstEncodingProfile * gst_encoding_profile_from_discoverer (GstDiscovererInfo *in
GST_PBUTILS_API
GstEncodingProfile * gst_encoding_profile_copy (GstEncodingProfile *self);
GST_PBUTILS_API
GstEncodingProfile * gst_encoding_profile_from_string (const gchar *string);
GST_PBUTILS_API
gchar * gst_encoding_profile_to_string (GstEncodingProfile *profile);
GST_PBUTILS_API
void gst_encoding_profile_set_element_properties (GstEncodingProfile *self,
GstStructure *element_properties);