code clean, remove unnecessary predefinition to set pad template.
Signed-off-by: Jaeyun <jy1210.jung@samsung.com>
#endif
/**
- * @brief Template for src pad.
- */
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY);
-
-/**
* @brief Private members in GstAMCSrc
*/
struct _GstAMCSrcPrivate
gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_amc_src_create);
/** ElementClass */
- gst_element_class_add_static_pad_template (gstelement_class, &src_factory);
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_CAPS_ANY));
+
gst_element_class_set_static_metadata (gstelement_class,
"amcsrc", "Source/AMC",
"Src element to feed the decoded data from Android MediaCodec (AMC)",
#define _LOCK(obj) g_mutex_lock (&(obj)->lock)
#define _UNLOCK(obj) g_mutex_unlock (&(obj)->lock)
-/**
- * @brief Template for src pad.
- * @todo Narrow down allowed tensors/tensor.
- */
-#if (GST_VERSION_MAJOR == 1) && (GST_VERSION_MINOR >= 8) /* >= 1.8 */
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT "; "
- "other/tensors, num_tensors = 1, "
- "framerate = " GST_TENSOR_RATE_RANGE));
-#endif
-
/** GObject method implementation */
static void gst_tensor_src_tizensensor_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseSrcClass *gstbasesrc_class = (GstBaseSrcClass *) klass;
+ GstPadTemplate *pad_template;
+ GstCaps *pad_caps;
gobject_class->set_property = gst_tensor_src_tizensensor_set_property;
gobject_class->get_property = gst_tensor_src_tizensensor_get_property;
DEFAULT_PROP_FREQ_N, DEFAULT_PROP_FREQ_D,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-#if (GST_VERSION_MAJOR == 1) && (GST_VERSION_MINOR >= 8) /* >= 1.8 */
- gst_element_class_add_static_pad_template (gstelement_class, &src_factory);
-#elif (GST_VERSION_MAJOR == 1) /* 1.0 ~ 1.8 */
- {
- GstPadTemplate *pad_template;
- GstCaps *pad_caps;
- pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT
- "; other/tensors, num_tensors = 1, framerate = " GST_TENSOR_RATE_RANGE);
- pad_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- pad_caps);
- gst_element_class_add_pad_template (gstelement_class, pad_template);
- gst_caps_unref (pad_caps);
- }
-#else
-#error We support GStreamer 1.x only.
-#endif
+ /* pad template */
+ /** @todo Narrow down allowed tensors/tensor. */
+ pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT "; "
+ GST_TENSORS_CAP_WITH_NUM ("1"));
+ pad_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ pad_caps);
+ gst_element_class_add_pad_template (gstelement_class, pad_template);
+ gst_caps_unref (pad_caps);
+
gst_element_class_set_static_metadata (gstelement_class,
"TensorSrcTizenSensor", "Source/Tizen-Sensor-FW/Tensor",
"Creates tensor(s) stream from a given Tizen sensour framework node",
*/
/**
- * @brief Default static capability for other/tensors
+ * @brief Caps string for the caps template (other/tensors).
+ * num should be a string format that describes the number of tensors, or the range of incoming tensors.
*/
-#define GST_TENSORS_CAP_DEFAULT \
+#define GST_TENSORS_CAP_WITH_NUM(num) \
"other/tensors, " \
- "num_tensors = " GST_TENSOR_NUM_TENSORS_RANGE ", "\
+ "num_tensors = " num ", " \
"framerate = " GST_TENSOR_RATE_RANGE
/**
* type should be one of types in GST_TENSOR_TYPE_ALL
*/
/**
+ * @brief Default static capability for other/tensors
+ */
+#define GST_TENSORS_CAP_DEFAULT \
+ GST_TENSORS_CAP_WITH_NUM(GST_TENSOR_NUM_TENSORS_RANGE)
+
+/**
* @brief Default static capability for Protocol Buffers
* protobuf converter will convert this capability to other/tensor(s)
* @todo Move this definition to proper header file
#define DEFAULT_QOS TRUE
#define DEFAULT_INDEX 0
-/**
- * @brief tensor_reposink sink template
- */
-#if (GST_VERSION_MAJOR == 1) && (GST_VERSION_MINOR >= 8) /* >= 1.8 */
-static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT "; " GST_TENSORS_CAP_DEFAULT));
-#endif
-
static void gst_tensor_reposink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_tensor_reposink_get_property (GObject * object, guint prop_id,
GObjectClass *gobject_class;
GstElementClass *element_class;
GstBaseSinkClass *basesink_class;
+ GstPadTemplate *pad_template;
+ GstCaps *pad_caps;
GST_DEBUG_CATEGORY_INIT (gst_tensor_reposink_debug, "tensor_reposink", 0,
"Sink element to handle tensor repository");
"Set element to handle tensor repository",
"Samsung Electronics Co., Ltd.");
-#if (GST_VERSION_MAJOR == 1) && (GST_VERSION_MINOR >= 8) /* >= 1.8 */
- gst_element_class_add_static_pad_template (element_class, &sink_template);
-#elif (GST_VERSION_MAJOR == 1) /* 1.0 ~ 1.8 */
- {
- GstPadTemplate *pad_template;
- GstCaps *pad_caps;
- pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT "; "
- GST_TENSORS_CAP_DEFAULT);
- pad_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- pad_caps);
- gst_element_class_add_pad_template (element_class, pad_template);
- gst_caps_unref (pad_caps);
- }
-#else
-#error We support GStreamer 1.x only.
-#endif
+ /* pad template */
+ pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT "; "
+ GST_TENSORS_CAP_DEFAULT);
+ pad_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
+ pad_caps);
+ gst_element_class_add_pad_template (element_class, pad_template);
+ gst_caps_unref (pad_caps);
basesink_class->start = GST_DEBUG_FUNCPTR (gst_tensor_reposink_start);
basesink_class->stop = GST_DEBUG_FUNCPTR (gst_tensor_reposink_stop);
#define DEFAULT_SILENT TRUE
#define DEFAULT_INDEX 0
-/**
- * @brief tensor_reposrc src template
- */
-#if (GST_VERSION_MAJOR == 1) && (GST_VERSION_MINOR >= 8) /* >= 1.8 */
-static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT "; " GST_TENSORS_CAP_DEFAULT));
-#endif
-
static void gst_tensor_reposrc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_tensor_reposrc_get_property (GObject * object, guint prop_id,
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstPushSrcClass *pushsrc_class = GST_PUSH_SRC_CLASS (klass);
GstBaseSrcClass *basesrc_class = GST_BASE_SRC_CLASS (klass);
+ GstPadTemplate *pad_template;
+ GstCaps *pad_caps;
GST_DEBUG_CATEGORY_INIT (gst_tensor_reposrc_debug, "tensor_reposrc", 0,
"Source element to handle tensor repository");
"Pop element to handle tensor repository",
"Samsung Electronics Co., Ltd.");
-#if (GST_VERSION_MAJOR == 1) && (GST_VERSION_MINOR >= 8) /* >= 1.8 */
- gst_element_class_add_static_pad_template (element_class, &src_template);
-#elif (GST_VERSION_MAJOR == 1) /* 1.0 ~ 1.8 */
- {
- GstPadTemplate *pad_template;
- GstCaps *pad_caps;
- pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT "; "
- GST_TENSORS_CAP_DEFAULT);
- pad_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- pad_caps);
- gst_element_class_add_pad_template (element_class, pad_template);
- gst_caps_unref (pad_caps);
- }
-#else
-#error We support GStreamer 1.x only.
-#endif
+ /* pad template */
+ pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT "; "
+ GST_TENSORS_CAP_DEFAULT);
+ pad_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ pad_caps);
+ gst_element_class_add_pad_template (element_class, pad_template);
+ gst_caps_unref (pad_caps);
}
/**
#define DEFAULT_SYNC FALSE
/**
- * @brief Template for sink pad.
- */
-#if (GST_VERSION_MAJOR == 1) && (GST_VERSION_MINOR >= 8) /* >= 1.8 */
-static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT "; " GST_TENSORS_CAP_DEFAULT));
-#endif
-
-/**
* @brief Variable for signal ids.
*/
static guint _tensor_sink_signals[LAST_SIGNAL] = { 0 };
GObjectClass *gobject_class;
GstElementClass *element_class;
GstBaseSinkClass *bsink_class;
+ GstPadTemplate *pad_template;
+ GstCaps *pad_caps;
GST_DEBUG_CATEGORY_INIT (gst_tensor_sink_debug, "tensor_sink", 0,
"Sink element to handle tensor stream");
"Sink element to handle tensor stream", "Samsung Electronics Co., Ltd.");
/** pad template */
-#if (GST_VERSION_MAJOR == 1) && (GST_VERSION_MINOR >= 8) /* >= 1.8 */
- gst_element_class_add_static_pad_template (element_class, &sink_template);
-#elif (GST_VERSION_MAJOR == 1) /* 1.0 ~ 1.8 */
- {
- GstPadTemplate *pad_template;
- GstCaps *pad_caps;
- pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT "; "
- GST_TENSORS_CAP_DEFAULT);
- pad_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- pad_caps);
- gst_element_class_add_pad_template (element_class, pad_template);
- gst_caps_unref (pad_caps);
- }
-#else
-#error We support GStreamer 1.x only.
-#endif
+ pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT "; "
+ GST_TENSORS_CAP_DEFAULT);
+ pad_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
+ pad_caps);
+ gst_element_class_add_pad_template (element_class, pad_template);
+ gst_caps_unref (pad_caps);
/** GstBaseSink methods */
bsink_class->event = GST_DEBUG_FUNCPTR (gst_tensor_sink_event);
#define AVAIL_FREQUENCY_FILE "sampling_frequency_available"
#define SAMPLING_FREQUENCY "sampling_frequency"
-/**
- * @brief Template for src pad.
- */
-static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT "; " GST_TENSORS_CAP_DEFAULT));
-
/** Define data processing functions for various types */
PROCESS_SCANNED_DATA (guint8, gint8);
PROCESS_SCANNED_DATA (guint16, gint16);
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSrcClass *bsrc_class;
+ GstPadTemplate *pad_template;
+ GstCaps *pad_caps;
GST_DEBUG_CATEGORY_INIT (gst_tensor_src_iio_debug, "tensor_src_iio", 0,
"Source element to handle Linux Industrial I/O sensors as input");
"Parichay Kapoor <pk.kapoor@samsung.com>");
/** pad template */
- gst_element_class_add_static_pad_template (gstelement_class, &src_factory);
+ pad_caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT "; "
+ GST_TENSORS_CAP_DEFAULT);
+ pad_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ pad_caps);
+ gst_element_class_add_pad_template (gstelement_class, pad_template);
+ gst_caps_unref (pad_caps);
+
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_tensor_src_iio_change_state);