2 * gstvaapisurfaceproxy.c - VA surface proxy
4 * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 * SECTION:gstvaapisurfaceproxy
23 * @short_description: VA surface proxy
27 #include "gstvaapisurfaceproxy.h"
30 #include "gstvaapidebug.h"
32 G_DEFINE_TYPE(GstVaapiSurfaceProxy, gst_vaapi_surface_proxy, G_TYPE_OBJECT);
42 gst_vaapi_surface_proxy_finalize(GObject *object)
44 GstVaapiSurfaceProxy * const proxy = GST_VAAPI_SURFACE_PROXY(object);
48 gst_vaapi_context_put_surface(proxy->context, proxy->surface);
49 g_object_unref(proxy->surface);
50 proxy->surface = NULL;
54 g_object_unref(proxy->context);
55 proxy->context = NULL;
58 G_OBJECT_CLASS(gst_vaapi_surface_proxy_parent_class)->finalize(object);
62 gst_vaapi_surface_proxy_set_property(
69 GstVaapiSurfaceProxy * const proxy = GST_VAAPI_SURFACE_PROXY(object);
73 gst_vaapi_surface_proxy_set_context(proxy, g_value_get_pointer(value));
76 gst_vaapi_surface_proxy_set_surface(proxy, g_value_get_pointer(value));
79 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
85 gst_vaapi_surface_proxy_get_property(
92 GstVaapiSurfaceProxy * const proxy = GST_VAAPI_SURFACE_PROXY(object);
96 g_value_set_pointer(value, gst_vaapi_surface_proxy_get_context(proxy));
99 g_value_set_pointer(value, gst_vaapi_surface_proxy_get_surface(proxy));
102 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
108 gst_vaapi_surface_proxy_class_init(GstVaapiSurfaceProxyClass *klass)
110 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
112 object_class->finalize = gst_vaapi_surface_proxy_finalize;
113 object_class->set_property = gst_vaapi_surface_proxy_set_property;
114 object_class->get_property = gst_vaapi_surface_proxy_get_property;
116 g_object_class_install_property
119 g_param_spec_pointer("context",
121 "The context stored in the proxy",
124 g_object_class_install_property
127 g_param_spec_pointer("surface",
129 "The surface stored in the proxy",
134 gst_vaapi_surface_proxy_init(GstVaapiSurfaceProxy *proxy)
136 proxy->context = NULL;
137 proxy->surface = NULL;
141 * gst_vaapi_surface_proxy_new:
142 * @context: a #GstVaapiContext
143 * @surface: a #GstVaapiSurface
145 * Creates a new #GstVaapiSurfaceProxy with the specified context and
148 * Return value: the newly allocated #GstVaapiSurfaceProxy object
150 GstVaapiSurfaceProxy *
151 gst_vaapi_surface_proxy_new(GstVaapiContext *context, GstVaapiSurface *surface)
153 g_return_val_if_fail(GST_VAAPI_IS_CONTEXT(context), NULL);
154 g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), NULL);
156 return g_object_new(GST_VAAPI_TYPE_SURFACE_PROXY,
163 * gst_vaapi_surface_proxy_get_context:
164 * @proxy: a #GstVaapiSurfaceProxy
166 * Returns the #GstVaapiContext stored in the @proxy.
168 * Return value: the #GstVaapiContext
171 gst_vaapi_surface_proxy_get_context(GstVaapiSurfaceProxy *proxy)
173 g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
175 return proxy->context;
179 * gst_vaapi_surface_proxy_set_context:
180 * @proxy: a #GstVaapiSurfaceProxy
181 * @context: the new #GstVaapiContext to be stored in @proxy
183 * Stores a new @context into the @proxy. The proxy releases the
184 * previous reference, if any, and then holds a reference to the new
188 gst_vaapi_surface_proxy_set_context(
189 GstVaapiSurfaceProxy *proxy,
190 GstVaapiContext *context
193 g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
194 g_return_if_fail(GST_VAAPI_IS_CONTEXT(context));
196 if (proxy->context) {
197 g_object_unref(proxy->context);
198 proxy->context = NULL;
202 proxy->context = g_object_ref(context);
206 * gst_vaapi_surface_proxy_get_surface:
207 * @proxy: a #GstVaapiSurfaceProxy
209 * Returns the #GstVaapiSurface stored in the @proxy.
211 * Return value: the #GstVaapiSurface
214 gst_vaapi_surface_proxy_get_surface(GstVaapiSurfaceProxy *proxy)
216 g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
218 return proxy->surface;
222 * gst_vaapi_surface_proxy_set_surface:
223 * @proxy: a #GstVaapiSurfaceProxy
224 * @surface: the new #GstVaapiSurface to be stored in @proxy
226 * Stores a new @surface into the @proxy. The proxy releases the
227 * previous reference, if any, and then holds a reference to the new
231 gst_vaapi_surface_proxy_set_surface(
232 GstVaapiSurfaceProxy *proxy,
233 GstVaapiSurface *surface
236 g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
237 g_return_if_fail(GST_VAAPI_IS_SURFACE(surface));
239 if (proxy->surface) {
240 g_object_unref(proxy->surface);
241 proxy->surface = NULL;
245 proxy->surface = g_object_ref(surface);