g_object_set assertion, G_IS_OBJECT (object) failed

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

g_object_set assertion, G_IS_OBJECT (object) failed

gonengoktug
Hi guys, as I posted before, I still want to capture frames from stream and
to do that I write some code but it gives me error that I can't figure it
out. Can anyone help me or make me understand this error.

Here is my test code
static void on_new_buffer_from_source (GstElement * elt, ProgramData * data)
{
  GstSample *sample;
  guint size;
  gpointer raw_buffer;
  GstBuffer *app_buffer, *buffer;
  GstElement *source;
  GstMapInfo map;
  GstStructure *s;
  const int width=g_value_get_int(gst_structure_get_value(s, "width"));
  const int height=g_value_get_int(gst_structure_get_value(s, "height"));

  sample=gst_app_sink_pull_sample(GST_APP_SINK(elt));
  buffer=gst_sample_get_buffer(sample);
  if(gst_buffer_map(buffer,&map,GST_MAP_READ))
      g_printerr("frame is catched");
  else
      g_printerr("frame is missed");
   cv::Mat
frame(cv::Size(width,height),CV_8UC3,(char*)map.data,cv::Mat::AUTO_STEP);
   cv::namedWindow("frames",CV_WINDOW_AUTOSIZE);
   cv::imshow("frame",frame);


}

int main(int argc, char*argv[]) {

    gchar *filename = NULL;
    ProgramData *data;
    gchar *string = NULL;
    GstBus *bus = NULL;
    GstElement *testsink = NULL;
    GstElement *testsource = NULL;

    gst_init(&argc,&argv);


    data = g_new0 (ProgramData, 1);

    data->loop = g_main_loop_new (NULL, FALSE);

    data->source=gst_parse_launch("v4l2src ! autovideosink",NULL);

    bus = gst_element_get_bus (data->source);
    gst_bus_add_watch (bus, (GstBusFunc) on_source_message, data);

    testsink = gst_bin_get_by_name (GST_BIN (data->source), "testsink");
    g_object_set(G_OBJECT(testsink), "emit-signals", TRUE, "sync", FALSE,
NULL);
    g_signal_connect (testsink, "new-buffer", G_CALLBACK
(on_new_buffer_from_source), data);
    gst_object_unref (testsink);
}
I tried to debug but whenever g_object_set command runs, gives me assertion
error. Also you can give me any advice about my code. Thanks





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

Re: g_object_set assertion, G_IS_OBJECT (object) failed

Michael Gruner
The assertion failure means that gst_bin_get_by_name failed to return an element. In your case it did because there is no element named “testsink” in the pipeline.

Change the pipeline to something like:

>    data->source=gst_parse_launch("v4l2src ! appsink name=testsink",NULL);

Michael

> On Jan 27, 2020, at 07:25, gonengoktug <[hidden email]> wrote:
>
> Hi guys, as I posted before, I still want to capture frames from stream and
> to do that I write some code but it gives me error that I can't figure it
> out. Can anyone help me or make me understand this error.
>
> Here is my test code
> static void on_new_buffer_from_source (GstElement * elt, ProgramData * data)
> {
>  GstSample *sample;
>  guint size;
>  gpointer raw_buffer;
>  GstBuffer *app_buffer, *buffer;
>  GstElement *source;
>  GstMapInfo map;
>  GstStructure *s;
>  const int width=g_value_get_int(gst_structure_get_value(s, "width"));
>  const int height=g_value_get_int(gst_structure_get_value(s, "height"));
>
>  sample=gst_app_sink_pull_sample(GST_APP_SINK(elt));
>  buffer=gst_sample_get_buffer(sample);
>  if(gst_buffer_map(buffer,&map,GST_MAP_READ))
>      g_printerr("frame is catched");
>  else
>      g_printerr("frame is missed");
>   cv::Mat
> frame(cv::Size(width,height),CV_8UC3,(char*)map.data,cv::Mat::AUTO_STEP);
>   cv::namedWindow("frames",CV_WINDOW_AUTOSIZE);
>   cv::imshow("frame",frame);
>
>
> }
>
> int main(int argc, char*argv[]) {
>
>    gchar *filename = NULL;
>    ProgramData *data;
>    gchar *string = NULL;
>    GstBus *bus = NULL;
>    GstElement *testsink = NULL;
>    GstElement *testsource = NULL;
>
>    gst_init(&argc,&argv);
>
>
>    data = g_new0 (ProgramData, 1);
>
>    data->loop = g_main_loop_new (NULL, FALSE);
>
>    data->source=gst_parse_launch("v4l2src ! autovideosink",NULL);
>
>    bus = gst_element_get_bus (data->source);
>    gst_bus_add_watch (bus, (GstBusFunc) on_source_message, data);
>
>    testsink = gst_bin_get_by_name (GST_BIN (data->source), "testsink");
>    g_object_set(G_OBJECT(testsink), "emit-signals", TRUE, "sync", FALSE,
> NULL);
>    g_signal_connect (testsink, "new-buffer", G_CALLBACK
> (on_new_buffer_from_source), data);
>    gst_object_unref (testsink);
> }
> I tried to debug but whenever g_object_set command runs, gives me assertion
> error. Also you can give me any advice about my code. Thanks
>
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: g_object_set assertion, G_IS_OBJECT (object) failed

gonengoktug
Thank you for fast reply, it worked.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel