2010-03-23 16:21:28 +00:00
|
|
|
/*
|
|
|
|
* gstvaapiobject.c - Base VA object
|
|
|
|
*
|
2012-01-16 09:41:10 +00:00
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
2013-11-22 05:37:12 +00:00
|
|
|
* Copyright (C) 2012-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2010-03-23 16:21:28 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
2010-03-23 16:21:28 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-03-23 16:21:28 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-05-03 07:07:27 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-03-23 16:21:28 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
2010-03-23 16:21:28 +00:00
|
|
|
*/
|
|
|
|
|
2010-03-24 08:16:32 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstvaapiobject
|
|
|
|
* @short_description: Base VA object
|
|
|
|
*/
|
|
|
|
|
2012-01-30 17:12:59 +00:00
|
|
|
#include "sysdeps.h"
|
2010-03-23 16:21:28 +00:00
|
|
|
#include "gstvaapiobject.h"
|
2013-04-30 15:20:46 +00:00
|
|
|
#include "gstvaapiobject_priv.h"
|
|
|
|
#include "gstvaapiminiobject.h"
|
|
|
|
#include "gstvaapidisplay_priv.h"
|
2010-03-23 16:21:28 +00:00
|
|
|
|
|
|
|
#define DEBUG 1
|
|
|
|
#include "gstvaapidebug.h"
|
|
|
|
|
2010-03-23 17:12:40 +00:00
|
|
|
static void
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_finalize (GstVaapiObject * object)
|
2010-03-23 17:12:40 +00:00
|
|
|
{
|
2014-12-02 13:15:49 +00:00
|
|
|
const GstVaapiObjectClass *const klass = GST_VAAPI_OBJECT_GET_CLASS (object);
|
2010-03-23 17:12:40 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
if (klass->finalize)
|
|
|
|
klass->finalize (object);
|
|
|
|
gst_vaapi_display_replace (&object->display, NULL);
|
2010-03-23 17:12:40 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 15:20:46 +00:00
|
|
|
void
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_class_init (GstVaapiObjectClass * klass, guint size)
|
2010-03-23 16:21:28 +00:00
|
|
|
{
|
2014-12-02 13:15:49 +00:00
|
|
|
GstVaapiMiniObjectClass *const object_class =
|
|
|
|
GST_VAAPI_MINI_OBJECT_CLASS (klass);
|
2010-03-24 13:19:58 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
object_class->size = size;
|
|
|
|
object_class->finalize = (GDestroyNotify) gst_vaapi_object_finalize;
|
2010-03-23 16:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 15:20:46 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_object_new:
|
2014-01-21 13:43:57 +00:00
|
|
|
* @klass: The object class
|
|
|
|
* @display: The #GstVaapiDisplay
|
2013-04-30 15:20:46 +00:00
|
|
|
*
|
2014-01-22 06:20:59 +00:00
|
|
|
* Creates a new #GstVaapiObject. The @klass argument shall not be
|
|
|
|
* %NULL, and it must reference a statically allocated descriptor.
|
2013-04-30 15:20:46 +00:00
|
|
|
*
|
|
|
|
* This function zero-initializes the derived object data. Also note
|
|
|
|
* that this is an internal function that shall not be used outside of
|
|
|
|
* libgstvaapi libraries.
|
|
|
|
*
|
|
|
|
* Returns: The newly allocated #GstVaapiObject
|
|
|
|
*/
|
|
|
|
gpointer
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_new (const GstVaapiObjectClass * klass,
|
|
|
|
GstVaapiDisplay * display)
|
2010-03-23 16:21:28 +00:00
|
|
|
{
|
2014-12-02 13:15:49 +00:00
|
|
|
const GstVaapiMiniObjectClass *const object_class =
|
|
|
|
GST_VAAPI_MINI_OBJECT_CLASS (klass);
|
|
|
|
GstVaapiObject *object;
|
|
|
|
guint sub_size;
|
2010-03-23 16:21:28 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
g_return_val_if_fail (klass != NULL, NULL);
|
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
2010-03-23 16:21:28 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
object = (GstVaapiObject *) gst_vaapi_mini_object_new (object_class);
|
|
|
|
if (!object)
|
|
|
|
return NULL;
|
2013-04-30 15:20:46 +00:00
|
|
|
|
2018-06-13 16:00:18 +00:00
|
|
|
object->display = gst_object_ref (display);
|
2014-12-02 13:15:49 +00:00
|
|
|
object->object_id = VA_INVALID_ID;
|
2010-03-23 16:21:28 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
sub_size = object_class->size - sizeof (*object);
|
|
|
|
if (sub_size > 0)
|
|
|
|
memset (((guchar *) object) + sizeof (*object), 0, sub_size);
|
2014-01-21 13:43:57 +00:00
|
|
|
|
2017-08-08 15:12:06 +00:00
|
|
|
if (klass->init)
|
2014-12-02 13:15:49 +00:00
|
|
|
klass->init (object);
|
|
|
|
return object;
|
2010-03-23 16:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 15:20:46 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_object_ref:
|
|
|
|
* @object: a #GstVaapiObject
|
|
|
|
*
|
|
|
|
* Atomically increases the reference count of the given @object by one.
|
|
|
|
*
|
|
|
|
* Returns: The same @object argument
|
|
|
|
*/
|
|
|
|
gpointer
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_ref (gpointer object)
|
2010-03-23 16:21:28 +00:00
|
|
|
{
|
2018-09-13 10:22:42 +00:00
|
|
|
return gst_vaapi_mini_object_ref (object);
|
2010-03-23 16:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 15:20:46 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_object_unref:
|
|
|
|
* @object: a #GstVaapiObject
|
|
|
|
*
|
|
|
|
* Atomically decreases the reference count of the @object by one. If
|
|
|
|
* the reference count reaches zero, the object will be free'd.
|
|
|
|
*/
|
|
|
|
void
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_unref (gpointer object)
|
2010-03-23 16:21:28 +00:00
|
|
|
{
|
2018-09-13 10:22:42 +00:00
|
|
|
gst_vaapi_mini_object_unref (object);
|
2013-04-30 15:20:46 +00:00
|
|
|
}
|
2010-03-23 16:21:28 +00:00
|
|
|
|
2013-04-30 15:20:46 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_object_replace:
|
|
|
|
* @old_object_ptr: a pointer to a #GstVaapiObject
|
|
|
|
* @new_object: a #GstVaapiObject
|
|
|
|
*
|
|
|
|
* Atomically replaces the object object held in @old_object_ptr with
|
|
|
|
* @new_object. This means that @old_object_ptr shall reference a
|
|
|
|
* valid object. However, @new_object can be NULL.
|
|
|
|
*/
|
|
|
|
void
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_replace (gpointer old_object_ptr, gpointer new_object)
|
2013-04-30 15:20:46 +00:00
|
|
|
{
|
2018-09-13 10:22:42 +00:00
|
|
|
gst_vaapi_mini_object_replace ((GstVaapiMiniObject **) old_object_ptr,
|
|
|
|
new_object);
|
2010-03-23 16:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_object_get_display:
|
|
|
|
* @object: a #GstVaapiObject
|
|
|
|
*
|
|
|
|
* Returns the #GstVaapiDisplay this @object is bound to.
|
|
|
|
*
|
|
|
|
* Return value: the parent #GstVaapiDisplay object
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_get_display (GstVaapiObject * object)
|
2010-03-23 16:21:28 +00:00
|
|
|
{
|
2014-12-02 13:15:49 +00:00
|
|
|
g_return_val_if_fail (object != NULL, NULL);
|
2010-03-23 16:21:28 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
return GST_VAAPI_OBJECT_DISPLAY (object);
|
2010-03-23 16:21:28 +00:00
|
|
|
}
|
2010-03-24 13:19:58 +00:00
|
|
|
|
2010-03-26 15:22:00 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_object_lock_display:
|
|
|
|
* @object: a #GstVaapiObject
|
|
|
|
*
|
|
|
|
* Locks @object parent display. If display is already locked by
|
|
|
|
* another thread, the current thread will block until display is
|
|
|
|
* unlocked by the other thread.
|
|
|
|
*/
|
|
|
|
void
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_lock_display (GstVaapiObject * object)
|
2010-03-26 15:22:00 +00:00
|
|
|
{
|
2014-12-02 13:15:49 +00:00
|
|
|
g_return_if_fail (object != NULL);
|
2010-03-26 15:22:00 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
GST_VAAPI_OBJECT_LOCK_DISPLAY (object);
|
2010-03-26 15:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_object_unlock_display:
|
|
|
|
* @object: a #GstVaapiObject
|
|
|
|
*
|
|
|
|
* Unlocks @object parent display. If another thread is blocked in a
|
|
|
|
* gst_vaapi_object_lock_display() call, it will be woken and can lock
|
|
|
|
* display itself.
|
|
|
|
*/
|
|
|
|
void
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_unlock_display (GstVaapiObject * object)
|
2010-03-26 15:22:00 +00:00
|
|
|
{
|
2014-12-02 13:15:49 +00:00
|
|
|
g_return_if_fail (object != NULL);
|
2010-03-26 15:22:00 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (object);
|
2010-03-26 15:22:00 +00:00
|
|
|
}
|
|
|
|
|
2010-03-24 13:19:58 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_object_get_id:
|
|
|
|
* @object: a #GstVaapiObject
|
|
|
|
*
|
|
|
|
* Returns the #GstVaapiID contained in the @object.
|
|
|
|
*
|
|
|
|
* Return value: the #GstVaapiID of the @object
|
|
|
|
*/
|
|
|
|
GstVaapiID
|
2014-12-02 13:15:49 +00:00
|
|
|
gst_vaapi_object_get_id (GstVaapiObject * object)
|
2010-03-24 13:19:58 +00:00
|
|
|
{
|
2014-12-02 13:15:49 +00:00
|
|
|
g_return_val_if_fail (object != NULL, 0);
|
2010-03-24 13:19:58 +00:00
|
|
|
|
2014-12-02 13:15:49 +00:00
|
|
|
return GST_VAAPI_OBJECT_ID (object);
|
2010-03-24 13:19:58 +00:00
|
|
|
}
|