2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <camera_internal.h>
22 #include <sound_manager.h>
23 #include <sound_manager_internal.h>
25 #include <storage-internal.h>
26 #include <muse_recorder.h>
27 #include <muse_recorder_msg.h>
28 #include <muse_core.h>
29 #include <muse_client.h>
30 #include <recorder_private.h>
33 #include <tzplatform_config.h>
38 #define LOG_TAG "TIZEN_N_RECORDER"
40 /* for device changed callback */
41 static GMutex g_rec_dev_state_changed_cb_lock;
42 static GList *g_rec_dev_state_changed_cb_list;
43 static int g_rec_dev_state_changed_cb_id;
44 static GDBusConnection *g_rec_dev_state_changed_cb_conn;
45 static guint g_rec_dev_state_changed_cb_subscribe_id;
46 static GMutex g_rec_idle_event_lock;
50 static void __recorder_update_api_waiting(recorder_cb_info_s *cb_info, int api, int value)
53 api < 0 || api >= MUSE_RECORDER_API_MAX) {
54 LOGE("invalid param %p %d", cb_info, api);
58 g_mutex_lock(&(cb_info->api_mutex[api]));
59 cb_info->api_waiting[api] += value;
60 g_mutex_unlock(&(cb_info->api_mutex[api]));
62 /*LOGD("api %d, value %d, waiting %d",
63 api, value, cb_info->api_waiting[api]);*/
69 static void __recorder_device_state_changed_cb(GDBusConnection *connection,
70 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
71 const gchar *signal_name, GVariant *param, gpointer user_data)
74 recorder_type_e type = RECORDER_TYPE_AUDIO;
75 recorder_device_state_e state = RECORDER_DEVICE_STATE_IDLE;
76 GList *tmp_list = NULL;
77 recorder_cb_info *info = NULL;
79 g_mutex_lock(&g_rec_dev_state_changed_cb_lock);
81 if (!g_rec_dev_state_changed_cb_list || !param) {
82 LOGW("no callback or NULL param %p", param);
86 /* get device type and state */
87 g_variant_get(param, "(i)", &value);
90 state = 0x0000ffff & value;
92 LOGD("type %d, state %d", type, state);
94 tmp_list = g_rec_dev_state_changed_cb_list;
97 info = (recorder_cb_info *)tmp_list->data;
100 if (info->callback) {
101 LOGD("start id[%d] callback", info->id);
102 ((recorder_device_state_changed_cb)info->callback)(type, state, info->user_data);
103 LOGD("returned id[%d] callback", info->id);
105 LOGW("NULL callback for id %d", info->id);
109 tmp_list = tmp_list->next;
113 g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
119 static int _recorder_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
121 tbm_bo tmp_bo = NULL;
122 tbm_bo_handle tmp_bo_handle = {NULL, };
124 if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
125 LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
126 bufmgr, bo, bo_handle, tbm_key);
130 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
131 if (tmp_bo == NULL) {
132 LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
136 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
137 if (tmp_bo_handle.ptr == NULL) {
138 LOGE("bo map failed %p", tmp_bo);
139 tbm_bo_unref(tmp_bo);
144 /* set bo and bo_handle */
146 *bo_handle = tmp_bo_handle;
151 static void _recorder_release_imported_bo(tbm_bo *bo)
153 if (bo == NULL || *bo == NULL) {
165 static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *recv_msg, muse_recorder_event_e event)
167 if (recv_msg == NULL || event >= MUSE_RECORDER_EVENT_TYPE_NUM) {
168 LOGE("invalid parameter - recorder msg %p, event %d", recv_msg, event);
172 /*LOGD("get recorder msg %s, event %d", recv_msg, event);*/
174 g_mutex_lock(&cb_info->user_cb_mutex[event]);
176 if (cb_info->user_cb[event] == NULL) {
177 if (event != MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM &&
178 event != MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM) {
179 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
180 LOGW("NULL callback for event %d, return here", event);
183 LOGW("NULL callback for event %d, NOT return here", event);
188 case MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE:
194 muse_recorder_msg_get(previous, recv_msg);
195 muse_recorder_msg_get(current, recv_msg);
196 muse_recorder_msg_get(by_policy, recv_msg);
198 ((recorder_state_changed_cb)cb_info->user_cb[event])((recorder_state_e)previous,
199 (recorder_state_e)current,
201 cb_info->user_data[event]);
204 case MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED:
208 muse_recorder_msg_get(type, recv_msg);
210 ((recorder_recording_limit_reached_cb)cb_info->user_cb[event])((recorder_recording_limit_type_e)type,
211 cb_info->user_data[event]);
214 case MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS:
216 int64_t cb_elapsed_time = 0;
217 int64_t cb_file_size = 0;
219 muse_recorder_msg_get(cb_elapsed_time, recv_msg);
220 muse_recorder_msg_get(cb_file_size, recv_msg);
222 ((recorder_recording_status_cb)cb_info->user_cb[event])((unsigned long long)cb_elapsed_time,
223 (unsigned long long)cb_file_size,
224 cb_info->user_data[event]);
227 case MUSE_RECORDER_EVENT_TYPE_INTERRUPTED:
233 muse_recorder_msg_get(policy, recv_msg);
234 muse_recorder_msg_get(previous, recv_msg);
235 muse_recorder_msg_get(current, recv_msg);
237 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
239 ((recorder_interrupted_cb)cb_info->user_cb[event])((recorder_policy_e)policy,
240 (recorder_state_e)previous,
241 (recorder_state_e)current,
242 cb_info->user_data[event]);
245 case MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED:
250 muse_recorder_msg_get(policy, recv_msg);
251 muse_recorder_msg_get(state, recv_msg);
253 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
255 ((recorder_interrupt_started_cb)cb_info->user_cb[event])((recorder_policy_e)policy,
256 (recorder_state_e)state, cb_info->user_data[event]);
259 case MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM:
267 tbm_bo_handle bo_handle = {.ptr = NULL};
268 char *send_msg = NULL;
270 muse_recorder_msg_get(tbm_key, recv_msg);
276 if (cb_info->user_cb[event]) {
277 if (_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
278 muse_recorder_msg_get(size, recv_msg);
279 muse_recorder_msg_get(format, recv_msg);
280 muse_recorder_msg_get(channel, recv_msg);
281 muse_recorder_msg_get(timestamp, recv_msg);
283 ((recorder_audio_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
284 size, (audio_sample_type_e)format, channel,
285 (unsigned int)timestamp, cb_info->user_data[event]);
287 /* release imported bo */
288 _recorder_release_imported_bo(&bo);
290 LOGE("tbm key %d import failed", tbm_key);
295 send_msg = muse_core_msg_new(MUSE_RECORDER_API_RETURN_BUFFER,
296 MUSE_TYPE_INT, "tbm_key", tbm_key, NULL);
298 if (muse_core_msg_send(cb_info->fd, send_msg) <= 0)
299 LOGE("sending message failed");
301 muse_core_msg_free(send_msg);
304 case MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM:
311 tbm_bo_handle bo_handle = {.ptr = NULL};
312 char *send_msg = NULL;
314 muse_recorder_msg_get(tbm_key, recv_msg);
320 if (cb_info->user_cb[event]) {
321 if (_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
322 muse_recorder_msg_get(size, recv_msg);
323 muse_recorder_msg_get(offset, recv_msg);
325 ((recorder_muxed_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
326 size, (unsigned long long)offset, cb_info->user_data[event]);
328 /* release imported bo */
329 _recorder_release_imported_bo(&bo);
331 LOGE("tbm key %d import failed", tbm_key);
336 send_msg = muse_core_msg_new(MUSE_RECORDER_API_RETURN_BUFFER,
337 MUSE_TYPE_INT, "tbm_key", tbm_key, NULL);
339 if (muse_core_msg_send(cb_info->fd, send_msg) <= 0)
340 LOGE("sending message failed");
342 muse_core_msg_free(send_msg);
345 LOGE("failed to create send msg for key %d", tbm_key);
349 case MUSE_RECORDER_EVENT_TYPE_ERROR:
352 int current_state = 0;
354 muse_recorder_msg_get(error, recv_msg);
355 muse_recorder_msg_get(current_state, recv_msg);
357 ((recorder_error_cb)cb_info->user_cb[event])((recorder_error_e)error,
358 (recorder_state_e)current_state,
359 cb_info->user_data[event]);
362 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER:
366 muse_recorder_msg_get(codec, recv_msg);
368 if (((recorder_supported_audio_encoder_cb)cb_info->user_cb[event])((recorder_audio_codec_e)codec, cb_info->user_data[event]) == false) {
369 cb_info->user_cb[event] = NULL;
370 cb_info->user_data[event] = NULL;
371 /*LOGD("stop foreach callback for SUPPORTED_AUDIO_ENCODER");*/
375 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT:
379 muse_recorder_msg_get(format, recv_msg);
381 if (((recorder_supported_file_format_cb)cb_info->user_cb[event])((recorder_file_format_e)format, cb_info->user_data[event]) == false) {
382 cb_info->user_cb[event] = NULL;
383 cb_info->user_data[event] = NULL;
384 /*LOGD("stop foreach callback for SUPPORTED_FILE_FORMAT");*/
388 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER:
392 muse_recorder_msg_get(codec, recv_msg);
394 if (((recorder_supported_video_encoder_cb)cb_info->user_cb[event])((recorder_video_codec_e)codec, cb_info->user_data[event]) == false) {
395 cb_info->user_cb[event] = NULL;
396 cb_info->user_data[event] = NULL;
397 /*LOGD("stop foreach callback for SUPPORTED_VIDEO_ENCODER");*/
401 default: /* MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION */
406 muse_recorder_msg_get(width, recv_msg);
407 muse_recorder_msg_get(height, recv_msg);
409 if (((recorder_supported_video_resolution_cb)cb_info->user_cb[event])(width, height, cb_info->user_data[event]) == false) {
410 cb_info->user_cb[event] = NULL;
411 cb_info->user_data[event] = NULL;
412 /*LOGD("stop foreach callback for SUPPORTED_VIDEO_RESOLUTION");*/
418 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
424 static gboolean _recorder_idle_event_callback(gpointer data)
426 recorder_cb_info_s *cb_info = NULL;
427 recorder_idle_event_s *rec_idle_event = (recorder_idle_event_s *)data;
429 if (rec_idle_event == NULL) {
430 LOGE("rec_idle_event is NULL");
435 g_mutex_lock(&g_rec_idle_event_lock);
437 cb_info = rec_idle_event->cb_info;
438 if (cb_info == NULL) {
439 LOGW("recorder cb_info is NULL. event %p %d", rec_idle_event, rec_idle_event->event);
440 g_mutex_unlock(&g_rec_idle_event_lock);
441 goto IDLE_EVENT_CALLBACK_DONE;
444 /* remove event from list */
445 if (cb_info->idle_event_list)
446 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
448 g_mutex_unlock(&g_rec_idle_event_lock);
451 _recorder_client_user_callback(cb_info, rec_idle_event->recv_msg, rec_idle_event->event);
453 IDLE_EVENT_CALLBACK_DONE:
455 g_free(rec_idle_event);
456 rec_idle_event = NULL;
462 static void _recorder_deactivate_idle_event_all(recorder_cb_info_s *cb_info)
464 recorder_idle_event_s *rec_idle_event = NULL;
467 if (cb_info == NULL) {
468 LOGE("cb_info is NULL");
472 g_mutex_lock(&g_rec_idle_event_lock);
474 if (cb_info->idle_event_list == NULL) {
477 list = cb_info->idle_event_list;
480 rec_idle_event = list->data;
481 list = g_list_next(list);
483 if (!rec_idle_event) {
484 LOGW("The event is NULL");
488 if (g_idle_remove_by_data(rec_idle_event)) {
489 LOGW("remove idle event %p done", rec_idle_event);
491 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
493 g_free(rec_idle_event);
494 rec_idle_event = NULL;
499 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
500 rec_idle_event, rec_idle_event->event);
502 rec_idle_event->cb_info = NULL;
504 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
507 g_list_free(cb_info->idle_event_list);
508 cb_info->idle_event_list = NULL;
511 g_mutex_unlock(&g_rec_idle_event_lock);
517 static void __recorder_add_msg_to_queue(recorder_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
519 recorder_message_s *rec_msg = NULL;
520 recorder_msg_handler_info_s *msg_handler_info = NULL;
522 if (!cb_info || !msg) {
523 LOGE("NULL pointer %p %p", cb_info, msg);
527 rec_msg = g_new0(recorder_message_s, 1);
529 LOGE("failed to alloc rec_msg for [%s]", msg);
534 rec_msg->event = event;
535 rec_msg->event_class = event_class;
537 strncpy(rec_msg->recv_msg, msg, sizeof(rec_msg->recv_msg) - 1);
539 /*LOGD("add recorder message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
541 if (event == MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM)
542 msg_handler_info = &cb_info->audio_stream_cb_info;
543 else if (event == MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM)
544 msg_handler_info = &cb_info->muxed_stream_cb_info;
546 msg_handler_info = &cb_info->msg_handler_info;
548 g_mutex_lock(&msg_handler_info->mutex);
549 g_queue_push_tail(msg_handler_info->queue, (gpointer)rec_msg);
550 g_cond_signal(&msg_handler_info->cond);
551 g_mutex_unlock(&msg_handler_info->mutex);
559 static void __recorder_get_api_operation(int api, recorder_cb_info_s *cb_info, char *msg)
561 if (!cb_info || !msg) {
562 LOGE("NULL pointer %p %p", cb_info, msg);
567 case MUSE_RECORDER_API_GET_STATE:
570 muse_recorder_msg_get(get_state, msg);
571 cb_info->get_int_value[_RECORDER_GET_INT_STATE] = get_state;
574 case MUSE_RECORDER_API_GET_VIDEO_RESOLUTION:
578 muse_recorder_msg_get(get_width, msg);
579 muse_recorder_msg_get(get_height, msg);
580 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] = get_width << 16;
581 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] |= get_height;
584 case MUSE_RECORDER_API_GET_FILE_FORMAT:
587 muse_recorder_msg_get(get_format, msg);
588 cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT] = get_format;
591 case MUSE_RECORDER_API_GET_AUDIO_ENCODER:
594 muse_recorder_msg_get(get_codec, msg);
595 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER] = get_codec;
598 case MUSE_RECORDER_API_GET_VIDEO_ENCODER:
601 muse_recorder_msg_get(get_codec, msg);
602 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER] = get_codec;
605 case MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT:
608 muse_recorder_msg_get(get_kbyte, msg);
609 cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT] = get_kbyte;
612 case MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT:
615 muse_recorder_msg_get(get_second, msg);
616 cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT] = get_second;
619 case MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE:
622 muse_recorder_msg_get(get_device, msg);
623 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE] = get_device;
626 case MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE:
628 int get_samplerate = 0;
629 muse_recorder_msg_get(get_samplerate, msg);
630 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE] = get_samplerate;
633 case MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE:
636 muse_recorder_msg_get(get_bitrate, msg);
637 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE] = get_bitrate;
640 case MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE:
643 muse_recorder_msg_get(get_bitrate, msg);
644 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE] = get_bitrate;
647 case MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE:
650 muse_recorder_msg_get_double(get_rate, msg);
651 cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE] = get_rate;
654 case MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL:
656 int get_channel_count = 0;
657 muse_recorder_msg_get(get_channel_count, msg);
658 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL] = get_channel_count;
661 case MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG:
663 int get_orientation = 0;
664 muse_recorder_msg_get(get_orientation, msg);
665 cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG] = get_orientation;
668 case MUSE_RECORDER_API_GET_AUDIO_LEVEL:
670 double get_level = 0.0;
671 muse_recorder_msg_get_double(get_level, msg);
672 cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL] = get_level;
675 case MUSE_RECORDER_API_GET_FILENAME:
677 char get_filename[MUSE_RECORDER_MSG_MAX_LENGTH] = {'\0',};
678 muse_recorder_msg_get_string(get_filename, msg);
679 if (cb_info->get_filename) {
680 free(cb_info->get_filename);
681 cb_info->get_filename = NULL;
683 cb_info->get_filename = strdup(get_filename);
694 static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg)
696 int ret = RECORDER_ERROR_NONE;
700 int event_class = -1;
702 if (!cb_info || !msg) {
703 LOGE("invalid ptr %p %p", cb_info, msg);
707 /*LOGD("msg [%s]", msg);*/
709 if (!muse_recorder_msg_get(api, msg)) {
710 LOGE("failed to get recorder api");
714 if (api == MUSE_RECORDER_CB_EVENT) {
715 if (!muse_recorder_msg_get(event, msg) ||
716 !muse_recorder_msg_get(event_class, msg)) {
717 LOGE("failed to get event or event_class [%s]", msg);
721 if (!muse_recorder_msg_get(api_class, msg)) {
722 LOGE("failed to get api_class [%s]", msg);
727 if (api_class == MUSE_RECORDER_API_CLASS_IMMEDIATE) {
728 if (api >= MUSE_RECORDER_API_MAX) {
729 LOGE("invalid api %d", api);
733 if (!muse_recorder_msg_get(ret, msg)) {
734 LOGE("failed to get recorder ret");
738 g_mutex_lock(&cb_info->api_mutex[api]);
740 if (api == MUSE_RECORDER_API_GET_DEVICE_STATE) {
741 g_atomic_int_set(&cb_info->msg_recv_running, 0);
742 LOGD("get device state done. close client cb handler");
745 case MUSE_RECORDER_API_CREATE:
746 if (ret != RECORDER_ERROR_NONE) {
747 g_atomic_int_set(&cb_info->msg_recv_running, 0);
748 LOGE("create error 0x%x. closing..", ret);
751 case MUSE_RECORDER_API_DESTROY:
752 if (ret == RECORDER_ERROR_NONE) {
753 g_atomic_int_set(&cb_info->msg_recv_running, 0);
754 LOGD("destroy done. closing..");
758 __recorder_get_api_operation(api, cb_info, msg);
763 if (cb_info->api_waiting[api] > 0) {
764 cb_info->api_ret[api] = ret;
765 cb_info->api_activating[api] = 1;
767 g_cond_signal(&cb_info->api_cond[api]);
769 LOGE("no waiting for api [%d]", api);
772 g_mutex_unlock(&cb_info->api_mutex[api]);
773 } else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB || api == MUSE_RECORDER_CB_EVENT) {
774 __recorder_add_msg_to_queue(cb_info, api, event, event_class, msg);
776 LOGW("unknown recorder api %d and api_class %d", api, api_class);
783 static void *_recorder_msg_handler_func(gpointer data)
787 recorder_message_s *rec_msg = NULL;
788 recorder_idle_event_s *rec_idle_event = NULL;
789 recorder_msg_handler_info_s *handler_info = (recorder_msg_handler_info_s *)data;
790 recorder_cb_info_s *cb_info = NULL;
792 if (!handler_info || !handler_info->cb_info) {
793 LOGE("NULL handler %p", handler_info);
797 cb_info = (recorder_cb_info_s *)handler_info->cb_info;
798 type = handler_info->type;
800 LOGD("t:%d start", type);
802 g_mutex_lock(&handler_info->mutex);
804 while (g_atomic_int_get(&handler_info->running)) {
805 if (g_queue_is_empty(handler_info->queue)) {
806 /*LOGD("signal wait...");*/
807 g_cond_wait(&handler_info->cond, &handler_info->mutex);
808 /*LOGD("signal received");*/
810 if (g_atomic_int_get(&handler_info->running) == 0) {
811 LOGD("stop event thread");
816 rec_msg = (recorder_message_s *)g_queue_pop_head(handler_info->queue);
817 g_mutex_unlock(&handler_info->mutex);
818 if (rec_msg == NULL) {
819 LOGE("NULL message");
820 g_mutex_lock(&handler_info->mutex);
826 if (api < MUSE_RECORDER_API_MAX) {
829 g_mutex_lock(&cb_info->api_mutex[api]);
831 if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
832 if (cb_info->api_waiting[api] > 0) {
833 cb_info->api_ret[api] = ret;
834 cb_info->api_activating[api] = 1;
836 /*LOGD("recorder api %d - return 0x%x", ret);*/
838 g_cond_signal(&cb_info->api_cond[api]);
840 LOGE("no waiting for api [%d]", api);
843 LOGE("t:%d failed to get ret for api %d, msg %s", type, api, rec_msg->recv_msg);
846 g_mutex_unlock(&cb_info->api_mutex[api]);
847 } else if (api == MUSE_RECORDER_CB_EVENT) {
848 switch (rec_msg->event_class) {
849 case MUSE_RECORDER_EVENT_CLASS_THREAD_SUB:
850 _recorder_client_user_callback(cb_info, rec_msg->recv_msg, rec_msg->event);
852 case MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN:
853 rec_idle_event = g_new0(recorder_idle_event_s, 1);
854 if (rec_idle_event == NULL) {
855 LOGE("event alloc failed");
859 rec_idle_event->event = rec_msg->event;
860 rec_idle_event->cb_info = cb_info;
862 strncpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg) - 1);
864 /*LOGD("add recorder event[%d, %p] to IDLE", rec_msg->event, rec_idle_event);*/
866 g_mutex_lock(&g_rec_idle_event_lock);
867 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)rec_idle_event);
868 g_mutex_unlock(&g_rec_idle_event_lock);
870 g_idle_add_full(G_PRIORITY_DEFAULT,
871 (GSourceFunc)_recorder_idle_event_callback,
872 (gpointer)rec_idle_event,
876 LOGE("unknown event class %d", rec_msg->event_class);
880 LOGE("unknown api[%d] message", api);
886 g_mutex_lock(&handler_info->mutex);
889 /* remove remained event */
890 while (!g_queue_is_empty(handler_info->queue)) {
891 rec_msg = (recorder_message_s *)g_queue_pop_head(handler_info->queue);
893 LOGD("remove message %p", rec_msg);
897 LOGW("NULL message");
901 g_mutex_unlock(&handler_info->mutex);
909 static void *_recorder_msg_recv_func(gpointer data)
912 int single_length = 0;
913 int remained_length = 0;
914 char *recv_msg = NULL;
915 char *single_msg = NULL;
916 char *remained_msg = NULL;
920 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
922 if (cb_info == NULL) {
923 LOGE("cb_info NULL");
929 single_msg = (char *)malloc(sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
930 if (single_msg == NULL) {
931 LOGE("single_msg malloc failed");
932 goto CB_HANDLER_EXIT;
935 recv_msg = cb_info->recv_msg;
937 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
938 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH);
939 if (recv_length <= 0) {
940 cb_info->is_server_connected = FALSE;
941 LOGE("receive msg failed - server disconnected");
945 recv_msg[recv_length] = '\0';
951 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
953 /* Need to split the combined entering msgs */
954 for (cur_pos = 0; cur_pos < recv_length; cur_pos++) {
955 if (recv_msg[cur_pos] == '}') {
956 single_length = cur_pos - prev_pos + 1;
958 if (single_length < MUSE_RECORDER_MSG_MAX_LENGTH) {
959 /* check remained msg */
960 if (remained_length > 0) {
962 strncpy(single_msg, remained_msg, remained_length);
963 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
964 single_msg[remained_length + single_length] = '\0';
969 strncpy(single_msg, recv_msg + prev_pos, single_length);
970 single_msg[single_length] = '\0';
971 LOGE("lost msg [%s], skip...", single_msg);
976 strncpy(single_msg, recv_msg + prev_pos, single_length);
977 single_msg[single_length] = '\0';
980 if (single_msg[0] == '{') {
982 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
983 __recorder_process_msg(cb_info, single_msg);
985 LOGE("invalid msg [%s]", single_msg);
988 LOGE("too long message [len %d] skip...", single_length);
991 prev_pos = cur_pos + 1;
995 /* check incompleted message */
996 if (recv_msg[recv_length - 1] != '}') {
997 remained_length = recv_length - prev_pos;
999 LOGW("incompleted message [len %d]", remained_length);
1003 remained_msg = NULL;
1006 remained_msg = (char *)malloc(remained_length + 1);
1008 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1009 remained_msg[remained_length] = '\0';
1011 LOGE("failed to alloc for remained msg");
1014 remained_length = 0;
1018 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1020 if (!cb_info->is_server_connected) {
1021 /* send error msg for server disconnection */
1022 char *error_msg = muse_core_msg_new(MUSE_RECORDER_CB_EVENT,
1023 MUSE_TYPE_INT, "error", RECORDER_ERROR_SERVICE_DISCONNECTED,
1024 MUSE_TYPE_INT, "current_state", RECORDER_STATE_NONE,
1028 LOGE("error_msg failed");
1029 goto CB_HANDLER_EXIT;
1032 LOGE("add error msg for service disconnection done");
1034 __recorder_add_msg_to_queue(cb_info,
1035 MUSE_RECORDER_CB_EVENT,
1036 MUSE_RECORDER_EVENT_TYPE_ERROR,
1037 MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN,
1040 muse_core_msg_free(error_msg);
1043 LOGE("add error msg for service disconnection done");
1054 remained_msg = NULL;
1061 static bool __create_msg_handler_thread(recorder_msg_handler_info_s *handler_info,
1062 int type, const char *thread_name, recorder_cb_info_s *cb_info)
1064 if (!handler_info || !thread_name || !cb_info) {
1065 LOGE("t:%d NULL %p %p %p",
1066 type, handler_info, thread_name, cb_info);
1072 handler_info->type = type;
1073 handler_info->queue = g_queue_new();
1074 if (handler_info->queue == NULL) {
1075 LOGE("t:%d queue failed", type);
1079 g_mutex_init(&handler_info->mutex);
1080 g_cond_init(&handler_info->cond);
1082 handler_info->cb_info = (void *)cb_info;
1083 g_atomic_int_set(&handler_info->running, 1);
1085 handler_info->thread = g_thread_try_new(thread_name,
1086 _recorder_msg_handler_func, (gpointer)handler_info, NULL);
1087 if (handler_info->thread == NULL) {
1088 LOGE("t:%d thread failed", type);
1090 g_mutex_clear(&handler_info->mutex);
1091 g_cond_clear(&handler_info->cond);
1092 g_queue_free(handler_info->queue);
1093 handler_info->queue = NULL;
1098 LOGD("t:%d done", type);
1104 static void __destroy_msg_handler_thread(recorder_msg_handler_info_s *handler_info)
1108 if (!handler_info) {
1109 LOGE("NULL handler");
1113 if (!handler_info->thread) {
1114 LOGW("thread is not created");
1118 type = handler_info->type;
1120 LOGD("t:%d thread %p", type, handler_info->thread);
1122 g_mutex_lock(&handler_info->mutex);
1123 g_atomic_int_set(&handler_info->running, 0);
1124 g_cond_signal(&handler_info->cond);
1125 g_mutex_unlock(&handler_info->mutex);
1127 g_thread_join(handler_info->thread);
1128 handler_info->thread = NULL;
1130 g_mutex_clear(&handler_info->mutex);
1131 g_cond_clear(&handler_info->cond);
1132 g_queue_free(handler_info->queue);
1133 handler_info->queue = NULL;
1135 LOGD("t:%d done", type);
1141 static recorder_cb_info_s *_recorder_client_callback_new(gint sockfd)
1143 recorder_cb_info_s *cb_info = NULL;
1146 g_return_val_if_fail(sockfd > 0, NULL);
1148 cb_info = g_new0(recorder_cb_info_s, 1);
1149 if (cb_info == NULL) {
1150 LOGE("cb_info failed");
1154 cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 1;
1156 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
1157 g_mutex_init(&cb_info->api_mutex[i]);
1158 g_cond_init(&cb_info->api_cond[i]);
1161 for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
1162 g_mutex_init(&cb_info->user_cb_mutex[i]);
1164 /* message handler thread */
1165 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
1166 _RECORDER_MESSAGE_HANDLER_TYPE_GENERAL, "recorder_msg_handler", cb_info)) {
1167 LOGE("msg_handler_info failed");
1171 /* message handler thread for audio stream callback */
1172 if (!__create_msg_handler_thread(&cb_info->audio_stream_cb_info,
1173 _RECORDER_MESSAGE_HANDLER_TYPE_AUDIO_STREAM_CB, "recorder_msg_handler:audio_stream_cb", cb_info)) {
1174 LOGE("audio_stream_cb_info failed");
1178 /* message handler thread for muxed stream callback */
1179 if (!__create_msg_handler_thread(&cb_info->muxed_stream_cb_info,
1180 _RECORDER_MESSAGE_HANDLER_TYPE_MUXED_STREAM_CB, "recorder_msg_handler:muxed_stream_cb", cb_info)) {
1181 LOGE("muxed_stream_cb_info failed");
1185 cb_info->fd = sockfd;
1187 /* message receive thread */
1188 g_atomic_int_set(&cb_info->msg_recv_running, 1);
1189 cb_info->msg_recv_thread = g_thread_try_new("recorder_msg_recv",
1190 _recorder_msg_recv_func, (gpointer)cb_info, NULL);
1191 if (cb_info->msg_recv_thread == NULL) {
1192 LOGE("message receive thread creation failed");
1196 cb_info->is_server_connected = TRUE;
1202 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
1203 __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
1204 __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
1206 for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
1207 g_mutex_clear(&cb_info->user_cb_mutex[i]);
1209 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
1210 g_mutex_clear(&cb_info->api_mutex[i]);
1211 g_cond_clear(&cb_info->api_cond[i]);
1221 static int _recorder_client_wait_for_cb_return(muse_recorder_api_e api, recorder_cb_info_s *cb_info, int time_out)
1223 int ret = RECORDER_ERROR_NONE;
1226 /*LOGD("Enter api : %d", api);*/
1228 if (!cb_info->is_server_connected) {
1229 LOGE("server is disconnected");
1230 return RECORDER_ERROR_SERVICE_DISCONNECTED;
1233 g_mutex_lock(&(cb_info->api_mutex[api]));
1235 if (cb_info->api_activating[api] == 0) {
1236 if (time_out == RECORDER_CB_NO_TIMEOUT) {
1237 LOGW("wait for api %d", api);
1238 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
1239 ret = cb_info->api_ret[api];
1240 cb_info->api_activating[api] = 0;
1241 LOGW("api %d returned 0x%x", api, ret);
1243 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
1244 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
1245 ret = cb_info->api_ret[api];
1246 cb_info->api_activating[api] = 0;
1247 /*LOGD("return value : 0x%x", ret);*/
1249 ret = RECORDER_ERROR_INVALID_OPERATION;
1250 LOGE("api %d was TIMED OUT!", api);
1254 ret = cb_info->api_ret[api];
1255 cb_info->api_activating[api] = 0;
1257 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
1260 if (ret != RECORDER_ERROR_NONE)
1261 LOGE("ERROR : api %d - ret 0x%x", api, ret);
1263 g_mutex_unlock(&(cb_info->api_mutex[api]));
1269 static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret, int timeout)
1274 if (!cb_info || !ret) {
1275 LOGE("invalid pointer for api %d - %p %p", api, cb_info, ret);
1276 return RECORDER_ERROR_INVALID_PARAMETER;
1279 msg = muse_core_msg_new(api, NULL);
1281 LOGE("msg creation failed: api %d", api);
1282 return RECORDER_ERROR_OUT_OF_MEMORY;
1285 /*LOGD("send msg %s", msg);*/
1287 if (cb_info->is_server_connected) {
1288 __recorder_update_api_waiting(cb_info, api, 1);
1289 send_ret = muse_core_msg_send(cb_info->fd, msg);
1293 LOGE("message send failed");
1294 *ret = RECORDER_ERROR_INVALID_OPERATION;
1296 *ret = _recorder_client_wait_for_cb_return(api, cb_info, timeout);
1299 __recorder_update_api_waiting(cb_info, api, -1);
1301 muse_core_msg_free(msg);
1303 return RECORDER_ERROR_NONE;
1307 static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *ret, recorder_msg_param *param)
1312 if (!cb_info || !ret || !param) {
1313 LOGE("invalid pointer for api %d - %p %p %p", api, cb_info, ret, param);
1314 return RECORDER_ERROR_INVALID_PARAMETER;
1317 /*LOGD("type %d, name %s", param->type, param->name);*/
1319 switch (param->type) {
1321 msg = muse_core_msg_new(api, param->type, param->name, param->value.value_INT, NULL);
1323 case MUSE_TYPE_DOUBLE:
1324 msg = muse_core_msg_new(api, param->type, param->name, param->value.value_DOUBLE, NULL);
1326 case MUSE_TYPE_STRING:
1327 msg = muse_core_msg_new(api, param->type, param->name, param->value.value_STRING, NULL);
1330 LOGE("unknown type %d", param->type);
1335 LOGE("msg creation failed: api %d, type %d, param name %s",
1336 api, param->type, param->name);
1337 return RECORDER_ERROR_OUT_OF_MEMORY;
1340 /*LOGD("send msg %s", msg);*/
1342 if (cb_info->is_server_connected) {
1343 __recorder_update_api_waiting(cb_info, api, 1);
1345 send_ret = muse_core_msg_send(cb_info->fd, msg);
1349 LOGE("message send failed");
1350 *ret = RECORDER_ERROR_INVALID_OPERATION;
1352 *ret = _recorder_client_wait_for_cb_return(api, cb_info, RECORDER_CB_TIMEOUT);
1355 __recorder_update_api_waiting(cb_info, api, -1);
1357 muse_core_msg_free(msg);
1359 return RECORDER_ERROR_NONE;
1363 static void _recorder_client_callback_destroy(recorder_cb_info_s *cb_info)
1367 g_return_if_fail(cb_info != NULL);
1369 LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
1371 g_thread_join(cb_info->msg_recv_thread);
1372 cb_info->msg_recv_thread = NULL;
1374 LOGD("msg_recv thread removed");
1376 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
1377 __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
1378 __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
1380 for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
1381 g_mutex_clear(&cb_info->user_cb_mutex[i]);
1383 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
1384 g_mutex_clear(&cb_info->api_mutex[i]);
1385 g_cond_clear(&cb_info->api_cond[i]);
1388 if (cb_info->fd > -1) {
1389 muse_client_close(cb_info->fd);
1393 if (cb_info->bufmgr) {
1394 tbm_bufmgr_deinit(cb_info->bufmgr);
1395 cb_info->bufmgr = NULL;
1397 if (cb_info->get_filename) {
1398 free(cb_info->get_filename);
1399 cb_info->get_filename = NULL;
1409 static int _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
1411 char **root_directory = (char **)user_data;
1413 if (root_directory == NULL) {
1414 LOGE("user data is NULL");
1418 LOGD("storage id %d, type %d, state %d, path %s",
1419 storage_id, type, state, path ? path : "NULL");
1421 if (type == STORAGE_TYPE_INTERNAL && path) {
1422 if (*root_directory) {
1423 free(*root_directory);
1424 *root_directory = NULL;
1427 *root_directory = strdup(path);
1428 if (*root_directory) {
1429 LOGD("get root directory %s", *root_directory);
1432 LOGE("strdup %s failed", path);
1439 static int _recorder_client_get_root_directory(char **root_directory)
1441 int ret = STORAGE_ERROR_NONE;
1443 if (root_directory == NULL) {
1444 LOGE("user data is NULL");
1448 ret = storage_foreach_device_supported((storage_device_supported_cb)_recorder_storage_device_supported_cb, root_directory);
1449 if (ret != STORAGE_ERROR_NONE) {
1450 LOGE("storage_foreach_device_supported failed 0x%x", ret);
1457 static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e type, camera_h camera)
1459 int ret = RECORDER_ERROR_NONE;
1460 int destroy_ret = RECORDER_ERROR_NONE;
1463 char *send_msg = NULL;
1464 char *root_directory = NULL;
1465 intptr_t camera_handle = 0;
1466 intptr_t handle = 0;
1467 tbm_bufmgr bufmgr = NULL;
1468 recorder_cli_s *pc = NULL;
1469 recorder_msg_param param;
1471 LOGD("Enter - type %d", type);
1473 if (recorder == NULL) {
1474 LOGE("NULL pointer for recorder handle");
1475 return RECORDER_ERROR_INVALID_PARAMETER;
1478 if (type == MUSE_RECORDER_TYPE_VIDEO && camera == NULL) {
1479 LOGE("NULL pointer for camera handle on video recorder mode");
1480 return RECORDER_ERROR_INVALID_PARAMETER;
1483 bufmgr = tbm_bufmgr_init(-1);
1484 if (bufmgr == NULL) {
1485 LOGE("get tbm bufmgr failed");
1486 return RECORDER_ERROR_INVALID_OPERATION;
1489 pc = g_new0(recorder_cli_s, 1);
1491 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1492 goto _ERR_RECORDER_EXIT;
1495 sock_fd = muse_client_new();
1497 LOGE("muse_client_new failed - returned fd %d", sock_fd);
1498 ret = RECORDER_ERROR_INVALID_OPERATION;
1499 goto _ERR_RECORDER_EXIT;
1502 if (type == MUSE_RECORDER_TYPE_AUDIO) {
1503 send_msg = muse_core_msg_new(MUSE_RECORDER_API_CREATE,
1504 MUSE_TYPE_INT, "module", MUSE_RECORDER,
1505 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_AUDIO,
1506 MUSE_TYPE_INT, "pid", getpid(),
1509 pc->camera = camera;
1510 camera_handle = (intptr_t)((camera_cli_s *)camera)->remote_handle;
1511 send_msg = muse_core_msg_new(MUSE_RECORDER_API_CREATE,
1512 MUSE_TYPE_INT, "module", MUSE_RECORDER,
1513 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_VIDEO,
1514 MUSE_TYPE_INT, "pid", getpid(),
1515 MUSE_TYPE_POINTER, "camera_handle", camera_handle,
1521 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1522 goto _ERR_RECORDER_EXIT;
1525 LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
1527 send_ret = muse_core_msg_send(sock_fd, send_msg);
1529 muse_core_msg_free(send_msg);
1533 LOGE("send msg failed %d", errno);
1534 ret = RECORDER_ERROR_INVALID_OPERATION;
1535 goto _ERR_RECORDER_EXIT;
1538 pc->cb_info = _recorder_client_callback_new(sock_fd);
1539 if (pc->cb_info == NULL) {
1540 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1541 goto _ERR_RECORDER_EXIT;
1546 ret = _recorder_client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CB_TIMEOUT);
1548 pc->cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 0;
1550 if (ret != RECORDER_ERROR_NONE) {
1551 LOGE("API_CREATE failed 0x%x", ret);
1552 goto _ERR_RECORDER_EXIT;
1555 muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
1557 LOGE("Receiving Handle Failed!!");
1558 ret = RECORDER_ERROR_INVALID_OPERATION;
1559 goto _ERR_RECORDER_AFTER_CREATE;
1562 if (!_recorder_client_get_root_directory(&root_directory) || root_directory == NULL) {
1563 LOGE("failed to get root directory of internal storage");
1564 ret = RECORDER_ERROR_INVALID_OPERATION;
1565 goto _ERR_RECORDER_AFTER_CREATE;
1568 LOGD("root directory [%s]", root_directory);
1570 RECORDER_MSG_PARAM_SET(param, STRING, root_directory);
1572 _recorder_msg_send_param1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY, pc->cb_info, &ret, ¶m);
1574 if (ret != RECORDER_ERROR_NONE) {
1575 LOGE("failed to set root directory %s", root_directory);
1576 ret = RECORDER_ERROR_INVALID_OPERATION;
1577 goto _ERR_RECORDER_AFTER_CREATE;
1580 free(root_directory);
1581 root_directory = NULL;
1583 pc->remote_handle = handle;
1584 pc->cb_info->bufmgr = bufmgr;
1586 LOGD("recorder[type %d] %p create success : remote handle 0x%td",
1587 type, pc, pc->remote_handle);
1589 *recorder = (recorder_h)pc;
1593 return RECORDER_ERROR_NONE;
1595 _ERR_RECORDER_AFTER_CREATE:
1596 _recorder_msg_send(MUSE_RECORDER_API_DESTROY, pc->cb_info, &destroy_ret, RECORDER_CB_TIMEOUT);
1597 LOGE("destroy return 0x%x", destroy_ret);
1600 tbm_bufmgr_deinit(bufmgr);
1603 if (root_directory) {
1604 free(root_directory);
1605 root_directory = NULL;
1609 muse_client_close(sock_fd);
1615 _recorder_client_callback_destroy(pc->cb_info);
1626 int recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
1628 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_VIDEO, camera);
1632 int recorder_create_audiorecorder(recorder_h *recorder)
1634 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_AUDIO, NULL);
1638 int recorder_get_state(recorder_h recorder, recorder_state_e *state)
1640 int ret = RECORDER_ERROR_NONE;
1641 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1642 muse_recorder_api_e api = MUSE_RECORDER_API_GET_STATE;
1644 if (!pc || !pc->cb_info) {
1645 LOGE("NULL handle");
1646 return RECORDER_ERROR_INVALID_PARAMETER;
1649 if (state == NULL) {
1650 LOGE("NULL pointer state");
1651 return RECORDER_ERROR_INVALID_PARAMETER;
1654 LOGD("Enter, remote_handle : %td", pc->remote_handle);
1656 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1658 if (ret == RECORDER_ERROR_NONE)
1659 *state = (recorder_state_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_STATE];
1661 LOGD("ret : 0x%x, state : %d", ret, *state);
1667 int recorder_destroy(recorder_h recorder)
1669 int ret = RECORDER_ERROR_NONE;
1670 muse_recorder_api_e api = MUSE_RECORDER_API_DESTROY;
1671 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1673 if (!pc || !pc->cb_info) {
1674 LOGE("NULL handle");
1675 return RECORDER_ERROR_INVALID_PARAMETER;
1680 if (pc->cb_info->is_server_connected)
1681 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1683 LOGW("server disconnected. release resource without send message.");
1685 if (ret == RECORDER_ERROR_NONE) {
1686 _recorder_deactivate_idle_event_all(pc->cb_info);
1687 _recorder_client_callback_destroy(pc->cb_info);
1692 LOGD("ret : 0x%x", ret);
1698 int recorder_prepare(recorder_h recorder)
1700 int ret = RECORDER_ERROR_NONE;
1701 muse_recorder_api_e api = MUSE_RECORDER_API_PREPARE;
1702 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1704 if (!pc || !pc->cb_info) {
1705 LOGE("NULL handle");
1706 return RECORDER_ERROR_INVALID_PARAMETER;
1711 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1713 LOGD("ret : 0x%x", ret);
1715 if (ret == RECORDER_ERROR_NONE && pc->camera)
1716 camera_start_evas_rendering(pc->camera);
1722 int recorder_unprepare(recorder_h recorder)
1724 int ret = RECORDER_ERROR_NONE;
1725 muse_recorder_api_e api = MUSE_RECORDER_API_UNPREPARE;
1726 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1727 camera_state_e camera_state = CAMERA_STATE_NONE;
1729 if (!pc || !pc->cb_info) {
1730 LOGE("NULL handle");
1731 return RECORDER_ERROR_INVALID_PARAMETER;
1737 ret = camera_get_state(pc->camera, &camera_state);
1738 if (ret != CAMERA_ERROR_NONE) {
1739 LOGE("failed to get camera state 0x%x", ret);
1740 return RECORDER_ERROR_INVALID_OPERATION;
1743 if (camera_state == CAMERA_STATE_PREVIEW) {
1744 ret = camera_stop_evas_rendering(pc->camera, false);
1745 if (ret != CAMERA_ERROR_NONE) {
1746 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1747 return RECORDER_ERROR_INVALID_OPERATION;
1752 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1754 LOGD("ret : 0x%x", ret);
1760 int recorder_start(recorder_h recorder)
1762 int ret = RECORDER_ERROR_NONE;
1763 muse_recorder_api_e api = MUSE_RECORDER_API_START;
1764 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1765 recorder_state_e current_state = RECORDER_STATE_NONE;
1767 if (!pc || !pc->cb_info) {
1768 LOGE("NULL handle");
1769 return RECORDER_ERROR_INVALID_PARAMETER;
1775 ret = recorder_get_state(recorder, ¤t_state);
1776 if (ret != RECORDER_ERROR_NONE) {
1777 LOGE("failed to get current state 0x%x", ret);
1778 return RECORDER_ERROR_INVALID_OPERATION;
1781 if (current_state == RECORDER_STATE_READY) {
1782 ret = camera_stop_evas_rendering(pc->camera, true);
1783 if (ret != CAMERA_ERROR_NONE) {
1784 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1785 return RECORDER_ERROR_INVALID_OPERATION;
1790 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_NO_TIMEOUT);
1792 if (pc->camera && current_state == RECORDER_STATE_READY)
1793 camera_start_evas_rendering(pc->camera);
1795 LOGD("ret : 0x%x", ret);
1801 int recorder_pause(recorder_h recorder)
1803 int ret = RECORDER_ERROR_NONE;
1804 muse_recorder_api_e api = MUSE_RECORDER_API_PAUSE;
1805 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1807 if (!pc || !pc->cb_info) {
1808 LOGE("NULL handle");
1809 return RECORDER_ERROR_INVALID_PARAMETER;
1814 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1816 LOGD("ret : 0x%x", ret);
1822 int recorder_commit(recorder_h recorder)
1824 int ret = RECORDER_ERROR_NONE;
1825 muse_recorder_api_e api = MUSE_RECORDER_API_COMMIT;
1826 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1827 recorder_state_e current_state = RECORDER_STATE_NONE;
1829 if (!pc || !pc->cb_info) {
1830 LOGE("NULL handle");
1831 return RECORDER_ERROR_INVALID_PARAMETER;
1837 ret = recorder_get_state(recorder, ¤t_state);
1838 if (ret != RECORDER_ERROR_NONE) {
1839 LOGE("failed to get current state 0x%x", ret);
1840 return RECORDER_ERROR_INVALID_OPERATION;
1843 if (current_state >= RECORDER_STATE_RECORDING) {
1844 ret = camera_stop_evas_rendering(pc->camera, true);
1845 if (ret != CAMERA_ERROR_NONE) {
1846 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1847 return RECORDER_ERROR_INVALID_OPERATION;
1852 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1854 if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
1855 camera_start_evas_rendering(pc->camera);
1857 LOGD("ret : 0x%x", ret);
1863 int recorder_cancel(recorder_h recorder)
1865 int ret = RECORDER_ERROR_NONE;
1866 muse_recorder_api_e api = MUSE_RECORDER_API_CANCEL;
1867 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1868 recorder_state_e current_state = RECORDER_STATE_NONE;
1870 if (!pc || !pc->cb_info) {
1871 LOGE("NULL handle");
1872 return RECORDER_ERROR_INVALID_PARAMETER;
1878 ret = recorder_get_state(recorder, ¤t_state);
1879 if (ret != RECORDER_ERROR_NONE) {
1880 LOGE("failed to get current state 0x%x", ret);
1881 return RECORDER_ERROR_INVALID_OPERATION;
1884 if (current_state >= RECORDER_STATE_RECORDING) {
1885 ret = camera_stop_evas_rendering(pc->camera, true);
1886 if (ret != CAMERA_ERROR_NONE) {
1887 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1888 return RECORDER_ERROR_INVALID_OPERATION;
1893 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1895 if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
1896 camera_start_evas_rendering(pc->camera);
1898 LOGD("ret : 0x%x", ret);
1904 int recorder_set_video_resolution(recorder_h recorder, int width, int height)
1906 int ret = RECORDER_ERROR_NONE;
1908 char *send_msg = NULL;
1909 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION;
1910 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1912 if (!pc || !pc->cb_info) {
1913 LOGE("NULL handle");
1914 return RECORDER_ERROR_INVALID_PARAMETER;
1919 send_msg = muse_core_msg_new(api,
1920 MUSE_TYPE_INT, "width", width,
1921 MUSE_TYPE_INT, "height", height,
1924 if (pc->cb_info->is_server_connected) {
1925 __recorder_update_api_waiting(pc->cb_info, api, 1);
1927 send_ret = muse_core_msg_send(pc->cb_info->fd, send_msg);
1931 LOGE("message send failed");
1932 ret = RECORDER_ERROR_INVALID_OPERATION;
1934 ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT);
1937 __recorder_update_api_waiting(pc->cb_info, api, -1);
1939 muse_core_msg_free(send_msg);
1941 LOGE("failed to create msg");
1942 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1945 LOGD("ret : 0x%x", ret);
1951 int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
1953 int ret = RECORDER_ERROR_NONE;
1954 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_RESOLUTION;
1955 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1957 if (!pc || !pc->cb_info) {
1958 LOGE("NULL handle");
1959 return RECORDER_ERROR_INVALID_PARAMETER;
1962 if (!width || !height) {
1963 LOGE("NULL pointer width = [%p], height = [%p]", width, height);
1964 return RECORDER_ERROR_INVALID_PARAMETER;
1969 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1971 if (ret == RECORDER_ERROR_NONE) {
1972 *width = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] >> 16;
1973 *height = (0x0000ffff & pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION]);
1976 LOGD("ret : 0x%x, %dx%d", ret, *width, *height);
1982 int recorder_foreach_supported_video_resolution(recorder_h recorder,
1983 recorder_supported_video_resolution_cb foreach_cb, void *user_data)
1985 int ret = RECORDER_ERROR_NONE;
1986 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1987 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_RESOLUTION;
1989 if (!pc || !pc->cb_info || foreach_cb == NULL) {
1990 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1991 return RECORDER_ERROR_INVALID_PARAMETER;
1994 LOGD("Enter, handle :%td", pc->remote_handle);
1996 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
1997 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
1999 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2001 LOGD("ret : 0x%x", ret);
2007 int recorder_get_audio_level(recorder_h recorder, double *level)
2009 int ret = RECORDER_ERROR_NONE;
2010 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_LEVEL;
2011 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2013 if (!pc || !pc->cb_info || level == NULL) {
2014 LOGE("NULL pointer %p %p", pc, level);
2015 return RECORDER_ERROR_INVALID_PARAMETER;
2020 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2022 if (ret == RECORDER_ERROR_NONE)
2023 *level = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL];
2025 LOGD("ret : 0x%x, level %lf", ret, *level);
2031 int recorder_set_filename(recorder_h recorder, const char *filename)
2033 int ret = RECORDER_ERROR_NONE;
2035 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
2036 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2037 recorder_msg_param param;
2038 char set_filename[RECORDER_FILENAME_MAX] = {'\0',};
2040 if (!pc || !pc->cb_info) {
2041 LOGE("NULL handle");
2042 return RECORDER_ERROR_INVALID_PARAMETER;
2045 if (filename == NULL) {
2046 LOGE("filename is NULL");
2047 return RECORDER_ERROR_INVALID_PARAMETER;
2050 LOGD("ENTER [%s]", filename);
2052 length = strlen(filename);
2054 if (length >= RECORDER_FILENAME_MAX - 1) {
2055 LOGE("too long file name [%zu]", length);
2056 return RECORDER_ERROR_INVALID_PARAMETER;
2059 if (storage_get_origin_internal_path(filename, RECORDER_FILENAME_MAX, set_filename) < 0) {
2060 /* Cannot convert. Use original path. */
2061 strncpy(set_filename, filename, length + 1);
2062 pc->cb_info->is_filename_converted = FALSE;
2064 /* Converted. Use converted path. */
2065 LOGD("Converted filename : %s -> %s", filename, set_filename);
2066 pc->cb_info->is_filename_converted = TRUE;
2069 RECORDER_MSG_PARAM_SET(param, STRING, set_filename);
2071 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2073 LOGD("ret : 0x%x", ret);
2079 int recorder_get_filename(recorder_h recorder, char **filename)
2081 int ret = RECORDER_ERROR_NONE;
2082 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILENAME;
2083 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2084 char compat_filename[RECORDER_FILENAME_MAX] = {0, };
2086 if (!pc || !pc->cb_info) {
2087 LOGE("NULL handle");
2088 return RECORDER_ERROR_INVALID_PARAMETER;
2091 if (filename == NULL) {
2092 LOGE("filename is NULL");
2093 return RECORDER_ERROR_INVALID_PARAMETER;
2098 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2100 if (ret == RECORDER_ERROR_NONE) {
2101 if (pc->cb_info->is_filename_converted == FALSE ||
2102 storage_get_compat_internal_path(pc->cb_info->get_filename, RECORDER_FILENAME_MAX, compat_filename) < 0) {
2103 /* Use original path. */
2104 *filename = pc->cb_info->get_filename;
2106 /* Converted. Use converted path. */
2107 LOGD("Converted filename : %s -> %s", pc->cb_info->get_filename, compat_filename);
2108 *filename = strdup(compat_filename);
2109 free(pc->cb_info->get_filename);
2112 pc->cb_info->get_filename = NULL;
2115 LOGD("ret : 0x%x, filename : [%s]", ret, (*filename) ? *filename : "NULL");
2121 int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
2123 int ret = RECORDER_ERROR_NONE;
2124 int set_format = (int)format;
2125 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT;
2126 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2127 recorder_msg_param param;
2129 if (!pc || !pc->cb_info) {
2130 LOGE("NULL handle");
2131 return RECORDER_ERROR_INVALID_PARAMETER;
2134 LOGD("ENTER, set_format : %d", set_format);
2136 RECORDER_MSG_PARAM_SET(param, INT, set_format);
2138 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2140 LOGD("ret : 0x%x", ret);
2145 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format)
2147 int ret = RECORDER_ERROR_NONE;
2148 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILE_FORMAT;
2149 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2151 if (!pc || !pc->cb_info) {
2152 LOGE("NULL handle");
2153 return RECORDER_ERROR_INVALID_PARAMETER;
2156 if (format == NULL) {
2157 LOGE("NULL pointer data");
2158 return RECORDER_ERROR_INVALID_PARAMETER;
2163 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2165 if (ret == RECORDER_ERROR_NONE)
2166 *format = (recorder_file_format_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT];
2168 LOGD("ret : 0x%x, format %d", ret, *format);
2174 int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stream_info)
2176 int ret = RECORDER_ERROR_NONE;
2177 muse_recorder_api_e api = MUSE_RECORDER_API_SET_SOUND_STREAM_INFO;
2178 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2179 bool is_available = false;
2180 int stream_index = 0;
2181 char *stream_type = NULL;
2182 char *send_msg = NULL;
2185 if (!pc || !pc->cb_info || stream_info == NULL) {
2186 LOGE("NULL handle");
2187 return RECORDER_ERROR_INVALID_PARAMETER;
2192 ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_RECORDER, &is_available);
2193 if (ret != SOUND_MANAGER_ERROR_NONE) {
2194 LOGE("stream info verification failed");
2195 return RECORDER_ERROR_INVALID_OPERATION;
2198 if (is_available == false) {
2199 LOGE("stream information is not available");
2200 return RECORDER_ERROR_INVALID_OPERATION;
2203 ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
2204 ret |= sound_manager_get_index_from_stream_information(stream_info, &stream_index);
2206 LOGD("sound manager return [0x%x]", ret);
2208 if (ret == SOUND_MANAGER_ERROR_NONE) {
2209 send_msg = muse_core_msg_new(api,
2210 MUSE_TYPE_STRING, "stream_type", stream_type,
2211 MUSE_TYPE_INT, "stream_index", stream_index,
2214 if (pc->cb_info->is_server_connected) {
2215 __recorder_update_api_waiting(pc->cb_info, api, 1);
2217 send_ret = muse_core_msg_send(pc->cb_info->fd, send_msg);
2221 LOGE("message send failed");
2222 ret = RECORDER_ERROR_INVALID_OPERATION;
2224 ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT);
2227 __recorder_update_api_waiting(pc->cb_info, api, -1);
2229 muse_core_msg_free(send_msg);
2231 LOGE("failed to create msg");
2232 ret = RECORDER_ERROR_OUT_OF_MEMORY;
2235 ret = RECORDER_ERROR_INVALID_OPERATION;
2242 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void *user_data)
2244 int ret = RECORDER_ERROR_NONE;
2245 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2246 muse_recorder_api_e api = MUSE_RECORDER_API_SET_STATE_CHANGED_CB;
2248 if (!pc || !pc->cb_info || callback == NULL) {
2249 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2250 return RECORDER_ERROR_INVALID_PARAMETER;
2253 LOGD("Enter, handle :%td", pc->remote_handle);
2255 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2257 if (ret == RECORDER_ERROR_NONE) {
2258 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
2260 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
2261 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
2263 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
2266 LOGD("ret : 0x%x", ret);
2272 int recorder_unset_state_changed_cb(recorder_h recorder)
2274 int ret = RECORDER_ERROR_NONE;
2275 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB;
2276 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2278 if (!pc || !pc->cb_info) {
2279 LOGE("NULL handle");
2280 return RECORDER_ERROR_INVALID_PARAMETER;
2285 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2287 if (ret == RECORDER_ERROR_NONE) {
2288 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
2290 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
2291 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
2293 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
2296 LOGD("ret : 0x%x", ret);
2302 int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data)
2304 int ret = RECORDER_ERROR_NONE;
2305 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2306 muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB;
2308 if (!pc || !pc->cb_info || callback == NULL) {
2309 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2310 return RECORDER_ERROR_INVALID_PARAMETER;
2313 LOGD("Enter, handle :%td", pc->remote_handle);
2315 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2317 if (ret == RECORDER_ERROR_NONE) {
2318 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
2320 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
2321 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
2323 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
2326 LOGD("ret : 0x%x", ret);
2332 int recorder_unset_interrupted_cb(recorder_h recorder)
2334 int ret = RECORDER_ERROR_NONE;
2335 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB;
2336 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2338 if (!pc || !pc->cb_info) {
2339 LOGE("NULL handle");
2340 return RECORDER_ERROR_INVALID_PARAMETER;
2345 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2347 if (ret == RECORDER_ERROR_NONE) {
2348 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
2350 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
2351 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
2353 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
2356 LOGD("ret : 0x%x", ret);
2362 int recorder_set_interrupt_started_cb(recorder_h recorder, recorder_interrupt_started_cb callback, void *user_data)
2364 int ret = RECORDER_ERROR_NONE;
2365 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2366 muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPT_STARTED_CB;
2368 if (!pc || !pc->cb_info || callback == NULL) {
2369 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2370 return RECORDER_ERROR_INVALID_PARAMETER;
2373 LOGD("Enter, handle :%td", pc->remote_handle);
2375 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2377 if (ret == RECORDER_ERROR_NONE) {
2378 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
2380 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = callback;
2381 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
2383 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
2386 LOGD("ret : 0x%x", ret);
2392 int recorder_unset_interrupt_started_cb(recorder_h recorder)
2394 int ret = RECORDER_ERROR_NONE;
2395 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPT_STARTED_CB;
2396 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2398 if (!pc || !pc->cb_info) {
2399 LOGE("NULL handle");
2400 return RECORDER_ERROR_INVALID_PARAMETER;
2405 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2407 if (ret == RECORDER_ERROR_NONE) {
2408 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
2410 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
2411 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
2413 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
2416 LOGD("ret : 0x%x", ret);
2422 int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void *user_data)
2424 int ret = RECORDER_ERROR_NONE;
2425 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2426 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_STREAM_CB;
2428 if (!pc || !pc->cb_info || callback == NULL) {
2429 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2430 return RECORDER_ERROR_INVALID_PARAMETER;
2433 LOGD("Enter, handle :%td", pc->remote_handle);
2435 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2437 if (ret == RECORDER_ERROR_NONE) {
2438 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
2440 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
2441 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
2443 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
2446 LOGD("ret : 0x%x", ret);
2452 int recorder_unset_audio_stream_cb(recorder_h recorder)
2454 int ret = RECORDER_ERROR_NONE;
2455 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB;
2456 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2458 if (!pc || !pc->cb_info) {
2459 LOGE("NULL handle");
2460 return RECORDER_ERROR_INVALID_PARAMETER;
2465 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2467 if (ret == RECORDER_ERROR_NONE) {
2468 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
2470 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
2471 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
2473 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
2476 LOGD("ret : 0x%x", ret);
2482 int recorder_set_muxed_stream_cb(recorder_h recorder, recorder_muxed_stream_cb callback, void *user_data)
2484 int ret = RECORDER_ERROR_NONE;
2485 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2486 muse_recorder_api_e api = MUSE_RECORDER_API_SET_MUXED_STREAM_CB;
2488 if (!pc || !pc->cb_info || !callback) {
2489 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2490 return RECORDER_ERROR_INVALID_PARAMETER;
2493 LOGD("Enter, handle :%td", pc->remote_handle);
2495 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2497 if (ret == RECORDER_ERROR_NONE) {
2498 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
2500 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = callback;
2501 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = user_data;
2503 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
2506 LOGD("ret : 0x%x", ret);
2512 int recorder_unset_muxed_stream_cb(recorder_h recorder)
2514 int ret = RECORDER_ERROR_NONE;
2515 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_MUXED_STREAM_CB;
2516 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2518 if (!pc || !pc->cb_info) {
2519 LOGE("NULL handle");
2520 return RECORDER_ERROR_INVALID_PARAMETER;
2525 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2527 if (ret == RECORDER_ERROR_NONE) {
2528 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
2530 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL;
2531 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL;
2533 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
2536 LOGD("ret : 0x%x", ret);
2542 int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data)
2544 int ret = RECORDER_ERROR_NONE;
2545 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2546 muse_recorder_api_e api = MUSE_RECORDER_API_SET_ERROR_CB;
2548 if (!pc || !pc->cb_info || callback == NULL) {
2549 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2550 return RECORDER_ERROR_INVALID_PARAMETER;
2553 LOGD("Enter, handle :%td", pc->remote_handle);
2555 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2557 if (ret == RECORDER_ERROR_NONE) {
2558 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
2560 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
2561 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
2563 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
2566 LOGD("ret : 0x%x", ret);
2572 int recorder_unset_error_cb(recorder_h recorder)
2574 int ret = RECORDER_ERROR_NONE;
2575 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_ERROR_CB;
2576 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2578 if (!pc || !pc->cb_info) {
2579 LOGE("NULL handle");
2580 return RECORDER_ERROR_INVALID_PARAMETER;
2585 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2587 if (ret == RECORDER_ERROR_NONE) {
2588 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
2590 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL;
2591 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL;
2593 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
2596 LOGD("ret : 0x%x", ret);
2602 int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void *user_data)
2604 int ret = RECORDER_ERROR_NONE;
2605 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2606 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_STATUS_CB;
2608 if (!pc || !pc->cb_info || callback == NULL) {
2609 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2610 return RECORDER_ERROR_INVALID_PARAMETER;
2613 LOGD("Enter, handle :%td", pc->remote_handle);
2615 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2617 if (ret == RECORDER_ERROR_NONE) {
2618 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
2620 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
2621 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
2623 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
2626 LOGD("ret : 0x%x", ret);
2632 int recorder_unset_recording_status_cb(recorder_h recorder)
2634 int ret = RECORDER_ERROR_NONE;
2635 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_STATUS_CB;
2636 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2638 if (!pc || !pc->cb_info) {
2639 LOGE("NULL handle");
2640 return RECORDER_ERROR_INVALID_PARAMETER;
2645 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2647 if (ret == RECORDER_ERROR_NONE) {
2648 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
2650 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
2651 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
2653 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
2656 LOGD("ret : 0x%x", ret);
2662 int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void *user_data)
2664 int ret = RECORDER_ERROR_NONE;
2665 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2666 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_LIMIT_REACHED_CB;
2668 if (!pc || !pc->cb_info || callback == NULL) {
2669 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2670 return RECORDER_ERROR_INVALID_PARAMETER;
2673 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2675 if (ret == RECORDER_ERROR_NONE) {
2676 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
2678 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
2679 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
2681 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
2684 LOGD("ret : 0x%x", ret);
2690 int recorder_unset_recording_limit_reached_cb(recorder_h recorder)
2692 int ret = RECORDER_ERROR_NONE;
2693 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_LIMIT_REACHED_CB;
2694 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2696 if (!pc || !pc->cb_info) {
2697 LOGE("NULL handle");
2698 return RECORDER_ERROR_INVALID_PARAMETER;
2703 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2705 if (ret == RECORDER_ERROR_NONE) {
2706 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
2708 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
2709 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
2711 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
2714 LOGD("ret : 0x%x", ret);
2720 int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb, void *user_data)
2722 int ret = RECORDER_ERROR_NONE;
2723 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2724 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_FILE_FORMAT;
2726 if (!pc || !pc->cb_info || foreach_cb == NULL) {
2727 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2728 return RECORDER_ERROR_INVALID_PARAMETER;
2731 LOGD("Enter, handle :%td", pc->remote_handle);
2733 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = foreach_cb;
2734 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = user_data;
2736 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2738 LOGD("ret : 0x%x", ret);
2744 int recorder_attr_set_size_limit(recorder_h recorder, int kbyte)
2746 int ret = RECORDER_ERROR_NONE;
2747 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_SIZE_LIMIT;
2748 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2749 recorder_msg_param param;
2751 if (!pc || !pc->cb_info) {
2752 LOGE("NULL handle");
2753 return RECORDER_ERROR_INVALID_PARAMETER;
2758 RECORDER_MSG_PARAM_SET(param, INT, kbyte);
2760 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2762 LOGD("ret : 0x%x", ret);
2768 int recorder_attr_set_time_limit(recorder_h recorder, int second)
2770 int ret = RECORDER_ERROR_NONE;
2771 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_TIME_LIMIT;
2772 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2773 recorder_msg_param param;
2775 if (!pc || !pc->cb_info) {
2776 LOGE("NULL handle");
2777 return RECORDER_ERROR_INVALID_PARAMETER;
2782 RECORDER_MSG_PARAM_SET(param, INT, second);
2784 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2786 LOGD("ret : 0x%x", ret);
2792 int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device)
2794 int ret = RECORDER_ERROR_NONE;
2795 int set_device = (int)device;
2796 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_DEVICE;
2797 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2798 recorder_msg_param param;
2800 if (!pc || !pc->cb_info) {
2801 LOGE("NULL handle");
2802 return RECORDER_ERROR_INVALID_PARAMETER;
2807 RECORDER_MSG_PARAM_SET(param, INT, set_device);
2809 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2811 LOGD("ret : 0x%x", ret);
2817 int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec)
2819 int ret = RECORDER_ERROR_NONE;
2820 int set_codec = (int)codec;
2821 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_ENCODER;
2822 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2823 recorder_msg_param param;
2825 if (!pc || !pc->cb_info) {
2826 LOGE("NULL handle");
2827 return RECORDER_ERROR_INVALID_PARAMETER;
2832 RECORDER_MSG_PARAM_SET(param, INT, set_codec);
2834 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2836 LOGD("ret : 0x%x", ret);
2842 int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec)
2844 int ret = RECORDER_ERROR_NONE;
2845 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_ENCODER;
2846 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2848 if (!pc || !pc->cb_info) {
2849 LOGE("NULL handle");
2850 return RECORDER_ERROR_INVALID_PARAMETER;
2853 if (codec == NULL) {
2854 LOGE("codec is NULL");
2855 return RECORDER_ERROR_INVALID_PARAMETER;
2860 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2862 if (ret == RECORDER_ERROR_NONE)
2863 *codec = (recorder_audio_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER];
2865 LOGD("ret : 0x%x, codec %d", ret, *codec);
2871 int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec)
2873 int ret = RECORDER_ERROR_NONE;
2874 int set_codec = (int)codec;
2875 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_ENCODER;
2876 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2877 recorder_msg_param param;
2879 if (!pc || !pc->cb_info) {
2880 LOGE("NULL handle");
2881 return RECORDER_ERROR_INVALID_PARAMETER;
2886 RECORDER_MSG_PARAM_SET(param, INT, set_codec);
2888 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2890 LOGD("ret : 0x%x", ret);
2896 int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec)
2898 int ret = RECORDER_ERROR_NONE;
2899 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_ENCODER;
2900 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2902 if (!pc || !pc->cb_info) {
2903 LOGE("NULL handle");
2904 return RECORDER_ERROR_INVALID_PARAMETER;
2907 if (codec == NULL) {
2908 LOGE("codec is NULL");
2909 return RECORDER_ERROR_INVALID_PARAMETER;
2914 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2916 if (ret == RECORDER_ERROR_NONE)
2917 *codec = (recorder_video_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER];
2919 LOGD("ret : 0x%x, codec %d", ret, *codec);
2925 int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate)
2927 int ret = RECORDER_ERROR_NONE;
2928 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_SAMPLERATE;
2929 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2930 recorder_msg_param param;
2932 if (!pc || !pc->cb_info) {
2933 LOGE("NULL handle");
2934 return RECORDER_ERROR_INVALID_PARAMETER;
2937 LOGD("ENTER, samplerate : %d", samplerate);
2939 RECORDER_MSG_PARAM_SET(param, INT, samplerate);
2941 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2943 LOGD("ret : 0x%x", ret);
2949 int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate)
2951 int ret = RECORDER_ERROR_NONE;
2952 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_ENCODER_BITRATE;
2953 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2954 recorder_msg_param param;
2956 if (!pc || !pc->cb_info) {
2957 LOGE("NULL handle");
2958 return RECORDER_ERROR_INVALID_PARAMETER;
2963 RECORDER_MSG_PARAM_SET(param, INT, bitrate);
2965 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2967 LOGD("ret : 0x%x", ret);
2973 int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate)
2975 int ret = RECORDER_ERROR_NONE;
2976 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_VIDEO_ENCODER_BITRATE;
2977 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2978 recorder_msg_param param;
2980 if (!pc || !pc->cb_info) {
2981 LOGE("NULL handle");
2982 return RECORDER_ERROR_INVALID_PARAMETER;
2987 RECORDER_MSG_PARAM_SET(param, INT, bitrate);
2989 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2991 LOGD("ret : 0x%x", ret);
2997 int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte)
2999 int ret = RECORDER_ERROR_NONE;
3000 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT;
3001 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3003 if (!pc || !pc->cb_info) {
3004 LOGE("NULL handle");
3005 return RECORDER_ERROR_INVALID_PARAMETER;
3008 if (kbyte == NULL) {
3009 LOGE("NULL pointer kbyte");
3010 return RECORDER_ERROR_INVALID_PARAMETER;
3015 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3017 if (ret == RECORDER_ERROR_NONE)
3018 *kbyte = pc->cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT];
3020 LOGD("ret : 0x%x, %d kbyte", ret, *kbyte);
3026 int recorder_attr_get_time_limit(recorder_h recorder, int *second)
3028 int ret = RECORDER_ERROR_NONE;
3029 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT;
3030 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3032 if (!pc || !pc->cb_info) {
3033 LOGE("NULL handle");
3034 return RECORDER_ERROR_INVALID_PARAMETER;
3037 if (second == NULL) {
3038 LOGE("NULL pointer second");
3039 return RECORDER_ERROR_INVALID_PARAMETER;
3044 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3046 if (ret == RECORDER_ERROR_NONE)
3047 *second = pc->cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT];
3049 LOGD("ret : 0x%x, %d second", ret, *second);
3055 int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device)
3057 int ret = RECORDER_ERROR_NONE;
3058 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE;
3059 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3061 if (!pc || !pc->cb_info) {
3062 LOGE("NULL handle");
3063 return RECORDER_ERROR_INVALID_PARAMETER;
3066 if (device == NULL) {
3067 LOGE("NULL pointer device");
3068 return RECORDER_ERROR_INVALID_PARAMETER;
3073 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3075 if (ret == RECORDER_ERROR_NONE)
3076 *device = (recorder_audio_device_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE];
3078 LOGD("ret : 0x%x, device %d", ret, *device);
3084 int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate)
3086 int ret = RECORDER_ERROR_NONE;
3087 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE;
3088 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3090 if (!pc || !pc->cb_info) {
3091 LOGE("NULL handle");
3092 return RECORDER_ERROR_INVALID_PARAMETER;
3095 if (samplerate == NULL) {
3096 LOGE("NULL pointer handle");
3097 return RECORDER_ERROR_INVALID_PARAMETER;
3102 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3104 if (ret == RECORDER_ERROR_NONE)
3105 *samplerate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE];
3107 LOGD("ret : 0x%x, samplerate %d", ret, *samplerate);
3113 int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate)
3115 int ret = RECORDER_ERROR_NONE;
3116 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE;
3117 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3119 if (!pc || !pc->cb_info) {
3120 LOGE("NULL handle");
3121 return RECORDER_ERROR_INVALID_PARAMETER;
3124 if (bitrate == NULL) {
3125 LOGE("NULL pointer");
3126 return RECORDER_ERROR_INVALID_PARAMETER;
3131 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3133 if (ret == RECORDER_ERROR_NONE)
3134 *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE];
3136 LOGD("ret : 0x%x, bitrate %d", ret, *bitrate);
3142 int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate)
3144 int ret = RECORDER_ERROR_NONE;
3145 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE;
3146 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3148 if (!pc || !pc->cb_info) {
3149 LOGE("NULL handle");
3150 return RECORDER_ERROR_INVALID_PARAMETER;
3153 if (bitrate == NULL) {
3154 LOGE("NULL pointer");
3155 return RECORDER_ERROR_INVALID_PARAMETER;
3160 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3162 if (ret == RECORDER_ERROR_NONE)
3163 *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE];
3165 LOGD("ret : 0x%x", ret);
3171 int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb, void *user_data)
3173 int ret = RECORDER_ERROR_NONE;
3174 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3175 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_AUDIO_ENCODER;
3177 if (!pc || !pc->cb_info || foreach_cb == NULL) {
3178 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
3179 return RECORDER_ERROR_INVALID_PARAMETER;
3182 LOGD("Enter, handle :%td", pc->remote_handle);
3184 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = foreach_cb;
3185 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = user_data;
3187 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3189 LOGD("ret : 0x%x", ret);
3195 int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb, void *user_data)
3197 int ret = RECORDER_ERROR_NONE;
3198 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3199 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_ENCODER;
3201 if (!pc || !pc->cb_info || foreach_cb == NULL) {
3202 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
3203 return RECORDER_ERROR_INVALID_PARAMETER;
3206 LOGD("Enter, handle :%td", pc->remote_handle);
3208 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = foreach_cb;
3209 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = user_data;
3211 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3213 LOGD("ret : 0x%x", ret);
3219 int recorder_attr_set_mute(recorder_h recorder, bool enable)
3221 int ret = RECORDER_ERROR_NONE;
3222 int set_enable = (int)enable;
3223 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_MUTE;
3224 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3225 recorder_msg_param param;
3227 if (!pc || !pc->cb_info) {
3228 LOGE("NULL handle");
3229 return RECORDER_ERROR_INVALID_PARAMETER;
3234 RECORDER_MSG_PARAM_SET(param, INT, set_enable);
3236 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3238 LOGD("ret : 0x%x", ret);
3244 bool recorder_attr_is_muted(recorder_h recorder)
3247 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_IS_MUTED;
3248 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3250 if (!pc || !pc->cb_info) {
3251 LOGE("NULL handle");
3257 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3259 if (ret == RECORDER_ERROR_SERVICE_DISCONNECTED)
3262 LOGD("ret : %d", ret);
3268 int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate)
3270 int ret = RECORDER_ERROR_NONE;
3271 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_RECORDING_MOTION_RATE;
3272 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3273 recorder_msg_param param;
3275 if (!pc || !pc->cb_info) {
3276 LOGE("NULL handle");
3277 return RECORDER_ERROR_INVALID_PARAMETER;
3280 LOGD("ENTER - %.20lf", rate);
3282 RECORDER_MSG_PARAM_SET(param, DOUBLE, rate);
3284 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3286 LOGD("ret : 0x%x", ret);
3292 int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate)
3294 int ret = RECORDER_ERROR_NONE;
3295 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE;
3296 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3298 if (!pc || !pc->cb_info) {
3299 LOGE("NULL handle");
3300 return RECORDER_ERROR_INVALID_PARAMETER;
3304 LOGE("rate is NULL");
3305 return RECORDER_ERROR_INVALID_PARAMETER;
3310 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3311 if (ret == RECORDER_ERROR_NONE)
3312 *rate = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE];
3314 LOGD("ret : 0x%x - rate %.20lf", ret, *rate);
3320 int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count)
3322 int ret = RECORDER_ERROR_NONE;
3323 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_CHANNEL;
3324 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3325 recorder_msg_param param;
3327 if (!pc || !pc->cb_info) {
3328 LOGE("NULL handle");
3329 return RECORDER_ERROR_INVALID_PARAMETER;
3334 RECORDER_MSG_PARAM_SET(param, INT, channel_count);
3336 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3338 LOGD("ret : 0x%x", ret);
3344 int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count)
3346 int ret = RECORDER_ERROR_NONE;
3347 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL;
3348 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3350 if (!pc || !pc->cb_info) {
3351 LOGE("NULL handle");
3352 return RECORDER_ERROR_INVALID_PARAMETER;
3355 if (channel_count == NULL) {
3356 LOGE("channel_count is NULL");
3357 return RECORDER_ERROR_INVALID_PARAMETER;
3362 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3364 if (ret == RECORDER_ERROR_NONE)
3365 *channel_count = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL];
3367 LOGD("ret : 0x%x, channel count %d", ret, *channel_count);
3373 int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation)
3375 int ret = RECORDER_ERROR_NONE;
3376 int set_orientation = (int)orientation;
3377 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_ORIENTATION_TAG;
3378 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3379 recorder_msg_param param;
3381 if (!pc || !pc->cb_info) {
3382 LOGE("NULL handle");
3383 return RECORDER_ERROR_INVALID_PARAMETER;
3388 RECORDER_MSG_PARAM_SET(param, INT, set_orientation);
3390 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3392 LOGD("ret : 0x%x", ret);
3398 int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation)
3400 int ret = RECORDER_ERROR_NONE;
3401 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG;
3402 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3404 if (!pc || !pc->cb_info) {
3405 LOGE("NULL handle");
3406 return RECORDER_ERROR_INVALID_PARAMETER;
3409 if (orientation == NULL) {
3410 LOGE("orientation is NULL");
3411 return RECORDER_ERROR_INVALID_PARAMETER;
3416 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3418 if (ret == RECORDER_ERROR_NONE)
3419 *orientation = (recorder_rotation_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG];
3421 LOGD("ret : 0x%x, orientation %d", ret, *orientation);
3427 int recorder_get_device_state(recorder_type_e type, recorder_device_state_e *state)
3429 int ret = RECORDER_ERROR_NONE;
3431 int get_device_state = 0;
3432 char *send_msg = NULL;
3433 char recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH] = {'\0',};
3436 LOGE("NULL pointer");
3437 return RECORDER_ERROR_INVALID_PARAMETER;
3440 LOGD("Enter - type %d", type);
3442 sock_fd = muse_client_new();
3444 LOGE("muse_client_new failed - returned fd %d", sock_fd);
3445 ret = RECORDER_ERROR_INVALID_OPERATION;
3446 goto _GET_DEVICE_STATE_EXIT;
3449 send_msg = muse_core_msg_new(MUSE_RECORDER_API_GET_DEVICE_STATE,
3450 MUSE_TYPE_INT, "module", MUSE_RECORDER,
3451 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, type,
3455 ret = RECORDER_ERROR_OUT_OF_MEMORY;
3456 goto _GET_DEVICE_STATE_EXIT;
3459 LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
3461 ret = muse_core_msg_send(sock_fd, send_msg);
3463 muse_core_msg_free(send_msg);
3467 LOGE("send msg failed %d", errno);
3468 ret = RECORDER_ERROR_INVALID_OPERATION;
3469 goto _GET_DEVICE_STATE_EXIT;
3472 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_RECORDER_MSG_MAX_LENGTH);
3474 LOGE("recv msg failed %d", errno);
3475 ret = RECORDER_ERROR_INVALID_OPERATION;
3476 goto _GET_DEVICE_STATE_EXIT;
3479 if (!muse_recorder_msg_get(ret, recv_msg)) {
3480 LOGE("failed to get return value from msg [%s]", recv_msg);
3481 ret = RECORDER_ERROR_INVALID_OPERATION;
3482 goto _GET_DEVICE_STATE_EXIT;
3485 if (ret == RECORDER_ERROR_NONE) {
3486 if (muse_recorder_msg_get(get_device_state, recv_msg)) {
3487 *state = (recorder_device_state_e)get_device_state;
3488 LOGD("device type %d state %d", type, *state);
3490 LOGE("failed to get device state from msg [%s]", recv_msg);
3491 ret = RECORDER_ERROR_INVALID_OPERATION;
3494 LOGE("failed 0x%x", ret);
3497 _GET_DEVICE_STATE_EXIT:
3499 muse_client_close(sock_fd);
3507 int recorder_add_device_state_changed_cb(recorder_device_state_changed_cb callback, void *user_data, int *cb_id)
3509 int ret = RECORDER_ERROR_NONE;
3510 recorder_device_state_e state = RECORDER_DEVICE_STATE_IDLE;
3511 recorder_cb_info *info = NULL;
3513 if (!callback || !cb_id) {
3514 LOGE("invalid pointer %p %p", callback, cb_id);
3515 return RECORDER_ERROR_INVALID_PARAMETER;
3518 g_mutex_lock(&g_rec_dev_state_changed_cb_lock);
3520 /* check recorder support */
3521 ret = recorder_get_device_state(RECORDER_TYPE_AUDIO, &state);
3522 if (ret != RECORDER_ERROR_NONE) {
3523 LOGE("get device state failed");
3524 g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
3528 info = g_new0(recorder_cb_info, 1);
3530 LOGE("info failed");
3531 ret = RECORDER_ERROR_OUT_OF_MEMORY;
3535 info->id = ++g_rec_dev_state_changed_cb_id;
3536 info->callback = (void *)callback;
3537 info->user_data = user_data;
3541 /* subscribe dbus signal for camera state change */
3542 if (!g_rec_dev_state_changed_cb_conn) {
3543 g_rec_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
3544 if (!g_rec_dev_state_changed_cb_conn) {
3545 LOGE("failed to get gdbus connection");
3546 ret = RECORDER_ERROR_INVALID_OPERATION;
3550 LOGD("subscribe signal %s - %s - %s",
3551 MM_CAMCORDER_DBUS_OBJECT,
3552 MM_CAMCORDER_DBUS_INTERFACE_RECORDER,
3553 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
3555 g_rec_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_rec_dev_state_changed_cb_conn,
3556 NULL, MM_CAMCORDER_DBUS_INTERFACE_RECORDER, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
3557 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__recorder_device_state_changed_cb, NULL, NULL);
3558 if (!g_rec_dev_state_changed_cb_subscribe_id) {
3559 LOGE("failed to get gdbus connection");
3560 ret = RECORDER_ERROR_INVALID_OPERATION;
3564 LOGD("signal subscribe id %u", g_rec_dev_state_changed_cb_subscribe_id);
3567 g_rec_dev_state_changed_cb_list = g_list_prepend(g_rec_dev_state_changed_cb_list, (gpointer)info);
3569 LOGD("callback id %d", info->id);
3572 if (ret != RECORDER_ERROR_NONE) {
3578 if (g_rec_dev_state_changed_cb_conn) {
3579 g_object_unref(g_rec_dev_state_changed_cb_conn);
3580 g_rec_dev_state_changed_cb_conn = NULL;
3584 g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
3590 int recorder_remove_device_state_changed_cb(int cb_id)
3592 int ret = RECORDER_ERROR_NONE;
3593 recorder_device_state_e state = RECORDER_DEVICE_STATE_IDLE;
3594 GList *tmp_list = NULL;
3595 recorder_cb_info *info = NULL;
3597 /* check recorder support */
3598 ret = recorder_get_device_state(RECORDER_TYPE_AUDIO, &state);
3599 if (ret != RECORDER_ERROR_NONE) {
3600 LOGE("get device state failed");
3604 g_mutex_lock(&g_rec_dev_state_changed_cb_lock);
3606 if (!g_rec_dev_state_changed_cb_list) {
3607 LOGE("there is no callback info");
3608 ret = RECORDER_ERROR_INVALID_OPERATION;
3612 tmp_list = g_rec_dev_state_changed_cb_list;
3615 info = tmp_list->data;
3616 tmp_list = tmp_list->next;
3623 if (info->id == cb_id) {
3624 g_rec_dev_state_changed_cb_list = g_list_remove(g_rec_dev_state_changed_cb_list, info);
3629 if (!g_rec_dev_state_changed_cb_list) {
3630 /* no remained callback */
3631 if (g_rec_dev_state_changed_cb_conn) {
3632 /* unsubscribe signal */
3633 g_dbus_connection_signal_unsubscribe(g_rec_dev_state_changed_cb_conn, g_rec_dev_state_changed_cb_subscribe_id);
3634 g_rec_dev_state_changed_cb_subscribe_id = 0;
3636 /* unref connection */
3637 g_object_unref(g_rec_dev_state_changed_cb_conn);
3638 g_rec_dev_state_changed_cb_conn = NULL;
3642 LOGD("id %d callback removed", cb_id);
3643 ret = RECORDER_ERROR_NONE;
3649 LOGE("id %d callback not found", cb_id);
3650 ret = RECORDER_ERROR_INVALID_PARAMETER;
3653 g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);