1

I am writing a simple application using gstreamer-1.0 and I want to receive the buffers that have flowed through the pipeline back into my application. To do so, I use the appsink plugin at the end of the pipeline.

Until now, everything is working, but when I want to recieve the buffers, I get these errors

(app:31759): GLib-GObject-CRITICAL **: g_signal_emit_by_name: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

and

(app:31759): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer

Here is the code I have wrote

typedef struct _AllElements 
{
    GstElement *pipeline;
    ...
    GstElement *appsink;

} AllElements;

static void new_sample (AllElements *element) 
{
     GstSample *sample = NULL;
     /* Retrieve the buffer */
     g_signal_emit_by_name (element->appsink, "pull-sample", &sample,NULL);
     if (sample) 
     {
          g_print ("*");
          gst_sample_unref (sample);
     }
}

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

         ...  // making and linking all the elements

    g_object_set (G_OBJECT (element.appsink), "sync", TRUE, NULL); 
    g_object_set (element.appsink, "emit-signals", TRUE, NULL);
    g_signal_connect (element.appsink, "new-sample", G_CALLBACK (new_sample), &element);

          ...   

    gst_element_set_state (element.pipeline, GST_STATE_PLAYING);

          ...

    return 0;
}

Does anyone can help me fix this ? Thanks to everyone !

MatheuGrondin
  • 107
  • 1
  • 8

1 Answers1

2

I found the solution for my problem.

I simply had the wrong signature for my function

static GstFlowReturn new_sample (GstElement *appsink, AllElements *element) 

and I now use gst_base_sink_get_last_sample(GST_BASE_SINK(appsink)); to get the sample.

MatheuGrondin
  • 107
  • 1
  • 8