goto error; \
}
+const guint TEST_TIME_OUT_MSEC = 2000;
+const guint DEFAULT_TIME_INTERVAL =10000;
const gulong MSEC_PER_USEC = 1000;
const gulong DEFAULT_JITTER = 0UL;
const gulong DEFAULT_FPS = 30UL;
}
/**
+ * @brief Wait until the pipeline processing the buffers
+ * @return TRUE on success, FALSE when a time-out occurs
+ */
+static gboolean
+_wait_pipeline_process_buffers (guint expected_num_buffers)
+{
+ guint timer_count = 0;
+ /* Waiting for expected buffers to arrive */
+ while (g_test_data.received < expected_num_buffers) {
+ timer_count++;
+ g_usleep (DEFAULT_TIME_INTERVAL);
+ if (timer_count > (TEST_TIME_OUT_MSEC / 10)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/**
* @brief Prepare test pipeline.
*/
static gboolean
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers / 3));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers / 2));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers / 3));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 5));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers / 2));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
- g_usleep (jitter);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers / 3));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
timeout_id = g_timeout_add (5000, _test_src_eos_timer_cb, g_test_data.loop);
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
-
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 2));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/* check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_free (pick);
gst_object_unref (demux);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/* check eos message */
g_free (pick);
gst_object_unref (demux);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/* check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
g_main_loop_run (g_test_data.loop);
g_source_remove (timeout_id);
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers ((num_buffers - 10) / 5 + 1));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers ((num_buffers - 10) / 5 + 1));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers ((num_buffers / 10)));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers / 4));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 5));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 10));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 10));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 25 - 1));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 10));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 10));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */
gst_element_set_state (g_test_data.pipeline, GST_STATE_PLAYING);
g_main_loop_run (g_test_data.loop);
+
+ EXPECT_TRUE (_wait_pipeline_process_buffers (num_buffers * 25 - 1));
gst_element_set_state (g_test_data.pipeline, GST_STATE_NULL);
/** check eos message */