2 * gstvaapiobject.c - Base VA object
4 * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 * SECTION:gstvaapiobject
23 * @short_description: Base VA object
27 #include "gstvaapiobject.h"
28 #include "gstvaapiobject_priv.h"
29 #include "gstvaapiparamspecs.h"
30 #include "gstvaapivalue.h"
31 #include "gstvaapimarshal.h"
34 #include "gstvaapidebug.h"
36 G_DEFINE_TYPE(GstVaapiObject, gst_vaapi_object, G_TYPE_OBJECT);
51 static guint object_signals[LAST_SIGNAL] = { 0, };
54 gst_vaapi_object_dispose(GObject *object)
56 GstVaapiObjectPrivate * const priv = GST_VAAPI_OBJECT(object)->priv;
58 if (!priv->is_destroying) {
59 priv->is_destroying = TRUE;
60 g_signal_emit(object, object_signals[DESTROY], 0);
61 priv->is_destroying = FALSE;
64 G_OBJECT_CLASS(gst_vaapi_object_parent_class)->dispose(object);
68 gst_vaapi_object_finalize(GObject *object)
70 GstVaapiObjectPrivate * const priv = GST_VAAPI_OBJECT(object)->priv;
72 priv->id = VA_INVALID_ID;
75 g_object_unref(priv->display);
79 G_OBJECT_CLASS(gst_vaapi_object_parent_class)->finalize(object);
83 gst_vaapi_object_set_property(
90 GstVaapiObject * const object = GST_VAAPI_OBJECT(gobject);
94 object->priv->display = g_object_ref(g_value_get_object(value));
97 object->priv->id = gst_vaapi_value_get_id(value);
100 G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
106 gst_vaapi_object_get_property(
113 GstVaapiObject * const object = GST_VAAPI_OBJECT(gobject);
117 g_value_set_object(value, gst_vaapi_object_get_display(object));
120 gst_vaapi_value_set_id(value, gst_vaapi_object_get_id(object));
123 G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
129 gst_vaapi_object_class_init(GstVaapiObjectClass *klass)
131 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
133 g_type_class_add_private(klass, sizeof(GstVaapiObjectPrivate));
135 object_class->dispose = gst_vaapi_object_dispose;
136 object_class->finalize = gst_vaapi_object_finalize;
137 object_class->set_property = gst_vaapi_object_set_property;
138 object_class->get_property = gst_vaapi_object_get_property;
141 * GstVaapiObject:display:
143 * The #GstVaapiDisplay this object is bound to.
145 g_object_class_install_property
148 g_param_spec_object("display",
150 "The GstVaapiDisplay this object is bound to",
151 GST_VAAPI_TYPE_DISPLAY,
152 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
157 * The #GstVaapiID contained in this object.
159 g_object_class_install_property
162 gst_vaapi_param_spec_id("id",
164 "The GstVaapiID contained in this object",
166 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
169 * GstVaapiObject::destroy:
170 * @object: the object which received the signal
172 * The ::destroy signal is emitted when an object is destroyed,
173 * when the user released the last reference to @object.
175 object_signals[DESTROY] = g_signal_new(
177 G_TYPE_FROM_CLASS(object_class),
178 G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
179 G_STRUCT_OFFSET(GstVaapiObjectClass, destroy),
181 gst_vaapi_marshal_VOID__VOID,
187 gst_vaapi_object_init(GstVaapiObject *object)
189 GstVaapiObjectPrivate *priv = GST_VAAPI_OBJECT_GET_PRIVATE(object);
192 priv->display = NULL;
193 priv->id = VA_INVALID_ID;
194 priv->is_destroying = FALSE;
198 * gst_vaapi_object_get_display:
199 * @object: a #GstVaapiObject
201 * Returns the #GstVaapiDisplay this @object is bound to.
203 * Return value: the parent #GstVaapiDisplay object
206 gst_vaapi_object_get_display(GstVaapiObject *object)
208 g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), NULL);
210 return object->priv->display;
214 * gst_vaapi_object_get_id:
215 * @object: a #GstVaapiObject
217 * Returns the #GstVaapiID contained in the @object.
219 * Return value: the #GstVaapiID of the @object
222 gst_vaapi_object_get_id(GstVaapiObject *object)
224 g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), VA_INVALID_ID);
226 return object->priv->id;