summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2020-12-22 21:01:38 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2020-12-23 16:37:04 +0900
commit8f42dd3c8024443532c4796f48fc213c937434c4 (patch)
treeb1679f7121a077f4ca564f5ef6b6a6402ad6f7bf
parent151c8babe2b0f05aa953aa4f0fd60e6e9a3f8b6c (diff)
downloadcamera-8f42dd3c8024443532c4796f48fc213c937434c4.tar.gz
camera-8f42dd3c8024443532c4796f48fc213c937434c4.tar.bz2
camera-8f42dd3c8024443532c4796f48fc213c937434c4.zip
- Add menu for device state and list [Version] 0.4.44 [Issue Type] Test Change-Id: I8f619f8001ac9dfacb63eb32816320b7324607aa Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r--packaging/capi-media-camera.spec2
-rw-r--r--src/camera_internal.c5
-rw-r--r--test/camera_test.c205
3 files changed, 184 insertions, 28 deletions
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec
index 5c53cb8..9992fff 100644
--- a/packaging/capi-media-camera.spec
+++ b/packaging/capi-media-camera.spec
@@ -1,6 +1,6 @@
Name: capi-media-camera
Summary: A Camera API
-Version: 0.4.43
+Version: 0.4.44
Release: 0
Group: Multimedia/API
License: Apache-2.0
diff --git a/src/camera_internal.c b/src/camera_internal.c
index 5521042..f909c3e 100644
--- a/src/camera_internal.c
+++ b/src/camera_internal.c
@@ -306,8 +306,9 @@ int camera_device_manager_get_device_list(camera_device_manager_h manager, camer
CAM_LOG_INFO("device count[%d]", list->count);
for (i = 0 ; i < list->count ; i++) {
- CAM_LOG_INFO(" [%d] : type[%d], device index[%d], name[%s]",
- i, list->device[i].type, list->device[i].index, list->device[i].name);
+ CAM_LOG_INFO(" [%d] : type[%d], device index[%d], name[%s], id[%s]",
+ i, list->device[i].type, list->device[i].index,
+ list->device[i].name, list->device[i].id);
}
return ret;
diff --git a/test/camera_test.c b/test/camera_test.c
index 905485e..3bfe894 100644
--- a/test/camera_test.c
+++ b/test/camera_test.c
@@ -63,7 +63,8 @@ appdata ad;
GIOChannel *stdin_channel;
camera_device_e camera_device;
static GTimer *timer;
-static int g_camera_device_changed_cb_id;
+static int g_camera_device_state_changed_cb_id;
+static int g_camera_device_list_changed_cb_id;
static struct timeval previous_time;
static struct timeval current_time;
@@ -135,7 +136,9 @@ enum {
enum {
MENU_STATE_INIT,
MENU_STATE_MAIN,
- MENU_STATE_SETTING,
+ MENU_STATE_MAIN_SETTING,
+ MENU_STATE_DEVICE_STATE,
+ MENU_STATE_DEVICE_LIST,
MENU_STATE_NUM,
};
@@ -174,6 +177,7 @@ typedef struct {
| LOCAL VARIABLE DEFINITIONS: |
---------------------------------------------------------------------------*/
static cam_handle_t *hcamcorder;
+static camera_device_manager_h g_device_manager;
const char *wb[SENSOR_WHITEBALANCE_NUM] = {
"None",
@@ -444,6 +448,26 @@ static void _camera_device_state_changed_cb(camera_device_e device, camera_devic
return;
}
+static void _camera_device_list_changed_cb(camera_device_list_s *device_list, void *user_data)
+{
+ unsigned int i = 0;
+
+ if (!device_list) {
+ g_print("NULL list");
+ return;
+ }
+
+ g_print("\n\tcamera device list changed[count:%d]\n", device_list->count);
+
+ for (i = 0 ; i < device_list->count ; i++) {
+ g_print("\t[%d] : type[%d], index[%d], name[%s], id[%s]\n",
+ i, device_list->device[i].type, device_list->device[i].index,
+ device_list->device[i].name, device_list->device[i].id);
+ }
+
+ return;
+}
+
static void _camera_interrupted_cb(camera_policy_e policy, camera_state_e previous, camera_state_e current, void *user_data)
{
g_print("\n\tcamera interrupted callback called[state %d -> %d, policy %d]\n",
@@ -707,9 +731,8 @@ static void print_menu()
g_print("\t CAMERA_TESTSUITE\n");
g_print("\t=======================================\n");
g_print("\t '1' Video Capture\n");
- g_print("\t '2' Add camera device state changed callback\n");
- g_print("\t '3' Remove camera device state changed callback\n");
- g_print("\t '4' Get camera device state\n");
+ g_print("\t '2' Device State\n");
+ g_print("\t '3' Device List\n");
g_print("\t 'q' Exit\n");
g_print("\t=======================================\n");
break;
@@ -726,7 +749,29 @@ static void print_menu()
g_print("\t 'b' back\n");
g_print("\t=======================================\n");
break;
- case MENU_STATE_SETTING:
+ case MENU_STATE_DEVICE_STATE:
+ g_print("\n\t=======================================\n");
+ g_print("\t Device State\n");
+ g_print("\t=======================================\n");
+ g_print("\t '1' Get camera device state\n");
+ g_print("\t '2' Add camera device state changed callback\n");
+ g_print("\t '3' Remove camera device state changed callback\n");
+ g_print("\t 'b' back\n");
+ g_print("\t=======================================\n");
+ break;
+ case MENU_STATE_DEVICE_LIST:
+ g_print("\n\t=======================================\n");
+ g_print("\t Device List\n");
+ g_print("\t=======================================\n");
+ g_print("\t '1' Initialize device manager\n");
+ g_print("\t '2' Get camera device list\n");
+ g_print("\t '3' Add camera device list changed callback\n");
+ g_print("\t '4' Remove camera device list changed callback\n");
+ g_print("\t '5' Deinitialize device manager\n");
+ g_print("\t 'b' back\n");
+ g_print("\t=======================================\n");
+ break;
+ case MENU_STATE_MAIN_SETTING:
g_print("\n\t=======================================\n");
g_print("\t Video Capture > Setting\n");
g_print("\t=======================================\n");
@@ -812,7 +857,7 @@ static void main_menu(gchar buf)
camera_start_preview(hcamcorder->camera);
break;
case '3': /* Setting */
- hcamcorder->menu_state = MENU_STATE_SETTING;
+ hcamcorder->menu_state = MENU_STATE_MAIN_SETTING;
break;
case '4': /* Change device (CAMERA0 <-> CAMERA1) */
camera_set_display_reuse_hint(hcamcorder->camera, true);
@@ -1323,6 +1368,123 @@ static void setting_menu(gchar buf)
}
+static void device_state_menu(gchar buf)
+{
+ int ret = 0;
+ camera_device_e device = CAMERA_DEVICE_CAMERA0;
+ camera_device_state_e device_state = CAMERA_DEVICE_STATE_NULL;
+
+ switch (buf) {
+ case '1': /* Get device state */
+ while (1) {
+ g_print("\n\tEnter Camera Index[0~9]: ");
+
+ ret = scanf("%d", (int *)&device);
+ flush_stdin();
+
+ if (ret == EOF) {
+ g_print("\n\t!!!read input error!!!\n");
+ return;
+ }
+
+ if (device < CAMERA_DEVICE_CAMERA0 ||
+ device > CAMERA_DEVICE_CAMERA9) {
+ g_print("\n\tinvalid input:[%d], try again...\n", device);
+ continue;
+ }
+
+ ret = camera_get_device_state(device, &device_state);
+ g_print("\n\tDevice[%d] state[%d], ret[0x%x]",
+ device, device_state, ret);
+ break;
+ }
+ break;
+ case '2': /* Add device state changed callback */
+ ret = camera_add_device_state_changed_cb(_camera_device_state_changed_cb,
+ NULL, &g_camera_device_state_changed_cb_id);
+ g_print("\n\tadd result[0x%x] - cb id[%d]\n", ret, g_camera_device_state_changed_cb_id);
+ break;
+ case '3': /* Remove device state changed callback */
+ if (g_camera_device_state_changed_cb_id > 0) {
+ ret = camera_remove_device_state_changed_cb(g_camera_device_state_changed_cb_id);
+ g_print("\n\tremove result[0x%x] - cb id[%d]\n", ret, g_camera_device_state_changed_cb_id);
+ g_camera_device_state_changed_cb_id = 0;
+ } else {
+ g_print("\n\tinvalid cb id[%d]\n", g_camera_device_state_changed_cb_id);
+ }
+ break;
+ case 'b': /* back */
+ hcamcorder->menu_state = MENU_STATE_INIT;
+ break;
+ default:
+ g_print("\n\tinvalid input[%c]\n", buf);
+ break;
+ }
+
+ return;
+}
+
+static void device_list_menu(gchar buf)
+{
+ int ret = 0;
+ unsigned int i = 0;
+ camera_device_list_s device_list;
+
+ switch (buf) {
+ case '1': /* Initialize device manager */
+ ret = camera_device_manager_initialize(&g_device_manager);
+ g_print("\n\tDevice manager[%p] initialize result[0x%x]\n",
+ g_device_manager, ret);
+ break;
+ case '2': /* Get device list */
+ memset(&device_list, 0x0, sizeof(camera_device_list_s));
+ ret = camera_device_manager_get_device_list(g_device_manager, &device_list);
+ if (ret != CAMERA_ERROR_NONE) {
+ g_print("\n\tGet device list failed[0x%x]\n", ret);
+ return;
+ }
+
+ g_print("\n\tDevice list[count:%d]\n", device_list.count);
+
+ for (i = 0 ; i < device_list.count ; i++) {
+ g_print("\t[%d] : type[%d], index[%d], name[%s], id[%s]\n",
+ i, device_list.device[i].type, device_list.device[i].index,
+ device_list.device[i].name, device_list.device[i].id);
+ }
+ break;
+ case '3': /* Add device list changed callback */
+ ret = camera_device_manager_add_device_list_changed_cb(g_device_manager,
+ _camera_device_list_changed_cb, NULL, &g_camera_device_list_changed_cb_id);
+ g_print("\n\tadd result[0x%x] - cb id[%d]\n", ret, g_camera_device_list_changed_cb_id);
+ break;
+ case '4': /* Remove device list changed callback */
+ if (g_camera_device_list_changed_cb_id > 0) {
+ ret = camera_device_manager_remove_device_list_changed_cb(g_device_manager,
+ g_camera_device_list_changed_cb_id);
+ g_print("\n\tremove result[0x%x] - cb id[%d]\n", ret, g_camera_device_list_changed_cb_id);
+ g_camera_device_list_changed_cb_id = 0;
+ } else {
+ g_print("\n\tinvalid cb id[%d]\n", g_camera_device_list_changed_cb_id);
+ }
+ break;
+ case '5': /* Deinitialize device manager */
+ ret = camera_device_manager_deinitialize(g_device_manager);
+ g_print("\n\tDevice manager[%p] deinitialize result[0x%x]\n",
+ g_device_manager, ret);
+ g_device_manager = NULL;
+ break;
+ case 'b': /* back */
+ hcamcorder->menu_state = MENU_STATE_INIT;
+ break;
+ default:
+ g_print("\n\tinvalid input[%c]\n", buf);
+ break;
+ }
+
+ return;
+}
+
+
/**
* This function is to execute command.
*
@@ -1358,9 +1520,15 @@ static gboolean cmd_input(GIOChannel *channel, GIOCondition condition, gpointer
case MENU_STATE_MAIN:
main_menu(buf[0]);
break;
- case MENU_STATE_SETTING:
+ case MENU_STATE_MAIN_SETTING:
setting_menu(buf[0]);
break;
+ case MENU_STATE_DEVICE_STATE:
+ device_state_menu(buf[0]);
+ break;
+ case MENU_STATE_DEVICE_LIST:
+ device_list_menu(buf[0]);
+ break;
default:
break;
}
@@ -1404,7 +1572,6 @@ static gboolean mode_change(gchar buf)
int camera_type = 0;
int display_type = 0;
bool check = FALSE;
- camera_device_state_e device_state = CAMERA_DEVICE_STATE_NULL;
switch (buf) {
case '1':
@@ -1441,23 +1608,11 @@ static gboolean mode_change(gchar buf)
}
break;
case '2':
- err = camera_add_device_state_changed_cb(_camera_device_state_changed_cb,
- NULL, &g_camera_device_changed_cb_id);
- g_print("add result 0x%x - cb id %d\n", err, g_camera_device_changed_cb_id);
- return FALSE;
+ hcamcorder->menu_state = MENU_STATE_DEVICE_STATE;
+ return TRUE;
case '3':
- if (g_camera_device_changed_cb_id > 0) {
- err = camera_remove_device_state_changed_cb(g_camera_device_changed_cb_id);
- g_camera_device_changed_cb_id = 0;
- g_print("remove result 0x%x\n", err);
- } else {
- g_print("invalid callback id %d\n", g_camera_device_changed_cb_id);
- }
- return FALSE;
- case '4':
- err = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &device_state);
- g_print("get result 0x%x - state %d\n", err, device_state);
- return FALSE;
+ hcamcorder->menu_state = MENU_STATE_DEVICE_LIST;
+ return TRUE;
case 'q':
g_print("\t Quit Camcorder Testsuite!!\n");
elm_exit();