diff --git a/ext/libpng/gstpng.c b/ext/libpng/gstpng.c index f3ac003c2d..54bcccbda8 100644 --- a/ext/libpng/gstpng.c +++ b/ext/libpng/gstpng.c @@ -16,70 +16,30 @@ * */ +#include + #include #include -#include #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; + if (!gst_element_register (plugin, "pngenc", GST_RANK_NONE, GST_TYPE_PNGENC)) + return FALSE; - /* 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); - - - /* 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) diff --git a/ext/libpng/gstpngenc.c b/ext/libpng/gstpngenc.c index a4578477fe..061e351451 100644 --- a/ext/libpng/gstpngenc.c +++ b/ext/libpng/gstpngenc.c @@ -22,6 +22,7 @@ #include #include #include "gstpngenc.h" +#include #define MAX_HEIGHT 4096 @@ -29,11 +30,8 @@ GstElementDetails gst_pngenc_details = { "PNG encoder", "Codec/Image", - "LGPL", "Encode a video frame to a .png image", - VERSION, "Jeremy SIMON ", - "(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) {