/**
* @brief Macro for debug mode.
*/
+#ifndef DBG
#define DBG (!_tensor_sink_get_silent (self))
+#endif
/**
* @brief Macro for debug message.
#define DEFAULT_LATENESS (30 * GST_MSECOND)
/**
+ * @brief Template for sink pad.
+ */
+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));
+
+/**
* @brief Variable for signal ids.
*/
static guint _tensor_sink_signals[LAST_SIGNAL] = { 0 };
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,
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);
"Sink element to handle tensor stream", "Samsung Electronics Co., Ltd.");
/** 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);
+ gst_element_class_add_static_pad_template (element_class, &sink_template);
/** GstBaseSink methods */
bsink_class->start = GST_DEBUG_FUNCPTR (gst_tensor_sink_start);
}
/**
- * @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
}
/**
+ * @brief Test pipeline for given type.
+ * @param type 0 for video test, 1 for audio test
+ */
+static gchar *
+_test_pipeline (guint type)
+{
+ gchar *str_pipeline;
+
+ switch (type) {
+ case 0:
+ /** video 640x480 30fps 100 buffers */
+ str_pipeline =
+ g_strdup_printf
+ ("videotestsrc num-buffers=100 ! video/x-raw,format=RGB,width=640,height=480 ! "
+ "tensor_converter ! tensor_sink name=tensor_sink");
+ break;
+
+ case 1:
+ /** audio sample rate 16000 10 buffers */
+ str_pipeline =
+ g_strdup_printf
+ ("audiotestsrc num-buffers=10 samplesperbuffer=16000 ! audio/x-raw,rate=16000 ! "
+ "tensor_converter ! tensor_sink name=tensor_sink");
+ break;
+
+ default:
+ return NULL;
+ }
+
+ return str_pipeline;
+}
+
+/**
* @brief Main function.
*/
int
main (int argc, char **argv)
{
- const guint num_buffers = 100;
- const guint width = 640;
- const guint height = 480;
-
gchar *str_pipeline;
gulong handle_id;
GstStateChangeReturn state_ret;
g_app.loop = g_main_loop_new (NULL, FALSE);
_check_cond_err (g_app.loop != NULL);
- /** 640x480 30fps for test */
- str_pipeline =
- g_strdup_printf
- ("videotestsrc num-buffers=%d ! video/x-raw,format=RGB,width=%d,height=%d ! "
- "tensor_converter ! tensor_sink name=tensor_sink",
- num_buffers, width, height);
+ /** set type 1 for audio test */
+ str_pipeline = _test_pipeline (0);
g_app.pipeline = gst_parse_launch (str_pipeline, NULL);
g_free (str_pipeline);
_check_cond_err (g_app.pipeline != NULL);