[gst-devel] string transforms for GObject properties

daniel fischer dan at f3c.com
Wed Apr 28 02:26:02 CEST 2004


hi there,

i'm experimenting with special property types for some elements. in a nutshell, i would like to specify positions and areas not with 2 or 4 properties each (x/y, resp x1,y1,x2,y2), but a single one , eg like so:
 gst-launch myelement roi=10,10,310,230

glib has a mechanism to register value transform functions, so i think it would be nice if i'd supply those to_string and from_string for my 'proprietary' properties, and gstreamer would just use those when setting the element's properties from gst-launch.

you'd probably agree that this kind of functionality belongs to glib, not gstreamer, but the core has quite some functions for converting strings to GValues, so i'm submitting this here first (i'm thinking about a post to gtk-list about this too to see what they think. if they'd supply conversion routines to/from string, gst core could spare quite some lines of ugly code).

adding a few lines for the 'default:' case in gst_parse_element_set in gst/parse/grammar.y does the trick for me quite nicely (line ~313):
if( g_value_type_transformable( G_TYPE_STRING, G_PARAM_SPEC_VALUE_TYPE (pspec) ) ) {
	g_value_init( &v2, G_TYPE_STRING );
	g_value_set_string( &v2, pos );
	if (!g_value_transform (&v2, &v)) goto error_conversion;
} else {
	  g_warning ("property \"%s\" in element %s cannot be set", value, GST_ELEMENT_NAME (element)); 
	  goto error;
}

i'm currenly unsure if this works if the transform func is registered with a plugin_init, i'm doing it within my app, before i initialize gst.

if you regard it as cool i would check it out a little further and submit a patch in bugzilla... so what do you think? and about the property issue in general?

regards,
-dan

-- 
dan at f3c.com
http://f3c.com/dan/





More information about the gstreamer-devel mailing list