<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<div class="moz-cite-prefix">gst_parse_launch() uses
gst_util_set_object_arg(): <a moz-do-not-send="true"
href="https://gstreamer.freedesktop.org/documentation/gstreamer/gstutils.html?gi-language=c#gst_util_set_object_arg">https://gstreamer.freedesktop.org/documentation/gstreamer/gstutils.html?gi-language=c#gst_util_set_object_arg</a><br>
<br>
On 23/7/20 8:00 pm, Gary Metalle wrote:<br>
</div>
<blockquote type="cite" cite="mid:1595498420198.76176@rvl.co.uk">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
<p>Is there a way to set a property value from a given string, i.e
convert from G_STRING to whatever type is required for that
property?<br>
</p>
<p><br>
</p>
<p>I have a string such as the following:<br>
</p>
<p><br>
</p>
<p>"byte-stream=TRUE rc-lookahead=0 tune=zerolatency
speed-preset=ultrafast sync-lookahead=0"<br>
</p>
<p><br>
</p>
<p>That I split up into name/value pairs and then need to set each
property.<br>
</p>
<p><br>
</p>
<p>I first use g_object_class_find_property() to find out if the
named property exists and this is ok and it returns a GParamSpec
which tells me the type of the property.<br>
</p>
<p><br>
</p>
<p>I've tried using g_value_transform() but this only seems to be
able to cope with simple stuff like converting a double to an
int etc. Is there no simple way to convert say a string of
"TRUE" to a gboolean?<br>
</p>
<p>I have also tried g_param_convert() but didn't get anywhere
with that either.<br>
</p>
<p><br>
</p>
<p>Someone must be doing it somehow because if you pass a
pipeline string to gst_parse_launch() then it has to cope with
this. It would be easy to custom write something for
"TRUE"/"FALSE" to gboolean but not so for the enum types and the
x264enc plugin has quite a few of those.<br>
</p>
<p><br>
</p>
<p>On a positive note I think g_param_value_validate() works when
you want to check that a given value is within the range for the
defined property, but it implies you've converted it to the
correct type first.<br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>