Zero-copy "decodebin ! glimagesink" equivalent to playbin on Android

Grégoire Gentil gregoire at gentil.com
Tue Feb 9 19:22:19 UTC 2016


It's working now. The solution was to add a queue element.

To summarize for the community, until bug 742924 is fixed, "decodebin ! 
queue ! glimagesink" is equivalent to "playbin" on Android 6.0.1 in 
terms of zero-copy performance, with the app code below (all hard-coded, 
only video is handled).

Thanks for the support on autoplug-query!

Grégoire





g_signal_connect(G_OBJECT(gst_bin_get_by_name(GST_BIN(pipeline), 
"decodebin0")), "autoplug-query", G_CALLBACK(autoplug_query_cb), data);


gboolean autoplug_query_cb(GstElement *bin, GstPad *pad, GstElement 
*element, GstQuery *query, CustomData *data) {
if (strstr(gst_element_get_name(element), "amcvideodec") == NULL)
return FALSE;

if (GST_QUERY_TYPE(query) == GST_QUERY_CONTEXT) {
GstPad *sinkpad = gst_element_get_static_pad(data->video_sink, "sink");
if (sinkpad) {
gboolean res = gst_pad_query(sinkpad, query);
gst_object_unref(sinkpad);
return res;
}
}

if (GST_QUERY_TYPE(query) == GST_QUERY_CAPS) {
GstCaps *filter;
gst_query_parse_caps(query, &filter);
int i = 0;
for (i = 0; i < gst_caps_get_size(filter); i++) {
GstStructure *structure = gst_caps_get_structure(filter, i);
if (strstr(gst_structure_to_string(structure), 
"texture-target=(string)external-oes") != NULL) {
gst_query_set_caps_result(query, gst_caps_new_full(structure, NULL));
return TRUE;
}
}

return FALSE;
}






On 02/08/2016 11:12 PM, Matthew Waters wrote:
> On 09/02/16 17:35, Grégoire Gentil wrote:
>>
>>
>> On 02/08/2016 04:31 PM, Matthew Waters wrote:
>>> If everything is working,  then it will be picked automatically.  The
>>> fact that it isn't, indicates a problem with your code.  Look at
>>> playbin's implementation as well as the debug logs to determine what
>>> exactly is happening (It's all there somewhere ;)).
>>
>>
>> Are you absolutely sure it's only bug 742924 and there is no problem
>> elsewhere?
>
> Never.  The problem you described was decodebin ! glimagesink not
> negotiating zerocopy which *is* the aforementioned bug.
>
>> I have implemented an horrible but working autoplug_query function:
>>
>>
>>
>> static gboolean autoplug_query_cb(GstElement *bin, GstPad *pad,
>> GstElement *element, GstQuery *query, CustomData *data) {
>>
>> if (strstr(gst_element_get_name(element), "amcvideodec") == NULL)
>> return FALSE;
>>
>> if (GST_QUERY_TYPE(query) == GST_QUERY_CONTEXT) {
>> GstPad *sinkpad = gst_element_get_static_pad(data->scd[0].video_sink,
>> "sink");
>> if (sinkpad) {
>> gboolean res = gst_pad_query(sinkpad, query);
>> gst_object_unref(sinkpad);
>> return res;
>> }
>> }
>>
>> if (GST_QUERY_TYPE(query) == GST_QUERY_CAPS) {
>> GstCaps *filter;
>> gst_query_parse_caps(query, &filter);
>> char *a = gst_caps_to_string(filter);
>> char *b = strstr(a, ";");//The first hunk is always the gl one
>> //structure from caps is confused by memory:GLMemory
>> //so we go down to string
>> if (b) *b = '\0';
>> if (strstr(a, "texture-target=(string)external-oes") != NULL) {
>> GstCaps *cc = gst_caps_from_string(a);
>> GST_DEBUG("WE FOUND IT %s\n", gst_caps_to_string(cc));
>> gst_query_set_caps_result(query, cc);
>> return TRUE;
>> }
>> }
>>
>> return FALSE;
>> }
>>
>>
>>
>> I'm pretty sure it's working because I get the following in the log:
>>
>>
>> aigstreamer.c:625:autoplug_query_cb WE FOUND IT
>> video/x-raw(memory:GLMemory), format=(string)RGBA,
>> texture-target=(string)external-oes
>>
>> 02-08 21:57:54.140 20973 21058 I GStreamer+GST_CONTEXT:
>> 0:00:08.614410400 0x9c73fe30
>> gstglutils.c:573:_gst_context_query:<amcvideodec-omxqcomvideodecoderavc0>
>> found context (0x96c68120) in downstream query
>>
>> 02-08 21:57:54.142 20973 21058 I GStreamer+amcvideodec:
>> 0:00:08.616394043 0x9c73fe30
>> gstamcvideodec.c:1953:gst_amc_video_dec_set_format:<amcvideodec-omxqcomvideodecoderavc0>
>> GL output: enabled
>>
>>
>> so hardware goes directly to GL and context is properly passed.
>>
>>
>> But decodebin ! glimagesink is still at 30fps while playbin is at
>> 50fps. I *really* suspect that there is another problem somewhere else,
>
> There may be.  If you believe there is a problem, you have to find it
> with your deductive skills ;)
>
> Cheers
> -Matt
>
>> Grégoire
>>
>
>


More information about the gstreamer-android mailing list