gstreamer/gst-libs/gst/vaapi/gstvaapivideobuffer.c

107 lines
3 KiB
C
Raw Normal View History

2010-03-12 23:48:50 +00:00
/*
* gstvaapivideobuffer.c - Gst VA video buffer
*
* Copyright (C) 2010-2011 Splitted-Desktop Systems
* Copyright (C) 2011-2013 Intel Corporation
2010-03-12 23:48:50 +00:00
*
2011-06-14 11:51:41 +00:00
* 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.
2010-03-12 23:48:50 +00:00
*
2011-06-14 11:51:41 +00:00
* This library is distributed in the hope that it will be useful,
2010-03-12 23:48:50 +00:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2011-06-14 11:51:41 +00:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
2010-03-12 23:48:50 +00:00
*
2011-06-14 11:51:41 +00:00
* 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
2010-03-12 23:48:50 +00:00
*/
2010-03-19 16:41:52 +00:00
/**
2010-03-24 08:16:32 +00:00
* SECTION:gstvaapivideobuffer
* @short_description: VA video buffer for GStreamer
2010-03-19 16:41:52 +00:00
*/
#include "sysdeps.h"
2010-03-12 23:48:50 +00:00
#include "gstvaapivideobuffer.h"
#define DEBUG 1
#include "gstvaapidebug.h"
2010-03-12 23:48:50 +00:00
G_DEFINE_TYPE(GstVaapiVideoBuffer,
gst_vaapi_video_buffer,
GST_TYPE_SURFACE_BUFFER)
2010-03-12 23:48:50 +00:00
typedef GstSurfaceConverter *(*GstSurfaceConverterCreateFunc)(
GstSurfaceBuffer *surface, const gchar *type, GValue *dest);
2010-03-12 23:48:50 +00:00
static GstSurfaceConverter *
gst_vaapi_video_buffer_create_converter(GstSurfaceBuffer *surface,
const gchar *type, GValue *dest)
{
GstVaapiVideoBuffer * const vbuffer = GST_VAAPI_VIDEO_BUFFER(surface);
GstSurfaceConverterCreateFunc func;
2010-03-12 23:48:50 +00:00
func = (GstSurfaceConverterCreateFunc)
gst_vaapi_video_meta_get_surface_converter(vbuffer->meta);
return func ? func(surface, type, dest) : NULL;
2010-03-12 23:48:50 +00:00
}
static void
gst_vaapi_video_buffer_class_init(GstVaapiVideoBufferClass *klass)
{
GstSurfaceBufferClass * const surface_class =
GST_SURFACE_BUFFER_CLASS(klass);
2010-03-12 23:48:50 +00:00
surface_class->create_converter = gst_vaapi_video_buffer_create_converter;
2010-03-12 23:48:50 +00:00
}
static void
gst_vaapi_video_buffer_init(GstVaapiVideoBuffer *buffer)
{
}
2010-04-29 21:56:10 +00:00
/**
* gst_vaapi_video_buffer_new:
* @meta: a #GstVaapiVideoMeta
2010-04-29 21:56:10 +00:00
*
* Creates a #GstBuffer that holds video @meta information.
*
2010-04-29 21:56:10 +00:00
* Return value: the newly allocated #GstBuffer, or %NULL or error
*/
GstBuffer *
gst_vaapi_video_buffer_new(GstVaapiVideoMeta *meta)
2010-04-29 21:56:10 +00:00
{
GstBuffer *buffer;
g_return_val_if_fail(meta != NULL, NULL);
buffer = GST_BUFFER_CAST(gst_mini_object_new(GST_TYPE_SURFACE_BUFFER));
if (!buffer)
return NULL;
gst_buffer_set_vaapi_video_meta(buffer, meta);
return buffer;
2010-03-12 23:48:50 +00:00
}
2010-03-19 16:41:52 +00:00
/**
* gst_vaapi_video_buffer_get_meta:
2010-03-19 16:41:52 +00:00
* @buffer: a #GstVaapiVideoBuffer
*
* Returns the #GstVaapiVideoMeta associated to this @buffer.
2010-03-19 16:41:52 +00:00
*
* Return value: the #GstVaapiVideoMeta bound to the @buffer, or %NULL
* if none was found
2010-03-19 16:41:52 +00:00
*/
GstVaapiVideoMeta *
gst_vaapi_video_buffer_get_meta(GstVaapiVideoBuffer *buffer)
2010-03-12 23:48:50 +00:00
{
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL);
return buffer->meta;
}