SET(CAPI_LIB "capi-media-camera")
SET(TC_SOURCES
+ utc_media_camera_util.c
utc_media_camera_attr.c
utc_media_camera_lifecycle.c
utc_media_camera_setting.c
#include <pthread.h>
#include <glib-object.h>
#include <system_info.h>
+#include "utc_media_camera_util.h"
#include "assert.h"
pkt = NULL;
}
+ utc_media_camera_util_mainloop_quit(user_data);
+
return;
}
ret = camera_start_preview(camera);
- usleep(50 * 1000);
+ utc_media_camera_util_mainloop_run();
camera_stop_preview(camera);
camera_unset_media_packet_preview_cb(camera);
static void _camera_capture_completed_cb(void *data)
{
+ utc_media_camera_util_mainloop_quit(data);
+
return;
}
ret = camera_start_capture(camera, _camera_capture_cb, _camera_capture_completed_cb, NULL);
- usleep(1000 * 2000);
+ utc_media_camera_util_mainloop_run();
camera_start_preview(camera);
camera_stop_preview(camera);
#include <Evas.h>
#endif /* TIZENIOT */
#include "tct_common.h"
+#include "utc_media_camera_util.h"
#include "assert.h"
static void _changed_cb(camera_state_e previous, camera_state_e current, bool by_asm, void *user_data)
{
+ utc_media_camera_util_mainloop_quit(user_data);
+
return;
}
ret = camera_set_state_changed_cb(camera, _changed_cb, NULL);
assert_eq(ret, CAMERA_ERROR_NONE);
+ camera_start_preview(camera);
+
+ utc_media_camera_util_mainloop_run();
+
+ camera_stop_preview(camera);
+
return 0;
}
static void _device_state_changed_cb(camera_device_e device, camera_device_state_e state, void *user_data)
{
+ if (state == CAMERA_DEVICE_STATE_WORKING)
+ utc_media_camera_util_mainloop_quit(user_data);
+
return;
}
else
check_ret = CAMERA_ERROR_NOT_SUPPORTED;
+ camera_start_preview(camera);
+
+ utc_media_camera_util_mainloop_run();
+
if (cb_id > 0)
camera_remove_device_state_changed_cb(cb_id);
+ camera_stop_preview(camera);
+
assert_eq(ret, check_ret);
return 0;
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+#include "utc_media_camera_util.h"
+
+
+#define CAMERA_MAINLOOP_TIMEOUT 5000 /* milliseconds */
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "UTC_CAMERA_UTIL"
+
+
+static GMainLoop *g_camera_mainloop;
+static guint g_camera_timeout_id;
+
+
+gboolean utc_media_camera_util_mainloop_quit(gpointer user_data)
+{
+ if (!g_camera_mainloop)
+ return FALSE;
+
+ dlog_print(DLOG_INFO, LOG_TAG, "QUIT MAINLOOP");
+
+ g_main_loop_quit(g_camera_mainloop);
+
+ return FALSE;
+}
+
+void utc_media_camera_util_mainloop_run(void)
+{
+ g_camera_timeout_id = g_timeout_add(CAMERA_MAINLOOP_TIMEOUT, utc_media_camera_util_mainloop_quit, NULL);
+ if (g_camera_timeout_id == 0) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to add timer");
+ return;
+ }
+
+ g_camera_mainloop = g_main_loop_new(NULL, FALSE);
+ if (!g_camera_mainloop) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to get new mainloop");
+ g_source_remove(g_camera_timeout_id);
+ g_camera_timeout_id = 0;
+ return;
+ }
+
+ g_main_loop_run(g_camera_mainloop);
+
+ if (g_main_context_find_source_by_id(NULL, g_camera_timeout_id)) {
+ dlog_print(DLOG_INFO, LOG_TAG, "FOUND source[%u]", g_camera_timeout_id);
+ g_source_remove(g_camera_timeout_id);
+ } else {
+ dlog_print(DLOG_WARN, LOG_TAG, "NOT FOUND source[%u]", g_camera_timeout_id);
+ }
+
+ g_camera_timeout_id = 0;
+
+ g_main_loop_unref(g_camera_mainloop);
+ g_camera_mainloop = NULL;
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UTC_MEDIA_CAMERA_UTIL_H__
+#define __UTC_MEDIA_CAMERA_UTIL_H__
+
+#include <glib.h>
+
+
+gboolean utc_media_camera_util_mainloop_quit(gpointer user_data);
+void utc_media_camera_util_mainloop_run(void);
+
+#endif /* __UTC_MEDIA_CAMERA_UTIL_H__ */