Merge pull request #48 from myungjoo/support/gstcaps

Allow editing GstCaps properties
This commit is contained in:
dabrain34 2018-11-16 10:28:55 +01:00 committed by GitHub
commit ba121a74d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -130,10 +130,11 @@ ElementProperties::addParamSimple (GParamSpec *param, GstElement *element,
QString propertyName = g_param_spec_get_name (param); QString propertyName = g_param_spec_get_name (param);
QString propertyValue; QString propertyValue;
GType type = G_VALUE_TYPE (&value);
bool skip = false; bool skip = false;
switch (G_VALUE_TYPE (&value)) { switch (type) {
case G_TYPE_STRING: { case G_TYPE_STRING: {
const char *string_val = g_value_get_string (&value); const char *string_val = g_value_get_string (&value);
propertyValue = string_val; propertyValue = string_val;
@ -186,6 +187,16 @@ ElementProperties::addParamSimple (GParamSpec *param, GstElement *element,
} }
default: { default: {
if (type == g_type_from_name("GstCaps")) {
GstCaps *gstcaps;
g_object_get (G_OBJECT (element), param->name, &gstcaps, NULL);
const char *string_val = gst_caps_to_string (gstcaps);
if (gstcaps == NULL)
string_val = "ANY";
propertyValue = string_val;
break;
}
skip = true; skip = true;
LOG_INFO("property %s not supported", propertyName.toStdString ().c_str ()); LOG_INFO("property %s not supported", propertyName.toStdString ().c_str ());
break; break;
@ -310,7 +321,8 @@ ElementProperties::applyClicked ()
} }
} }
else { else {
switch (param->value_type) { GType type = param->value_type;
switch (type) {
case G_TYPE_STRING: { case G_TYPE_STRING: {
g_object_set (G_OBJECT (element), propName, g_object_set (G_OBJECT (element), propName,
valStr.toStdString ().c_str (), NULL); valStr.toStdString ().c_str (), NULL);
@ -372,6 +384,20 @@ ElementProperties::applyClicked ()
break; break;
} }
default: { default: {
if (type == g_type_from_name("GstCaps")) {
GstCaps *oldval;
GstCaps *newval = gst_caps_from_string (valStr.toStdString ().c_str ());
g_object_get (G_OBJECT (element), propName, &oldval, NULL);
if (oldval != newval && oldval != NULL) {
/* Release old */
gst_caps_unref (oldval);
}
g_object_set (G_OBJECT (element), propName, newval, NULL);
break;
}
LOG_INFO("property %s not supported", itr.key ()); LOG_INFO("property %s not supported", itr.key ());
break; break;
} }