felipec gst-openmax: gst-openmax/tests/
[email protected] Thu, 20 Nov 2008 09:01:59 -0800 (PST)
Newsgroups
gmane.comp.video.gstreamer.cvs
Message-ID
<[email protected] >
CVS Root: /cvs/gstreamer
Module: gst-openmax
Changes by: felipec
Date: Thu Nov 20 2008 17:01:59 UTC
Log message:
Improve internal libomxil unit tests.
Do switch to Idle, still needs buffer handling.
Modified files:
tests : Makefile.am check_libomxil.c
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/tests/Makefile.am.diff?r1=1.4&r2=1.5
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-openmax/tests/check_libomxil.c.diff?r1=1.4&r2=1.5
====Begin Diffs====
Index: Makefile.am
===================================================================
RCS file: /cvs/gstreamer/gst-openmax/tests/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.am 5 Jun 2008 16:10:00 -0000 1.4
+++ Makefile.am 20 Nov 2008 17:01:45 -0000 1.5
@@ -19,8 +19,8 @@
check_PROGRAMS += check_libomxil
check_libomxil_SOURCES = check_libomxil.c
-check_libomxil_CFLAGS = $(CHECK_CFLAGS) -I$(top_srcdir)/omx/headers
-check_libomxil_LDADD = $(CHECK_LIBS) -ldl
+check_libomxil_CFLAGS = $(CHECK_CFLAGS) $(GTHREAD_CFLAGS) -I$(top_srcdir)/omx/headers
+check_libomxil_LDADD = $(CHECK_LIBS) $(GTHREAD_LIBS) -ldl
check_PROGRAMS += check_gstomx
check_gstomx_SOURCES = check_gstomx.c
Index: check_libomxil.c
RCS file: /cvs/gstreamer/gst-openmax/tests/check_libomxil.c,v
--- check_libomxil.c 23 Jun 2008 12:29:12 -0000 1.4
+++ check_libomxil.c 20 Nov 2008 17:01:45 -0000 1.5
@@ -21,7 +21,9 @@
#include <check.h>
#include <OMX_Core.h>
+#include <OMX_Component.h>
+#include <glib.h>
#include <dlfcn.h>
static const char *lib_name;
@@ -34,6 +36,104 @@
OMX_CALLBACKTYPE *callbacks);
static OMX_ERRORTYPE (*free_handle) (OMX_HANDLETYPE handle);
+typedef struct CustomData CustomData;
+
+struct CustomData
+{
+ OMX_HANDLETYPE omx_handle;
+ OMX_STATETYPE omx_state;
+ GCond *omx_state_condition;
+ GMutex *omx_state_mutex;
+};
+static CustomData *
+custom_data_new (void)
+ CustomData *custom_data;
+ custom_data = g_new0 (CustomData, 1);
+ custom_data->omx_state_condition = g_cond_new ();
+ custom_data->omx_state_mutex = g_mutex_new ();
+ return custom_data;
+}
+static void
+custom_data_free (CustomData *custom_data)
+ g_mutex_free (custom_data->omx_state_mutex);
+ g_cond_free (custom_data->omx_state_condition);
+ g_free (custom_data);
+static inline void
+change_state (CustomData *core,
+ OMX_STATETYPE state)
+ fail_if (OMX_SendCommand (core->omx_handle, OMX_CommandStateSet, state, NULL) != OMX_ErrorNone);
+complete_change_state (CustomData *core,
+ OMX_STATETYPE state)
+ g_mutex_lock (core->omx_state_mutex);
+ core->omx_state = state;
+ g_cond_signal (core->omx_state_condition);
+ g_mutex_unlock (core->omx_state_mutex);
+wait_for_state (CustomData *core,
+ OMX_STATETYPE state)
+ while (core->omx_state != state)
+ g_cond_wait (core->omx_state_condition, core->omx_state_mutex);
+static OMX_ERRORTYPE
+EventHandler (OMX_HANDLETYPE omx_handle,
+ OMX_PTR app_data,
+ OMX_EVENTTYPE event,
+ OMX_U32 data_1,
+ OMX_U32 data_2,
+ OMX_PTR event_data)
+ CustomData *core;
+ core = app_data;
+ switch (event)
+ {
+ case OMX_EventCmdComplete:
+ {
+ OMX_COMMANDTYPE cmd;
+ cmd = (OMX_COMMANDTYPE) data_1;
+ switch (cmd)
+ {
+ case OMX_CommandStateSet:
+ complete_change_state (core, data_2);
+ break;
+ default:
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return OMX_ErrorNone;
+static OMX_CALLBACKTYPE callbacks = { EventHandler, NULL, NULL };
START_TEST (test_basic)
{
OMX_ERRORTYPE omx_error;
@@ -63,6 +163,44 @@
}
END_TEST
+START_TEST (test_idle)
+ OMX_ERRORTYPE omx_error;
+ custom_data = custom_data_new ();
+ omx_error = init ();
+ fail_if (omx_error != OMX_ErrorNone);
+ omx_error = get_handle (&omx_handle, "OMX.check.dummy", custom_data, &callbacks);
+ custom_data->omx_handle = omx_handle;
+ change_state (custom_data, OMX_StateIdle);
+ /* allocate_buffers */
+ wait_for_state (custom_data, OMX_StateIdle);
+ change_state (custom_data, OMX_StateLoaded);
+ /* free_buffers */
+ wait_for_state (custom_data, OMX_StateLoaded);
+ omx_error = free_handle (omx_handle);
+ omx_error = deinit ();
+ custom_data_free (custom_data);
+END_TEST
static Suite *
util_suite (void)
@@ -71,6 +209,9 @@
lib_name = "libomxil-foo.so";
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
{
dl_handle = dlopen (lib_name, RTLD_LAZY);
if (!dl_handle)
@@ -86,6 +227,7 @@
tcase_add_test (tc_chain, test_basic);
tcase_add_test (tc_chain, test_handle);
+ tcase_add_test (tc_chain, test_idle);
suite_add_tcase (s, tc_chain);
return s;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/