From 8748ce94f4360dd5b2bc7fa1febdd41698fe1955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 1 Aug 2016 10:28:26 +0300 Subject: [PATCH] amc: If we find multiple codecs with the same name, just merge them On the ODroid C1+ the H265 and H264 have the same name but are listed as two different codecs. We have to handle them as the same one that supports both, as otherwise we will register the same GType name twice which fails and we then only have H265 support and not H264 support. --- sys/androidmedia/gstamc.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/sys/androidmedia/gstamc.c b/sys/androidmedia/gstamc.c index 9f26141a2c..dac51ed17e 100644 --- a/sys/androidmedia/gstamc.c +++ b/sys/androidmedia/gstamc.c @@ -1852,9 +1852,41 @@ scan_codecs (GstPlugin * plugin) /* We need at least a valid supported type */ if (valid_codec) { - GST_LOG ("Successfully scanned codec '%s'", name_str); - g_queue_push_tail (&codec_infos, gst_codec_info); - gst_codec_info = NULL; + GList *l; + + for (l = codec_infos.head; l; l = l->next) { + GstAmcCodecInfo *tmp = l->data; + + if (strcmp (tmp->name, gst_codec_info->name) == 0 + && ! !tmp->is_encoder == ! !gst_codec_info->is_encoder) { + gint m = tmp->n_supported_types, n; + + GST_LOG ("Successfully scanned codec '%s', appending to existing", + name_str); + + tmp->gl_output_only |= gst_codec_info->gl_output_only; + tmp->n_supported_types += gst_codec_info->n_supported_types; + tmp->supported_types = + g_realloc (tmp->supported_types, tmp->n_supported_types); + + for (n = 0; n < gst_codec_info->n_supported_types; n++, m++) { + tmp->supported_types[m] = gst_codec_info->supported_types[n]; + } + g_free (gst_codec_info->supported_types); + g_free (gst_codec_info->name); + g_free (gst_codec_info); + gst_codec_info = NULL; + + break; + } + } + + /* Found no existing codec with this name */ + if (l == NULL) { + GST_LOG ("Successfully scanned codec '%s'", name_str); + g_queue_push_tail (&codec_infos, gst_codec_info); + gst_codec_info = NULL; + } } /* Clean up of all local references we got */