2 * gstvaapiparamspecs.c - GParamSpecs for some of our types
4 * Copyright (C) 2010-2011 Splitted-Desktop Systems
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
23 * SECTION:gstvaapiparamspecs
24 * @short_description: GParamSpecs for some of our types
28 #include "gstvaapiparamspecs.h"
29 #include "gstvaapivalue.h"
31 /* --- GstVaapiParamSpecID --- */
34 gst_vaapi_param_id_init(GParamSpec *pspec)
36 GST_VAAPI_PARAM_SPEC_ID(pspec)->default_value = GST_VAAPI_ID_NONE;
40 gst_vaapi_param_id_set_default(GParamSpec *pspec, GValue *value)
42 gst_vaapi_value_set_id(value, GST_VAAPI_PARAM_SPEC_ID(pspec)->default_value);
46 gst_vaapi_param_id_validate(GParamSpec *pspec, GValue *value)
48 /* Return FALSE if everything is OK, otherwise TRUE */
53 gst_vaapi_param_id_compare(
59 const GstVaapiID v1 = gst_vaapi_value_get_id(value1);
60 const GstVaapiID v2 = gst_vaapi_value_get_id(value2);
62 return (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0));
66 gst_vaapi_param_spec_id_get_type(void)
70 if (G_UNLIKELY(type == 0)) {
71 static GParamSpecTypeInfo pspec_info = {
72 sizeof(GstVaapiParamSpecID), /* instance_size */
74 gst_vaapi_param_id_init, /* instance_init */
75 G_TYPE_INVALID, /* value_type */
77 gst_vaapi_param_id_set_default, /* value_set_default */
78 gst_vaapi_param_id_validate, /* value_validate */
79 gst_vaapi_param_id_compare, /* values_cmp */
81 pspec_info.value_type = GST_VAAPI_TYPE_ID;
82 type = g_param_type_register_static("GstVaapiParamSpecID", &pspec_info);
88 * gst_vaapi_param_spec_id:
89 * @name: canonical name of the property specified
90 * @nick: nick name for the property specified
91 * @blurb: description of the property specified
92 * @default_value: default value
93 * @flags: flags for the property specified
95 * This function creates an ID GParamSpec for use by #GstVaapiObject
96 * objects. This function is typically used in connection with
97 * g_object_class_install_property() in a GObjects's instance_init
100 * Return value: a newly created parameter specification
103 gst_vaapi_param_spec_id(
107 GstVaapiID default_value,
111 GstVaapiParamSpecID *ispec;
113 GValue value = { 0, };
115 ispec = g_param_spec_internal(
116 GST_VAAPI_TYPE_PARAM_ID,
125 ispec->default_value = default_value;
126 pspec = G_PARAM_SPEC(ispec);
128 /* Validate default value */
129 g_value_init(&value, GST_VAAPI_TYPE_ID);
130 gst_vaapi_value_set_id(&value, default_value);
131 if (gst_vaapi_param_id_validate(pspec, &value)) {
132 g_param_spec_ref(pspec);
133 g_param_spec_sink(pspec);
134 g_param_spec_unref(pspec);
137 g_value_unset(&value);