[Spice-devel] [PATCH spice-gtk 2/2] Let user rank gstreamer element

Snir Sheriber ssheribe at redhat.com
Wed Jan 3 09:00:12 UTC 2018


Hi,


On 01/02/2018 10:22 PM, Jonathon Jongsma wrote:
> On Sun, 2017-12-31 at 17:46 +0200, Snir Sheriber wrote:
>> User can now rank a gstreamer element with high rank
>> by setting SPICE_GST_RANK_HIGH to the element's name.
>> This can be used to prioritize specific decoder to
>> be chosen by playbin.
>> ---
>>   src/channel-display-gst.c | 23 +++++++++++++++++++++++
>>   1 file changed, 23 insertions(+)
>>
>> diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
>> index af87fb5..fe3918d 100644
>> --- a/src/channel-display-gst.c
>> +++ b/src/channel-display-gst.c
>> @@ -340,6 +340,27 @@ static void app_source_setup(GstElement
>> *pipeline G_GNUC_UNUSED,
>>       gst_caps_unref(caps);
>>       decoder->appsrc = GST_APP_SRC(gst_object_ref(source));
>>   }
>> +
>> +static void gst_factory_rank_high(void) {
> Not a huge deal, but in general I'd avoid a gst_ prefix in application
> code. Perhaps spice_gst_factory_rank_high() instead?
>
>> +    GstRegistry *registry = NULL;
>> +    GstElementFactory *factory = NULL;
>> +    const gchar *name = NULL;
>> +
>> +
>> +    registry = gst_registry_get ();
>> +    if (!registry) return;
>> +
>> +    name = g_getenv("SPICE_GST_RANK_HIGH");
> Is there ever a case where you'd want to specify rank for more than a
> single element? Would it make sense to treat this as a comma-separated
> list? Maybe overkill.

True, actually in second though I'm not sure this patch is even
needed, if another plugin is available and has higher\same rank
i want to believe it should also works better\similarly.
It was useful for me in order to choose specific plugin while i had
another one that does the same thing installed, not sure it's a
common use case.

Snir.
>> +    if (!name) return;
>> +
>> +    factory = gst_element_factory_find (name);
>> +    if (!factory) return;
>> +
>> +    gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory),
>> GST_RANK_PRIMARY + 1);
>> +
>> +    gst_registry_add_feature (registry, GST_PLUGIN_FEATURE
>> (factory));
>> +    return;
>> +}
>>   #endif
>>   
>>   static gboolean create_pipeline(SpiceGstDecoder *decoder)
>> @@ -358,6 +379,8 @@ static gboolean create_pipeline(SpiceGstDecoder
>> *decoder)
>>           return FALSE;
>>       }
>>   
>> +    gst_factory_rank_high();
>> +
>>       convert = gst_element_factory_make("autovideoconvert",
>> "autovideoconvert");
>>       download = gst_element_factory_make("gldownload", "gldownload");
>>       appsink = gst_element_factory_make("appsink", "appsink");
>
> Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com>
>



More information about the Spice-devel mailing list