Using appsink with GLib asynchronous API

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

Using appsink with GLib asynchronous API

hyperlight
In my application, I have the following pipeline (simplified to exclude
filter-like elements):

                                    queue -> appsink (start asynchronous
tasks)
                                  /
v4l2src -> [...] -> tee1
                                  \                         queue -> [...]
-> videosink
                                   \                      /  
                                    queue -> tee2      
                                                          \
                                                            queue -> [...]
->  filesink

Use case: when a buffer arrive at appsink with metadata attached by some
upstream element, the appsink read the metadata and if a condition is met,
turn A on, after X amount of time, turn A off. I tried to simulate this with
the sleep() function but doing that lead to many loss frame from the source
and affect the result of other sinks in the pipeline:

v4l2src gstv4l2src.c:976:gst_v4l2src_create:<camera-source> lost frames
detected: count = 28 - ts: 0:00:12.084989155

I think the reason why the issue happens is because the appsink couldn’t
keep up the the source element due to the delay introduced (i.e., wait for X
amount of time before turn A off), which is why we see v4l2src reports lost
frames and prevent those lost frames to be received by other sinks
(videosink and filesink). Is that correct?

TO achieve this task from appsink: "using arrived buffer metadata, if a
condition is met, turn A on, after X amount of time turn A off", I think I
will need to use some sort of asynchronous programming. I look into  GLib
Asynchronous Programming
<https://developer.gnome.org/programming-guidelines/stable/async-programming.html.en>  
and it seems like what I need since gstreamer is built on top of GLib but
I'm not sure how to do so in gstreamer without blocking the flow of the
pipeline.







--
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: Using appsink with GLib asynchronous API

hyperlight
Sorry the code I used was:

[...]
/* The appsink has received a buffer */
static GstFlowReturn new_sample(GstElement *sink, gpointer *data)
{
   GstSample *sample;

   /* Retrieve the buffer */
   sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));

   if (gst_app_sink_is_eos(GST_APP_SINK(sink)))
   {
       g_print("EOS received in Appsink********\n");
   }

   if (sample)
   {
       /* print a * to indicate a received buffer */
       g_print("*");
       sleep(1);
       gst_sample_unref(sample);
       return GST_FLOW_OK;
   }

   return GST_FLOW_ERROR;
}
[...]

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

[...]

g_signal_connect(appsink, "new-sample", G_CALLBACK(new_sample), NULL);

[...]

}



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