[Spice-devel] [PATCH v3 spice-streaming-agent] gst-plugin: receive encoder properties as command parameters

Frediano Ziglio fziglio at redhat.com
Mon Jul 22 07:53:39 UTC 2019


> 
> This allows to set plugin key=value properties on run time.
> To add encoder plugin property use the following syntax:
> -c gst.prop="property=value" -c gst.prop="property2=value2"...
> Make sure syntax is accurate and that the property is supported by
> the chosen plugin, wrong properties may ignored silently.
> 
> Signed-off-by: Snir Sheriber <ssheribe at redhat.com>

Acked. Line limit should be 100 characters.

> ---
> Changes from v2:
> -Mainly c++ style and other minor changes
> 
> ---
>  src/gst-plugin.cpp | 25 ++++++++++++++++++++-----
>  1 file changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/src/gst-plugin.cpp b/src/gst-plugin.cpp
> index 4e802f1..a60afb5 100644
> --- a/src/gst-plugin.cpp
> +++ b/src/gst-plugin.cpp
> @@ -35,6 +35,7 @@ struct GstreamerEncoderSettings
>      int fps = 25;
>      SpiceVideoCodecType codec = SPICE_VIDEO_CODEC_TYPE_H264;
>      std::string encoder;
> +    std::vector<std::pair<std::string, std::string>> prop_pairs;
>  };
>  
>  template <typename T>
> @@ -179,11 +180,18 @@ GstElement
> *GstreamerFrameCapture::get_encoder_plugin(const GstreamerEncoderSett
>      }
>  
>      encoder = factory ? gst_element_factory_create(factory, "encoder") :
>      nullptr;
> -    if (encoder) { // Invalid properties will be ignored silently
> -        /* x264enc properties */
> -        gst_util_set_object_arg(G_OBJECT(encoder), "tune", "zerolatency");//
> stillimage, fastdecode, zerolatency
> -        gst_util_set_object_arg(G_OBJECT(encoder), "bframes", "0");
> -        gst_util_set_object_arg(G_OBJECT(encoder), "speed-preset", "1");//
> 1-ultrafast, 6-med, 9-veryslow
> +    if (encoder) { // Set encoder properties
> +        for (const auto &prop : settings.prop_pairs) {
> +            const auto &name = prop.first;
> +            const auto &value = prop.second;
> +            if (!g_object_class_find_property(G_OBJECT_GET_CLASS(encoder),
> name.c_str())) {
> +                gst_syslog(LOG_WARNING, "'%s' property was not found for
> this encoder", name.c_str());
> +                continue;
> +            }
> +            gst_syslog(LOG_NOTICE, "Trying to set encoder property: '%s =
> %s'", name.c_str(), value.c_str());
> +            /* Invalid properties will be ignored silently */
> +            gst_util_set_object_arg(G_OBJECT(encoder), name.c_str(),
> value.c_str());
> +        }
>      }
>      gst_plugin_feature_list_free(filtered);
>      gst_plugin_feature_list_free(encoders);
> @@ -449,6 +457,13 @@ void GstreamerPlugin::ParseOptions(const ConfigureOption
> *options)
>              }
>          } else if (name == "gst.encoder") {
>              settings.encoder = value;
> +        } else if (name == "gst.prop") {
> +            size_t pos = value.find('=');
> +            if (pos == 0 || pos >= value.size() - 1) {
> +                gst_syslog(LOG_WARNING, "Property input is invalid ('%s'
> Ignored)", value.c_str());
> +                continue;
> +            }
> +            settings.prop_pairs.push_back(make_pair(value.substr(0, pos),
> value.substr(pos + 1)));
>          }
>      }
>  }

Frediano


More information about the Spice-devel mailing list