#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <mm_types.h>
+#include <inttypes.h>
+#include <camera_internal.h>
#include <recorder.h>
+#include <sound_manager.h>
+#include <sound_manager_internal.h>
+#include <storage.h>
+#include <storage-internal.h>
#include <muse_recorder.h>
#include <muse_recorder_msg.h>
-#include <muse_core_ipc.h>
-#include <recorder_private.h>
-#include <glib.h>
#include <muse_core.h>
-#include <muse_core_msg_json.h>
-#include <mm_camcorder_client.h>
+#include <muse_client.h>
+#include <recorder_private.h>
+#include <gio/gio.h>
#include <dlog.h>
+#include <tzplatform_config.h>
#ifdef LOG_TAG
#undef LOG_TAG
#endif
-#define LOG_TAG "TIZEN_N_RECORDER"
+#define LOG_TAG "TIZEN_N_RECORDER"
+#define MODULE_NAME "recorder"
+
+/* for device changed callback */
+static GMutex g_rec_dev_state_changed_cb_lock;
+static GList *g_rec_dev_state_changed_cb_list;
+static int g_rec_dev_state_changed_cb_id;
+static GDBusConnection *g_rec_dev_state_changed_cb_conn;
+static guint g_rec_dev_state_changed_cb_subscribe_id;
+static GMutex g_rec_idle_event_lock;
+
+
+
+static void __recorder_update_api_waiting(recorder_cb_info_s *cb_info, int api, int value)
+{
+ if (!cb_info ||
+ api < 0 || api >= MUSE_RECORDER_API_MAX) {
+ LOGE("invalid param %p %d", cb_info, api);
+ return;
+ }
+
+ g_mutex_lock(&(cb_info->api_mutex[api]));
+ cb_info->api_waiting[api] += value;
+ g_mutex_unlock(&(cb_info->api_mutex[api]));
+
+ /*LOGD("api %d, value %d, waiting %d",
+ api, value, cb_info->api_waiting[api]);*/
+
+ return;
+}
+
+
+static void __recorder_device_state_changed_cb(GDBusConnection *connection,
+ const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
+ const gchar *signal_name, GVariant *param, gpointer user_data)
+{
+ int value = 0;
+ recorder_type_e type = RECORDER_TYPE_AUDIO;
+ recorder_device_state_e state = RECORDER_DEVICE_STATE_IDLE;
+ GList *tmp_list = NULL;
+ recorder_cb_info *info = NULL;
+
+ g_mutex_lock(&g_rec_dev_state_changed_cb_lock);
+
+ if (!g_rec_dev_state_changed_cb_list || !param) {
+ LOGW("no callback or NULL param %p", param);
+ goto _DONE;
+ }
+
+ /* get device type and state */
+ g_variant_get(param, "(i)", &value);
+
+ type = value >> 16;
+ state = 0x0000ffff & value;
+
+ LOGD("type %d, state %d", type, state);
+
+ tmp_list = g_rec_dev_state_changed_cb_list;
+
+ do {
+ info = (recorder_cb_info *)tmp_list->data;
+
+ if (info) {
+ if (info->callback) {
+ LOGD("start id[%d] callback", info->id);
+ ((recorder_device_state_changed_cb)info->callback)(type, state, info->user_data);
+ LOGD("returned id[%d] callback", info->id);
+ } else {
+ LOGW("NULL callback for id %d", info->id);
+ }
+ }
+
+ tmp_list = tmp_list->next;
+ } while (tmp_list);
+
+_DONE:
+ g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
+
+ return;
+}
+
+
+static int _recorder_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
+{
+ tbm_bo tmp_bo = NULL;
+ tbm_bo_handle tmp_bo_handle = {NULL, };
+
+ if (bufmgr == NULL || bo == NULL || bo_handle == NULL || fd < 0) {
+ LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, fd %d",
+ bufmgr, bo, bo_handle, fd);
+ return false;
+ }
+
+ tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
+ if (tmp_bo == NULL) {
+ LOGE("bo import failed - bufmgr %p, fd %d", bufmgr, fd);
+ return false;
+ }
+
+ tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
+ if (tmp_bo_handle.ptr == NULL) {
+ LOGE("bo map failed %p", tmp_bo);
+ tbm_bo_unref(tmp_bo);
+ tmp_bo = NULL;
+ return false;
+ }
+
+ /* set bo and bo_handle */
+ *bo = tmp_bo;
+ *bo_handle = tmp_bo_handle;
+
+ return true;
+}
-static void _client_user_callback(callback_cb_info_s * cb_info, muse_recorder_event_e event)
+static void _recorder_release_imported_bo(tbm_bo *bo)
{
- char *recvMsg = cb_info->recvMsg;
- LOGD("get event %d", event);
+ if (bo == NULL || *bo == NULL) {
+ LOGW("NULL bo");
+ return;
+ }
+
+ tbm_bo_unmap(*bo);
+ tbm_bo_unref(*bo);
+ *bo = NULL;
+
+ return;
+}
+
+static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *recv_msg, muse_recorder_event_e event, int tfd)
+{
+ if (recv_msg == NULL || event >= MUSE_RECORDER_EVENT_TYPE_NUM) {
+ LOGE("invalid parameter - recorder msg %p, event %d", recv_msg, event);
+ return;
+ }
+
+ /*LOGD("get recorder msg %s, event %d", recv_msg, event);*/
+
+ g_mutex_lock(&cb_info->user_cb_mutex[event]);
+
+ if (cb_info->user_cb[event] == NULL) {
+ if (event != MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM &&
+ event != MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM) {
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+ LOGW("NULL callback for event %d, return here", event);
+ return;
+ } else {
+ LOGW("NULL callback for event %d, NOT return here", event);
+ }
+ }
switch (event) {
- case MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE:
+ case MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE:
{
- int cb_previous, cb_current, cb_by_policy;
- muse_recorder_msg_get(cb_previous, recvMsg);
- muse_recorder_msg_get(cb_current, recvMsg);
- muse_recorder_msg_get(cb_by_policy, recvMsg);
- ((recorder_state_changed_cb)cb_info->user_cb[event])((recorder_state_e)cb_previous,
- (recorder_state_e)cb_current,
- (bool)cb_by_policy,
- cb_info->user_data[event]);
+ int previous = 0;
+ int current = 0;
+ int by_policy = 0;
+
+ muse_recorder_msg_get(previous, recv_msg);
+ muse_recorder_msg_get(current, recv_msg);
+ muse_recorder_msg_get(by_policy, recv_msg);
+
+ ((recorder_state_changed_cb)cb_info->user_cb[event])((recorder_state_e)previous,
+ (recorder_state_e)current,
+ (bool)by_policy,
+ cb_info->user_data[event]);
break;
}
- case MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED:
+ case MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED:
{
- int cb_type;
- muse_recorder_msg_get(cb_type, recvMsg);
- ((recorder_recording_limit_reached_cb)cb_info->user_cb[event])((recorder_recording_limit_type_e)cb_type,
- cb_info->user_data[event]);
+ int type = 0;
+
+ muse_recorder_msg_get(type, recv_msg);
+
+ ((recorder_recording_limit_reached_cb)cb_info->user_cb[event])((recorder_recording_limit_type_e)type,
+ cb_info->user_data[event]);
break;
}
- case MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS:
+ case MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS:
{
- double cb_elapsed_time;
- double cb_file_size;
- muse_recorder_msg_get(cb_elapsed_time, recvMsg);
- muse_recorder_msg_get(cb_file_size, recvMsg);
+ int64_t cb_elapsed_time = 0;
+ int64_t cb_file_size = 0;
+
+ muse_recorder_msg_get_int64(cb_elapsed_time, recv_msg);
+ muse_recorder_msg_get_int64(cb_file_size, recv_msg);
+
((recorder_recording_status_cb)cb_info->user_cb[event])((unsigned long long)cb_elapsed_time,
- (unsigned long long)cb_file_size,
- cb_info->user_data[event]);
+ (unsigned long long)cb_file_size,
+ cb_info->user_data[event]);
break;
}
- case MUSE_RECORDER_EVENT_TYPE_INTERRUPTED:
+ case MUSE_RECORDER_EVENT_TYPE_INTERRUPTED:
{
- int cb_policy, cb_previous, cb_current;
- muse_recorder_msg_get(cb_policy, recvMsg);
- muse_recorder_msg_get(cb_previous, recvMsg);
- muse_recorder_msg_get(cb_current, recvMsg);
- ((recorder_interrupted_cb)cb_info->user_cb[event])((recorder_policy_e)cb_policy,
- (recorder_state_e)cb_previous,
- (recorder_state_e)cb_current,
- cb_info->user_data[event]);
+ int policy = 0;
+ int previous = 0;
+ int current = 0;
+
+ muse_recorder_msg_get(policy, recv_msg);
+ muse_recorder_msg_get(previous, recv_msg);
+ muse_recorder_msg_get(current, recv_msg);
+
+ LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
+
+ ((recorder_interrupted_cb)cb_info->user_cb[event])((recorder_policy_e)policy,
+ (recorder_state_e)previous,
+ (recorder_state_e)current,
+ cb_info->user_data[event]);
break;
}
- case MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM:
+ case MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED:
{
- muse_recorder_transport_info_s transport_info;
- int tKey = 0;
- int cb_size = 0;
- int cb_format;
- int cb_channel;
- int cb_timestamp;
- unsigned char *stream = NULL;
- muse_recorder_msg_get(tKey, recvMsg);
-
- if (tKey != 0) {
- transport_info.tbm_key = tKey;
- LOGE("Read key_info INFO : %d", transport_info.tbm_key);
-
- if(muse_recorder_ipc_init_tbm(&transport_info) == FALSE) {
- LOGE("Initialize TBM ERROR!!");
- break;
- }
+ int policy = 0;
+ int state = 0;
- if(muse_recorder_ipc_import_tbm(&transport_info) == FALSE) {
- LOGE("Import TBM Key ERROR!!");
- break;
+ muse_recorder_msg_get(policy, recv_msg);
+ muse_recorder_msg_get(state, recv_msg);
+
+ LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
+
+ ((recorder_interrupt_started_cb)cb_info->user_cb[event])((recorder_policy_e)policy,
+ (recorder_state_e)state, cb_info->user_data[event]);
+ }
+ break;
+ case MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM:
+ {
+ int audio_fd = -1;
+ int size = 0;
+ int format = 0;
+ int channel = 0;
+ int timestamp = 0;
+ tbm_bo bo = NULL;
+ tbm_bo_handle bo_handle = {.ptr = NULL};
+ char *send_msg = NULL;
+
+ if (tfd < 0) {
+ LOGE("invalid fd %d", tfd);
+ break;
+ }
+
+ muse_recorder_msg_get(audio_fd, recv_msg);
+
+ if (cb_info->user_cb[event]) {
+ if (_recorder_import_tbm_fd(cb_info->bufmgr, tfd, &bo, &bo_handle)) {
+ muse_recorder_msg_get(size, recv_msg);
+ muse_recorder_msg_get(format, recv_msg);
+ muse_recorder_msg_get(channel, recv_msg);
+ muse_recorder_msg_get(timestamp, recv_msg);
+
+ LOGD("%p, size %d, format %d, channel %d, timestamp %d",
+ bo_handle.ptr, size, format, channel, timestamp);
+
+ ((recorder_audio_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
+ size, (audio_sample_type_e)format, channel,
+ (unsigned int)timestamp, cb_info->user_data[event]);
+
+ LOGD("returned");
+
+ /* release imported bo */
+ _recorder_release_imported_bo(&bo);
} else {
- muse_recorder_msg_get(cb_size, recvMsg);
- if (cb_size > 0) {
- stream = (unsigned char *)transport_info.bo_handle.ptr;
- }
+ LOGE("tbm fd %d import failed", tfd);
}
+ }
+
+ /* return buffer */
+ send_msg = muse_core_msg_new(MUSE_RECORDER_API_RETURN_BUFFER,
+ MUSE_TYPE_INT, "ret_fd", audio_fd, NULL);
+
+ if (send_msg) {
+ if (muse_core_msg_send(cb_info->fd, send_msg) <= 0)
+ LOGE("sending message failed");
+
+ muse_core_msg_free(send_msg);
+ send_msg = NULL;
} else {
- LOGE("Get KEY INFO sock msg ERROR!!");
- break;
+ LOGE("failed to create send msg for fd %d", audio_fd);
}
- muse_recorder_msg_get(cb_format, recvMsg);
- muse_recorder_msg_get(cb_channel, recvMsg);
- muse_recorder_msg_get(cb_timestamp, recvMsg);
- ((recorder_audio_stream_cb)cb_info->user_cb[event])((void *)stream,
- cb_size,
- (audio_sample_type_e)cb_format,
- cb_channel,
- (unsigned int)cb_timestamp,
- cb_info->user_data[event]);
- //unref tbm after hand over the buffer.
- muse_recorder_ipc_unref_tbm(&transport_info);
+
+ /* close imported fd */
+ close(tfd);
+ tfd = -1;
break;
}
- case MUSE_RECORDER_EVENT_TYPE_ERROR:
+ case MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM:
{
- int cb_error, cb_current_state;
- muse_recorder_msg_get(cb_error, recvMsg);
- muse_recorder_msg_get(cb_current_state, recvMsg);
- ((recorder_error_cb)cb_info->user_cb[event])((recorder_error_e)cb_error,
- (recorder_state_e)cb_current_state,
- cb_info->user_data[event]);
+ int muxed_fd = -1;
+ int size = 0;
+ int64_t offset = 0;
+
+ tbm_bo bo = NULL;
+ tbm_bo_handle bo_handle = {.ptr = NULL};
+ char *send_msg = NULL;
+
+ if (tfd < 0) {
+ LOGE("invalid fd %d", tfd);
+ break;
+ }
+
+ muse_recorder_msg_get(muxed_fd, recv_msg);
+
+ if (cb_info->user_cb[event]) {
+ if (_recorder_import_tbm_fd(cb_info->bufmgr, tfd, &bo, &bo_handle)) {
+ muse_recorder_msg_get(size, recv_msg);
+ muse_recorder_msg_get_int64(offset, recv_msg);
+
+ LOGD("%p, size %d, offset %"PRId64, bo_handle.ptr, size, offset);
+
+ ((recorder_muxed_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
+ size, (unsigned long long)offset, cb_info->user_data[event]);
+
+ LOGD("returned");
+
+ /* release imported bo */
+ _recorder_release_imported_bo(&bo);
+ } else {
+ LOGE("tbm fd %d import failed", tfd);
+ }
+ }
+
+ /* return buffer */
+ send_msg = muse_core_msg_new(MUSE_RECORDER_API_RETURN_BUFFER,
+ MUSE_TYPE_INT, "ret_fd", muxed_fd, NULL);
+ if (send_msg) {
+ if (muse_core_msg_send(cb_info->fd, send_msg) <= 0)
+ LOGE("sending message failed");
+
+ muse_core_msg_free(send_msg);
+ send_msg = NULL;
+ } else {
+ LOGE("failed to create send msg for fd %d", tfd);
+ }
+
+ /* close imported fd */
+ close(tfd);
+ tfd = -1;
break;
}
- case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER:
+//LCOV_EXCL_START
+ case MUSE_RECORDER_EVENT_TYPE_ERROR:
{
- int cb_codec;
- muse_recorder_msg_get(cb_codec, recvMsg);
- ((recorder_supported_audio_encoder_cb)cb_info->user_cb[event])((recorder_audio_codec_e)cb_codec,
- cb_info->user_data[event]);
+ int error = 0;
+ int current_state = 0;
+
+ muse_recorder_msg_get(error, recv_msg);
+ muse_recorder_msg_get(current_state, recv_msg);
+
+ ((recorder_error_cb)cb_info->user_cb[event])((recorder_error_e)error,
+ (recorder_state_e)current_state,
+ cb_info->user_data[event]);
break;
}
- case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT:
+//LCOV_EXCL_STOP
+ case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER:
{
- int cb_format;
- muse_recorder_msg_get(cb_format, recvMsg);
- ((recorder_supported_file_format_cb)cb_info->user_cb[event])((recorder_file_format_e)cb_format,
- cb_info->user_data[event]);
+ int codec = 0;
+
+ muse_recorder_msg_get(codec, recv_msg);
+
+ if (((recorder_supported_audio_encoder_cb)cb_info->user_cb[event])((recorder_audio_codec_e)codec, cb_info->user_data[event]) == false) {
+ cb_info->user_cb[event] = NULL;
+ cb_info->user_data[event] = NULL;
+ /*LOGD("stop foreach callback for SUPPORTED_AUDIO_ENCODER");*/
+ }
break;
}
- case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER:
+ case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT:
{
- int cb_codec;
- muse_recorder_msg_get(cb_codec, recvMsg);
- ((recorder_supported_video_encoder_cb)cb_info->user_cb[event])((recorder_video_codec_e)cb_codec,
- cb_info->user_data[event]);
+ int format = 0;
+
+ muse_recorder_msg_get(format, recv_msg);
+
+ if (((recorder_supported_file_format_cb)cb_info->user_cb[event])((recorder_file_format_e)format, cb_info->user_data[event]) == false) {
+ cb_info->user_cb[event] = NULL;
+ cb_info->user_data[event] = NULL;
+ /*LOGD("stop foreach callback for SUPPORTED_FILE_FORMAT");*/
+ }
break;
}
- case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION:
+ case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER:
{
- int width;
- int height;
- muse_recorder_msg_get(width, recvMsg);
- muse_recorder_msg_get(height, recvMsg);
- ((recorder_supported_video_resolution_cb)cb_info->user_cb[event])(width,
- height,
- cb_info->user_data[event]);
+ int codec = 0;
+
+ muse_recorder_msg_get(codec, recv_msg);
+
+ if (((recorder_supported_video_encoder_cb)cb_info->user_cb[event])((recorder_video_codec_e)codec, cb_info->user_data[event]) == false) {
+ cb_info->user_cb[event] = NULL;
+ cb_info->user_data[event] = NULL;
+ /*LOGD("stop foreach callback for SUPPORTED_VIDEO_ENCODER");*/
+ }
break;
}
+ default: /* MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION */
+ {
+ int width = 0;
+ int height = 0;
- default:
- LOGE("Unknonw event");
+ muse_recorder_msg_get(width, recv_msg);
+ muse_recorder_msg_get(height, recv_msg);
+
+ if (((recorder_supported_video_resolution_cb)cb_info->user_cb[event])(width, height, cb_info->user_data[event]) == false) {
+ cb_info->user_cb[event] = NULL;
+ cb_info->user_data[event] = NULL;
+ /*LOGD("stop foreach callback for SUPPORTED_VIDEO_RESOLUTION");*/
+ }
break;
+ }
}
+
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+
return;
}
-static void *_client_cb_handler(gpointer data)
+
+static gboolean _recorder_idle_event_callback(gpointer data)
{
- int ret;
- int api;
- int num_token = 0;
- int i = 0;
- int str_pos = 0;
- int prev_pos = 0;
- callback_cb_info_s *cb_info = data;
- char *recvMsg = cb_info->recvMsg;
- char parseStr[RECORDER_PARSE_STRING_SIZE][MUSE_RECORDER_MSG_MAX_LENGTH] = {{0,0},};
+ recorder_cb_info_s *cb_info = NULL;
+ recorder_idle_event_s *rec_idle_event = (recorder_idle_event_s *)data;
- while (g_atomic_int_get(&cb_info->running)) {
- ret = muse_core_ipc_recv_msg(cb_info->fd, recvMsg);
- if (ret <= 0)
- break;
- recvMsg[ret] = '\0';
- str_pos = 0;
- prev_pos = 0;
- num_token = 0;
- memset(parseStr, 0, RECORDER_PARSE_STRING_SIZE * MUSE_RECORDER_MSG_MAX_LENGTH);
- LOGD("recvMSg : %s, length : %d", recvMsg, ret);
-
- /* Need to split the combined entering msgs.
- This module supports up to 5 combined msgs. */
- for (str_pos = 0; str_pos < ret; str_pos++) {
- if(recvMsg[str_pos] == '}') {
- strncpy(&(parseStr[num_token][0]), recvMsg + prev_pos, str_pos - prev_pos + 1);
- LOGD("splitted msg : %s, Index : %d", &(parseStr[num_token][0]), num_token);
- prev_pos = str_pos+1;
- num_token++;
- }
- }
- LOGD("num_token : %d", num_token);
- /* Re-construct to the useful single msg. */
- for (i = 0; i < num_token; i++) {
+ if (rec_idle_event == NULL) {
+ LOGE("rec_idle_event is NULL");
+ return FALSE;
+ }
- if (i >= RECORDER_PARSE_STRING_SIZE)
- break;
- if (muse_recorder_msg_get(api, &(parseStr[i][0]))) {
- if(api < MUSE_RECORDER_API_MAX){
- LOGD("api : %d, wait ends.", api);
- g_mutex_lock(&(cb_info->pMutex[api]));
- /* The api msgs should be distinguished from the event msg. */
- memset(cb_info->recvApiMsg, 0, strlen(cb_info->recvApiMsg));
- strcpy(cb_info->recvApiMsg, &(parseStr[i][0]));
- LOGD("cb_info->recvApiMsg : %s", cb_info->recvApiMsg);
- cb_info->activating[api] = 1;
- g_cond_signal(&(cb_info->pCond[api]));
- g_mutex_unlock(&(cb_info->pMutex[api]));
- if(api == MUSE_RECORDER_API_DESTROY) {
- g_atomic_int_set(&cb_info->running, 0);
- LOGD("close client cb handler");
- }
-
- } else if(api == MUSE_RECORDER_CB_EVENT) {
- int event;
- if (muse_recorder_msg_get(event, &(parseStr[i][0]))) {
- LOGD("go callback : %d", event);
- _client_user_callback(cb_info, event);
- }
- }
- }else{
- LOGD("muse_recorder_msg_get FAIL");
- }
- }
+ /* lock event */
+ g_mutex_lock(&g_rec_idle_event_lock);
+
+ cb_info = rec_idle_event->cb_info;
+ if (cb_info == NULL) {
+ LOGW("recorder cb_info is NULL. event %p %d", rec_idle_event, rec_idle_event->event);
+ g_mutex_unlock(&g_rec_idle_event_lock);
+ goto IDLE_EVENT_CALLBACK_DONE;
}
- LOGD("client cb exit");
- return NULL;
-}
+ /* remove event from list */
+ if (cb_info->idle_event_list)
+ cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
-static callback_cb_info_s *_client_callback_new(gint sockfd)
-{
- callback_cb_info_s *cb_info;
- GCond *recorder_cond;
- GMutex *recorder_mutex;
- gint *recorder_activ;
- g_return_val_if_fail(sockfd > 0, NULL);
+ g_mutex_unlock(&g_rec_idle_event_lock);
- cb_info = g_new0(callback_cb_info_s, 1);
- recorder_cond = g_new0(GCond, MUSE_RECORDER_API_MAX);
- recorder_mutex = g_new0(GMutex, MUSE_RECORDER_API_MAX);
- recorder_activ = g_new0(gint, MUSE_RECORDER_API_MAX);
+ /* user callback */
+ _recorder_client_user_callback(cb_info, rec_idle_event->recv_msg, rec_idle_event->event, -1);
- g_atomic_int_set(&cb_info->running, 1);
- cb_info->fd = sockfd;
- cb_info->pCond = recorder_cond;
- cb_info->pMutex = recorder_mutex;
- cb_info->activating = recorder_activ;
- cb_info->thread =
- g_thread_new("callback_thread", _client_cb_handler,
- (gpointer) cb_info);
+IDLE_EVENT_CALLBACK_DONE:
+ /* release event */
+ g_free(rec_idle_event);
+ rec_idle_event = NULL;
- return cb_info;
+ return FALSE;
}
-static int client_wait_for_cb_return(muse_recorder_api_e api, callback_cb_info_s *cb_info, int time_out)
+
+static void _recorder_deactivate_idle_event_all(recorder_cb_info_s *cb_info)
{
- int ret = RECORDER_ERROR_NONE;
- gint64 end_time;
+ recorder_idle_event_s *rec_idle_event = NULL;
+ GList *list = NULL;
- LOGD("Enter api : %d", api);
- g_mutex_lock(&(cb_info->pMutex[api]));
+ if (cb_info == NULL) {
+ LOGE("cb_info is NULL");
+ return;
+ }
- end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
- if (cb_info->activating[api] != 1) {
- if (g_cond_wait_until(&(cb_info->pCond[api]), &(cb_info->pMutex[api]), end_time)) {
- LOGD("cb_info->recvApiMsg : %s", cb_info->recvApiMsg);
- if (!muse_recorder_msg_get(ret, cb_info->recvApiMsg)) {
- ret = RECORDER_ERROR_INVALID_OPERATION;
- } else {
- LOGD("API %d passed successfully", api);
- }
- } else {
- ret = RECORDER_ERROR_INVALID_OPERATION;
- }
+ g_mutex_lock(&g_rec_idle_event_lock);
+
+ if (cb_info->idle_event_list == NULL) {
+ LOGD("No event");
} else {
- LOGD("condition is already checked for the api : %d.", api);
- cb_info->activating[api] = 0;
- if (!muse_recorder_msg_get(ret, cb_info->recvApiMsg)) {
- ret = RECORDER_ERROR_INVALID_OPERATION;
- } else {
- LOGD("Already checked condition, Wait passed, ret : 0x%x", ret);
+ list = cb_info->idle_event_list;
+
+ while (list) {
+ rec_idle_event = list->data;
+ list = g_list_next(list);
+
+ if (!rec_idle_event) {
+ LOGW("The event is NULL");
+ continue;
+ }
+
+ if (g_idle_remove_by_data(rec_idle_event)) {
+ LOGW("remove idle event %p done", rec_idle_event);
+
+ cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
+
+ g_free(rec_idle_event);
+ rec_idle_event = NULL;
+
+ continue;
+ }
+
+ LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
+ rec_idle_event, rec_idle_event->event);
+
+ rec_idle_event->cb_info = NULL;
+
+ cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
}
+
+ g_list_free(cb_info->idle_event_list);
+ cb_info->idle_event_list = NULL;
}
- g_mutex_unlock(&(cb_info->pMutex[api]));
- LOGD("ret of api %d : 0x%x", api, ret);
- return ret;
+
+ g_mutex_unlock(&g_rec_idle_event_lock);
+
+ return;
}
-static void _client_callback_destroy(callback_cb_info_s * cb_info)
+
+static void __recorder_add_msg_to_queue(recorder_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int tfd)
{
- g_return_if_fail(cb_info != NULL);
+ recorder_message_s *rec_msg = NULL;
+ recorder_msg_handler_info_s *msg_handler_info = NULL;
+
+ if (!cb_info || !msg) {
+ LOGE("NULL pointer %p %p", cb_info, msg);
+ return;
+ }
+
+ rec_msg = g_new0(recorder_message_s, 1);
+ if (!rec_msg) {
+ LOGE("failed to alloc rec_msg for [%s]", msg);
+ return;
+ }
+
+ rec_msg->api = api;
+ rec_msg->event = event;
+ rec_msg->event_class = event_class;
+ rec_msg->tfd = tfd;
+
+ strncpy(rec_msg->recv_msg, msg, sizeof(rec_msg->recv_msg) - 1);
+
+ /*LOGD("add recorder message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
- LOGI("%p Callback destroyed", cb_info->thread);
- g_thread_join(cb_info->thread);
- g_thread_unref(cb_info->thread);
+ if (event == MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM)
+ msg_handler_info = &cb_info->audio_stream_cb_info;
+ else if (event == MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM)
+ msg_handler_info = &cb_info->muxed_stream_cb_info;
+ else
+ msg_handler_info = &cb_info->msg_handler_info;
+
+ g_mutex_lock(&msg_handler_info->mutex);
+ g_queue_push_tail(msg_handler_info->queue, (gpointer)rec_msg);
+ g_cond_signal(&msg_handler_info->cond);
+ g_mutex_unlock(&msg_handler_info->mutex);
+
+ rec_msg = NULL;
+
+ return;
+}
- if (cb_info->pCond) {
- g_free(cb_info->pCond);
+static void __recorder_get_api_operation(int api, recorder_cb_info_s *cb_info, char *msg)
+{
+ if (!cb_info || !msg) {
+ LOGE("NULL pointer %p %p", cb_info, msg);
+ return;
}
- if (cb_info->pMutex) {
- g_free(cb_info->pMutex);
+
+ switch (api) {
+ case MUSE_RECORDER_API_GET_STATE:
+ {
+ int get_state = 0;
+ muse_recorder_msg_get(get_state, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_STATE] = get_state;
+ }
+ break;
+ case MUSE_RECORDER_API_GET_VIDEO_RESOLUTION:
+ {
+ int get_width = 0;
+ int get_height = 0;
+ muse_recorder_msg_get(get_width, msg);
+ muse_recorder_msg_get(get_height, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] = get_width << 16;
+ cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] |= get_height;
+ }
+ break;
+ case MUSE_RECORDER_API_GET_FILE_FORMAT:
+ {
+ int get_format = 0;
+ muse_recorder_msg_get(get_format, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT] = get_format;
+ }
+ break;
+ case MUSE_RECORDER_API_GET_AUDIO_ENCODER:
+ {
+ int get_codec = 0;
+ muse_recorder_msg_get(get_codec, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER] = get_codec;
+ }
+ break;
+ case MUSE_RECORDER_API_GET_VIDEO_ENCODER:
+ {
+ int get_codec = 0;
+ muse_recorder_msg_get(get_codec, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER] = get_codec;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT:
+ {
+ int get_kbyte = 0;
+ muse_recorder_msg_get(get_kbyte, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT] = get_kbyte;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT:
+ {
+ int get_second = 0;
+ muse_recorder_msg_get(get_second, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT] = get_second;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE:
+ {
+ int get_device = 0;
+ muse_recorder_msg_get(get_device, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE] = get_device;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE:
+ {
+ int get_samplerate = 0;
+ muse_recorder_msg_get(get_samplerate, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE] = get_samplerate;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE:
+ {
+ int get_bitrate = 0;
+ muse_recorder_msg_get(get_bitrate, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE] = get_bitrate;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE:
+ {
+ int get_bitrate = 0;
+ muse_recorder_msg_get(get_bitrate, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE] = get_bitrate;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE:
+ {
+ double get_rate = 0;
+ muse_recorder_msg_get_double(get_rate, msg);
+ cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE] = get_rate;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL:
+ {
+ int get_channel_count = 0;
+ muse_recorder_msg_get(get_channel_count, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL] = get_channel_count;
+ }
+ break;
+ case MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG:
+ {
+ int get_orientation = 0;
+ muse_recorder_msg_get(get_orientation, msg);
+ cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG] = get_orientation;
+ }
+ break;
+ case MUSE_RECORDER_API_GET_AUDIO_LEVEL:
+ {
+ double get_level = 0.0;
+ muse_recorder_msg_get_double(get_level, msg);
+ cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL] = get_level;
+ }
+ break;
+ case MUSE_RECORDER_API_GET_FILENAME:
+ {
+ char get_filename[MUSE_RECORDER_MSG_MAX_LENGTH] = {'\0',};
+ muse_recorder_msg_get_string(get_filename, msg);
+ if (cb_info->get_filename) {
+ free(cb_info->get_filename);
+ cb_info->get_filename = NULL;
+ }
+ cb_info->get_filename = strdup(get_filename);
+ }
+ break;
+ default:
+ break;
}
- g_free(cb_info);
+
+ return;
}
-int recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
+
+static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg, int tfd)
{
- if (camera == NULL) {
- LOGE("NULL pointer camera handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
+ int ret = RECORDER_ERROR_NONE;
+ int api = -1;
+ int api_class = -1;
+ int event = -1;
+ int event_class = -1;
+
+ if (!cb_info || !msg) {
+ LOGE("invalid ptr %p %p", cb_info, msg);
+ return;
}
- if (recorder == NULL) {
- LOGE("NULL pointer recorder handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
+
+ /*LOGD("msg [%s]", msg);*/
+
+ if (!muse_recorder_msg_get(api, msg)) {
+ LOGE("failed to get recorder api");
+ return;
}
- int sock_fd = -1;
- char *sndMsg;
- int ret = RECORDER_ERROR_NONE;
- camera_cli_s *camera_pc = (camera_cli_s *)camera;
- recorder_cli_s *pc;
- muse_recorder_api_e api = MUSE_RECORDER_API_CREATE;
- muse_core_api_module_e muse_module = MUSE_RECORDER;
- intptr_t camera_handle = (intptr_t)camera_pc->remote_handle;
- intptr_t handle;
- int recorder_type = MUSE_RECORDER_TYPE_VIDEO;
+ if (api == MUSE_RECORDER_CB_EVENT) {
+ if (!muse_recorder_msg_get(event, msg) ||
+ !muse_recorder_msg_get(event_class, msg)) {
+ LOGE("failed to get event or event_class [%s]", msg);
+ return;
+ }
+ } else {
+ if (!muse_recorder_msg_get(api_class, msg)) {
+ LOGE("failed to get api_class [%s]", msg);
+ return;
+ }
+ }
- pc = g_new0(recorder_cli_s, 1);
- if (pc == NULL) {
- return 0;
+ if (api_class == MUSE_RECORDER_API_CLASS_IMMEDIATE) {
+ if (api >= MUSE_RECORDER_API_MAX) {
+ LOGE("invalid api %d", api);
+ return;
+ }
+
+ if (!muse_recorder_msg_get(ret, msg)) {
+ LOGE("failed to get recorder ret");
+ return;
+ }
+
+ g_mutex_lock(&cb_info->api_mutex[api]);
+
+ if (api == MUSE_RECORDER_API_GET_DEVICE_STATE) {
+ g_atomic_int_set(&cb_info->msg_recv_running, 0);
+ LOGD("get device state done. close client cb handler");
+ } else {
+ switch (api) {
+ case MUSE_RECORDER_API_CREATE:
+ if (ret != RECORDER_ERROR_NONE) {
+ g_atomic_int_set(&cb_info->msg_recv_running, 0);
+ LOGE("create error 0x%x. closing..", ret);
+ }
+ break;
+ case MUSE_RECORDER_API_DESTROY:
+ if (ret == RECORDER_ERROR_NONE) {
+ g_atomic_int_set(&cb_info->msg_recv_running, 0);
+ LOGD("destroy done. closing..");
+ }
+ break;
+ default:
+ __recorder_get_api_operation(api, cb_info, msg);
+ break;
+ }
+ }
+
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = TRUE;
+
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGE("no waiting for api [%d]", api);
+ }
+
+ g_mutex_unlock(&cb_info->api_mutex[api]);
+ } else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB || api == MUSE_RECORDER_CB_EVENT) {
+ __recorder_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
+ } else {
+ LOGW("unknown recorder api %d and api_class %d", api, api_class);
+ }
+
+ return;
+}
+
+
+static void *_recorder_msg_handler_func(gpointer data)
+{
+ int api = 0;
+ int type = 0;
+ recorder_message_s *rec_msg = NULL;
+ recorder_idle_event_s *rec_idle_event = NULL;
+ recorder_msg_handler_info_s *handler_info = (recorder_msg_handler_info_s *)data;
+ recorder_cb_info_s *cb_info = NULL;
+
+ if (!handler_info || !handler_info->cb_info) {
+ LOGE("NULL handler %p", handler_info);
+ return NULL;
+ }
+
+ cb_info = (recorder_cb_info_s *)handler_info->cb_info;
+ type = handler_info->type;
+
+ LOGD("t:%d start", type);
+
+ g_mutex_lock(&handler_info->mutex);
+
+ while (g_atomic_int_get(&handler_info->running)) {
+ if (g_queue_is_empty(handler_info->queue)) {
+ /*LOGD("signal wait...");*/
+ g_cond_wait(&handler_info->cond, &handler_info->mutex);
+ /*LOGD("signal received");*/
+
+ if (g_atomic_int_get(&handler_info->running) == 0) {
+ LOGD("stop event thread");
+ break;
+ }
+ }
+
+ rec_msg = (recorder_message_s *)g_queue_pop_head(handler_info->queue);
+ g_mutex_unlock(&handler_info->mutex);
+ if (rec_msg == NULL) {
+ LOGE("NULL message");
+ g_mutex_lock(&handler_info->mutex);
+ continue;
+ }
+
+ api = rec_msg->api;
+
+ if (api < MUSE_RECORDER_API_MAX) {
+ int ret = 0;
+
+ g_mutex_lock(&cb_info->api_mutex[api]);
+
+ if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = TRUE;
+
+ /*LOGD("recorder api %d - return 0x%x", api, ret);*/
+
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGE("no waiting for api [%d]", api);
+ }
+ } else {
+ LOGE("t:%d failed to get ret for api %d, msg %s", type, api, rec_msg->recv_msg);
+ }
+
+ g_mutex_unlock(&cb_info->api_mutex[api]);
+ } else if (api == MUSE_RECORDER_CB_EVENT) {
+ switch (rec_msg->event_class) {
+ case MUSE_RECORDER_EVENT_CLASS_THREAD_SUB:
+ _recorder_client_user_callback(cb_info, rec_msg->recv_msg, rec_msg->event, rec_msg->tfd);
+ break;
+ case MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN:
+ rec_idle_event = g_new0(recorder_idle_event_s, 1);
+ if (rec_idle_event == NULL) {
+ LOGE("event alloc failed");
+ break;
+ }
+
+ rec_idle_event->event = rec_msg->event;
+ rec_idle_event->cb_info = cb_info;
+
+ strncpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg));
+
+ /*LOGD("add recorder event[%d, %p] to IDLE", rec_msg->event, rec_idle_event);*/
+
+ g_mutex_lock(&g_rec_idle_event_lock);
+ cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)rec_idle_event);
+ g_mutex_unlock(&g_rec_idle_event_lock);
+
+ g_idle_add_full(G_PRIORITY_DEFAULT,
+ (GSourceFunc)_recorder_idle_event_callback,
+ (gpointer)rec_idle_event,
+ NULL);
+ break;
+ default:
+ LOGE("unknown event class %d", rec_msg->event_class);
+ break;
+ }
+ } else {
+ LOGE("unknown api[%d] message", api);
+ }
+
+ g_free(rec_msg);
+ rec_msg = NULL;
+
+ g_mutex_lock(&handler_info->mutex);
+ }
+
+ /* remove remained event */
+ while (!g_queue_is_empty(handler_info->queue)) {
+ rec_msg = (recorder_message_s *)g_queue_pop_head(handler_info->queue);
+ if (rec_msg) {
+ LOGD("remove message %p", rec_msg);
+ free(rec_msg);
+ rec_msg = NULL;
+ } else {
+ LOGW("NULL message");
+ }
+ }
+
+ g_mutex_unlock(&handler_info->mutex);
+
+ LOGD("return");
+
+ return NULL;
+}
+
+
+static void *_recorder_msg_recv_func(gpointer data)
+{
+ int recv_length = 0;
+ int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
+ char *recv_msg = NULL;
+ recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
+
+ if (cb_info == NULL) {
+ LOGE("cb_info NULL");
+ return NULL;
+ }
+
+ LOGD("start");
+
+ recv_msg = cb_info->recv_msg;
+
+ while (g_atomic_int_get(&cb_info->msg_recv_running)) {
+ /* tfd[0] is only used. */
+ tfd[0] = -1;
+
+ recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
+ if (recv_length <= 0) {
+//LCOV_EXCL_START
+ cb_info->is_server_connected = FALSE;
+ LOGE("receive msg failed - server disconnected");
+ break;
+//LCOV_EXCL_STOP
+ }
+
+ recv_msg[recv_length] = '\0';
+
+ /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
+
+ __recorder_process_msg(cb_info, recv_msg, tfd[0]);
+ }
+
+ LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
+
+ if (!cb_info->is_server_connected) {
+//LCOV_EXCL_START
+ /* send error msg for server disconnection */
+ char *error_msg = muse_core_msg_new(MUSE_RECORDER_CB_EVENT,
+ MUSE_TYPE_INT, "error", RECORDER_ERROR_SERVICE_DISCONNECTED,
+ MUSE_TYPE_INT, "current_state", RECORDER_STATE_NONE,
+ NULL);
+
+ if (!error_msg) {
+ LOGE("error_msg failed");
+ goto CB_HANDLER_EXIT;
+ }
+
+ LOGE("add error msg for service disconnection done");
+
+ __recorder_add_msg_to_queue(cb_info,
+ MUSE_RECORDER_CB_EVENT,
+ MUSE_RECORDER_EVENT_TYPE_ERROR,
+ MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN,
+ error_msg,
+ -1);
+
+ muse_core_msg_free(error_msg);
+ error_msg = NULL;
+
+ LOGE("add error msg for service disconnection done");
+//LCOV_EXCL_STOP
+ }
+
+CB_HANDLER_EXIT:
+ return NULL;
+}
+
+
+static bool __create_msg_handler_thread(recorder_msg_handler_info_s *handler_info,
+ int type, const char *thread_name, recorder_cb_info_s *cb_info)
+{
+ if (!handler_info || !thread_name || !cb_info) {
+ LOGE("t:%d NULL %p %p %p",
+ type, handler_info, thread_name, cb_info);
+ return false;
+ }
+
+ LOGD("t:%d", type);
+
+ handler_info->type = type;
+ handler_info->queue = g_queue_new();
+ if (handler_info->queue == NULL) {
+ LOGE("t:%d queue failed", type);
+ return false;
+ }
+
+ g_mutex_init(&handler_info->mutex);
+ g_cond_init(&handler_info->cond);
+
+ handler_info->cb_info = (void *)cb_info;
+ g_atomic_int_set(&handler_info->running, 1);
+
+ handler_info->thread = g_thread_try_new(thread_name,
+ _recorder_msg_handler_func, (gpointer)handler_info, NULL);
+ if (handler_info->thread == NULL) {
+//LCOV_EXCL_START
+ LOGE("t:%d thread failed", type);
+
+ g_mutex_clear(&handler_info->mutex);
+ g_cond_clear(&handler_info->cond);
+ g_queue_free(handler_info->queue);
+ handler_info->queue = NULL;
+
+ return false;
+//LCOV_EXCL_STOP
+ }
+
+ LOGD("t:%d done", type);
+
+ return true;
+}
+
+
+static void __destroy_msg_handler_thread(recorder_msg_handler_info_s *handler_info)
+{
+ int type = 0;
+
+ if (!handler_info) {
+ LOGE("NULL handler");
+ return;
+ }
+
+ if (!handler_info->thread) {
+ LOGW("thread is not created");
+ return;
+ }
+
+ type = handler_info->type;
+
+ LOGD("t:%d thread %p", type, handler_info->thread);
+
+ g_mutex_lock(&handler_info->mutex);
+ g_atomic_int_set(&handler_info->running, 0);
+ g_cond_signal(&handler_info->cond);
+ g_mutex_unlock(&handler_info->mutex);
+
+ g_thread_join(handler_info->thread);
+ handler_info->thread = NULL;
+
+ g_mutex_clear(&handler_info->mutex);
+ g_cond_clear(&handler_info->cond);
+ g_queue_free(handler_info->queue);
+ handler_info->queue = NULL;
+
+ LOGD("t:%d done", type);
+
+ return;
+}
+
+
+static recorder_cb_info_s *_recorder_client_callback_new(gint sockfd)
+{
+ recorder_cb_info_s *cb_info = NULL;
+ gint i = 0;
+
+ g_return_val_if_fail(sockfd > 0, NULL);
+
+ cb_info = g_new0(recorder_cb_info_s, 1);
+ if (cb_info == NULL) {
+ LOGE("cb_info failed");
+ goto ErrorExit;
+ }
+
+ cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 1;
+
+ for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
+ g_mutex_init(&cb_info->api_mutex[i]);
+ g_cond_init(&cb_info->api_cond[i]);
+ }
+
+ for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+ g_mutex_init(&cb_info->user_cb_mutex[i]);
+
+ /* message handler thread */
+ if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
+ _RECORDER_MESSAGE_HANDLER_TYPE_GENERAL, "recorder_msg_handler", cb_info)) {
+ LOGE("msg_handler_info failed");
+ goto ErrorExit;
+ }
+
+ /* message handler thread for audio stream callback */
+ if (!__create_msg_handler_thread(&cb_info->audio_stream_cb_info,
+ _RECORDER_MESSAGE_HANDLER_TYPE_AUDIO_STREAM_CB, "recorder_msg_handler:audio_stream_cb", cb_info)) {
+ LOGE("audio_stream_cb_info failed");
+ goto ErrorExit;
+ }
+
+ /* message handler thread for muxed stream callback */
+ if (!__create_msg_handler_thread(&cb_info->muxed_stream_cb_info,
+ _RECORDER_MESSAGE_HANDLER_TYPE_MUXED_STREAM_CB, "recorder_msg_handler:muxed_stream_cb", cb_info)) {
+ LOGE("muxed_stream_cb_info failed");
+ goto ErrorExit;
+ }
+
+ cb_info->fd = sockfd;
+
+ /* message receive thread */
+ g_atomic_int_set(&cb_info->msg_recv_running, 1);
+ cb_info->msg_recv_thread = g_thread_try_new("recorder_msg_recv",
+ _recorder_msg_recv_func, (gpointer)cb_info, NULL);
+ if (cb_info->msg_recv_thread == NULL) {
+ LOGE("message receive thread creation failed");
+ goto ErrorExit;
+ }
+
+ cb_info->is_server_connected = TRUE;
+
+ return cb_info;
+//LCOV_EXCL_START
+ErrorExit:
+ if (cb_info) {
+ __destroy_msg_handler_thread(&cb_info->msg_handler_info);
+ __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
+ __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
+
+ for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
+ for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
+ g_mutex_clear(&cb_info->api_mutex[i]);
+ g_cond_clear(&cb_info->api_cond[i]);
+ }
+
+ g_free(cb_info);
+ cb_info = NULL;
+ }
+
+ return NULL;
+//LCOV_EXCL_STOP
+}
+
+static int _recorder_client_wait_for_cb_return(muse_recorder_api_e api, recorder_cb_info_s *cb_info, int time_out)
+{
+ int ret = RECORDER_ERROR_NONE;
+ gint64 end_time;
+
+ /*LOGD("Enter api : %d", api);*/
+
+ if (!cb_info->is_server_connected) {
+ LOGE("server is disconnected");
+ return RECORDER_ERROR_SERVICE_DISCONNECTED;
+ }
+
+ g_mutex_lock(&(cb_info->api_mutex[api]));
+
+ LOGD("api [%d], timeout [%d sec]", api, time_out);
+
+ end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
+
+ while (!cb_info->api_activating[api]) {
+ if (time_out == RECORDER_CB_NO_TIMEOUT) {
+ g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
+ LOGW("api %d returned 0x%x", api, cb_info->api_ret[api]);
+ } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
+ LOGE("api %d was TIMED OUT!", api);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _CB_RETURN_END;
+ }
+
+ if (!cb_info->api_activating[api])
+ LOGW("invalid signal received, wait again...");
+ }
+
+ ret = cb_info->api_ret[api];
+ cb_info->api_activating[api] = FALSE;
+
+_CB_RETURN_END:
+ g_mutex_unlock(&(cb_info->api_mutex[api]));
+
+ if (ret != RECORDER_ERROR_NONE)
+ LOGE("ERROR : api %d - ret 0x%x", api, ret);
+
+ return ret;
+}
+
+
+static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret, int timeout)
+{
+ int send_ret = 0;
+ char *msg = NULL;
+
+ if (!cb_info || !ret) {
+ LOGE("invalid pointer for api %d - %p %p", api, cb_info, ret);
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ msg = muse_core_msg_new(api, NULL);
+ if (!msg) {
+ LOGE("msg creation failed: api %d", api);
+ return RECORDER_ERROR_OUT_OF_MEMORY;
+ }
+
+ /*LOGD("send msg %s", msg);*/
+
+ if (cb_info->is_server_connected) {
+ __recorder_update_api_waiting(cb_info, api, 1);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ }
+
+ if (send_ret < 0) {
+ LOGE("message send failed");
+ *ret = RECORDER_ERROR_INVALID_OPERATION;
+ } else {
+ *ret = _recorder_client_wait_for_cb_return(api, cb_info, timeout);
+ }
+
+ __recorder_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+ return RECORDER_ERROR_NONE;
+}
+
+
+static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *ret, recorder_msg_param *param)
+{
+ int send_ret = 0;
+ char *msg = NULL;
+
+ if (!cb_info || !ret || !param) {
+ LOGE("invalid pointer for api %d - %p %p %p", api, cb_info, ret, param);
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ /*LOGD("type %d, name %s", param->type, param->name);*/
+
+ switch (param->type) {
+ case MUSE_TYPE_INT:
+ msg = muse_core_msg_new(api, param->type, param->name, param->value.value_INT, NULL);
+ break;
+ case MUSE_TYPE_DOUBLE:
+ msg = muse_core_msg_new(api, param->type, param->name, param->value.value_DOUBLE, NULL);
+ break;
+ case MUSE_TYPE_STRING:
+ msg = muse_core_msg_new(api, param->type, param->name, param->value.value_STRING, NULL);
+ break;
+ default:
+ LOGE("unknown type %d", param->type);
+ break;
+ }
+
+ if (!msg) {
+ LOGE("msg creation failed: api %d, type %d, param name %s",
+ api, param->type, param->name);
+ return RECORDER_ERROR_OUT_OF_MEMORY;
+ }
+
+ /*LOGD("send msg %s", msg);*/
+
+ if (cb_info->is_server_connected) {
+ __recorder_update_api_waiting(cb_info, api, 1);
+
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ }
+
+ if (send_ret < 0) {
+ LOGE("message send failed");
+ *ret = RECORDER_ERROR_INVALID_OPERATION;
+ } else {
+ *ret = _recorder_client_wait_for_cb_return(api, cb_info, RECORDER_CB_TIMEOUT);
+ }
+
+ __recorder_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+ return RECORDER_ERROR_NONE;
+}
+
+
+static void _recorder_client_callback_destroy(recorder_cb_info_s *cb_info)
+{
+ gint i = 0;
+
+ g_return_if_fail(cb_info != NULL);
+
+ LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
+
+ g_thread_join(cb_info->msg_recv_thread);
+ cb_info->msg_recv_thread = NULL;
+
+ LOGD("msg_recv thread removed");
+
+ __destroy_msg_handler_thread(&cb_info->msg_handler_info);
+ __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
+ __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
+
+ for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
+ for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
+ g_mutex_clear(&cb_info->api_mutex[i]);
+ g_cond_clear(&cb_info->api_cond[i]);
+ }
+
+ if (cb_info->fd > -1) {
+ muse_client_close(cb_info->fd);
+ cb_info->fd = -1;
+ }
+
+ if (cb_info->bufmgr) {
+ tbm_bufmgr_deinit(cb_info->bufmgr);
+ cb_info->bufmgr = NULL;
+ }
+ if (cb_info->get_filename) {
+ free(cb_info->get_filename);
+ cb_info->get_filename = NULL;
+ }
+
+ g_free(cb_info);
+ cb_info = NULL;
+
+ return;
+}
+
+
+static bool _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
+{
+ char **root_directory = (char **)user_data;
+
+ if (root_directory == NULL) {
+ LOGE("user data is NULL");
+ return false;
+ }
+
+ LOGD("storage id %d, type %d, state %d, path %s",
+ storage_id, type, state, path ? path : "NULL");
+
+ if (type == STORAGE_TYPE_INTERNAL && path) {
+ if (*root_directory) {
+ free(*root_directory);
+ *root_directory = NULL;
+ }
+
+ *root_directory = strdup(path);
+ if (*root_directory) {
+ LOGD("get root directory %s", *root_directory);
+ return false;
+ } else {
+ LOGE("strdup %s failed", path);
+ }
+ }
+
+ return true;
+}
+
+static int _recorder_client_get_root_directory(char **root_directory)
+{
+ int ret = STORAGE_ERROR_NONE;
+
+ if (root_directory == NULL) {
+ LOGE("user data is NULL");
+ return false;
+ }
+
+ ret = storage_foreach_device_supported((storage_device_supported_cb)_recorder_storage_device_supported_cb, root_directory);
+ if (ret != STORAGE_ERROR_NONE) {
+ LOGE("storage_foreach_device_supported failed 0x%x", ret);
+ return false;
+ }
+
+ return true;
+}
+
+static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e type, camera_h camera)
+{
+ int ret = RECORDER_ERROR_NONE;
+ int destroy_ret = RECORDER_ERROR_NONE;
+ int sock_fd = -1;
+ int module_index = -1;
+ int send_ret = 0;
+ char *send_msg = NULL;
+ char *root_directory = NULL;
+ intptr_t camera_handle = 0;
+ intptr_t handle = 0;
+ tbm_bufmgr bufmgr = NULL;
+ recorder_cli_s *pc = NULL;
+ recorder_msg_param param;
+
+ LOGD("Enter - type %d", type);
+
+ if (recorder == NULL) {
+ LOGE("NULL pointer for recorder handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (type == MUSE_RECORDER_TYPE_VIDEO && camera == NULL) {
+ LOGE("NULL pointer for camera handle on video recorder mode");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ bufmgr = tbm_bufmgr_init(-1);
+ if (bufmgr == NULL) {
+ LOGE("get tbm bufmgr failed");
+ return RECORDER_ERROR_INVALID_OPERATION;
+ }
+
+ pc = g_new0(recorder_cli_s, 1);
+ if (pc == NULL) {
+ ret = RECORDER_ERROR_OUT_OF_MEMORY;
+ goto _ERR_RECORDER_EXIT;
+ }
+
+ sock_fd = muse_client_new();
+ if (sock_fd < 0) {
+//LCOV_EXCL_START
+ LOGE("muse_client_new failed - returned fd %d", sock_fd);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _ERR_RECORDER_EXIT;
+//LCOV_EXCL_STOP
+ }
+
+ if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
+ LOGE("muse client get module index failed");
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _ERR_RECORDER_EXIT;
+ }
+
+ if (type == MUSE_RECORDER_TYPE_AUDIO) {
+ send_msg = muse_core_msg_new(MUSE_RECORDER_API_CREATE,
+ MUSE_TYPE_INT, "module", module_index,
+ MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_AUDIO,
+ MUSE_TYPE_INT, "pid", getpid(),
+ NULL);
+ } else {
+ pc->camera = camera;
+ camera_handle = (intptr_t)((camera_cli_s *)camera)->remote_handle;
+ send_msg = muse_core_msg_new(MUSE_RECORDER_API_CREATE,
+ MUSE_TYPE_INT, "module", module_index,
+ MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_VIDEO,
+ MUSE_TYPE_INT, "pid", getpid(),
+ MUSE_TYPE_POINTER, "camera_handle", camera_handle,
+ NULL);
+ }
+
+ if (!send_msg) {
+//LCOV_EXCL_START
+ LOGE("NULL msg");
+ ret = RECORDER_ERROR_OUT_OF_MEMORY;
+ goto _ERR_RECORDER_EXIT;
+//LCOV_EXCL_STOP
+ }
+
+ LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
+
+ send_ret = muse_core_msg_send(sock_fd, send_msg);
+
+ muse_core_msg_free(send_msg);
+ send_msg = NULL;
+
+ if (send_ret < 0) {
+//LCOV_EXCL_START
+ LOGE("send msg failed %d", errno);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _ERR_RECORDER_EXIT;
+//LCOV_EXCL_STOP
+ }
+
+ pc->cb_info = _recorder_client_callback_new(sock_fd);
+ if (pc->cb_info == NULL) {
+ ret = RECORDER_ERROR_OUT_OF_MEMORY;
+ goto _ERR_RECORDER_EXIT;
+ }
+
+ sock_fd = -1;
+
+ ret = _recorder_client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CB_TIMEOUT);
+
+ pc->cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 0;
+
+ if (ret != RECORDER_ERROR_NONE) {
+ LOGE("API_CREATE failed 0x%x", ret);
+ goto _ERR_RECORDER_EXIT;
+ }
+
+ muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
+ if (handle == 0) {
+//LCOV_EXCL_START
+ LOGE("Receiving Handle Failed!!");
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _ERR_RECORDER_AFTER_CREATE;
+//LCOV_EXCL_STOP
+ }
+
+ if (!_recorder_client_get_root_directory(&root_directory) || root_directory == NULL) {
+//LCOV_EXCL_START
+ LOGE("failed to get root directory of internal storage");
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _ERR_RECORDER_AFTER_CREATE;
+//LCOV_EXCL_STOP
+ }
+
+ LOGD("root directory [%s]", root_directory);
+
+ RECORDER_MSG_PARAM_SET(param, STRING, root_directory);
+
+ _recorder_msg_send_param1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY, pc->cb_info, &ret, ¶m);
+
+ if (ret != RECORDER_ERROR_NONE) {
+ LOGE("failed to set root directory %s", root_directory);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _ERR_RECORDER_AFTER_CREATE;
+ }
+
+ free(root_directory);
+ root_directory = NULL;
+
+ pc->remote_handle = handle;
+ pc->cb_info->bufmgr = bufmgr;
+
+ LOGD("recorder[type %d] %p create success : remote handle 0x%td",
+ type, pc, pc->remote_handle);
+
+ *recorder = (recorder_h)pc;
+
+ LOGD("done");
+
+ return RECORDER_ERROR_NONE;
+//LCOV_EXCL_START
+_ERR_RECORDER_AFTER_CREATE:
+ _recorder_msg_send(MUSE_RECORDER_API_DESTROY, pc->cb_info, &destroy_ret, RECORDER_CB_TIMEOUT);
+ LOGE("destroy return 0x%x", destroy_ret);
+
+_ERR_RECORDER_EXIT:
+ tbm_bufmgr_deinit(bufmgr);
+ bufmgr = NULL;
+
+ if (root_directory) {
+ free(root_directory);
+ root_directory = NULL;
+ }
+
+ if (sock_fd > -1) {
+ muse_client_close(sock_fd);
+ sock_fd = -1;
+ }
+
+ if (pc) {
+ if (pc->cb_info) {
+ _recorder_client_callback_destroy(pc->cb_info);
+ pc->cb_info = NULL;
+ }
+ g_free(pc);
+ pc = NULL;
+ }
+
+ return ret;
+//LCOV_EXCL_STOP
+}
+
+
+int recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
+{
+ return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_VIDEO, camera);
+}
+
+
+int recorder_create_audiorecorder(recorder_h *recorder)
+{
+ return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_AUDIO, NULL);
+}
+
+
+int recorder_get_state(recorder_h recorder, recorder_state_e *state)
+{
+ int ret = RECORDER_ERROR_NONE;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+ muse_recorder_api_e api = MUSE_RECORDER_API_GET_STATE;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (state == NULL) {
+ LOGE("NULL pointer state");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("Enter, remote_handle : %td", pc->remote_handle);
+
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *state = (recorder_state_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_STATE];
+
+ LOGD("ret : 0x%x, state : %d", ret, *state);
+
+ return ret;
+}
+
+
+int recorder_destroy(recorder_h recorder)
+{
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_DESTROY;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("ENTER");
+
+ if (pc->cb_info->is_server_connected)
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+ else
+ LOGW("server disconnected. release resource without send message.");
+
+ if (ret == RECORDER_ERROR_NONE) {
+ _recorder_deactivate_idle_event_all(pc->cb_info);
+ _recorder_client_callback_destroy(pc->cb_info);
+ g_free(pc);
+ pc = NULL;
+ }
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
+int recorder_prepare(recorder_h recorder)
+{
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_PREPARE;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("ENTER");
+
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ LOGD("ret : 0x%x", ret);
+
+ if (ret == RECORDER_ERROR_NONE && pc->camera)
+ camera_start_evas_rendering(pc->camera);
+
+ return ret;
+}
+
+
+int recorder_unprepare(recorder_h recorder)
+{
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_UNPREPARE;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+ camera_state_e camera_state = CAMERA_STATE_NONE;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("ENTER");
+
+ if (pc->camera) {
+//LCOV_EXCL_START
+ ret = camera_get_state(pc->camera, &camera_state);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("failed to get camera state 0x%x", ret);
+ return RECORDER_ERROR_INVALID_OPERATION;
+ }
+
+ if (camera_state == CAMERA_STATE_PREVIEW) {
+ ret = camera_stop_evas_rendering(pc->camera, false);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("camera_stop_evas_rendering failed 0x%x", ret);
+ return RECORDER_ERROR_INVALID_OPERATION;
+ }
+ }
+//LCOV_EXCL_STOP
}
- LOGD("remote handle : 0x%x", camera_handle);
- sock_fd = muse_core_client_new();
- sndMsg = muse_core_msg_json_factory_new(api,
- MUSE_TYPE_INT, "module", muse_module,
- MUSE_TYPE_INT, PARAM_RECORDER_TYPE, recorder_type,
- MUSE_TYPE_POINTER, "camera_handle", camera_handle,
- 0);
- muse_core_ipc_send_msg(sock_fd, sndMsg);
- LOGD("sock_fd : %d, msg : %s", sock_fd, sndMsg);
- muse_core_msg_json_factory_free(sndMsg);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- pc->cb_info = _client_callback_new(sock_fd);
- LOGD("cb info : %d", pc->cb_info->fd);
+ LOGD("ret : 0x%x", ret);
- ret = client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
- if (ret == RECORDER_ERROR_NONE) {
- char *root_directory = NULL;
+ return ret;
+}
- muse_recorder_msg_get_pointer(handle, pc->cb_info->recvMsg);
- if (handle == 0) {
- LOGE("Receiving Handle Failed!!");
- goto ErrorExit;
- } else {
- pc->remote_handle = handle;
- }
- if (mm_camcorder_client_get_root_directory(&root_directory) == MM_ERROR_NONE &&
- root_directory != NULL) {
- LOGD("set root directory %s", root_directory);
+int recorder_start(recorder_h recorder)
+{
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_START;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+ recorder_state_e current_state = RECORDER_STATE_NONE;
- muse_recorder_msg_send1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY, sock_fd, pc->cb_info, ret, STRING, root_directory);
- if (ret != RECORDER_ERROR_NONE) {
- LOGE("failed to set root directory %s", root_directory);
- }
- }
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
- if (root_directory) {
- free(root_directory);
- root_directory = NULL;
- }
+ LOGD("ENTER");
- LOGD("recorder create 0x%x", pc->remote_handle);
+ if (pc->camera) {
+//LCOV_EXCL_START
+ ret = recorder_get_state(recorder, ¤t_state);
+ if (ret != RECORDER_ERROR_NONE) {
+ LOGE("failed to get current state 0x%x", ret);
+ return RECORDER_ERROR_INVALID_OPERATION;
+ }
- *recorder = (recorder_h) pc;
- } else {
- goto ErrorExit;
+ if (current_state == RECORDER_STATE_READY) {
+ ret = camera_stop_evas_rendering(pc->camera, true);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("camera_stop_evas_rendering failed 0x%x", ret);
+ return RECORDER_ERROR_INVALID_OPERATION;
+ }
+ }
+//LCOV_EXCL_STOP
}
- LOGD("done");
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_NO_TIMEOUT);
- return RECORDER_ERROR_NONE;
+ if (pc->camera && current_state == RECORDER_STATE_READY)
+ camera_start_evas_rendering(pc->camera);
+
+ LOGD("ret : 0x%x", ret);
-ErrorExit:
- g_free(pc);
- LOGD("ErrorExit!!! ret value : %d", ret);
return ret;
}
-int recorder_create_audiorecorder(recorder_h *recorder)
+int recorder_pause(recorder_h recorder)
{
- int sock_fd = -1;
- int pid = 0;
- char *sndMsg;
int ret = RECORDER_ERROR_NONE;
- recorder_cli_s *pc = NULL;
- muse_recorder_api_e api = MUSE_RECORDER_API_CREATE;
- muse_core_api_module_e muse_module = MUSE_RECORDER;
- int recorder_type = MUSE_RECORDER_TYPE_AUDIO;
-
- LOGW("Enter");
+ muse_recorder_api_e api = MUSE_RECORDER_API_PAUSE;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = muse_core_client_new();
- if (sock_fd < 0) {
- LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
- return RECORDER_ERROR_INVALID_OPERATION;
- }
+ LOGD("ENTER");
- pid = getpid();
- sndMsg = muse_core_msg_json_factory_new(api,
- MUSE_TYPE_INT, "module", muse_module,
- MUSE_TYPE_INT, PARAM_RECORDER_TYPE, recorder_type,
- MUSE_TYPE_INT, "pid", pid,
- 0);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- LOGD("sock_fd : %d, msg : %s", sock_fd, sndMsg);
+ LOGD("ret : 0x%x", ret);
- muse_core_ipc_send_msg(sock_fd, sndMsg);
- muse_core_msg_json_factory_free(sndMsg);
+ return ret;
+}
- pc = g_new0(recorder_cli_s, 1);
- if (pc == NULL) {
- return 0;
- }
- pc->cb_info = _client_callback_new(sock_fd);
- ret = client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
- if (ret == RECORDER_ERROR_NONE) {
- char *root_directory = NULL;
- intptr_t handle = 0;
+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;
- muse_recorder_msg_get_pointer(handle, pc->cb_info->recvMsg);
- if (handle == 0) {
- LOGE("Receiving Handle Failed!!");
- goto ErrorExit;
- } else {
- pc->remote_handle = handle;
- }
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
- if (mm_camcorder_client_get_root_directory(&root_directory) == MM_ERROR_NONE &&
- root_directory != NULL) {
- LOGD("set root directory %s", root_directory);
+ LOGD("ENTER");
- muse_recorder_msg_send1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY, sock_fd, pc->cb_info, ret, STRING, root_directory);
- if (ret != RECORDER_ERROR_NONE) {
- LOGE("failed to set root directory %s", root_directory);
- }
+ if (pc->camera) {
+//LCOV_EXCL_START
+ ret = recorder_get_state(recorder, ¤t_state);
+ if (ret != RECORDER_ERROR_NONE) {
+ LOGE("failed to get current state 0x%x", ret);
+ return RECORDER_ERROR_INVALID_OPERATION;
}
- if (root_directory) {
- free(root_directory);
- root_directory = NULL;
+ if (current_state >= RECORDER_STATE_RECORDING) {
+ ret = camera_stop_evas_rendering(pc->camera, true);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("camera_stop_evas_rendering failed 0x%x", ret);
+ return RECORDER_ERROR_INVALID_OPERATION;
+ }
}
-
- LOGD("recorder create 0x%x", pc->remote_handle);
-
- *recorder = (recorder_h)pc;
- } else {
- goto ErrorExit;
+//LCOV_EXCL_STOP
}
- LOGD("done");
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- return RECORDER_ERROR_NONE;
+ if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
+ camera_start_evas_rendering(pc->camera);
+
+ LOGD("ret : 0x%x", ret);
-ErrorExit:
- g_free(pc);
- LOGD("ret value : %d", ret);
return ret;
}
-int recorder_get_state(recorder_h recorder, recorder_state_e *state)
+int recorder_cancel(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (state == NULL) {
- LOGE("NULL pointer state");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
-
int ret = RECORDER_ERROR_NONE;
-
+ muse_recorder_api_e api = MUSE_RECORDER_API_CANCEL;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- muse_recorder_api_e api = MUSE_RECORDER_API_GET_STATE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_state_e current_state = RECORDER_STATE_NONE;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_state;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("ENTER");
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_state, pc->cb_info->recvMsg);
- *state = (recorder_state_e)get_state;
+ if (pc->camera) {
+ ret = recorder_get_state(recorder, ¤t_state);
+ if (ret != RECORDER_ERROR_NONE) {
+ LOGE("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) {
+ LOGE("camera_stop_evas_rendering failed 0x%x", ret);
+ return RECORDER_ERROR_INVALID_OPERATION;
+ }
+ }
}
- LOGD("ret : 0x%x, get_state : %d", ret, get_state);
+
+ _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);
+
+ LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_destroy(recorder_h recorder)
+int recorder_set_video_resolution(recorder_h recorder, int width, int height)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_DESTROY;
+ int send_ret = 0;
+ char *send_msg = NULL;
+ muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- if (pc == NULL) {
- return RECORDER_ERROR_INVALID_OPERATION;
- } else if (pc->cb_info == NULL) {
- return RECORDER_ERROR_INVALID_OPERATION;
+ send_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) {
+ LOGE("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 {
+ LOGE("failed to create msg");
+ ret = RECORDER_ERROR_OUT_OF_MEMORY;
}
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- _client_callback_destroy(pc->cb_info);
- g_free(pc);
- pc = NULL;
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_prepare(recorder_h recorder)
+int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_RESOLUTION;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_PREPARE;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ if (!width || !height) {
+ LOGE("NULL pointer width = [%p], height = [%p]", width, height);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- LOGD("ret : 0x%x", ret);
+ if (ret == RECORDER_ERROR_NONE) {
+ *width = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] >> 16;
+ *height = (0x0000ffff & pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION]);
+ }
+
+ LOGD("ret : 0x%x, %dx%d", ret, *width, *height);
return ret;
}
-int recorder_unprepare(recorder_h recorder)
+int recorder_foreach_supported_video_resolution(recorder_h recorder,
+ recorder_supported_video_resolution_cb foreach_cb, void *user_data)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_UNPREPARE;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_RESOLUTION;
+
+ if (!pc || !pc->cb_info || foreach_cb == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("ENTER");
+ LOGD("Enter, handle :%td", pc->remote_handle);
+
+ pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
+ pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
+
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_start(recorder_h recorder)
+int recorder_get_audio_level(recorder_h recorder, double *level)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_START;
+ muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_LEVEL;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || level == NULL) {
+ LOGE("NULL pointer %p %p", pc, level);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *level = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL];
+
+ LOGD("ret : 0x%x, level %lf", ret, *level);
+
return ret;
}
-int recorder_pause(recorder_h recorder)
+int recorder_set_filename(recorder_h recorder, const char *filename)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_PAUSE;
+ size_t length = 0;
+ muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+ char set_filename[RECORDER_FILENAME_MAX] = {'\0',};
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("ENTER");
+ if (filename == NULL) {
+ LOGE("filename is NULL");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
- return ret;
-}
+ LOGD("ENTER [%s]", filename);
+ length = strlen(filename);
-int recorder_commit(recorder_h recorder)
-{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ if (length >= RECORDER_FILENAME_MAX - 1) {
+ LOGE("too long file name [%zu]", length);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_COMMIT;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+
+ if (storage_get_origin_internal_path(filename, RECORDER_FILENAME_MAX, set_filename) < 0) {
+ /* Cannot convert. Use original path. */
+ strncpy(set_filename, filename, length + 1);
+ pc->cb_info->is_filename_converted = FALSE;
+ } else {
+ /* Converted. Use converted path. */
+ LOGD("Converted filename : %s -> %s", filename, set_filename);
+ pc->cb_info->is_filename_converted = TRUE;
}
- sock_fd = pc->cb_info->fd;
- LOGD("ENTER");
+ RECORDER_MSG_PARAM_SET(param, STRING, set_filename);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_cancel(recorder_h recorder)
+int recorder_get_filename(recorder_h recorder, char **filename)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_CANCEL;
+ muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILENAME;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ char compat_filename[RECORDER_FILENAME_MAX] = {0, };
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (filename == NULL) {
+ LOGE("filename is NULL");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE) {
+ if (pc->cb_info->is_filename_converted == FALSE ||
+ storage_get_compat_internal_path(pc->cb_info->get_filename, RECORDER_FILENAME_MAX, compat_filename) < 0) {
+ /* Use original path. */
+ *filename = pc->cb_info->get_filename;
+ } else {
+ /* Converted. Use converted path. */
+ LOGD("Converted filename : %s -> %s", pc->cb_info->get_filename, compat_filename);
+ *filename = strdup(compat_filename);
+ free(pc->cb_info->get_filename);
+ }
+
+ pc->cb_info->get_filename = NULL;
+ }
+
+ LOGD("ret : 0x%x, filename : [%s]", ret, (*filename) ? *filename : "NULL");
+
return ret;
}
-int recorder_set_video_resolution(recorder_h recorder, int width, int height)
+int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION;
+ int set_format = (int)format;
+ muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("ENTER");
+ LOGD("ENTER, set_format : %d", set_format);
+
+ RECORDER_MSG_PARAM_SET(param, INT, set_format);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
- muse_recorder_msg_send2(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, width,
- INT, height);
LOGD("ret : 0x%x", ret);
return ret;
}
-int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
+int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (!width || !height) {
- LOGE("NULL pointer width = [%p], height = [%p]", width, height);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_RESOLUTION;
+ muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILE_FORMAT;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (format == NULL) {
+ LOGE("NULL pointer data");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_width;
- int get_height;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_width, pc->cb_info->recvMsg);
- muse_recorder_msg_get(get_height, pc->cb_info->recvMsg);
- *width = get_width;
- *height = get_height;
- }
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *format = (recorder_file_format_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT];
+
+ LOGD("ret : 0x%x, format %d", ret, *format);
+
return ret;
}
-int recorder_foreach_supported_video_resolution(recorder_h recorder,
- recorder_supported_video_resolution_cb foreach_cb, void *user_data)
+int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stream_info)
{
- if( recorder == NULL || foreach_cb == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
-
+ muse_recorder_api_e api = MUSE_RECORDER_API_SET_SOUND_STREAM_INFO;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_RESOLUTION;
+ bool is_available = false;
+ int stream_index = 0;
+ char *stream_type = NULL;
+ char *send_msg = NULL;
+ int send_ret = 0;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || stream_info == NULL) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
- pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
-
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
- return ret;
-}
+ LOGD("ENTER");
-int recorder_get_audio_level(recorder_h recorder, double *level)
-{
- if (recorder == NULL || level == NULL) {
- LOGE("NULL pointer %p %p", recorder, level);
- return RECORDER_ERROR_INVALID_PARAMETER;
+ ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_RECORDER, &is_available);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ LOGE("stream info verification failed");
+ return RECORDER_ERROR_INVALID_OPERATION;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_LEVEL;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+ if (is_available == false) {
+ LOGE("stream information is not available");
+ return RECORDER_ERROR_INVALID_OPERATION;
}
- sock_fd = pc->cb_info->fd;
- double get_level;
- LOGD("ENTER");
+ ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
+ ret |= sound_manager_get_index_from_stream_information(stream_info, &stream_index);
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_level, pc->cb_info->recvMsg);
- *level = get_level;
+ LOGD("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) {
+ LOGE("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 {
+ LOGE("failed to create msg");
+ ret = RECORDER_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ ret = RECORDER_ERROR_INVALID_OPERATION;
}
- LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_set_filename(recorder_h recorder, const char *filename)
+int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void *user_data)
{
- if (recorder == NULL) {
- LOGE("handle is NULL");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
-
- if (filename == NULL) {
- LOGE("filename is NULL");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ muse_recorder_api_e api = MUSE_RECORDER_API_SET_STATE_CHANGED_CB;
+
+ if (!pc || !pc->cb_info || callback == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("ENTER");
+ LOGD("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]);
+ }
- muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, filename);
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_get_filename(recorder_h recorder, char **filename)
+int recorder_unset_state_changed_cb(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("handle is NULL");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
-
- if (filename == NULL) {
- LOGE("filename is NULL");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILENAME;
+ muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- char get_filename[MUSE_RECORDER_MSG_MAX_LENGTH] = {0,};
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get_string(get_filename, pc->cb_info->recvMsg);
- *filename = strdup(get_filename);
+ 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]);
}
- LOGD("ret : 0x%x, filename : %s", ret, *filename);
+
+ LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
+int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (format < RECORDER_FILE_FORMAT_3GP || format > RECORDER_FILE_FORMAT_OGG) {
- LOGE("invalid format %d", format);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB;
+
+ if (!pc || !pc->cb_info || callback == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_format = (int)format;
- LOGD("ENTER, set_format : %d", set_format);
+ LOGD("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]);
+ }
- muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format)
+int recorder_unset_interrupted_cb(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (format == NULL) {
- LOGE("NULL pointer data");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILE_FORMAT;
+ muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_format;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_format, pc->cb_info->recvMsg);
- LOGD("get_fileformat : %d", get_format);
- *format = (recorder_file_format_e)get_format;
+ 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]);
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data)
+int recorder_set_interrupt_started_cb(recorder_h recorder, recorder_interrupt_started_cb callback, void *user_data)
{
- if( recorder == NULL || callback == NULL){
+ 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) {
LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- 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;
+ LOGD("Enter, handle :%td", pc->remote_handle);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+ 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]);
}
- sock_fd = pc->cb_info->fd;
- 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;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_unset_state_changed_cb(recorder_h recorder)
+int recorder_unset_interrupt_started_cb(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB;
+ muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPT_STARTED_CB;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _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]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data)
+int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void *user_data)
{
- if( recorder == NULL || callback == NULL){
+ 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) {
LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB;
+ LOGD("Enter, handle :%td", pc->remote_handle);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+ 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]);
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
- pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_unset_interrupted_cb(recorder_h recorder)
+int recorder_unset_audio_stream_cb(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB;
+ muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _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]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data)
+int recorder_set_muxed_stream_cb(recorder_h recorder, recorder_muxed_stream_cb callback, void *user_data)
{
- if( recorder == NULL || callback == NULL){
+ 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) {
LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- 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;
+ LOGD("Enter, handle :%td", pc->remote_handle);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+ 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]);
}
- sock_fd = pc->cb_info->fd;
- 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;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_unset_audio_stream_cb(recorder_h recorder)
+int recorder_unset_muxed_stream_cb(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB;
+ muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_MUXED_STREAM_CB;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _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]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data)
{
- if( recorder == NULL || callback == NULL){
+ 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) {
LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- muse_recorder_api_e api = MUSE_RECORDER_API_SET_ERROR_CB;
+ LOGD("Enter, handle :%td", pc->remote_handle);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+ 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]);
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
- pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_unset_error_cb(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_ERROR_CB;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _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]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void* user_data)
+int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void *user_data)
{
- if( recorder == NULL || callback == NULL){
+ 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) {
LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- 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;
+ LOGD("Enter, handle :%td", pc->remote_handle);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+ 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]);
}
- sock_fd = pc->cb_info->fd;
- 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;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_unset_recording_status_cb(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _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]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void* user_data)
+int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void *user_data)
{
- if( recorder == NULL || callback == NULL){
+ 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) {
LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- 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;
+ _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]);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ 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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
}
- sock_fd = pc->cb_info->fd;
- 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;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_unset_recording_limit_reached_cb(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _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]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb, void *user_data)
{
- if( recorder == NULL || foreach_cb == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
-
recorder_cli_s *pc = (recorder_cli_s *)recorder;
muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_FILE_FORMAT;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || foreach_cb == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter, handle :%td", pc->remote_handle);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = foreach_cb;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = user_data;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_set_size_limit(recorder_h recorder, int kbyte)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, kbyte);
+ RECORDER_MSG_PARAM_SET(param, INT, kbyte);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_set_time_limit(recorder_h recorder, int second)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, second);
+ RECORDER_MSG_PARAM_SET(param, INT, second);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int set_device = (int)device;
+ };
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, set_device);
+ RECORDER_MSG_PARAM_SET(param, INT, set_device);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (codec != RECORDER_AUDIO_CODEC_DISABLE &&
- (codec < RECORDER_AUDIO_CODEC_AMR || codec > RECORDER_AUDIO_CODEC_PCM)) {
- LOGE("invalid parameter : codec %d", codec);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_codec = (int)codec;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, set_codec);
+ RECORDER_MSG_PARAM_SET(param, INT, set_codec);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_ENCODER;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (codec == NULL) {
LOGE("codec is NULL");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_ENCODER;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int get_codec;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_codec, pc->cb_info->recvMsg);
- *codec = (recorder_audio_codec_e)get_codec;
- }
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *codec = (recorder_audio_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER];
+
+ LOGD("ret : 0x%x, codec %d", ret, *codec);
+
return ret;
}
int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (codec < RECORDER_VIDEO_CODEC_H263 || codec > RECORDER_VIDEO_CODEC_THEORA) {
- LOGE("invalid codec %d", codec);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_codec = (int)codec;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, set_codec);
+ RECORDER_MSG_PARAM_SET(param, INT, set_codec);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_ENCODER;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (codec == NULL) {
LOGE("codec is NULL");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_ENCODER;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int get_codec;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_codec, pc->cb_info->recvMsg);
- *codec = (recorder_audio_codec_e)get_codec;
- }
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *codec = (recorder_video_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER];
+
+ LOGD("ret : 0x%x, codec %d", ret, *codec);
+
return ret;
}
int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (samplerate < 1) {
- LOGE("invalid samplerate %d", samplerate);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER, samplerate : %d", samplerate);
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, samplerate);
- LOGD("ret : 0x%x, samplerate : %d", ret, samplerate);
+ RECORDER_MSG_PARAM_SET(param, INT, samplerate);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
+ LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (bitrate < 1) {
- LOGE("invalid bitrate %d", bitrate);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, bitrate);
+ RECORDER_MSG_PARAM_SET(param, INT, bitrate);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
-
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, bitrate);
+ RECORDER_MSG_PARAM_SET(param, INT, bitrate);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (kbyte == NULL) {
LOGE("NULL pointer kbyte");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int get_kbyte;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_kbyte, pc->cb_info->recvMsg);
- *kbyte = get_kbyte;
- }
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *kbyte = pc->cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT];
+
+ LOGD("ret : 0x%x, %d kbyte", ret, *kbyte);
+
return ret;
}
int recorder_attr_get_time_limit(recorder_h recorder, int *second)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (second == NULL) {
LOGE("NULL pointer second");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int get_second;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_second, pc->cb_info->recvMsg);
- *second = get_second;
- }
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *second = pc->cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT];
+
+ LOGD("ret : 0x%x, %d second", ret, *second);
+
return ret;
}
int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (device == NULL) {
LOGE("NULL pointer device");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int get_device;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_device, pc->cb_info->recvMsg);
- *device = (recorder_audio_device_e)get_device;
- }
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *device = (recorder_audio_device_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE];
+
+ LOGD("ret : 0x%x, device %d", ret, *device);
- LOGD("ret : 0x%x", ret);
return ret;
}
int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (samplerate == NULL) {
LOGE("NULL pointer handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int get_samplerate;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_samplerate, pc->cb_info->recvMsg);
- *samplerate = get_samplerate;
- }
- LOGD("ret : 0x%x, get_samplerate : %d", ret, get_samplerate);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *samplerate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE];
+
+ LOGD("ret : 0x%x, samplerate %d", ret, *samplerate);
+
return ret;
}
int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (bitrate == NULL) {
- LOGE("NULL pointer");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ if (bitrate == NULL) {
+ LOGE("NULL pointer");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_bitrate;
- pc->cb_info->activating[api] = 0;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_bitrate, pc->cb_info->recvMsg);
- *bitrate = get_bitrate;
- }
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE];
+
+ LOGD("ret : 0x%x, bitrate %d", ret, *bitrate);
+
return ret;
}
int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (bitrate == NULL) {
LOGE("NULL pointer");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int get_bitrate;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_bitrate, pc->cb_info->recvMsg);
- *bitrate = get_bitrate;
- }
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE];
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb, void *user_data)
{
- if( recorder == NULL || foreach_cb == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
-
recorder_cli_s *pc = (recorder_cli_s *)recorder;
muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_AUDIO_ENCODER;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || foreach_cb == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter, handle :%td", pc->remote_handle);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = foreach_cb;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = user_data;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb, void *user_data)
{
- if( recorder == NULL || foreach_cb == NULL){
- LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
int ret = RECORDER_ERROR_NONE;
-
recorder_cli_s *pc = (recorder_cli_s *)recorder;
muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_ENCODER;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || foreach_cb == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter, handle :%td", pc->remote_handle);
+
pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = foreach_cb;
pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = user_data;
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_set_mute(recorder_h recorder, bool enable)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_enable = (int)enable;
- pc->cb_info->activating[api] = 0;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, set_enable);
+ RECORDER_MSG_PARAM_SET(param, INT, set_enable);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
bool recorder_attr_is_muted(recorder_h recorder)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return false;
- }
- int ret = RECORDER_ERROR_NONE;
+ int ret = false;
muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_IS_MUTED;
recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return false;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
- return ret;
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_SERVICE_DISCONNECTED)
+ ret = false;
+
+ LOGD("ret : %d", ret);
+
+ return (bool)ret;
}
int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("ENTER");
+ LOGD("ENTER - %.20lf", rate);
+
+ RECORDER_MSG_PARAM_SET(param, DOUBLE, rate);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- DOUBLE, rate);
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (rate == NULL) {
LOGE("rate is NULL");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- double get_rate;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_rate, pc->cb_info->recvMsg);
- *rate = get_rate;
- }
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+ if (ret == RECORDER_ERROR_NONE)
+ *rate = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE];
+
+ LOGD("ret : 0x%x - rate %.20lf", ret, *rate);
+
return ret;
}
int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (channel_count < 1) {
- LOGE("invalid channel %d", channel_count);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, channel_count);
+ RECORDER_MSG_PARAM_SET(param, INT, channel_count);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (channel_count == NULL) {
LOGE("channel_count is NULL");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- sock_fd = pc->cb_info->fd;
- int get_channel_count;
LOGD("ENTER");
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
- if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_channel_count, pc->cb_info->recvMsg);
- *channel_count = get_channel_count;
- }
- LOGD("ret : 0x%x", ret);
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *channel_count = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL];
+
+ LOGD("ret : 0x%x, channel count %d", ret, *channel_count);
+
return ret;
}
int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
- if (orientation > RECORDER_ROTATION_270) {
- LOGE("invalid orientation %d", orientation);
- return RECORDER_ERROR_INVALID_PARAMETER;
- }
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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ recorder_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_orientation = (int)orientation;
LOGD("ENTER");
- muse_recorder_msg_send1(api,
- sock_fd,
- pc->cb_info,
- ret,
- INT, set_orientation);
+ RECORDER_MSG_PARAM_SET(param, INT, set_orientation);
+
+ _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation)
{
- if (recorder == NULL) {
- LOGE("NULL pointer handle");
+ int ret = RECORDER_ERROR_NONE;
+ muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG;
+ recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
if (orientation == NULL) {
LOGE("orientation is NULL");
return RECORDER_ERROR_INVALID_PARAMETER;
}
+
+ LOGD("ENTER");
+
+ _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+ if (ret == RECORDER_ERROR_NONE)
+ *orientation = (recorder_rotation_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG];
+
+ LOGD("ret : 0x%x, orientation %d", ret, *orientation);
+
+ return ret;
+}
+
+
+int recorder_get_device_state(recorder_type_e type, recorder_device_state_e *state)
+{
int ret = RECORDER_ERROR_NONE;
- muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG;
- recorder_cli_s *pc = (recorder_cli_s *)recorder;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
+ int sock_fd = -1;
+ int module_index = -1;
+ int get_device_state = 0;
+ char *send_msg = NULL;
+ char recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH] = {'\0',};
+
+ if (!state) {
+ LOGE("NULL pointer");
return RECORDER_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_orientation;
- LOGD("ENTER");
+ LOGD("Enter - type %d", type);
+
+ sock_fd = muse_client_new();
+ if (sock_fd < 0) {
+//LCOV_EXCL_START
+ LOGE("muse_client_new failed - returned fd %d", sock_fd);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
+ }
+
+ if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
+ LOGE("muse client get module index failed");
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _GET_DEVICE_STATE_EXIT;
+ }
+
+ send_msg = muse_core_msg_new(MUSE_RECORDER_API_GET_DEVICE_STATE,
+ MUSE_TYPE_INT, "module", module_index,
+ MUSE_TYPE_INT, PARAM_RECORDER_TYPE, type,
+ NULL);
+ if (!send_msg) {
+//LCOV_EXCL_START
+ LOGE("NULL msg");
+ ret = RECORDER_ERROR_OUT_OF_MEMORY;
+ goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
+ }
+
+ LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
+
+ ret = muse_core_msg_send(sock_fd, send_msg);
+
+ muse_core_msg_free(send_msg);
+ send_msg = NULL;
+
+ if (ret < 0) {
+//LCOV_EXCL_START
+ LOGE("send msg failed %d", errno);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
+ }
+
+ ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_RECORDER_MSG_MAX_LENGTH);
+ if (ret <= 0) {
+//LCOV_EXCL_START
+ LOGE("recv msg failed %d", errno);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
+ }
+
+ if (!muse_recorder_msg_get(ret, recv_msg)) {
+//LCOV_EXCL_START
+ LOGE("failed to get return value from msg [%s]", recv_msg);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
+ }
- muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
if (ret == RECORDER_ERROR_NONE) {
- muse_recorder_msg_get(get_orientation, pc->cb_info->recvMsg);
- *orientation = (recorder_rotation_e)get_orientation;
+ if (muse_recorder_msg_get(get_device_state, recv_msg)) {
+ *state = (recorder_device_state_e)get_device_state;
+ LOGD("device type %d state %d", type, *state);
+ } else {
+ LOGE("failed to get device state from msg [%s]", recv_msg);
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ }
+ } else {
+ LOGE("failed 0x%x", ret);
}
- LOGD("ret : 0x%x", ret);
+
+_GET_DEVICE_STATE_EXIT:
+ if (sock_fd > -1) {
+ muse_client_close(sock_fd);
+ sock_fd = -1;
+ }
+
+ return ret;
+}
+
+
+int recorder_add_device_state_changed_cb(recorder_device_state_changed_cb callback, void *user_data, int *cb_id)
+{
+ int ret = RECORDER_ERROR_NONE;
+ recorder_device_state_e state = RECORDER_DEVICE_STATE_IDLE;
+ recorder_cb_info *info = NULL;
+
+ if (!callback || !cb_id) {
+ LOGE("invalid pointer %p %p", callback, cb_id);
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ g_mutex_lock(&g_rec_dev_state_changed_cb_lock);
+
+ /* check recorder support */
+ ret = recorder_get_device_state(RECORDER_TYPE_AUDIO, &state);
+ if (ret != RECORDER_ERROR_NONE) {
+ LOGE("get device state failed");
+ g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
+ return ret;
+ }
+
+ info = g_new0(recorder_cb_info, 1);
+ if (!info) {
+ LOGE("info failed");
+ ret = RECORDER_ERROR_OUT_OF_MEMORY;
+ goto _DONE;
+ }
+
+ info->id = ++g_rec_dev_state_changed_cb_id;
+ info->callback = (void *)callback;
+ info->user_data = user_data;
+
+ *cb_id = info->id;
+
+ /* subscribe dbus signal for camera state change */
+ if (!g_rec_dev_state_changed_cb_conn) {
+ g_rec_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+ if (!g_rec_dev_state_changed_cb_conn) {
+ LOGE("failed to get gdbus connection");
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
+
+ LOGD("subscribe signal %s - %s - %s",
+ MM_CAMCORDER_DBUS_OBJECT,
+ MM_CAMCORDER_DBUS_INTERFACE_RECORDER,
+ MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
+
+ g_rec_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_rec_dev_state_changed_cb_conn,
+ NULL, MM_CAMCORDER_DBUS_INTERFACE_RECORDER, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__recorder_device_state_changed_cb, NULL, NULL);
+ if (!g_rec_dev_state_changed_cb_subscribe_id) {
+ LOGE("failed to get gdbus connection");
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
+
+ LOGD("signal subscribe id %u", g_rec_dev_state_changed_cb_subscribe_id);
+ }
+
+ g_rec_dev_state_changed_cb_list = g_list_prepend(g_rec_dev_state_changed_cb_list, (gpointer)info);
+
+ LOGD("callback id %d", info->id);
+
+_DONE:
+ if (ret != RECORDER_ERROR_NONE) {
+//LCOV_EXCL_START
+ if (info) {
+ g_free(info);
+ info = NULL;
+ }
+
+ if (g_rec_dev_state_changed_cb_conn) {
+ g_object_unref(g_rec_dev_state_changed_cb_conn);
+ g_rec_dev_state_changed_cb_conn = NULL;
+ }
+//LCOV_EXCL_STOP
+ }
+
+ g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
+
+ return ret;
+}
+
+
+int recorder_remove_device_state_changed_cb(int cb_id)
+{
+ int ret = RECORDER_ERROR_NONE;
+ recorder_device_state_e state = RECORDER_DEVICE_STATE_IDLE;
+ GList *tmp_list = NULL;
+ recorder_cb_info *info = NULL;
+
+ /* check recorder support */
+ ret = recorder_get_device_state(RECORDER_TYPE_AUDIO, &state);
+ if (ret != RECORDER_ERROR_NONE) {
+ LOGE("get device state failed");
+ return ret;
+ }
+
+ g_mutex_lock(&g_rec_dev_state_changed_cb_lock);
+
+ if (!g_rec_dev_state_changed_cb_list) {
+ LOGE("there is no callback info");
+ ret = RECORDER_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
+
+ tmp_list = g_rec_dev_state_changed_cb_list;
+
+ do {
+ info = tmp_list->data;
+ tmp_list = tmp_list->next;
+
+ if (!info) {
+ LOGW("NULL info");
+ continue;
+ }
+
+ if (info->id == cb_id) {
+ g_rec_dev_state_changed_cb_list = g_list_remove(g_rec_dev_state_changed_cb_list, info);
+
+ g_free(info);
+ info = NULL;
+
+ if (!g_rec_dev_state_changed_cb_list) {
+ /* no remained callback */
+ if (g_rec_dev_state_changed_cb_conn) {
+ /* unsubscribe signal */
+ g_dbus_connection_signal_unsubscribe(g_rec_dev_state_changed_cb_conn, g_rec_dev_state_changed_cb_subscribe_id);
+ g_rec_dev_state_changed_cb_subscribe_id = 0;
+
+ /* unref connection */
+ g_object_unref(g_rec_dev_state_changed_cb_conn);
+ g_rec_dev_state_changed_cb_conn = NULL;
+ }
+ }
+
+ LOGD("id %d callback removed", cb_id);
+ ret = RECORDER_ERROR_NONE;
+
+ goto _DONE;
+ }
+ } while (tmp_list);
+
+ LOGE("id %d callback not found", cb_id);
+ ret = RECORDER_ERROR_INVALID_PARAMETER;
+
+_DONE:
+ g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
+
return ret;
}