cancel
Showing results for 
Search instead for 
Did you mean: 
Observer
Observer
268 Views
Registered: ‎09-02-2018

Unable to get DMABUF buffer from Decoder --> APPSink

Hi, 

I checked release note of petalinux 2018.3, it wrote this bug should be fixed. (https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/56524900/2018.3+Release+Notes+for+Open+Source+Components?showComments=true&showCommentArea=true#id-2018.3ReleaseNotesforOpenSourceComponents-2018.3BugFixes)

Currently, I develop an application to test the function, but I cannot get dmabuf from appsink.

Does anyone know how to get dmabuf from appsink?

static GstFlowReturn on_new_sample_from_sink (GstElement * elt, PCIE_BUF_HANDLE *pData)
{
GstSample *sample;
GstBuffer *buffer;
GstFlowReturn ret = GST_FLOW_OK;
int width, height;
/*CAPS*/

/* get the sample from appsink */
sample = gst_app_sink_pull_sample (GST_APP_SINK (elt));
GstCaps *caps = gst_sample_get_caps(sample);

GstStructure *capsStruct = gst_caps_get_structure(caps,0);
gst_structure_get_int(capsStruct,"width",&width);
gst_structure_get_int(capsStruct,"height",&height);
// printf("width x height:%dx%d\n",width,height);
// printf("%s",gst_caps_to_string(caps));
buffer = gst_sample_get_buffer (sample);
printf("GSTMemory:%d\n",gst_is_dmabuf_memory (gst_buffer_peek_memory (buffer,0))); // it always print 0.
send_es_to_host(buffer,pData,pData->ch,false);
// gst_buffer_unref (buffer);
gst_sample_unref (sample);

return ret;
}

 

1 Reply
Highlighted
Participant
Participant
82 Views
Registered: ‎10-13-2019

Re: Unable to get DMABUF buffer from Decoder --> APPSink

to get DMABUF from VCU decoder you should add a probe to the src pad of decoder and reply to allocation query with GST_VIDEO_META_API_TYPE.

for a starting point check kmscude decoder :

https://gitlab.freedesktop.org/mesa/kmscube/blob/master/gst-decoder.c#L242 

 

static GstPadProbeReturn dec_pad_query_cb(GstPad *pad G_GNUC_UNUSED, GstPadProbeInfo *info, gpointer user_data G_GNUC_UNUSED)
{
    GstQuery *query = GST_PAD_PROBE_INFO_QUERY(info);
    switch(GST_QUERY_TYPE(query))
    {
        case GST_QUERY_ALLOCATION:
            gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
            return GST_PAD_PROBE_OK;
        break;
    }

 

 

 

0 Kudos