<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yiv8770200344"><div id="yui_3_16_0_ym19_1_1499061832761_95230"><div style="color:#000;background-color:#fff;font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;" id="yui_3_16_0_ym19_1_1499061832761_95229"><div id="yui_3_16_0_ym19_1_1499061832761_95240"><span id="yui_3_16_0_ym19_1_1499061832761_95406">Hi.</span></div> <div class="yiv8770200344qtdSeparateBR" id="yui_3_16_0_ym19_1_1499061832761_95228" dir="ltr"><br></div><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95821">>G_GNUC_INTERNAL</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95822"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95823">>gboolean gstvideo_has_codec(int codec_type)</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95824"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95825">>{</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95826"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95827">>- gboolean has_codec = FALSE;</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95828"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95829">>+ GList *all_decoders, *codec_decoders;</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95830"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95831">>+ GstCaps *caps;</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95832"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95833">>+ GstElementFactoryListType type;</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95834"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95835">>+</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95836"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95837">>+ g_return_val_if_fail(gstvideo_init(), FALSE);</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95838"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95839">>+ g_return_val_if_fail(VALID_VIDEO_CODEC_TYPE(codec_type), FALSE);></span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95840">><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95841"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95842">>- VideoDecoder *decoder = create_gstreamer_decoder(codec_type, NULL);</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95843"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95844">>- if (decoder) {</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95845"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95846">>- has_codec = TRUE;</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95847"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95848">>- decoder->destroy(decoder);</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95849"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95850">>+ type = GST_ELEMENT_FACTORY_TYPE_DECODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO;</span><br clear="none" style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95851"><div class="yiv8770200344qtdSeparateBR" id="yui_3_16_0_ym19_1_1499061832761_95228" dir="ltr"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95852">>+ all_decoders = gst_element_factory_list_get_elements(type, GST_RANK_NONE);</span></div><div class="yiv8770200344qtdSeparateBR" id="yui_3_16_0_ym19_1_1499061832761_95228" dir="ltr"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;"><br></span></div><div class="yiv8770200344qtdSeparateBR" id="yui_3_16_0_ym19_1_1499061832761_95228" dir="ltr"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95992">Playbin is using</span> <span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1499061832761_95717">GST_RANK_MARGINAL to filter its elements. Maybe we could follow that?</span><br clear="none" id="yui_3_16_0_ym19_1_1499061832761_95718"></div><div class="yiv8770200344qtdSeparateBR" id="yui_3_16_0_ym19_1_1499061832761_95228" dir="ltr"><span style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 16px;"><br></span></div><div class="yiv8770200344yqt4954201568" id="yiv8770200344yqt72707"></div></div></div></div><div class=".yiv8770200344yahoo_quoted" id="yui_3_16_0_ym19_1_1499061832761_95283"> <div style="font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px;" id="yui_3_16_0_ym19_1_1499061832761_95282"> <div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;" id="yui_3_16_0_ym19_1_1499061832761_95281"> <div dir="ltr" id="yui_3_16_0_ym19_1_1499061832761_95331"><font size="2" face="Arial" id="yui_3_16_0_ym19_1_1499061832761_95330"> On Wednesday, June 28, 2017 8:43 PM, Victor Toso <victortoso@redhat.com> wrote:<br clear="none"></font></div> <br clear="none"><br clear="none"> <div class="yiv8770200344y_msg_container" id="yui_3_16_0_ym19_1_1499061832761_95280"><div dir="ltr" id="yui_3_16_0_ym19_1_1499061832761_95279">From: Victor Toso <<a rel="nofollow" shape="rect" ymailto="mailto:me@victortoso.com" target="_blank" href="mailto:me@victortoso.com" id="yui_3_16_0_ym19_1_1499061832761_95377">me@victortoso.com</a>><br clear="none"><br clear="none">With this patch, we can find all the elements in the registry that are<br clear="none">video decoders which can handle the predefined GstCaps.<br clear="none"><br clear="none">Main benefits are:<br clear="none">- We don't rely on a predefined list of GstElements. We don't need to<br clear="none"> update them;<br clear="none">- debugging: It does help to know what the registry has at runtime;<br clear="none"><br clear="none">Signed-off-by: Victor Toso <<a rel="nofollow" shape="rect" ymailto="mailto:victortoso@redhat.com" target="_blank" href="mailto:victortoso@redhat.com" id="yui_3_16_0_ym19_1_1499061832761_95755">victortoso@redhat.com</a>><br clear="none">Acked-by: Frediano Ziglio <<a rel="nofollow" shape="rect" ymailto="mailto:fziglio@redhat.com" target="_blank" href="mailto:fziglio@redhat.com" id="yui_3_16_0_ym19_1_1499061832761_95452">fziglio@redhat.com</a>><br clear="none">Signed-off-by: Victor Toso <<a rel="nofollow" shape="rect" ymailto="mailto:me@victortoso.com" target="_blank" href="mailto:me@victortoso.com" id="yui_3_16_0_ym19_1_1499061832761_95376">me@victortoso.com</a>><br clear="none">---<br clear="none"> src/channel-display-gst.c | 56 ++++++++++++++++++++++++++++++++++++++++++-----<br clear="none"> 1 file changed, 50 insertions(+), 6 deletions(-)<br clear="none"><br clear="none">diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c<br clear="none">index 57f0eb7..1b40002 100644<br clear="none">--- a/src/channel-display-gst.c<br clear="none">+++ b/src/channel-display-gst.c<br clear="none">@@ -521,16 +521,60 @@ VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream)<br clear="none"> return (VideoDecoder*)decoder;<br clear="none"> }<br clear="none"> <br clear="none">+static void gstvideo_debug_available_decoders(int codec_type,<br clear="none">+ GList *all_decoders,<br clear="none">+ GList *codec_decoders)<br clear="none">+{<br clear="none">+ GList *l;<br clear="none">+ GString *msg = g_string_new(NULL);<br clear="none">+ /* Print list of available decoders to make debugging easier */<br clear="none">+ g_string_printf(msg, "From %3u video decoder elements, %2u can handle caps %12s: ",<br clear="none">+ g_list_length(all_decoders), g_list_length(codec_decoders),<br clear="none">+ gst_opts[codec_type].dec_caps);<br clear="none">+<br clear="none">+ for (l = codec_decoders; l != NULL; l = l->next) {<br clear="none">+ GstPluginFeature *pfeat = GST_PLUGIN_FEATURE(l->data);<br clear="none">+ g_string_append_printf(msg, "%s, ", gst_plugin_feature_get_name(pfeat));<br clear="none">+ }<br clear="none">+<br clear="none">+ /* Drop trailing ", " */<br clear="none">+ g_string_truncate(msg, msg->len - 2);<br clear="none">+ spice_debug("%s", msg->str);<br clear="none">+ g_string_free(msg, TRUE);<br clear="none">+}<br clear="none">+<br clear="none"> G_GNUC_INTERNAL<br clear="none"> gboolean gstvideo_has_codec(int codec_type)<br clear="none"> {<br clear="none">- gboolean has_codec = FALSE;<br clear="none">+ GList *all_decoders, *codec_decoders;<br clear="none">+ GstCaps *caps;<br clear="none">+ GstElementFactoryListType type;<br clear="none">+<br clear="none">+ g_return_val_if_fail(gstvideo_init(), FALSE);<br clear="none">+ g_return_val_if_fail(VALID_VIDEO_CODEC_TYPE(codec_type), FALSE);<br clear="none"> <br clear="none">- VideoDecoder *decoder = create_gstreamer_decoder(codec_type, NULL);<br clear="none">- if (decoder) {<br clear="none">- has_codec = TRUE;<br clear="none">- decoder->destroy(decoder);<br clear="none">+ type = GST_ELEMENT_FACTORY_TYPE_DECODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO;<br clear="none">+ all_decoders = gst_element_factory_list_get_elements(type, GST_RANK_NONE);<br clear="none">+ if (all_decoders == NULL) {<br clear="none">+ spice_warning("No video decoders from GStreamer were found");<br clear="none">+ return FALSE;<br clear="none"> }<br clear="none"> <br clear="none">- return has_codec;<br clear="none">+ caps = gst_caps_from_string(gst_opts[codec_type].dec_caps);<br clear="none">+ codec_decoders = gst_element_factory_list_filter(all_decoders, caps, GST_PAD_SINK, TRUE);<br clear="none">+ gst_caps_unref(caps);<br clear="none">+<br clear="none">+ if (codec_decoders == NULL) {<br clear="none">+ spice_debug("From %u decoders, none can handle '%s'",<br clear="none">+ g_list_length(all_decoders), gst_opts[codec_type].dec_caps);<br clear="none">+ gst_plugin_feature_list_free(all_decoders);<br clear="none">+ return FALSE;<br clear="none">+ }<br clear="none">+<br clear="none">+ if (spice_util_get_debug())<br clear="none">+ gstvideo_debug_available_decoders(codec_type, all_decoders, codec_decoders);<br clear="none">+<br clear="none">+ gst_plugin_feature_list_free(codec_decoders);<br clear="none">+ gst_plugin_feature_list_free(all_decoders);<br clear="none">+ return TRUE;<div class="yiv8770200344yqt7156606361" id="yiv8770200344yqtfd25666"><br clear="none"> }<br clear="none">-- <br clear="none">2.13.0<br clear="none"><br clear="none">_______________________________________________<br clear="none">Spice-devel mailing list<br clear="none"><a rel="nofollow" shape="rect" ymailto="mailto:Spice-devel@lists.freedesktop.org" target="_blank" href="mailto:Spice-devel@lists.freedesktop.org">Spice-devel@lists.freedesktop.org</a><br clear="none"><a rel="nofollow" shape="rect" target="_blank" href="https://lists.freedesktop.org/mailman/listinfo/spice-devel">https://lists.freedesktop.org/mailman/listinfo/spice-devel</a><br clear="none"></div></div><br clear="none"><br clear="none"></div> </div> </div> </div></div></body></html>