static void _gst_param_fraction_init (GParamSpec * pspec) { GstParamSpecFraction *fspec = GST_PARAM_SPEC_FRACTION (pspec); fspec->min_num = 0; fspec->min_den = 1; fspec->max_num = G_MAXINT; fspec->max_den = 1; fspec->def_num = 1; fspec->def_den = 1; }
static gboolean _gst_param_fraction_validate (GParamSpec * pspec, GValue * value) { GstParamSpecFraction *fspec = GST_PARAM_SPEC_FRACTION (pspec); gboolean within_range = FALSE; GValue f_this = { 0, }; GValue f_min = { 0, }; GValue f_max = { 0, }; gint res; g_value_init (&f_this, GST_TYPE_FRACTION); gst_value_set_fraction (&f_this, value->data[0].v_int, value->data[1].v_int); g_value_init (&f_min, GST_TYPE_FRACTION); gst_value_set_fraction (&f_min, fspec->min_num, fspec->min_den); g_value_init (&f_max, GST_TYPE_FRACTION); gst_value_set_fraction (&f_max, fspec->max_num, fspec->max_den); res = gst_value_compare (&f_min, &f_this); #ifndef GST_DISABLE_GST_DEBUG GST_LOG ("comparing %d/%d to %d/%d, result = %d", fspec->min_num, fspec->min_den, value->data[0].v_int, value->data[1].v_int, res); #endif if (res != GST_VALUE_LESS_THAN && res != GST_VALUE_EQUAL) goto out; #ifndef GST_DISABLE_GST_DEBUG GST_LOG ("comparing %d/%d to %d/%d, result = %d", value->data[0].v_int, value->data[1].v_int, fspec->max_num, fspec->max_den, res); #endif res = gst_value_compare (&f_this, &f_max); if (res != GST_VALUE_LESS_THAN && res != GST_VALUE_EQUAL) goto out; within_range = TRUE; out: g_value_unset (&f_min); g_value_unset (&f_max); g_value_unset (&f_this); #ifndef GST_DISABLE_GST_DEBUG GST_LOG ("%swithin range", (within_range) ? "" : "not "); #endif /* return FALSE if everything ok, otherwise TRUE */ return !within_range; }
static void _gst_param_fraction_set_default (GParamSpec * pspec, GValue * value) { value->data[0].v_int = GST_PARAM_SPEC_FRACTION (pspec)->def_num; value->data[1].v_int = GST_PARAM_SPEC_FRACTION (pspec)->def_den; }
// make json formated description void Property::make_description() { if (nullptr == property_) { g_warning("%s: cannot make description from a nullptr property", __PRETTY_FUNCTION__); return; } GValue value = G_VALUE_INIT; g_value_init(&value, property_->value_type); g_object_get_property(object_, property_->name, &value); json_description_->reset(); json_description_->begin_object(); // long name json_description_->add_string_member("name", long_name_.c_str()); // name json_description_->add_string_member("id", name_.c_str()); // nickname // json_description_->add_string_member ("nickname", g_param_spec_get_nick (property_)); // short description json_description_->add_string_member("description", g_param_spec_get_blurb(property_)); json_description_->add_string_member("parent", get_category().c_str()); json_description_->add_int_member("order", get_position_weight()); // name // json_description_->add_string_member ("internal name", g_param_spec_get_name (property_)); if (property_->flags &G_PARAM_WRITABLE) json_description_->add_string_member("writable", "true"); else json_description_->add_string_member("writable", "false"); switch (G_VALUE_TYPE(&value)) { case G_TYPE_STRING: { const char *string_val = g_value_get_string(&value); json_description_->add_string_member("type", "string"); if (string_val == nullptr) json_description_->add_string_member("default value", ""); else json_description_->add_string_member("default value", string_val); break; } case G_TYPE_BOOLEAN: { gboolean bool_val = g_value_get_boolean(&value); json_description_->add_string_member("type", "boolean"); if (bool_val) json_description_->add_string_member("default value", "true"); else json_description_->add_string_member("default value", "false"); break; } case G_TYPE_ULONG: { GParamSpecULong *pulong = G_PARAM_SPEC_ULONG(property_); json_description_->add_string_member("type", "ulong"); gchar *min = g_strdup_printf("%lu", pulong->minimum); gchar *max = g_strdup_printf("%lu", pulong->maximum); gchar *default_value = g_strdup_printf("%lu", g_value_get_ulong(&value)); json_description_->add_string_member("minimum", min); json_description_->add_string_member("maximum", max); json_description_->add_string_member("default value", default_value); g_free(min); g_free(max); g_free(default_value); break; } case G_TYPE_LONG: { GParamSpecLong *plong = G_PARAM_SPEC_LONG(property_); gchar *min = g_strdup_printf("%ld", plong->minimum); gchar *max = g_strdup_printf("%ld", plong->maximum); gchar *default_value = g_strdup_printf("%ld", g_value_get_ulong(&value)); json_description_->add_string_member("type", "long"); json_description_->add_string_member("minimum", min); json_description_->add_string_member("maximum", max); json_description_->add_string_member("default value", default_value); g_free(min); g_free(max); g_free(default_value); break; } case G_TYPE_UINT: { GParamSpecUInt *puint = G_PARAM_SPEC_UINT(property_); gchar *min = g_strdup_printf("%u", puint->minimum); gchar *max = g_strdup_printf("%u", puint->maximum); gchar *default_value = g_strdup_printf("%u", g_value_get_uint(&value)); json_description_->add_string_member("type", "uint"); json_description_->add_string_member("minimum", min); json_description_->add_string_member("maximum", max); json_description_->add_string_member("default value", default_value); g_free(min); g_free(max); g_free(default_value); break; } case G_TYPE_INT: { GParamSpecInt *pint = G_PARAM_SPEC_INT(property_); gchar *min = g_strdup_printf("%d", pint->minimum); gchar *max = g_strdup_printf("%d", pint->maximum); gchar *default_value = g_strdup_printf("%d", g_value_get_int(&value)); json_description_->add_string_member("type", "int"); json_description_->add_string_member("minimum", min); json_description_->add_string_member("maximum", max); json_description_->add_string_member("default value", default_value); g_free(min); g_free(max); g_free(default_value); break; } case G_TYPE_UINT64: { GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64(property_); gchar *min = g_strdup_printf("%" G_GUINT64_FORMAT, puint64->minimum); gchar *max = g_strdup_printf("%" G_GUINT64_FORMAT, puint64->maximum); gchar *default_value = g_strdup_printf("%" G_GUINT64_FORMAT, g_value_get_uint64(&value)); json_description_->add_string_member("type", "uint64"); json_description_->add_string_member("minimum", min); json_description_->add_string_member("maximum", max); json_description_->add_string_member("default value", default_value); g_free(min); g_free(max); g_free(default_value); break; } case G_TYPE_INT64: { GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64(property_); gchar *min = g_strdup_printf("%" G_GINT64_FORMAT, pint64->minimum); gchar *max = g_strdup_printf("%" G_GINT64_FORMAT, pint64->maximum); gchar *default_value = g_strdup_printf("%" G_GINT64_FORMAT, g_value_get_int64(&value)); json_description_->add_string_member("type", "int64"); json_description_->add_string_member("minimum", min); json_description_->add_string_member("maximum", max); json_description_->add_string_member("default value", default_value); g_free(min); g_free(max); g_free(default_value); break; } case G_TYPE_FLOAT: { GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT(property_); gchar *min = g_strdup_printf("%.7g", pfloat->minimum); gchar *max = g_strdup_printf("%.7g", pfloat->maximum); gchar *default_value = g_strdup_printf("%.7g", g_value_get_float(&value)); json_description_->add_string_member("type", "float"); json_description_->add_string_member("minimum", min); json_description_->add_string_member("maximum", max); json_description_->add_string_member("default value", default_value); g_free(min); g_free(max); g_free(default_value); break; } case G_TYPE_DOUBLE: { GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE(property_); gchar *min = g_strdup_printf("%.7g", pdouble->minimum); gchar *max = g_strdup_printf("%.7g", pdouble->maximum); gchar *default_value = g_strdup_printf("%.7g", g_value_get_double(&value)); json_description_->add_string_member("type", "double"); json_description_->add_string_member("minimum", min); json_description_->add_string_member("maximum", max); json_description_->add_string_member("default value", default_value); g_free(min); g_free(max); g_free(default_value); break; } default: if (property_->value_type == GST_TYPE_CAPS) { const GstCaps *caps = gst_value_get_caps(&value); json_description_->add_string_member("type", "caps"); if (!caps) json_description_->add_string_member("default value", ""); else json_description_->add_string_member("default value", gst_caps_to_string(caps)); } else if (G_IS_PARAM_SPEC_ENUM(property_)) { GEnumValue *values; guint j = 0; gint enum_value; const gchar *value_nick = ""; const gchar *value_name = ""; json_description_->add_string_member("type", "enum"); values = G_ENUM_CLASS(g_type_class_ref(property_->value_type))->values; enum_value = g_value_get_enum(&value); while (values[j].value_name) { if (values[j].value == enum_value) { value_nick = values[j].value_nick; value_name = values[j].value_name; } j++; } json_description_->set_member_name("default value"); json_description_->begin_object(); gchar *value = g_strdup_printf("%d", enum_value); json_description_->add_string_member("value", value); g_free(value); json_description_->add_string_member("nick", value_nick); json_description_->add_string_member("name", value_name); json_description_->end_object(); // g_debug ("Enum \"%s\" Default: %d, \"%s\" \"%s\"", // g_type_name (G_VALUE_TYPE (&value)), // enum_value, // value_nick, // value_name); j = 0; json_description_->set_member_name("values"); json_description_->begin_array(); while (values[j].value_name) { json_description_->begin_object(); json_description_->add_string_member("name", values[j].value_name); json_description_->add_string_member("nick", values[j].value_nick); gchar *values_value = g_strdup_printf("%d", values[j].value); json_description_->add_string_member("value", values_value); g_free(values_value); json_description_->end_object(); j++; } json_description_->end_array(); /* g_type_class_unref (ec); */ } else if (G_IS_PARAM_SPEC_FLAGS(property_)) { g_debug("warning: param spec flags not handled"); // GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (property_); // GFlagsValue *vals; // gchar *cur; // vals = pflags->flags_class->values; // cur = flags_to_string (vals, g_value_get_flags (&value)); // g_debug ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "", // g_type_name (G_VALUE_TYPE (&value)), // g_value_get_flags (&value), cur); // while (vals[0].value_name) { // g_debug (""); // if (_name) // g_debug ("%s", _name); // g_debug ("%-23.23s (0x%08x): %-16s - %s", "", // vals[0].value, vals[0].value_nick, vals[0].value_name); // ++vals; // } // g_free (cur); } else if (G_IS_PARAM_SPEC_OBJECT(property_)) { g_debug("warning: param spec object not handled"); // g_debug ("%-23.23s Object of type \"%s\"", "", // g_type_name (property_->value_type)); } else if (G_IS_PARAM_SPEC_BOXED(property_)) { g_debug("warning: param spec boxed not handled"); // g_debug ("%-23.23s Boxed pointer of type \"%s\"", "", // g_type_name (property_->value_type)); } else if (G_IS_PARAM_SPEC_POINTER(property_)) { g_debug("warning: param spec pointer not handled"); // if (property_->value_type != G_TYPE_POINTER) { // g_debug ("%-23.23s Pointer of type \"%s\".", "", // g_type_name (property_->value_type)); // } else if (property_->value_type == G_TYPE_VALUE_ARRAY) { // GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (property_); // g_debug ("warning: array not handled"); // if (pvarray->element_spec) { // g_debug ("%-23.23s Array of GValues of type \"%s\"", "", // g_type_name (pvarray->element_spec->value_type)); // } else { // g_debug ("%-23.23s Array of GValues", ""); // } } else if (GST_IS_PARAM_SPEC_FRACTION(property_)) { GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION(property_); json_description_->add_string_member("type", "fraction"); gchar *minnum = g_strdup_printf("%d", pfraction->min_num); gchar *minden = g_strdup_printf("%d", pfraction->min_den); gchar *maxnum = g_strdup_printf("%d", pfraction->max_num); gchar *maxden = g_strdup_printf("%d", pfraction->max_den); gchar *defaultnum = g_strdup_printf("%d", gst_value_get_fraction_numerator (&value)); gchar *defaultden = g_strdup_printf("%d", gst_value_get_fraction_denominator (&value)); json_description_->add_string_member("minimum numerator", minnum); json_description_->add_string_member("maximum numerator", minden); json_description_->add_string_member("minimum denominator", maxnum); json_description_->add_string_member("maximum denominator", maxden); json_description_->add_string_member("default numerator", defaultnum); json_description_->add_string_member("default denominator", defaultden); g_free(minnum); g_free(minden); g_free(maxnum); g_free(maxden); g_free(defaultnum); g_free(defaultden); // g_debug ("Range: %d/%d - %d/%d Default: %d/%d ", // pfraction->min_num, pfraction->min_den, // pfraction->max_num, pfraction->max_den, // gst_value_get_fraction_numerator (&value), // gst_value_get_fraction_denominator (&value)); } else { g_warning("warning: unknown type"); // g_debug ("%-23.23s Unknown type %ld \"%s\"", "", property_->value_type, // g_type_name (property_->value_type)); } break; } g_value_reset(&value); json_description_->end_object(); }
static void print_element_properties_info (GstElement * element) { GParamSpec **property_specs; guint num_properties, i; gboolean readable; gboolean first_flag; property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element), &num_properties); n_print ("\n"); n_print ("Element Properties:\n"); for (i = 0; i < num_properties; i++) { GValue value = { 0, }; GParamSpec *param = property_specs[i]; readable = FALSE; g_value_init (&value, param->value_type); n_print (" %-20s: %s\n", g_param_spec_get_name (param), g_param_spec_get_blurb (param)); first_flag = TRUE; n_print ("%-23.23s flags: ", ""); if (param->flags & G_PARAM_READABLE) { g_object_get_property (G_OBJECT (element), param->name, &value); readable = TRUE; g_print ("%s%s", (first_flag) ? "" : ", ", _("readable")); first_flag = FALSE; } else { /* if we can't read the property value, assume it's set to the default * (which might not be entirely true for sub-classes, but that's an * unlikely corner-case anyway) */ g_param_value_set_default (param, &value); } if (param->flags & G_PARAM_WRITABLE) { g_print ("%s%s", (first_flag) ? "" : ", ", _("writable")); first_flag = FALSE; } if (param->flags & G_PARAM_DEPRECATED) { g_print ("%s%s", (first_flag) ? "" : ", ", _("deprecated")); first_flag = FALSE; } if (param->flags & GST_PARAM_CONTROLLABLE) { g_print (", %s", _("controllable")); first_flag = FALSE; } if (param->flags & GST_PARAM_MUTABLE_PLAYING) { g_print (", %s", _("changeable in NULL, READY, PAUSED or PLAYING state")); } else if (param->flags & GST_PARAM_MUTABLE_PAUSED) { g_print (", %s", _("changeable only in NULL, READY or PAUSED state")); } else if (param->flags & GST_PARAM_MUTABLE_READY) { g_print (", %s", _("changeable only in NULL or READY state")); } if (param->flags & ~KNOWN_PARAM_FLAGS) { g_print ("%s0x%0x", (first_flag) ? "" : ", ", param->flags & ~KNOWN_PARAM_FLAGS); } n_print ("\n"); switch (G_VALUE_TYPE (&value)) { case G_TYPE_STRING: { const char *string_val = g_value_get_string (&value); n_print ("%-23.23s String. ", ""); if (string_val == NULL) g_print ("Default: null"); else g_print ("Default: \"%s\"", string_val); break; } case G_TYPE_BOOLEAN: { gboolean bool_val = g_value_get_boolean (&value); n_print ("%-23.23s Boolean. ", ""); g_print ("Default: %s", bool_val ? "true" : "false"); break; } case G_TYPE_ULONG: { GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); n_print ("%-23.23s Unsigned Long. ", ""); g_print ("Range: %lu - %lu Default: %lu ", pulong->minimum, pulong->maximum, g_value_get_ulong (&value)); GST_ERROR ("%s: property '%s' of type ulong: consider changing to " "uint/uint64", GST_OBJECT_NAME (element), g_param_spec_get_name (param)); break; } case G_TYPE_LONG: { GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); n_print ("%-23.23s Long. ", ""); g_print ("Range: %ld - %ld Default: %ld ", plong->minimum, plong->maximum, g_value_get_long (&value)); GST_ERROR ("%s: property '%s' of type long: consider changing to " "int/int64", GST_OBJECT_NAME (element), g_param_spec_get_name (param)); break; } case G_TYPE_UINT: { GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); n_print ("%-23.23s Unsigned Integer. ", ""); g_print ("Range: %u - %u Default: %u ", puint->minimum, puint->maximum, g_value_get_uint (&value)); break; } case G_TYPE_INT: { GParamSpecInt *pint = G_PARAM_SPEC_INT (param); n_print ("%-23.23s Integer. ", ""); g_print ("Range: %d - %d Default: %d ", pint->minimum, pint->maximum, g_value_get_int (&value)); break; } case G_TYPE_UINT64: { GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); n_print ("%-23.23s Unsigned Integer64. ", ""); g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT " Default: %" G_GUINT64_FORMAT " ", puint64->minimum, puint64->maximum, g_value_get_uint64 (&value)); break; } case G_TYPE_INT64: { GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); n_print ("%-23.23s Integer64. ", ""); g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " Default: %" G_GINT64_FORMAT " ", pint64->minimum, pint64->maximum, g_value_get_int64 (&value)); break; } case G_TYPE_FLOAT: { GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param); n_print ("%-23.23s Float. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", pfloat->minimum, pfloat->maximum, g_value_get_float (&value)); break; } case G_TYPE_DOUBLE: { GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param); n_print ("%-23.23s Double. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", pdouble->minimum, pdouble->maximum, g_value_get_double (&value)); break; } case G_TYPE_CHAR: case G_TYPE_UCHAR: GST_ERROR ("%s: property '%s' of type char: consider changing to " "int/string", GST_OBJECT_NAME (element), g_param_spec_get_name (param)); /* fall through */ default: if (param->value_type == GST_TYPE_CAPS) { const GstCaps *caps = gst_value_get_caps (&value); if (!caps) n_print ("%-23.23s Caps (NULL)", ""); else { print_caps (caps, " "); } } else if (G_IS_PARAM_SPEC_ENUM (param)) { GEnumValue *values; guint j = 0; gint enum_value; const gchar *value_nick = ""; values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; enum_value = g_value_get_enum (&value); while (values[j].value_name) { if (values[j].value == enum_value) value_nick = values[j].value_nick; j++; } n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\"", "", g_type_name (G_VALUE_TYPE (&value)), enum_value, value_nick); j = 0; while (values[j].value_name) { g_print ("\n"); if (_name) g_print ("%s", _name); g_print ("%-23.23s (%d): %-16s - %s", "", values[j].value, values[j].value_nick, values[j].value_name); j++; } /* g_type_class_unref (ec); */ } else if (G_IS_PARAM_SPEC_FLAGS (param)) { GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param); GFlagsValue *vals; gchar *cur; vals = pflags->flags_class->values; cur = flags_to_string (vals, g_value_get_flags (&value)); n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\"", "", g_type_name (G_VALUE_TYPE (&value)), g_value_get_flags (&value), cur); while (vals[0].value_name) { g_print ("\n"); if (_name) g_print ("%s", _name); g_print ("%-23.23s (0x%08x): %-16s - %s", "", vals[0].value, vals[0].value_nick, vals[0].value_name); ++vals; } g_free (cur); } else if (G_IS_PARAM_SPEC_OBJECT (param)) { n_print ("%-23.23s Object of type \"%s\"", "", g_type_name (param->value_type)); } else if (G_IS_PARAM_SPEC_BOXED (param)) { n_print ("%-23.23s Boxed pointer of type \"%s\"", "", g_type_name (param->value_type)); if (param->value_type == GST_TYPE_STRUCTURE) { const GstStructure *s = gst_value_get_structure (&value); if (s) gst_structure_foreach (s, print_field, (gpointer) " "); } } else if (G_IS_PARAM_SPEC_POINTER (param)) { if (param->value_type != G_TYPE_POINTER) { n_print ("%-23.23s Pointer of type \"%s\".", "", g_type_name (param->value_type)); } else { n_print ("%-23.23s Pointer.", ""); } } else if (param->value_type == G_TYPE_VALUE_ARRAY) { GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param); if (pvarray->element_spec) { n_print ("%-23.23s Array of GValues of type \"%s\"", "", g_type_name (pvarray->element_spec->value_type)); } else { n_print ("%-23.23s Array of GValues", ""); } } else if (GST_IS_PARAM_SPEC_FRACTION (param)) { GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param); n_print ("%-23.23s Fraction. ", ""); g_print ("Range: %d/%d - %d/%d Default: %d/%d ", pfraction->min_num, pfraction->min_den, pfraction->max_num, pfraction->max_den, gst_value_get_fraction_numerator (&value), gst_value_get_fraction_denominator (&value)); } else { n_print ("%-23.23s Unknown type %ld \"%s\"", "", (glong) param->value_type, g_type_name (param->value_type)); } break; } if (!readable) g_print (" Write only\n"); else g_print ("\n"); g_value_reset (&value); } if (num_properties == 0) n_print (" none\n"); g_free (property_specs); }
static void print_element_properties_info (GstElement * element) { GParamSpec **property_specs; guint num_properties, i; gboolean readable; gboolean first_flag; property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element), &num_properties); n_print ("\n"); n_print ("Element Properties:\n"); for (i = 0; i < num_properties; i++) { GValue value = { 0, }; GParamSpec *param = property_specs[i]; readable = FALSE; g_value_init (&value, param->value_type); n_print (" %-20s: %s\n", g_param_spec_get_name (param), g_param_spec_get_blurb (param)); first_flag = TRUE; n_print ("%-23.23s flags: ", ""); if (param->flags & G_PARAM_READABLE) { g_object_get_property (G_OBJECT (element), param->name, &value); readable = TRUE; if (!first_flag) g_print (", "); else first_flag = FALSE; g_print (_("readable")); } if (param->flags & G_PARAM_WRITABLE) { if (!first_flag) g_print (", "); else first_flag = FALSE; g_print (_("writable")); } if (param->flags & GST_PARAM_CONTROLLABLE) { if (!first_flag) g_print (", "); else first_flag = FALSE; g_print (_("controllable")); } n_print ("\n"); switch (G_VALUE_TYPE (&value)) { case G_TYPE_STRING: { GParamSpecString *pstring = G_PARAM_SPEC_STRING (param); n_print ("%-23.23s String. ", ""); if (pstring->default_value == NULL) g_print ("Default: null "); else g_print ("Default: \"%s\" ", pstring->default_value); if (readable) { const char *string_val = g_value_get_string (&value); if (string_val == NULL) g_print ("Current: null"); else g_print ("Current: \"%s\"", string_val); } break; } case G_TYPE_BOOLEAN: { GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param); n_print ("%-23.23s Boolean. ", ""); g_print ("Default: %s ", (pboolean->default_value ? "true" : "false")); if (readable) g_print ("Current: %s", (g_value_get_boolean (&value) ? "true" : "false")); break; } case G_TYPE_ULONG: { GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); n_print ("%-23.23s Unsigned Long. ", ""); g_print ("Range: %lu - %lu Default: %lu ", pulong->minimum, pulong->maximum, pulong->default_value); if (readable) g_print ("Current: %lu", g_value_get_ulong (&value)); break; } case G_TYPE_LONG: { GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); n_print ("%-23.23s Long. ", ""); g_print ("Range: %ld - %ld Default: %ld ", plong->minimum, plong->maximum, plong->default_value); if (readable) g_print ("Current: %ld", g_value_get_long (&value)); break; } case G_TYPE_UINT: { GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); n_print ("%-23.23s Unsigned Integer. ", ""); g_print ("Range: %u - %u Default: %u ", puint->minimum, puint->maximum, puint->default_value); if (readable) g_print ("Current: %u", g_value_get_uint (&value)); break; } case G_TYPE_INT: { GParamSpecInt *pint = G_PARAM_SPEC_INT (param); n_print ("%-23.23s Integer. ", ""); g_print ("Range: %d - %d Default: %d ", pint->minimum, pint->maximum, pint->default_value); if (readable) g_print ("Current: %d", g_value_get_int (&value)); break; } case G_TYPE_UINT64: { GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); n_print ("%-23.23s Unsigned Integer64. ", ""); g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT " Default: %" G_GUINT64_FORMAT " ", puint64->minimum, puint64->maximum, puint64->default_value); if (readable) g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value)); break; } case G_TYPE_INT64: { GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); n_print ("%-23.23s Integer64. ", ""); g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " Default: %" G_GINT64_FORMAT " ", pint64->minimum, pint64->maximum, pint64->default_value); if (readable) g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value)); break; } case G_TYPE_FLOAT: { GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param); n_print ("%-23.23s Float. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", pfloat->minimum, pfloat->maximum, pfloat->default_value); if (readable) g_print ("Current: %15.7g", g_value_get_float (&value)); break; } case G_TYPE_DOUBLE: { GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param); n_print ("%-23.23s Double. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", pdouble->minimum, pdouble->maximum, pdouble->default_value); if (readable) g_print ("Current: %15.7g", g_value_get_double (&value)); break; } default: if (param->value_type == GST_TYPE_CAPS) { const GstCaps *caps = gst_value_get_caps (&value); if (!caps) n_print ("%-23.23s Caps (NULL)", ""); else { print_caps (caps, " "); } } else if (G_IS_PARAM_SPEC_ENUM (param)) { GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param); GEnumValue *values; guint j = 0; gint enum_value; const gchar *def_val_nick = "", *cur_val_nick = ""; values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; enum_value = g_value_get_enum (&value); while (values[j].value_name) { if (values[j].value == enum_value) cur_val_nick = values[j].value_nick; if (values[j].value == penum->default_value) def_val_nick = values[j].value_nick; j++; } n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"", "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value, def_val_nick, enum_value, cur_val_nick); j = 0; while (values[j].value_name) { g_print ("\n"); if (_name) g_print ("%s", _name); g_print ("%-23.23s (%d): %-16s - %s", "", values[j].value, values[j].value_nick, values[j].value_name); j++; } /* g_type_class_unref (ec); */ } else if (G_IS_PARAM_SPEC_FLAGS (param)) { GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param); GFlagsValue *values; guint j = 0; gint flags_value; GString *cur_flags = NULL, *def_flags = NULL; values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values; flags_value = g_value_get_flags (&value); while (values[j].value_name) { if (values[j].value & flags_value) { if (cur_flags) { g_string_append_printf (cur_flags, " | %s", values[j].value_nick); } else { cur_flags = g_string_new (values[j].value_nick); } } if (values[j].value & pflags->default_value) { if (def_flags) { g_string_append_printf (def_flags, " | %s", values[j].value_nick); } else { def_flags = g_string_new (values[j].value_nick); } } j++; } n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"", "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value, (def_flags ? def_flags->str : "(none)"), flags_value, (cur_flags ? cur_flags->str : "(none)")); j = 0; while (values[j].value_name) { g_print ("\n"); if (_name) g_print ("%s", _name); g_print ("%-23.23s (0x%08x): %-16s - %s", "", values[j].value, values[j].value_nick, values[j].value_name); j++; } if (cur_flags) g_string_free (cur_flags, TRUE); if (def_flags) g_string_free (def_flags, TRUE); } else if (G_IS_PARAM_SPEC_OBJECT (param)) { n_print ("%-23.23s Object of type \"%s\"", "", g_type_name (param->value_type)); } else if (G_IS_PARAM_SPEC_BOXED (param)) { n_print ("%-23.23s Boxed pointer of type \"%s\"", "", g_type_name (param->value_type)); } else if (G_IS_PARAM_SPEC_POINTER (param)) { if (param->value_type != G_TYPE_POINTER) { n_print ("%-23.23s Pointer of type \"%s\".", "", g_type_name (param->value_type)); } else { n_print ("%-23.23s Pointer.", ""); } } else if (param->value_type == G_TYPE_VALUE_ARRAY) { GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param); if (pvarray->element_spec) { n_print ("%-23.23s Array of GValues of type \"%s\"", "", g_type_name (pvarray->element_spec->value_type)); } else { n_print ("%-23.23s Array of GValues", ""); } } else if (GST_IS_PARAM_SPEC_FRACTION (param)) { GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param); n_print ("%-23.23s Fraction. ", ""); g_print ("Range: %d/%d - %d/%d Default: %d/%d ", pfraction->min_num, pfraction->min_den, pfraction->max_num, pfraction->max_den, pfraction->def_num, pfraction->def_den); if (readable) g_print ("Current: %d/%d", gst_value_get_fraction_numerator (&value), gst_value_get_fraction_denominator (&value)); } else if (GST_IS_PARAM_SPEC_MINI_OBJECT (param)) { n_print ("%-23.23s MiniObject of type \"%s\"", "", g_type_name (param->value_type)); } else { n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type, g_type_name (param->value_type)); } break; } if (!readable) g_print (" Write only\n"); else g_print ("\n"); g_value_reset (&value); } if (num_properties == 0) n_print (" none\n"); g_free (property_specs); }