summaryrefslogtreecommitdiff
path: root/gst-libs/gst/video/gstsurfaceconverter.c
blob: 9404c5879fb15eb5e5ffd2dca5a961a28e6212e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* 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
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "gstsurfaceconverter.h"
#include "gstsurfacemeta.h"

/**
 * 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>
 *   The GstSurfaceConverter interface is unstable API and may change in future.
 *   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
 * @buffer: the #GstBuffer to upload
 *
 * Convert and uploads the #GstSurfaceBuffer to the converter destination.
 *
 * Returns: #TRUE on success, #FALSE otherwise
 */
gboolean
gst_surface_converter_upload (GstSurfaceConverter * converter,
    GstBuffer * buffer)
{
  g_return_val_if_fail (GST_IS_SURFACE_CONVERTER (converter), FALSE);
  g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
  return GST_SURFACE_CONVERTER_GET_IFACE (converter)->upload (converter,
      buffer);
}