2 * gstvaapiobject.c - Base VA object
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:gstvaapiobject
24 * @short_description: Base VA object
28 #include "gstvaapiobject.h"
29 #include "gstvaapi_priv.h"
30 #include "gstvaapiparamspecs.h"
31 #include "gstvaapivalue.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 = GST_VAAPI_ID_NONE;
74 g_clear_object(&priv->display);
76 G_OBJECT_CLASS(gst_vaapi_object_parent_class)->finalize(object);
80 gst_vaapi_object_set_property(
87 GstVaapiObject * const object = GST_VAAPI_OBJECT(gobject);
91 object->priv->display = g_object_ref(g_value_get_object(value));
94 object->priv->id = gst_vaapi_value_get_id(value);
97 G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
103 gst_vaapi_object_get_property(
110 GstVaapiObject * const object = GST_VAAPI_OBJECT(gobject);
114 g_value_set_object(value, gst_vaapi_object_get_display(object));
117 gst_vaapi_value_set_id(value, gst_vaapi_object_get_id(object));
120 G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
126 gst_vaapi_object_class_init(GstVaapiObjectClass *klass)
128 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
130 g_type_class_add_private(klass, sizeof(GstVaapiObjectPrivate));
132 object_class->dispose = gst_vaapi_object_dispose;
133 object_class->finalize = gst_vaapi_object_finalize;
134 object_class->set_property = gst_vaapi_object_set_property;
135 object_class->get_property = gst_vaapi_object_get_property;
138 * GstVaapiObject:display:
140 * The #GstVaapiDisplay this object is bound to.
142 g_object_class_install_property
145 g_param_spec_object("display",
147 "The GstVaapiDisplay this object is bound to",
148 GST_VAAPI_TYPE_DISPLAY,
149 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
154 * The #GstVaapiID contained in this object.
156 g_object_class_install_property
159 gst_vaapi_param_spec_id("id",
161 "The GstVaapiID contained in this object",
163 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
166 * GstVaapiObject::destroy:
167 * @object: the object which received the signal
169 * The ::destroy signal is emitted when an object is destroyed,
170 * when the user released the last reference to @object.
172 object_signals[DESTROY] = g_signal_new(
174 G_TYPE_FROM_CLASS(object_class),
175 G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
176 G_STRUCT_OFFSET(GstVaapiObjectClass, destroy),
178 g_cclosure_marshal_VOID__VOID,
184 gst_vaapi_object_init(GstVaapiObject *object)
186 GstVaapiObjectPrivate *priv = GST_VAAPI_OBJECT_GET_PRIVATE(object);
189 priv->display = NULL;
190 priv->id = GST_VAAPI_ID_NONE;
191 priv->is_destroying = FALSE;
195 * gst_vaapi_object_get_display:
196 * @object: a #GstVaapiObject
198 * Returns the #GstVaapiDisplay this @object is bound to.
200 * Return value: the parent #GstVaapiDisplay object
203 gst_vaapi_object_get_display(GstVaapiObject *object)
205 g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), NULL);
207 return object->priv->display;
211 * gst_vaapi_object_lock_display:
212 * @object: a #GstVaapiObject
214 * Locks @object parent display. If display is already locked by
215 * another thread, the current thread will block until display is
216 * unlocked by the other thread.
219 gst_vaapi_object_lock_display(GstVaapiObject *object)
221 g_return_if_fail(GST_VAAPI_IS_OBJECT(object));
223 GST_VAAPI_OBJECT_LOCK_DISPLAY(object);
227 * gst_vaapi_object_unlock_display:
228 * @object: a #GstVaapiObject
230 * Unlocks @object parent display. If another thread is blocked in a
231 * gst_vaapi_object_lock_display() call, it will be woken and can lock
235 gst_vaapi_object_unlock_display(GstVaapiObject *object)
237 g_return_if_fail(GST_VAAPI_IS_OBJECT(object));
239 GST_VAAPI_OBJECT_UNLOCK_DISPLAY(object);
243 * gst_vaapi_object_get_id:
244 * @object: a #GstVaapiObject
246 * Returns the #GstVaapiID contained in the @object.
248 * Return value: the #GstVaapiID of the @object
251 gst_vaapi_object_get_id(GstVaapiObject *object)
253 g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), GST_VAAPI_ID_NONE);
255 return object->priv->id;