mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
surfaceproxy: port to GstVaapiMiniObject.
GstVaapiSurfaceProxy does not use any particular functionality from GObject. Actually, it only needs a basic object type with reference counting. This is an API and ABI change.
This commit is contained in:
parent
44945ac9eb
commit
1130a46837
9 changed files with 185 additions and 272 deletions
|
@ -229,7 +229,8 @@ gst_vaapi_decoder_finalize(GObject *object)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->surfaces) {
|
if (priv->surfaces) {
|
||||||
clear_queue(priv->surfaces, (GDestroyNotify)g_object_unref);
|
clear_queue(priv->surfaces, (GDestroyNotify)
|
||||||
|
gst_vaapi_surface_proxy_unref);
|
||||||
g_queue_free(priv->surfaces);
|
g_queue_free(priv->surfaces);
|
||||||
priv->surfaces = NULL;
|
priv->surfaces = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ gst_vaapi_picture_destroy(GstVaapiPicture *picture)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (picture->proxy) {
|
if (picture->proxy) {
|
||||||
g_object_unref(picture->proxy);
|
gst_vaapi_surface_proxy_unref(picture->proxy);
|
||||||
picture->proxy = NULL;
|
picture->proxy = NULL;
|
||||||
}
|
}
|
||||||
else if (picture->surface) {
|
else if (picture->surface) {
|
||||||
|
@ -107,7 +107,7 @@ gst_vaapi_picture_create(
|
||||||
if (args->flags & GST_VAAPI_CREATE_PICTURE_FLAG_CLONE) {
|
if (args->flags & GST_VAAPI_CREATE_PICTURE_FLAG_CLONE) {
|
||||||
GstVaapiPicture * const parent_picture = GST_VAAPI_PICTURE(args->data);
|
GstVaapiPicture * const parent_picture = GST_VAAPI_PICTURE(args->data);
|
||||||
|
|
||||||
picture->proxy = g_object_ref(parent_picture->proxy);
|
picture->proxy = gst_vaapi_surface_proxy_ref(parent_picture->proxy);
|
||||||
picture->surface = gst_vaapi_surface_proxy_get_surface(picture->proxy);
|
picture->surface = gst_vaapi_surface_proxy_get_surface(picture->proxy);
|
||||||
picture->type = parent_picture->type;
|
picture->type = parent_picture->type;
|
||||||
picture->pts = parent_picture->pts;
|
picture->pts = parent_picture->pts;
|
||||||
|
@ -341,7 +341,7 @@ gst_vaapi_picture_output(GstVaapiPicture *picture)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!GST_VAAPI_PICTURE_IS_SKIPPED(picture)) {
|
if (!GST_VAAPI_PICTURE_IS_SKIPPED(picture)) {
|
||||||
proxy = g_object_ref(picture->proxy);
|
proxy = gst_vaapi_surface_proxy_ref(picture->proxy);
|
||||||
gst_vaapi_surface_proxy_set_timestamp(proxy, picture->pts);
|
gst_vaapi_surface_proxy_set_timestamp(proxy, picture->pts);
|
||||||
if (GST_VAAPI_PICTURE_IS_INTERLACED(picture))
|
if (GST_VAAPI_PICTURE_IS_INTERLACED(picture))
|
||||||
gst_vaapi_surface_proxy_set_interlaced(proxy, TRUE);
|
gst_vaapi_surface_proxy_set_interlaced(proxy, TRUE);
|
||||||
|
|
|
@ -28,18 +28,21 @@
|
||||||
#include "sysdeps.h"
|
#include "sysdeps.h"
|
||||||
#include "gstvaapisurfaceproxy.h"
|
#include "gstvaapisurfaceproxy.h"
|
||||||
#include "gstvaapiobject_priv.h"
|
#include "gstvaapiobject_priv.h"
|
||||||
|
#include "gstvaapiminiobject.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#include "gstvaapidebug.h"
|
#include "gstvaapidebug.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE(GstVaapiSurfaceProxy, gst_vaapi_surface_proxy, G_TYPE_OBJECT)
|
#define GST_VAAPI_SURFACE_PROXY(obj) \
|
||||||
|
((GstVaapiSurfaceProxy *)(obj))
|
||||||
|
|
||||||
#define GST_VAAPI_SURFACE_PROXY_GET_PRIVATE(obj) \
|
#define GST_VAAPI_IS_SURFACE_PROXY(obj) \
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
|
(GST_VAAPI_SURFACE_PROXY(obj) != NULL)
|
||||||
GST_VAAPI_TYPE_SURFACE_PROXY, \
|
|
||||||
GstVaapiSurfaceProxyPrivate))
|
struct _GstVaapiSurfaceProxy {
|
||||||
|
/*< private >*/
|
||||||
|
GstVaapiMiniObject parent_instance;
|
||||||
|
|
||||||
struct _GstVaapiSurfaceProxyPrivate {
|
|
||||||
GstVaapiContext *context;
|
GstVaapiContext *context;
|
||||||
GstVaapiSurface *surface;
|
GstVaapiSurface *surface;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
|
@ -48,175 +51,31 @@ struct _GstVaapiSurfaceProxyPrivate {
|
||||||
guint tff : 1;
|
guint tff : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
PROP_0,
|
|
||||||
|
|
||||||
PROP_CONTEXT,
|
|
||||||
PROP_SURFACE,
|
|
||||||
PROP_TIMESTAMP,
|
|
||||||
PROP_DURATION,
|
|
||||||
PROP_INTERLACED,
|
|
||||||
PROP_TFF
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_surface_proxy_finalize(GObject *object)
|
gst_vaapi_surface_proxy_finalize(GstVaapiSurfaceProxy *proxy)
|
||||||
{
|
{
|
||||||
GstVaapiSurfaceProxy * const proxy = GST_VAAPI_SURFACE_PROXY(object);
|
|
||||||
|
|
||||||
gst_vaapi_surface_proxy_set_surface(proxy, NULL);
|
gst_vaapi_surface_proxy_set_surface(proxy, NULL);
|
||||||
gst_vaapi_surface_proxy_set_context(proxy, NULL);
|
gst_vaapi_surface_proxy_set_context(proxy, NULL);
|
||||||
|
|
||||||
G_OBJECT_CLASS(gst_vaapi_surface_proxy_parent_class)->finalize(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_surface_proxy_set_property(
|
|
||||||
GObject *object,
|
|
||||||
guint prop_id,
|
|
||||||
const GValue *value,
|
|
||||||
GParamSpec *pspec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GstVaapiSurfaceProxy * const proxy = GST_VAAPI_SURFACE_PROXY(object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_CONTEXT:
|
|
||||||
gst_vaapi_surface_proxy_set_context(proxy, g_value_get_pointer(value));
|
|
||||||
break;
|
|
||||||
case PROP_SURFACE:
|
|
||||||
gst_vaapi_surface_proxy_set_surface(proxy, g_value_get_pointer(value));
|
|
||||||
break;
|
|
||||||
case PROP_TIMESTAMP:
|
|
||||||
gst_vaapi_surface_proxy_set_timestamp(proxy, g_value_get_uint64(value));
|
|
||||||
break;
|
|
||||||
case PROP_DURATION:
|
|
||||||
gst_vaapi_surface_proxy_set_duration(proxy, g_value_get_uint64(value));
|
|
||||||
break;
|
|
||||||
case PROP_INTERLACED:
|
|
||||||
gst_vaapi_surface_proxy_set_interlaced(proxy, g_value_get_boolean(value));
|
|
||||||
break;
|
|
||||||
case PROP_TFF:
|
|
||||||
gst_vaapi_surface_proxy_set_tff(proxy, g_value_get_boolean(value));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_surface_proxy_get_property(
|
|
||||||
GObject *object,
|
|
||||||
guint prop_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GstVaapiSurfaceProxy * const proxy = GST_VAAPI_SURFACE_PROXY(object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
case PROP_CONTEXT:
|
|
||||||
g_value_set_pointer(value, gst_vaapi_surface_proxy_get_context(proxy));
|
|
||||||
break;
|
|
||||||
case PROP_SURFACE:
|
|
||||||
g_value_set_pointer(value, gst_vaapi_surface_proxy_get_surface(proxy));
|
|
||||||
break;
|
|
||||||
case PROP_TIMESTAMP:
|
|
||||||
g_value_set_uint64(value, gst_vaapi_surface_proxy_get_timestamp(proxy));
|
|
||||||
break;
|
|
||||||
case PROP_DURATION:
|
|
||||||
g_value_set_uint64(value, gst_vaapi_surface_proxy_get_duration(proxy));
|
|
||||||
break;
|
|
||||||
case PROP_INTERLACED:
|
|
||||||
g_value_set_boolean(value, gst_vaapi_surface_proxy_get_interlaced(proxy));
|
|
||||||
break;
|
|
||||||
case PROP_TFF:
|
|
||||||
g_value_set_boolean(value, gst_vaapi_surface_proxy_get_tff(proxy));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_vaapi_surface_proxy_class_init(GstVaapiSurfaceProxyClass *klass)
|
|
||||||
{
|
|
||||||
GObjectClass * const object_class = G_OBJECT_CLASS(klass);
|
|
||||||
|
|
||||||
g_type_class_add_private(klass, sizeof(GstVaapiSurfaceProxyPrivate));
|
|
||||||
|
|
||||||
object_class->finalize = gst_vaapi_surface_proxy_finalize;
|
|
||||||
object_class->set_property = gst_vaapi_surface_proxy_set_property;
|
|
||||||
object_class->get_property = gst_vaapi_surface_proxy_get_property;
|
|
||||||
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_CONTEXT,
|
|
||||||
g_param_spec_pointer("context",
|
|
||||||
"Context",
|
|
||||||
"The context stored in the proxy",
|
|
||||||
G_PARAM_READWRITE));
|
|
||||||
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_SURFACE,
|
|
||||||
g_param_spec_pointer("surface",
|
|
||||||
"Surface",
|
|
||||||
"The surface stored in the proxy",
|
|
||||||
G_PARAM_READWRITE));
|
|
||||||
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_TIMESTAMP,
|
|
||||||
g_param_spec_uint64("timestamp",
|
|
||||||
"Timestamp",
|
|
||||||
"The presentation time of the surface",
|
|
||||||
0, G_MAXUINT64, GST_CLOCK_TIME_NONE,
|
|
||||||
G_PARAM_READWRITE));
|
|
||||||
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_DURATION,
|
|
||||||
g_param_spec_uint64("duration",
|
|
||||||
"Duration",
|
|
||||||
"The amount of time the surface is to be presented",
|
|
||||||
0, G_MAXUINT64, GST_CLOCK_TIME_NONE,
|
|
||||||
G_PARAM_READWRITE));
|
|
||||||
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_INTERLACED,
|
|
||||||
g_param_spec_boolean("interlaced",
|
|
||||||
"Interlaced",
|
|
||||||
"Flag indicating whether surface is interlaced",
|
|
||||||
FALSE,
|
|
||||||
G_PARAM_READWRITE));
|
|
||||||
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class,
|
|
||||||
PROP_TFF,
|
|
||||||
g_param_spec_boolean("tff",
|
|
||||||
"Top-Field-First",
|
|
||||||
"Flag indicating for interlaced surfaces whether Top Field is First",
|
|
||||||
FALSE,
|
|
||||||
G_PARAM_READWRITE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_surface_proxy_init(GstVaapiSurfaceProxy *proxy)
|
gst_vaapi_surface_proxy_init(GstVaapiSurfaceProxy *proxy)
|
||||||
{
|
{
|
||||||
GstVaapiSurfaceProxyPrivate *priv;
|
proxy->timestamp = GST_CLOCK_TIME_NONE;
|
||||||
|
proxy->duration = GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
priv = GST_VAAPI_SURFACE_PROXY_GET_PRIVATE(proxy);
|
proxy->is_interlaced = FALSE;
|
||||||
proxy->priv = priv;
|
proxy->tff = FALSE;
|
||||||
priv->context = NULL;
|
}
|
||||||
priv->surface = NULL;
|
|
||||||
priv->timestamp = GST_CLOCK_TIME_NONE;
|
static inline const GstVaapiMiniObjectClass *
|
||||||
priv->duration = GST_CLOCK_TIME_NONE;
|
gst_vaapi_surface_proxy_class(void)
|
||||||
priv->is_interlaced = FALSE;
|
{
|
||||||
priv->tff = FALSE;
|
static const GstVaapiMiniObjectClass GstVaapiSurfaceProxyClass = {
|
||||||
|
sizeof(GstVaapiSurfaceProxy),
|
||||||
|
(GDestroyNotify)gst_vaapi_surface_proxy_finalize
|
||||||
|
};
|
||||||
|
return &GstVaapiSurfaceProxyClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,13 +91,111 @@ gst_vaapi_surface_proxy_init(GstVaapiSurfaceProxy *proxy)
|
||||||
GstVaapiSurfaceProxy *
|
GstVaapiSurfaceProxy *
|
||||||
gst_vaapi_surface_proxy_new(GstVaapiContext *context, GstVaapiSurface *surface)
|
gst_vaapi_surface_proxy_new(GstVaapiContext *context, GstVaapiSurface *surface)
|
||||||
{
|
{
|
||||||
|
GstVaapiMiniObject *object;
|
||||||
|
GstVaapiSurfaceProxy *proxy;
|
||||||
|
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_CONTEXT(context), NULL);
|
g_return_val_if_fail(GST_VAAPI_IS_CONTEXT(context), NULL);
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), NULL);
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), NULL);
|
||||||
|
|
||||||
return g_object_new(GST_VAAPI_TYPE_SURFACE_PROXY,
|
object = gst_vaapi_mini_object_new(gst_vaapi_surface_proxy_class());
|
||||||
"context", context,
|
if (!object)
|
||||||
"surface", surface,
|
return NULL;
|
||||||
NULL);
|
|
||||||
|
proxy = GST_VAAPI_SURFACE_PROXY(object);
|
||||||
|
gst_vaapi_surface_proxy_init(proxy);
|
||||||
|
gst_vaapi_surface_proxy_set_context(proxy, context);
|
||||||
|
gst_vaapi_surface_proxy_set_surface(proxy, surface);
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_surface_proxy_ref:
|
||||||
|
* @proxy: a #GstVaapiSurfaceProxy
|
||||||
|
*
|
||||||
|
* Atomically increases the reference count of the given @proxy by one.
|
||||||
|
*
|
||||||
|
* Returns: The same @proxy argument
|
||||||
|
*/
|
||||||
|
GstVaapiSurfaceProxy *
|
||||||
|
gst_vaapi_surface_proxy_ref(GstVaapiSurfaceProxy *proxy)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
||||||
|
|
||||||
|
return GST_VAAPI_SURFACE_PROXY(gst_vaapi_mini_object_ref(
|
||||||
|
GST_VAAPI_MINI_OBJECT(proxy)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_surface_proxy_unref:
|
||||||
|
* @proxy: a #GstVaapiSurfaceProxy
|
||||||
|
*
|
||||||
|
* Atomically decreases the reference count of the @proxy by one. If
|
||||||
|
* the reference count reaches zero, the object will be free'd.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_surface_proxy_unref(GstVaapiSurfaceProxy *proxy)
|
||||||
|
{
|
||||||
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
|
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(proxy));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_surface_proxy_replace:
|
||||||
|
* @old_proxy_ptr: a pointer to a #GstVaapiSurfaceProxy
|
||||||
|
* @new_proxy: a #GstVaapiSurfaceProxy
|
||||||
|
*
|
||||||
|
* Atomically replaces the proxy object held in @old_proxy_ptr with
|
||||||
|
* @new_proxy. This means that @old_proxy_ptr shall reference a valid
|
||||||
|
* object. However, @new_proxy can be NULL.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_surface_proxy_replace(GstVaapiSurfaceProxy **old_proxy_ptr,
|
||||||
|
GstVaapiSurfaceProxy *new_proxy)
|
||||||
|
{
|
||||||
|
g_return_if_fail(old_proxy_ptr != NULL);
|
||||||
|
|
||||||
|
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)old_proxy_ptr,
|
||||||
|
GST_VAAPI_MINI_OBJECT(new_proxy));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_surface_proxy_get_user_data:
|
||||||
|
* @proxy: a #GstVaapiSurfaceProxy
|
||||||
|
*
|
||||||
|
* Gets user-provided data set on the object via a previous call to
|
||||||
|
* gst_vaapi_surface_proxy_set_user_data().
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The previously set user_data
|
||||||
|
*/
|
||||||
|
gpointer
|
||||||
|
gst_vaapi_surface_proxy_get_user_data(GstVaapiSurfaceProxy *proxy)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
||||||
|
|
||||||
|
return gst_vaapi_mini_object_get_user_data(GST_VAAPI_MINI_OBJECT(proxy));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_surface_proxy_set_user_data:
|
||||||
|
* @proxy: a #GstVaapiSurfaceProxy
|
||||||
|
* @user_data: user-provided data
|
||||||
|
* @destroy_notify: (closure user_data): a #GDestroyNotify
|
||||||
|
*
|
||||||
|
* Sets @user_data on the object and the #GDestroyNotify that will be
|
||||||
|
* called when the data is freed.
|
||||||
|
*
|
||||||
|
* If some @user_data was previously set, then the former @destroy_notify
|
||||||
|
* function will be called before the @user_data is replaced.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_surface_proxy_set_user_data(GstVaapiSurfaceProxy *proxy,
|
||||||
|
gpointer user_data, GDestroyNotify destroy_notify)
|
||||||
|
{
|
||||||
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
|
gst_vaapi_mini_object_set_user_data(GST_VAAPI_MINI_OBJECT(proxy),
|
||||||
|
user_data, destroy_notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,7 +211,7 @@ gst_vaapi_surface_proxy_get_context(GstVaapiSurfaceProxy *proxy)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
||||||
|
|
||||||
return proxy->priv->context;
|
return proxy->context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,16 +229,12 @@ gst_vaapi_surface_proxy_set_context(
|
||||||
GstVaapiContext *context
|
GstVaapiContext *context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
GstVaapiSurfaceProxyPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
priv = proxy->priv;
|
g_clear_object(&proxy->context);
|
||||||
|
|
||||||
g_clear_object(&priv->context);
|
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
priv->context = g_object_ref(context);
|
proxy->context = g_object_ref(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,7 +250,7 @@ gst_vaapi_surface_proxy_get_surface(GstVaapiSurfaceProxy *proxy)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
||||||
|
|
||||||
return proxy->priv->surface;
|
return proxy->surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,9 +265,9 @@ GstVaapiID
|
||||||
gst_vaapi_surface_proxy_get_surface_id(GstVaapiSurfaceProxy *proxy)
|
gst_vaapi_surface_proxy_get_surface_id(GstVaapiSurfaceProxy *proxy)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), GST_VAAPI_ID_NONE);
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), GST_VAAPI_ID_NONE);
|
||||||
g_return_val_if_fail(proxy->priv->surface != NULL, GST_VAAPI_ID_NONE);
|
g_return_val_if_fail(proxy->surface != NULL, GST_VAAPI_ID_NONE);
|
||||||
|
|
||||||
return GST_VAAPI_OBJECT_ID(proxy->priv->surface);
|
return GST_VAAPI_OBJECT_ID(proxy->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,21 +285,17 @@ gst_vaapi_surface_proxy_set_surface(
|
||||||
GstVaapiSurface *surface
|
GstVaapiSurface *surface
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
GstVaapiSurfaceProxyPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
priv = proxy->priv;
|
if (proxy->surface) {
|
||||||
|
if (proxy->context)
|
||||||
if (priv->surface) {
|
gst_vaapi_context_put_surface(proxy->context, proxy->surface);
|
||||||
if (priv->context)
|
g_object_unref(proxy->surface);
|
||||||
gst_vaapi_context_put_surface(priv->context, priv->surface);
|
proxy->surface = NULL;
|
||||||
g_object_unref(priv->surface);
|
|
||||||
priv->surface = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface)
|
if (surface)
|
||||||
priv->surface = g_object_ref(surface);
|
proxy->surface = g_object_ref(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -361,9 +310,10 @@ gst_vaapi_surface_proxy_set_surface(
|
||||||
GstClockTime
|
GstClockTime
|
||||||
gst_vaapi_surface_proxy_get_timestamp(GstVaapiSurfaceProxy *proxy)
|
gst_vaapi_surface_proxy_get_timestamp(GstVaapiSurfaceProxy *proxy)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), GST_CLOCK_TIME_NONE);
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy),
|
||||||
|
GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
return proxy->priv->timestamp;
|
return proxy->timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -381,7 +331,7 @@ gst_vaapi_surface_proxy_set_timestamp(
|
||||||
{
|
{
|
||||||
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
proxy->priv->timestamp = timestamp;
|
proxy->timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -399,7 +349,7 @@ gst_vaapi_surface_proxy_get_duration(GstVaapiSurfaceProxy *proxy)
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy),
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy),
|
||||||
GST_CLOCK_TIME_NONE);
|
GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
return proxy->priv->duration;
|
return proxy->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,7 +367,7 @@ gst_vaapi_surface_proxy_set_duration(
|
||||||
{
|
{
|
||||||
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
proxy->priv->duration = duration;
|
proxy->duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -434,7 +384,7 @@ gst_vaapi_surface_proxy_get_interlaced(GstVaapiSurfaceProxy *proxy)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), FALSE);
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), FALSE);
|
||||||
|
|
||||||
return proxy->priv->is_interlaced;
|
return proxy->is_interlaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -450,7 +400,7 @@ gst_vaapi_surface_proxy_set_interlaced(GstVaapiSurfaceProxy *proxy, gboolean b)
|
||||||
{
|
{
|
||||||
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
proxy->priv->is_interlaced = b;
|
proxy->is_interlaced = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -466,7 +416,7 @@ gst_vaapi_surface_proxy_get_tff(GstVaapiSurfaceProxy *proxy)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), FALSE);
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), FALSE);
|
||||||
|
|
||||||
return proxy->priv->is_interlaced && proxy->priv->tff;
|
return proxy->is_interlaced && proxy->tff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -481,5 +431,5 @@ gst_vaapi_surface_proxy_set_tff(GstVaapiSurfaceProxy *proxy, gboolean tff)
|
||||||
{
|
{
|
||||||
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
proxy->priv->tff = tff;
|
proxy->tff = tff;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,35 +23,12 @@
|
||||||
#ifndef GST_VAAPI_SURFACE_PROXY_H
|
#ifndef GST_VAAPI_SURFACE_PROXY_H
|
||||||
#define GST_VAAPI_SURFACE_PROXY_H
|
#define GST_VAAPI_SURFACE_PROXY_H
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
#include <gst/vaapi/gstvaapicontext.h>
|
#include <gst/vaapi/gstvaapicontext.h>
|
||||||
#include <gst/vaapi/gstvaapisurface.h>
|
#include <gst/vaapi/gstvaapisurface.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_VAAPI_TYPE_SURFACE_PROXY \
|
typedef struct _GstVaapiSurfaceProxy GstVaapiSurfaceProxy;
|
||||||
(gst_vaapi_surface_proxy_get_type())
|
|
||||||
|
|
||||||
#define GST_VAAPI_SURFACE_PROXY(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
|
|
||||||
GST_VAAPI_TYPE_SURFACE_PROXY, \
|
|
||||||
GstVaapiSurfaceProxy))
|
|
||||||
|
|
||||||
#define GST_VAAPI_SURFACE_PROXY_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass), \
|
|
||||||
GST_VAAPI_TYPE_SURFACE_PROXY, \
|
|
||||||
GstVaapiSurfaceProxyClass))
|
|
||||||
|
|
||||||
#define GST_VAAPI_IS_SURFACE_PROXY(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_SURFACE_PROXY))
|
|
||||||
|
|
||||||
#define GST_VAAPI_IS_SURFACE_PROXY_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_SURFACE_PROXY))
|
|
||||||
|
|
||||||
#define GST_VAAPI_SURFACE_PROXY_GET_CLASS(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_CLASS((obj), \
|
|
||||||
GST_VAAPI_TYPE_SURFACE_PROXY, \
|
|
||||||
GstVaapiSurfaceProxyClass))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GST_VAAPI_SURFACE_PROXY_SURFACE:
|
* GST_VAAPI_SURFACE_PROXY_SURFACE:
|
||||||
|
@ -100,38 +77,26 @@ G_BEGIN_DECLS
|
||||||
#define GST_VAAPI_SURFACE_PROXY_TFF(surface) \
|
#define GST_VAAPI_SURFACE_PROXY_TFF(surface) \
|
||||||
gst_vaapi_surface_proxy_get_tff(surface)
|
gst_vaapi_surface_proxy_get_tff(surface)
|
||||||
|
|
||||||
typedef struct _GstVaapiSurfaceProxy GstVaapiSurfaceProxy;
|
|
||||||
typedef struct _GstVaapiSurfaceProxyPrivate GstVaapiSurfaceProxyPrivate;
|
|
||||||
typedef struct _GstVaapiSurfaceProxyClass GstVaapiSurfaceProxyClass;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiSurfaceProxy:
|
|
||||||
*
|
|
||||||
* A wrapper around a VA surface and context.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiSurfaceProxy {
|
|
||||||
/*< private >*/
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
GstVaapiSurfaceProxyPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiSurfaceProxyClass:
|
|
||||||
*
|
|
||||||
* A wrapper around a VA surface and context.
|
|
||||||
*/
|
|
||||||
struct _GstVaapiSurfaceProxyClass {
|
|
||||||
/*< private >*/
|
|
||||||
GObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_vaapi_surface_proxy_get_type(void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GstVaapiSurfaceProxy *
|
GstVaapiSurfaceProxy *
|
||||||
gst_vaapi_surface_proxy_new(GstVaapiContext *context, GstVaapiSurface *surface);
|
gst_vaapi_surface_proxy_new(GstVaapiContext *context, GstVaapiSurface *surface);
|
||||||
|
|
||||||
|
GstVaapiSurfaceProxy *
|
||||||
|
gst_vaapi_surface_proxy_ref(GstVaapiSurfaceProxy *proxy);
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_vaapi_surface_proxy_unref(GstVaapiSurfaceProxy *proxy);
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_vaapi_surface_proxy_replace(GstVaapiSurfaceProxy **old_proxy_ptr,
|
||||||
|
GstVaapiSurfaceProxy *new_proxy);
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
gst_vaapi_surface_proxy_get_user_data(GstVaapiSurfaceProxy *proxy);
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_vaapi_surface_proxy_set_user_data(GstVaapiSurfaceProxy *proxy,
|
||||||
|
gpointer user_data, GDestroyNotify destroy_notify);
|
||||||
|
|
||||||
GstVaapiContext *
|
GstVaapiContext *
|
||||||
gst_vaapi_surface_proxy_get_context(GstVaapiSurfaceProxy *proxy);
|
gst_vaapi_surface_proxy_get_context(GstVaapiSurfaceProxy *proxy);
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ gst_vaapi_video_buffer_destroy_surface(GstVaapiVideoBuffer *buffer)
|
||||||
{
|
{
|
||||||
GstVaapiVideoBufferPrivate * const priv = buffer->priv;
|
GstVaapiVideoBufferPrivate * const priv = buffer->priv;
|
||||||
|
|
||||||
g_clear_object(&priv->proxy);
|
gst_vaapi_surface_proxy_replace(&priv->proxy, NULL);
|
||||||
|
|
||||||
if (priv->surface) {
|
if (priv->surface) {
|
||||||
if (priv->surface_pool)
|
if (priv->surface_pool)
|
||||||
|
@ -353,7 +353,7 @@ gst_vaapi_video_buffer_typed_new_with_surface_proxy(
|
||||||
{
|
{
|
||||||
GstVaapiVideoBuffer *buffer;
|
GstVaapiVideoBuffer *buffer;
|
||||||
|
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
g_return_val_if_fail(proxy != NULL, NULL);
|
||||||
|
|
||||||
buffer = _gst_vaapi_video_buffer_typed_new(type);
|
buffer = _gst_vaapi_video_buffer_typed_new(type);
|
||||||
if (buffer)
|
if (buffer)
|
||||||
|
@ -570,7 +570,7 @@ gst_vaapi_video_buffer_set_surface_proxy(
|
||||||
GstVaapiSurface *surface;
|
GstVaapiSurface *surface;
|
||||||
|
|
||||||
g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer));
|
g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer));
|
||||||
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
g_return_if_fail(proxy != NULL);
|
||||||
|
|
||||||
gst_vaapi_video_buffer_destroy_surface(buffer);
|
gst_vaapi_video_buffer_destroy_surface(buffer);
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ gst_vaapi_video_buffer_set_surface_proxy(
|
||||||
if (!surface)
|
if (!surface)
|
||||||
return;
|
return;
|
||||||
set_surface(buffer, surface);
|
set_surface(buffer, surface);
|
||||||
buffer->priv->proxy = g_object_ref(proxy);
|
buffer->priv->proxy = gst_vaapi_surface_proxy_ref(proxy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ gst_vaapidecode_update_src_caps(GstVaapiDecode *decode, GstCaps *caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapidecode_release(GstVaapiDecode *decode, GObject *dead_object)
|
gst_vaapidecode_release(GstVaapiDecode *decode)
|
||||||
{
|
{
|
||||||
g_mutex_lock(&decode->decoder_mutex);
|
g_mutex_lock(&decode->decoder_mutex);
|
||||||
g_cond_signal(&decode->decoder_ready);
|
g_cond_signal(&decode->decoder_ready);
|
||||||
|
@ -216,11 +216,8 @@ gst_vaapidecode_step(GstVaapiDecode *decode)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_weak_ref(
|
gst_vaapi_surface_proxy_set_user_data(proxy,
|
||||||
G_OBJECT(proxy),
|
decode, (GDestroyNotify)gst_vaapidecode_release);
|
||||||
(GWeakNotify)gst_vaapidecode_release,
|
|
||||||
decode
|
|
||||||
);
|
|
||||||
|
|
||||||
buffer = gst_vaapi_video_buffer_new(decode->display);
|
buffer = gst_vaapi_video_buffer_new(decode->display);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
|
@ -247,7 +244,7 @@ gst_vaapidecode_step(GstVaapiDecode *decode)
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto error_commit_buffer;
|
goto error_commit_buffer;
|
||||||
|
|
||||||
g_object_unref(proxy);
|
gst_vaapi_surface_proxy_unref(proxy);
|
||||||
}
|
}
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
@ -281,13 +278,13 @@ error_create_buffer:
|
||||||
GST_DEBUG("video sink failed to create video buffer for proxy'ed "
|
GST_DEBUG("video sink failed to create video buffer for proxy'ed "
|
||||||
"surface %" GST_VAAPI_ID_FORMAT,
|
"surface %" GST_VAAPI_ID_FORMAT,
|
||||||
GST_VAAPI_ID_ARGS(surface_id));
|
GST_VAAPI_ID_ARGS(surface_id));
|
||||||
g_object_unref(proxy);
|
gst_vaapi_surface_proxy_unref(proxy);
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_UNEXPECTED;
|
||||||
}
|
}
|
||||||
error_commit_buffer:
|
error_commit_buffer:
|
||||||
{
|
{
|
||||||
GST_DEBUG("video sink rejected the video buffer (error %d)", ret);
|
GST_DEBUG("video sink rejected the video buffer (error %d)", ret);
|
||||||
g_object_unref(proxy);
|
gst_vaapi_surface_proxy_unref(proxy);
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_UNEXPECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,7 +363,7 @@ gst_vaapidecode_destroy(GstVaapiDecode *decode)
|
||||||
decode->decoder_caps = NULL;
|
decode->decoder_caps = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_vaapidecode_release(decode, NULL);
|
gst_vaapidecode_release(decode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -122,7 +122,7 @@ gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy)
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
GstVaapiSurface *surface;
|
GstVaapiSurface *surface;
|
||||||
|
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
g_return_val_if_fail(proxy != NULL, NULL);
|
||||||
|
|
||||||
surface = gst_vaapi_surface_proxy_get_surface(proxy);
|
surface = gst_vaapi_surface_proxy_get_surface(proxy);
|
||||||
if (!surface)
|
if (!surface)
|
||||||
|
|
|
@ -194,7 +194,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
pause();
|
pause();
|
||||||
|
|
||||||
g_object_unref(proxy);
|
gst_vaapi_surface_proxy_unref(proxy);
|
||||||
g_object_unref(decoder);
|
g_object_unref(decoder);
|
||||||
g_object_unref(window);
|
g_object_unref(window);
|
||||||
g_object_unref(display);
|
g_object_unref(display);
|
||||||
|
|
|
@ -219,7 +219,7 @@ main(int argc, char *argv[])
|
||||||
pause();
|
pause();
|
||||||
|
|
||||||
gst_buffer_unref(buffer);
|
gst_buffer_unref(buffer);
|
||||||
g_object_unref(proxy);
|
gst_vaapi_surface_proxy_unref(proxy);
|
||||||
g_object_unref(decoder);
|
g_object_unref(decoder);
|
||||||
g_object_unref(window);
|
g_object_unref(window);
|
||||||
g_object_unref(display);
|
g_object_unref(display);
|
||||||
|
|
Loading…
Reference in a new issue