From e504dc3f6b13c00f1b1db9b97bd42ba0449bfb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 17 Mar 2012 15:16:29 +0000 Subject: tools: add videofilter template for gst-element-maker --- tools/element-templates/videofilter | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tools/element-templates/videofilter (limited to 'tools') diff --git a/tools/element-templates/videofilter b/tools/element-templates/videofilter new file mode 100644 index 000000000..fb22b2884 --- /dev/null +++ b/tools/element-templates/videofilter @@ -0,0 +1,78 @@ +/* vim: set filetype=c: */ +% ClassName +GstVideoFilter +% TYPE_CLASS_NAME +GST_TYPE_VIDEO_FILTER +% pads +sinkpad-simple srcpad-simple +% pkg-config +gstreamer-video-0.10 +% includes +#include +#include +% prototypes +static gboolean +gst_replace_start (GstBaseTransform * trans); +static gboolean +gst_replace_stop (GstBaseTransform * trans); +static GstFlowReturn +gst_replace_transform_ip (GstBaseTransform * trans, GstBuffer * buf); +static gboolean +gst_replace_set_caps (GstBaseTransform * trans, GstCaps * incaps, + GstCaps * outcaps); +% declare-class + GstBaseTransformClass *base_transform_class = GST_BASE_TRANSFORM_CLASS (klass); +% set-methods + base_transform_class->start = GST_DEBUG_FUNCPTR (gst_replace_start); + base_transform_class->stop = GST_DEBUG_FUNCPTR (gst_replace_stop); + base_transform_class->set_caps = GST_DEBUG_FUNCPTR (gst_replace_set_caps); + base_transform_class->transform_ip = GST_DEBUG_FUNCPTR (gst_replace_transform_ip); +% methods + +static gboolean +gst_replace_start (GstBaseTransform * trans) +{ + /* GstReplace *replace = GST_REPLACE (trans); */ + + /* initialize processing */ + return TRUE; +} + +static gboolean +gst_replace_stop (GstBaseTransform * trans) +{ + /* GstReplace *replace = GST_REPLACE (trans); */ + + /* finalize processing */ + return TRUE; +} + +static gboolean +gst_replace_set_caps (GstBaseTransform * trans, GstCaps * incaps, + GstCaps * outcaps) +{ + /* GstReplace *replace = GST_REPLACE (trans); */ + GstVideoFormat video_format; + int w, h; + + /* parse input caps, output caps are the same so we ignore them */ + if (!gst_video_format_parse_caps (incaps, &video_format, &w, &h)) + return FALSE; + + /* You'll need to add those fields to the instance struct first */ + /* replace->video_format = video_format; */ + /* replace->width = w; */ + /* replace->height = h; */ + return TRUE; +} + +static GstFlowReturn +gst_replace_transform_ip (GstBaseTransform * trans, GstBuffer * buf) +{ + /* GstReplace *replace = GST_REPLACE (trans); */ + + /* process the video data in the buffer in-place */ + return GST_FLOW_OK; +} + +% end -- cgit v1.2.1 From 48398114e672e7900faf239c2fe5ae6f343fa9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 17 Mar 2012 15:49:45 +0000 Subject: gst-element-maker: add {src,sink}pad-template, since many base classes create pads for us And use them in the videofilter template. --- tools/element-templates/sinkpad-template | 19 +++++++++++++++++++ tools/element-templates/srcpad-template | 19 +++++++++++++++++++ tools/element-templates/videofilter | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tools/element-templates/sinkpad-template create mode 100644 tools/element-templates/srcpad-template (limited to 'tools') diff --git a/tools/element-templates/sinkpad-template b/tools/element-templates/sinkpad-template new file mode 100644 index 000000000..b06b346b1 --- /dev/null +++ b/tools/element-templates/sinkpad-template @@ -0,0 +1,19 @@ +/* vim: set filetype=c: */ + +% instance-members +% prototypes +% pad-template +static GstStaticPadTemplate gst_replace_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/unknown") + ); + +% base-init + gst_element_class_add_static_pad_template (element_class, + &gst_replace_sink_template); +% instance-init +% methods +% end + diff --git a/tools/element-templates/srcpad-template b/tools/element-templates/srcpad-template new file mode 100644 index 000000000..dd0842bbd --- /dev/null +++ b/tools/element-templates/srcpad-template @@ -0,0 +1,19 @@ +/* vim: set filetype=c: */ + +% instance-members +% prototypes +% pad-template +static GstStaticPadTemplate gst_replace_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/unknown") + ); + +% base-init + gst_element_class_add_static_pad_template (element_class, + &gst_replace_src_template); +% instance-init +% methods +% end + diff --git a/tools/element-templates/videofilter b/tools/element-templates/videofilter index fb22b2884..65b2f3756 100644 --- a/tools/element-templates/videofilter +++ b/tools/element-templates/videofilter @@ -4,7 +4,7 @@ GstVideoFilter % TYPE_CLASS_NAME GST_TYPE_VIDEO_FILTER % pads -sinkpad-simple srcpad-simple +sinkpad-template srcpad-template % pkg-config gstreamer-video-0.10 % includes -- cgit v1.2.1 From 3991742d77a81183f8ffbad59df7e1ec741ff803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 17 Mar 2012 16:05:20 +0000 Subject: gst-element-maker: add video pad template and use it in videofilter class Would be nicer if one could just supplement the generic template from the element template though. Also, I would really have liked to just add those sections from the pads template into the element templet directly (so I can cater for src template caps == sink template caps), but that didn't seem to work. --- tools/element-templates/sinkpad-template-video | 33 ++++++++++++++++++++++++++ tools/element-templates/srcpad-template-video | 33 ++++++++++++++++++++++++++ tools/element-templates/videofilter | 2 +- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tools/element-templates/sinkpad-template-video create mode 100644 tools/element-templates/srcpad-template-video (limited to 'tools') diff --git a/tools/element-templates/sinkpad-template-video b/tools/element-templates/sinkpad-template-video new file mode 100644 index 000000000..ffdac843a --- /dev/null +++ b/tools/element-templates/sinkpad-template-video @@ -0,0 +1,33 @@ +/* vim: set filetype=c: */ + +% instance-members +% prototypes +% pad-template +/* FIXME: add/remove formats you can handle */ +#define VIDEO_SINK_CAPS \ + GST_VIDEO_CAPS_RGBA \ + GST_VIDEO_CAPS_ARGB \ + GST_VIDEO_CAPS_BGRA \ + GST_VIDEO_CAPS_ABGR \ + GST_VIDEO_CAPS_RGBx \ + GST_VIDEO_CAPS_xRGB \ + GST_VIDEO_CAPS_BGRx \ + GST_VIDEO_CAPS_xBGR \ + GST_VIDEO_CAPS_RGB \ + GST_VIDEO_CAPS_BGR \ + GST_VIDEO_CAPS_YUV("{ AYUV }") + +static GstStaticPadTemplate gst_replace_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (VIDEO_SINK_CAPS) + ); + +% base-init + gst_element_class_add_static_pad_template (element_class, + &gst_replace_sink_template); +% instance-init +% methods +% end + diff --git a/tools/element-templates/srcpad-template-video b/tools/element-templates/srcpad-template-video new file mode 100644 index 000000000..bfdc931c5 --- /dev/null +++ b/tools/element-templates/srcpad-template-video @@ -0,0 +1,33 @@ +/* vim: set filetype=c: */ + +% instance-members +% prototypes +% pad-template +/* FIXME: add/remove formats you can handle */ +#define VIDEO_SRC_CAPS \ + GST_VIDEO_CAPS_RGBA \ + GST_VIDEO_CAPS_ARGB \ + GST_VIDEO_CAPS_BGRA \ + GST_VIDEO_CAPS_ABGR \ + GST_VIDEO_CAPS_RGBx \ + GST_VIDEO_CAPS_xRGB \ + GST_VIDEO_CAPS_BGRx \ + GST_VIDEO_CAPS_xBGR \ + GST_VIDEO_CAPS_RGB \ + GST_VIDEO_CAPS_BGR \ + GST_VIDEO_CAPS_YUV("{ AYUV }") + +static GstStaticPadTemplate gst_replace_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (VIDEO_SRC_CAPS) + ); + +% base-init + gst_element_class_add_static_pad_template (element_class, + &gst_replace_src_template); +% instance-init +% methods +% end + diff --git a/tools/element-templates/videofilter b/tools/element-templates/videofilter index 65b2f3756..3a94b0838 100644 --- a/tools/element-templates/videofilter +++ b/tools/element-templates/videofilter @@ -4,7 +4,7 @@ GstVideoFilter % TYPE_CLASS_NAME GST_TYPE_VIDEO_FILTER % pads -sinkpad-template srcpad-template +sinkpad-template-video srcpad-template-video % pkg-config gstreamer-video-0.10 % includes -- cgit v1.2.1 From 9aa9903430ee384a7ea46034f60b3e5d76f5abb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 17 Mar 2012 16:09:31 +0000 Subject: gst-element-maker: fix -template-video caps string Don't forget separator. --- tools/element-templates/sinkpad-template-video | 20 ++++++++++---------- tools/element-templates/srcpad-template-video | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'tools') diff --git a/tools/element-templates/sinkpad-template-video b/tools/element-templates/sinkpad-template-video index ffdac843a..b317c6fd7 100644 --- a/tools/element-templates/sinkpad-template-video +++ b/tools/element-templates/sinkpad-template-video @@ -5,16 +5,16 @@ % pad-template /* FIXME: add/remove formats you can handle */ #define VIDEO_SINK_CAPS \ - GST_VIDEO_CAPS_RGBA \ - GST_VIDEO_CAPS_ARGB \ - GST_VIDEO_CAPS_BGRA \ - GST_VIDEO_CAPS_ABGR \ - GST_VIDEO_CAPS_RGBx \ - GST_VIDEO_CAPS_xRGB \ - GST_VIDEO_CAPS_BGRx \ - GST_VIDEO_CAPS_xBGR \ - GST_VIDEO_CAPS_RGB \ - GST_VIDEO_CAPS_BGR \ + GST_VIDEO_CAPS_RGBA "; " \ + GST_VIDEO_CAPS_ARGB "; " \ + GST_VIDEO_CAPS_BGRA "; " \ + GST_VIDEO_CAPS_ABGR "; " \ + GST_VIDEO_CAPS_RGBx "; " \ + GST_VIDEO_CAPS_xRGB "; " \ + GST_VIDEO_CAPS_BGRx "; " \ + GST_VIDEO_CAPS_xBGR "; " \ + GST_VIDEO_CAPS_RGB "; " \ + GST_VIDEO_CAPS_BGR "; " \ GST_VIDEO_CAPS_YUV("{ AYUV }") static GstStaticPadTemplate gst_replace_sink_template = diff --git a/tools/element-templates/srcpad-template-video b/tools/element-templates/srcpad-template-video index bfdc931c5..4f3932086 100644 --- a/tools/element-templates/srcpad-template-video +++ b/tools/element-templates/srcpad-template-video @@ -5,16 +5,16 @@ % pad-template /* FIXME: add/remove formats you can handle */ #define VIDEO_SRC_CAPS \ - GST_VIDEO_CAPS_RGBA \ - GST_VIDEO_CAPS_ARGB \ - GST_VIDEO_CAPS_BGRA \ - GST_VIDEO_CAPS_ABGR \ - GST_VIDEO_CAPS_RGBx \ - GST_VIDEO_CAPS_xRGB \ - GST_VIDEO_CAPS_BGRx \ - GST_VIDEO_CAPS_xBGR \ - GST_VIDEO_CAPS_RGB \ - GST_VIDEO_CAPS_BGR \ + GST_VIDEO_CAPS_RGBA "; " \ + GST_VIDEO_CAPS_ARGB "; " \ + GST_VIDEO_CAPS_BGRA "; " \ + GST_VIDEO_CAPS_ABGR "; " \ + GST_VIDEO_CAPS_RGBx "; " \ + GST_VIDEO_CAPS_xRGB "; " \ + GST_VIDEO_CAPS_BGRx "; " \ + GST_VIDEO_CAPS_xBGR "; " \ + GST_VIDEO_CAPS_RGB "; " \ + GST_VIDEO_CAPS_BGR "; " \ GST_VIDEO_CAPS_YUV("{ AYUV }") static GstStaticPadTemplate gst_replace_src_template = -- cgit v1.2.1 From b45c206647f669d60c6e23cb03acb1c14882b9a3 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sat, 17 Mar 2012 11:45:39 -0700 Subject: element-templates: chain query/event functions Chain up to parent class. This fix should be done to all of the templates. --- tools/element-templates/basesrc | 16 ++++++++++++++-- tools/element-templates/element | 12 +++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/element-templates/basesrc b/tools/element-templates/basesrc index 0b7e56fc1..1be325a22 100644 --- a/tools/element-templates/basesrc +++ b/tools/element-templates/basesrc @@ -161,10 +161,16 @@ static gboolean gst_replace_event (GstBaseSrc * src, GstEvent * event) { GstReplace *replace = GST_REPLACE (src); + gboolean ret; GST_DEBUG_OBJECT (replace, "event"); - return TRUE; + switch (GST_EVENT_TYPE (event)) { + default: + ret = GST_BASE_SRC_CLASS (parent_class)->event (src, event); + } + + return ret; } static GstFlowReturn @@ -192,10 +198,16 @@ static gboolean gst_replace_query (GstBaseSrc * src, GstQuery * query) { GstReplace *replace = GST_REPLACE (src); + gboolean ret; GST_DEBUG_OBJECT (replace, "query"); - return TRUE; + switch (GST_QUERY_TYPE (query)) { + default: + ret = GST_BASE_SRC_CLASS (parent_class)->query (src, query); + } + + return ret; } static gboolean diff --git a/tools/element-templates/element b/tools/element-templates/element index ed025ee2b..f0d76ebc3 100644 --- a/tools/element-templates/element +++ b/tools/element-templates/element @@ -123,7 +123,17 @@ gst_replace_send_event (GstElement * element, GstEvent * event) static gboolean gst_replace_query (GstElement * element, GstQuery * query) { + GstReplace *replace = GST_REPLACE (element); + gboolean ret; - return FALSE; + GST_DEBUG_OBJECT (replace, "query"); + + switch (GST_QUERY_TYPE (query)) { + default: + ret = GST_ELEMENT_CLASS (parent_class)->query (element, query); + break; + } + + return ret; } % end -- cgit v1.2.1