video: port somewhat to 0.11

In 0.11 this should be done differently
This commit is contained in:
Wim Taymans 2011-11-04 11:24:53 +01:00
parent f4c283a9cc
commit 8e5579c594
8 changed files with 109 additions and 144 deletions

View file

@ -8,7 +8,7 @@ libgstbasevideo_@GST_MAJORMINOR@_la_SOURCES = \
gstbasevideoutils.c \
gstbasevideodecoder.c \
gstbasevideoencoder.c \
gstsurfacebuffer.c \
gstsurfacemeta.c \
gstsurfaceconverter.c \
videocontext.c
@ -18,7 +18,7 @@ libgstbasevideo_@GST_MAJORMINOR@include_HEADERS = \
gstbasevideoutils.h \
gstbasevideodecoder.h \
gstbasevideoencoder.h \
gstsurfacebuffer.h \
gstsurfacemeta.h \
gstsurfaceconverter.h \
videocontext.h

View file

@ -1,93 +0,0 @@
/* 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.
*/
#ifndef _GST_SURFACE_BUFFER_H_
#define _GST_SURFACE_BUFFER_H_
#ifndef GST_USE_UNSTABLE_API
#warning "GstSurfaceBuffer is unstable API and may change in future."
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
#endif
#include <gst/gst.h>
#include <gst/video/gstsurfaceconverter.h>
G_BEGIN_DECLS
#define GST_TYPE_SURFACE_BUFFER (gst_surface_buffer_get_type())
#define GST_SURFACE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SURFACE_BUFFER,GstSurfaceBuffer))
#define GST_SURFACE_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SURFACE_BUFFER,GstSurfaceBufferClass))
#define GST_SURFACE_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_SURFACE_BUFFER,GstSurfaceBufferClass))
#define GST_IS_SURFACE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SURFACE_BUFFER))
#define GST_IS_SURFACE_BUFFER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SURFACE_BUFFER))
/**
* GST_VIDEO_CAPS_SURFACE:
*
* Base caps for GstSurfaceBuffer. Implementation specific type must be marked
* using the type attribute (e.g. type=vaapi). Available convertion shall be
* specified using boolean attributes (e.g. opengl=true).
*/
#define GST_VIDEO_CAPS_SURFACE "video/x-surface"
typedef struct _GstSurfaceBufferClass GstSurfaceBufferClass;
/**
* GstSurfaceBuffer:
* @parent: parent object
*/
struct _GstSurfaceBuffer
{
GstBuffer parent;
/*< private >*/
void *padding[GST_PADDING];
};
/**
* GstSurfaceBufferClass:
* @parent_class: parent class type.
* @create_converter: vmethod to create a converter.
*
* #GstVideoContextInterface interface.
*/
struct _GstSurfaceBufferClass
{
GstBufferClass parent_class;
GstSurfaceConverter * (*create_converter) (GstSurfaceBuffer *buffer,
const gchar *type,
GValue *dest);
/*< private >*/
void *padding[GST_PADDING];
};
GType gst_surface_buffer_get_type (void);
GstSurfaceConverter *gst_surface_buffer_create_converter (GstSurfaceBuffer *buffer,
const gchar *type,
GValue *dest);
G_END_DECLS
#endif

View file

@ -25,7 +25,7 @@
#endif
#include "gstsurfaceconverter.h"
#include "gstsurfacebuffer.h"
#include "gstsurfacemeta.h"
/**
* SECTION:gstsurfaceconverter
@ -63,7 +63,7 @@ gst_surface_converter_default_init (GstSurfaceConverterInterface * iface)
/**
* gst_surface_converter_upload:
* @converter: a #GstSurfaceConverter
* @buffer: the #GstSurfaceBuffer to upload
* @buffer: the #GstBuffer to upload
*
* Convert and uploads the #GstSurfaceBuffer to the converter destination.
*
@ -71,10 +71,10 @@ gst_surface_converter_default_init (GstSurfaceConverterInterface * iface)
*/
gboolean
gst_surface_converter_upload (GstSurfaceConverter * converter,
GstSurfaceBuffer * buffer)
GstBuffer * buffer)
{
g_return_val_if_fail (GST_IS_SURFACE_CONVERTER (converter), FALSE);
g_return_val_if_fail (GST_IS_SURFACE_BUFFER (buffer), FALSE);
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
return GST_SURFACE_CONVERTER_GET_IFACE (converter)->upload (converter,
buffer);
}

View file

@ -32,12 +32,9 @@
G_BEGIN_DECLS
/* Forward declaration from gstsurfacebuffer.h */
typedef struct _GstSurfaceBuffer GstSurfaceBuffer;
#define GST_TYPE_SURFACE_CONVERTER (gst_surface_converter_get_type ())
#define GST_SURFACE_CONVERTER(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SURFACE_CONVERTER, GstSurfaceConverter))
#define GST_IS_SURFACE_CONVERTER(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SURFACE_CONVERTER))
#define GST_SURFACE_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SURFACE_CONVERTER, GstSurfaceConverter))
#define GST_IS_SURFACE_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SURFACE_CONVERTER))
#define GST_SURFACE_CONVERTER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_SURFACE_CONVERTER, GstSurfaceConverterInterface))
typedef struct _GstSurfaceConverter GstSurfaceConverter;
@ -55,13 +52,13 @@ struct _GstSurfaceConverterInterface
GTypeInterface parent;
gboolean (*upload) (GstSurfaceConverter *converter,
GstSurfaceBuffer *buffer);
GstBuffer *buffer);
};
GType gst_surface_converter_get_type (void);
gboolean gst_surface_converter_upload (GstSurfaceConverter *converter,
GstSurfaceBuffer *buffer);
GstBuffer *buffer);
G_END_DECLS

View file

@ -24,13 +24,13 @@
#include "config.h"
#endif
#include "gstsurfacebuffer.h"
#include "gstsurfacemeta.h"
/**
* SECTION:gstsurfacebuffer
* @short_description: Accelerated surface base class
* SECTION:gstsurfacemeta
* @short_description: Accelerated surface metadata
*
* This base class is used to abstract hardware accelerated buffers and enable
* This meta data is used to abstract hardware accelerated buffers and enable
* generic convertion to standard type such as GL textures. The media type for
* those buffers is defined by #GST_VIDEO_CAPS_SURFACE. An implementation
* specific type must be set using the "type" key (e.g. type="vaapi").
@ -44,30 +44,25 @@
* </note>
*/
G_DEFINE_TYPE (GstSurfaceBuffer, gst_surface_buffer, GST_TYPE_BUFFER);
static GstSurfaceConverter *
gst_surface_buffer_default_create_converter (GstSurfaceBuffer * surface,
const gchar * type, GValue * dest)
const GstMetaInfo *
gst_surface_meta_get_info (void)
{
return NULL;
}
static const GstMetaInfo *meta_info = NULL;
static void
gst_surface_buffer_class_init (GstSurfaceBufferClass * klass)
{
klass->create_converter = gst_surface_buffer_default_create_converter;
}
static void
gst_surface_buffer_init (GstSurfaceBuffer * surface)
{
/* Nothing to do */
if (meta_info == NULL) {
meta_info = gst_meta_register ("GstSurfaceMeta", "GstSurfaceMeta",
sizeof (GstSurfaceMeta),
(GstMetaInitFunction) NULL,
(GstMetaFreeFunction) NULL,
(GstMetaCopyFunction) NULL, (GstMetaTransformFunction) NULL);
}
return meta_info;
}
/**
* gst_surface_buffer_create_converter:
* @buffer: a #GstSurfaceBuffer
* gst_surface_meta_create_converter:
* @meta: a #GstSurfaceMeta
* @type: the type to convert to
* @dest: a #GValue containing the destination to upload
*
@ -79,10 +74,10 @@ gst_surface_buffer_init (GstSurfaceBuffer * surface)
* Returns: newly allocated #GstSurfaceConverter
*/
GstSurfaceConverter *
gst_surface_buffer_create_converter (GstSurfaceBuffer * buffer,
gst_surface_meta_create_converter (GstSurfaceMeta * meta,
const gchar * type, GValue * dest)
{
g_return_val_if_fail (GST_IS_SURFACE_BUFFER (buffer), FALSE);
return GST_SURFACE_BUFFER_GET_CLASS (buffer)->create_converter (buffer,
type, dest);
g_return_val_if_fail (meta != NULL, FALSE);
return meta->create_converter (meta, type, dest);
}

View file

@ -0,0 +1,65 @@
/* 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.
*/
#ifndef _GST_SURFACE_META_H_
#define _GST_SURFACE_META_H_
#ifndef GST_USE_UNSTABLE_API
#warning "GstSurfaceBuffer is unstable API and may change in future."
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
#endif
#include <gst/gst.h>
#include <gst/video/gstsurfaceconverter.h>
G_BEGIN_DECLS
typedef struct _GstSurfaceMeta GstSurfaceMeta;
/**
* GstSurfaceMeta:
* @create_converter: vmethod to create a converter.
*
*/
struct _GstSurfaceMeta {
GstMeta meta;
GstSurfaceConverter * (*create_converter) (GstSurfaceMeta *meta,
const gchar *type,
GValue *dest);
};
const GstMetaInfo *gst_surface_meta_get_info (void);
#define GST_SURFACE_META_INFO (gst_surface_meta_get_info())
#define gst_buffer_get_surface_meta(b) \
((GstSurfaceMeta*)gst_buffer_get_meta((b),GST_SURFACE_META_INFO))
#define gst_buffer_add_surface_meta(b) \
((GstSurfaceMeta*)gst_buffer_add_meta((b),GST_SURFACE_META_INFO,NULL))
GstSurfaceConverter *gst_surface_meta_create_converter (GstSurfaceMeta *meta,
const gchar *type,
GValue *dest);
G_END_DECLS
#endif

View file

@ -184,9 +184,10 @@ gst_video_context_new_structure (const gchar ** types)
}
static gboolean
gst_video_context_pad_query (gpointer item, GValue * value, gpointer user_data)
gst_video_context_pad_query (const GValue * item, GValue * value,
gpointer user_data)
{
GstPad *pad = GST_PAD (item);
GstPad *pad = g_value_get_object (item);
GstQuery *query = user_data;
gboolean res;
@ -353,7 +354,7 @@ gst_video_context_message_parse_prepare (GstMessage * message,
if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
return FALSE;
if (!gst_structure_has_name (message->structure, "prepare-video-context"))
if (!gst_message_has_name (message, "prepare-video-context"))
return FALSE;
if (!GST_IS_VIDEO_CONTEXT (src))
@ -384,7 +385,7 @@ GstQuery *
gst_video_context_query_new (const gchar ** types)
{
GstStructure *structure = gst_video_context_new_structure (types);
return gst_query_new_application (GST_QUERY_CUSTOM, structure);
return gst_query_new_custom (GST_QUERY_CUSTOM, structure);
}
/**
@ -440,7 +441,7 @@ gst_video_context_run_query (GstElement * element, GstQuery * query)
const gchar **
gst_video_context_query_get_supported_types (GstQuery * query)
{
GstStructure *structure = gst_query_get_structure (query);
const GstStructure *structure = gst_query_get_structure (query);
const GValue *value = gst_structure_get_value (structure, "types");
if (G_VALUE_HOLDS (value, G_TYPE_STRV))
@ -461,7 +462,7 @@ void
gst_video_context_query_parse_value (GstQuery * query, const gchar ** type,
const GValue ** value)
{
GstStructure *structure = gst_query_get_structure (query);
const GstStructure *structure = gst_query_get_structure (query);
if (type)
*type = gst_structure_get_string (structure, "video-context-type");
@ -482,7 +483,7 @@ void
gst_video_context_query_set_value (GstQuery * query, const gchar * type,
GValue * value)
{
GstStructure *structure = gst_query_get_structure (query);
GstStructure *structure = gst_query_writable_structure (query);
gst_structure_set (structure, "video-context-type", G_TYPE_STRING, type,
"video-context", G_TYPE_VALUE, value, NULL);
}
@ -499,7 +500,7 @@ void
gst_video_context_query_set_string (GstQuery * query, const gchar * type,
const gchar * value)
{
GstStructure *structure = gst_query_get_structure (query);
GstStructure *structure = gst_query_writable_structure (query);
gst_structure_set (structure, "video-context-type", G_TYPE_STRING, type,
"video-context", G_TYPE_STRING, value, NULL);
}
@ -516,7 +517,7 @@ void
gst_video_context_query_set_pointer (GstQuery * query, const gchar * type,
gpointer value)
{
GstStructure *structure = gst_query_get_structure (query);
GstStructure *structure = gst_query_writable_structure (query);
gst_structure_set (structure, "video-context-type", G_TYPE_STRING, type,
"video-context", G_TYPE_POINTER, value, NULL);
}
@ -533,7 +534,7 @@ void
gst_video_context_query_set_object (GstQuery * query, const gchar * type,
GObject * value)
{
GstStructure *structure = gst_query_get_structure (query);
GstStructure *structure = gst_query_writable_structure (query);
gst_structure_set (structure, "video-context-type", G_TYPE_STRING, type,
"video-context", G_TYPE_OBJECT, value, NULL);
}

View file

@ -36,8 +36,8 @@
G_BEGIN_DECLS
#define GST_TYPE_VIDEO_CONTEXT (gst_video_context_iface_get_type ())
#define GST_VIDEO_CONTEXT(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VIDEO_CONTEXT, GstVideoContext))
#define GST_IS_VIDEO_CONTEXT(obj) (GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VIDEO_CONTEXT))
#define GST_VIDEO_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VIDEO_CONTEXT, GstVideoContext))
#define GST_IS_VIDEO_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VIDEO_CONTEXT))
#define GST_VIDEO_CONTEXT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_VIDEO_CONTEXT, GstVideoContextInterface))
/**