[Filter/Main] Add "Custom" Property
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 14 Jun 2018 09:21:13 +0000 (18:21 +0900)
committer함명주/동작제어Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Fri, 15 Jun 2018 02:09:30 +0000 (11:09 +0900)
Added "Custom" property so that each sub-plugins may get properties
from users (gst apps) directly.

Partially addresses #71

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
tensor_filter/tensor_filter.c
tensor_filter/tensor_filter.h

index a755334..71d6f45 100644 (file)
@@ -210,6 +210,9 @@ gst_tensor_filter_class_init (GstTensor_FilterClass * g_class)
   g_object_class_install_property (gobject_class, PROP_DEBUG,
       g_param_spec_boolean ("debug", "Debug", "Produce a lot of log messages ?",
           FALSE, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, PROP_CUSTOM,
+      g_param_spec_string ("custom", "Custom properties for subplugins",
+          "Custom properties for subplugins ?", "", G_PARAM_READWRITE));
 
   gst_element_class_set_details_simple (gstelement_class,
       "Tensor_Filter",
@@ -270,6 +273,7 @@ gst_tensor_filter_init (GstTensor_Filter * filter)
   filter->outputType = _NNS_END;        /* not initialized */
   filter->outputCapNegotiated = FALSE;
 
+  filter->customProperties = NULL;
   filter->privateData = NULL;   /* mark not initialized. */
 }
 
@@ -481,6 +485,13 @@ gst_tensor_filter_set_property (GObject * object, guint prop_id,
       if (filter->outputConfigured == TRUE && filter->debug == TRUE)
         gst_tensor_filter_fix_caps (filter, FALSE, NULL, TRUE);
       break;
+    case PROP_CUSTOM:
+      g_assert (filter->customProperties == NULL && value);
+      /* Once configures, it cannot be changed in runtime */
+      filter->customProperties = g_value_dup_string (value);
+      if (filter->debug == TRUE)
+        g_printerr ("Custom Option = %s\n", filter->customProperties);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -536,6 +547,9 @@ gst_tensor_filter_get_property (GObject * object, guint prop_id,
     case PROP_OUTPUTTYPE:
       g_value_set_string (value, tensor_element_typename[filter->outputType]);
       break;
+    case PROP_CUSTOM:
+      g_value_set_string (value, filter->customProperties);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
index 812c3d7..6492646 100644 (file)
@@ -137,6 +137,8 @@ struct _GstTensor_Filter
   tensor_type outputType; /**< The type for each element in the output tensor */
   gboolean outputCapNegotiated;
 
+  const gchar *customProperties; /**< sub-plugin specific custom property values in string */
+
   void *privateData; /**< NNFW plugin's private data is stored here */
 };