From afd75017e71129a200ca19ea68161f3526265e6a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 26 Sep 2012 16:09:07 +0200 Subject: port to 1.0 --- README | 4 +- gst-app/configure.ac | 38 +++++++++---------- gst-app/src/play.c | 6 +-- gst-plugin/configure.ac | 36 +++++++++--------- gst-plugin/src/gstplugin.c | 87 +++++++++++++++++++++++-------------------- gst-plugin/src/gsttransform.c | 52 ++++++++++++-------------- 6 files changed, 111 insertions(+), 112 deletions(-) diff --git a/README b/README index 44dc857..e7b724e 100644 --- a/README +++ b/README @@ -33,7 +33,7 @@ Once the plugin is built you can either install it with 'sudo make install' (however, this will by default go into the /usr/local prefix where it won't be picked up by a GStreamer installed from packages, so you would need to set the GST_PLUGIN_PATH environment variable to include or point to -/usr/local/lib/gstreamer-0.10/ for your plugin to be found by a from-package +/usr/local/lib/gstreamer-1.0/ for your plugin to be found by a from-package GStreamer). Alternatively, you will find your plugin binary in gst-plugins/src/.libs/ as libgstplugin.so or similar (the extension may vary), so you can also set the GST_PLUGIN_PATH environmen variable to the @@ -41,7 +41,7 @@ gst-plugins/src/.libs/ directory (best to specify an absolute path though). You can also check if it has been built correctly with: - gst-inspect-0.10 gst-plugins/src/.libs/libgstplugin.so + gst-inspect-1.0 gst-plugins/src/.libs/libgstplugin.so [1] http://www.opensource.org/licenses/mit-license.php or COPYING.MIT diff --git a/gst-app/configure.ac b/gst-app/configure.ac index a172c18..e72cd6e 100644 --- a/gst-app/configure.ac +++ b/gst-app/configure.ac @@ -2,10 +2,10 @@ dnl required version of autoconf AC_PREREQ([2.53]) dnl TODO: fill in your package name and package version here -AC_INIT([my-app],[0.1.1]) +AC_INIT([my-app],[1.0.0]) dnl required version of gstreamer and gst-plugins-base -GST_REQUIRED=0.10.16 +GST_REQUIRED=1.0.0 AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([config.h]) @@ -34,21 +34,21 @@ dnl dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am dnl dnl If you need libraries from gst-plugins-base here, also add: -dnl for libgstaudio-0.10: gstreamer-audio-0.10 >= $GST_REQUIRED -dnl for libgstvideo-0.10: gstreamer-video-0.10 >= $GST_REQUIRED -dnl for libgsttag-0.10: gstreamer-tag-0.10 >= $GST_REQUIRED -dnl for libgstpbutils-0.10: gstreamer-pbutils-0.10 >= $GST_REQUIRED -dnl for libgstfft-0.10: gstreamer-fft-0.10 >= $GST_REQUIRED -dnl for libgstinterfaces-0.10: gstreamer-interfaces-0.10 >= $GST_REQUIRED -dnl for libgstrtp-0.10: gstreamer-rtp-0.10 >= $GST_REQUIRED -dnl for libgstrtsp-0.10: gstreamer-rtsp-0.10 >= $GST_REQUIRED +dnl for libgstaudio-1.0: gstreamer-audio-1.0 >= $GST_REQUIRED +dnl for libgstvideo-1.0: gstreamer-video-1.0 >= $GST_REQUIRED +dnl for libgsttag-1.0: gstreamer-tag-1.0 >= $GST_REQUIRED +dnl for libgstpbutils-1.0: gstreamer-pbutils-1.0 >= $GST_REQUIRED +dnl for libgstfft-1.0: gstreamer-fft-1.0 >= $GST_REQUIRED +dnl for libgstinterfaces-1.0: gstreamer-interfaces-1.0 >= $GST_REQUIRED +dnl for libgstrtp-1.0: gstreamer-rtp-1.0 >= $GST_REQUIRED +dnl for libgstrtsp-1.0: gstreamer-rtsp-1.0 >= $GST_REQUIRED dnl etc. dnl ======================================================================= PKG_CHECK_MODULES(GST, [ - gstreamer-0.10 >= $GST_REQUIRED - gstreamer-base-0.10 >= $GST_REQUIRED - gstreamer-controller-0.10 >= $GST_REQUIRED + gstreamer-1.0 >= $GST_REQUIRED + gstreamer-base-1.0 >= $GST_REQUIRED + gstreamer-controller-1.0 >= $GST_REQUIRED ], [ AC_SUBST(GST_CFLAGS) AC_SUBST(GST_LIBS) @@ -56,18 +56,18 @@ PKG_CHECK_MODULES(GST, [ AC_MSG_ERROR([ Can't find the following GStreamer development packages: - gstreamer-0.10 >= $GST_REQUIRED - gstreamer-base-0.10 >= $GST_REQUIRED - gstreamer-controller-0.10 >= $GST_REQUIRED + gstreamer-1.0 >= $GST_REQUIRED + gstreamer-base-1.0 >= $GST_REQUIRED + gstreamer-controller-1.0 >= $GST_REQUIRED - Please make sure you have the necessary GStreamer-0.10 + Please make sure you have the necessary GStreamer-1.0 development headers installed. On debian/Ubuntu systems you will probably need to install the - 'libgstreamer0.10-dev' and 'libgstreamer-plugins-base0.10-dev' packages. + 'libgstreamer1.0-dev' and 'libgstreamer-plugins-base1.0-dev' packages. On RPM-based systems you will probably need to install the - 'gstreamer-devel-0.10' package. + 'gstreamer-devel-1.0' package. ]) ]) diff --git a/gst-app/src/play.c b/gst-app/src/play.c index 339ccab..f24fb1b 100644 --- a/gst-app/src/play.c +++ b/gst-app/src/play.c @@ -92,12 +92,10 @@ play_uri (const gchar * uri) g_print ("Playing ...\n"); while (1) { - GstFormat time_format; gint64 dur, pos; - time_format = GST_FORMAT_TIME; - if (gst_element_query_duration (playbin, &time_format, &dur) && - gst_element_query_position (playbin, &time_format, &pos)) { + if (gst_element_query_duration (playbin, GST_FORMAT_TIME, &dur) && + gst_element_query_position (playbin, GST_FORMAT_TIME, &pos)) { g_print (" %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (pos), GST_TIME_ARGS (dur)); } diff --git a/gst-plugin/configure.ac b/gst-plugin/configure.ac index ea85c18..1908b28 100644 --- a/gst-plugin/configure.ac +++ b/gst-plugin/configure.ac @@ -2,11 +2,11 @@ dnl required version of autoconf AC_PREREQ([2.53]) dnl TODO: fill in your package name and package version here -AC_INIT([my-plugin-package],[0.10.0]) +AC_INIT([my-plugin-package],[1.0.0]) dnl required versions of gstreamer and plugins-base -GST_REQUIRED=0.10.16 -GSTPB_REQUIRED=0.10.16 +GST_REQUIRED=1.0.0 +GSTPB_REQUIRED=1.0.0 AC_CONFIG_SRCDIR([src/gstplugin.c]) AC_CONFIG_HEADERS([config.h]) @@ -33,19 +33,19 @@ dnl Check for the required version of GStreamer core (and gst-plugins-base) dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am dnl dnl If you need libraries from gst-plugins-base here, also add: -dnl for libgstaudio-0.10: gstreamer-audio-0.10 >= $GST_REQUIRED -dnl for libgstvideo-0.10: gstreamer-video-0.10 >= $GST_REQUIRED -dnl for libgsttag-0.10: gstreamer-tag-0.10 >= $GST_REQUIRED -dnl for libgstpbutils-0.10: gstreamer-pbutils-0.10 >= $GST_REQUIRED -dnl for libgstfft-0.10: gstreamer-fft-0.10 >= $GST_REQUIRED -dnl for libgstinterfaces-0.10: gstreamer-interfaces-0.10 >= $GST_REQUIRED -dnl for libgstrtp-0.10: gstreamer-rtp-0.10 >= $GST_REQUIRED -dnl for libgstrtsp-0.10: gstreamer-rtsp-0.10 >= $GST_REQUIRED +dnl for libgstaudio-1.0: gstreamer-audio-1.0 >= $GST_REQUIRED +dnl for libgstvideo-1.0: gstreamer-video-1.0 >= $GST_REQUIRED +dnl for libgsttag-1.0: gstreamer-tag-1.0 >= $GST_REQUIRED +dnl for libgstpbutils-1.0: gstreamer-pbutils-1.0 >= $GST_REQUIRED +dnl for libgstfft-1.0: gstreamer-fft-1.0 >= $GST_REQUIRED +dnl for libgstinterfaces-1.0: gstreamer-interfaces-1.0 >= $GST_REQUIRED +dnl for libgstrtp-1.0: gstreamer-rtp-1.0 >= $GST_REQUIRED +dnl for libgstrtsp-1.0: gstreamer-rtsp-1.0 >= $GST_REQUIRED dnl etc. PKG_CHECK_MODULES(GST, [ - gstreamer-0.10 >= $GST_REQUIRED - gstreamer-base-0.10 >= $GST_REQUIRED - gstreamer-controller-0.10 >= $GST_REQUIRED + gstreamer-1.0 >= $GST_REQUIRED + gstreamer-base-1.0 >= $GST_REQUIRED + gstreamer-controller-1.0 >= $GST_REQUIRED ], [ AC_SUBST(GST_CFLAGS) AC_SUBST(GST_LIBS) @@ -53,8 +53,8 @@ PKG_CHECK_MODULES(GST, [ AC_MSG_ERROR([ You need to install or upgrade the GStreamer development packages on your system. On debian-based systems these are - libgstreamer0.10-dev and libgstreamer-plugins-base0.10-dev. - on RPM-based systems gstreamer0.10-devel, libgstreamer0.10-devel + libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev. + on RPM-based systems gstreamer1.0-devel, libgstreamer1.0-devel or similar. The minimum version required is $GST_REQUIRED. ]) ]) @@ -72,9 +72,9 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [ dnl set the plugindir where plugins should be installed (for src/Makefile.am) if test "x${prefix}" = "x$HOME"; then - plugindir="$HOME/.gstreamer-0.10/plugins" + plugindir="$HOME/.gstreamer-1.0/plugins" else - plugindir="\$(libdir)/gstreamer-0.10" + plugindir="\$(libdir)/gstreamer-1.0" fi AC_SUBST(plugindir) diff --git a/gst-plugin/src/gstplugin.c b/gst-plugin/src/gstplugin.c index 464be87..d6617ea 100644 --- a/gst-plugin/src/gstplugin.c +++ b/gst-plugin/src/gstplugin.c @@ -96,36 +96,19 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_CAPS ("ANY") ); -GST_BOILERPLATE (GstPluginTemplate, gst_plugin_template, GstElement, - GST_TYPE_ELEMENT); +#define gst_plugin_template_parent_class parent_class +G_DEFINE_TYPE (GstPluginTemplate, gst_plugin_template, GST_TYPE_ELEMENT); static void gst_plugin_template_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_plugin_template_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static gboolean gst_plugin_template_set_caps (GstPad * pad, GstCaps * caps); -static GstFlowReturn gst_plugin_template_chain (GstPad * pad, GstBuffer * buf); +static gboolean gst_plugin_template_sink_event (GstPad * pad, GstObject * parent, GstEvent * event); +static GstFlowReturn gst_plugin_template_chain (GstPad * pad, GstObject * parent, GstBuffer * buf); /* GObject vmethod implementations */ -static void -gst_plugin_template_base_init (gpointer gclass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (gclass); - - gst_element_class_set_details_simple(element_class, - "Plugin", - "FIXME:Generic", - "FIXME:Generic Template Element", - "AUTHOR_NAME AUTHOR_EMAIL"); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_factory)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&sink_factory)); -} - /* initialize the plugin's class */ static void gst_plugin_template_class_init (GstPluginTemplateClass * klass) @@ -142,6 +125,17 @@ gst_plugin_template_class_init (GstPluginTemplateClass * klass) g_object_class_install_property (gobject_class, PROP_SILENT, g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?", FALSE, G_PARAM_READWRITE)); + + gst_element_class_set_details_simple(gstelement_class, + "Plugin", + "FIXME:Generic", + "FIXME:Generic Template Element", + "AUTHOR_NAME AUTHOR_EMAIL"); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&src_factory)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&sink_factory)); } /* initialize the new element @@ -150,23 +144,20 @@ gst_plugin_template_class_init (GstPluginTemplateClass * klass) * initialize instance structure */ static void -gst_plugin_template_init (GstPluginTemplate * filter, - GstPluginTemplateClass * gclass) +gst_plugin_template_init (GstPluginTemplate * filter) { filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); - gst_pad_set_setcaps_function (filter->sinkpad, - GST_DEBUG_FUNCPTR(gst_plugin_template_set_caps)); - gst_pad_set_getcaps_function (filter->sinkpad, - GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps)); + gst_pad_set_event_function (filter->sinkpad, + GST_DEBUG_FUNCPTR(gst_plugin_template_sink_event)); gst_pad_set_chain_function (filter->sinkpad, GST_DEBUG_FUNCPTR(gst_plugin_template_chain)); + GST_PAD_SET_PROXY_CAPS (filter->sinkpad); + gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); - gst_pad_set_getcaps_function (filter->srcpad, - GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps)); - - gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); + GST_PAD_SET_PROXY_CAPS (filter->srcpad); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); + filter->silent = FALSE; } @@ -204,29 +195,43 @@ gst_plugin_template_get_property (GObject * object, guint prop_id, /* GstElement vmethod implementations */ -/* this function handles the link with other elements */ +/* this function handles sink events */ static gboolean -gst_plugin_template_set_caps (GstPad * pad, GstCaps * caps) +gst_plugin_template_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) { + gboolean ret; GstPluginTemplate *filter; - GstPad *otherpad; - filter = GST_PLUGIN_TEMPLATE (gst_pad_get_parent (pad)); - otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad; - gst_object_unref (filter); + filter = GST_PLUGIN_TEMPLATE (parent); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_CAPS: + { + GstCaps * caps; - return gst_pad_set_caps (otherpad, caps); + gst_event_parse_caps (event, &caps); + /* do something with the caps */ + + /* and forward */ + ret = gst_pad_event_default (pad, parent, event); + break; + } + default: + ret = gst_pad_event_default (pad, parent, event); + break; + } + return ret; } /* chain function * this function does the actual processing */ static GstFlowReturn -gst_plugin_template_chain (GstPad * pad, GstBuffer * buf) +gst_plugin_template_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) { GstPluginTemplate *filter; - filter = GST_PLUGIN_TEMPLATE (GST_OBJECT_PARENT (pad)); + filter = GST_PLUGIN_TEMPLATE (parent); if (filter->silent == FALSE) g_print ("I'm plugged, therefore I'm in.\n"); @@ -270,7 +275,7 @@ plugin_init (GstPlugin * plugin) GST_PLUGIN_DEFINE ( GST_VERSION_MAJOR, GST_VERSION_MINOR, - "plugin", + plugin, "Template plugin", plugin_init, VERSION, diff --git a/gst-plugin/src/gsttransform.c b/gst-plugin/src/gsttransform.c index 6cf223e..536357b 100644 --- a/gst-plugin/src/gsttransform.c +++ b/gst-plugin/src/gsttransform.c @@ -78,15 +78,8 @@ GST_STATIC_PAD_TEMPLATE ( GST_STATIC_CAPS ("ANY") ); -/* debug category for fltering log messages - * - * FIXME:exchange the string 'Template plugin' with your description - */ -#define DEBUG_INIT(bla) \ - GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin", 0, "Template plugin"); - -GST_BOILERPLATE_FULL (GstPluginTemplate, gst_plugin_template, GstBaseTransform, - GST_TYPE_BASE_TRANSFORM, DEBUG_INIT); +#define gst_plugin_template_parent_class parent_class +G_DEFINE_TYPE (GstPluginTemplate, gst_plugin_template, GST_TYPE_BASE_TRANSFORM); static void gst_plugin_template_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -98,30 +91,16 @@ static GstFlowReturn gst_plugin_template_transform_ip (GstBaseTransform * base, /* GObject vmethod implementations */ -static void -gst_plugin_template_base_init (gpointer klass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - - gst_element_class_set_details_simple (element_class, - "Plugin", - "Generic/Filter", - "FIXME:Generic Template Filter", - "AUTHOR_NAME AUTHOR_EMAIL"); - - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_template)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&sink_template)); -} - /* initialize the plugin's class */ static void gst_plugin_template_class_init (GstPluginTemplateClass * klass) { GObjectClass *gobject_class; + GstElementClass *gstelement_class; gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + gobject_class->set_property = gst_plugin_template_set_property; gobject_class->get_property = gst_plugin_template_get_property; @@ -129,15 +108,32 @@ gst_plugin_template_class_init (GstPluginTemplateClass * klass) g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?", FALSE, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); + gst_element_class_set_details_simple (gstelement_class, + "Plugin", + "Generic/Filter", + "FIXME:Generic Template Filter", + "AUTHOR_NAME AUTHOR_EMAIL"); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&src_template)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&sink_template)); + GST_BASE_TRANSFORM_CLASS (klass)->transform_ip = GST_DEBUG_FUNCPTR (gst_plugin_template_transform_ip); + + /* debug category for fltering log messages + * + * FIXME:exchange the string 'Template plugin' with your description + */ + GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin", 0, "Template plugin"); } /* initialize the new element * initialize instance structure */ static void -gst_plugin_template_init (GstPluginTemplate *filter, GstPluginTemplateClass * klass) +gst_plugin_template_init (GstPluginTemplate *filter) { filter->silent = FALSE; } @@ -217,7 +213,7 @@ plugin_init (GstPlugin * plugin) GST_PLUGIN_DEFINE ( GST_VERSION_MAJOR, GST_VERSION_MINOR, - "plugin", + plugin, "Template plugin", plugin_init, VERSION, -- cgit v1.2.3