From a0302d6faab6586f7fc1c95a0053c863cd9184cc Mon Sep 17 00:00:00 2001 From: "Joshua M. Doe" Date: Mon, 11 Jul 2016 11:28:49 -0400 Subject: [PATCH] niimaqdxsrc: allow attributes to be set at any time, not just startup --- sys/niimaqdx/gstniimaqdx.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/sys/niimaqdx/gstniimaqdx.c b/sys/niimaqdx/gstniimaqdx.c index 4c2c437..daef493 100644 --- a/sys/niimaqdx/gstniimaqdx.c +++ b/sys/niimaqdx/gstniimaqdx.c @@ -90,6 +90,7 @@ static GstFlowReturn gst_niimaqdxsrc_fill (GstPushSrc * src, GstBuffer * buf); static GstCaps *gst_niimaqdxsrc_get_cam_caps (GstNiImaqDxSrc * src); static gboolean gst_niimaqdxsrc_close_interface (GstNiImaqDxSrc * niimaqdxsrc); static void gst_niimaqdxsrc_reset (GstNiImaqDxSrc * niimaqdxsrc); +static void gst_niimaqdxsrc_set_dx_attributes (GstNiImaqDxSrc * niimaqdxsrc); IMAQdxError gst_niimaqdxsrc_report_imaq_error (IMAQdxError code) @@ -420,11 +421,10 @@ gst_niimaqdxsrc_class_init (GstNiImaqDxSrcClass * klass) G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ATTRIBUTES, g_param_spec_string ("attributes", - "Attributes", "Initial attributes to set", DEFAULT_PROP_ATTRIBUTES, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), - PROP_BAYER_AS_GRAY, g_param_spec_boolean ("bayer-as-gray", - "Bayer as gray", + "Attributes", "Attributes to change, comma separated key=value pairs", + DEFAULT_PROP_ATTRIBUTES, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BAYER_AS_GRAY, + g_param_spec_boolean ("bayer-as-gray", "Bayer as gray", "For Bayer sources use GRAY caps", DEFAULT_PROP_BAYER_AS_GRAY, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)); @@ -665,6 +665,9 @@ gst_niimaqdxsrc_fill (GstPushSrc * src, GstBuffer * buf) } } + /* will change attributes if provided */ + gst_niimaqdxsrc_set_dx_attributes (niimaqdxsrc); + if (niimaqdxsrc->caps_info == NULL) { GST_ELEMENT_ERROR (niimaqdxsrc, RESOURCE, FAILED, ("Failed to create caps, possibly unsupported format (%s).", @@ -907,13 +910,20 @@ error: return NULL; } -void +static void gst_niimaqdxsrc_set_dx_attributes (GstNiImaqDxSrc * niimaqdxsrc) { gchar **pairs; int i; IMAQdxError rval; + if (!niimaqdxsrc->attributes) { + return; + } + + GST_DEBUG_OBJECT (niimaqdxsrc, "Trying to set following attributes: %s", + niimaqdxsrc->attributes); + pairs = g_strsplit (niimaqdxsrc->attributes, ";", 0); for (i = 0;; i++) { @@ -938,6 +948,11 @@ gst_niimaqdxsrc_set_dx_attributes (GstNiImaqDxSrc * niimaqdxsrc) g_strfreev (pair); } g_strfreev (pairs); + + if (niimaqdxsrc->attributes) { + g_free (niimaqdxsrc->attributes); + niimaqdxsrc->attributes = NULL; + } } /**