[Spice-devel] [PATCH spice-gtk 2/2] Let user rank gstreamer element
Jonathon Jongsma
jjongsma at redhat.com
Tue Jan 2 20:22:20 UTC 2018
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.
> + 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