[gst-devel] Making plugs with scons and gob

John Janecek nopa90 at gmail.com
Thu Nov 24 17:45:03 CET 2005


This is just boiler plate what me use

Anyway just posting this because of request on irc not polished.
gob is at http://www.5z.com/jirka/gob.html

Also helpful to look at gobject tutorial

anyway

//Sconstruct file
import sys
env = Environment()
env.ParseConfig('pkg-config --cflags --libs gstreamer-base-0.9')
if sys.platform == "win32" :
    env.Append(CPPPATH=["C:/msys/1.0/local/include"])
    env.Append(LIBS=[''])
else :
    env.Command("gst-gob-plug.cc",'gob_plug.gob',"gob2 --for-cpp $SOURCE")
env.SharedLibrary(target ="gob_plug",source = ["gst-gob-plug.cc"],
SHLIBPREFIX='')

//gob_plug.gob
%alltop{
#include <gst/gst.h>
#include <gst/video/videosink.h>
%}

%{
#define VERSION "0.01"
#define PACKAGE "gob_plugin"

static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
  "sink",
  GST_PAD_SINK,
  GST_PAD_ALWAYS,
  GST_STATIC_CAPS ("ANY")
);

static GstStaticPadTemplate src_factory =
GST_STATIC_PAD_TEMPLATE (
  "src",
  GST_PAD_SRC,
  GST_PAD_ALWAYS,
  GST_STATIC_CAPS ("ANY")
);
%}

class Gst:Gob:Plug from Gst:Element {
    //variables
    public GstPad *sinkpad;
    public GstPad *srcpad;
    //properties
    public gboolean silent;
    property BOOLEAN silent
                (nick = "Silent",
                 blurb = "Produce output",
                 default_value = TRUE,
                 /* Export get/set functions for this property */
                 export,
                 /* link to the data memeber 'name' */
                 link);

    public gint size;
    property INT size
                (nick = "Size",
                 blurb = "Produce output",
                 default_value = 0,
                 /* Export get/set functions for this property */
                 export,
                 /* link to the data memeber 'name' */
                 link);

    //methods
    init(self) {
        GstElementClass *klass = GST_ELEMENT_GET_CLASS (self);
        self->sinkpad = gst_pad_new_from_template (
            gst_element_class_get_pad_template (klass, "sink"), "sink");
        gst_pad_set_setcaps_function (self->sinkpad,gst_gob_plug_set_caps);
        gst_pad_set_getcaps_function (self->sinkpad, gst_pad_proxy_getcaps);

        self->srcpad = gst_pad_new_from_template (
            gst_element_class_get_pad_template (klass,"src"),"src");
        gst_pad_set_getcaps_function (self->srcpad, gst_pad_proxy_getcaps);

        gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
        gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
        }

    public void
    base_init(gpointer klass) {
        static GstElementDetails plugin_details = {
            "GobPlugin",
            "Generic/GobPlugin",
            "GobPlugin Plugin",
            "John Janecek <nopa90 at gmail.com>"
            };
        GstElementClass *element_class = GST_ELEMENT_CLASS (klass);

        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));
        gst_element_class_set_details (element_class, &plugin_details);
        }

    public gboolean
    set_caps (GstPad *pad, GstCaps *caps) {
        return TRUE;
        }

    public GType
    get_type (void) {
        static GType plugin_type = 0;
        if (!plugin_type)
        {
            static const GTypeInfo plugin_info =
                {
                  sizeof (SelfClass),
                  (GBaseInitFunc) gst_gob_plug_base_init,
                  NULL,
                  (GClassInitFunc) gst_gob_plug_class_init,
                  NULL,
                  NULL,
                  sizeof (Self),
                  0,
                  (GInstanceInitFunc) gst_gob_plug_init,
                };
            plugin_type = g_type_register_static (GST_TYPE_ELEMENT,
                                              "gobplugin",
                                              &plugin_info,(GTypeFlags)0);
            }
        return plugin_type;
        }
}

%{
static gboolean
plugin_init (GstPlugin *plugin)
{
  return gst_element_register (plugin, "gobplugin",
                   GST_RANK_NONE,
                   GST_TYPE_GOB_PLUG );
}

/* this is the structure that gst-register looks for
 * so keep the name plugin_desc, or you cannot get your plug-in registered */
GST_PLUGIN_DEFINE (
  GST_VERSION_MAJOR,
  GST_VERSION_MINOR,
  "gobplugin",
  "gobplugin plugin",
  plugin_init,
  VERSION,
  "LGPL",
  "GStreamer",
  "http://gstreamer.net/"
)
%}




More information about the gstreamer-devel mailing list