Getting a instance type error

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting a instance type error

iron_guitarist1987
This post was updated on .
Hello all,

I have some custom plugins that I have been working on. I haven't updated anything on Gstreamer, and I'm using version 0.10. For some reason I started getting these messages when I run gst-inspect:

(gst-plugin-scanner:10801): GLib-GObject-WARNING **: specified instance size for type `GstMyPlugin' is smaller than the parent type's `GstElement' instance size

(gst-plugin-scanner:10801): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(gst-plugin-scanner:10801): GStreamer-CRITICAL **: gst_element_register: assertion `g_type_is_a (type, GST_TYPE_ELEMENT)' failed

(gst-plugin-scanner:10801): GLib-GObject-WARNING **: cannot register existing type `GstTestElement'

(gst-plugin-scanner:10801): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(gst-plugin-scanner:10801): GStreamer-CRITICAL **: gst_element_register: assertion `g_type_is_a (type, GST_TYPE_ELEMENT)' failed


any ideas?? Thank you.
All your bases are belong to us.
Reply | Threaded
Open this post in threaded view
|

Re: Getting a instance type error

Krzysztof Konopko
Probably something is wrong with your "GStreamer plugin boilerplate"
code, e. g. the whole GObject/GstElement inheritance and all fun around
it. Or simply your GstMyPlugin doesn't inherit from GstElement.

Probably someone will help you if you provide more details, e. g. code
snippets.

Kris

On 14/12/12 20:31, iron_guitarist1987 wrote:

> Hello all,
>
> I have some custom plugins that I have been working on. For some reason I
> started getting these messages when I run gst-inspect:
>
> (gst-plugin-scanner:10801): GLib-GObject-WARNING **: specified instance size
> for type `GstMyPlugin' is smaller than the parent type's `GstElement'
> instance size
>
> (gst-plugin-scanner:10801): GLib-CRITICAL **: g_once_init_leave: assertion
> `initialization_value != 0' failed
>
> (gst-plugin-scanner:10801): GStreamer-CRITICAL **: gst_element_register:
> assertion `g_type_is_a (type, GST_TYPE_ELEMENT)' failed
>
> (gst-plugin-scanner:10801): GLib-GObject-WARNING **: cannot register
> existing type `GstTestElement'
>
> (gst-plugin-scanner:10801): GLib-CRITICAL **: g_once_init_leave: assertion
> `initialization_value != 0' failed
>
> (gst-plugin-scanner:10801): GStreamer-CRITICAL **: gst_element_register:
> assertion `g_type_is_a (type, GST_TYPE_ELEMENT)' failed
>
>
> any ideas?? Thank you.
>
>
>
> -----
> All your bases are belong to us.
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Getting-a-instance-type-error-tp4657469.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Getting a instance type error

Tim-Philipp Müller-2
In reply to this post by iron_guitarist1987
On Fri, 2012-12-14 at 12:31 -0800, iron_guitarist1987 wrote:

Hi,

> I have some custom plugins that I have been working on. For some reason I
> started getting these messages when I run gst-inspect:
>
> (gst-plugin-scanner:10801): GLib-GObject-WARNING **: specified instance size
> for type `GstMyPlugin' is smaller than the parent type's `GstElement'
> instance size
>
> (gst-plugin-scanner:10801): GLib-CRITICAL **: g_once_init_leave: assertion
> `initialization_value != 0' failed
>
> (gst-plugin-scanner:10801): GStreamer-CRITICAL **: gst_element_register:
> assertion `g_type_is_a (type, GST_TYPE_ELEMENT)' failed
>
> (gst-plugin-scanner:10801): GLib-GObject-WARNING **: cannot register
> existing type `GstTestElement'
>
> (gst-plugin-scanner:10801): GLib-CRITICAL **: g_once_init_leave: assertion
> `initialization_value != 0' failed
>
> (gst-plugin-scanner:10801): GStreamer-CRITICAL **: gst_element_register:
> assertion `g_type_is_a (type, GST_TYPE_ELEMENT)' failed

> any ideas?? Thank you.

Please post your GstMyPlugin structure and your
GST_BOILERPLATE/G_DEFINE_TYPE code.

Cheers
 -Tim

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Getting a instance type error

iron_guitarist1987
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.
Reply | Threaded
Open this post in threaded view
|

Re: Getting a instance type error

Tim-Philipp Müller-2
On Mon, 2012-12-17 at 11:08 -0800, iron_guitarist1987 wrote:

Hi,

> My header is :
> typedef struct _GstMYPLUGIN GstMYPLUGIN;
> typedef struct _GstMYPLUGINClass GstMYPLUGINClass;
>
> struct _GstMyPlugin {
>   GstElement    element;
> ...
>   myStruct data;
>   myStruct  next_data;
> ...
> };
> struct _GstMYPLUGINClass {
>   GstElementClass parent_class;
> };
>
> My plugin:
>
> GST_BOILERPLATE (GstMYPLUGIN, gst_myplugin, GstElement, GST_TYPE_ELEMENT);
>
This looks all fine to me. How large are the myStruct structures?
GObject instances are limited to 64kB, so if those contain huge arrays,
that won't work.

You could add a

  g_print ("sizeof(GstMYPLUGIN) = %d\n", (int) sizeof (GstMYPLUGIN));

at the very beginning of myplugin_init.

Cheers
 -Tim

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Getting a instance type error

iron_guitarist1987
Yeah. My structures are huge. I'll delete them and see if that fixes it. Thanks.
All your bases are belong to us.
Reply | Threaded
Open this post in threaded view
|

GstBuffer to numpy conversion

Peter Rennert
In reply to this post by Tim-Philipp Müller-2
I am using gstreamer 0.10 with python bindings.

I want to convert a gst buffer into a numpy array. Online I found only
examples [1] for audio and they are using

import pygst
pygst.require('0.10')
import gst
import gobject
import numpy as np

def getBuffer(buf):
     array = np.fromBuffer(buf.data, dtype=float32)
     return array

Which is clearly not correct for video frames. Normally I would expect a
datatype like uchar. In my C++ code I used guint8 which I got from some
reference online.

However, if I try in python dtype=np.uint8 or dtype="I" (for c-uint8) or
"B" (for c-uchar) [2], I get some data,  but I am not getting a proper
length of my array. I am expecting a frame of 1920x1080x3 = 6220800
pixels. My  buffers are too short. Using "B", I get only an array of
length 3110400, which is strangely half of what I would expect
(1920x1080x1.5 (!)).

Has anyone done a conversion from gst-buffers to python? Or an idea what
I could try?

Thanks

[1]
http://timeside.googlecode.com/git-history/994b745dd577b2a0474492c56349e1edefaa3aa5/tests/api/gstreamer.py
[2]
http://docs.scipy.org/doc/numpy/reference/arrays.scalars.html#arrays-scalars-built-in
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GstBuffer to numpy conversion

Michael Smith
On Mon, Dec 17, 2012 at 11:52 AM, Peter Rennert <[hidden email]> wrote:
> I am using gstreamer 0.10 with python bindings.
>
> I want to convert a gst buffer into a numpy array. Online I found only
> examples [1] for audio and they are using

You didn't describe what format of raw video you're using - it's
probably, based on the 1.5 bytes per pixel figure you quoted, some
sort of 4:2:0 YUV format.

If you're expecting/wanting RGB data, you'll need to use capfilter and
a colourspace converter to get that.

Mike
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GstBuffer to numpy conversion

Chuck Crisler-2
Or request RGB from the capture source.

On Mon, Dec 17, 2012 at 3:53 PM, Michael Smith <[hidden email]> wrote:
On Mon, Dec 17, 2012 at 11:52 AM, Peter Rennert <[hidden email]> wrote:
> I am using gstreamer 0.10 with python bindings.
>
> I want to convert a gst buffer into a numpy array. Online I found only
> examples [1] for audio and they are using

You didn't describe what format of raw video you're using - it's
probably, based on the 1.5 bytes per pixel figure you quoted, some
sort of 4:2:0 YUV format.

If you're expecting/wanting RGB data, you'll need to use capfilter and
a colourspace converter to get that.

Mike
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel