Getting a instance type error
iron_guitarist1987
jtrinidadperez at gmail.com
Mon Dec 17 11:08:45 PST 2012
The name is now GstMYPLUGIN
My header is :
#ifndef __GST_MYPLUGIN_H__
#define __GST_MYPLUGIN_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_MYPLUGIN \
(gst_myplugin_get_type())
#define GST_MYPLUGIN(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MYPLUGIN,GstMYPLUGIN))
#define GST_MYPLUGIN_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MYPLUGIN,GstMYPLUGINClass))
#define GST_IS_MYPLUGIN(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MYPLUGIN))
#define GST_IS_MYPLUGIN_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MYPLUGIN))
#define EMPTY_BUFFER_SIZE 16
typedef struct _GstMYPLUGIN GstMYPLUGIN;
typedef struct _GstMYPLUGINClass GstMYPLUGINClass;
struct _GstMyPlugin {
GstElement element;
/* pads */
GstPad *srcpad,
*sink0,
*sink1,
*sink2;
GstClockTime timestamp0;
GstClockTime timestamp1;
GstClockTime timestamp2;
/* properties */
guint input;
/* negotiated format */
gint format;
gint width;
gint height;
gdouble fps;
gint fps_num;
gint fps_denom;
gdouble x,y;
myStruct data;
myStruct next_data;
GstBuffer *bufhead1;
GstBuffer *buftail1;
guint queue_size1;
GstBuffer *bufhead2;
GstBuffer *buftail2;
guint queue_size2;
};
struct _GstMYPLUGINClass {
GstElementClass parent_class;
};
GType gst_myplugin_get_type (void);
G_END_DECLS
#endif /* __GST_MYPLUGIN_H__ */
My plugin:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "myplugin_chain.h"
GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);
#define GST_CAT_DEFAULT gst_myplugin_debug
static GstStaticPadTemplate gst_myplugin_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (OBJECT_MIME_TYPE)
);
static GstStaticPadTemplate gst_myplugin_video_sink_template =
GST_STATIC_PAD_TEMPLATE ("geovideo_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-rgb")
);
static GstStaticPadTemplate gst_myplugin_data_sink_template =
GST_STATIC_PAD_TEMPLATE ("data_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (DATA_CAPS)
);
static GstStaticPadTemplate gst_myplugin_obj_sink_template =
GST_STATIC_PAD_TEMPLATE ("obj_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (OBJ_OBJECT_MIME_TYPE)
);
GST_BOILERPLATE (GstMYPLUGIN, gst_myplugin, GstElement, GST_TYPE_ELEMENT);
enum
{
LAST_SIGNAL
};
#define DEFAULT_PROP_INPUT 1
enum
{
PROP_0,
PROP_INPUT,
PROP_LAST
};
static void gst_myplugin_finalize (GstMYPLUGIN * myplugin);
static void gst_myplugin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_myplugin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstFlowReturn gst_myplugin_chain_video (GstPad * pad, GstBuffer *
buf);
static GstFlowReturn gst_myplugin_chain_data (GstPad *pad, GstBuffer *buf);
static GstFlowReturn gst_myplugin_chain_obj (GstPad *pad, GstBuffer *buf);
static gboolean gst_myplugin_sink_event (GstPad *pad, GstEvent *event);
static void
gst_myplugin_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_myplugin_video_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_myplugin_data_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_myplugin_obj_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_myplugin_src_template));
gst_element_class_set_details_simple (element_class, "MyPlugin",
"obj",
"My plugin",
"Jason");
}
static void
gst_myplugin_class_init (GstMYPLUGINClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->set_property = gst_myplugin_set_property;
gobject_class->get_property = gst_myplugin_get_property;
gobject_class->finalize = (GObjectFinalizeFunc) gst_myplugin_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_INPUT,
g_param_spec_int ("input", "Input",
"Chooses the input that will be displayed", 0, 2,
1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
GST_DEBUG("Leaving base init");
}
static gboolean
gst_myplugin_setcaps (GstPad * pad, GstCaps * caps)
{
GstMYPLUGIN *myplugin;
GstStructure *structure;
gboolean ret = TRUE;
myplugin = GST_MYPLUGIN (GST_PAD_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
GST_DEBUG("The mime type is %s", gst_structure_get_name (structure));
ret = gst_structure_get_int (structure, "width", &myplugin->width);
ret &= gst_structure_get_int (structure, "height", &myplugin->height);
ret &= gst_structure_get_fraction (structure, "framerate",
&myplugin->fps_num, &myplugin->fps_denom);
if (!ret) {
return FALSE;
}
myplugin->fps = ((gdouble) myplugin->fps_num) / myplugin->fps_denom;
return ret;
}
static GstCaps *
gst_myplugin_data_getcaps (GstPad * pad)
{
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
}
static gboolean
gst_myplugin_data_setcaps (GstPad * pad, GstCaps * caps)
{
gboolean res = FALSE;
GstStructure *s = gst_caps_get_structure (caps, 0);
GST_DEBUG("Entering data setcaps");
GST_DEBUG("The mime type is %s", gst_structure_get_name (s));
if (gst_structure_has_name (s, DATA_DATA_MIME_TYPE)) {
res = TRUE;
}
return res;
}
static GstCaps *
gst_myplugin_obj_getcaps (GstPad * pad)
{
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
}
static gboolean
gst_myplugin_obj_setcaps (GstPad * pad, GstCaps * caps)
{
gboolean res = FALSE;
GstStructure *s = gst_caps_get_structure (caps, 0);
if (gst_structure_has_name (s, OBJ_OBJECT_MIME_TYPE)) {
res = TRUE;
}
return res;
}
static gboolean
gst_myplugin_sink_event (GstPad *pad, GstEvent *event)
{
gboolean ret;
GstMYPLUGIN *myplugin;
myplugin = GST_MYPLUGIN (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NEWSEGMENT:
ret = gst_pad_push_event (myplugin->srcpad, event);
break;
case GST_EVENT_EOS:
ret = gst_pad_push_event (myplugin->srcpad, event);
break;
case GST_EVENT_FLUSH_STOP:
ret = gst_pad_push_event (myplugin->srcpad, event);
break;
case GST_EVENT_FLUSH_START:
ret = gst_pad_push_event (myplugin->srcpad, event);
break;
default:
ret = gst_pad_event_default (pad, event);
break;
}
gst_object_unref (myplugin);
return ret;
}
static void
gst_myplugin_init (GstMYPLUGIN * myplugin, GstMYPLUGINClass * gclass)
{
myplugin->video_sink =
gst_pad_new_from_static_template (&gst_myplugin_video_sink_template,
"geovideo_sink");
gst_pad_set_setcaps_function (myplugin->video_sink,
GST_DEBUG_FUNCPTR (gst_myplugin_setcaps));
gst_pad_set_chain_function (myplugin->video_sink,
GST_DEBUG_FUNCPTR(gst_myplugin_chain_video));
gst_pad_set_event_function (myplugin->video_sink,
GST_DEBUG_FUNCPTR (gst_myplugin_sink_event));
gst_element_add_pad (GST_ELEMENT (myplugin), myplugin->video_sink);
myplugin->data_sink =
gst_pad_new_from_static_template (&gst_myplugin_data_sink_template,
"data_sink");
gst_pad_set_setcaps_function (myplugin->data_sink,
GST_DEBUG_FUNCPTR (gst_myplugin_data_setcaps));
gst_pad_set_getcaps_function (myplugin->data_sink,
GST_DEBUG_FUNCPTR(gst_myplugin_data_getcaps));
gst_pad_set_chain_function (myplugin->data_sink,
GST_DEBUG_FUNCPTR(gst_myplugin_chain_data));
gst_pad_set_event_function (myplugin->data_sink,
GST_DEBUG_FUNCPTR (gst_myplugin_sink_event));
gst_element_add_pad (GST_ELEMENT (myplugin), myplugin->data_sink);
myplugin->obj_sink =
gst_pad_new_from_static_template (&gst_myplugin_obj_sink_template,
"obj_sink");
gst_pad_set_setcaps_function (myplugin->obj_sink,
GST_DEBUG_FUNCPTR (gst_myplugin_obj_setcaps));
gst_pad_set_getcaps_function (myplugin->obj_sink,
GST_DEBUG_FUNCPTR(gst_myplugin_obj_getcaps));
gst_pad_set_chain_function (myplugin->obj_sink,
GST_DEBUG_FUNCPTR(gst_myplugin_chain_obj));
gst_pad_set_event_function (myplugin->obj_sink,
GST_DEBUG_FUNCPTR (gst_myplugin_sink_event));
gst_element_add_pad (GST_ELEMENT (myplugin), myplugin->obj_sink);
myplugin->srcpad =
gst_pad_new_from_static_template (&gst_myplugin_src_template, "src");
gst_pad_set_setcaps_function (myplugin->srcpad,
GST_DEBUG_FUNCPTR (gst_myplugin_obj_setcaps));
gst_pad_set_getcaps_function (myplugin->srcpad,
GST_DEBUG_FUNCPTR (gst_myplugin_obj_getcaps));
gst_element_add_pad (GST_ELEMENT (myplugin), myplugin->srcpad);
init_data(myplugin);
GST_DEBUG("Leaving init");
}
static void
gst_myplugin_finalize (GstMYPLUGIN * myplugin)
{
G_OBJECT_CLASS (parent_class)->finalize ((GObject *) myplugin);
}
static GstFlowReturn
gst_myplugin_chain_video (GstPad * pad, GstBuffer * buf)
{
//I don’t do anything here
gst_buffer_unref (buf);
return GST_FLOW_OK;
}
static GstFlowReturn
gst_myplugin_chain_data (GstPad * pad, GstBuffer * buf)
{
GstMYPLUGIN *myplugin;
DataData data_data;
int dataLength = GST_BUFFER_SIZE(buf);
myplugin = GST_MYPLUGIN (GST_PAD_PARENT (pad));
// I just store incoming data
gst_buffer_unref (buf);
return GST_FLOW_OK;
}
static GstFlowReturn
gst_myplugin_chain_obj (GstPad * pad, GstBuffer * buf)
{
GstMYPLUGIN *myplugin;
GstBuffer *out = NULL;
//I do most processing here
return gst_pad_push (myplugin->srcpad, buf);
}
static void
gst_myplugin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstMYPLUGIN *myplugin;
myplugin = GST_MYPLUGIN (object);
switch (prop_id) {
case PROP_INPUT:
myplugin->input = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
gst_object_unref (myplugin);
}
static void
gst_myplugin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstMYPLUGIN *myplugin;
myplugin = GST_MYPLUGIN (object);
switch (prop_id) {
case PROP_INPUT:
g_value_set_int (value, myplugin->input);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
myplugin_init (GstPlugin * myplugin)
{
GST_DEBUG_CATEGORY_INIT (gst_myplugin_debug, "myplugin",
0, "OBJ Stuff");
return gst_element_register (myplugin, "myplugin", GST_RANK_NONE,
GST_TYPE_MYPLUGIN);
}
#ifndef PACKAGE
#define PACKAGE "myplugin"
#endif
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"myplugin",
"Myplugin element",
myplugin_init,
VERSION,
"Proprietary",
GST_PACKAGE_NAME,
"http://myurl.com/"
)
-----
All your bases are belong to us.
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Getting-a-instance-type-error-tp4657469p4657498.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
More information about the gstreamer-devel
mailing list