pngenc fixed
authorIain Holmes <iain@prettypeople.org>
Sun, 2 Nov 2003 00:21:14 +0000 (00:21 +0000)
committerIain Holmes <iain@prettypeople.org>
Sun, 2 Nov 2003 00:21:14 +0000 (00:21 +0000)
Original commit message from CVS:
pngenc fixed

ext/libpng/gstpng.c
ext/libpng/gstpngenc.c

index f3ac003..54bcccb 100644 (file)
  *
  */
 
+#include <config.h>
+
 #include <string.h>
 #include <gst/gst.h>
-#include <gst/video/video.h>
 
 #include "gstpngenc.h"
 
-extern GstElementDetails gst_pngenc_details;
-
-static GstCaps*
-png_caps_factory (void)
-{
-  return gst_caps_new ( "png_png",
-                       "video/x-png",
-                       gst_props_new (
-                         "width",     GST_PROPS_INT_RANGE (16, 4096),
-                         "height",    GST_PROPS_INT_RANGE (16, 4096),
-                         "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
-                         NULL));
-}
-
-
-static GstCaps*
-raw_caps_factory (void)
-{ 
-  return gst_caps_new ( "png_raw", 
-                       "video/x-raw-rgb",
-                        GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24
-                     );
-}
-
 static gboolean
-plugin_init (GModule * module, GstPlugin * plugin)
+plugin_init (GstPlugin * plugin)
 {
-  GstElementFactory *png_enc;
-  GstCaps *raw_caps, *png_caps;
-
-  /* create an elementfactory for the jpegdec element */
-  png_enc = gst_element_factory_new("pngenc", GST_TYPE_PNGENC, &gst_pngenc_details);
-  g_return_val_if_fail(png_enc != NULL, FALSE);
-
-  raw_caps = raw_caps_factory ();
-  png_caps = png_caps_factory ();
-
-  /* register sink pads */
-  pngenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
-                                                      GST_PAD_ALWAYS,
-                                                      raw_caps, NULL);
-  gst_element_factory_add_pad_template (png_enc, pngenc_sink_template);
-  
+  if (!gst_element_register (plugin, "pngenc", GST_RANK_NONE, GST_TYPE_PNGENC))
+    return FALSE;
 
-  /* register src pads */
-  pngenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
-                                                    GST_PAD_ALWAYS,
-                                                    png_caps, NULL);
-  gst_element_factory_add_pad_template (png_enc, pngenc_src_template);
-  
-  gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (png_enc));
-  
   return TRUE;
 }
 
-GstPluginDesc plugin_desc = {
+GST_PLUGIN_DEFINE (
   GST_VERSION_MAJOR,
   GST_VERSION_MINOR,
   "png",
-  plugin_init
-};
+  "PNG plugin library",
+  plugin_init,
+  VERSION,
+  "LGPL",
+  GST_COPYRIGHT,
+  GST_PACKAGE,
+  GST_ORIGIN)
index a457847..061e351 100644 (file)
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <gst/gst.h>
 #include "gstpngenc.h"
+#include <gst/video/video.h>
 
 #define MAX_HEIGHT             4096
 
 GstElementDetails gst_pngenc_details = {
   "PNG encoder",
   "Codec/Image",
-  "LGPL",
   "Encode a video frame to a .png image",
-  VERSION,
   "Jeremy SIMON <jsimon13@yahoo.fr>",
-  "(C) 2000 Donald Graft",
 };
 
 
@@ -49,6 +47,7 @@ enum
   ARG_0
 };
 
+static void     gst_pngenc_base_init    (gpointer g_class);
 static void    gst_pngenc_class_init   (GstPngEncClass *klass);
 static void    gst_pngenc_init         (GstPngEnc *pngenc);
 
@@ -74,7 +73,8 @@ GType gst_pngenc_get_type (void)
 
   if (!pngenc_type) {
     static const GTypeInfo pngenc_info = {
-      sizeof (GstPngEncClass), NULL,
+      sizeof (GstPngEncClass),
+      gst_pngenc_base_init,
       NULL,
       (GClassInitFunc) gst_pngenc_class_init,
       NULL,
@@ -90,6 +90,50 @@ GType gst_pngenc_get_type (void)
   return pngenc_type;
 }
 
+static GstCaps*
+png_caps_factory (void)
+{
+  return gst_caps_new ( "png_png",
+                       "video/x-png",
+                       gst_props_new (
+                         "width",     GST_PROPS_INT_RANGE (16, 4096),
+                         "height",    GST_PROPS_INT_RANGE (16, 4096),
+                         "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
+                         NULL));
+}
+
+
+static GstCaps*
+raw_caps_factory (void)
+{ 
+  return gst_caps_new ( "png_raw", 
+                       "video/x-raw-rgb",
+                        GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24
+                     );
+}
+
+static void
+gst_pngenc_base_init (gpointer g_class)
+{
+  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+  GstCaps *raw_caps, *png_caps;
+  
+  raw_caps = raw_caps_factory ();
+  png_caps = png_caps_factory ();
+
+  pngenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
+                                              GST_PAD_ALWAYS,
+                                              raw_caps, NULL);
+  
+  pngenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
+                                             GST_PAD_ALWAYS,
+                                             png_caps, NULL);
+  
+  gst_element_class_add_pad_template (element_class, pngenc_sink_template);
+  gst_element_class_add_pad_template (element_class, pngenc_src_template);
+  gst_element_class_set_details (element_class, &gst_pngenc_details);
+}
+
 static void
 gst_pngenc_class_init (GstPngEncClass *klass)
 {