[Sink] update pad template
authorjy1210.jung <jy1210.jung@samsung.com>
Mon, 30 Jul 2018 10:22:38 +0000 (19:22 +0900)
committer함명주/동작제어Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Mon, 30 Jul 2018 11:34:12 +0000 (20:34 +0900)
prepare tensors caps,
1. add function to merge tensor caps
2. set sink pad caps (other/tensor, other/tensors)

**Self evaluation:**
1. Build test: [*]Passed [ ]Failed [ ]Skipped
2. Run test: [ ]Passed [ ]Failed [*]Skipped

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
gst/tensor_sink/tensor_sink.c

index e96a0cc..6028c8e 100644 (file)
@@ -104,14 +104,6 @@ enum
 #define DEFAULT_LATENESS (30 * GST_MSECOND)
 
 /**
- * @brief Template for sink pad.
- */
-static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
-    GST_PAD_SINK,
-    GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT));
-
-/**
  * @brief Variable for signal ids.
  */
 static guint _tensor_sink_signals[LAST_SIGNAL] = { 0 };
@@ -137,6 +129,7 @@ static gboolean gst_tensor_sink_set_caps (GstBaseSink * sink, GstCaps * caps);
 static GstCaps *gst_tensor_sink_get_caps (GstBaseSink * sink, GstCaps * filter);
 
 /** internal functions */
+static GstCaps *_tensor_sink_get_tensor_caps (void);
 static void _tensor_sink_render_buffer (GstTensorSink * self,
     GstBuffer * buffer);
 static void _tensor_sink_set_last_render_time (GstTensorSink * self,
@@ -164,6 +157,8 @@ gst_tensor_sink_class_init (GstTensorSinkClass * klass)
   GObjectClass *gobject_class;
   GstElementClass *element_class;
   GstBaseSinkClass *bsink_class;
+  GstPadTemplate *pad_template;
+  GstCaps *pad_caps;
 
   gobject_class = G_OBJECT_CLASS (klass);
   element_class = GST_ELEMENT_CLASS (klass);
@@ -211,7 +206,12 @@ gst_tensor_sink_class_init (GstTensorSinkClass * klass)
       "Sink/Tensor",
       "Sink element to handle tensor stream", "Samsung Electronics Co., Ltd.");
 
-  gst_element_class_add_static_pad_template (element_class, &sinktemplate);
+  /** pad template */
+  pad_caps = _tensor_sink_get_tensor_caps ();
+  pad_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
+      pad_caps);
+  gst_caps_unref (pad_caps);
+  gst_element_class_add_pad_template (element_class, pad_template);
 
   /** GstBaseSink methods */
   bsink_class->start = GST_DEBUG_FUNCPTR (gst_tensor_sink_start);
@@ -544,6 +544,22 @@ gst_tensor_sink_get_caps (GstBaseSink * sink, GstCaps * filter)
 }
 
 /**
+ * @brief Get merged tensor caps.
+ */
+static GstCaps *
+_tensor_sink_get_tensor_caps (void)
+{
+  GstCaps *caps;
+  GstStaticCaps caps_tensor = GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT);
+  GstStaticCaps caps_tensors = GST_STATIC_CAPS (GST_TENSORS_CAP_DEFAULT);
+
+  caps = gst_caps_merge (gst_static_caps_get (&caps_tensor),
+      gst_static_caps_get (&caps_tensors));
+
+  return gst_caps_simplify (caps);
+}
+
+/**
  * @brief Handle buffer data.
  * @return None
  * @param self pointer to GstTensorSink