much cleanup hacking made possible by plugin changes
authorDavid Schleef <ds@schleef.org>
Sat, 8 Nov 2003 02:52:41 +0000 (02:52 +0000)
committerDavid Schleef <ds@schleef.org>
Sat, 8 Nov 2003 02:52:41 +0000 (02:52 +0000)
Original commit message from CVS:
much cleanup hacking made possible by plugin changes

gst/videofilter/gstvideobalance.c
gst/videofilter/gstvideofilter.c
gst/videofilter/gstvideofilter.h
gst/videofilter/gstvideoflip.c
gst/videofilter/gstvideoflip.h

index 498e1e5..842b311 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+/*
+ * This file was (probably) generated from gstvideobalance.c,
+ * $Id$
+ */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 #include <string.h>
 #include <math.h>
 
-
-/* elementfactory information */
-static GstElementDetails videobalance_details = {
-  "Video Balance control",
-  "Filter/Video",
-  "Adjusts brightness, contrast, hue, saturation on a video stream",
-  "David Schleef <ds@schleef.org>"
-};
-
 /* GstVideobalance signals and args */
 enum {
   /* FILL ME */
@@ -51,9 +47,9 @@ enum {
   /* FILL ME */
 };
 
-static void    gst_videobalance_class_init     (GstVideobalanceClass *klass);
-static void    gst_videobalance_base_init      (GstVideobalanceClass *klass);
-static void    gst_videobalance_init           (GstVideobalance *videobalance);
+static void    gst_videobalance_base_init      (gpointer g_class);
+static void    gst_videobalance_class_init     (gpointer g_class, gpointer class_data);
+static void    gst_videobalance_init           (GTypeInstance *instance, gpointer g_class);
 
 static void    gst_videobalance_set_property           (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
 static void    gst_videobalance_get_property           (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@@ -61,10 +57,6 @@ static void  gst_videobalance_get_property           (GObject *object, guint prop_id, GVal
 static void gst_videobalance_planar411(GstVideofilter *videofilter, void *dest, void *src);
 static void gst_videobalance_setup(GstVideofilter *videofilter);
 
-static GstVideobalanceClass *this_class = NULL;
-static GstVideofilterClass *parent_class = NULL;
-static GstElementClass *element_class = NULL;
-
 GType
 gst_videobalance_get_type (void)
 {
@@ -73,16 +65,17 @@ gst_videobalance_get_type (void)
   if (!videobalance_type) {
     static const GTypeInfo videobalance_info = {
       sizeof(GstVideobalanceClass),
-      (GBaseInitFunc)gst_videobalance_base_init,
+      gst_videobalance_base_init,
       NULL,
-      (GClassInitFunc)gst_videobalance_class_init,
+      gst_videobalance_class_init,
       NULL,
       NULL,
       sizeof(GstVideobalance),
       0,
-      (GInstanceInitFunc)gst_videobalance_init,
+      gst_videobalance_init,
     };
-    videobalance_type = g_type_register_static(GST_TYPE_VIDEOFILTER, "GstVideobalance", &videobalance_info, 0);
+    videobalance_type = g_type_register_static(GST_TYPE_VIDEOFILTER,
+        "GstVideobalance", &videobalance_info, 0);
   }
   return videobalance_type;
 }
@@ -91,129 +84,74 @@ static GstVideofilterFormat gst_videobalance_formats[] = {
   { "I420", 12, gst_videobalance_planar411, },
 };
 
-static GstPadTemplate *gst_videobalance_sink_template_factory (void);
-static GstPadTemplate *gst_videobalance_src_template_factory (void);
-
+  
 static void
-gst_videobalance_base_init (GstVideobalanceClass *klass)
+gst_videobalance_base_init (gpointer g_class)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-       GST_PAD_TEMPLATE_GET (gst_videobalance_sink_template_factory));
-  gst_element_class_add_pad_template (element_class,
-       GST_PAD_TEMPLATE_GET (gst_videobalance_src_template_factory));
+  static GstElementDetails videobalance_details = GST_ELEMENT_DETAILS (
+    "Video Balance Control",
+    "Filter/Video",
+    "Adjusts brightness, contrast, hue, saturation on a video stream",
+    "David Schleef <ds@schleef.org>"
+  );
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
+  int i;
+  
   gst_element_class_set_details (element_class, &videobalance_details);
+
+  for(i=0;i<G_N_ELEMENTS(gst_videobalance_formats);i++){
+    gst_videofilter_class_add_format(videofilter_class,
+       gst_videobalance_formats + i);
+  }
+
+  gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
 }
 
 static void
-gst_videobalance_class_init (GstVideobalanceClass *klass)
+gst_videobalance_class_init (gpointer g_class, gpointer class_data)
 {
   GObjectClass *gobject_class;
-  GstElementClass *gstelement_class;
-  GstVideofilterClass *gstvideofilter_class;
-  int i;
+  GstVideofilterClass *videofilter_class;
 
-  gobject_class = (GObjectClass*)klass;
-  gstelement_class = (GstElementClass*)klass;
-  gstvideofilter_class = (GstVideofilterClass *)klass;
+  gobject_class = G_OBJECT_CLASS (g_class);
+  videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
 
-  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CONTRAST,
+  g_object_class_install_property(gobject_class, ARG_CONTRAST,
       g_param_spec_double("contrast","Contrast","contrast",
       0, 2, 1, G_PARAM_READWRITE));
-  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BRIGHTNESS,
+  g_object_class_install_property(gobject_class, ARG_BRIGHTNESS,
       g_param_spec_double("brightness","Brightness","brightness",
       -1, 1, 0, G_PARAM_READWRITE));
-  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HUE,
+  g_object_class_install_property(gobject_class, ARG_HUE,
       g_param_spec_double("hue","Hue","hue",
       -1, 1, 0, G_PARAM_READWRITE));
-  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SATURATION,
+  g_object_class_install_property(gobject_class, ARG_SATURATION,
       g_param_spec_double("saturation","Saturation","saturation",
       0, 2, 1, G_PARAM_READWRITE));
 
-  this_class = klass;
-  parent_class = g_type_class_ref(GST_TYPE_VIDEOFILTER);
-  element_class = g_type_class_ref(GST_TYPE_ELEMENT);
-
   gobject_class->set_property = gst_videobalance_set_property;
   gobject_class->get_property = gst_videobalance_get_property;
 
-  gstvideofilter_class->setup = gst_videobalance_setup;
-
-  for(i=0;i<G_N_ELEMENTS(gst_videobalance_formats);i++){
-    gst_videofilter_class_add_format(gstvideofilter_class,
-       gst_videobalance_formats + i);
-  }
-}
-
-static GstCaps *gst_videobalance_get_capslist(void)
-{
-  GstVideofilterClass *klass;
-
-  klass = g_type_class_ref(GST_TYPE_VIDEOFILTER);
-
-  return gst_videofilter_class_get_capslist(klass);
-}
-
-static GstPadTemplate *
-gst_videobalance_src_template_factory(void)
-{
-  static GstPadTemplate *templ = NULL;
-
-  if(!templ){
-    GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
-               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
-
-    caps = gst_caps_intersect(caps, gst_videobalance_get_capslist ());
-
-    templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
-  }
-  return templ;
-}
-
-static GstPadTemplate *
-gst_videobalance_sink_template_factory(void)
-{
-  static GstPadTemplate *templ = NULL;
-
-  if(!templ){
-    GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
-               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
-
-    caps = gst_caps_intersect(caps, gst_videobalance_get_capslist ());
-
-    templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
-  }
-  return templ;
+  videofilter_class->setup = gst_videobalance_setup;
 }
 
 static void
-gst_videobalance_init (GstVideobalance *videobalance)
+gst_videobalance_init (GTypeInstance *instance, gpointer g_class)
 {
+  GstVideobalance *videobalance = GST_VIDEOBALANCE (instance);
   GstVideofilter *videofilter;
 
   GST_DEBUG("gst_videobalance_init");
 
   videofilter = GST_VIDEOFILTER(videobalance);
 
-  videofilter->sinkpad = gst_pad_new_from_template (
-                 GST_PAD_TEMPLATE_GET (gst_videobalance_sink_template_factory),
-                 "sink");
-
-  videofilter->srcpad = gst_pad_new_from_template (
-                 GST_PAD_TEMPLATE_GET (gst_videobalance_src_template_factory),
-                 "src");
-
+  /* do stuff */
   videobalance->contrast = 1;
   videobalance->brightness = 0;
   videobalance->saturation = 1;
   videobalance->hue = 0;
 
-  gst_videofilter_postinit(GST_VIDEOFILTER(videobalance));
 }
 
 static void
@@ -277,8 +215,8 @@ static gboolean plugin_init (GstPlugin *plugin)
   if(!gst_library_load("gstvideofilter"))
     return FALSE;
 
-  return gst_element_register(plugin, "videobalance",
-                             GST_RANK_NONE, GST_TYPE_VIDEOBALANCE);
+  return gst_element_register (plugin, "videobalance", GST_RANK_NONE,
+      GST_TYPE_VIDEOBALANCE);
 }
 
 GST_PLUGIN_DEFINE (
@@ -288,7 +226,7 @@ GST_PLUGIN_DEFINE (
   "Changes hue, saturation, brightness etc. on video images",
   plugin_init,
   VERSION,
-  "LGPL",
+  GST_LICENSE,
   GST_COPYRIGHT,
   GST_PACKAGE,
   GST_ORIGIN
@@ -301,6 +239,8 @@ static void gst_videobalance_setup(GstVideofilter *videofilter)
   g_return_if_fail(GST_IS_VIDEOBALANCE(videofilter));
   videobalance = GST_VIDEOBALANCE(videofilter);
 
+  /* if any setup needs to be done, do it here */
+
 }
 
 static void gst_videobalance_planar411(GstVideofilter *videofilter,
@@ -373,5 +313,6 @@ static void gst_videobalance_planar411(GstVideofilter *videofilter,
       }
     }
   }
+
 }
 
index 3eb92f9..b388aab 100644 (file)
 
 
 
-#if 0
-/* elementfactory information */
-static GstElementDetails videofilter_details = {
-  "Video scaler",
-  "Filter/Video",
-  "Resizes video",
-  "David Schleef <ds@schleef.org>"
-};
-#endif
-
 /* GstVideofilter signals and args */
 enum {
   /* FILL ME */
@@ -49,9 +39,9 @@ enum {
   /* FILL ME */
 };
 
-static void     gst_videofilter_base_init       (GstVideofilterClass *klass);
-static void    gst_videofilter_class_init      (GstVideofilterClass *klass);
-static void    gst_videofilter_init            (GstVideofilter *videofilter);
+static void     gst_videofilter_base_init       (gpointer g_class);
+static void    gst_videofilter_class_init      (gpointer g_class, gpointer class_data);
+static void    gst_videofilter_init            (GTypeInstance *instance, gpointer g_class);
 
 static void    gst_videofilter_set_property            (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
 static void    gst_videofilter_get_property            (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@@ -70,14 +60,14 @@ gst_videofilter_get_type (void)
   if (!videofilter_type) {
     static const GTypeInfo videofilter_info = {
       sizeof(GstVideofilterClass),
-      (GBaseInitFunc)gst_videofilter_base_init,
+      gst_videofilter_base_init,
       NULL,
-      (GClassInitFunc)gst_videofilter_class_init,
+      gst_videofilter_class_init,
       NULL,
       NULL,
       sizeof(GstVideofilter),
       0,
-      (GInstanceInitFunc)gst_videofilter_init,
+      gst_videofilter_init,
     };
     videofilter_type = g_type_register_static(GST_TYPE_ELEMENT,
        "GstVideofilter", &videofilter_info, G_TYPE_FLAG_ABSTRACT);
@@ -85,26 +75,29 @@ gst_videofilter_get_type (void)
   return videofilter_type;
 }
 
-static void gst_videofilter_base_init (GstVideofilterClass *klass)
+static void gst_videofilter_base_init (gpointer g_class)
 {
-  klass->formats = g_ptr_array_new();
-
-#if 0
+  static GstElementDetails videofilter_details = {
+    "Video scaler",
+    "Filter/Video",
+    "Resizes video",
+    "David Schleef <ds@schleef.org>"
+  };
+  GstVideofilterClass *klass = (GstVideofilterClass *) g_class;
   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
 
-  gst_element_class_add_pad_template (element_class,
-      GST_PAD_TEMPLATE_GET (gst_videofilter_sink_template_factory));
-  gst_element_class_add_pad_template (element_class,
-      GST_PAD_TEMPLATE_GET (gst_videofilter_src_template_factory));
+  klass->formats = g_ptr_array_new();
+
   gst_element_class_set_details (element_class, &videofilter_details);
-#endif
 }
 
-static void gst_videofilter_class_init (GstVideofilterClass *klass)
+static void gst_videofilter_class_init (gpointer g_class, gpointer class_data)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
+  GstVideofilterClass *klass;
 
+  klass = (GstVideofilterClass *)g_class;
   gobject_class = (GObjectClass*)klass;
   gstelement_class = (GstElementClass*)klass;
 
@@ -114,44 +107,6 @@ static void gst_videofilter_class_init (GstVideofilterClass *klass)
   gobject_class->get_property = gst_videofilter_get_property;
 }
 
-#if 0
-static GstPadTemplate *
-gst_videofilter_src_template_factory(void)
-{
-  static GstPadTemplate *templ = NULL;
-
-  if(!templ){
-    GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
-               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
-
-    caps = gst_caps_intersect(caps, gst_videofilter_get_capslist ());
-
-    templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
-  }
-  return templ;
-}
-
-static GstPadTemplate *
-gst_videofilter_sink_template_factory(void)
-{
-  static GstPadTemplate *templ = NULL;
-
-  if(!templ){
-    GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
-               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
-
-    caps = gst_caps_intersect(caps, gst_videofilter_get_capslist ());
-
-    templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
-  }
-  return templ;
-}
-#endif
-
 static GstCaps *gst_videofilter_format_get_caps(GstVideofilterFormat *format)
 {
   unsigned int fourcc;
@@ -347,34 +302,49 @@ gst_videofilter_sink_link (GstPad *pad, GstCaps *caps)
 }
 
 static void
-gst_videofilter_init (GstVideofilter *videofilter)
+gst_videofilter_init (GTypeInstance *instance, gpointer g_class)
 {
+  GstVideofilter *videofilter = GST_VIDEOFILTER (instance);
+  GstPadTemplate *pad_template;
+
   GST_DEBUG("gst_videofilter_init");
 
-}
+  {
+    GList *list;
+
+    list = gst_element_class_get_pad_template_list (GST_ELEMENT_CLASS(g_class));
+g_print("getting pad templates from %s\n",
+      g_type_name(G_TYPE_FROM_CLASS(g_class)));
+    g_print("pad template list:");
+    while(list){
+      GstPadTemplate *padtempl = (GstPadTemplate*) list->data;
+      g_print(" %p \"%s\",", padtempl, padtempl->name_template);
+      list = g_list_next(list);
+    }
+    g_print("\n");
+  }
 
-void
-gst_videofilter_postinit (GstVideofilter *videofilter)
-{
-  /* sinkpad and srcpad should be inited by subclass */
 
-  /* FIXME */
-  //videofilter->sinkpad = NULL;
+  pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
+      "sink");
+  g_return_if_fail(pad_template != NULL);
+  videofilter->sinkpad = gst_pad_new_from_template(pad_template, "sink");
   gst_element_add_pad(GST_ELEMENT(videofilter),videofilter->sinkpad);
   gst_pad_set_chain_function(videofilter->sinkpad,gst_videofilter_chain);
   gst_pad_set_link_function(videofilter->sinkpad,gst_videofilter_sink_link);
   gst_pad_set_getcaps_function(videofilter->sinkpad,gst_videofilter_sink_getcaps);
 
-  /* FIXME */
-  //videofilter->srcpad = NULL;
+  pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
+      "src");
+  g_return_if_fail(pad_template != NULL);
+  videofilter->srcpad = gst_pad_new_from_template(pad_template, "src");
   gst_element_add_pad(GST_ELEMENT(videofilter),videofilter->srcpad);
   gst_pad_set_link_function(videofilter->srcpad,gst_videofilter_src_link);
-  //gst_pad_set_getcaps_function(videofilter->srcpad,gst_videofilter_getcaps);
+  //gst_pad_set_getcaps_function(videofilter->srcpad,gst_videofilter_src_getcaps);
 
   videofilter->inited = FALSE;
 }
 
-
 static void
 gst_videofilter_chain (GstPad *pad, GstData *_data)
 {
@@ -574,14 +544,32 @@ void gst_videofilter_class_add_format(GstVideofilterClass *videofilterclass,
   g_ptr_array_add(videofilterclass->formats, format);
 }
 
+void gst_videofilter_class_add_pad_templates (GstVideofilterClass *videofilter_class)
+{
+  GstCaps *caps;
+  GstElementClass *element_class = GST_ELEMENT_CLASS (videofilter_class);
+
+g_print("adding pad templates to %s\n",g_type_name(G_TYPE_FROM_CLASS(videofilter_class)));
+
+  caps = GST_CAPS_NEW("src","video/x-raw-yuv",
+               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
+               "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
+
+  gst_element_class_add_pad_template (element_class,
+      GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, 
+        gst_caps_intersect(caps,
+          gst_videofilter_class_get_capslist (videofilter_class))));
+
+  gst_element_class_add_pad_template (element_class,
+      GST_PAD_TEMPLATE_NEW("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
+        gst_caps_intersect(caps,
+          gst_videofilter_class_get_capslist (videofilter_class))));
+}
+
 static gboolean
 plugin_init (GstPlugin *plugin)
 {
-#if 0
-  return gst_element_register(plugin, "videofilter",
-                             GST_RANK_NONE, GST_TYPE_VIDEOFILTER);
-#endif
-
   return TRUE;
 }
 
index fa70832..63f9692 100644 (file)
@@ -98,10 +98,9 @@ GstVideofilterFormat *gst_videofilter_find_format_by_caps(GstVideofilter *filter
     GstCaps *caps);
 GstCaps *gst_videofilter_class_get_capslist(GstVideofilterClass *videofilterclass);
 
-void gst_videofilter_postinit(GstVideofilter *videofilter);
-
 void gst_videofilter_class_add_format(GstVideofilterClass *videofilterclass,
     GstVideofilterFormat *format);
+void gst_videofilter_class_add_pad_templates (GstVideofilterClass *videofilterclass);
 
 G_END_DECLS
 
index 375d304..307f2f2 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+/*
+ * This file was (probably) generated from gstvideoflip.c,
+ * $Id$
+ */
 
-/*#define DEBUG_ENABLED */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
-#include <gstvideoflip.h>
 
-#include <stdlib.h>
-#include <math.h>
+/*#define DEBUG_ENABLED */
+#include <gstvideoflip.h>
 #include <string.h>
 
-
-
-/* elementfactory information */
-static GstElementDetails videoflip_details = {
-  "Video flipper",
-  "Filter/Video",
-  "Flips and rotates video",
-  "David Schleef <ds@schleef.org>"
-};
-
 /* GstVideoflip signals and args */
 enum {
   /* FILL ME */
@@ -51,9 +43,9 @@ enum {
   /* FILL ME */
 };
 
-static void    gst_videoflip_class_init        (GstVideoflipClass *klass);
-static void    gst_videoflip_base_init         (GstVideoflipClass *klass);
-static void    gst_videoflip_init              (GstVideoflip *videoflip);
+static void    gst_videoflip_base_init (gpointer g_class);
+static void    gst_videoflip_class_init        (gpointer g_class, gpointer class_data);
+static void    gst_videoflip_init              (GTypeInstance *instance, gpointer g_class);
 
 static void    gst_videoflip_set_property              (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
 static void    gst_videoflip_get_property              (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@@ -61,10 +53,6 @@ static void  gst_videoflip_get_property              (GObject *object, guint prop_id, GValue
 static void gst_videoflip_planar411(GstVideofilter *videofilter, void *dest, void *src);
 static void gst_videoflip_setup(GstVideofilter *videofilter);
 
-static GstVideoflipClass *this_class = NULL;
-static GstVideofilterClass *parent_class = NULL;
-static GstElementClass *element_class = NULL;
-
 #define GST_TYPE_VIDEOFLIP_METHOD (gst_videoflip_method_get_type())
 
 static GType
@@ -72,19 +60,19 @@ gst_videoflip_method_get_type(void)
 {
   static GType videoflip_method_type = 0;
   static GEnumValue videoflip_methods[] = {
-    { GST_VIDEOFLIP_METHOD_IDENTITY,   "0", "Identity (no rotation)" },
-    { GST_VIDEOFLIP_METHOD_90R,                "1", "Rotate clockwise 90 degrees" },
-    { GST_VIDEOFLIP_METHOD_180,                "2", "Rotate 180 degrees" },
-    { GST_VIDEOFLIP_METHOD_90L,                "3", "Rotate counter-clockwise 90 degrees" },
-    { GST_VIDEOFLIP_METHOD_HORIZ,      "4", "Flip horizontally" },
-    { GST_VIDEOFLIP_METHOD_VERT,       "5", "Flip vertically" },
-    { GST_VIDEOFLIP_METHOD_TRANS,      "6", "Flip across upper left/lower right diagonal" },
-    { GST_VIDEOFLIP_METHOD_OTHER,      "7", "Flip across upper right/lower left diagonal" },
+    { GST_VIDEOFLIP_METHOD_IDENTITY,   "0", "Identity (no rotation)" },
+    { GST_VIDEOFLIP_METHOD_90R,                "1", "Rotate clockwise 90 degrees" },
+    { GST_VIDEOFLIP_METHOD_180,                "2", "Rotate 180 degrees" },
+    { GST_VIDEOFLIP_METHOD_90L,                "3", "Rotate counter-clockwise 90 degrees" },
+    { GST_VIDEOFLIP_METHOD_HORIZ,      "4", "Flip horizontally" },
+    { GST_VIDEOFLIP_METHOD_VERT,       "5", "Flip vertically" },
+    { GST_VIDEOFLIP_METHOD_TRANS,      "6", "Flip across upper left/lower right diagonal" },
+    { GST_VIDEOFLIP_METHOD_OTHER,      "7", "Flip across upper right/lower left diagonal" },
     { 0, NULL, NULL },
   };
   if(!videoflip_method_type){
     videoflip_method_type = g_enum_register_static("GstVideoflipMethod",
-       videoflip_methods);
+       videoflip_methods);
   }
   return videoflip_method_type;
 }
@@ -97,16 +85,17 @@ gst_videoflip_get_type (void)
   if (!videoflip_type) {
     static const GTypeInfo videoflip_info = {
       sizeof(GstVideoflipClass),
-      (GBaseInitFunc)gst_videoflip_base_init,
+      gst_videoflip_base_init,
       NULL,
-      (GClassInitFunc)gst_videoflip_class_init,
+      gst_videoflip_class_init,
       NULL,
       NULL,
       sizeof(GstVideoflip),
       0,
-      (GInstanceInitFunc)gst_videoflip_init,
+      gst_videoflip_init,
     };
-    videoflip_type = g_type_register_static(GST_TYPE_VIDEOFILTER, "GstVideoflip", &videoflip_info, 0);
+    videoflip_type = g_type_register_static(GST_TYPE_VIDEOFILTER,
+        "GstVideoflip", &videoflip_info, 0);
   }
   return videoflip_type;
 }
@@ -118,133 +107,77 @@ static GstVideofilterFormat gst_videoflip_formats[] = {
   { "IYUV", 12, gst_videoflip_planar411, },
 };
 
-static GstPadTemplate *gst_videoflip_sink_template_factory (void);
-static GstPadTemplate *gst_videoflip_src_template_factory (void);
-
 static void
-gst_videoflip_base_init (GstVideoflipClass *klass)
+gst_videoflip_base_init (gpointer g_class)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_pad_template (element_class,
-       GST_PAD_TEMPLATE_GET (gst_videoflip_sink_template_factory));
-  gst_element_class_add_pad_template (element_class,
-       GST_PAD_TEMPLATE_GET (gst_videoflip_src_template_factory));
+  static GstElementDetails videoflip_details = GST_ELEMENT_DETAILS (
+    "Video Flipper",
+    "Filter/Video",
+    "Flips and rotates video",
+    "David Schleef <ds@schleef.org>"
+  );
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
+  int i;
+  
   gst_element_class_set_details (element_class, &videoflip_details);
+
+  for(i=0;i<G_N_ELEMENTS(gst_videoflip_formats);i++){
+    gst_videofilter_class_add_format(videofilter_class,
+       gst_videoflip_formats + i);
+  }
+
+  gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
 }
 
 static void
-gst_videoflip_class_init (GstVideoflipClass *klass)
+gst_videoflip_class_init (gpointer g_class, gpointer class_data)
 {
   GObjectClass *gobject_class;
-  GstElementClass *gstelement_class;
-  GstVideofilterClass *gstvideofilter_class;
-  int i;
+  GstVideofilterClass *videofilter_class;
 
-  gobject_class = (GObjectClass*)klass;
-  gstelement_class = (GstElementClass*)klass;
-  gstvideofilter_class = (GstVideofilterClass *)klass;
+  gobject_class = G_OBJECT_CLASS (g_class);
+  videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
 
-  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_METHOD,
+  g_object_class_install_property(gobject_class, ARG_METHOD,
       g_param_spec_enum("method","method","method",
       GST_TYPE_VIDEOFLIP_METHOD, GST_VIDEOFLIP_METHOD_90R,
       G_PARAM_READWRITE));
 
-  this_class = klass;
-  parent_class = g_type_class_ref(GST_TYPE_VIDEOFILTER);
-  element_class = g_type_class_ref(GST_TYPE_ELEMENT);
-
   gobject_class->set_property = gst_videoflip_set_property;
   gobject_class->get_property = gst_videoflip_get_property;
 
-  gstvideofilter_class->setup = gst_videoflip_setup;
-
-  for(i=0;i<G_N_ELEMENTS(gst_videoflip_formats);i++){
-    gst_videofilter_class_add_format(gstvideofilter_class,
-       gst_videoflip_formats + i);
-  }
-}
-
-static GstCaps *gst_videoflip_get_capslist(void)
-{
-  GstVideofilterClass *klass;
-
-  klass = g_type_class_ref(GST_TYPE_VIDEOFILTER);
-
-  return gst_videofilter_class_get_capslist(klass);
-}
-
-static GstPadTemplate *
-gst_videoflip_src_template_factory(void)
-{
-  static GstPadTemplate *templ = NULL;
-
-  if(!templ){
-    GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
-               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
-
-    caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ());
-
-    templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
-  }
-  return templ;
-}
-
-static GstPadTemplate *
-gst_videoflip_sink_template_factory(void)
-{
-  static GstPadTemplate *templ = NULL;
-
-  if(!templ){
-    GstCaps *caps = GST_CAPS_NEW("sink","video/x-raw-yuv",
-               "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
-               "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
-
-    caps = gst_caps_intersect(caps, gst_videoflip_get_capslist ());
-
-    templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
-  }
-  return templ;
+  videofilter_class->setup = gst_videoflip_setup;
 }
 
 static void
-gst_videoflip_init (GstVideoflip *videoflip)
+gst_videoflip_init (GTypeInstance *instance, gpointer g_class)
 {
+  GstVideoflip *videoflip = GST_VIDEOFLIP (instance);
   GstVideofilter *videofilter;
 
-  GST_DEBUG ("gst_videoflip_init");
+  GST_DEBUG("gst_videoflip_init");
 
   videofilter = GST_VIDEOFILTER(videoflip);
 
-  videofilter->sinkpad = gst_pad_new_from_template (
-                 GST_PAD_TEMPLATE_GET (gst_videoflip_sink_template_factory),
-                 "sink");
-
-  videofilter->srcpad = gst_pad_new_from_template (
-                 GST_PAD_TEMPLATE_GET (gst_videoflip_src_template_factory),
-                 "src");
-
-  gst_videofilter_postinit(GST_VIDEOFILTER(videoflip));
+  /* do stuff */
 }
 
 static void
 gst_videoflip_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
-  GstVideoflip *videoflip;
+  GstVideoflip *src;
 
   /* it's not null if we got it, but it might not be ours */
   g_return_if_fail(GST_IS_VIDEOFLIP(object));
-  videoflip = GST_VIDEOFLIP(object);
+  src = GST_VIDEOFLIP(object);
 
-  GST_DEBUG ("gst_videoflip_set_property");
+  GST_DEBUG("gst_videoflip_set_property");
   switch (prop_id) {
     case ARG_METHOD:
-      videoflip->method = g_value_get_enum (value);
+      src->method = g_value_get_enum (value);
       /* FIXME is this ok? (threading issues) */
-      gst_videoflip_setup(GST_VIDEOFILTER(videoflip));
+      gst_videoflip_setup(GST_VIDEOFILTER(src));
       break;
     default:
       break;
@@ -254,15 +187,15 @@ gst_videoflip_set_property (GObject *object, guint prop_id, const GValue *value,
 static void
 gst_videoflip_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 {
-  GstVideoflip *videoflip;
+  GstVideoflip *src;
 
   /* it's not null if we got it, but it might not be ours */
   g_return_if_fail(GST_IS_VIDEOFLIP(object));
-  videoflip = GST_VIDEOFLIP(object);
+  src = GST_VIDEOFLIP(object);
 
   switch (prop_id) {
     case ARG_METHOD:
-      g_value_set_enum (value, videoflip->method);
+      g_value_set_enum (value, src->method);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -275,24 +208,23 @@ static gboolean plugin_init (GstPlugin *plugin)
   if(!gst_library_load("gstvideofilter"))
     return FALSE;
 
-  return gst_element_register(plugin, "videoflip",
-                             GST_RANK_NONE, GST_TYPE_VIDEOFLIP);
+  return gst_element_register (plugin, "videoflip", GST_RANK_NONE,
+      GST_TYPE_VIDEOFLIP);
 }
 
 GST_PLUGIN_DEFINE (
   GST_VERSION_MAJOR,
   GST_VERSION_MINOR,
   "videoflip",
-  "Flips video",
+  "Flips and rotates video",
   plugin_init,
   VERSION,
-  "LGPL",
+  GST_LICENSE,
   GST_COPYRIGHT,
   GST_PACKAGE,
   GST_ORIGIN
 )
 
-
 static void gst_videoflip_flip(GstVideoflip *videoflip, unsigned char *dest,
     unsigned char *src, int sw, int sh, int dw, int dh);
 
@@ -332,9 +264,9 @@ static void gst_videoflip_setup (GstVideofilter *videofilter)
   }
 
   GST_DEBUG ("format=%p \"%s\" from %dx%d to %dx%d",
-               videofilter->format, videofilter->format->fourcc,
-               from_width, from_height,
-               videofilter->to_width, videofilter->to_height);
+               videofilter->format, videofilter->format->fourcc,
+               from_width, from_height,
+               videofilter->to_width, videofilter->to_height);
 
   if(videoflip->method == GST_VIDEOFLIP_METHOD_IDENTITY){
     GST_DEBUG ("videoflip: using passthru");
@@ -344,9 +276,9 @@ static void gst_videoflip_setup (GstVideofilter *videofilter)
   }
 
   videofilter->from_buf_size = (videofilter->from_width * videofilter->from_height
-                 * videofilter->format->depth) / 8;
+                 * videofilter->format->depth) / 8;
   videofilter->to_buf_size = (videofilter->to_width * videofilter->to_height
-                 * videofilter->format->depth) / 8;
+                 * videofilter->format->depth) / 8;
 
   videofilter->inited = TRUE;
 }
@@ -398,50 +330,50 @@ gst_videoflip_flip(GstVideoflip *videoflip, unsigned char *dest,
     case GST_VIDEOFLIP_METHOD_90R:
       for(y=0;y<dh;y++){
         for(x=0;x<dw;x++){
-         dest[y*dw + x] = src[(sh - 1 - x)*sw + y];
-       }
+         dest[y*dw + x] = src[(sh - 1 - x)*sw + y];
+       }
       }
       break;
     case GST_VIDEOFLIP_METHOD_90L:
       for(y=0;y<dh;y++){
         for(x=0;x<dw;x++){
-         dest[y*dw + x] = src[x*sw + (sw - 1 - y)];
-       }
+         dest[y*dw + x] = src[x*sw + (sw - 1 - y)];
+       }
       }
       break;
     case GST_VIDEOFLIP_METHOD_180:
       for(y=0;y<dh;y++){
         for(x=0;x<dw;x++){
-         dest[y*dw + x] = src[(sh - 1 - y)*sw + (sw - 1 - x)];
-       }
+         dest[y*dw + x] = src[(sh - 1 - y)*sw + (sw - 1 - x)];
+       }
       }
       break;
     case GST_VIDEOFLIP_METHOD_HORIZ:
       for(y=0;y<dh;y++){
         for(x=0;x<dw;x++){
-         dest[y*dw + x] = src[y*sw + (sw - 1 - x)];
-       }
+         dest[y*dw + x] = src[y*sw + (sw - 1 - x)];
+       }
       }
       break;
     case GST_VIDEOFLIP_METHOD_VERT:
       for(y=0;y<dh;y++){
         for(x=0;x<dw;x++){
-         dest[y*dw + x] = src[(sh - 1 - y)*sw + x];
-       }
+         dest[y*dw + x] = src[(sh - 1 - y)*sw + x];
+       }
       }
       break;
     case GST_VIDEOFLIP_METHOD_TRANS:
       for(y=0;y<dh;y++){
         for(x=0;x<dw;x++){
-         dest[y*dw + x] = src[x*sw + y];
-       }
+         dest[y*dw + x] = src[x*sw + y];
+       }
       }
       break;
     case GST_VIDEOFLIP_METHOD_OTHER:
       for(y=0;y<dh;y++){
         for(x=0;x<dw;x++){
-         dest[y*dw + x] = src[(sh - 1 - x)*sw + (sw - 1 - y)];
-       }
+         dest[y*dw + x] = src[(sh - 1 - x)*sw + (sw - 1 - y)];
+       }
       }
       break;
     default:
index b6aad29..83b3771 100644 (file)
@@ -40,7 +40,6 @@ typedef enum {
   GST_VIDEOFLIP_METHOD_OTHER,
 } GstVideoflipMethod;
 
-
 #define GST_TYPE_VIDEOFLIP \
   (gst_videoflip_get_type())
 #define GST_VIDEOFLIP(obj) \