- Add macros to check handle.
- Add sub functions for duplicated code.
- Rename camera_test to camera_test_headed.
- Add common source file for camera_test_headed/headless.
[Version] 0.4.82
[Issue Type] SAM Improvement
Change-Id: I2901b473e968dcbd132bf0db6c2d9fbb74978800
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
ADD_SUBDIRECTORY(test)
-ADD_SUBDIRECTORY(test_headless)
IF(UNIX)
Name: capi-media-camera
Summary: A Camera API
-Version: 0.4.81
+Version: 0.4.82
Release: 0
Group: Multimedia/API
License: Apache-2.0
Development related files for a Camera library in Tizen Native API.
-%package test
-Summary: A Camera API testsuite
+%package test-headed
+Summary: A Camera API testsuite for headed target
Requires: %{name} = %{version}-%{release}
-%description test
-Tizen Native camera API testsuite.
+%description test-headed
+Tizen Native camera API testsuite for headed target.
%package test-headless
Summary: A Camera API testsuite for headless target
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-media-camera.so
-%files test
-%manifest capi-media-camera-test.manifest
+%files test-headed
+%manifest capi-media-camera-test-headed.manifest
%license LICENSE.APLv2
-%{_bindir}/camera_test
+%{_bindir}/camera_test_headed
%files test-headless
%manifest capi-media-camera-test-headless.manifest
return CAMERA_ERROR_NOT_SUPPORTED;\
}\
} while (0)
+#define CAMERA_CHECK_HANDLE_RETURN(pc) \
+ do {\
+ if (!pc || !pc->cb_info) {\
+ CAM_LOG_ERROR("NULL handle[%p]", pc);\
+ return;\
+ }\
+ } while (0)
+#define CAMERA_CHECK_HANDLE_RETURN_VAL(pc, val) \
+ do {\
+ if (!pc || !pc->cb_info) {\
+ CAM_LOG_ERROR("NULL handle[%p]", pc);\
+ return (val);\
+ }\
+ } while (0)
/* for camera device manager */
typedef struct _cdm_symbol_table {
camera_cli_s *pc = (camera_cli_s *)camera;
camera_cb_info_s *cb_info = NULL;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
- return FALSE;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, FALSE);
cb_info = pc->cb_info;
camera_cli_s *pc = (camera_cli_s *)camera;
camera_cb_info_s *cb_info = NULL;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
- return;
- }
+ CAMERA_CHECK_HANDLE_RETURN(pc);
CAM_LOG_INFO("Enter");
}
-static bool __is_supported_common(camera_h camera, muse_camera_api_e api)
+static bool __is_supported(camera_h camera, muse_camera_api_e api)
{
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
- return (bool)ret;
+ return !!ret;
+}
+
+
+static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
+
+ return ret;
+}
+
+
+static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
+
+ return ret;
+}
+
+
+static void __send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
+{
+ int send_ret = 0;
+
+ if (!msg) {
+ CAM_LOG_ERROR("api[%d] message failed", api);
+ if (ret)
+ *ret = CAMERA_ERROR_OUT_OF_MEMORY;
+
+ return;
+ }
+
+ CAM_LOG_INFO("api[%d], message[%s]", api, msg);
+
+ if (cb_info->is_server_connected) {
+ _camera_update_api_waiting(cb_info, api, 1);
+
+ g_mutex_lock(&cb_info->fd_lock);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ g_mutex_unlock(&cb_info->fd_lock);
+ }
+
+ if (send_ret < 0) {
+ CAM_LOG_ERROR("message send failed");
+ if (ret)
+ *ret = CAMERA_ERROR_INVALID_OPERATION;
+ } else {
+ if (ret)
+ *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
+ }
+
+ _camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+ CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
}
void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
int *ret, int timeout)
{
- int send_ret = 0;
char *msg = NULL;
if (!cb_info) {
}
msg = muse_core_msg_new(api, NULL);
- if (!msg) {
- CAM_LOG_ERROR("msg failed: api %d", api);
-
- if (ret)
- *ret = CAMERA_ERROR_OUT_OF_MEMORY;
-
- return;
- }
-
- CAM_LOG_DEBUG("send msg[%s]", msg);
-
- if (cb_info->is_server_connected) {
- _camera_update_api_waiting(cb_info, api, 1);
-
- g_mutex_lock(&cb_info->fd_lock);
- send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
- g_mutex_unlock(&cb_info->fd_lock);
- }
-
- if (send_ret < 0) {
- CAM_LOG_ERROR("msg send failed");
- if (ret)
- *ret = CAMERA_ERROR_INVALID_OPERATION;
- } else {
- if (ret)
- *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
- }
-
- _camera_update_api_waiting(cb_info, api, -1);
- muse_core_msg_free(msg);
+ __send_message_get_return(cb_info, api, msg, timeout, ret);
}
void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
int *ret, camera_msg_param *param, int timeout)
{
- int send_ret = 0;
int array_length;
char *msg = NULL;
break;
}
- if (!msg) {
- CAM_LOG_ERROR("msg failed: api %d", api);
-
- if (ret)
- *ret = CAMERA_ERROR_OUT_OF_MEMORY;
-
- return;
- }
-
- CAM_LOG_DEBUG("send msg[%s]", msg);
-
- if (cb_info->is_server_connected) {
- _camera_update_api_waiting(cb_info, api, 1);
-
- g_mutex_lock(&cb_info->fd_lock);
- send_ret = muse_core_msg_send(cb_info->fd, msg);
- g_mutex_unlock(&cb_info->fd_lock);
- }
-
- if (send_ret < 0) {
- CAM_LOG_ERROR("msg send failed");
-
- if (ret)
- *ret = CAMERA_ERROR_INVALID_OPERATION;
- } else {
- if (ret)
- *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
- }
-
- _camera_update_api_waiting(cb_info, api, -1);
-
- muse_core_msg_free(msg);
+ __send_message_get_return(cb_info, api, msg, timeout, ret);
}
void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
{
- int func_ret = CAMERA_ERROR_NONE;
- int send_ret = 0;
char *msg = NULL;
if (!cb_info || !param0 || !param1) {
CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
cb_info, param0, param1, api);
- func_ret = CAMERA_ERROR_INVALID_PARAMETER;
- goto _SEND_PARAM2_INT_DONE;
+
+ if (ret)
+ *ret = CAMERA_ERROR_INVALID_PARAMETER;
+
+ return;
}
CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
param0->type, param0->name, param0->value.value_INT,
param1->type, param1->name, param1->value.value_INT,
NULL);
- if (!msg) {
- CAM_LOG_ERROR("msg failed: api %d", api);
- func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
- goto _SEND_PARAM2_INT_DONE;
- }
-
- CAM_LOG_DEBUG("send msg[%s]", msg);
-
- if (cb_info->is_server_connected) {
- _camera_update_api_waiting(cb_info, api, 1);
-
- g_mutex_lock(&cb_info->fd_lock);
- send_ret = muse_core_msg_send(cb_info->fd, msg);
- g_mutex_unlock(&cb_info->fd_lock);
- }
-
- if (send_ret < 0) {
- CAM_LOG_ERROR("msg send failed");
- func_ret = CAMERA_ERROR_INVALID_OPERATION;
- } else {
- func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
- }
-
- _camera_update_api_waiting(cb_info, api, -1);
-
- muse_core_msg_free(msg);
-
-_SEND_PARAM2_INT_DONE:
- if (ret)
- *ret = func_ret;
+ __send_message_get_return(cb_info, api, msg, timeout, ret);
}
{
camera_cli_s *pc = (camera_cli_s *)camera;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("start");
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("stop - keep screen %d", keep_screen);
camera_cli_s *pc = (camera_cli_s *)camera;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAMERA_MSG_PARAM_SET(param, INT, device);
muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
camera_cli_s *pc = (camera_cli_s *)camera;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
camera_state_e current_state = CAMERA_STATE_NONE;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter : preview format %d, display type %d",
pc->cb_info->preview_format, pc->cb_info->dp_info.type);
muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
camera_state_e current_state = CAMERA_STATE_NONE;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
bool camera_is_supported_continuous_capture(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
+ return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
}
camera_msg_param param;
int value = 0;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
bool camera_is_supported_face_detection(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
+ return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
}
bool camera_is_supported_zero_shutter_lag(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
+ return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
}
bool camera_is_supported_media_packet_preview_cb(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
+ return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
}
bool camera_is_supported_extra_preview(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
+ return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
}
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param;
int is_continuous = (int)continuous;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
muse_camera_display_info_s *dp_info = NULL;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
CAM_LOG_ERROR("invalid type %d", type);
camera_msg_param param;
int value = 0;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
if (pc->cb_info->is_evas_render) {
ret = camera_get_state(camera, ¤t_state);
camera_msg_param param;
int value = 0;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter - format %d", set_format);
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter - format %d", set_format);
camera_cli_s *pc = (camera_cli_s *)camera;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
camera_cli_s *pc = (camera_cli_s *)camera;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
camera_cli_s *pc = (camera_cli_s *)camera;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
camera_cli_s *pc = (camera_cli_s *)camera;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
if (pc->cb_info->is_evas_render) {
ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
camera_cli_s *pc = (camera_cli_s *)camera;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter - hint %d", set_hint);
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
if (camera_is_supported_media_packet_preview_cb(camera) == false) {
CAM_LOG_ERROR("NOT SUPPORTED");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
if (camera_is_supported_media_packet_preview_cb(camera) == false) {
CAM_LOG_ERROR("NOT SUPPORTED");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
- camera_msg_param param;
- int set_mode = (int)mode;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
}
camera_msg_param param;
int set_fps = (int)fps;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param;
int set_bitrate = bitrate;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param;
int set_gop_interval = interval;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
- camera_msg_param param;
- int set_mode = (int)mode;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
-
- CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- return ret;
+ return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
}
camera_msg_param param;
int value = 0;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter - %d,%d", x, y);
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
- camera_msg_param param;
- int set_mode = (int)mode;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
}
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param;
int set_iso = (int)iso;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
camera_msg_param param;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param;
int set_whitebalance = (int)wb;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param;
int set_effect = (int)effect;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
- camera_msg_param param;
- int set_mode = (int)mode;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
}
int camera_attr_enable_tag(camera_h camera, bool enable)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
- camera_msg_param param;
- int set_enable = (int)enable;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_enable);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
}
camera_msg_param param;
int set_orientation = (int)orientation;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
double set_geotag[3] = {latitude, longitude, altitude};
char *msg = NULL;
int length = 0;
- int send_ret = 0;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
msg = muse_core_msg_new(api,
MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
NULL);
- if (!msg) {
- CAM_LOG_ERROR("msg creation failed: api %d", api);
- return CAMERA_ERROR_OUT_OF_MEMORY;
- }
-
- if (pc->cb_info->is_server_connected) {
- _camera_update_api_waiting(pc->cb_info, api, 1);
-
- g_mutex_lock(&pc->cb_info->fd_lock);
- send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
- g_mutex_unlock(&pc->cb_info->fd_lock);
- }
-
- if (send_ret < 0) {
- CAM_LOG_ERROR("message send failed");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- } else {
- ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
- }
-
- _camera_update_api_waiting(pc->cb_info, api, -1);
- muse_core_msg_free(msg);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
+ __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
return ret;
}
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
- camera_msg_param param;
- int set_mode = (int)mode;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
}
camera_msg_param param;
int set_rotation = (int)rotation;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param;
int set_flip = (int)flip;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
- camera_msg_param param;
- int set_mode = (int)mode;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
}
bool camera_attr_is_supported_hdr_capture(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
+ return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
}
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
int camera_attr_enable_anti_shake(camera_h camera, bool enable)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
- camera_msg_param param;
- int set_enable = (int)enable;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_enable);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
}
bool camera_attr_is_supported_anti_shake(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
+ return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
}
int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
- camera_msg_param param;
- int set_enable = (int)enable;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_enable);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
}
bool camera_attr_is_supported_video_stabilization(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
+ return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
}
int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
- camera_msg_param param;
- int set_enable = (int)enable;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, set_enable);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
}
bool camera_attr_is_supported_auto_contrast(camera_h camera)
{
- return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
+ return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
}
camera_msg_param param;
int set_disable = (int)disable;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param0;
camera_msg_param param1;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param0;
camera_msg_param param1;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
camera_msg_param param;
int set_ptz_type = (int)ptz_type;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
int set_display_roi_area[4] = {x, y, width, height};
char *msg = NULL;
int length = 0;
- int send_ret = 0;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
msg = muse_core_msg_new(api,
MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
NULL);
- if (!msg) {
- CAM_LOG_ERROR("msg creation failed: api %d", api);
- return CAMERA_ERROR_OUT_OF_MEMORY;
- }
- if (pc->cb_info->is_server_connected) {
- _camera_update_api_waiting(pc->cb_info, api, 1);
-
- g_mutex_lock(&pc->cb_info->fd_lock);
- send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
- g_mutex_unlock(&pc->cb_info->fd_lock);
- }
-
- if (send_ret < 0) {
- CAM_LOG_ERROR("message send failed");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- } else {
- ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
- }
-
- _camera_update_api_waiting(pc->cb_info, api, -1);
-
- muse_core_msg_free(msg);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
+ __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
return ret;
}
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
g_mutex_lock(&pc->cb_info->bridge_lock);
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
g_mutex_lock(&pc->cb_info->bridge_lock);
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter");
int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e pixel_format, int width, int height, int fps)
{
int ret = CAMERA_ERROR_NONE;
- int send_ret = 0;
int stream_format[4] = {pixel_format, width, height, fps};
char *msg = NULL;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
stream_id, pixel_format, width, height, fps);
MUSE_TYPE_INT, "stream_id", stream_id,
MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
NULL);
- if (!msg) {
- CAM_LOG_ERROR("msg creation failed: api %d", api);
- return CAMERA_ERROR_OUT_OF_MEMORY;
- }
-
- if (pc->cb_info->is_server_connected) {
- _camera_update_api_waiting(pc->cb_info, api, 1);
-
- g_mutex_lock(&pc->cb_info->fd_lock);
- send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
- g_mutex_unlock(&pc->cb_info->fd_lock);
- }
-
- if (send_ret < 0) {
- CAM_LOG_ERROR("message send failed");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- } else {
- ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
- }
- _camera_update_api_waiting(pc->cb_info, api, -1);
-
- muse_core_msg_free(msg);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
+ __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
return ret;
}
camera_msg_param param0;
camera_msg_param param1;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
camera_msg_param param0;
camera_msg_param param1;
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle[%p]", pc);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);
//LCOV_EXCL_START
+int __set_level(camera_h camera, muse_camera_api_e api, int level)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ CAM_LOG_ERROR("NULL handle - api[%d]", api);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ CAM_LOG_INFO("Enter - api[%d], level[%d]", api, level);
+
+ CAMERA_MSG_PARAM_SET(param, INT, level);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ CAM_LOG_INFO("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
int camera_start_evas_rendering(camera_h camera)
{
return _camera_start_evas_rendering(camera);
//LCOV_EXCL_START
int camera_attr_set_flash_brightness(camera_h camera, int level)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_BRIGHTNESS;
- camera_msg_param param;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle");
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, level);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_level(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_BRIGHTNESS, level);
}
int camera_attr_set_focus_level(camera_h camera, int level)
{
- int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FOCUS_LEVEL;
- camera_msg_param param;
-
- if (!pc || !pc->cb_info) {
- CAM_LOG_ERROR("NULL handle");
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("Enter");
-
- CAMERA_MSG_PARAM_SET(param, INT, level);
-
- _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
-
- CAM_LOG_INFO("ret : 0x%x", ret);
-
- return ret;
+ return __set_level(camera, MUSE_CAMERA_API_ATTR_SET_FOCUS_LEVEL, level);
}
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(fw_test "${fw_name}-test")
+SET(EXTRA_CFLAGS_HEADED "${EXTRA_CFLAGS}")
+SET(EXTRA_CFLAGS_HEADLESS "${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS} -fPIC -pie -Wall")
+SET(COMMON_SRC_NAME "camera_test.c")
-#INCLUDE_DIRECTORIES(../include)
-#link_directories(${CMAKE_SOURCE_DIR}/../)
+# camera_test_headed
+SET(fw_test_headed "${fw_test}-headed")
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED elementary evas ecore appcore-efl libtbm)
-FOREACH(flag ${${fw_test}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+PKG_CHECK_MODULES(${fw_test_headed} REQUIRED elementary evas ecore appcore-efl libtbm)
+FOREACH(flag ${${fw_test_headed}_CFLAGS})
+ SET(EXTRA_CFLAGS_HEADED "${EXTRA_CFLAGS_HEADED} ${flag}")
MESSAGE(${flag})
ENDFOREACH()
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -pie -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT} ${EXTRA_CFLAGS_HEADED} -fPIC -pie -Wall")
+SET(EXEC_NAME_HEADED camera_test_headed)
-aux_source_directory(. sources)
-FOREACH(src ${sources})
- GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
- MESSAGE("${src_name}")
- ADD_EXECUTABLE(${src_name} ${src})
- TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
- INSTALL(TARGETS ${src_name} DESTINATION bin)
+ADD_EXECUTABLE(${EXEC_NAME_HEADED} ${COMMON_SRC_NAME} ${EXEC_NAME_HEADED}.c)
+TARGET_LINK_LIBRARIES(${EXEC_NAME_HEADED} ${fw_name} ${${fw_test_headed}_LDFLAGS})
+INSTALL(TARGETS ${EXEC_NAME_HEADED} DESTINATION bin)
+# camera_test_headless
+SET(fw_test_headless "${fw_test}-headless")
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(${fw_test_headless} REQUIRED libtbm)
+FOREACH(flag ${${fw_test_headless}_CFLAGS})
+ SET(EXTRA_CFLAGS_HEADLESS "${EXTRA_CFLAGS_HEADLESS} ${flag}")
+ MESSAGE(${flag})
ENDFOREACH()
+
+SET(EXEC_NAME_HEADLESS camera_test_headless)
+
+ADD_EXECUTABLE(${EXEC_NAME_HEADLESS} ${COMMON_SRC_NAME} ${EXEC_NAME_HEADLESS}.c)
+TARGET_LINK_LIBRARIES(${EXEC_NAME_HEADLESS} ${fw_name} ${${fw_test_headless}_LDFLAGS})
+INSTALL(TARGETS ${EXEC_NAME_HEADLESS} DESTINATION bin)
+
/*
* camera_test
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Jeongmo Yang <jm80.yang@samsung.com>
*
/*=======================================================================================
| INCLUDE FILES |
=======================================================================================*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <glib.h>
-#include <sys/time.h>
-#include <dlog.h>
-#include <camera_internal.h>
-#include <Ecore.h>
-#include <Elementary.h>
-#include <appcore-efl.h>
-#include <tbm_surface.h>
-#include <media_bridge_internal.h>
+#include "camera_test.h"
/*-----------------------------------------------------------------------
| GLOBAL VARIABLE DEFINITIONS: |
-----------------------------------------------------------------------*/
#define EXPORT_API __attribute__((__visibility__("default")))
-#ifdef PACKAGE
-#undef PACKAGE
-#endif
-#define PACKAGE "camera_test"
-
-
-static int app_create(void *data);
-static int app_terminate(void *data);
-
-struct _appdata {
- Evas_Object *win;
- Evas_Object *eo;
- Evas_Object *bg;
- Evas_Object *rect;
-};
-typedef struct _appdata appdata;
-
-static struct appcore_ops ops = {
- .create = app_create,
- .terminate = app_terminate,
-};
-
-static appdata ad;
-static GIOChannel *stdin_channel;
+static cam_handle_t *hcamcorder;
static camera_device_e camera_device;
-static GTimer *timer;
static int g_camera_device_state_changed_cb_id;
static int g_camera_device_connection_changed_cb_id;
static int g_camera_preview_cb_dump;
| IMPORTED FUNCTION DECLARATIONS: |
-----------------------------------------------------------------------*/
-
-/*-----------------------------------------------------------------------
-| LOCAL #defines: |
------------------------------------------------------------------------*/
-#define DEFAULT_FILE_PATH "/home/owner/media"
-#define PREVIEW_CB_DUMP_FILE_NAME "preview.data"
-#define EXTRA_PREVIEW_CB_DUMP_FILE_NAME "extra_preview.data"
-#define MP_PREVIEW_CB_DUMP_FILE_NAME "mp_preview.data"
-#define MAX_FILE_NAME_LENGTH 256
-#define MAX_FILE_PATH_LENGTH (MAX_FILE_NAME_LENGTH - 20)
-
-#define CHECK_MM_ERROR(expr) \
- do {\
- int ret = 0; \
- ret = expr; \
- if (ret != 0) {\
- g_print("[%s:%d] error code : %x \n", __func__, __LINE__, ret); \
- return; \
- } \
- } while (0)
-
-
-#ifndef SAFE_FREE
-#define SAFE_FREE(x) \
- if (x) {\
- g_free(x);\
- x = NULL;\
- }
-#endif
-
-#define SENSOR_WHITEBALANCE_NUM 10
-#define SENSOR_COLOR_TONE_NUM 31
-#define SENSOR_FLIP_NUM 4
-#define SENSOR_PROGRAM_MODE_NUM 15
-#define SENSOR_FOCUS_NUM 6
-#define SENSOR_INPUT_ROTATION 4
-#define SENSOR_AF_SCAN_NUM 4
-#define SENSOR_ISO_NUM 8
-#define SENSOR_EXPOSURE_NUM 9
-#define SENSOR_IMAGE_FORMAT 20
-
-
-/*-----------------------------------------------------------------------
- | LOCAL CONSTANT DEFINITIONS: |
- -----------------------------------------------------------------------*/
-enum {
- MODE_VIDEO_CAPTURE, /* recording and image capture mode */
- MODE_AUDIO, /* audio recording*/
- MODE_NUM,
-};
-
-enum {
- MENU_STATE_INIT,
- MENU_STATE_MAIN,
- MENU_STATE_MAIN_SETTING,
- MENU_STATE_DEVICE_STATE,
- MENU_STATE_DEVICE_MANAGER,
- MENU_STATE_NUM,
-};
-
-/*-----------------------------------------------------------------------
- | LOCAL DATA TYPE DEFINITIONS: |
- -----------------------------------------------------------------------*/
-typedef struct _cam_handle {
- camera_h camera;
- int type;
- int is_multishot; /* flag for multishot mode */
- int stillshot_count; /* stillshot count */
- int multishot_count; /* multishot count */
- char file_path[MAX_FILE_PATH_LENGTH]; /* file path for captured data */
- int menu_state;
- unsigned long long elapsed_time;
-} cam_handle_t;
-
-typedef struct {
- int width[100];
- int height[100];
- int count;
-} resolution_stack;
-
-typedef struct {
- camera_attr_exposure_mode_e mode;
- int count;
-} exposure_stack;
-
-typedef struct {
- camera_attr_iso_e mode;
- int count;
-} iso_stack;
-
-
/*---------------------------------------------------------------------------
| LOCAL VARIABLE DEFINITIONS: |
---------------------------------------------------------------------------*/
-static cam_handle_t *hcamcorder;
static camera_device_manager_h g_device_manager;
const char *wb[SENSOR_WHITEBALANCE_NUM] = {
/*---------------------------------------------------------------------------
| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------*/
-static void print_menu();
-static gboolean cmd_input(GIOChannel *channel, GIOCondition condition, gpointer data);
static gboolean mode_change(gchar buf);
int camcordertest_set_attr_int(const char* attr_subcategory, int value);
}
}
-static inline void flush_stdin()
+void flush_stdin()
{
int ch;
while ((ch = getchar()) != EOF && ch != '\n');
media_packet_unref(pkt);
}
-static bool preview_resolution_cb(int width, int height, void *user_data)
-{
- resolution_stack *data = (resolution_stack *)user_data;
-
- if (data == NULL) {
- g_print("NULL data\n");
- return false;
- }
-
- data->width[data->count] = width;
- data->height[data->count] = height;
-
- g_print("\t%d. %dx%d\n", data->count, width, height);
-
- data->count++;
-
- return true;
-}
-
-static bool capture_resolution_test_cb(int width, int height, void *user_data)
+static bool _resolution_cb(int width, int height, void *user_data)
{
resolution_stack *data = (resolution_stack *)user_data;
camera_start_preview(hcamcorder->camera);
}
-static void print_menu()
+void print_menu()
{
switch (hcamcorder->menu_state) {
case MENU_STATE_INIT:
resolution_list.count = 0;
camera_foreach_supported_preview_resolution(hcamcorder->camera,
- preview_resolution_cb, &resolution_list);
+ _resolution_cb, &resolution_list);
g_print("\tCommand >> ");
g_print("\tFAIL\n");
break;
case '1': /* Setting > Capture Resolution setting */
- g_print("\t* Select the preview resolution!\n");
+ g_print("\t* Select the capture resolution!\n");
resolution_list.count = 0;
camera_foreach_supported_capture_resolution(hcamcorder->camera,
- capture_resolution_test_cb, &resolution_list);
+ _resolution_cb, &resolution_list);
g_print("\tCommand > ");
* @remark
* @see
*/
-static gboolean cmd_input(GIOChannel *channel, GIOCondition condition, gpointer data)
+gboolean cmd_input(GIOChannel *channel, GIOCondition condition, gpointer data)
{
gchar *buf = NULL;
gsize read_size;
return TRUE;
}
-static gboolean init_handle()
+
+cam_handle_t *init_handle()
{
+ hcamcorder = (cam_handle_t *)g_malloc0(sizeof(cam_handle_t));
+
hcamcorder->is_multishot = FALSE;
hcamcorder->stillshot_count = 0;
hcamcorder->multishot_count = 0;
snprintf(hcamcorder->file_path, MAX_FILE_PATH_LENGTH, DEFAULT_FILE_PATH);
hcamcorder->menu_state = MENU_STATE_INIT;
- hcamcorder->elapsed_time = 0;
- return TRUE;
+ return hcamcorder;
}
{
int err = 0;
int camera_type = 0;
- int display_type = 0;
- bool check = FALSE;
switch (buf) {
case '1':
return TRUE;
case 'q':
g_print("\t Quit Camcorder Testsuite!!\n");
- elm_exit();
+ quit_test();
return FALSE;
default:
g_print("\t Invalid media type(%c)\n", buf);
gettimeofday(&previous_time, NULL);
- g_timer_reset(timer);
-
if (camera_type)
err = camera_create_network(camera_device, &hcamcorder->camera);
else
err = camera_create(camera_device, &hcamcorder->camera);
- g_print("[camera_create() : %12.6lfs]\n", g_timer_elapsed(timer, NULL));
-
if (err != 0) {
g_print("\n\tmmcamcorder_create = 0x%x\n", err);
return FALSE;
}
- while (!check) {
- g_print("\n\tEnter the Display Type [1:Overlay, 2:Evas, 3:None] : ");
- err = scanf("%d", &display_type);
- flush_stdin();
- if (err == EOF) {
- g_print("\t!!!read input error!!!\n");
- continue;
- }
-
- switch (display_type) {
- case 1:
- camera_set_display(hcamcorder->camera, CAMERA_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(ad.win));
- check = TRUE;
- break;
- case 2:
- camera_set_display(hcamcorder->camera, CAMERA_DISPLAY_TYPE_EVAS, GET_DISPLAY(ad.eo));
- check = TRUE;
- break;
- case 3:
- camera_set_display(hcamcorder->camera, CAMERA_DISPLAY_TYPE_NONE, NULL);
- check = TRUE;
- break;
- default:
- g_print("\t Invalid display type(%d)\n", display_type);
- break;
- }
- }
+ set_display(hcamcorder);
camera_set_error_cb(hcamcorder->camera, _camera_error_cb, NULL);
camera_set_state_changed_cb(hcamcorder->camera, _camera_state_changed_cb, NULL);
return TRUE;
}
-
-static int app_create(void *data)
-{
- appdata *app_data = data;
- int w = 0;
- int h = 0;
- Evas_Object *win = NULL;
- Evas_Object *eo = NULL;
- Evas_Object *bg = NULL;
- Evas_Object *rect = NULL;
-
- if (app_data == NULL) {
- g_print("\t\nappdata is NULL\n");
- return 0;
- }
-
- /* use gl backend */
- elm_config_accel_preference_set("opengl");
-
- win = elm_win_add(NULL, "camera_test", ELM_WIN_BASIC);
- if (win) {
- elm_win_title_set(win, "camera_test");
- elm_win_borderless_set(win, EINA_TRUE);
- elm_win_screen_size_get(win, NULL, NULL, &w, &h);
- g_print("\n\tscreen size %dx%d\n\n", w, h);
- evas_object_resize(win, w, h);
- elm_win_autodel_set(win, EINA_TRUE);
- elm_win_alpha_set(win, EINA_TRUE);
- } else {
- g_print("\n\tfailed to get window\n\n");
- return 1;
- }
-
- bg = elm_bg_add(win);
- if (bg) {
- elm_win_resize_object_add(win, bg);
- evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(bg);
- } else {
- g_print("\n\tfailed to get elm bg\n\n");
- return 1;
- }
-
- rect = evas_object_rectangle_add(evas_object_evas_get(win));
- if (rect) {
- evas_object_color_set(rect, 0, 0, 0, 0);
- evas_object_render_op_set(rect, EVAS_RENDER_COPY);
- } else {
- g_print("\n\tfailed to get rectangle\n\n");
- return 1;
- }
-
- elm_win_resize_object_add(win, rect);
- evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(rect);
-
- /* Create evas image object for EVAS surface */
- eo = evas_object_image_add(evas_object_evas_get(win));
- evas_object_image_size_set(eo, w, h);
- evas_object_image_fill_set(eo, 0, 0, w, h);
- evas_object_resize(eo, w, h);
- evas_object_show(eo);
-
- elm_win_activate(win);
- evas_object_show(win);
-
- app_data->win = win;
- app_data->eo = eo;
-
- timer = g_timer_new();
- g_timer_reset(timer);
-
- init_handle();
-
- print_menu();
-
- return 0;
-}
-
-static int app_terminate(void *data)
-{
- appdata *app_data = data;
-
- if (app_data == NULL) {
- g_print("\n\tappdata is NULL\n");
- return 0;
- }
-
- if (timer) {
- g_timer_stop(timer);
- g_timer_destroy(timer);
- timer = NULL;
- }
-
- return 0;
-}
-
-
-/**
- * This function is the example main function for mmcamcorder API.
- *
- * @param
- *
- * @return This function returns 0.
- * @remark
- * @see other functions
- */
-int main(int argc, char **argv)
-{
- int bret;
-
- hcamcorder = (cam_handle_t *) g_malloc0(sizeof(cam_handle_t));
-
- stdin_channel = g_io_channel_unix_new(fileno(stdin));/* read from stdin */
- g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)cmd_input, NULL);
-
- memset(&ad, 0x0, sizeof(appdata));
- ops.data = &ad;
-
- bret = appcore_efl_main(PACKAGE, &argc, &argv, &ops);
-
- g_print("\n\treturn appcore_efl : %d\n\n", bret);
-
- g_free(hcamcorder);
- g_io_channel_unref(stdin_channel);
-
- return bret;
-}
/*EOF*/
--- /dev/null
+/*
+ * camera_test
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jeongmo Yang <jm80.yang@samsung.com>
+ *
+ * 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 f(r the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __CAMERA_TEST_H__
+#define __CAMERA_TEST_H__
+
+/*=======================================================================================
+| INCLUDE FILES |
+=======================================================================================*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <glib.h>
+#include <sys/time.h>
+#include <dlog.h>
+#include <camera_internal.h>
+#include <tbm_surface.h>
+#include <media_bridge_internal.h>
+
+/*-----------------------------------------------------------------------
+| GLOBAL VARIABLE DEFINITIONS: |
+-----------------------------------------------------------------------*/
+#define EXPORT_API __attribute__((__visibility__("default")))
+
+/*-----------------------------------------------------------------------
+| GLOBAL CONSTANT DEFINITIONS: |
+-----------------------------------------------------------------------*/
+
+
+/*-----------------------------------------------------------------------
+| IMPORTED VARIABLE DECLARATIONS: |
+-----------------------------------------------------------------------*/
+
+
+/*-----------------------------------------------------------------------
+| IMPORTED FUNCTION DECLARATIONS: |
+-----------------------------------------------------------------------*/
+
+
+/*-----------------------------------------------------------------------
+| LOCAL #defines: |
+-----------------------------------------------------------------------*/
+#define DEFAULT_FILE_PATH "/home/owner/media"
+#define PREVIEW_CB_DUMP_FILE_NAME "preview.data"
+#define EXTRA_PREVIEW_CB_DUMP_FILE_NAME "extra_preview.data"
+#define MP_PREVIEW_CB_DUMP_FILE_NAME "mp_preview.data"
+#define MAX_FILE_NAME_LENGTH 256
+#define MAX_FILE_PATH_LENGTH (MAX_FILE_NAME_LENGTH - 20)
+
+#define CHECK_MM_ERROR(expr) \
+ do {\
+ int ret = 0; \
+ ret = expr; \
+ if (ret != 0) {\
+ g_print("[%s:%d] error code : %x \n", __func__, __LINE__, ret); \
+ return; \
+ } \
+ } while (0)
+
+
+#ifndef SAFE_FREE
+#define SAFE_FREE(x) \
+ if (x) {\
+ g_free(x);\
+ x = NULL;\
+ }
+#endif
+
+#define SENSOR_WHITEBALANCE_NUM 10
+#define SENSOR_COLOR_TONE_NUM 31
+#define SENSOR_FLIP_NUM 4
+#define SENSOR_PROGRAM_MODE_NUM 15
+#define SENSOR_FOCUS_NUM 6
+#define SENSOR_INPUT_ROTATION 4
+#define SENSOR_AF_SCAN_NUM 4
+#define SENSOR_ISO_NUM 8
+#define SENSOR_EXPOSURE_NUM 9
+#define SENSOR_IMAGE_FORMAT 20
+
+
+/*-----------------------------------------------------------------------
+ | LOCAL CONSTANT DEFINITIONS: |
+ -----------------------------------------------------------------------*/
+enum {
+ MODE_VIDEO_CAPTURE, /* recording and image capture mode */
+ MODE_AUDIO, /* audio recording*/
+ MODE_NUM,
+};
+
+enum {
+ MENU_STATE_INIT,
+ MENU_STATE_MAIN,
+ MENU_STATE_MAIN_SETTING,
+ MENU_STATE_DEVICE_STATE,
+ MENU_STATE_DEVICE_MANAGER,
+ MENU_STATE_NUM,
+};
+
+/*-----------------------------------------------------------------------
+ | LOCAL DATA TYPE DEFINITIONS: |
+ -----------------------------------------------------------------------*/
+typedef struct _cam_handle {
+ camera_h camera;
+ int type;
+ int is_multishot; /* flag for multishot mode */
+ int stillshot_count; /* stillshot count */
+ int multishot_count; /* multishot count */
+ char file_path[MAX_FILE_PATH_LENGTH]; /* file path for captured data */
+ int menu_state;
+} cam_handle_t;
+
+typedef struct {
+ int width[100];
+ int height[100];
+ int count;
+} resolution_stack;
+
+typedef struct {
+ camera_attr_exposure_mode_e mode;
+ int count;
+} exposure_stack;
+
+typedef struct {
+ camera_attr_iso_e mode;
+ int count;
+} iso_stack;
+
+
+void set_display(cam_handle_t *hcamcorder);
+void quit_test();
+gboolean cmd_input(GIOChannel *channel, GIOCondition condition, gpointer data);
+cam_handle_t *init_handle();
+void print_menu();
+void flush_stdin();
+
+#endif /* __CAMERA_TEST_H__ */
--- /dev/null
+/*
+ * camera_test_headed
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jeongmo Yang <jm80.yang@samsung.com>
+ *
+ * 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 f(r the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <Ecore.h>
+#include <Elementary.h>
+#include <appcore-efl.h>
+#include "camera_test.h"
+
+static int app_create(void *data);
+static int app_terminate(void *data);
+
+struct _appdata {
+ Evas_Object *win;
+ Evas_Object *eo;
+ Evas_Object *bg;
+ Evas_Object *rect;
+};
+typedef struct _appdata appdata;
+
+static struct appcore_ops ops = {
+ .create = app_create,
+ .terminate = app_terminate,
+};
+
+static appdata ad;
+
+
+void set_display(cam_handle_t *hcamcorder)
+{
+ int err = 0;
+ int display_type = 0;
+ bool check = FALSE;
+
+ while (!check) {
+ g_print("\n\tEnter the Display Type [1:Overlay, 2:Evas, 3:None] : ");
+ err = scanf("%d", &display_type);
+ flush_stdin();
+ if (err == EOF) {
+ g_print("\t!!!read input error!!!\n");
+ continue;
+ }
+
+ switch (display_type) {
+ case 1:
+ camera_set_display(hcamcorder->camera, CAMERA_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(ad.win));
+ check = TRUE;
+ break;
+ case 2:
+ camera_set_display(hcamcorder->camera, CAMERA_DISPLAY_TYPE_EVAS, GET_DISPLAY(ad.eo));
+ check = TRUE;
+ break;
+ case 3:
+ camera_set_display(hcamcorder->camera, CAMERA_DISPLAY_TYPE_NONE, NULL);
+ check = TRUE;
+ break;
+ default:
+ g_print("\t Invalid display type(%d)\n", display_type);
+ break;
+ }
+ }
+}
+
+
+void quit_test(void)
+{
+ elm_exit();
+}
+
+
+static int app_create(void *data)
+{
+ appdata *app_data = data;
+ int w = 0;
+ int h = 0;
+ Evas_Object *win = NULL;
+ Evas_Object *eo = NULL;
+ Evas_Object *bg = NULL;
+ Evas_Object *rect = NULL;
+
+ if (app_data == NULL) {
+ g_print("\t\nappdata is NULL\n");
+ return 0;
+ }
+
+ /* use gl backend */
+ elm_config_accel_preference_set("opengl");
+
+ win = elm_win_add(NULL, "camera_test", ELM_WIN_BASIC);
+ if (win) {
+ elm_win_title_set(win, "camera_test");
+ elm_win_borderless_set(win, EINA_TRUE);
+ elm_win_screen_size_get(win, NULL, NULL, &w, &h);
+ g_print("\n\tscreen size %dx%d\n\n", w, h);
+ evas_object_resize(win, w, h);
+ elm_win_autodel_set(win, EINA_TRUE);
+ elm_win_alpha_set(win, EINA_TRUE);
+ } else {
+ g_print("\n\tfailed to get window\n\n");
+ return 1;
+ }
+
+ bg = elm_bg_add(win);
+ if (bg) {
+ elm_win_resize_object_add(win, bg);
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(bg);
+ } else {
+ g_print("\n\tfailed to get elm bg\n\n");
+ return 1;
+ }
+
+ rect = evas_object_rectangle_add(evas_object_evas_get(win));
+ if (rect) {
+ evas_object_color_set(rect, 0, 0, 0, 0);
+ evas_object_render_op_set(rect, EVAS_RENDER_COPY);
+ } else {
+ g_print("\n\tfailed to get rectangle\n\n");
+ return 1;
+ }
+
+ elm_win_resize_object_add(win, rect);
+ evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(rect);
+
+ /* Create evas image object for EVAS surface */
+ eo = evas_object_image_add(evas_object_evas_get(win));
+ evas_object_image_size_set(eo, w, h);
+ evas_object_image_fill_set(eo, 0, 0, w, h);
+ evas_object_resize(eo, w, h);
+ evas_object_show(eo);
+
+ elm_win_activate(win);
+ evas_object_show(win);
+
+ app_data->win = win;
+ app_data->eo = eo;
+
+ print_menu();
+
+ return 0;
+}
+
+static int app_terminate(void *data)
+{
+ appdata *app_data = data;
+
+ if (app_data == NULL) {
+ g_print("\n\tappdata is NULL\n");
+ return 0;
+ }
+
+ return 0;
+}
+
+
+int main(int argc, char **argv)
+{
+ int bret;
+ cam_handle_t *handle = init_handle();
+ GIOChannel *stdin_channel = g_io_channel_unix_new(fileno(stdin));/* read from stdin */
+
+ g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)cmd_input, NULL);
+
+ memset(&ad, 0x0, sizeof(appdata));
+ ops.data = &ad;
+
+ bret = appcore_efl_main("camera_test_headed", &argc, &argv, &ops);
+
+ g_print("\n\treturn appcore_efl : %d\n\n", bret);
+
+ g_free(handle);
+ g_io_channel_unref(stdin_channel);
+
+ return bret;
+}
--- /dev/null
+/*
+ * camera_test_headless
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jeongmo Yang <jm80.yang@samsung.com>
+ *
+ * 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 f(r the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "camera_test.h"
+
+
+static GMainLoop *g_mainloop_camera_test;
+
+
+void set_display(cam_handle_t *hcamcorder)
+{
+ g_print("Display type : NULL for headless\n");
+ camera_set_display(hcamcorder->camera, CAMERA_DISPLAY_TYPE_NONE, NULL);
+}
+
+
+void quit_test(void)
+{
+ g_main_loop_quit(g_mainloop_camera_test);
+}
+
+
+int main(int argc, char **argv)
+{
+ cam_handle_t *handle = init_handle();
+ GIOChannel *stdin_channel = g_io_channel_unix_new(fileno(stdin));/* read from stdin */
+
+ g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)cmd_input, NULL);
+
+ init_handle();
+
+ print_menu();
+
+ g_mainloop_camera_test = g_main_loop_new(NULL, FALSE);
+
+ g_main_loop_run(g_mainloop_camera_test);
+
+ g_print("\n\treturn main loop\n\n");
+
+ g_main_loop_unref(g_mainloop_camera_test);
+
+ g_free(handle);
+ g_io_channel_unref(stdin_channel);
+
+ return 0;
+}
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-SET(fw_test "${fw_name}-test-headless")
-
-#INCLUDE_DIRECTORIES(../include)
-#link_directories(${CMAKE_SOURCE_DIR}/../)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED libtbm)
-FOREACH(flag ${${fw_test}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
- MESSAGE(${flag})
-ENDFOREACH()
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -pie -Wall")
-
-aux_source_directory(. sources)
-FOREACH(src ${sources})
- GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
- MESSAGE("${src_name}")
- ADD_EXECUTABLE(${src_name} ${src})
- TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
- INSTALL(TARGETS ${src_name} DESTINATION bin)
-
-ENDFOREACH()
+++ /dev/null
-/*
- * camera_test_headless
- *
- * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jeongmo Yang <jm80.yang@samsung.com>
- *
- * 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 f(r the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/*=======================================================================================
-| INCLUDE FILES |
-=======================================================================================*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <glib.h>
-#include <sys/time.h>
-#include <dlog.h>
-#include <camera_internal.h>
-#include <tbm_surface.h>
-#include <media_bridge_internal.h>
-
-/*-----------------------------------------------------------------------
-| GLOBAL VARIABLE DEFINITIONS: |
------------------------------------------------------------------------*/
-#define EXPORT_API __attribute__((__visibility__("default")))
-
-#ifdef PACKAGE
-#undef PACKAGE
-#endif
-#define PACKAGE "camera_test"
-
-static GMainLoop *g_mainloop_camera_test = NULL;
-static GIOChannel *stdin_channel;
-static camera_device_e camera_device;
-static GTimer *timer;
-static int g_camera_device_state_changed_cb_id;
-static int g_camera_device_connection_changed_cb_id;
-static int g_camera_preview_cb_dump;
-static int g_camera_extra_preview_cb_dump;
-static int g_camera_mp_preview_cb_dump;
-
-static struct timeval previous_time;
-static struct timeval current_time;
-static struct timeval result_time;
-
-static media_bridge_h bridge;
-
-/*-----------------------------------------------------------------------
-| GLOBAL CONSTANT DEFINITIONS: |
------------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------
-| IMPORTED VARIABLE DECLARATIONS: |
------------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------
-| IMPORTED FUNCTION DECLARATIONS: |
------------------------------------------------------------------------*/
-
-
-/*-----------------------------------------------------------------------
-| LOCAL #defines: |
------------------------------------------------------------------------*/
-#define DEFAULT_FILE_PATH "/home/owner/media"
-#define PREVIEW_CB_DUMP_FILE_NAME "preview.data"
-#define EXTRA_PREVIEW_CB_DUMP_FILE_NAME "extra_preview.data"
-#define MP_PREVIEW_CB_DUMP_FILE_NAME "mp_preview.data"
-#define MAX_FILE_NAME_LENGTH 256
-#define MAX_FILE_PATH_LENGTH (MAX_FILE_NAME_LENGTH - 20)
-
-#define CHECK_MM_ERROR(expr) \
- do {\
- int ret = 0; \
- ret = expr; \
- if (ret != 0) {\
- g_print("[%s:%d] error code : %x \n", __func__, __LINE__, ret); \
- return; \
- } \
- } while (0)
-
-
-#ifndef SAFE_FREE
-#define SAFE_FREE(x) \
- if (x) {\
- g_free(x);\
- x = NULL;\
- }
-#endif
-
-#define SENSOR_WHITEBALANCE_NUM 10
-#define SENSOR_COLOR_TONE_NUM 31
-#define SENSOR_FLIP_NUM 4
-#define SENSOR_PROGRAM_MODE_NUM 15
-#define SENSOR_FOCUS_NUM 6
-#define SENSOR_INPUT_ROTATION 4
-#define SENSOR_AF_SCAN_NUM 4
-#define SENSOR_ISO_NUM 8
-#define SENSOR_EXPOSURE_NUM 9
-#define SENSOR_IMAGE_FORMAT 20
-
-
-/*-----------------------------------------------------------------------
- | LOCAL CONSTANT DEFINITIONS: |
- -----------------------------------------------------------------------*/
-enum {
- MODE_VIDEO_CAPTURE, /* recording and image capture mode */
- MODE_AUDIO, /* audio recording*/
- MODE_NUM,
-};
-
-enum {
- MENU_STATE_INIT,
- MENU_STATE_MAIN,
- MENU_STATE_MAIN_SETTING,
- MENU_STATE_DEVICE_STATE,
- MENU_STATE_DEVICE_MANAGER,
- MENU_STATE_NUM,
-};
-
-/*-----------------------------------------------------------------------
- | LOCAL DATA TYPE DEFINITIONS: |
- -----------------------------------------------------------------------*/
-typedef struct _cam_handle {
- camera_h camera;
- int type;
- int is_multishot; /* flag for multishot mode */
- int stillshot_count; /* stillshot count */
- int multishot_count; /* multishot count */
- char file_path[MAX_FILE_PATH_LENGTH]; /* file path for captured data */
- int menu_state;
- unsigned long long elapsed_time;
-} cam_handle_t;
-
-typedef struct {
- int width[100];
- int height[100];
- int count;
-} resolution_stack;
-
-typedef struct {
- camera_attr_exposure_mode_e mode;
- int count;
-} exposure_stack;
-
-typedef struct {
- camera_attr_iso_e mode;
- int count;
-} iso_stack;
-
-
-/*---------------------------------------------------------------------------
- | LOCAL VARIABLE DEFINITIONS: |
- ---------------------------------------------------------------------------*/
-static cam_handle_t *hcamcorder;
-static camera_device_manager_h g_device_manager;
-
-const char *wb[SENSOR_WHITEBALANCE_NUM] = {
- "None",
- "Auto",
- "Daylight",
- "Cloudy",
- "Fluoroscent",
- "Incandescent",
- "Shade",
- "Horizon",
- "Flash",
- "Custom",
-};
-
-const char *ct[SENSOR_COLOR_TONE_NUM] = {
- "NONE",
- "MONO",
- "SEPIA",
- "NEGATIVE",
- "BLUE",
- "GREEN",
- "AQUA",
- "VIOLET",
- "ORANGE",
- "GRAY",
- "RED",
- "ANTIQUE",
- "WARM",
- "PINK",
- "YELLOW",
- "PURPLE",
- "EMBOSS",
- "OUTLINE",
- "SOLARIZATION",
- "SKETCH",
- "WASHED",
- "VINTAGE_WARM",
- "VINTAGE_COLD",
- "POSTERIZATION",
- "CARTOON",
- "SELECTVE_COLOR_RED",
- "SELECTVE_COLOR_GREEN",
- "SELECTVE_COLOR_BLUE",
- "SELECTVE_COLOR_YELLOW",
- "SELECTVE_COLOR_RED_YELLOW",
- "GRAPHICS"
-};
-
-const char *sensor_flip[SENSOR_FLIP_NUM] = {
- "NONE",
- "HORIZONTAL",
- "VERTICAL",
- "BOTH"
-};
-
-const char *program_mode[SENSOR_PROGRAM_MODE_NUM] = {
- "NORMAL",
- "PORTRAIT",
- "LANDSCAPE",
- "SPORTS",
- "PARTY_N_INDOOR",
- "BEACH_N_INDOOR",
- "SUNSET",
- "DUSK_N_DAWN",
- "FALL_COLOR",
- "NIGHT_SCENE",
- "FIREWORK",
- "TEXT",
- "SHOW_WINDOW",
- "CANDLE_LIGHT",
- "BACKLIGHT",
-};
-
-const char *focus_mode[SENSOR_FOCUS_NUM] = {
- "None",
- "Pan",
- "Auto",
- "Manual",
- "Touch Auto",
- "Continuous Auto",
-};
-
-const char *camera_rotation[SENSOR_INPUT_ROTATION] = {
- "None",
- "90",
- "180",
- "270",
-};
-
-const char *iso_mode[SENSOR_ISO_NUM] = {
- "ISO Auto",
- "ISO 50",
- "ISO 100",
- "ISO 200",
- "ISO 400",
- "ISO 800",
- "ISO 1600",
- "ISO 3200",
-};
-
-const char *exposure_mode[SENSOR_EXPOSURE_NUM] = {
- "AE off",
- "AE all mode",
- "AE center mode",
- "AE spot 1 mode",
- "AE custom mode",
-};
-
-const char *image_fmt[SENSOR_IMAGE_FORMAT] = {
- "NV12",
- "NV12T",
- "NV16",
- "NV21",
- "YUYV",
- "UYVY",
- "422P",
- "I420",
- "YV12",
- "RGB565",
- "RGB888",
- "RGBA",
- "ARGB",
- "JPEG",
- "ITLV(YUYV+JPEG, but should not be seen)",
- "H264",
- "INVZ",
- "MJPEG",
- "VP8",
- "VP9"
-};
-
-const char *face_zoom_mode[] = {
- "Face Zoom OFF",
- "Face Zoom ON",
-};
-
-const char *display_mode[] = {
- "Letter Box mode",
- "Original Size mode",
- "Full Screen mode",
- "Cropped Full Screen mode",
- "ROI mode",
-};
-
-const char *capture_sound[] = {
- "Default",
- "Extra 01",
- "Extra 02",
-};
-
-const char *rotate_mode[] = {
- "0",
- "90",
- "180",
- "270",
-};
-
-const char* strobe_mode[] = {
- "Strobe OFF",
- "Strobe ON",
- "Strobe Auto",
- "Strobe RedEyeReduction",
- "Strobe SlowSync",
- "Strobe FrontCurtain",
- "Strobe RearCurtain",
- "Strobe Permanent",
-};
-
-const char *detection_mode[2] = {
- "Face Detection OFF",
- "Face Detection ON",
-};
-
-const char *wdr_mode[] = {
- "WDR OFF",
- "WDR ON",
- "WDR AUTO",
-};
-
-const char *af_scan[SENSOR_AF_SCAN_NUM] = {
- "None",
- "Normal",
- "Macro mode",
- "Full mode",
-};
-
-const char *hdr_mode[] = {
- "HDR OFF",
- "HDR ON",
- "HDR ON and Original",
-};
-
-const char *ahs_mode[] = {
- "Anti-handshake OFF",
- "Anti-handshake ON",
- "Anti-handshake AUTO",
- "Anti-handshake MOVIE",
-};
-
-const char *vs_mode[] = {
- "Video-stabilization OFF",
- "Video-stabilization ON",
-};
-
-const char *visible_mode[] = {
- "Display OFF",
- "Display ON",
-};
-
-const char *facing_direction[] = {
- "REAR",
- "FRONT",
-};
-
-
-/*---------------------------------------------------------------------------
- | LOCAL FUNCTION PROTOTYPES: |
- ---------------------------------------------------------------------------*/
-static void print_menu();
-static gboolean cmd_input(GIOChannel *channel, GIOCondition condition, gpointer data);
-static gboolean mode_change(gchar buf);
-int camcordertest_set_attr_int(const char* attr_subcategory, int value);
-
-
-static void __release_media_bridge()
-{
- if (bridge) {
- media_bridge_unset_source(bridge); /* not mandatory, it will be done in media_bridge_destroy() */
- media_bridge_destroy(bridge);
- bridge = NULL;
- }
-}
-
-static inline void flush_stdin()
-{
- int ch;
- while ((ch = getchar()) != EOF && ch != '\n');
-}
-
-static gboolean _release_idle_event_callback(void *data)
-{
- g_print("destroy camera handle\n\n");
-
- camera_destroy(hcamcorder->camera);
- hcamcorder->camera = NULL;
- hcamcorder->menu_state = MENU_STATE_INIT;
-
- print_menu();
-
- return 0;
-}
-
-static void _camera_error_cb(int error, camera_state_e current_state, void *user_data)
-{
- g_print("\n\n\tERROR [0x%x], current state %d\n", error, current_state);
-
- switch (error) {
- case CAMERA_ERROR_RESOURCE_CONFLICT:
- g_print("\t\t[CAMERA_ERROR_RESOURCE_CONFLICT]\n\n");
- break;
- case CAMERA_ERROR_SECURITY_RESTRICTED:
- g_print("\t\t[CAMERA_ERROR_SECURITY_RESTRICTED]\n\n");
- break;
- case CAMERA_ERROR_SERVICE_DISCONNECTED:
- g_print("\t\t[CAMERA_ERROR_SERVICE_DISCONNECTED]\n\n");
- g_idle_add_full(G_PRIORITY_DEFAULT,
- (GSourceFunc)_release_idle_event_callback,
- NULL, NULL);
- break;
- default:
- break;
- }
-}
-
-static void _camera_state_changed_cb(camera_state_e previous, camera_state_e current, bool by_policy, void *user_data)
-{
- g_print("\n\tcamera state changed %d -> %d\n", previous, current);
-}
-
-static void _camera_device_state_changed_cb(camera_device_e device, camera_device_state_e state, void *user_data)
-{
- g_print("\n\tcamera device[%d] state changed to %d\n", device, state);
-}
-
-static void _camera_device_connection_changed_cb(camera_device_type_e type, camera_device_e device,
- const char *name, const char *id, int extra_preview_stream_num, bool is_connected, void *user_data)
-{
- g_print("\n\tcamera device changed[is_connected:%d][Type:%d,index:%d,name:%s,id:%s,exstream:%d]\n",
- is_connected, type, device, name, id, extra_preview_stream_num);
-}
-
-static bool _camera_supported_device_cb(camera_device_type_e type, camera_device_e device,
- const char *name, const char *id, int extra_preview_stream_num, void *user_data)
-{
- g_print("\n\tcamera supported device[Type:%d,index:%d,name:%s,id:%s,exstream:%d]\n",
- type, device, name, id, extra_preview_stream_num);
-
- return true;
-}
-
-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",
- previous, current, policy);
-}
-
-static void _camera_interrupt_started_cb(camera_policy_e policy, camera_state_e state, void *user_data)
-{
- g_print("\n\tcamera interrupt started callback called[state %d, policy %d]\n", state, policy);
-}
-
-static void _dump_preview_data(camera_preview_data_s *frame, const char *file_name)
-{
- char dump_path[MAX_FILE_NAME_LENGTH] = {'\0',};
- FILE *fp = NULL;
-
- if (!frame) {
- g_print("\n[DUMP_PREVIEW_DATA] NULL frame\n");
- return;
- }
-
- snprintf(dump_path, MAX_FILE_NAME_LENGTH, "%s/%s", DEFAULT_FILE_PATH, file_name);
-
- fp = fopen(dump_path, "a");
- if (fp == NULL) {
- g_print("\n[DUMP_PREVIEW_DATA] file[%s] open failed\n", dump_path);
- return;
- }
-
- switch (frame->format) {
- case CAMERA_PIXEL_FORMAT_RGBA:
- /* fall through */
- case CAMERA_PIXEL_FORMAT_ARGB:
- fwrite(frame->data.rgb_plane.data, 1, frame->data.rgb_plane.size, fp);
- break;
- case CAMERA_PIXEL_FORMAT_INVZ:
- fwrite(frame->data.depth_plane.data, 1, frame->data.depth_plane.size, fp);
- break;
- case CAMERA_PIXEL_FORMAT_H264:
- /* fall through */
- case CAMERA_PIXEL_FORMAT_MJPEG:
- /* fall through */
- case CAMERA_PIXEL_FORMAT_VP8:
- /* fall through */
- case CAMERA_PIXEL_FORMAT_VP9:
- fwrite(frame->data.encoded_plane.data, 1, frame->data.encoded_plane.size, fp);
- break;
- default:
- switch (frame->num_of_planes) {
- case 1:
- fwrite(frame->data.single_plane.yuv, 1, frame->data.single_plane.size, fp);
- break;
- case 2:
- fwrite(frame->data.double_plane.y, 1, frame->data.double_plane.y_size, fp);
- fwrite(frame->data.double_plane.uv, 1, frame->data.double_plane.uv_size, fp);
- break;
- case 3:
- fwrite(frame->data.triple_plane.y, 1, frame->data.triple_plane.y_size, fp);
- fwrite(frame->data.triple_plane.u, 1, frame->data.triple_plane.u_size, fp);
- fwrite(frame->data.triple_plane.v, 1, frame->data.triple_plane.v_size, fp);
- break;
- default:
- break;
- }
- break;
- }
-
- g_print("[DUMP_PREVIEW_DATA] file[%s] write done\n", dump_path);
-
- fclose(fp);
-}
-
-static void _camera_print_preview_info(camera_preview_data_s *frame)
-{
- if (!frame) {
- g_print("\n[PREVIEW_CB] NULL frame!\n");
- return;
- }
-
- g_print("format[%d] res[%dx%d] num plane[%d] ",
- frame->format, frame->width, frame->height, frame->num_of_planes);
-
- if (frame->num_of_planes == 1) {
- g_print("size [%d]\n",
- frame->data.single_plane.size);
- } else if (frame->num_of_planes == 2) {
- g_print("size Y[%d] UV[%d]\n",
- frame->data.double_plane.y_size,
- frame->data.double_plane.uv_size);
- } else if (frame->num_of_planes == 3) {
- g_print("size Y[%d] U[%d] V[%d]\n",
- frame->data.triple_plane.y_size,
- frame->data.triple_plane.u_size,
- frame->data.triple_plane.v_size);
- }
-}
-
-static void _camera_preview_cb(camera_preview_data_s *frame, void *user_data)
-{
- int ret = CAMERA_ERROR_NONE;
- camera_h cam_handle = (camera_h)user_data;
- camera_rotation_e rotation = CAMERA_ROTATION_NONE;
-
- if (!cam_handle || !frame) {
- g_print("\n[PREVIEW_CB] NULL param! %p %p\n", cam_handle, frame);
- return;
- }
-
- ret = camera_attr_get_preview_frame_rotation(cam_handle, &rotation);
- if (ret != CAMERA_ERROR_NONE)
- g_print("[PREVIEW_CB] get preview frame rotation failed[0x%x]\n", ret);
-
- g_print("[PREVIEW_CB] preview[rotation:%d] callback - ", rotation);
-
- _camera_print_preview_info(frame);
-
- if (g_camera_preview_cb_dump)
- _dump_preview_data(frame, PREVIEW_CB_DUMP_FILE_NAME);
-}
-
-static void _camera_extra_preview_cb(camera_preview_data_s *frame, int stream_id, void *user_data)
-{
- if (!frame) {
- g_print("\n[PREVIEW_CB] NULL frame!\n");
- return;
- }
-
- g_print("[EXTRA_PREVIEW_CB][stream_id:%d] preview callback - ", stream_id);
-
- _camera_print_preview_info(frame);
-
- if (g_camera_extra_preview_cb_dump)
- _dump_preview_data(frame, EXTRA_PREVIEW_CB_DUMP_FILE_NAME);
-}
-
-static void _dump_media_packet_data(media_packet_h pkt, const char *file_name)
-{
- int ret = 0;
- unsigned int i = 0;
- bool has_surface = false;
- FILE *fp = NULL;
- char dump_path[MAX_FILE_NAME_LENGTH] = {'\0',};
- tbm_surface_h surface = NULL;
- tbm_surface_info_s s_info;
- void *data = NULL;
- uint64_t data_size = 0;
-
- if (!pkt) {
- g_print("\n[DUMP_MEDIA_PACKET_DATA] NULL packet\n");
- return;
- }
-
- snprintf(dump_path, MAX_FILE_NAME_LENGTH, "%s/%s", DEFAULT_FILE_PATH, file_name);
- fp = fopen(dump_path, "a");
- if (fp == NULL) {
- g_print("\n[DUMP_MEDIA_PACKET_DATA] file[%s] open failed ====\n", dump_path);
- goto _DUMP_MEDIA_PACKET_DATA_OUT;
- }
-
- ret = media_packet_has_tbm_surface_buffer(pkt, &has_surface);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- g_print("\n[DUMP_MEDIA_PACKET_DATA] has tbm surface failed[0x%x] ====\n", ret);
- goto _DUMP_MEDIA_PACKET_DATA_OUT;
- }
-
- if (has_surface) {
- ret = media_packet_get_tbm_surface(pkt, &surface);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- g_print("\n[DUMP_MEDIA_PACKET_DATA] get tbm surface failed[0x%x] ====\n", ret);
- goto _DUMP_MEDIA_PACKET_DATA_OUT;
- }
-
- ret = tbm_surface_get_info(surface, &s_info);
- if (ret != TBM_SURFACE_ERROR_NONE) {
- g_print("\n[DUMP_MEDIA_PACKET_DATA] get tbm surface info failed[0x%x] ====\n", ret);
- goto _DUMP_MEDIA_PACKET_DATA_OUT;
- }
-
- g_print(" tbm surface [%dx%d], total size[%u]\n",
- s_info.width, s_info.height, s_info.size);
-
- for (i = 0 ; i < s_info.num_planes ; i++) {
- g_print(" plane[%d][%p] stride[%u] size[%u]\n",
- i, s_info.planes[i].ptr, s_info.planes[i].stride, s_info.planes[i].size);
- fwrite(s_info.planes[i].ptr, 1, s_info.planes[i].size, fp);
- }
- } else {
- ret = media_packet_get_buffer_data_ptr(pkt, &data);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- g_print("\n[DUMP_MEDIA_PACKET_DATA] get data ptr failed[0x%x] ====\n", ret);
- goto _DUMP_MEDIA_PACKET_DATA_OUT;
- }
-
- ret = media_packet_get_buffer_size(pkt, &data_size);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- g_print("\n[DUMP_MEDIA_PACKET_DATA] get data size failed[0x%x] ====\n", ret);
- goto _DUMP_MEDIA_PACKET_DATA_OUT;
- }
-
- g_print(" no tbm surface, data[%p], size[%"PRIu64"]\n", data, data_size);
-
- fwrite(data, 1, data_size, fp);
- }
-
-_DUMP_MEDIA_PACKET_DATA_OUT:
- if (fp)
- fclose(fp);
-}
-
-static void _camera_media_packet_preview_cb(media_packet_h pkt, void *user_data)
-{
- int ret = 0;
- int width = 0;
- int height = 0;
- media_format_h fmt = NULL;
- media_format_mimetype_e type = MEDIA_FORMAT_I420;
-
- if (!pkt) {
- g_print("\n[MP_PREVIEW_CB] NULL packet!\n");
- return;
- }
-
- ret = media_packet_get_format(pkt, &fmt);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- g_print("\n[MP_PREVIEW_CB] get media format failed[0x%x]", ret);
- goto _MEDIA_PACKET_PREVIEW_CB_OUT;
- }
-
- ret = media_format_get_video_info(fmt, &type, &width, &height, NULL, NULL);
- if (ret != MEDIA_FORMAT_ERROR_NONE) {
- g_print("\n[MP_PREVIEW_CB] get video info failed[0x%x]", ret);
- goto _MEDIA_PACKET_PREVIEW_CB_OUT;
- }
-
- g_print("[MP_PREVIEW_CB] media_packet_preview_cb[mimetype:0x%x, %dx%d]\n", type, width, height);
-
- if (g_camera_mp_preview_cb_dump)
- _dump_media_packet_data(pkt, MP_PREVIEW_CB_DUMP_FILE_NAME);
-
-_MEDIA_PACKET_PREVIEW_CB_OUT:
- if (fmt) {
- media_format_unref(fmt);
- fmt = NULL;
- }
-
- media_packet_unref(pkt);
-}
-
-static bool preview_resolution_cb(int width, int height, void *user_data)
-{
- resolution_stack *data = (resolution_stack *)user_data;
-
- if (data == NULL) {
- g_print("NULL data\n");
- return false;
- }
-
- data->width[data->count] = width;
- data->height[data->count] = height;
-
- g_print("\t%d. %dx%d\n", data->count, width, height);
-
- data->count++;
-
- return true;
-}
-
-static bool capture_resolution_test_cb(int width, int height, void *user_data)
-{
- resolution_stack *data = (resolution_stack *)user_data;
-
- if (data == NULL) {
- g_print("NULL data\n");
- return false;
- }
-
- data->width[data->count] = width;
- data->height[data->count] = height;
-
- g_print("\t%d. %dx%d\n", data->count, width, height);
-
- data->count++;
-
- return true;
-}
-
-static bool af_mode_foreach_cb(camera_attr_iso_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, af_scan[mode]);
- return true;
-}
-
-static bool exposure_mode_cb(camera_attr_af_mode_e mode, void *user_data)
-{
- exposure_stack *data = (exposure_stack *)user_data;
-
- if (data == NULL) {
- g_print("NULL data\n");
- return false;
- }
-
- data->mode = mode;
- data->count++;
-
- g_print("\t%d. %s\n", mode, exposure_mode[mode]);
- return true;
-}
-
-static bool iso_mode_cb(camera_attr_iso_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, iso_mode[mode]);
- return true;
-}
-
-static bool camera_rotation_cb(camera_rotation_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, camera_rotation[mode]);
- return true;
-}
-
-static bool camera_flip_cb(camera_flip_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, sensor_flip[mode]);
- return true;
-}
-
-static bool preview_format_cb(camera_pixel_format_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, image_fmt[mode]);
- return true;
-}
-
-static bool white_balance_cb(camera_attr_whitebalance_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, wb[mode]);
- return true;
-}
-
-static bool colortone_cb(camera_attr_effect_mode_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, ct[mode]);
- return true;
-}
-
-static bool program_mode_cb(camera_attr_scene_mode_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, program_mode[mode]);
- return true;
-}
-
-static bool strobe_mode_cb(camera_attr_flash_mode_e mode, void *user_data)
-{
- g_print("\t%d. %s\n", mode, strobe_mode[mode]);
- return true;
-}
-
-static void _face_detected(camera_detected_face_s *faces, int count, void *user_data)
-{
- int i;
-
- g_print("\tface detected!! - count %d\n", count);
-
- for (i = 0 ; i < count ; i++)
- g_print("\t%d] %dx%d\n", faces[i].id, faces[i].x, faces[i].y);
-}
-
-static void _file_write(char *path, void *data, int size)
-{
- FILE *fp = NULL;
-
- if (!path || !data || size <= 0) {
- g_print("\n\tERROR %p %p %d\n", path, data, size);
- return;
- }
-
- fp = fopen(path, "w");
- if (fp) {
- g_print("\n\topen success [%s]\n", path);
- if (fwrite(data, size, 1, fp) != 1)
- g_print("\n\twrite error! errno %d\n", errno);
- else
- g_print("\n\twrite success [%s]\n", path);
-
- fclose(fp);
- fp = NULL;
- } else {
- g_print("\n\topen error! [%s], errno %d\n", path, errno);
- }
-}
-
-static void capturing_cb(camera_image_data_s* image, camera_image_data_s* postview, camera_image_data_s* thumbnail, void *user_data)
-{
- char m_filename[MAX_FILE_NAME_LENGTH];
-
- /* main image */
- if (image) {
- if (hcamcorder->is_multishot) {
- snprintf(m_filename, MAX_FILE_NAME_LENGTH, "%s/multishot%03d.jpg",
- hcamcorder->file_path, hcamcorder->multishot_count++);
- } else {
- snprintf(m_filename, MAX_FILE_NAME_LENGTH, "%s/stillshot%03d.jpg",
- hcamcorder->file_path, hcamcorder->stillshot_count++);
- }
-
- _file_write(m_filename, image->data, image->size);
- }
-}
-
-static void capture_completed_cb(void *user_data)
-{
- camera_start_preview(hcamcorder->camera);
-}
-
-static void print_menu()
-{
- switch (hcamcorder->menu_state) {
- case MENU_STATE_INIT:
- g_print("\n\t=======================================\n");
- g_print("\t CAMERA_TESTSUITE\n");
- g_print("\t=======================================\n");
- g_print("\t '1' Video Capture\n");
- g_print("\t '2' Device State\n");
- g_print("\t '3' Device Manager\n");
- g_print("\t 'q' Exit\n");
- g_print("\t=======================================\n");
- break;
- case MENU_STATE_MAIN:
- g_print("\n\t=======================================\n");
- g_print("\t Video Capture (CAMERA%d)\n", camera_device);
- g_print("\t=======================================\n");
- g_print("\t '1' Stillshot test\n");
- g_print("\t '2' Multishot test\n");
- g_print("\t '3' Setting\n");
- g_print("\t '4' Change device (CAMERA0 <-> CAMERA1)\n");
- g_print("\t '5' Set/Unset preview callback\n");
- g_print("\t '6' Set/Unset extra preview callback\n");
- g_print("\t '7' Set/Unset media packet preview callback\n");
- g_print("\t 'b' back\n");
- g_print("\t=======================================\n");
- break;
- 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_MANAGER:
- 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' Foreach supported camera device\n");
- g_print("\t '3' Add camera device connection changed callback\n");
- g_print("\t '4' Remove camera device connection changed callback\n");
- g_print("\t '9' 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");
- g_print("\t >>>>>>>>>>>>>>>>>>>>>>>>>>>> [Camera] \n");
- g_print("\t '0' Preview resolution \n");
- g_print("\t '1' Capture resolution \n");
- g_print("\t '2' Digital zoom level \n");
- g_print("\t '3' AF mode \n");
- g_print("\t '4' AF scan range \n");
- g_print("\t '5' Exposure mode \n");
- g_print("\t '6' Exposure value \n");
- g_print("\t '7' F number \n");
- g_print("\t '8' Display reuse hint \n");
- g_print("\t '9' Manual Focus \n");
- g_print("\t 'i' ISO \n");
- g_print("\t 'r' Rotate camera input \n");
- g_print("\t 'f' Flip camera input \n");
- g_print("\t 'j' Jpeg quality \n");
- g_print("\t 'p' Picture format \n");
- g_print("\t 'E' EXIF orientation \n");
- g_print("\t 'F' Get facing direction of camera module\n");
- g_print("\t 's' Extra preview stream format\n");
- g_print("\t 'B' Extra preview bitrate\n");
- g_print("\t 'V' Extra preview GOP interval\n");
- g_print("\t >>>>>>>>>>>>>>>>>>>> [Display/Filter]\n");
- g_print("\t 'v' Visible \n");
- g_print("\t 'o' Output mode \n");
- g_print("\t 'y' Rotate display \n");
- g_print("\t 'Y' Flip display \n");
- g_print("\t 'g' Brightness \n");
- g_print("\t 'c' Contrast \n");
- g_print("\t 'h' Hue \n");
- g_print("\t 'w' White balance \n");
- g_print("\t 't' Color tone \n");
- g_print("\t 'd' WDR \n");
- g_print("\t 'e' EV program mode \n");
- g_print("\t 'R' Display ROI area \n");
- g_print("\t >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [etc.]\n");
- g_print("\t 'z' Strobe (Flash) \n");
- g_print("\t 'S' Strobe (Flash) state\n");
- g_print("\t 'G' Strobe (Flash) brightness\n");
- g_print("\t 'x' Capture mode (Still/Multishot/HDR)\n");
- g_print("\t 'l' Face detection \n");
- g_print("\t 'k' Anti-handshake \n");
- g_print("\t 'K' Video-stabilization \n");
- g_print("\t 'u' Touch AF area \n");
- g_print("\t 'n' Set file path to write captured image\n");
- g_print("\t 'm' Set media bridge\n");
- g_print("\t 'b' back\n");
- g_print("\t=======================================\n");
- break;
- default:
- g_print("\n\tunknow menu state !!\n");
- return;
- }
-
- g_print("\tCommand >> ");
-}
-
-
-static void main_menu(gchar buf)
-{
- int err = 0;
- int interval = 0;
- int count = 0;
- int set_cb = 0;
-
- switch (buf) {
- case '1': /* Capture */
- hcamcorder->is_multishot = FALSE;
- camera_attr_set_image_quality(hcamcorder->camera, 100);
- camera_set_capture_format(hcamcorder->camera, CAMERA_PIXEL_FORMAT_JPEG);
- camera_start_capture(hcamcorder->camera, capturing_cb, capture_completed_cb, hcamcorder);
- break;
- case '2': /* multishot Capture */
- g_print("multishot capture");
- hcamcorder->is_multishot = TRUE;
- g_print("\n\tinput interval(ms) : ");
- err = scanf("%d", &interval);
- flush_stdin();
- g_print("\n\tinput count : ");
- err = scanf("%d", &count);
- flush_stdin();
- camera_attr_set_image_quality(hcamcorder->camera, 100);
- camera_set_capture_format(hcamcorder->camera, CAMERA_PIXEL_FORMAT_JPEG);
- camera_start_continuous_capture(hcamcorder->camera, count, interval, capturing_cb, NULL, NULL);
- sleep(3);
- camera_start_preview(hcamcorder->camera);
- break;
- case '3': /* Setting */
- hcamcorder->menu_state = MENU_STATE_MAIN_SETTING;
- break;
- case '4': /* Change device (CAMERA0 <-> CAMERA1) */
- camera_set_display_reuse_hint(hcamcorder->camera, true);
-
- camera_stop_preview(hcamcorder->camera);
-
- if (hcamcorder->type == CAMERA_DEVICE_CAMERA0)
- hcamcorder->type = CAMERA_DEVICE_CAMERA1;
- else
- hcamcorder->type = CAMERA_DEVICE_CAMERA0;
-
- camera_change_device(hcamcorder->camera, hcamcorder->type);
-
- camera_set_error_cb(hcamcorder->camera, _camera_error_cb, NULL);
- camera_set_state_changed_cb(hcamcorder->camera, _camera_state_changed_cb, NULL);
- camera_set_interrupted_cb(hcamcorder->camera, _camera_interrupted_cb, NULL);
- camera_set_interrupt_started_cb(hcamcorder->camera, _camera_interrupt_started_cb, NULL);
-
- camera_set_display_mode(hcamcorder->camera, CAMERA_DISPLAY_MODE_LETTER_BOX);
-
- camera_start_preview(hcamcorder->camera);
- break;
- case '5':
- g_print("* Preview Callback\n");
- g_print("\tUnset[0] / Set[Others] :");
- err = scanf("%d", &set_cb);
- flush_stdin();
- if (set_cb) {
- g_print("\n\tDump preview data to file - NO[0], YES[Others] : ");
- err = scanf("%d", &g_camera_preview_cb_dump);
- flush_stdin();
- err = camera_set_preview_cb(hcamcorder->camera, _camera_preview_cb, hcamcorder->camera);
- } else {
- err = camera_unset_preview_cb(hcamcorder->camera);
- }
- g_print("\tresult[0x%x]\n\n", err);
- break;
- case '6':
- g_print("* Extra Preview Callback\n");
- g_print("\tUnset[0] / Set[Others] :");
- err = scanf("%d", &set_cb);
- flush_stdin();
- if (set_cb) {
- g_print("\n\tDump extra preview data to file - NO[0], YES[Others] : ");
- err = scanf("%d", &g_camera_extra_preview_cb_dump);
- flush_stdin();
- err = camera_set_extra_preview_cb(hcamcorder->camera, _camera_extra_preview_cb, hcamcorder->camera);
- } else {
- err = camera_unset_extra_preview_cb(hcamcorder->camera);
- }
- g_print("\tresult[0x%x]\n\n", err);
- break;
- case '7':
- g_print("* Media Packet Preview Callback\n");
- g_print("\tUnset[0] / Set[Others] :");
- err = scanf("%d", &set_cb);
- flush_stdin();
- if (set_cb) {
- g_print("\n\tDump media packet preview data to file - NO[0], YES[Others] : ");
- err = scanf("%d", &g_camera_mp_preview_cb_dump);
- flush_stdin();
- err = camera_set_media_packet_preview_cb(hcamcorder->camera, _camera_media_packet_preview_cb, hcamcorder->camera);
- } else {
- err = camera_unset_media_packet_preview_cb(hcamcorder->camera);
- }
- g_print("\tresult[0x%x]\n\n", err);
- break;
- case 'b': /* back */
- __release_media_bridge();
-
- camera_stop_preview(hcamcorder->camera);
- camera_destroy(hcamcorder->camera);
- hcamcorder->camera = NULL;
- hcamcorder->menu_state = MENU_STATE_INIT;
- break;
- default:
- g_print("\t Invalid input \n");
- break;
- }
-}
-
-
-static void setting_menu(gchar buf)
-{
- int bret = FALSE;
- int idx = 0;
- int min = 0;
- int max = 0;
- int i = 0;
- int err = 0;
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
- int result = 0;
- int set_bridge = 0;
- int stream_id;
- int pixel_format;
- int fps;
- int bitrate;
- int interval;
-
- switch (buf) {
- /* Camera setting */
- case '0': /* Setting > Preview Resolution setting */
- g_print("\t* Select the preview resolution!\n");
- resolution_stack resolution_list;
- resolution_list.count = 0;
-
- camera_foreach_supported_preview_resolution(hcamcorder->camera,
- preview_resolution_cb, &resolution_list);
-
- g_print("\tCommand >> ");
-
- err = scanf("%d", &idx);
- flush_stdin();
- if (resolution_list.count > idx && idx >= 0) {
- g_print("\t-----------------PREVIEW RESOLUTION (%dx%d)---------------------\n",
- resolution_list.width[idx], resolution_list.height[idx]);
-
- result = camera_set_preview_resolution(hcamcorder->camera,
- resolution_list.width[idx], resolution_list.height[idx]);
- } else {
- g_print("\tInvalid command [%d]\n", idx);
- result = -1;
- }
- resolution_list.count = 0;
- if (result == CAMERA_ERROR_NONE)
- g_print("\tPASS\n");
- else
- g_print("\tFAIL\n");
- break;
- case '1': /* Setting > Capture Resolution setting */
- g_print("\t* Select the preview resolution!\n");
- resolution_list.count = 0;
-
- camera_foreach_supported_capture_resolution(hcamcorder->camera,
- capture_resolution_test_cb, &resolution_list);
-
- g_print("\tCommand > ");
-
- err = scanf("%d", &idx);
- flush_stdin();
- if (resolution_list.count > idx && idx >= 0) {
- g_print("\t-----------------CAPTURE RESOLUTION (%dx%d)---------------------\n",
- resolution_list.width[idx], resolution_list.height[idx]);
-
- result = camera_set_capture_resolution(hcamcorder->camera,
- resolution_list.width[idx], resolution_list.height[idx]);
- } else {
- g_print("\tInvalid command [%d]\n", idx);
- result = -1;
- }
- resolution_list.count = 0;
- if (result == CAMERA_ERROR_NONE)
- g_print("\tPASS\n");
- else
- g_print("\tFAIL\n");
- break;
- case '2': /* Setting > Digital zoom level */
- camera_attr_get_zoom_range(hcamcorder->camera, &min, &max);
- if (min > max) {
- g_print("\tDigital Zoom Not supported\n");
- } else {
- g_print("\tDigital zoom level [%d ~ %d] > ", min, max);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_zoom(hcamcorder->camera, idx);
- }
- break;
- case '3': /* Setting > AF mode */
- g_print("\tAuto Focus [1:Start, 2:Stop] > ");
- err = scanf("%d", &idx);
- flush_stdin();
- switch (idx) {
- case 1:
- camera_start_focusing(hcamcorder->camera, 0);
- break;
- case 2:
- camera_cancel_focusing(hcamcorder->camera);
- break;
- default:
- g_print("\tInvalid command [%d]\n", idx);
- break;
- }
- break;
- case '4': /* Setting > AF scan range */
- g_print("\t* AF scan range !\n");
- camera_attr_foreach_supported_af_mode(hcamcorder->camera, (camera_attr_supported_af_mode_cb)af_mode_foreach_cb, NULL);
- g_print("\tCommand > ");
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_af_mode(hcamcorder->camera, idx);
- break;
- case '5': /* Setting > Exposure mode */
- g_print("* Exposure mode!\n");
- camera_attr_foreach_supported_exposure_mode(hcamcorder->camera, (camera_attr_supported_exposure_mode_cb)exposure_mode_cb, NULL);
- g_print("\n Select Exposure mode \n");
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_exposure_mode(hcamcorder->camera, idx);
- break;
-
- case '6': /* Setting > Exposure value */
- camera_attr_get_exposure_range(hcamcorder->camera, &min, &max);
- if (min >= max)
- g_print("Not supported !! \n");
- else {
- g_print("\n Select Exposure mode min%d -max %d\n", min, max);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_exposure(hcamcorder->camera, idx);
- }
- break;
- case '7': /* Setting > F number */
- g_print("Not supported !! \n");
- break;
- case '8': /* Setting > Display reuse hint */
- {
- bool reuse_hint = false;
-
- err = camera_get_display_reuse_hint(hcamcorder->camera, &reuse_hint);
- if (err != CAMERA_ERROR_NONE) {
- g_print("failed to get display reuse hint 0x%x\n", err);
- break;
- }
-
- g_print("*Display reuse hint : current %d -> set %d\n", reuse_hint, !reuse_hint);
- reuse_hint = !reuse_hint;
- err = camera_set_display_reuse_hint(hcamcorder->camera, reuse_hint);
- g_print("set display reuse hint result : 0x%x\n", err);
- }
- break;
- case '9': /* Setting > Manual focus */
- g_print("*Manual focus !\n");
- camera_attr_get_focus_level_range(hcamcorder->camera, &min, &max);
- if (min > max) {
- g_print("\n\tManual focus is NOT SUPPORTED\n");
- break;
- }
- camera_attr_get_focus_level(hcamcorder->camera, &idx);
- g_print("\tCurrent focus level (%d)\n", idx);
- g_print("\tSelect focus level min(%d) - max(%d) > ", min, max);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_focus_level(hcamcorder->camera, idx);
- idx = -1;
- if (bret == CAMERA_ERROR_NONE) {
- bret = camera_attr_get_focus_level(hcamcorder->camera, &idx);
- g_print("\tfocus level[%d] after set\n", idx);
- } else {
- g_print("\tset focus level failed[0x%x]\n", bret);
- }
- break;
- case 'i': /* Setting > ISO */
- g_print("*ISO !\n");
- camera_attr_foreach_supported_iso(hcamcorder->camera, iso_mode_cb, NULL);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_iso(hcamcorder->camera, idx);
- break;
- case 'r': /* Setting > Rotate camera input when recording */
- g_print("*Rotate camera input\n");
- camera_attr_foreach_supported_stream_rotation(hcamcorder->camera, camera_rotation_cb, NULL);
- err = scanf("%d", &idx);
- flush_stdin();
- CHECK_MM_ERROR(camera_stop_preview(hcamcorder->camera));
- bret = camera_attr_set_stream_rotation(hcamcorder->camera, idx);
- CHECK_MM_ERROR(camera_start_preview(hcamcorder->camera));
- break;
- case 'f': /* Setting > Flip camera input */
- g_print("*Flip camera input\n");
- camera_attr_foreach_supported_stream_flip(hcamcorder->camera, camera_flip_cb, NULL);
- err = scanf("%d", &idx);
- flush_stdin();
- CHECK_MM_ERROR(camera_stop_preview(hcamcorder->camera));
- bret = camera_attr_set_stream_flip(hcamcorder->camera, idx);
- CHECK_MM_ERROR(camera_start_preview(hcamcorder->camera));
- break;
- case 'j': /* Setting > Jpeg quality */
- g_print("*Jpeg quality !\n");
- g_print("\n Select Jpeg quality \n");
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_image_quality(hcamcorder->camera, idx);
- break;
- case 'p': /* Setting > Picture format */
- g_print("* Picture format!\n");
- camera_foreach_supported_preview_format(hcamcorder->camera, preview_format_cb, NULL);
- err = scanf("%d", &idx);
- flush_stdin();
- CHECK_MM_ERROR(camera_stop_preview(hcamcorder->camera));
- bret = camera_set_preview_format(hcamcorder->camera, idx);
- CHECK_MM_ERROR(camera_start_preview(hcamcorder->camera));
- break;
- case 'E': /* Setting > EXIF orientation */
- g_print("* EXIF Orientation\n");
- g_print("\t 1. TOP_LEFT\n");
- g_print("\t 2. TOP_RIGHT(flipped)\n");
- g_print("\t 3. BOTTOM_RIGHT\n");
- g_print("\t 4. BOTTOM_LEFT(flipped)\n");
- g_print("\t 5. LEFT_TOP(flipped)\n");
- g_print("\t 6. RIGHT_TOP\n");
- g_print("\t 7. RIGHT_BOTTOM(flipped)\n");
- g_print("\t 8. LEFT_BOTTOM\n");
- err = scanf("%d", &idx);
- flush_stdin();
- if (idx < 1 || idx > 8)
- g_print("Wrong INPUT[%d]!! \n", idx);
- else
- camera_attr_set_tag_orientation(hcamcorder->camera, idx);
- break;
- case 'F': /* Setting > Get Facing direction */
- g_print("* Get facing direction of camera module\n");
- err = camera_get_facing_direction(hcamcorder->camera, (camera_facing_direction_e *)&idx);
- if (CAMERA_ERROR_NONE == err)
- g_print("* Facing direction : %s(%d)\n", facing_direction[idx], idx);
- else
- g_print("* Error : %d\n", err);
- break;
- case 's': /* Setting > Set extra preview stream format */
- g_print("* Set extra preview stream format\n");
-
- g_print("\tstream_id,pixel format[NV12:0,H264:15,VP8:18],width,height,fps : ");
- err = scanf("%d,%d,%d,%d,%d", &stream_id, &pixel_format, &width, &height, &fps);
- flush_stdin();
-
- err = camera_set_extra_preview_stream_format(hcamcorder->camera,
- stream_id, pixel_format, width, height, fps);
- if (err != CAMERA_ERROR_NONE) {
- g_print("* Set Error : 0x%x\n", err);
- break;
- }
-
- pixel_format = width = height = fps = -1;
-
- err = camera_get_extra_preview_stream_format(hcamcorder->camera,
- stream_id, &pixel_format, &width, &height, &fps);
- if (err != CAMERA_ERROR_NONE) {
- g_print("* Get Error : 0x%x\n", err);
- break;
- }
-
- g_print("\tGet stream_id[%d],pixel format[%d],res[%dx%d],fps[%d]\n",
- stream_id, pixel_format, width, height, fps);
- break;
- case 'B': /* Setting > Set extra preview bitrate */
- g_print("* Set extra preview bitrate\n");
- g_print("\tstream_id : ");
- err = scanf("%d", &stream_id);
- flush_stdin();
-
- err = camera_attr_get_extra_preview_bitrate(hcamcorder->camera, stream_id, &bitrate);
- if (err != CAMERA_ERROR_NONE) {
- g_print("\tFailed to get bitrate for stream_id[%d]\n", stream_id);
- break;
- }
-
- g_print("\tCurrent bitrate[%d]bps for stream_id[%d]\n", bitrate, stream_id);
-
- g_print("\tSet bitrate(bps) : ");
- err = scanf("%d", &bitrate);
- flush_stdin();
-
- err = camera_attr_set_extra_preview_bitrate(hcamcorder->camera, stream_id, bitrate);
- if (err != CAMERA_ERROR_NONE) {
- g_print("* Set Error : 0x%x\n", err);
- break;
- }
-
- bitrate = -1;
-
- err = camera_attr_get_extra_preview_bitrate(hcamcorder->camera, stream_id, &bitrate);
- if (err != CAMERA_ERROR_NONE) {
- g_print("* Get Error : 0x%x\n", err);
- break;
- }
-
- g_print("\tResult bitrate[%d]bps for stream_id[%d]\n", bitrate, stream_id);
- break;
- case 'V': /* Setting > Set extra preview GOP interval */
- g_print("* Set extra preview GOP interval\n");
- g_print("\tstream_id : ");
- err = scanf("%d", &stream_id);
- flush_stdin();
-
- err = camera_attr_get_extra_preview_gop_interval(hcamcorder->camera, stream_id, &interval);
- if (err != CAMERA_ERROR_NONE) {
- g_print("\tFailed to get GOP interval for stream_id[%d]\n", stream_id);
- break;
- }
-
- g_print("\tCurrent GOP interval[%d]bps for stream_id[%d]\n", interval, stream_id);
-
- g_print("\tSet GOP interval(ms) : ");
- err = scanf("%d", &interval);
- flush_stdin();
-
- err = camera_attr_set_extra_preview_gop_interval(hcamcorder->camera, stream_id, interval);
- if (err != CAMERA_ERROR_NONE) {
- g_print("* Set Error : 0x%x\n", err);
- break;
- }
-
- interval = -1;
-
- err = camera_attr_get_extra_preview_gop_interval(hcamcorder->camera, stream_id, &interval);
- if (err != CAMERA_ERROR_NONE) {
- g_print("* Get Error : 0x%x\n", err);
- break;
- }
-
- g_print("\tResult GOP interval[%d]bps for stream_id[%d]\n", interval, stream_id);
- break;
- /* Display / Filter setting */
- case 'v': /* Display visible */
- g_print("* Display visible setting !\n");
- g_print("\n Select Display visible \n");
- for (i = 0 ; i < 2 ; i++)
- g_print("\t %d. %s\n", i, visible_mode[i]);
- err = scanf("%d", &idx);
- flush_stdin();
- if (idx == 0 || idx == 1)
- bret = camera_set_display_visible(hcamcorder->camera, idx);
- else
- g_print("invalid input %d", idx);
- break;
- case 'o': /* Setting > Display Mode */
- g_print("* Display mode!\n");
- for (i = 0 ; i < 5 ; i++)
- g_print("%d. %s\n", i, display_mode[i]);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_set_display_mode(hcamcorder->camera, idx);
- break;
- case 'y': /* Setting > Rotate Display */
- g_print("\n Select Rotate mode\n");
- g_print("\t0. 0\n\t1. 90\n\t2. 180\n\t3. 270\n\n");
- err = scanf("%d", &idx);
- flush_stdin();
- CHECK_MM_ERROR(camera_stop_preview(hcamcorder->camera));
- bret = camera_set_display_rotation(hcamcorder->camera, idx);
- CHECK_MM_ERROR(camera_start_preview(hcamcorder->camera));
- break;
- case 'Y': /* Setting > Flip Display */
- g_print("\n Select Rotate mode\n");
- g_print("\t0. NONE\n\t1. HORIZONTAL\n\t2. VERTICAL\n\t3. BOTH\n\n");
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_set_display_flip(hcamcorder->camera, idx);
- break;
- case 'g': /* Setting > Brightness */
- g_print("*Brightness !\n");
- camera_attr_get_brightness_range(hcamcorder->camera, &min, &max);
- g_print("\n Select brightness min (%d) -max(%d) > ", min, max);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_brightness(hcamcorder->camera, idx);
- break;
- case 'c': /* Setting > Contrast */
- g_print("*Contrast !\n");
- camera_attr_get_contrast_range(hcamcorder->camera, &min, &max);
- g_print("\n Select Contrast min(%d)-max(%d) > ", min, max);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_contrast(hcamcorder->camera, idx);
- break;
- case 'h': /* Setting > Hue */
- g_print("*Hue !\n");
- camera_attr_get_hue_range(hcamcorder->camera, &min, &max);
- if (max >= min) {
- g_print("\n Select Hue min(%d)-max(%d) > ", min, max);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_hue(hcamcorder->camera, idx);
- } else {
- g_print("\n Hue is not supported (%d,%d)\n", min, max);
- }
- break;
- case 'w': /* Setting > White balance */
- g_print("*White balance !\n");
- g_print("\n Select White balance \n");
- camera_attr_foreach_supported_whitebalance(hcamcorder->camera, white_balance_cb, NULL);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_whitebalance(hcamcorder->camera, idx);
- break;
- case 't': /* Setting > Color tone */
- g_print("*Color tone !\n");
- camera_attr_foreach_supported_effect(hcamcorder->camera, colortone_cb, NULL);
- g_print("\n Select Color tone \n");
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_effect(hcamcorder->camera, idx);
- break;
- case 'd': /* Setting > WDR */
- g_print("*WDR !\n");
- g_print("\n Select WDR Mode \n");
- for (i = 0 ; i < 2 ; i++)
- g_print("\t %d. %s\n", i+1, wdr_mode[i]);
- err = scanf("%d", &idx);
- flush_stdin();
- if (idx == 1)
- bret = camera_attr_enable_auto_contrast(hcamcorder->camera, 0);
- else if (idx == 2)
- bret = camera_attr_enable_auto_contrast(hcamcorder->camera, 1);
- break;
- case 'e': /* Setting > EV program mode */
- g_print("* EV program mode!\n");
- camera_attr_foreach_supported_scene_mode(hcamcorder->camera, program_mode_cb, NULL);
- g_print("\n Select EV program mode \n");
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_scene_mode(hcamcorder->camera, idx);
- break;
- case 'R': /* Setting > Display ROI area */
- g_print("* Set display roi area. Select x y width height \n");
- err = scanf("%d %d %d %d", &x, &y, &width, &height);
- flush_stdin();
- camera_set_display_mode(hcamcorder->camera, CAMERA_DISPLAY_MODE_CUSTOM_ROI);
- err = camera_attr_set_display_roi_area(hcamcorder->camera, x, y, width, height);
- if (CAMERA_ERROR_NONE != err)
- g_print("* Error : %d\n", err);
-
- err = camera_attr_get_display_roi_area(hcamcorder->camera, &x, &y, &width, &height);
- if (CAMERA_ERROR_NONE == err)
- g_print("Current display roi area : x %d, y %d, width %d, height %d\n", x, y, width, height);
- else
- g_print("* Error : %d\n", err);
- break;
-
- /* ext. setting */
- case 'z': /* Setting > Strobe setting */
- g_print("*Strobe Mode\n");
- camera_attr_foreach_supported_flash_mode(hcamcorder->camera, strobe_mode_cb, NULL);
- g_print("\n Select Strobe Mode \n");
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_flash_mode(hcamcorder->camera, idx);
- break;
- case 'S': /* Setting > flash state */
- g_print("*flash state\n");
- err = camera_get_flash_state(camera_device, (camera_flash_state_e *)&idx);
- if (CAMERA_ERROR_NONE == err)
- g_print("Current flash state = %s\n", idx ? "ON" : "OFF");
- else
- g_print("* Error : %d\n", err);
- break;
- case 'G': /* Setting > flash brightness */
- g_print("*Flash brightness !\n");
- camera_attr_get_flash_brightness_range(hcamcorder->camera, &min, &max);
- g_print("\n Select flash brightness min(%d) - max(%d) > ", min, max);
- err = scanf("%d", &idx);
- flush_stdin();
- bret = camera_attr_set_flash_brightness(hcamcorder->camera, idx);
- break;
- case 'x': /* Setting > Capture mode ,Muitishot? */
- g_print("*Select Capture mode!\n");
- g_print(" \n\t1. Stillshot mode\n\t2. Multishot mode\n\t3. HDR capture\n");
- err = scanf("%d", &idx);
- flush_stdin();
-
- switch (idx) {
- case 1:
- g_print("stillshot mode selected and capture callback is set!!!!\n");
- hcamcorder->is_multishot = FALSE;
- camera_attr_set_hdr_mode(hcamcorder->camera, 0);
- break;
- case 2:
- g_print("HDR Capture mode selected\n");
- hcamcorder->is_multishot = FALSE;
- g_print("\nSelect HDR capture mode\n");
- for (i = 0 ; i < 3 ; i++)
- g_print("\t %d. %s\n", i, hdr_mode[i]);
- err = scanf("%d", &idx);
- flush_stdin();
- if (idx >= CAMERA_ATTR_HDR_MODE_DISABLE && idx <= CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL)
- bret = camera_attr_set_hdr_mode(hcamcorder->camera, idx);
- else
- g_print("invalid input %d\n", idx);
- break;
- default:
- g_print("Wrong input, select again!!\n");
- break;
- }
- break;
- case 'l': /* Setting > Face detection setting */
- if (camera_is_supported_face_detection(hcamcorder->camera)) {
- g_print("* Face detect mode !\n");
- for (i = 0 ; i < 2 ; i++)
- g_print("\t %d. %s \n", i, detection_mode[i]);
- err = scanf("%d", &idx);
- flush_stdin();
- if (idx == 0)
- bret = camera_stop_face_detection(hcamcorder->camera);
- else if (idx == 1)
- bret = camera_start_face_detection(hcamcorder->camera, _face_detected, NULL);
- else
- g_print("\n invalid input [%d]\n\n", idx);
- } else {
- g_print("face detection_not supported");
- }
- break;
- case 'k': /* Setting > Anti-handshake */
- g_print("*Anti-handshake !\n");
- g_print("\n Select Anti-handshake mode \n");
- for (i = 0; i < 2; i++)
- g_print("\t %d. %s\n", i, ahs_mode[i]);
- err = scanf("%d", &idx);
- flush_stdin();
- if (idx == 0 || idx == 1)
- bret = camera_attr_enable_anti_shake(hcamcorder->camera, idx);
- else
- g_print("invalid input %d\n", idx);
- break;
- case 'K': /* Setting > Video-stabilization */
- g_print("*Video-stabilization !\n");
- g_print("\n Select Video-stabilization mode \n");
- for (i = 0 ; i < 2 ; i++)
- g_print("\t %d. %s\n", i, vs_mode[i]);
- err = scanf("%d", &idx);
- flush_stdin();
- if (idx < 0 || idx > 1) {
- g_print("invalid input %d\n", idx);
- break;
- }
-
- if (idx == 1) {
- g_print("\n Restart preview with NV12 and 720p resolution\n");
- err = camera_stop_preview(hcamcorder->camera);
- g_print("stop preview result 0x%x\n", err);
- camera_set_preview_resolution(hcamcorder->camera, 1280, 720);
- camera_set_preview_format(hcamcorder->camera, CAMERA_PIXEL_FORMAT_NV12);
- }
-
- bret = camera_attr_enable_video_stabilization(hcamcorder->camera, idx);
-
- if (idx == 1) {
- err = camera_start_preview(hcamcorder->camera);
- if (err != CAMERA_ERROR_NONE)
- g_print("\n Restart FAILED! 0x%x\n", err);
- }
- break;
- case 'u': /* Touch AF area */
- g_print("* Touch AF area !\n");
- g_print("\n Input x,y,width,height \n");
- err = scanf("%d,%d,%d,%d", &x, &y, &width, &height);
- flush_stdin();
- err = camera_attr_set_af_area(hcamcorder->camera, width, height);
- if (err != 0)
- g_print("Failed to set touch AF area.(%x)\n", err);
- else
- g_print("Succeed to set touch AF area.\n");
- break;
- case 'n': /* file path */
- g_print("* File path !\n");
- g_print("\n Input file path to save captured data(string) : ");
- if (fgets(hcamcorder->file_path, sizeof(hcamcorder->file_path), stdin))
- g_print("\ncaptured data will be saved in [%s]\n", hcamcorder->file_path);
- else
- g_print("\nset file path failed\n");
- break;
- case 'm': /* media bridge */
- g_print("* Media Bridge !\n");
- g_print("\tUnset[0] / Set[Others] :");
- err = scanf("%d", &set_bridge);
- flush_stdin();
- if (set_bridge) {
- __release_media_bridge();
-
- err = media_bridge_create(&bridge);
- err |= media_bridge_set_source(bridge, MEDIA_BRIDGE_MODULE_CAMERA, hcamcorder->camera);
- } else {
- __release_media_bridge();
- }
- g_print("\tresult[0x%x]\n\n", err);
- break;
- case 'b': /* back */
- hcamcorder->menu_state = MENU_STATE_MAIN;
- break;
- default:
- g_print("\t Invalid input \n");
- break;
- }
-
- g_print("\t bret : 0x%x \n", bret);
-}
-
-
-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;
- }
-}
-
-static void device_manager_menu(gchar buf)
-{
- int ret = 0;
-
- 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': /* Foreach supported camera device */
- ret = camera_device_manager_foreach_supported_device(g_device_manager, _camera_supported_device_cb, NULL);
- if (ret != CAMERA_ERROR_NONE) {
- g_print("\n\tGet device list failed[0x%x]\n", ret);
- return;
- }
- break;
- case '3': /* Add device connection changed callback */
- ret = camera_device_manager_add_device_connection_changed_cb(g_device_manager,
- _camera_device_connection_changed_cb, NULL, &g_camera_device_connection_changed_cb_id);
- g_print("\n\tadd result[0x%x] - cb id[%d]\n", ret, g_camera_device_connection_changed_cb_id);
- break;
- case '4': /* Remove device connection changed callback */
- if (g_camera_device_connection_changed_cb_id > 0) {
- ret = camera_device_manager_remove_device_connection_changed_cb(g_device_manager,
- g_camera_device_connection_changed_cb_id);
- g_print("\n\tremove result[0x%x] - cb id[%d]\n", ret, g_camera_device_connection_changed_cb_id);
- g_camera_device_connection_changed_cb_id = 0;
- } else {
- g_print("\n\tinvalid cb id[%d]\n", g_camera_device_connection_changed_cb_id);
- }
- break;
- case '9': /* 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;
- }
-}
-
-
-/**
- * This function is to execute command.
- *
- * @param channel [in] 1st parameter
- *
- * @return This function returns TRUE/FALSE
- * @remark
- * @see
- */
-static gboolean cmd_input(GIOChannel *channel, GIOCondition condition, gpointer data)
-{
- gchar *buf = NULL;
- gsize read_size;
- GError *g_error = NULL;
-
- g_print("\n\tENTER\n");
-
- g_io_channel_read_line(channel, &buf, &read_size, NULL, &g_error);
- if (g_error) {
- g_print("\n\tg_io_channel_read_chars error\n");
- g_error_free(g_error);
- g_error = NULL;
- }
-
- if (buf) {
- g_strstrip(buf);
-
- g_print("\n\tMenu Status : %d\n", hcamcorder->menu_state);
- switch (hcamcorder->menu_state) {
- case MENU_STATE_INIT:
- mode_change(buf[0]);
- break;
- case MENU_STATE_MAIN:
- main_menu(buf[0]);
- break;
- 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_MANAGER:
- device_manager_menu(buf[0]);
- break;
- default:
- break;
- }
-
- g_free(buf);
- buf = NULL;
-
- print_menu();
- } else {
- g_print("\n\tNo read input\n");
- }
-
- return TRUE;
-}
-
-static gboolean init_handle()
-{
- hcamcorder->is_multishot = FALSE;
- hcamcorder->stillshot_count = 0;
- hcamcorder->multishot_count = 0;
- snprintf(hcamcorder->file_path, MAX_FILE_PATH_LENGTH, DEFAULT_FILE_PATH);
- hcamcorder->menu_state = MENU_STATE_INIT;
- hcamcorder->elapsed_time = 0;
-
- return TRUE;
-}
-
-
-/**
- * This function is to change camcorder mode.
- *
- * @param buf [in] user input
- *
- * @return This function returns TRUE/FALSE
- * @remark
- * @see other functions
- */
-static gboolean mode_change(gchar buf)
-{
- int err = 0;
- int camera_type = 0;
-
- switch (buf) {
- case '1':
- while (1) {
- g_print("\n\tEnter the Camera Type[0:Local, 1:Network] : ");
- err = scanf("%d", &camera_type);
- flush_stdin();
- if (err == EOF) {
- g_print("\t!!!read input error!!!\n");
- continue;
- }
-
- if (camera_type != 0 && camera_type != 1) {
- g_print("\t Invalid camera type(%d)\n", camera_type);
- continue;
- }
-
- g_print("\n\tEnter the Camera Device[0 ~ 9] : ");
- err = scanf("%d", (int *)&camera_device);
- flush_stdin();
- if (err == EOF) {
- g_print("\t!!!read input error!!!\n");
- continue;
- }
-
- if (camera_device < 0 || camera_device > 9) {
- g_print("\t Invalid camera device(%d)\n", camera_device);
- continue;
- }
-
- hcamcorder->type = camera_device;
-
- break;
- }
- break;
- case '2':
- hcamcorder->menu_state = MENU_STATE_DEVICE_STATE;
- return TRUE;
- case '3':
- hcamcorder->menu_state = MENU_STATE_DEVICE_MANAGER;
- return TRUE;
- case 'q':
- g_print("\t Quit Camcorder Testsuite!!\n");
- g_main_loop_quit(g_mainloop_camera_test);
- return FALSE;
- default:
- g_print("\t Invalid media type(%c)\n", buf);
- return FALSE;
- }
-
- g_print("\n[camcorder_create - type %d, device %d]\n", camera_type, camera_device);
-
- gettimeofday(&previous_time, NULL);
-
- g_timer_reset(timer);
-
- if (camera_type)
- err = camera_create_network(camera_device, &hcamcorder->camera);
- else
- err = camera_create(camera_device, &hcamcorder->camera);
-
- g_print("[camera_create() : %12.6lfs]\n", g_timer_elapsed(timer, NULL));
-
- if (err != 0) {
- g_print("\n\tmmcamcorder_create = 0x%x\n", err);
- return FALSE;
- }
-
- g_print("Display type : NULL for headless\n");
- camera_set_display(hcamcorder->camera, CAMERA_DISPLAY_TYPE_NONE, NULL);
-
- camera_set_error_cb(hcamcorder->camera, _camera_error_cb, NULL);
- camera_set_state_changed_cb(hcamcorder->camera, _camera_state_changed_cb, NULL);
- camera_set_interrupted_cb(hcamcorder->camera, _camera_interrupted_cb, NULL);
- camera_set_interrupt_started_cb(hcamcorder->camera, _camera_interrupt_started_cb, NULL);
- camera_set_display_mode(hcamcorder->camera, CAMERA_DISPLAY_MODE_LETTER_BOX);
- /*camera_set_display_rotation(hcamcorder->camera, CAMERA_ROTATION_90);*/
- /*camera_set_display_flip(hcamcorder->camera, CAMERA_FLIP_VERTICAL);*/
- /*camera_set_preview_cb(hcamcorder->camera, _preview_cb, hcamcorder->camera);*/
-
- camera_start_preview(hcamcorder->camera);
-
- gettimeofday(¤t_time, NULL);
- timersub(¤t_time, &previous_time, &result_time);
-
- g_print("\n\tCamera Starting Time : %ld.%lds\n", result_time.tv_sec, result_time.tv_usec);
-
- hcamcorder->menu_state = MENU_STATE_MAIN;
-
- return TRUE;
-}
-
-/**
- * This function is the example main function for mmcamcorder API.
- *
- * @param
- *
- * @return This function returns 0.
- * @remark
- * @see other functions
- */
-int main(int argc, char **argv)
-{
- hcamcorder = (cam_handle_t *)g_malloc0(sizeof(cam_handle_t));
-
- stdin_channel = g_io_channel_unix_new(fileno(stdin));/* read from stdin */
- g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)cmd_input, NULL);
-
- timer = g_timer_new();
- g_timer_reset(timer);
-
- init_handle();
-
- print_menu();
-
- g_mainloop_camera_test = g_main_loop_new(NULL, FALSE);
-
- g_main_loop_run(g_mainloop_camera_test);
-
- g_print("\n\treturn main loop\n\n");
-
- g_main_loop_unref(g_mainloop_camera_test);
-
- if (timer) {
- g_timer_stop(timer);
- g_timer_destroy(timer);
- }
-
- g_free(hcamcorder);
- g_io_channel_unref(stdin_channel);
-
- return 0;
-}
-/*EOF*/