[Tizen 4.0] Make it compatible with GStreamer 1.6
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 30 Mar 2020 10:04:08 +0000 (19:04 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Tue, 7 Apr 2020 07:32:09 +0000 (16:32 +0900)
gst_element_class_add_staic_pad_template is introduced with
GStreamer 1.8

For Tizen 4.0, which uses GStreamer 1.6, use
gst_element_class_add_pad_template() instead if
it is < 1.8.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
ext/nnstreamer/tensor_source/tensor_src_tizensensor.c
gst/nnstreamer/tensor_repo/tensor_reposink.c
gst/nnstreamer/tensor_repo/tensor_reposrc.c
gst/nnstreamer/tensor_sink/tensor_sink.c

index a425c67..f12f920 100644 (file)
@@ -150,12 +150,14 @@ enum
  * @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,
@@ -403,7 +405,22 @@ gst_tensor_src_tizensensor_class_init (GstTensorSrcTIZENSENSORClass * klass)
           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
   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",
index 27f1f01..5afdd50 100644 (file)
@@ -57,10 +57,12 @@ enum
 /**
  * @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);
@@ -127,7 +129,22 @@ gst_tensor_reposink_class_init (GstTensorRepoSinkClass * klass)
       "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
 
   basesink_class->start = GST_DEBUG_FUNCPTR (gst_tensor_reposink_start);
   basesink_class->stop = GST_DEBUG_FUNCPTR (gst_tensor_reposink_stop);
index 96c4ca1..df76bc8 100644 (file)
@@ -57,10 +57,12 @@ enum
 /**
  * @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);
@@ -115,7 +117,22 @@ gst_tensor_reposrc_class_init (GstTensorRepoSrcClass * klass)
       "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
 }
 
 /**
index f248149..3d5b19c 100644 (file)
@@ -100,10 +100,12 @@ enum
 /**
  * @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.
@@ -236,7 +238,22 @@ gst_tensor_sink_class_init (GstTensorSinkClass * klass)
       "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
 
   /** GstBaseSink methods */
   bsink_class->event = GST_DEBUG_FUNCPTR (gst_tensor_sink_event);