logger.entering("GObject", "set", new Object[] { property, data });
GObjectAPI.GParamSpec propertySpec = findProperty(property);
if (propertySpec == null) {
throw new IllegalArgumentException("Unknown property: " + property);
}
final GType propType = propertySpec.value_type;
GValue propValue = new GValue();
GVALUE_API.g_value_init(propValue, propType);
if (propType.equals(GType.INT)) {
GVALUE_API.g_value_set_int(propValue, intValue(data));
} else if (propType.equals(GType.UINT)) {
GVALUE_API.g_value_set_uint(propValue, intValue(data));
} else if (propType.equals(GType.CHAR)) {
GVALUE_API.g_value_set_char(propValue, (byte) intValue(data));
} else if (propType.equals(GType.UCHAR)) {
GVALUE_API.g_value_set_uchar(propValue, (byte) intValue(data));
} else if (propType.equals(GType.LONG)) {
GVALUE_API.g_value_set_long(propValue, new NativeLong(longValue(data)));
} else if (propType.equals(GType.ULONG)) {
GVALUE_API.g_value_set_ulong(propValue, new NativeLong(longValue(data)));
} else if (propType.equals(GType.INT64)) {
GVALUE_API.g_value_set_int64(propValue, longValue(data));
} else if (propType.equals(GType.UINT64)) {
GVALUE_API.g_value_set_uint64(propValue, longValue(data));
} else if (propType.equals(GType.BOOLEAN)) {
GVALUE_API.g_value_set_boolean(propValue, booleanValue(data));
} else if (propType.equals(GType.FLOAT)) {
GVALUE_API.g_value_set_float(propValue, floatValue(data));
} else if (propType.equals(GType.DOUBLE)) {
GVALUE_API.g_value_set_double(propValue, doubleValue(data));
} else if (propType.equals(GType.STRING)) {
//
// Special conversion of java URI to gstreamer compatible uri
//
if (data instanceof URI) {
URI uri = (URI) data;
String uriString = uri.toString();
// Need to fixup file:/ to be file:/// for gstreamer
if ("file".equals(uri.getScheme()) && uri.getHost() == null) {
final String path = uri.getRawPath();
uriString = "file://" + path;
}
GVALUE_API.g_value_set_string(propValue, uriString);
} else {
GVALUE_API.g_value_set_string(propValue, data.toString());
}
} else if (propType.equals(GType.OBJECT)) {
GVALUE_API.g_value_set_object(propValue, (GObject) data);
} else if (GVALUE_API.g_value_type_transformable(GType.INT64, propType)) {
transform(data, GType.INT64, propValue);
} else if (GVALUE_API.g_value_type_transformable(GType.LONG, propType)) {
transform(data, GType.LONG, propValue);