g_test_data.received++;
_print_log ("new data callback [%d]", g_test_data.received);
+ /* example to get data */
if (DBG) {
GstMemory *mem;
GstMapInfo info;
}
}
}
+
+ /* example to get negotiated caps */
+ if (DBG) {
+ GstPad *sink_pad;
+ GstCaps *caps;
+
+ sink_pad = gst_element_get_static_pad (g_test_data.sink, "sink");
+
+ if (sink_pad) {
+ g_object_get (sink_pad, "caps", &caps, NULL);
+
+ if (caps) {
+ guint caps_size, i;
+
+ caps_size = gst_caps_get_size (caps);
+ _print_log ("caps size is %d", caps_size);
+
+ for (i = 0; i < caps_size; i++) {
+ GstStructure *structure = gst_caps_get_structure (caps, i);
+ gchar *str = gst_structure_to_string (structure);
+
+ _print_log ("[%d] %s", i, str);
+ g_free (str);
+ }
+
+ gst_caps_unref (caps);
+ }
+
+ gst_object_unref (sink_pad);
+ }
+ }
}
/**
_setup_pipeline (const guint num_buffers)
{
gchar *str_pipeline;
+ gulong handle_id;
g_test_data.status = TEST_START;
g_test_data.received = 0;
_check_cond_err (g_test_data.bus != NULL);
gst_bus_add_signal_watch (g_test_data.bus);
- g_signal_connect (g_test_data.bus, "message", (GCallback) _message_cb, NULL);
+ handle_id = g_signal_connect (g_test_data.bus, "message",
+ (GCallback) _message_cb, NULL);
+ _check_cond_err (handle_id > 0);
g_test_data.sink =
gst_bin_get_by_name (GST_BIN (g_test_data.pipeline), "test_sink");
TEST (tensor_sink_test, properties)
{
guint64 rate, res_rate;
+ gint64 lateness, res_lateness;
gboolean silent, res_silent;
gboolean emit, res_emit;
+ gboolean sync, res_sync;
+ gboolean qos, res_qos;
ASSERT_TRUE (_setup_pipeline (1));
g_object_get (g_test_data.sink, "silent", &res_silent, NULL);
EXPECT_EQ (res_silent, !silent);
+ /* GstBaseSink:sync TRUE */
+ g_object_get (g_test_data.sink, "sync", &sync, NULL);
+ EXPECT_EQ (sync, TRUE);
+
+ g_object_set (g_test_data.sink, "sync", !sync, NULL);
+ g_object_get (g_test_data.sink, "sync", &res_sync, NULL);
+ EXPECT_EQ (res_sync, !sync);
+
+ /* GstBaseSink:max-lateness 30ms */
+ g_object_get (g_test_data.sink, "max-lateness", &lateness, NULL);
+ EXPECT_EQ (lateness, (30 * GST_MSECOND));
+
+ /* -1 means unlimited time */
+ g_object_set (g_test_data.sink, "max-lateness", (gint64) (-1), NULL);
+ g_object_get (g_test_data.sink, "max-lateness", &res_lateness, NULL);
+ EXPECT_EQ (res_lateness, -1);
+
+ /* GstBaseSink:qos TRUE */
+ g_object_get (g_test_data.sink, "qos", &qos, NULL);
+ EXPECT_EQ (qos, TRUE);
+
+ g_object_set (g_test_data.sink, "qos", !qos, NULL);
+ g_object_get (g_test_data.sink, "qos", &res_qos, NULL);
+ EXPECT_EQ (res_qos, !qos);
+
_free_test_data ();
}
TEST (tensor_sink_test, signals)
{
const guint num_buffers = 10;
+ gulong handle_id;
ASSERT_TRUE (_setup_pipeline (num_buffers));
+ if (DBG) {
+ /* print logs */
+ g_object_set (g_test_data.sink, "silent", FALSE, NULL);
+ }
+
/* enable emit-signal */
g_object_set (g_test_data.sink, "emit-signal", TRUE, NULL);
/* tensor sink signals */
- g_signal_connect (g_test_data.sink, "new-data",
+ handle_id = g_signal_connect (g_test_data.sink, "new-data",
(GCallback) _new_data_cb, NULL);
- g_signal_connect (g_test_data.sink, "stream-start",
+ EXPECT_TRUE (handle_id > 0);
+
+ handle_id = g_signal_connect (g_test_data.sink, "stream-start",
(GCallback) _stream_start_cb, NULL);
- g_signal_connect (g_test_data.sink, "eos", (GCallback) _eos_cb, NULL);
+ EXPECT_TRUE (handle_id > 0);
+
+ handle_id = g_signal_connect (g_test_data.sink, "eos",
+ (GCallback) _eos_cb, NULL);
+ EXPECT_TRUE (handle_id > 0);
_print_log ("start pipeline for signals test");
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
TEST (tensor_sink_test, render_rate)
{
const guint num_buffers = 10;
+ gulong handle_id;
ASSERT_TRUE (_setup_pipeline (num_buffers));
+ if (DBG) {
+ /* print logs */
+ g_object_set (g_test_data.sink, "silent", FALSE, NULL);
+ }
+
/* enable emit-signal */
g_object_set (g_test_data.sink, "emit-signal", TRUE, NULL);
/* set render-rate */
- g_object_set (g_test_data.sink, "render-rate", 15, NULL);
+ g_object_set (g_test_data.sink, "render-rate", (guint64) 15, NULL);
/* signal for new data */
- g_signal_connect (g_test_data.sink, "new-data",
+ handle_id = g_signal_connect (g_test_data.sink, "new-data",
(GCallback) _new_data_cb, NULL);
+ EXPECT_TRUE (handle_id > 0);
_print_log ("start pipeline for render-rate test");
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
}
/**
+ * @brief Test for unknown property and signal.
+ */
+TEST (tensor_sink_test, unknown_case)
+{
+ const guint num_buffers = 10;
+ gulong handle_id;
+ gint unknown = -1;
+
+ ASSERT_TRUE (_setup_pipeline (num_buffers));
+
+ if (DBG) {
+ /* print logs */
+ g_object_set (g_test_data.sink, "silent", FALSE, NULL);
+ }
+
+ /* try to set/get unknown property */
+ g_object_set (g_test_data.sink, "unknown-prop", 1, NULL);
+ g_object_get (g_test_data.sink, "unknown-prop", &unknown, NULL);
+ EXPECT_EQ (unknown, -1);
+
+ /* unknown signal */
+ handle_id = g_signal_connect (g_test_data.sink, "unknown-sig",
+ (GCallback) _new_data_cb, NULL);
+ EXPECT_EQ (handle_id, 0);
+
+ _print_log ("start pipeline for unknown case test");
+ gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
+ g_main_loop_run (g_test_data.loop);
+ gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
+
+ /* check eos message */
+ EXPECT_EQ (g_test_data.status, TEST_EOS);
+
+ /* check received buffers */
+ EXPECT_EQ (g_test_data.received, 0);
+
+ _free_test_data ();
+}
+
+/**
* @brief Main function for unit test.
*/
int