2 * gstvaapivalue.c - GValue implementations specific to VA-API
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:gstvaapivalue
24 * @short_description: GValue implementations specific to VA-API
28 #include <gobject/gvaluecollector.h>
29 #include "gstvaapivalue.h"
31 static GTypeInfo gst_vaapi_type_info = {
44 static GTypeFundamentalInfo gst_vaapi_type_finfo = {
48 #define GST_VAAPI_TYPE_DEFINE(type, name) \
49 GType gst_vaapi_ ## type ## _get_type(void) \
51 static GType gst_vaapi_ ## type ## _type = 0; \
53 if (G_UNLIKELY(gst_vaapi_ ## type ## _type == 0)) { \
54 gst_vaapi_type_info.value_table = \
55 &gst_vaapi_ ## type ## _value_table; \
56 gst_vaapi_ ## type ## _type = g_type_register_fundamental( \
57 g_type_fundamental_next(), \
59 &gst_vaapi_type_info, \
60 &gst_vaapi_type_finfo, \
64 return gst_vaapi_ ## type ## _type; \
67 /* --- GstVaapiID --- */
69 #if GST_VAAPI_TYPE_ID_SIZE == 4
70 # define GST_VAAPI_VALUE_ID_(cvalue) ((cvalue).v_int)
71 # define GST_VAAPI_VALUE_ID_CFORMAT "i"
72 #elif GST_VAAPI_TYPE_ID_SIZE == 8
73 # define GST_VAAPI_VALUE_ID_(cvalue) ((cvalue).v_int64)
74 # define GST_VAAPI_VALUE_ID_CFORMAT "q"
76 # error "unsupported GstVaapiID size"
78 #define GST_VAAPI_VALUE_ID(value) GST_VAAPI_VALUE_ID_((value)->data[0])
81 gst_vaapi_value_id_init(GValue *value)
83 GST_VAAPI_VALUE_ID(value) = 0;
87 gst_vaapi_value_id_copy(const GValue *src_value, GValue *dst_value)
89 GST_VAAPI_VALUE_ID(dst_value) = GST_VAAPI_VALUE_ID(src_value);
93 gst_vaapi_value_id_collect(
95 guint n_collect_values,
96 GTypeCValue *collect_values,
100 GST_VAAPI_VALUE_ID(value) = GST_VAAPI_VALUE_ID_(collect_values[0]);
106 gst_vaapi_value_id_lcopy(
108 guint n_collect_values,
109 GTypeCValue *collect_values,
113 GstVaapiID *id_p = collect_values[0].v_pointer;
116 return g_strdup_printf("value location for `%s' passed as NULL",
117 G_VALUE_TYPE_NAME(value));
119 *id_p = GST_VAAPI_VALUE_ID(value);
123 static const GTypeValueTable gst_vaapi_id_value_table = {
124 gst_vaapi_value_id_init,
126 gst_vaapi_value_id_copy,
128 GST_VAAPI_VALUE_ID_CFORMAT,
129 gst_vaapi_value_id_collect,
131 gst_vaapi_value_id_lcopy
134 GST_VAAPI_TYPE_DEFINE(id, "GstVaapiID");
137 * gst_vaapi_value_get_id:
138 * @value: a GValue initialized to #GstVaapiID
140 * Gets the integer contained in @value.
142 * Return value: the integer contained in @value
145 gst_vaapi_value_get_id(const GValue *value)
147 g_return_val_if_fail(GST_VAAPI_VALUE_HOLDS_ID(value), 0);
149 return GST_VAAPI_VALUE_ID(value);
153 * gst_vaapi_value_set_id:
154 * @value: a GValue initialized to #GstVaapiID
157 * Sets the integer contained in @id to @value.
160 gst_vaapi_value_set_id(GValue *value, GstVaapiID id)
162 g_return_if_fail(GST_VAAPI_VALUE_HOLDS_ID(value));
164 GST_VAAPI_VALUE_ID(value) = id;
167 /* --- GstVaapiRenderMode --- */
170 gst_vaapi_render_mode_get_type(void)
172 static GType render_mode_type = 0;
174 static const GEnumValue render_modes[] = {
175 { GST_VAAPI_RENDER_MODE_OVERLAY,
176 "Overlay render mode", "overlay" },
177 { GST_VAAPI_RENDER_MODE_TEXTURE,
178 "Textured-blit render mode", "texture" },
182 if (!render_mode_type) {
184 g_enum_register_static("GstVaapiRenderMode", render_modes);
186 return render_mode_type;
189 /* --- GstVaapiRotation --- */
192 gst_vaapi_rotation_get_type(void)
194 static GType g_type = 0;
196 static const GEnumValue rotation_values[] = {
197 { GST_VAAPI_ROTATION_0,
198 "Unrotated mode", "0" },
199 { GST_VAAPI_ROTATION_90,
200 "Rotated by 90°, clockwise", "90" },
201 { GST_VAAPI_ROTATION_180,
202 "Rotated by 180°, clockwise", "180" },
203 { GST_VAAPI_ROTATION_270,
204 "Rotated by 270°, clockwise", "270" },
208 g_type = g_enum_register_static("GstVaapiRotation", rotation_values);