2011-10-07 23:05:30 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2011 Collabora Ltd.
|
|
|
|
* Copyright (C) 2011 Intel
|
|
|
|
*
|
|
|
|
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2011-10-07 23:05:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstsurfaceconverter.h"
|
2011-11-04 10:24:53 +00:00
|
|
|
#include "gstsurfacemeta.h"
|
2011-10-07 23:05:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gstsurfaceconverter
|
|
|
|
* @short_description: Interface for #GstSurfaceBuffer convertion
|
|
|
|
*
|
|
|
|
* Objects implementing this interface are used as a convertion context. This
|
|
|
|
* allow element optimizing the upload by keeping required resources between
|
|
|
|
* uploads. The context must be discarded when the pipeline goes to
|
|
|
|
* #GST_STATE_NULL or renewed whenever the caps are changed.
|
|
|
|
* <note>
|
2012-04-18 09:02:52 +00:00
|
|
|
* The GstSurfaceConverter interface is unstable API and may change in future.
|
2011-10-07 23:05:30 +00:00
|
|
|
* One can define GST_USE_UNSTABLE_API to acknowledge and avoid this warning.
|
|
|
|
* </note>
|
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <title>Example uploading to GL texture</title>
|
|
|
|
* |[
|
|
|
|
* if (G_UNLIKELY (priv->converter == NULL))
|
|
|
|
* priv->converter = gst_surface_buffer_create_converter (surface, "opengl", &value);
|
|
|
|
*
|
|
|
|
* gst_surface_converter_uplaod (priv->converter, surface);
|
|
|
|
* ]|
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
|
|
|
G_DEFINE_INTERFACE (GstSurfaceConverter, gst_surface_converter, G_TYPE_INVALID);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_surface_converter_default_init (GstSurfaceConverterInterface * iface)
|
|
|
|
{
|
|
|
|
/* default virtual functions */
|
|
|
|
iface->upload = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_surface_converter_upload:
|
|
|
|
* @converter: a #GstSurfaceConverter
|
2011-11-04 10:24:53 +00:00
|
|
|
* @buffer: the #GstBuffer to upload
|
2011-10-07 23:05:30 +00:00
|
|
|
*
|
|
|
|
* Convert and uploads the #GstSurfaceBuffer to the converter destination.
|
|
|
|
*
|
|
|
|
* Returns: #TRUE on success, #FALSE otherwise
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_surface_converter_upload (GstSurfaceConverter * converter,
|
2011-11-04 10:24:53 +00:00
|
|
|
GstBuffer * buffer)
|
2011-10-07 23:05:30 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_SURFACE_CONVERTER (converter), FALSE);
|
2011-11-04 10:24:53 +00:00
|
|
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
2011-10-07 23:05:30 +00:00
|
|
|
return GST_SURFACE_CONVERTER_GET_IFACE (converter)->upload (converter,
|
|
|
|
buffer);
|
|
|
|
}
|