diff options
-rw-r--r-- | include/recorder_private.h | 10 | ||||
-rw-r--r-- | packaging/capi-media-recorder.spec | 4 | ||||
-rw-r--r-- | src/recorder.c | 1062 | ||||
-rw-r--r-- | test/recorder_test.c | 723 |
4 files changed, 503 insertions, 1296 deletions
diff --git a/include/recorder_private.h b/include/recorder_private.h index faa791a..5ef87f7 100644 --- a/include/recorder_private.h +++ b/include/recorder_private.h @@ -184,16 +184,6 @@ typedef struct _recorder_cli_s { camera_h camera; } recorder_cli_s; -typedef struct _recorder_msg_param { - int type; - const char *name; - union { - int value_INT; - double value_DOUBLE; - const char *value_STRING; - } value; -} recorder_msg_param; - typedef struct _camera_cli_s { intptr_t remote_handle; void *cb_info; diff --git a/packaging/capi-media-recorder.spec b/packaging/capi-media-recorder.spec index 22005aa..5f0e105 100644 --- a/packaging/capi-media-recorder.spec +++ b/packaging/capi-media-recorder.spec @@ -1,7 +1,7 @@ Name: capi-media-recorder Summary: A Recorder API -Version: 0.3.32 -Release: 1 +Version: 0.3.33 +Release: 0 Group: Multimedia/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/recorder.c b/src/recorder.c index 62129a2..7b889ae 100644 --- a/src/recorder.c +++ b/src/recorder.c @@ -1340,97 +1340,142 @@ _CB_RETURN_END: } -static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret, int timeout) +static int __send_msg_free(muse_recorder_api_e api, recorder_cb_info_s *cb_info, + char *msg, int timeout) { + int ret = RECORDER_ERROR_NONE; int send_ret = 0; - char *msg = NULL; - if (!cb_info || !ret) { - REC_LOG_ERROR("invalid pointer for api[%d] -[%p][%p]", api, cb_info, ret); + if (!cb_info) { + REC_LOG_ERROR("NULL handle"); return RECORDER_ERROR_INVALID_PARAMETER; } - msg = muse_core_msg_new(api, NULL); if (!msg) { - REC_LOG_ERROR("msg creation failed: api[%d]", api); + REC_LOG_ERROR("NULL msg"); return RECORDER_ERROR_OUT_OF_MEMORY; } - REC_LOG_VERBOSE("send msg[%s]", msg); + __recorder_update_api_waiting(cb_info, api, 1); - if (cb_info->is_server_connected) { - __recorder_update_api_waiting(cb_info, api, 1); + if (cb_info->is_server_connected) send_ret = muse_core_msg_send(cb_info->fd, msg); - } if (send_ret < 0) { REC_LOG_ERROR("message send failed"); - *ret = RECORDER_ERROR_INVALID_OPERATION; + ret = RECORDER_ERROR_INVALID_OPERATION; } else { - *ret = _recorder_client_wait_for_cb_return(api, cb_info, timeout); + ret = _recorder_client_wait_for_cb_return(api, cb_info, timeout); } __recorder_update_api_waiting(cb_info, api, -1); muse_core_msg_free(msg); + REC_LOG_INFO("api[%d] - ret[0x%x]", api, ret); + + return ret; +} + + +static int _recorder_msg_send(muse_recorder_api_e api, recorder_cb_info_s *cb_info, + int *ret, int timeout) +{ + if (!cb_info || !ret) { + REC_LOG_ERROR("invalid pointer for api[%d] -[%p][%p]", api, cb_info, ret); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + *ret = __send_msg_free(api, cb_info, muse_core_msg_new(api, NULL), timeout); + return RECORDER_ERROR_NONE; } -static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *ret, recorder_msg_param *param) +static int _recorder_msg_send_param(muse_recorder_api_e api, recorder_cb_info_s *cb_info, + int *ret, int type, const char *name, void *value) { - int send_ret = 0; char *msg = NULL; - if (!cb_info || !ret || !param) { - REC_LOG_ERROR("invalid pointer for api[%d] -[%p][%p][%p]", api, cb_info, ret, param); + if (!cb_info || !ret || !name || !value) { + REC_LOG_ERROR("NULL param for api[%d] -[%p,%p,%p,%p]", api, cb_info, ret, name, value); return RECORDER_ERROR_INVALID_PARAMETER; } - REC_LOG_VERBOSE("type[%d], name[%s]", param->type, param->name); - - switch (param->type) { + switch (type) { case MUSE_TYPE_INT: - msg = muse_core_msg_new(api, param->type, param->name, param->value.value_INT, NULL); + msg = muse_core_msg_new(api, type, name, *(int *)value, NULL); break; case MUSE_TYPE_DOUBLE: - msg = muse_core_msg_new(api, param->type, param->name, param->value.value_DOUBLE, NULL); + msg = muse_core_msg_new(api, type, name, *(double *)value, NULL); break; case MUSE_TYPE_STRING: - msg = muse_core_msg_new(api, param->type, param->name, param->value.value_STRING, NULL); + msg = muse_core_msg_new(api, type, name, (char *)value, NULL); break; default: - REC_LOG_ERROR("unknown type[%d]", param->type); + REC_LOG_ERROR("unknown type[%d]", type); break; } - if (!msg) { - REC_LOG_ERROR("msg creation failed: api[%d], type[%d], param name[%s]", - api, param->type, param->name); - return RECORDER_ERROR_OUT_OF_MEMORY; + *ret = __send_msg_free(api, cb_info, msg, RECORDER_CB_TIMEOUT); + + return RECORDER_ERROR_NONE; +} + + +static int _recorder_set_int(recorder_h recorder, muse_recorder_api_e api, const char *name, int value) +{ + int ret = RECORDER_ERROR_NONE; + recorder_cli_s *pc = (recorder_cli_s *)recorder; + + if (!pc || !pc->cb_info) { + REC_LOG_ERROR("NULL handle"); + return RECORDER_ERROR_INVALID_PARAMETER; } - REC_LOG_VERBOSE("send msg[%s]", msg); + REC_LOG_INFO("api[%d] - value[%d]", api, value); - if (cb_info->is_server_connected) { - __recorder_update_api_waiting(cb_info, api, 1); + _recorder_msg_send_param(api, pc->cb_info, &ret, + MUSE_TYPE_INT, name, (void *)&value); - send_ret = muse_core_msg_send(cb_info->fd, msg); + REC_LOG_INFO("api[%d] - ret[0x%x]", api, ret); + + return ret; +} + + +static int _recorder_set_cb(recorder_h recorder, muse_recorder_api_e api, muse_recorder_event_e event, bool is_set, void *callback, void *user_data) +{ + int ret = RECORDER_ERROR_NONE; + recorder_cli_s *pc = (recorder_cli_s *)recorder; + + if (!pc || !pc->cb_info) { + REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); + return RECORDER_ERROR_INVALID_PARAMETER; } - if (send_ret < 0) { - REC_LOG_ERROR("message send failed"); - *ret = RECORDER_ERROR_INVALID_OPERATION; - } else { - *ret = _recorder_client_wait_for_cb_return(api, cb_info, RECORDER_CB_TIMEOUT); + REC_LOG_INFO("Enter[%p] - api[%d], is_set[%d], cb[%p], user_data[%p]", + recorder, api, is_set, callback, user_data); + + if (is_set && callback == NULL) { + REC_LOG_ERROR("NULL callback"); + return RECORDER_ERROR_INVALID_PARAMETER; } - __recorder_update_api_waiting(cb_info, api, -1); + _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - muse_core_msg_free(msg); + if (ret == RECORDER_ERROR_NONE) { + g_mutex_lock(&pc->cb_info->user_cb_mutex[event]); - return RECORDER_ERROR_NONE; + pc->cb_info->user_cb[event] = callback; + pc->cb_info->user_data[event] = user_data; + + g_mutex_unlock(&pc->cb_info->user_cb_mutex[event]); + } + + REC_LOG_INFO("ret[0x%x]", ret); + + return ret; } @@ -1545,7 +1590,6 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty intptr_t handle = 0; tbm_bufmgr bufmgr = NULL; recorder_cli_s *pc = NULL; - recorder_msg_param param; REC_LOG_INFO("type[%d]", type); @@ -1666,9 +1710,8 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty REC_LOG_INFO("root directory[%s], log level[%d]", root_directory, g_recorder_log_level); - RECORDER_MSG_PARAM_SET(param, STRING, root_directory); - - _recorder_msg_send_param1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY, pc->cb_info, &ret, ¶m); + _recorder_msg_send_param(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY, pc->cb_info, &ret, + MUSE_TYPE_STRING, "root_directory", (void *)root_directory); if (ret != RECORDER_ERROR_NONE) { REC_LOG_ERROR("failed to set root directory[%s]", root_directory); @@ -1723,6 +1766,48 @@ _ERR_RECORDER_EXIT: } +static int _recorder_stop(recorder_h recorder, muse_recorder_api_e api) +{ + int ret = RECORDER_ERROR_NONE; + recorder_cli_s *pc = (recorder_cli_s *)recorder; + recorder_state_e current_state = RECORDER_STATE_NONE; + + if (!pc || !pc->cb_info) { + REC_LOG_ERROR("NULL handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + REC_LOG_INFO("ENTER - api[%d]", api); + + if (pc->camera) { +//LCOV_EXCL_START + ret = recorder_get_state(recorder, ¤t_state); + if (ret != RECORDER_ERROR_NONE) { + REC_LOG_ERROR("failed to get current state[0x%x]", ret); + return RECORDER_ERROR_INVALID_OPERATION; + } + + if (current_state >= RECORDER_STATE_RECORDING) { + ret = camera_stop_evas_rendering(pc->camera, true); + if (ret != CAMERA_ERROR_NONE) { + REC_LOG_ERROR("camera_stop_evas_rendering failed[0x%x]", ret); + return RECORDER_ERROR_INVALID_OPERATION; + } + } +//LCOV_EXCL_STOP + } + + _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); + + if (pc->camera && current_state >= RECORDER_STATE_RECORDING) + camera_start_evas_rendering(pc->camera); + + REC_LOG_INFO("ret[0x%x]", ret); + + return ret; +} + + int recorder_create_videorecorder(camera_h camera, recorder_h *recorder) { return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_VIDEO, camera); @@ -1924,93 +2009,19 @@ int recorder_pause(recorder_h recorder) int recorder_commit(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_COMMIT; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_state_e current_state = RECORDER_STATE_NONE; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - if (pc->camera) { -//LCOV_EXCL_START - ret = recorder_get_state(recorder, ¤t_state); - if (ret != RECORDER_ERROR_NONE) { - REC_LOG_ERROR("failed to get current state[0x%x]", ret); - return RECORDER_ERROR_INVALID_OPERATION; - } - - if (current_state >= RECORDER_STATE_RECORDING) { - ret = camera_stop_evas_rendering(pc->camera, true); - if (ret != CAMERA_ERROR_NONE) { - REC_LOG_ERROR("camera_stop_evas_rendering failed[0x%x]", ret); - return RECORDER_ERROR_INVALID_OPERATION; - } - } -//LCOV_EXCL_STOP - } - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (pc->camera && current_state >= RECORDER_STATE_RECORDING) - camera_start_evas_rendering(pc->camera); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_stop(recorder, MUSE_RECORDER_API_COMMIT); } int recorder_cancel(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_CANCEL; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_state_e current_state = RECORDER_STATE_NONE; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - if (pc->camera) { - ret = recorder_get_state(recorder, ¤t_state); - if (ret != RECORDER_ERROR_NONE) { - REC_LOG_ERROR("failed to get current state[0x%x]", ret); - return RECORDER_ERROR_INVALID_OPERATION; - } - - if (current_state >= RECORDER_STATE_RECORDING) { - ret = camera_stop_evas_rendering(pc->camera, true); - if (ret != CAMERA_ERROR_NONE) { - REC_LOG_ERROR("camera_stop_evas_rendering failed[0x%x]", ret); - return RECORDER_ERROR_INVALID_OPERATION; - } - } - } - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (pc->camera && current_state >= RECORDER_STATE_RECORDING) - camera_start_evas_rendering(pc->camera); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_stop(recorder, MUSE_RECORDER_API_CANCEL); } int recorder_set_video_resolution(recorder_h recorder, int width, int height) { - int ret = RECORDER_ERROR_NONE; - int send_ret = 0; - char *send_msg = NULL; + char *msg = NULL; muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION; recorder_cli_s *pc = (recorder_cli_s *)recorder; @@ -2021,35 +2032,12 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height) REC_LOG_INFO("ENTER"); - send_msg = muse_core_msg_new(api, + msg = muse_core_msg_new(api, MUSE_TYPE_INT, "width", width, MUSE_TYPE_INT, "height", height, NULL); - if (send_msg) { - if (pc->cb_info->is_server_connected) { - __recorder_update_api_waiting(pc->cb_info, api, 1); - - send_ret = muse_core_msg_send(pc->cb_info->fd, send_msg); - } - if (send_ret < 0) { - REC_LOG_ERROR("message send failed"); - ret = RECORDER_ERROR_INVALID_OPERATION; - } else { - ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT); - } - - __recorder_update_api_waiting(pc->cb_info, api, -1); - - muse_core_msg_free(send_msg); - } else { - REC_LOG_ERROR("failed to create msg"); - ret = RECORDER_ERROR_OUT_OF_MEMORY; - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return __send_msg_free(api, pc->cb_info, msg, RECORDER_CB_TIMEOUT); } @@ -2139,7 +2127,6 @@ int recorder_set_filename(recorder_h recorder, const char *filename) size_t length = 0; muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME; recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; char set_filename[RECORDER_FILENAME_MAX] = {'\0',}; if (!pc || !pc->cb_info) { @@ -2171,9 +2158,8 @@ int recorder_set_filename(recorder_h recorder, const char *filename) pc->cb_info->is_filename_converted = TRUE; } - RECORDER_MSG_PARAM_SET(param, STRING, set_filename); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); + _recorder_msg_send_param(api, pc->cb_info, &ret, + MUSE_TYPE_STRING, "set_filename", (void *)set_filename); REC_LOG_INFO("ret[0x%x]", ret); @@ -2225,25 +2211,7 @@ int recorder_get_filename(recorder_h recorder, char **filename) int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format) { - int ret = RECORDER_ERROR_NONE; - int set_format = (int)format; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER, set_format[%d]", set_format); - - RECORDER_MSG_PARAM_SET(param, INT, set_format); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_SET_FILE_FORMAT, "set_format", format); } @@ -2284,8 +2252,7 @@ int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stre bool is_available = false; int stream_index = 0; char *stream_type = NULL; - char *send_msg = NULL; - int send_ret = 0; + char *msg = NULL; if (!pc || !pc->cb_info || stream_info == NULL) { REC_LOG_ERROR("NULL handle"); @@ -2308,577 +2275,143 @@ int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stre ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type); ret |= sound_manager_get_index_from_stream_information(stream_info, &stream_index); - REC_LOG_INFO("sound manager return [0x%x]", ret); - - if (ret == SOUND_MANAGER_ERROR_NONE) { - send_msg = muse_core_msg_new(api, - MUSE_TYPE_STRING, "stream_type", stream_type, - MUSE_TYPE_INT, "stream_index", stream_index, - NULL); - if (send_msg) { - if (pc->cb_info->is_server_connected) { - __recorder_update_api_waiting(pc->cb_info, api, 1); - - send_ret = muse_core_msg_send(pc->cb_info->fd, send_msg); - } - - if (send_ret < 0) { - REC_LOG_ERROR("message send failed"); - ret = RECORDER_ERROR_INVALID_OPERATION; - } else { - ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT); - } - - __recorder_update_api_waiting(pc->cb_info, api, -1); - - muse_core_msg_free(send_msg); - } else { - REC_LOG_ERROR("failed to create msg"); - ret = RECORDER_ERROR_OUT_OF_MEMORY; - } - } else { - ret = RECORDER_ERROR_INVALID_OPERATION; + if (ret != SOUND_MANAGER_ERROR_NONE) { + REC_LOG_ERROR("sound manager failed[0x%x]", ret); + return RECORDER_ERROR_INVALID_OPERATION; } - return ret; + msg = muse_core_msg_new(api, + MUSE_TYPE_STRING, "stream_type", stream_type, + MUSE_TYPE_INT, "stream_index", stream_index, + NULL); + + return __send_msg_free(api, pc->cb_info, msg, RECORDER_CB_TIMEOUT); } int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_STATE_CHANGED_CB; - - if (!pc || !pc->cb_info || callback == NULL) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("Enter, handle[%td]", pc->remote_handle); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_STATE_CHANGED_CB, + MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE, true, callback, user_data); } int recorder_unset_state_changed_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB, + MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE, false, NULL, NULL); } int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB; - - if (!pc || !pc->cb_info || callback == NULL) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("Enter, handle[%td]", pc->remote_handle); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_INTERRUPTED_CB, + MUSE_RECORDER_EVENT_TYPE_INTERRUPTED, true, callback, user_data); } int recorder_unset_interrupted_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_INTERRUPTED_CB, + MUSE_RECORDER_EVENT_TYPE_INTERRUPTED, false, NULL, NULL); } int recorder_set_interrupt_started_cb(recorder_h recorder, recorder_interrupt_started_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPT_STARTED_CB; - - if (!pc || !pc->cb_info || callback == NULL) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("Enter, handle[%td]", pc->remote_handle); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_INTERRUPT_STARTED_CB, + MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED, true, callback, user_data); } int recorder_unset_interrupt_started_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPT_STARTED_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_INTERRUPT_STARTED_CB, + MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED, false, NULL, NULL); } int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_STREAM_CB; - - if (!pc || !pc->cb_info || callback == NULL) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("Enter, handle[%td]", pc->remote_handle); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_AUDIO_STREAM_CB, + MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM, true, callback, user_data); } int recorder_unset_audio_stream_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB, + MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM, false, NULL, NULL); } int recorder_set_muxed_stream_cb(recorder_h recorder, recorder_muxed_stream_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_MUXED_STREAM_CB; - - if (!pc || !pc->cb_info || !callback) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("Enter, handle[%td]", pc->remote_handle); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_MUXED_STREAM_CB, + MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM, true, callback, user_data); } int recorder_unset_muxed_stream_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_MUXED_STREAM_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_MUXED_STREAM_CB, + MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM, false, NULL, NULL); } int recorder_set_video_encode_decision_cb(recorder_h recorder, recorder_video_encode_decision_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_ENCODE_DECISION_CB; - - if (!pc || !pc->cb_info || !callback) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("Enter, handle[%td]", pc->remote_handle); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_VIDEO_ENCODE_DECISION_CB, + MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION, true, callback, user_data); } int recorder_unset_video_encode_decision_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_VIDEO_ENCODE_DECISION_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_VIDEO_ENCODE_DECISION_CB, + MUSE_RECORDER_EVENT_TYPE_VIDEO_ENCODE_DECISION, false, NULL, NULL); } int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_ERROR_CB; - - if (!pc || !pc->cb_info || callback == NULL) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("Enter, handle[%td]", pc->remote_handle); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_ERROR_CB, + MUSE_RECORDER_EVENT_TYPE_ERROR, true, callback, user_data); } int recorder_unset_error_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_ERROR_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_ERROR_CB, + MUSE_RECORDER_EVENT_TYPE_ERROR, false, NULL, NULL); } int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_STATUS_CB; - - if (!pc || !pc->cb_info || callback == NULL) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("Enter, handle[%td]", pc->remote_handle); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_RECORDING_STATUS_CB, + MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS, true, callback, user_data); } int recorder_unset_recording_status_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_STATUS_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_RECORDING_STATUS_CB, + MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS, false, NULL, NULL); } int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void *user_data) { - int ret = RECORDER_ERROR_NONE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_LIMIT_REACHED_CB; - - if (!pc || !pc->cb_info || callback == NULL) { - REC_LOG_ERROR("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_SET_RECORDING_LIMIT_REACHED_CB, + MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED, true, callback, user_data); } int recorder_unset_recording_limit_reached_cb(recorder_h recorder) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_LIMIT_REACHED_CB; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); - - if (ret == RECORDER_ERROR_NONE) { - g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]); - - pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL; - pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL; - - g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]); - } - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_cb(recorder, MUSE_RECORDER_API_UNSET_RECORDING_LIMIT_REACHED_CB, + MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED, false, NULL, NULL); } @@ -2908,99 +2441,25 @@ int recorder_foreach_supported_file_format(recorder_h recorder, recorder_support int recorder_attr_set_size_limit(recorder_h recorder, int kbyte) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_SIZE_LIMIT; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, kbyte); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_SIZE_LIMIT, "kbyte", kbyte); } int recorder_attr_set_time_limit(recorder_h recorder, int second) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_TIME_LIMIT; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, second); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_TIME_LIMIT, "second", second); } int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device) { - int ret = RECORDER_ERROR_NONE; - int set_device = (int)device; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_DEVICE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - }; - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, set_device); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_AUDIO_DEVICE, "set_device", device); } int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec) { - int ret = RECORDER_ERROR_NONE; - int set_codec = (int)codec; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_ENCODER; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, set_codec); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_SET_AUDIO_ENCODER, "set_codec", codec); } @@ -3035,26 +2494,7 @@ int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *code int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec) { - int ret = RECORDER_ERROR_NONE; - int set_codec = (int)codec; - muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_ENCODER; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, set_codec); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_SET_VIDEO_ENCODER, "set_codec", codec); } @@ -3089,73 +2529,19 @@ int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *code int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_SAMPLERATE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER, samplerate[%d]", samplerate); - - RECORDER_MSG_PARAM_SET(param, INT, samplerate); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_AUDIO_SAMPLERATE, "samplerate", samplerate); } int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_ENCODER_BITRATE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, bitrate); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_AUDIO_ENCODER_BITRATE, "bitrate", bitrate); } int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_VIDEO_ENCODER_BITRATE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, bitrate); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_VIDEO_ENCODER_BITRATE, "bitrate", bitrate); } @@ -3383,26 +2769,7 @@ int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_suppo int recorder_attr_set_mute(recorder_h recorder, bool enable) { - int ret = RECORDER_ERROR_NONE; - int set_enable = (int)enable; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_MUTE; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, set_enable); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_MUTE, "set_enable", enable); } @@ -3435,7 +2802,6 @@ int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate) int ret = RECORDER_ERROR_NONE; muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_RECORDING_MOTION_RATE; recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; if (!pc || !pc->cb_info) { REC_LOG_ERROR("NULL handle"); @@ -3444,9 +2810,8 @@ int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate) REC_LOG_INFO("ENTER - %.20lf", rate); - RECORDER_MSG_PARAM_SET(param, DOUBLE, rate); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); + _recorder_msg_send_param(api, pc->cb_info, &ret, + MUSE_TYPE_DOUBLE, "rate", (void *)&rate); REC_LOG_INFO("ret[0x%x]", ret); @@ -3484,25 +2849,7 @@ int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate) int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count) { - int ret = RECORDER_ERROR_NONE; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_CHANNEL; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, channel_count); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_AUDIO_CHANNEL, "channel_count", channel_count); } @@ -3537,26 +2884,7 @@ int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count) int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation) { - int ret = RECORDER_ERROR_NONE; - int set_orientation = (int)orientation; - muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_ORIENTATION_TAG; - recorder_cli_s *pc = (recorder_cli_s *)recorder; - recorder_msg_param param; - - if (!pc || !pc->cb_info) { - REC_LOG_ERROR("NULL handle"); - return RECORDER_ERROR_INVALID_PARAMETER; - } - - REC_LOG_INFO("ENTER"); - - RECORDER_MSG_PARAM_SET(param, INT, set_orientation); - - _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m); - - REC_LOG_INFO("ret[0x%x]", ret); - - return ret; + return _recorder_set_int(recorder, MUSE_RECORDER_API_ATTR_SET_ORIENTATION_TAG, "set_orientation", orientation); } diff --git a/test/recorder_test.c b/test/recorder_test.c index c516681..d0ecfd5 100644 --- a/test/recorder_test.c +++ b/test/recorder_test.c @@ -449,6 +449,159 @@ static void _recorder_error_cb(int error, recorder_state_e current_state, void * } +static int _recorder_set_muxed_stream_cb(void) +{ + int idx = 0; + int err = 0; + + g_print("* Muxed stream callback\n"); + + flush_stdin(); + + g_print("[set(1)/unset(2)] : "); + + err = scanf("%d", &idx); + + switch (idx) { + case 1: + return recorder_set_muxed_stream_cb(hcamcorder->recorder, _recording_muxed_stream_cb, NULL); + case 2: + return recorder_unset_muxed_stream_cb(hcamcorder->recorder); + default: + return RECORDER_ERROR_INVALID_PARAMETER; + } +} + + +static int _recorder_set_audio_encoder(void) +{ + int encoder = 0; + int err = 0; + + g_print("* Audio codec\n"); + + flush_stdin(); + + g_print("-1. DISABLE\n"); + recorder_foreach_supported_audio_encoder(hcamcorder->recorder, audio_codec_cb, (void *)hcamcorder); + + err = scanf("%d", &encoder); + + return recorder_set_audio_encoder(hcamcorder->recorder, encoder); +} + + +static int _recorder_set_file_format(void) +{ + int format = 0; + int err = 0; + + g_print("* File format\n"); + + flush_stdin(); + + recorder_foreach_supported_file_format(hcamcorder->recorder, file_format_cb, (void *)hcamcorder); + + err = scanf("%d", &format); + + return recorder_set_file_format(hcamcorder->recorder, format); +} + + +static int _recorder_set_size_limit(void) +{ + int limit = 0; + int err = 0; + + g_print("* Size limit\n"); + + flush_stdin(); + + g_print("[KByte] : "); + + err = scanf("%d", &limit); + + return recorder_attr_set_size_limit(hcamcorder->recorder, limit); +} + + +static int _recorder_set_time_limit(void) +{ + int limit = 0; + int err = 0; + + g_print("* Time limit\n"); + + flush_stdin(); + + g_print("[Second] : "); + + err = scanf("%d", &limit); + + return recorder_attr_set_time_limit(hcamcorder->recorder, limit); +} + + +static int _recorder_set_audio_samplerate(void) +{ + int samplerate = 0; + int err = 0; + + g_print("* Samplerate\n"); + + flush_stdin(); + + g_print("[Hz] : "); + + err = scanf("%d", &samplerate); + + return recorder_attr_set_audio_samplerate(hcamcorder->recorder, samplerate); +} + + +static int _recorder_set_audio_channel(void) +{ + int channel = 0; + int err = 0; + + g_print("* Channel\n"); + + flush_stdin(); + + g_print("[1 or 2] : "); + + err = scanf("%d", &channel); + + return recorder_attr_set_audio_channel(hcamcorder->recorder, channel); +} + + +static int _recorder_set_encoder_bitrate(void) +{ + int type = 0; + int bitrate = 0; + int err = 0; + + g_print("* Bitrate\n"); + + flush_stdin(); + + g_print("[type(1:Audio,2:Video) bps] : "); + + err = scanf("%d %d", &type, &bitrate); + + switch (type) { + case 1: + return recorder_attr_set_audio_encoder_bitrate(hcamcorder->recorder, bitrate); + case 2: + return recorder_attr_set_video_encoder_bitrate(hcamcorder->recorder, bitrate); + default: + g_print("invalid type [%d]", type); + return -1; + } +} + + static void print_menu() { switch (hcamcorder->menu_state) { @@ -467,43 +620,26 @@ static void print_menu() g_print("\t Choose the menu :\n\t"); break; case MENU_STATE_MAIN: - if (hcamcorder->mode == MODE_VIDEO_CAPTURE) { - g_print("\n\t=======================================\n"); + g_print("\n\t=======================================\n"); + if (hcamcorder->mode == MODE_VIDEO_CAPTURE) g_print("\t Video + Audio Recording\n"); - g_print("\t=======================================\n"); - if (recorder_state <= RECORDER_STATE_NONE) { - g_print("\t '1' Start Recording\n"); - g_print("\t '2' Setting\n"); - g_print("\t 'b' back\n"); - } else if (recorder_state == RECORDER_STATE_RECORDING) { - g_print("\t 'p' Pause Recording\n"); - g_print("\t 'c' Cancel\n"); - g_print("\t 's' Save\n"); - } else if (recorder_state == RECORDER_STATE_PAUSED) { - g_print("\t 'r' Resume Recording\n"); - g_print("\t 'c' Cancel\n"); - g_print("\t 's' Save\n"); - } - g_print("\t=======================================\n"); - } else { - g_print("\n\t=======================================\n"); + else g_print("\t Audio Recording\n"); - g_print("\t=======================================\n"); - if (recorder_state <= RECORDER_STATE_NONE) { - g_print("\t '1' Start Recording\n"); - g_print("\t '2' Setting\n"); - g_print("\t 'b' back\n"); - } else if (recorder_state == RECORDER_STATE_RECORDING) { - g_print("\t 'p' Pause Recording\n"); - g_print("\t 'c' Cancel\n"); - g_print("\t 's' Save\n"); - } else if (recorder_state == RECORDER_STATE_PAUSED) { - g_print("\t 'r' Resume Recording\n"); - g_print("\t 'c' Cancel\n"); - g_print("\t 's' Save\n"); - } - g_print("\t=======================================\n"); + g_print("\t=======================================\n"); + if (recorder_state <= RECORDER_STATE_NONE) { + g_print("\t '1' Start Recording\n"); + g_print("\t '2' Setting\n"); + g_print("\t 'b' back\n"); + } else if (recorder_state == RECORDER_STATE_RECORDING) { + g_print("\t 'p' Pause Recording\n"); + g_print("\t 'c' Cancel\n"); + g_print("\t 's' Save\n"); + } else if (recorder_state == RECORDER_STATE_PAUSED) { + g_print("\t 'r' Resume Recording\n"); + g_print("\t 'c' Cancel\n"); + g_print("\t 's' Save\n"); } + g_print("\t=======================================\n"); break; case MENU_STATE_SETTING: @@ -566,178 +702,99 @@ static void main_menu(gchar buf) { int err = 0; - if (hcamcorder->mode == MODE_VIDEO_CAPTURE) { - if (recorder_state == RECORDER_STATE_NONE) { - switch (buf) { - case '1': /* Start Recording */ - g_print("*Recording start!\n"); - hcamcorder->elapsed_time = 0; - ve_frame_count = 0; - - g_timer_reset(timer); - err = recorder_start(hcamcorder->recorder); + if (hcamcorder->mode != MODE_VIDEO_CAPTURE && hcamcorder->mode != MODE_AUDIO) { + g_print("\t Invalid mode, back to upper menu \n"); + hcamcorder->menu_state = MENU_STATE_INIT; + return; + } - if (err != 0) - g_print("Rec start camcorder_record 0x%x\n", err); + if (recorder_state == RECORDER_STATE_NONE) { + switch (buf) { + case '1': /* Start Recording */ + g_print("*Recording start!\n"); + hcamcorder->elapsed_time = 0; + ve_frame_count = 0; - recorder_state = RECORDER_STATE_RECORDING; - break; + g_timer_reset(timer); + err = recorder_start(hcamcorder->recorder); - case '2': /* Setting */ - hcamcorder->menu_state = MENU_STATE_SETTING; - break; + if (err != 0) + g_print("Rec start camcorder_record 0x%x\n", err); - case 'b': /* back */ - recorder_unprepare(hcamcorder->recorder); - recorder_destroy(hcamcorder->recorder); - hcamcorder->recorder = NULL; + recorder_state = RECORDER_STATE_RECORDING; + break; - if (hcamcorder->camera) { - camera_destroy(hcamcorder->camera); - hcamcorder->camera = NULL; - } + case '2': /* Setting */ + hcamcorder->menu_state = MENU_STATE_SETTING; + break; - hcamcorder->menu_state = MENU_STATE_INIT; - break; + case 'b': /* back */ + recorder_unprepare(hcamcorder->recorder); + recorder_destroy(hcamcorder->recorder); + hcamcorder->recorder = NULL; - default: - g_print("\t Invalid input \n"); - break; + if (hcamcorder->camera) { + camera_destroy(hcamcorder->camera); + hcamcorder->camera = NULL; } - } else if (recorder_state == RECORDER_STATE_RECORDING || recorder_state == RECORDER_STATE_PAUSED) { - switch (buf) { - case 'p': /* Pause Recording */ - g_print("*Pause!\n"); - err = recorder_pause(hcamcorder->recorder); - - if (err < 0) - g_print("Rec pause camcorder_pause = %x\n", err); - - recorder_state = RECORDER_STATE_PAUSED; - break; - - case 'r': /* Resume Recording */ - g_print("*Resume!\n"); - err = recorder_start(hcamcorder->recorder); - if (err < 0) - g_print("Rec start camcorder_record = %x\n", err); - - recorder_state = RECORDER_STATE_RECORDING; - break; - - case 'c': /* Cancel */ - g_print("*Cancel Recording !\n"); - - err = recorder_cancel(hcamcorder->recorder); - - if (err < 0) - g_print("Cancel recording camcorder_cancel = %x\n", err); - - recorder_state = RECORDER_STATE_NONE; - break; - - case 's': /* Save */ - g_print("*Save Recording!\n"); - g_timer_reset(timer); - err = recorder_commit(hcamcorder->recorder); - - if (err < 0) - g_print("Save recording recorder_commit = %x\n", err); - - recorder_state = RECORDER_STATE_NONE; - break; + hcamcorder->menu_state = MENU_STATE_INIT; + break; - default: - g_print("\t Invalid input \n"); - break; - } /* switch */ - } else { - g_print("Wrong camcorder state, check status!!\n"); + default: + g_print("\t Invalid input \n"); + break; } - } else if (hcamcorder->mode == MODE_AUDIO) { - if (recorder_state == RECORDER_STATE_NONE) { - switch (buf) { - case '1': /* Start Recording */ - g_print("*Recording start!\n"); - hcamcorder->elapsed_time = 0; - g_timer_reset(timer); - err = recorder_start(hcamcorder->recorder); - - if (err < 0) - g_print("Rec start camcorder_record = %x\n", err); - - recorder_state = RECORDER_STATE_RECORDING; - break; - - case '2': /* Setting */ - hcamcorder->menu_state = MENU_STATE_SETTING; - break; - - case 'b': /* back */ - recorder_unprepare(hcamcorder->recorder); - recorder_destroy(hcamcorder->recorder); - hcamcorder->recorder = NULL; + } else if (recorder_state == RECORDER_STATE_RECORDING || recorder_state == RECORDER_STATE_PAUSED) { + switch (buf) { + case 'p': /* Pause Recording */ + g_print("*Pause!\n"); + err = recorder_pause(hcamcorder->recorder); - hcamcorder->menu_state = MENU_STATE_INIT; - break; + if (err < 0) + g_print("Rec pause camcorder_pause = %x\n", err); - default: - g_print("\t Invalid input \n"); - break; - } - } else if (recorder_state == RECORDER_STATE_RECORDING || recorder_state == RECORDER_STATE_PAUSED) { - switch (buf) { - case 'p': /* Pause Recording */ - g_print("*Pause!\n"); - err = recorder_pause(hcamcorder->recorder); + recorder_state = RECORDER_STATE_PAUSED; + break; - if (err < 0) - g_print("Rec pause camcorder_pause = %x\n", err); + case 'r': /* Resume Recording */ + g_print("*Resume!\n"); + err = recorder_start(hcamcorder->recorder); + if (err < 0) + g_print("Rec start camcorder_record = %x\n", err); - recorder_state = RECORDER_STATE_PAUSED; - break; + recorder_state = RECORDER_STATE_RECORDING; + break; - case 'r': /* Resume Recording */ - g_print("*Resume!\n"); - err = recorder_start(hcamcorder->recorder); - if (err < 0) - g_print("Rec start camcorder_record = %x\n", err); + case 'c': /* Cancel */ + g_print("*Cancel Recording !\n"); - recorder_state = RECORDER_STATE_RECORDING; - break; + err = recorder_cancel(hcamcorder->recorder); - case 'c': /* Cancel */ - g_print("*Cancel Recording !\n"); - err = recorder_cancel(hcamcorder->recorder); + if (err < 0) + g_print("Cancel recording camcorder_cancel = %x\n", err); - if (err < 0) - g_print("Cancel recording camcorder_cancel = %x\n", err); + recorder_state = RECORDER_STATE_NONE; + break; - recorder_state = RECORDER_STATE_NONE; - break; + case 's': /* Save */ + g_print("*Save Recording!\n"); + g_timer_reset(timer); - case 's': /* Save */ - g_print("*Save Recording!\n"); - g_timer_reset(timer); - err = recorder_commit(hcamcorder->recorder); + err = recorder_commit(hcamcorder->recorder); - if (err < 0) - g_print("Save recording recorder_commit = %x\n", err); + if (err < 0) + g_print("Save recording recorder_commit = %x\n", err); - recorder_state = RECORDER_STATE_NONE; - break; + recorder_state = RECORDER_STATE_NONE; + break; - default: + default: g_print("\t Invalid input \n"); break; - } - } else { - g_print("Wrong camcorder state, check status!!\n"); } } else { - g_print("\t Invalid mode, back to upper menu \n"); - hcamcorder->menu_state = MENU_STATE_INIT; + g_print("Wrong camcorder state, check status!!\n"); } return; @@ -822,99 +879,31 @@ static void setting_menu(gchar buf) break; case '3': /* Setting > Audio codec */ - g_print("* Audio codec\n"); - - flush_stdin(); - - g_print("-1. DISABLE\n"); - recorder_foreach_supported_audio_encoder(hcamcorder->recorder, audio_codec_cb, (void *)hcamcorder); - - err = scanf("%d", &idx); - - result = recorder_set_audio_encoder(hcamcorder->recorder, idx); + result = _recorder_set_audio_encoder(); break; case '4': /* Setting > File format */ - g_print("* File format\n"); - - flush_stdin(); - - recorder_foreach_supported_file_format(hcamcorder->recorder, file_format_cb, (void *)hcamcorder); - - err = scanf("%d", &idx); - - result = recorder_set_file_format(hcamcorder->recorder, idx); + result = _recorder_set_file_format(); break; case '5': /* Setting > Size limit */ - g_print("* Size limit\n"); - - flush_stdin(); - - g_print("[KByte] : "); - - err = scanf("%d", &idx); - - result = recorder_attr_set_size_limit(hcamcorder->recorder, idx); + result = _recorder_set_size_limit(); break; case '6': /* Setting > Time limit */ - g_print("* Time limit\n"); - - flush_stdin(); - - g_print("[Second] : "); - - err = scanf("%d", &idx); - - result = recorder_attr_set_time_limit(hcamcorder->recorder, idx); + result = _recorder_set_time_limit(); break; case '7': /* Setting > Samplerate */ - g_print("* Samplerate\n"); - - flush_stdin(); - - g_print("[Hz] : "); - - err = scanf("%d", &idx); - - result = recorder_attr_set_audio_samplerate(hcamcorder->recorder, idx); + result = _recorder_set_audio_samplerate(); break; case '8': /* Setting > Channel */ - g_print("* Channel\n"); - - flush_stdin(); - - g_print("[1 or 2] : "); - - err = scanf("%d", &idx); - - result = recorder_attr_set_audio_channel(hcamcorder->recorder, idx); + result = _recorder_set_audio_channel(); break; case '9': /* Setting > Bitrate */ - g_print("* Bitrate\n"); - - flush_stdin(); - - g_print("[type(1:Audio,2:Video) bps] : "); - - err = scanf("%d %d", &idx, &bitrate); - - switch (idx) { - case 1: - result = recorder_attr_set_audio_encoder_bitrate(hcamcorder->recorder, bitrate); - break; - case 2: - result = recorder_attr_set_video_encoder_bitrate(hcamcorder->recorder, bitrate); - break; - default: - g_print("invalid type [%d]", idx); - result = -1; - break; - } + result = _recorder_set_encoder_bitrate(); break; /* Display setting */ @@ -1023,21 +1012,7 @@ static void setting_menu(gchar buf) break; case 'M': /* Setting > muxed stream callback */ - g_print("* Muxed stream callback\n"); - - flush_stdin(); - - g_print("[set(1)/unset(2)] : "); - - err = scanf("%d", &idx); - - if (idx == 1) - result = recorder_set_muxed_stream_cb(hcamcorder->recorder, _recording_muxed_stream_cb, NULL); - else if (idx == 2) - result = recorder_unset_muxed_stream_cb(hcamcorder->recorder); - else - result = RECORDER_ERROR_INVALID_PARAMETER; - + result = _recorder_set_muxed_stream_cb(); break; case 'E': /* Setting > video encode decision callback */ @@ -1073,76 +1048,27 @@ static void setting_menu(gchar buf) } else { switch (buf) { case '1': /* Setting > Audio codec */ - g_print("* Audio codec\n"); - - flush_stdin(); - - g_print("-1. DISABLE\n"); - recorder_foreach_supported_audio_encoder(hcamcorder->recorder, audio_codec_cb, (void *)hcamcorder); - - err = scanf("%d", &idx); - - result = recorder_set_audio_encoder(hcamcorder->recorder, idx); + result = _recorder_set_audio_encoder(); break; case '2': /* Setting > File format */ - g_print("* File format\n"); - - flush_stdin(); - - recorder_foreach_supported_file_format(hcamcorder->recorder, file_format_cb, (void *)hcamcorder); - - err = scanf("%d", &idx); - - result = recorder_set_file_format(hcamcorder->recorder, idx); + result = _recorder_set_file_format(); break; case '3': /* Setting > Size limit */ - g_print("* Size limit\n"); - - flush_stdin(); - - g_print("[KByte] : "); - - err = scanf("%d", &idx); - - result = recorder_attr_set_size_limit(hcamcorder->recorder, idx); + result = _recorder_set_size_limit(); break; case '4': /* Setting > Time limit */ - g_print("* Time limit\n"); - - flush_stdin(); - - g_print("[Second] : "); - - err = scanf("%d", &idx); - - result = recorder_attr_set_time_limit(hcamcorder->recorder, idx); + result = _recorder_set_time_limit(); break; case '5': /* Setting > Samplerate */ - g_print("* Samplerate\n"); - - flush_stdin(); - - g_print("[Hz] : "); - - err = scanf("%d", &idx); - - result = recorder_attr_set_audio_samplerate(hcamcorder->recorder, idx); + result = _recorder_set_audio_samplerate(); break; case '6': /* Setting > Channel */ - g_print("* Channel\n"); - - flush_stdin(); - - g_print("[1 or 2] : "); - - err = scanf("%d", &idx); - - result = recorder_attr_set_audio_channel(hcamcorder->recorder, idx); + result = _recorder_set_audio_channel(); break; case '7': /* Setting > Bitrate */ @@ -1158,21 +1084,7 @@ static void setting_menu(gchar buf) break; case 'M': /* Setting > muxed stream callback */ - g_print("* Muxed stream callback\n"); - - flush_stdin(); - - g_print("[set(1)/unset(2)] : "); - - err = scanf("%d", &idx); - - if (idx == 1) - result = recorder_set_muxed_stream_cb(hcamcorder->recorder, _recording_muxed_stream_cb, NULL); - else if (idx == 2) - result = recorder_unset_muxed_stream_cb(hcamcorder->recorder); - else - result = RECORDER_ERROR_INVALID_PARAMETER; - + result = _recorder_set_muxed_stream_cb(); break; case 'F': /* Set file name */ @@ -1255,91 +1167,72 @@ static gboolean cmd_input(GIOChannel *channel, GIOCondition condition, gpointer static gboolean init(int type) { - int err; + int ret; + + if (!hcamcorder || !hcamcorder->recorder) { + g_print("NULL handle[%p]\n", hcamcorder); + return FALSE; + } + + ret = recorder_set_file_format(hcamcorder->recorder, RECORDER_FILE_FORMAT_MP4); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_set_file_format failed[0x%x]\n", ret); + return FALSE; + } + + ret = recorder_attr_set_audio_device(hcamcorder->recorder, RECORDER_AUDIO_DEVICE_MIC); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_attr_set_audio_device failed[0x%x]\n", ret); + return FALSE; + } - if (!hcamcorder) + ret = recorder_set_audio_encoder(hcamcorder->recorder, RECORDER_AUDIO_CODEC_AAC); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_set_audio_encoder failed[0x%x]\n", ret); return FALSE; + } - if (!hcamcorder->recorder) + ret = recorder_attr_set_audio_samplerate(hcamcorder->recorder, AUDIO_SOURCE_SAMPLERATE_AAC); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_attr_set_audio_samplerate failed[0x%x]\n", ret); return FALSE; + } + + ret = recorder_attr_set_audio_channel(hcamcorder->recorder, AUDIO_SOURCE_CHANNEL_AAC); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_attr_set_audio_channel failed[0x%x]\n", ret); + return FALSE; + } - /*================================================================================ - Video capture mode - *=================================================================================*/ if (type == MODE_VIDEO_CAPTURE) { - err = recorder_set_file_format(hcamcorder->recorder, RECORDER_FILE_FORMAT_MP4); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_attr_set_audio_device(hcamcorder->recorder, RECORDER_AUDIO_DEVICE_MIC); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_set_audio_encoder(hcamcorder->recorder, RECORDER_AUDIO_CODEC_AAC); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_set_video_encoder(hcamcorder->recorder, RECORDER_VIDEO_CODEC_MPEG4); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_attr_set_video_encoder_bitrate(hcamcorder->recorder, VIDEO_ENCODE_BITRATE); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_attr_set_audio_samplerate(hcamcorder->recorder, AUDIO_SOURCE_SAMPLERATE_AAC); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; + /*================================================================================ + Video capture mode + *=================================================================================*/ + ret = recorder_set_video_encoder(hcamcorder->recorder, RECORDER_VIDEO_CODEC_MPEG4); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_set_video_encoder failed[0x%x]\n", ret); + return FALSE; } - err = recorder_attr_set_audio_channel(hcamcorder->recorder, AUDIO_SOURCE_CHANNEL_AAC); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; + + ret = recorder_attr_set_video_encoder_bitrate(hcamcorder->recorder, VIDEO_ENCODE_BITRATE); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_attr_set_video_encoder_bitrate failed[0x%x]\n", ret); + return FALSE; } } else if (type == MODE_AUDIO) { - /*================================================================================ - Audio mode - *=================================================================================*/ - err = recorder_set_file_format(hcamcorder->recorder, RECORDER_FILE_FORMAT_MP4); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_attr_set_audio_device(hcamcorder->recorder, RECORDER_AUDIO_DEVICE_MIC); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_set_audio_encoder(hcamcorder->recorder, RECORDER_AUDIO_CODEC_AAC); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_attr_set_audio_samplerate(hcamcorder->recorder, AUDIO_SOURCE_SAMPLERATE_AAC); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_attr_set_audio_channel(hcamcorder->recorder, AUDIO_SOURCE_CHANNEL_AAC); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; - } - err = recorder_attr_set_time_limit(hcamcorder->recorder, 360000); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; + /*================================================================================ + Audio mode + *=================================================================================*/ + ret = recorder_attr_set_time_limit(hcamcorder->recorder, 360000); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_attr_set_time_limit failed[0x%x]\n", ret); + return FALSE; } - err = recorder_attr_set_audio_encoder_bitrate(hcamcorder->recorder, 128000); - if (err < 0) { - g_print("Init fail. (%x)\n", err); - goto ERROR; + + ret = recorder_attr_set_audio_encoder_bitrate(hcamcorder->recorder, 128000); + if (ret != RECORDER_ERROR_NONE) { + g_print("recorder_attr_set_audio_encoder_bitrate failed[0x%x]\n", ret); + return FALSE; } } @@ -1352,10 +1245,6 @@ static gboolean init(int type) g_print("Init DONE.\n"); return TRUE; - -ERROR: - g_print("init failed.\n"); - return FALSE; } static gboolean init_handle() |