2 * gstvaapiobject.c - Base VA object
4 * gstreamer-vaapi (C) 2010 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:gstvaapiobject
24 * @short_description: Base VA object
28 #include "gstvaapiobject.h"
29 #include "gstvaapi_priv.h"
30 #include "gstvaapiparamspecs.h"
31 #include "gstvaapivalue.h"
32 #include "gstvaapimarshal.h"
35 #include "gstvaapidebug.h"
37 G_DEFINE_TYPE(GstVaapiObject, gst_vaapi_object, G_TYPE_OBJECT);
52 static guint object_signals[LAST_SIGNAL] = { 0, };
55 gst_vaapi_object_dispose(GObject *object)
57 GstVaapiObjectPrivate * const priv = GST_VAAPI_OBJECT(object)->priv;
59 if (!priv->is_destroying) {
60 priv->is_destroying = TRUE;
61 g_signal_emit(object, object_signals[DESTROY], 0);
62 priv->is_destroying = FALSE;
65 G_OBJECT_CLASS(gst_vaapi_object_parent_class)->dispose(object);
69 gst_vaapi_object_finalize(GObject *object)
71 GstVaapiObjectPrivate * const priv = GST_VAAPI_OBJECT(object)->priv;
73 priv->id = GST_VAAPI_ID_NONE;
76 g_object_unref(priv->display);
80 G_OBJECT_CLASS(gst_vaapi_object_parent_class)->finalize(object);
84 gst_vaapi_object_set_property(
91 GstVaapiObject * const object = GST_VAAPI_OBJECT(gobject);
95 object->priv->display = g_object_ref(g_value_get_object(value));
98 object->priv->id = gst_vaapi_value_get_id(value);
101 G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
107 gst_vaapi_object_get_property(
114 GstVaapiObject * const object = GST_VAAPI_OBJECT(gobject);
118 g_value_set_object(value, gst_vaapi_object_get_display(object));
121 gst_vaapi_value_set_id(value, gst_vaapi_object_get_id(object));
124 G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
130 gst_vaapi_object_class_init(GstVaapiObjectClass *klass)
132 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
134 g_type_class_add_private(klass, sizeof(GstVaapiObjectPrivate));
136 object_class->dispose = gst_vaapi_object_dispose;
137 object_class->finalize = gst_vaapi_object_finalize;
138 object_class->set_property = gst_vaapi_object_set_property;
139 object_class->get_property = gst_vaapi_object_get_property;
142 * GstVaapiObject:display:
144 * The #GstVaapiDisplay this object is bound to.
146 g_object_class_install_property
149 g_param_spec_object("display",
151 "The GstVaapiDisplay this object is bound to",
152 GST_VAAPI_TYPE_DISPLAY,
153 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
158 * The #GstVaapiID contained in this object.
160 g_object_class_install_property
163 gst_vaapi_param_spec_id("id",
165 "The GstVaapiID contained in this object",
167 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
170 * GstVaapiObject::destroy:
171 * @object: the object which received the signal
173 * The ::destroy signal is emitted when an object is destroyed,
174 * when the user released the last reference to @object.
176 object_signals[DESTROY] = g_signal_new(
178 G_TYPE_FROM_CLASS(object_class),
179 G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
180 G_STRUCT_OFFSET(GstVaapiObjectClass, destroy),
182 gst_vaapi_marshal_VOID__VOID,
188 gst_vaapi_object_init(GstVaapiObject *object)
190 GstVaapiObjectPrivate *priv = GST_VAAPI_OBJECT_GET_PRIVATE(object);
193 priv->display = NULL;
194 priv->id = GST_VAAPI_ID_NONE;
195 priv->is_destroying = FALSE;
199 * gst_vaapi_object_get_display:
200 * @object: a #GstVaapiObject
202 * Returns the #GstVaapiDisplay this @object is bound to.
204 * Return value: the parent #GstVaapiDisplay object
207 gst_vaapi_object_get_display(GstVaapiObject *object)
209 g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), NULL);
211 return object->priv->display;
215 * gst_vaapi_object_lock_display:
216 * @object: a #GstVaapiObject
218 * Locks @object parent display. If display is already locked by
219 * another thread, the current thread will block until display is
220 * unlocked by the other thread.
223 gst_vaapi_object_lock_display(GstVaapiObject *object)
225 g_return_if_fail(GST_VAAPI_IS_OBJECT(object));
227 GST_VAAPI_OBJECT_LOCK_DISPLAY(object);
231 * gst_vaapi_object_unlock_display:
232 * @object: a #GstVaapiObject
234 * Unlocks @object parent display. If another thread is blocked in a
235 * gst_vaapi_object_lock_display() call, it will be woken and can lock
239 gst_vaapi_object_unlock_display(GstVaapiObject *object)
241 g_return_if_fail(GST_VAAPI_IS_OBJECT(object));
243 GST_VAAPI_OBJECT_UNLOCK_DISPLAY(object);
247 * gst_vaapi_object_get_id:
248 * @object: a #GstVaapiObject
250 * Returns the #GstVaapiID contained in the @object.
252 * Return value: the #GstVaapiID of the @object
255 gst_vaapi_object_get_id(GstVaapiObject *object)
257 g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), GST_VAAPI_ID_NONE);
259 return object->priv->id;