From 95a4bca0ee45c62ae2915705f08e22ca151c8bd8 Mon Sep 17 00:00:00 2001 From: gb Date: Fri, 5 Mar 2010 17:11:52 +0000 Subject: [PATCH] Add boilerplate for vaapiconvert and vaapisink elements. --- configure.ac | 14 +++++ sys/vaapiconvert/Makefile.am | 15 ++++- sys/vaapiconvert/gstvaapiconvert.c | 122 +++++++++++++++++++++++++++++++++++++ sys/vaapiconvert/gstvaapiconvert.h | 73 ++++++++++++++++++++++ sys/vaapisink/Makefile.am | 15 ++++- sys/vaapisink/gstvaapisink.c | 85 ++++++++++++++++++++++++++ sys/vaapisink/gstvaapisink.h | 73 ++++++++++++++++++++++ 7 files changed, 391 insertions(+), 6 deletions(-) create mode 100644 sys/vaapiconvert/gstvaapiconvert.c create mode 100644 sys/vaapiconvert/gstvaapiconvert.h create mode 100644 sys/vaapisink/gstvaapisink.c create mode 100644 sys/vaapisink/gstvaapisink.h diff --git a/configure.ac b/configure.ac index 0d36f04..7ada779 100644 --- a/configure.ac +++ b/configure.ac @@ -80,6 +80,20 @@ PKG_CHECK_MODULES([GST_PLUGINS_BASE], AC_SUBST(GST_PLUGINS_BASE_CFLAGS) AC_SUBST(GST_PLUGINS_BASE_LIBS) +dnl Check for GStreamer base +PKG_CHECK_MODULES([GST_BASE], + [gstreamer-base-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED] +) +AC_SUBST(GST_BASE_CFLAGS) +AC_SUBST(GST_BASE_LIBS) + +dnl Check for GStreamer video +PKG_CHECK_MODULES([GST_VIDEO], + [gstreamer-video-$GST_MAJORMINOR >= $GST_VERSION_REQUIRED] +) +AC_SUBST(GST_VIDEO_CFLAGS) +AC_SUBST(GST_VIDEO_LIBS) + dnl Check for the GStreamer plugins directory AC_MSG_CHECKING([for GStreamer plugins directory]) GST_PLUGINS_DIR=`$PKG_CONFIG gstreamer-$GST_MAJORMINOR --variable pluginsdir` diff --git a/sys/vaapiconvert/Makefile.am b/sys/vaapiconvert/Makefile.am index 549bd99..1cb2dbe 100644 --- a/sys/vaapiconvert/Makefile.am +++ b/sys/vaapiconvert/Makefile.am @@ -1,14 +1,23 @@ plugin_LTLIBRARIES = libgstvaapiconvert.la libgstvaapiconvert_la_SOURCES = \ + gstvaapiconvert.c \ $(NULL) noinst_HEADERS = \ + gstvaapiconvert.h \ $(NULL) -libgstvaapiconvert_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) -libgstvaapiconvert_la_LIBADD = $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) -libgstvaapiconvert_la_LDFLAGS = +libgstvaapiconvert_la_CFLAGS = \ + $(GST_CFLAGS) \ + $(GST_BASE_CFLAGS) \ + $(GST_PLUGINS_BASE_CFLAGS) + +libgstvaapiconvert_la_LIBADD = \ + $(GST_LIBS) \ + $(GST_BASE_LIBS) \ + $(GST_PLUGINS_BASE_LIBS) + libgstvaapiconvert_la_LIBTOOLFLAGS = --tag=disable-static # Extra clean files so that maintainer-clean removes *everything* diff --git a/sys/vaapiconvert/gstvaapiconvert.c b/sys/vaapiconvert/gstvaapiconvert.c new file mode 100644 index 0000000..4ac789a --- /dev/null +++ b/sys/vaapiconvert/gstvaapiconvert.c @@ -0,0 +1,122 @@ +/* + * gstvaapiconvert.c - VA-API video converter + * + * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include +#include "gstvaapiconvert.h" + +/* ElementFactory information */ +static const GstElementDetails gst_vaapiconvert_details = + GST_ELEMENT_DETAILS( + "Video convert", + "Convert/Video", + "A VA-API based videoconvert", + "Gwenole Beauchesne "); + +/* Default templates */ +static GstStaticPadTemplate gst_vaapiconvert_sink_factory = + GST_STATIC_PAD_TEMPLATE( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS( + "video/x-raw-yuv, " + "width = (int) [ 1, MAX ], " + "height = (int) [ 1, MAX ]; ")); + +static GstStaticPadTemplate gst_vaapiconvert_src_factory = + GST_STATIC_PAD_TEMPLATE( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS( + "video/x-vaapi-surface, " + "width = (int) [ 1, MAX ], " + "height = (int) [ 1, MAX ]; ")); + +GST_BOILERPLATE( + GstVaapiConvert, + gst_vaapiconvert, + GstBaseTransform, + GST_TYPE_BASE_TRANSFORM); + +static GstFlowReturn +gst_vaapiconvert_transform( + GstBaseTransform *trans, + GstBuffer *inbuf, + GstBuffer *outbuf +); + +static void gst_vaapiconvert_base_init(gpointer klass) +{ + GstElementClass * const element_class = GST_ELEMENT_CLASS(klass); + + gst_element_class_set_details(element_class, &gst_vaapiconvert_details); + + gst_element_class_add_pad_template( + element_class, + gst_static_pad_template_get(&gst_vaapiconvert_sink_factory) + ); + gst_element_class_add_pad_template( + element_class, + gst_static_pad_template_get(&gst_vaapiconvert_src_factory) + ); +} + +static void gst_vaapiconvert_class_init(GstVaapiConvertClass *klass) +{ + GObjectClass * const object_class = G_OBJECT_CLASS(klass); + GstBaseTransformClass * const trans_class = GST_BASE_TRANSFORM_CLASS(klass); + + trans_class->transform = GST_DEBUG_FUNCPTR(gst_vaapiconvert_transform); +} + +static void +gst_vaapiconvert_init(GstVaapiConvert *convert, GstVaapiConvertClass *klass) +{ +} + +static GstFlowReturn +gst_vaapiconvert_transform( + GstBaseTransform *trans, + GstBuffer *inbuf, + GstBuffer *outbuf +) +{ + return GST_FLOW_OK; +} + +static gboolean plugin_init(GstPlugin *plugin) +{ + return gst_element_register(plugin, + "vaapiconvert", + GST_RANK_PRIMARY, + GST_TYPE_VAAPICONVERT); +} + +GST_PLUGIN_DEFINE( + GST_VERSION_MAJOR, GST_VERSION_MINOR, + "vaapiconvert", + "A VA-API based video pixels format converter", + plugin_init, + PACKAGE_VERSION, + "GPL", + PACKAGE, + PACKAGE_BUGREPORT); diff --git a/sys/vaapiconvert/gstvaapiconvert.h b/sys/vaapiconvert/gstvaapiconvert.h new file mode 100644 index 0000000..20189ad --- /dev/null +++ b/sys/vaapiconvert/gstvaapiconvert.h @@ -0,0 +1,73 @@ +/* + * gstvaapiconvert.h - VA-API video converter + * + * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef GST_VAAPICONVERT_H +#define GST_VAAPICONVERT_H + +#include + +G_BEGIN_DECLS + +#define GST_TYPE_VAAPICONVERT \ + (gst_vaapiconvert_get_type()) + +#define GST_VAAPICONVERT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + GST_TYPE_VAAPICONVERT, \ + GstVaapiConvert)) + +#define GST_VAAPICONVERT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + GST_TYPE_VAAPICONVERT, \ + GstVaapiConvertClass)) + +#define GST_IS_VAAPICONVERT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPICONVERT)) + +#define GST_IS_VAAPICONVERT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPICONVERT)) + +#define GST_VAAPICONVERT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + GST_TYPE_VAAPICONVERT, \ + GstVaapiConvert)) + +typedef struct _GstVaapiConvert GstVaapiConvert; +typedef struct _GstVaapiConvertPrivate GstVaapiConvertPrivate; +typedef struct _GstVaapiConvertClass GstVaapiConvertClass; + +struct _GstVaapiConvert { + /*< private >*/ + GstBaseTransform parent_instance; + + GstVaapiConvertPrivate *priv; +}; + +struct _GstVaapiConvertClass { + /*< private >*/ + GstBaseTransformClass parent_class; +}; + +GType +gst_vaapiconvert_get_type(void); + +G_END_DECLS + +#endif /* GST_VAAPICONVERT_H */ diff --git a/sys/vaapisink/Makefile.am b/sys/vaapisink/Makefile.am index 648082c..f886efa 100644 --- a/sys/vaapisink/Makefile.am +++ b/sys/vaapisink/Makefile.am @@ -1,14 +1,23 @@ plugin_LTLIBRARIES = libgstvaapisink.la libgstvaapisink_la_SOURCES = \ + gstvaapisink.c \ $(NULL) noinst_HEADERS = \ + gstvaapisink.h \ $(NULL) -libgstvaapisink_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) -libgstvaapisink_la_LIBADD = $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) -libgstvaapisink_la_LDFLAGS = +libgstvaapisink_la_CFLAGS = \ + $(GST_CFLAGS) \ + $(GST_VIDEO_CFLAGS) \ + $(GST_PLUGINS_BASE_CFLAGS) + +libgstvaapisink_la_LIBADD = \ + $(GST_LIBS) \ + $(GST_VIDEO_LIBS) \ + $(GST_PLUGINS_BASE_LIBS) + libgstvaapisink_la_LIBTOOLFLAGS = --tag=disable-static # Extra clean files so that maintainer-clean removes *everything* diff --git a/sys/vaapisink/gstvaapisink.c b/sys/vaapisink/gstvaapisink.c new file mode 100644 index 0000000..19a0d69 --- /dev/null +++ b/sys/vaapisink/gstvaapisink.c @@ -0,0 +1,85 @@ +/* + * gstvaapisink.c - VA-API video sink + * + * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "gstvaapisink.h" + +/* ElementFactory information */ +static const GstElementDetails gst_vaapisink_details = + GST_ELEMENT_DETAILS( + "Video sink", + "Sink/Video", + "A VA-API based videosink", + "Gwenole Beauchesne "); + +/* Default template */ +static GstStaticPadTemplate gst_vaapisink_sink_factory = + GST_STATIC_PAD_TEMPLATE( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS( + "video/x-vaapi-surface, " + "width = (int) [ 1, MAX ], " + "height = (int) [ 1, MAX ]; ")); + +GST_BOILERPLATE(GstVaapiSink, gst_vaapisink, GstVideoSink, GST_TYPE_VIDEO_SINK); + +static void gst_vaapisink_base_init(gpointer klass) +{ + GstElementClass * const element_class = GST_ELEMENT_CLASS(klass); + + gst_element_class_set_details(element_class, &gst_vaapisink_details); + + gst_element_class_add_pad_template( + element_class, + gst_static_pad_template_get(&gst_vaapisink_sink_factory) + ); +} + +static void gst_vaapisink_class_init(GstVaapiSinkClass *klass) +{ + GObjectClass * const object_class = G_OBJECT_CLASS(klass); + GstElementClass * const element_class = GST_ELEMENT_CLASS(klass); + GstBaseSinkClass * const basesink_class = GST_BASE_SINK_CLASS(klass); + GstVideoSinkClass * const videosink_class = GST_VIDEO_SINK_CLASS(klass); +} + +static void gst_vaapisink_init(GstVaapiSink *sink, GstVaapiSinkClass *klass) +{ +} + +static gboolean plugin_init(GstPlugin *plugin) +{ + return gst_element_register(plugin, + "vaapisink", + GST_RANK_PRIMARY, + GST_TYPE_VAAPISINK); +} + +GST_PLUGIN_DEFINE( + GST_VERSION_MAJOR, GST_VERSION_MINOR, + "vaapisink", + "A VA-API based videosink", + plugin_init, + PACKAGE_VERSION, + "GPL", + PACKAGE, + PACKAGE_BUGREPORT); diff --git a/sys/vaapisink/gstvaapisink.h b/sys/vaapisink/gstvaapisink.h new file mode 100644 index 0000000..270d1a6 --- /dev/null +++ b/sys/vaapisink/gstvaapisink.h @@ -0,0 +1,73 @@ +/* + * gstvaapisink.h - VA-API video sink + * + * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef GST_VAAPISINK_H +#define GST_VAAPISINK_H + +#include + +G_BEGIN_DECLS + +#define GST_TYPE_VAAPISINK \ + (gst_vaapisink_get_type()) + +#define GST_VAAPISINK(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + GST_TYPE_VAAPISINK, \ + GstVaapiSink)) + +#define GST_VAAPISINK_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + GST_TYPE_VAAPISINK, \ + GstVaapiSinkClass)) + +#define GST_IS_VAAPISINK(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPISINK)) + +#define GST_IS_VAAPISINK_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPISINK)) + +#define GST_VAAPISINK_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + GST_TYPE_VAAPISINK, \ + GstVaapiSink)) + +typedef struct _GstVaapiSink GstVaapiSink; +typedef struct _GstVaapiSinkPrivate GstVaapiSinkPrivate; +typedef struct _GstVaapiSinkClass GstVaapiSinkClass; + +struct _GstVaapiSink { + /*< private >*/ + GstVideoSink parent_instance; + + GstVaapiSinkPrivate *priv; +}; + +struct _GstVaapiSinkClass { + /*< private >*/ + GstVideoSinkClass parent_class; +}; + +GType +gst_vaapisink_get_type(void); + +G_END_DECLS + +#endif /* GST_VAAPISINK_H */ -- 2.7.4