#include <assert.h>
#include "gstvaapicompat.h"
#include "gstvaapicontext.h"
+#include "gstvaapisurface.h"
+#include "gstvaapisurface_priv.h"
#include "gstvaapisurfacepool.h"
#include "gstvaapiutils.h"
#include "gstvaapi_priv.h"
static void
unref_surface_cb(gpointer data, gpointer user_data)
{
- g_object_unref(GST_VAAPI_SURFACE(data));
+ GstVaapiSurface * const surface = GST_VAAPI_SURFACE(data);
+
+ gst_vaapi_surface_set_parent_context(surface, NULL);
+ g_object_unref(surface);
}
static void
g_ptr_array_add(priv->surfaces, surface);
if (!gst_vaapi_video_pool_add_object(priv->surfaces_pool, surface))
return FALSE;
+ gst_vaapi_surface_set_parent_context(surface, context);
}
return TRUE;
}
#include "gstvaapicompat.h"
#include "gstvaapiutils.h"
#include "gstvaapisurface.h"
+#include "gstvaapisurface_priv.h"
+#include "gstvaapicontext.h"
#include "gstvaapiimage.h"
#include "gstvaapi_priv.h"
guint height;
GstVaapiChromaType chroma_type;
GPtrArray *subpictures;
+ GstVaapiContext *parent_context;
};
enum {
PROP_WIDTH,
PROP_HEIGHT,
- PROP_CHROMA_TYPE
+ PROP_CHROMA_TYPE,
+ PROP_PARENT_CONTEXT
};
static gboolean
GST_DEBUG("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(surface_id));
gst_vaapi_surface_destroy_subpictures(surface);
+ gst_vaapi_surface_set_parent_context(surface, NULL);
if (surface_id != VA_INVALID_SURFACE) {
GST_VAAPI_DISPLAY_LOCK(display);
case PROP_CHROMA_TYPE:
priv->chroma_type = g_value_get_uint(value);
break;
+ case PROP_PARENT_CONTEXT:
+ gst_vaapi_surface_set_parent_context(surface, g_value_get_object(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
case PROP_CHROMA_TYPE:
g_value_set_uint(value, gst_vaapi_surface_get_chroma_type(surface));
break;
+ case PROP_PARENT_CONTEXT:
+ g_value_set_object(value, gst_vaapi_surface_get_parent_context(surface));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
"The chroma type of the surface",
0, G_MAXUINT32, 0,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (object_class,
+ PROP_PARENT_CONTEXT,
+ g_param_spec_object("parent-context",
+ "Parent Context",
+ "The parent context, if any",
+ GST_VAAPI_TYPE_CONTEXT,
+ G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
}
static void
{
GstVaapiSurfacePrivate *priv = GST_VAAPI_SURFACE_GET_PRIVATE(surface);
- surface->priv = priv;
- priv->width = 0;
- priv->height = 0;
- priv->chroma_type = 0;
- priv->subpictures = NULL;
+ surface->priv = priv;
+ priv->width = 0;
+ priv->height = 0;
+ priv->chroma_type = 0;
+ priv->subpictures = NULL;
+ priv->parent_context = NULL;
}
/**
}
/**
+ * gst_vaapi_surface_set_parent_context:
+ * @surface: a #GstVaapiSurface
+ * @context: a #GstVaapiContext
+ *
+ * Sets new parent context, or clears any parent context if @context
+ * is %NULL. This function owns an extra reference to the context,
+ * which will be released when the surface is destroyed.
+ */
+void
+gst_vaapi_surface_set_parent_context(
+ GstVaapiSurface *surface,
+ GstVaapiContext *context
+)
+{
+ GstVaapiSurfacePrivate *priv;
+
+ g_return_if_fail(GST_VAAPI_IS_SURFACE(surface));
+
+ priv = surface->priv;
+
+ if (priv->parent_context) {
+ g_object_unref(priv->parent_context);
+ priv->parent_context = NULL;
+ }
+
+ if (context)
+ priv->parent_context = g_object_ref(context);
+}
+
+/**
+ * gst_vaapi_surface_get_parent_context:
+ * @surface: a #GstVaapiSurface
+ *
+ * Retrieves the parent #GstVaapiContext, or %NULL if there is
+ * none. The surface shall still own a reference to the context.
+ * i.e. the caller shall not unreference the returned context object.
+ *
+ * Return value: the parent context, if any.
+ */
+GstVaapiContext *
+gst_vaapi_surface_get_parent_context(GstVaapiSurface *surface)
+{
+ g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), NULL);
+
+ return surface->priv->parent_context;
+}
+
+/**
* gst_vaapi_surface_derive_image:
* @surface: a #GstVaapiSurface
*
--- /dev/null
+/*
+ * gstvaapisurface_priv.h - VA surface abstraction (private data)
+ *
+ * Copyright (C) 2011 Intel Corporation
+ *
+ * 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.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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
+ */
+
+#ifndef GST_VAAPI_SURFACE_PRIV_H
+#define GST_VAAPI_SURFACE_PRIV_H
+
+#include <gst/vaapi/gstvaapisurface.h>
+
+void
+gst_vaapi_surface_set_parent_context(
+ GstVaapiSurface *surface,
+ GstVaapiContext *context
+) attribute_hidden;
+
+#endif /* GST_VAAPI_SURFACE_PRIV_H */