Processing inside buffer_probe makes slow in display update

I have extra processing inside buffer_probing in example Deepstream_test3_app.c.
I like to do some processing inside this probing function using bounding boxes.

To test the processing, I have
gSOAP test function gSoapInterface(3, 4);
inside probing.

static GstPadProbeReturn
tiler_src_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
{ } 

before
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next) {}

I have two printings. One is before for loop and another one is inside the for loop for frame infos.
Both are printing ok in acceptable speed for testing with 6 video sources.

result = 7
Soruce id = 5 Frame Number = 32 Number of objects = 2  Person Count = 2
Soruce id = 0 Frame Number = 32 Number of objects = 2  Person Count = 0
Soruce id = 1 Frame Number = 32 Number of objects = 2  Person Count = 0
Soruce id = 2 Frame Number = 32 Number of objects = 3  Person Count = 1
Soruce id = 3 Frame Number = 32 Number of objects = 5  Person Count = 2
Soruce id = 4 Frame Number = 31 Number of objects = 7  Person Count = 2
result = 7
Soruce id = 5 Frame Number = 33 Number of objects = 2  Person Count = 2
Soruce id = 0 Frame Number = 33 Number of objects = 2  Person Count = 0
Soruce id = 1 Frame Number = 33 Number of objects = 2  Person Count = 0
Soruce id = 2 Frame Number = 33 Number of objects = 2  Person Count = 0
Soruce id = 3 Frame Number = 33 Number of objects = 4  Person Count = 2
Soruce id = 4 Frame Number = 32 Number of objects = 6  Person Count = 2
result = 7
Soruce id = 5 Frame Number = 34 Number of objects = 2  Person Count = 2
Soruce id = 0 Frame Number = 34 Number of objects = 2  Person Count = 0
Soruce id = 1 Frame Number = 34 Number of objects = 2  Person Count = 0
Soruce id = 2 Frame Number = 34 Number of objects = 2  Person Count = 0
Soruce id = 3 Frame Number = 34 Number of objects = 4  Person Count = 2
Soruce id = 4 Frame Number = 33 Number of objects = 6  Person Count = 2

But it makes frame display speed slow down a lot.
What could be the issue?

#include <gst/gst.h>
#include <glib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <sys/time.h>
#include "gstnvdsmeta.h"
#include "soapH.h"
#include "calc.nsmap"
//#include "gstnvstreammeta.h"
#ifndef PLATFORM_TEGRA
#include "gst-nvmessage.h"
#endif

/*gSOAP interface*/
const char server[] = "http://websrv.cs.fsu.edu/~engelen/calcserver.cgi";
static void gSoapInterface(double a_, int b_){
    struct soap soap;
    double a, b, result;
    soap_init1(&soap, SOAP_XML_INDENT);
    soap_call_ns__add(&soap, server, "", a_, b_, &result);

    if (soap.error)
       soap_print_fault(&soap, stderr);
    else
       printf("result = %g\n", result);
    soap_destroy(&soap);
    soap_end(&soap);
    soap_done(&soap);
}

static GstPadProbeReturn
tiler_src_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info, gpointer u_data)
{
    GstBuffer *buf = (GstBuffer *) info->data;
    guint num_rects = 0; 
    NvDsObjectMeta *obj_meta = NULL;
    //guint vehicle_count = 0;
    //guint person_count = 0;
    NvDsMetaList * l_frame = NULL;
    NvDsMetaList * l_obj = NULL;
    //NvDsDisplayMeta *display_meta = NULL;

    NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);
   ////////////////////////////////////////////////////////////
    gSoapInterface(3, 4);
   ////////////////////////////////////////////////////////////
    for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {
        NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
        //int offset = 0;
        guint person_count = 0;
        for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
                l_obj = l_obj->next) {
            obj_meta = (NvDsObjectMeta *) (l_obj->data);
            //if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
            //    vehicle_count++;
            //    num_rects++;
            //}
            if (obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
                person_count++;
                num_rects++;
                //////////////////////////////////////////////////////////////////
                g_print ("Soruce_id left top width height :%d %f %f %f %f\n",frame_meta->source_id, obj_meta->rect_params.left,obj_meta->rect_params.top,obj_meta->rect_params.width,obj_meta->rect_params.height);
                ////////////////////////////////////////////////////////// 
            }
        }
    }
    return GST_PAD_PROBE_OK;
}

pad buffer probe is a callback which will hold the buffers before it finishes. So when implement the processing inside probe functions, please avoid any time consuming function.

Will it be improved if it is implemented inside gstplugin like gstdsample.cpp?

If the processing speed is much lower than the original frame rate, it will slow down the pipeline no matter where it is.

@Fiona.Chen. Thanks so wherever I put I’ll face this issue. Original frame rate means source’s fps?

You can implement it outside the pipeline. Work in asynchronized way.

@Fiona.Chen that is good idea, any sample I can see?

No sample. It is not specific for Deepstream.

@Fiona.Chen you meaned like pthread?

Any way you like. Just make sure the pipeline is not blocked.

Thanks let me try. Thank you