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);
350 case MUSE_RECORDER_EVENT_TYPE_ERROR:
353 int current_state = 0;
355 muse_recorder_msg_get(error, recv_msg);
356 muse_recorder_msg_get(current_state, recv_msg);
358 ((recorder_error_cb)cb_info->user_cb[event])((recorder_error_e)error,
359 (recorder_state_e)current_state,
360 cb_info->user_data[event]);
364 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER:
368 muse_recorder_msg_get(codec, recv_msg);
370 if (((recorder_supported_audio_encoder_cb)cb_info->user_cb[event])((recorder_audio_codec_e)codec, cb_info->user_data[event]) == false) {
371 cb_info->user_cb[event] = NULL;
372 cb_info->user_data[event] = NULL;
373 /*LOGD("stop foreach callback for SUPPORTED_AUDIO_ENCODER");*/
377 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT:
381 muse_recorder_msg_get(format, recv_msg);
383 if (((recorder_supported_file_format_cb)cb_info->user_cb[event])((recorder_file_format_e)format, cb_info->user_data[event]) == false) {
384 cb_info->user_cb[event] = NULL;
385 cb_info->user_data[event] = NULL;
386 /*LOGD("stop foreach callback for SUPPORTED_FILE_FORMAT");*/
390 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER:
394 muse_recorder_msg_get(codec, recv_msg);
396 if (((recorder_supported_video_encoder_cb)cb_info->user_cb[event])((recorder_video_codec_e)codec, cb_info->user_data[event]) == false) {
397 cb_info->user_cb[event] = NULL;
398 cb_info->user_data[event] = NULL;
399 /*LOGD("stop foreach callback for SUPPORTED_VIDEO_ENCODER");*/
403 default: /* MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION */
408 muse_recorder_msg_get(width, recv_msg);
409 muse_recorder_msg_get(height, recv_msg);
411 if (((recorder_supported_video_resolution_cb)cb_info->user_cb[event])(width, height, cb_info->user_data[event]) == false) {
412 cb_info->user_cb[event] = NULL;
413 cb_info->user_data[event] = NULL;
414 /*LOGD("stop foreach callback for SUPPORTED_VIDEO_RESOLUTION");*/
420 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
426 static gboolean _recorder_idle_event_callback(gpointer data)
428 recorder_cb_info_s *cb_info = NULL;
429 recorder_idle_event_s *rec_idle_event = (recorder_idle_event_s *)data;
431 if (rec_idle_event == NULL) {
432 LOGE("rec_idle_event is NULL");
437 g_mutex_lock(&g_rec_idle_event_lock);
439 cb_info = rec_idle_event->cb_info;
440 if (cb_info == NULL) {
441 LOGW("recorder cb_info is NULL. event %p %d", rec_idle_event, rec_idle_event->event);
442 g_mutex_unlock(&g_rec_idle_event_lock);
443 goto IDLE_EVENT_CALLBACK_DONE;
446 /* remove event from list */
447 if (cb_info->idle_event_list)
448 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
450 g_mutex_unlock(&g_rec_idle_event_lock);
453 _recorder_client_user_callback(cb_info, rec_idle_event->recv_msg, rec_idle_event->event);
455 IDLE_EVENT_CALLBACK_DONE:
457 g_free(rec_idle_event);
458 rec_idle_event = NULL;
464 static void _recorder_deactivate_idle_event_all(recorder_cb_info_s *cb_info)
466 recorder_idle_event_s *rec_idle_event = NULL;
469 if (cb_info == NULL) {
470 LOGE("cb_info is NULL");
474 g_mutex_lock(&g_rec_idle_event_lock);
476 if (cb_info->idle_event_list == NULL) {
479 list = cb_info->idle_event_list;
482 rec_idle_event = list->data;
483 list = g_list_next(list);
485 if (!rec_idle_event) {
486 LOGW("The event is NULL");
490 if (g_idle_remove_by_data(rec_idle_event)) {
491 LOGW("remove idle event %p done", rec_idle_event);
493 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
495 g_free(rec_idle_event);
496 rec_idle_event = NULL;
501 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
502 rec_idle_event, rec_idle_event->event);
504 rec_idle_event->cb_info = NULL;
506 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
509 g_list_free(cb_info->idle_event_list);
510 cb_info->idle_event_list = NULL;
513 g_mutex_unlock(&g_rec_idle_event_lock);
519 static void __recorder_add_msg_to_queue(recorder_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
521 recorder_message_s *rec_msg = NULL;
522 recorder_msg_handler_info_s *msg_handler_info = NULL;
524 if (!cb_info || !msg) {
525 LOGE("NULL pointer %p %p", cb_info, msg);
529 rec_msg = g_new0(recorder_message_s, 1);
531 LOGE("failed to alloc rec_msg for [%s]", msg);
536 rec_msg->event = event;
537 rec_msg->event_class = event_class;
539 strncpy(rec_msg->recv_msg, msg, sizeof(rec_msg->recv_msg) - 1);
541 /*LOGD("add recorder message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
543 if (event == MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM)
544 msg_handler_info = &cb_info->audio_stream_cb_info;
545 else if (event == MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM)
546 msg_handler_info = &cb_info->muxed_stream_cb_info;
548 msg_handler_info = &cb_info->msg_handler_info;
550 g_mutex_lock(&msg_handler_info->mutex);
551 g_queue_push_tail(msg_handler_info->queue, (gpointer)rec_msg);
552 g_cond_signal(&msg_handler_info->cond);
553 g_mutex_unlock(&msg_handler_info->mutex);
561 static void __recorder_get_api_operation(int api, recorder_cb_info_s *cb_info, char *msg)
563 if (!cb_info || !msg) {
564 LOGE("NULL pointer %p %p", cb_info, msg);
569 case MUSE_RECORDER_API_GET_STATE:
572 muse_recorder_msg_get(get_state, msg);
573 cb_info->get_int_value[_RECORDER_GET_INT_STATE] = get_state;
576 case MUSE_RECORDER_API_GET_VIDEO_RESOLUTION:
580 muse_recorder_msg_get(get_width, msg);
581 muse_recorder_msg_get(get_height, msg);
582 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] = get_width << 16;
583 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] |= get_height;
586 case MUSE_RECORDER_API_GET_FILE_FORMAT:
589 muse_recorder_msg_get(get_format, msg);
590 cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT] = get_format;
593 case MUSE_RECORDER_API_GET_AUDIO_ENCODER:
596 muse_recorder_msg_get(get_codec, msg);
597 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER] = get_codec;
600 case MUSE_RECORDER_API_GET_VIDEO_ENCODER:
603 muse_recorder_msg_get(get_codec, msg);
604 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER] = get_codec;
607 case MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT:
610 muse_recorder_msg_get(get_kbyte, msg);
611 cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT] = get_kbyte;
614 case MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT:
617 muse_recorder_msg_get(get_second, msg);
618 cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT] = get_second;
621 case MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE:
624 muse_recorder_msg_get(get_device, msg);
625 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE] = get_device;
628 case MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE:
630 int get_samplerate = 0;
631 muse_recorder_msg_get(get_samplerate, msg);
632 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE] = get_samplerate;
635 case MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE:
638 muse_recorder_msg_get(get_bitrate, msg);
639 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE] = get_bitrate;
642 case MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE:
645 muse_recorder_msg_get(get_bitrate, msg);
646 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE] = get_bitrate;
649 case MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE:
652 muse_recorder_msg_get_double(get_rate, msg);
653 cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE] = get_rate;
656 case MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL:
658 int get_channel_count = 0;
659 muse_recorder_msg_get(get_channel_count, msg);
660 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL] = get_channel_count;
663 case MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG:
665 int get_orientation = 0;
666 muse_recorder_msg_get(get_orientation, msg);
667 cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG] = get_orientation;
670 case MUSE_RECORDER_API_GET_AUDIO_LEVEL:
672 double get_level = 0.0;
673 muse_recorder_msg_get_double(get_level, msg);
674 cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL] = get_level;
677 case MUSE_RECORDER_API_GET_FILENAME:
679 char get_filename[MUSE_RECORDER_MSG_MAX_LENGTH] = {'\0',};
680 muse_recorder_msg_get_string(get_filename, msg);
681 if (cb_info->get_filename) {
682 free(cb_info->get_filename);
683 cb_info->get_filename = NULL;
685 cb_info->get_filename = strdup(get_filename);
696 static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg)
698 int ret = RECORDER_ERROR_NONE;
702 int event_class = -1;
704 if (!cb_info || !msg) {
705 LOGE("invalid ptr %p %p", cb_info, msg);
709 /*LOGD("msg [%s]", msg);*/
711 if (!muse_recorder_msg_get(api, msg)) {
712 LOGE("failed to get recorder api");
716 if (api == MUSE_RECORDER_CB_EVENT) {
717 if (!muse_recorder_msg_get(event, msg) ||
718 !muse_recorder_msg_get(event_class, msg)) {
719 LOGE("failed to get event or event_class [%s]", msg);
723 if (!muse_recorder_msg_get(api_class, msg)) {
724 LOGE("failed to get api_class [%s]", msg);
729 if (api_class == MUSE_RECORDER_API_CLASS_IMMEDIATE) {
730 if (api >= MUSE_RECORDER_API_MAX) {
731 LOGE("invalid api %d", api);
735 if (!muse_recorder_msg_get(ret, msg)) {
736 LOGE("failed to get recorder ret");
740 g_mutex_lock(&cb_info->api_mutex[api]);
742 if (api == MUSE_RECORDER_API_GET_DEVICE_STATE) {
743 g_atomic_int_set(&cb_info->msg_recv_running, 0);
744 LOGD("get device state done. close client cb handler");
747 case MUSE_RECORDER_API_CREATE:
748 if (ret != RECORDER_ERROR_NONE) {
749 g_atomic_int_set(&cb_info->msg_recv_running, 0);
750 LOGE("create error 0x%x. closing..", ret);
753 case MUSE_RECORDER_API_DESTROY:
754 if (ret == RECORDER_ERROR_NONE) {
755 g_atomic_int_set(&cb_info->msg_recv_running, 0);
756 LOGD("destroy done. closing..");
760 __recorder_get_api_operation(api, cb_info, msg);
765 if (cb_info->api_waiting[api] > 0) {
766 cb_info->api_ret[api] = ret;
767 cb_info->api_activating[api] = 1;
769 g_cond_signal(&cb_info->api_cond[api]);
771 LOGE("no waiting for api [%d]", api);
774 g_mutex_unlock(&cb_info->api_mutex[api]);
775 } else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB || api == MUSE_RECORDER_CB_EVENT) {
776 __recorder_add_msg_to_queue(cb_info, api, event, event_class, msg);
778 LOGW("unknown recorder api %d and api_class %d", api, api_class);
785 static void *_recorder_msg_handler_func(gpointer data)
789 recorder_message_s *rec_msg = NULL;
790 recorder_idle_event_s *rec_idle_event = NULL;
791 recorder_msg_handler_info_s *handler_info = (recorder_msg_handler_info_s *)data;
792 recorder_cb_info_s *cb_info = NULL;
794 if (!handler_info || !handler_info->cb_info) {
795 LOGE("NULL handler %p", handler_info);
799 cb_info = (recorder_cb_info_s *)handler_info->cb_info;
800 type = handler_info->type;
802 LOGD("t:%d start", type);
804 g_mutex_lock(&handler_info->mutex);
806 while (g_atomic_int_get(&handler_info->running)) {
807 if (g_queue_is_empty(handler_info->queue)) {
808 /*LOGD("signal wait...");*/
809 g_cond_wait(&handler_info->cond, &handler_info->mutex);
810 /*LOGD("signal received");*/
812 if (g_atomic_int_get(&handler_info->running) == 0) {
813 LOGD("stop event thread");
818 rec_msg = (recorder_message_s *)g_queue_pop_head(handler_info->queue);
819 g_mutex_unlock(&handler_info->mutex);
820 if (rec_msg == NULL) {
821 LOGE("NULL message");
822 g_mutex_lock(&handler_info->mutex);
828 if (api < MUSE_RECORDER_API_MAX) {
831 g_mutex_lock(&cb_info->api_mutex[api]);
833 if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
834 if (cb_info->api_waiting[api] > 0) {
835 cb_info->api_ret[api] = ret;
836 cb_info->api_activating[api] = 1;
838 /*LOGD("recorder api %d - return 0x%x", ret);*/
840 g_cond_signal(&cb_info->api_cond[api]);
842 LOGE("no waiting for api [%d]", api);
845 LOGE("t:%d failed to get ret for api %d, msg %s", type, api, rec_msg->recv_msg);
848 g_mutex_unlock(&cb_info->api_mutex[api]);
849 } else if (api == MUSE_RECORDER_CB_EVENT) {
850 switch (rec_msg->event_class) {
851 case MUSE_RECORDER_EVENT_CLASS_THREAD_SUB:
852 _recorder_client_user_callback(cb_info, rec_msg->recv_msg, rec_msg->event);
854 case MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN:
855 rec_idle_event = g_new0(recorder_idle_event_s, 1);
856 if (rec_idle_event == NULL) {
857 LOGE("event alloc failed");
861 rec_idle_event->event = rec_msg->event;
862 rec_idle_event->cb_info = cb_info;
864 strncpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg) - 1);
866 /*LOGD("add recorder event[%d, %p] to IDLE", rec_msg->event, rec_idle_event);*/
868 g_mutex_lock(&g_rec_idle_event_lock);
869 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)rec_idle_event);
870 g_mutex_unlock(&g_rec_idle_event_lock);
872 g_idle_add_full(G_PRIORITY_DEFAULT,
873 (GSourceFunc)_recorder_idle_event_callback,
874 (gpointer)rec_idle_event,
878 LOGE("unknown event class %d", rec_msg->event_class);
882 LOGE("unknown api[%d] message", api);
888 g_mutex_lock(&handler_info->mutex);
891 /* remove remained event */
892 while (!g_queue_is_empty(handler_info->queue)) {
893 rec_msg = (recorder_message_s *)g_queue_pop_head(handler_info->queue);
895 LOGD("remove message %p", rec_msg);
899 LOGW("NULL message");
903 g_mutex_unlock(&handler_info->mutex);
911 static void *_recorder_msg_recv_func(gpointer data)
914 int single_length = 0;
915 int remained_length = 0;
916 char *recv_msg = NULL;
917 char *single_msg = NULL;
918 char *remained_msg = NULL;
922 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
924 if (cb_info == NULL) {
925 LOGE("cb_info NULL");
931 single_msg = (char *)malloc(sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
932 if (single_msg == NULL) {
933 LOGE("single_msg malloc failed");
934 goto CB_HANDLER_EXIT;
937 recv_msg = cb_info->recv_msg;
939 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
940 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH);
941 if (recv_length <= 0) {
943 cb_info->is_server_connected = FALSE;
944 LOGE("receive msg failed - server disconnected");
949 recv_msg[recv_length] = '\0';
955 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
957 /* Need to split the combined entering msgs */
958 for (cur_pos = 0; cur_pos < recv_length; cur_pos++) {
959 if (recv_msg[cur_pos] == '}') {
960 single_length = cur_pos - prev_pos + 1;
962 if (single_length < MUSE_RECORDER_MSG_MAX_LENGTH) {
963 /* check remained msg */
964 if (remained_length > 0) {
967 strncpy(single_msg, remained_msg, remained_length);
968 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
969 single_msg[remained_length + single_length] = '\0';
974 strncpy(single_msg, recv_msg + prev_pos, single_length);
975 single_msg[single_length] = '\0';
976 LOGE("lost msg [%s], skip...", single_msg);
982 strncpy(single_msg, recv_msg + prev_pos, single_length);
983 single_msg[single_length] = '\0';
986 if (single_msg[0] == '{') {
988 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
989 __recorder_process_msg(cb_info, single_msg);
991 LOGE("invalid msg [%s]", single_msg);
994 LOGE("too long message [len %d] skip...", single_length);
997 prev_pos = cur_pos + 1;
1001 /* check incompleted message */
1002 if (recv_msg[recv_length - 1] != '}') {
1004 remained_length = recv_length - prev_pos;
1006 LOGW("incompleted message [len %d]", remained_length);
1010 remained_msg = NULL;
1013 remained_msg = (char *)malloc(remained_length + 1);
1015 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1016 remained_msg[remained_length] = '\0';
1018 LOGE("failed to alloc for remained msg");
1022 remained_length = 0;
1026 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1028 if (!cb_info->is_server_connected) {
1030 /* send error msg for server disconnection */
1031 char *error_msg = muse_core_msg_new(MUSE_RECORDER_CB_EVENT,
1032 MUSE_TYPE_INT, "error", RECORDER_ERROR_SERVICE_DISCONNECTED,
1033 MUSE_TYPE_INT, "current_state", RECORDER_STATE_NONE,
1037 LOGE("error_msg failed");
1038 goto CB_HANDLER_EXIT;
1041 LOGE("add error msg for service disconnection done");
1043 __recorder_add_msg_to_queue(cb_info,
1044 MUSE_RECORDER_CB_EVENT,
1045 MUSE_RECORDER_EVENT_TYPE_ERROR,
1046 MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN,
1049 muse_core_msg_free(error_msg);
1052 LOGE("add error msg for service disconnection done");
1064 remained_msg = NULL;
1071 static bool __create_msg_handler_thread(recorder_msg_handler_info_s *handler_info,
1072 int type, const char *thread_name, recorder_cb_info_s *cb_info)
1074 if (!handler_info || !thread_name || !cb_info) {
1075 LOGE("t:%d NULL %p %p %p",
1076 type, handler_info, thread_name, cb_info);
1082 handler_info->type = type;
1083 handler_info->queue = g_queue_new();
1084 if (handler_info->queue == NULL) {
1085 LOGE("t:%d queue failed", type);
1089 g_mutex_init(&handler_info->mutex);
1090 g_cond_init(&handler_info->cond);
1092 handler_info->cb_info = (void *)cb_info;
1093 g_atomic_int_set(&handler_info->running, 1);
1095 handler_info->thread = g_thread_try_new(thread_name,
1096 _recorder_msg_handler_func, (gpointer)handler_info, NULL);
1097 if (handler_info->thread == NULL) {
1099 LOGE("t:%d thread failed", type);
1101 g_mutex_clear(&handler_info->mutex);
1102 g_cond_clear(&handler_info->cond);
1103 g_queue_free(handler_info->queue);
1104 handler_info->queue = NULL;
1110 LOGD("t:%d done", type);
1116 static void __destroy_msg_handler_thread(recorder_msg_handler_info_s *handler_info)
1120 if (!handler_info) {
1121 LOGE("NULL handler");
1125 if (!handler_info->thread) {
1126 LOGW("thread is not created");
1130 type = handler_info->type;
1132 LOGD("t:%d thread %p", type, handler_info->thread);
1134 g_mutex_lock(&handler_info->mutex);
1135 g_atomic_int_set(&handler_info->running, 0);
1136 g_cond_signal(&handler_info->cond);
1137 g_mutex_unlock(&handler_info->mutex);
1139 g_thread_join(handler_info->thread);
1140 handler_info->thread = NULL;
1142 g_mutex_clear(&handler_info->mutex);
1143 g_cond_clear(&handler_info->cond);
1144 g_queue_free(handler_info->queue);
1145 handler_info->queue = NULL;
1147 LOGD("t:%d done", type);
1153 static recorder_cb_info_s *_recorder_client_callback_new(gint sockfd)
1155 recorder_cb_info_s *cb_info = NULL;
1158 g_return_val_if_fail(sockfd > 0, NULL);
1160 cb_info = g_new0(recorder_cb_info_s, 1);
1161 if (cb_info == NULL) {
1162 LOGE("cb_info failed");
1166 cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 1;
1168 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
1169 g_mutex_init(&cb_info->api_mutex[i]);
1170 g_cond_init(&cb_info->api_cond[i]);
1173 for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
1174 g_mutex_init(&cb_info->user_cb_mutex[i]);
1176 /* message handler thread */
1177 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
1178 _RECORDER_MESSAGE_HANDLER_TYPE_GENERAL, "recorder_msg_handler", cb_info)) {
1179 LOGE("msg_handler_info failed");
1183 /* message handler thread for audio stream callback */
1184 if (!__create_msg_handler_thread(&cb_info->audio_stream_cb_info,
1185 _RECORDER_MESSAGE_HANDLER_TYPE_AUDIO_STREAM_CB, "recorder_msg_handler:audio_stream_cb", cb_info)) {
1186 LOGE("audio_stream_cb_info failed");
1190 /* message handler thread for muxed stream callback */
1191 if (!__create_msg_handler_thread(&cb_info->muxed_stream_cb_info,
1192 _RECORDER_MESSAGE_HANDLER_TYPE_MUXED_STREAM_CB, "recorder_msg_handler:muxed_stream_cb", cb_info)) {
1193 LOGE("muxed_stream_cb_info failed");
1197 cb_info->fd = sockfd;
1199 /* message receive thread */
1200 g_atomic_int_set(&cb_info->msg_recv_running, 1);
1201 cb_info->msg_recv_thread = g_thread_try_new("recorder_msg_recv",
1202 _recorder_msg_recv_func, (gpointer)cb_info, NULL);
1203 if (cb_info->msg_recv_thread == NULL) {
1204 LOGE("message receive thread creation failed");
1208 cb_info->is_server_connected = TRUE;
1214 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
1215 __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
1216 __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
1218 for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
1219 g_mutex_clear(&cb_info->user_cb_mutex[i]);
1221 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
1222 g_mutex_clear(&cb_info->api_mutex[i]);
1223 g_cond_clear(&cb_info->api_cond[i]);
1234 static int _recorder_client_wait_for_cb_return(muse_recorder_api_e api, recorder_cb_info_s *cb_info, int time_out)
1236 int ret = RECORDER_ERROR_NONE;
1239 /*LOGD("Enter api : %d", api);*/
1241 if (!cb_info->is_server_connected) {
1242 LOGE("server is disconnected");
1243 return RECORDER_ERROR_SERVICE_DISCONNECTED;
1246 g_mutex_lock(&(cb_info->api_mutex[api]));
1248 if (cb_info->api_activating[api] == 0) {
1249 if (time_out == RECORDER_CB_NO_TIMEOUT) {
1250 LOGW("wait for api %d", api);
1251 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
1252 ret = cb_info->api_ret[api];
1253 cb_info->api_activating[api] = 0;
1254 LOGW("api %d returned 0x%x", api, ret);
1256 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
1257 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
1258 ret = cb_info->api_ret[api];
1259 cb_info->api_activating[api] = 0;
1260 /*LOGD("return value : 0x%x", ret);*/
1262 ret = RECORDER_ERROR_INVALID_OPERATION;
1263 LOGE("api %d was TIMED OUT!", api);
1267 ret = cb_info->api_ret[api];
1268 cb_info->api_activating[api] = 0;
1270 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
1273 if (ret != RECORDER_ERROR_NONE)
1274 LOGE("ERROR : api %d - ret 0x%x", api, ret);
1276 g_mutex_unlock(&(cb_info->api_mutex[api]));
1282 static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret, int timeout)
1287 if (!cb_info || !ret) {
1288 LOGE("invalid pointer for api %d - %p %p", api, cb_info, ret);
1289 return RECORDER_ERROR_INVALID_PARAMETER;
1292 msg = muse_core_msg_new(api, NULL);
1294 LOGE("msg creation failed: api %d", api);
1295 return RECORDER_ERROR_OUT_OF_MEMORY;
1298 /*LOGD("send msg %s", msg);*/
1300 if (cb_info->is_server_connected) {
1301 __recorder_update_api_waiting(cb_info, api, 1);
1302 send_ret = muse_core_msg_send(cb_info->fd, msg);
1306 LOGE("message send failed");
1307 *ret = RECORDER_ERROR_INVALID_OPERATION;
1309 *ret = _recorder_client_wait_for_cb_return(api, cb_info, timeout);
1312 __recorder_update_api_waiting(cb_info, api, -1);
1314 muse_core_msg_free(msg);
1316 return RECORDER_ERROR_NONE;
1320 static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *ret, recorder_msg_param *param)
1325 if (!cb_info || !ret || !param) {
1326 LOGE("invalid pointer for api %d - %p %p %p", api, cb_info, ret, param);
1327 return RECORDER_ERROR_INVALID_PARAMETER;
1330 /*LOGD("type %d, name %s", param->type, param->name);*/
1332 switch (param->type) {
1334 msg = muse_core_msg_new(api, param->type, param->name, param->value.value_INT, NULL);
1336 case MUSE_TYPE_DOUBLE:
1337 msg = muse_core_msg_new(api, param->type, param->name, param->value.value_DOUBLE, NULL);
1339 case MUSE_TYPE_STRING:
1340 msg = muse_core_msg_new(api, param->type, param->name, param->value.value_STRING, NULL);
1343 LOGE("unknown type %d", param->type);
1348 LOGE("msg creation failed: api %d, type %d, param name %s",
1349 api, param->type, param->name);
1350 return RECORDER_ERROR_OUT_OF_MEMORY;
1353 /*LOGD("send msg %s", msg);*/
1355 if (cb_info->is_server_connected) {
1356 __recorder_update_api_waiting(cb_info, api, 1);
1358 send_ret = muse_core_msg_send(cb_info->fd, msg);
1362 LOGE("message send failed");
1363 *ret = RECORDER_ERROR_INVALID_OPERATION;
1365 *ret = _recorder_client_wait_for_cb_return(api, cb_info, RECORDER_CB_TIMEOUT);
1368 __recorder_update_api_waiting(cb_info, api, -1);
1370 muse_core_msg_free(msg);
1372 return RECORDER_ERROR_NONE;
1376 static void _recorder_client_callback_destroy(recorder_cb_info_s *cb_info)
1380 g_return_if_fail(cb_info != NULL);
1382 LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
1384 g_thread_join(cb_info->msg_recv_thread);
1385 cb_info->msg_recv_thread = NULL;
1387 LOGD("msg_recv thread removed");
1389 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
1390 __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
1391 __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
1393 for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
1394 g_mutex_clear(&cb_info->user_cb_mutex[i]);
1396 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
1397 g_mutex_clear(&cb_info->api_mutex[i]);
1398 g_cond_clear(&cb_info->api_cond[i]);
1401 if (cb_info->fd > -1) {
1402 muse_client_close(cb_info->fd);
1406 if (cb_info->bufmgr) {
1407 tbm_bufmgr_deinit(cb_info->bufmgr);
1408 cb_info->bufmgr = NULL;
1410 if (cb_info->get_filename) {
1411 free(cb_info->get_filename);
1412 cb_info->get_filename = NULL;
1422 static int _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
1424 char **root_directory = (char **)user_data;
1426 if (root_directory == NULL) {
1427 LOGE("user data is NULL");
1431 LOGD("storage id %d, type %d, state %d, path %s",
1432 storage_id, type, state, path ? path : "NULL");
1434 if (type == STORAGE_TYPE_INTERNAL && path) {
1435 if (*root_directory) {
1436 free(*root_directory);
1437 *root_directory = NULL;
1440 *root_directory = strdup(path);
1441 if (*root_directory) {
1442 LOGD("get root directory %s", *root_directory);
1445 LOGE("strdup %s failed", path);
1452 static int _recorder_client_get_root_directory(char **root_directory)
1454 int ret = STORAGE_ERROR_NONE;
1456 if (root_directory == NULL) {
1457 LOGE("user data is NULL");
1461 ret = storage_foreach_device_supported((storage_device_supported_cb)_recorder_storage_device_supported_cb, root_directory);
1462 if (ret != STORAGE_ERROR_NONE) {
1463 LOGE("storage_foreach_device_supported failed 0x%x", ret);
1470 static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e type, camera_h camera)
1472 int ret = RECORDER_ERROR_NONE;
1473 int destroy_ret = RECORDER_ERROR_NONE;
1476 char *send_msg = NULL;
1477 char *root_directory = NULL;
1478 intptr_t camera_handle = 0;
1479 intptr_t handle = 0;
1480 tbm_bufmgr bufmgr = NULL;
1481 recorder_cli_s *pc = NULL;
1482 recorder_msg_param param;
1484 LOGD("Enter - type %d", type);
1486 if (recorder == NULL) {
1487 LOGE("NULL pointer for recorder handle");
1488 return RECORDER_ERROR_INVALID_PARAMETER;
1491 if (type == MUSE_RECORDER_TYPE_VIDEO && camera == NULL) {
1492 LOGE("NULL pointer for camera handle on video recorder mode");
1493 return RECORDER_ERROR_INVALID_PARAMETER;
1496 bufmgr = tbm_bufmgr_init(-1);
1497 if (bufmgr == NULL) {
1498 LOGE("get tbm bufmgr failed");
1499 return RECORDER_ERROR_INVALID_OPERATION;
1502 pc = g_new0(recorder_cli_s, 1);
1504 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1505 goto _ERR_RECORDER_EXIT;
1508 sock_fd = muse_client_new();
1511 LOGE("muse_client_new failed - returned fd %d", sock_fd);
1512 ret = RECORDER_ERROR_INVALID_OPERATION;
1513 goto _ERR_RECORDER_EXIT;
1517 if (type == MUSE_RECORDER_TYPE_AUDIO) {
1518 send_msg = muse_core_msg_new(MUSE_RECORDER_API_CREATE,
1519 MUSE_TYPE_INT, "module", MUSE_RECORDER,
1520 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_AUDIO,
1521 MUSE_TYPE_INT, "pid", getpid(),
1524 pc->camera = camera;
1525 camera_handle = (intptr_t)((camera_cli_s *)camera)->remote_handle;
1526 send_msg = muse_core_msg_new(MUSE_RECORDER_API_CREATE,
1527 MUSE_TYPE_INT, "module", MUSE_RECORDER,
1528 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_VIDEO,
1529 MUSE_TYPE_INT, "pid", getpid(),
1530 MUSE_TYPE_POINTER, "camera_handle", camera_handle,
1537 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1538 goto _ERR_RECORDER_EXIT;
1542 LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
1544 send_ret = muse_core_msg_send(sock_fd, send_msg);
1546 muse_core_msg_free(send_msg);
1551 LOGE("send msg failed %d", errno);
1552 ret = RECORDER_ERROR_INVALID_OPERATION;
1553 goto _ERR_RECORDER_EXIT;
1557 pc->cb_info = _recorder_client_callback_new(sock_fd);
1558 if (pc->cb_info == NULL) {
1559 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1560 goto _ERR_RECORDER_EXIT;
1565 ret = _recorder_client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CB_TIMEOUT);
1567 pc->cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 0;
1569 if (ret != RECORDER_ERROR_NONE) {
1570 LOGE("API_CREATE failed 0x%x", ret);
1571 goto _ERR_RECORDER_EXIT;
1574 muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
1577 LOGE("Receiving Handle Failed!!");
1578 ret = RECORDER_ERROR_INVALID_OPERATION;
1579 goto _ERR_RECORDER_AFTER_CREATE;
1583 if (!_recorder_client_get_root_directory(&root_directory) || root_directory == NULL) {
1585 LOGE("failed to get root directory of internal storage");
1586 ret = RECORDER_ERROR_INVALID_OPERATION;
1587 goto _ERR_RECORDER_AFTER_CREATE;
1591 LOGD("root directory [%s]", root_directory);
1593 RECORDER_MSG_PARAM_SET(param, STRING, root_directory);
1595 _recorder_msg_send_param1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY, pc->cb_info, &ret, ¶m);
1597 if (ret != RECORDER_ERROR_NONE) {
1598 LOGE("failed to set root directory %s", root_directory);
1599 ret = RECORDER_ERROR_INVALID_OPERATION;
1600 goto _ERR_RECORDER_AFTER_CREATE;
1603 free(root_directory);
1604 root_directory = NULL;
1606 pc->remote_handle = handle;
1607 pc->cb_info->bufmgr = bufmgr;
1609 LOGD("recorder[type %d] %p create success : remote handle 0x%td",
1610 type, pc, pc->remote_handle);
1612 *recorder = (recorder_h)pc;
1616 return RECORDER_ERROR_NONE;
1618 _ERR_RECORDER_AFTER_CREATE:
1619 _recorder_msg_send(MUSE_RECORDER_API_DESTROY, pc->cb_info, &destroy_ret, RECORDER_CB_TIMEOUT);
1620 LOGE("destroy return 0x%x", destroy_ret);
1623 tbm_bufmgr_deinit(bufmgr);
1626 if (root_directory) {
1627 free(root_directory);
1628 root_directory = NULL;
1632 muse_client_close(sock_fd);
1638 _recorder_client_callback_destroy(pc->cb_info);
1650 int recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
1652 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_VIDEO, camera);
1656 int recorder_create_audiorecorder(recorder_h *recorder)
1658 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_AUDIO, NULL);
1662 int recorder_get_state(recorder_h recorder, recorder_state_e *state)
1664 int ret = RECORDER_ERROR_NONE;
1665 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1666 muse_recorder_api_e api = MUSE_RECORDER_API_GET_STATE;
1668 if (!pc || !pc->cb_info) {
1669 LOGE("NULL handle");
1670 return RECORDER_ERROR_INVALID_PARAMETER;
1673 if (state == NULL) {
1674 LOGE("NULL pointer state");
1675 return RECORDER_ERROR_INVALID_PARAMETER;
1678 LOGD("Enter, remote_handle : %td", pc->remote_handle);
1680 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1682 if (ret == RECORDER_ERROR_NONE)
1683 *state = (recorder_state_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_STATE];
1685 LOGD("ret : 0x%x, state : %d", ret, *state);
1691 int recorder_destroy(recorder_h recorder)
1693 int ret = RECORDER_ERROR_NONE;
1694 muse_recorder_api_e api = MUSE_RECORDER_API_DESTROY;
1695 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1697 if (!pc || !pc->cb_info) {
1698 LOGE("NULL handle");
1699 return RECORDER_ERROR_INVALID_PARAMETER;
1704 if (pc->cb_info->is_server_connected)
1705 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1707 LOGW("server disconnected. release resource without send message.");
1709 if (ret == RECORDER_ERROR_NONE) {
1710 _recorder_deactivate_idle_event_all(pc->cb_info);
1711 _recorder_client_callback_destroy(pc->cb_info);
1716 LOGD("ret : 0x%x", ret);
1722 int recorder_prepare(recorder_h recorder)
1724 int ret = RECORDER_ERROR_NONE;
1725 muse_recorder_api_e api = MUSE_RECORDER_API_PREPARE;
1726 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1728 if (!pc || !pc->cb_info) {
1729 LOGE("NULL handle");
1730 return RECORDER_ERROR_INVALID_PARAMETER;
1735 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1737 LOGD("ret : 0x%x", ret);
1739 if (ret == RECORDER_ERROR_NONE && pc->camera)
1740 camera_start_evas_rendering(pc->camera);
1746 int recorder_unprepare(recorder_h recorder)
1748 int ret = RECORDER_ERROR_NONE;
1749 muse_recorder_api_e api = MUSE_RECORDER_API_UNPREPARE;
1750 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1751 camera_state_e camera_state = CAMERA_STATE_NONE;
1753 if (!pc || !pc->cb_info) {
1754 LOGE("NULL handle");
1755 return RECORDER_ERROR_INVALID_PARAMETER;
1762 ret = camera_get_state(pc->camera, &camera_state);
1763 if (ret != CAMERA_ERROR_NONE) {
1764 LOGE("failed to get camera state 0x%x", ret);
1765 return RECORDER_ERROR_INVALID_OPERATION;
1768 if (camera_state == CAMERA_STATE_PREVIEW) {
1769 ret = camera_stop_evas_rendering(pc->camera, false);
1770 if (ret != CAMERA_ERROR_NONE) {
1771 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1772 return RECORDER_ERROR_INVALID_OPERATION;
1778 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1780 LOGD("ret : 0x%x", ret);
1786 int recorder_start(recorder_h recorder)
1788 int ret = RECORDER_ERROR_NONE;
1789 muse_recorder_api_e api = MUSE_RECORDER_API_START;
1790 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1791 recorder_state_e current_state = RECORDER_STATE_NONE;
1793 if (!pc || !pc->cb_info) {
1794 LOGE("NULL handle");
1795 return RECORDER_ERROR_INVALID_PARAMETER;
1802 ret = recorder_get_state(recorder, ¤t_state);
1803 if (ret != RECORDER_ERROR_NONE) {
1804 LOGE("failed to get current state 0x%x", ret);
1805 return RECORDER_ERROR_INVALID_OPERATION;
1808 if (current_state == RECORDER_STATE_READY) {
1809 ret = camera_stop_evas_rendering(pc->camera, true);
1810 if (ret != CAMERA_ERROR_NONE) {
1811 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1812 return RECORDER_ERROR_INVALID_OPERATION;
1818 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_NO_TIMEOUT);
1820 if (pc->camera && current_state == RECORDER_STATE_READY)
1821 camera_start_evas_rendering(pc->camera);
1823 LOGD("ret : 0x%x", ret);
1829 int recorder_pause(recorder_h recorder)
1831 int ret = RECORDER_ERROR_NONE;
1832 muse_recorder_api_e api = MUSE_RECORDER_API_PAUSE;
1833 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1835 if (!pc || !pc->cb_info) {
1836 LOGE("NULL handle");
1837 return RECORDER_ERROR_INVALID_PARAMETER;
1842 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1844 LOGD("ret : 0x%x", ret);
1850 int recorder_commit(recorder_h recorder)
1852 int ret = RECORDER_ERROR_NONE;
1853 muse_recorder_api_e api = MUSE_RECORDER_API_COMMIT;
1854 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1855 recorder_state_e current_state = RECORDER_STATE_NONE;
1857 if (!pc || !pc->cb_info) {
1858 LOGE("NULL handle");
1859 return RECORDER_ERROR_INVALID_PARAMETER;
1866 ret = recorder_get_state(recorder, ¤t_state);
1867 if (ret != RECORDER_ERROR_NONE) {
1868 LOGE("failed to get current state 0x%x", ret);
1869 return RECORDER_ERROR_INVALID_OPERATION;
1872 if (current_state >= RECORDER_STATE_RECORDING) {
1873 ret = camera_stop_evas_rendering(pc->camera, true);
1874 if (ret != CAMERA_ERROR_NONE) {
1875 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1876 return RECORDER_ERROR_INVALID_OPERATION;
1882 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1884 if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
1885 camera_start_evas_rendering(pc->camera);
1887 LOGD("ret : 0x%x", ret);
1893 int recorder_cancel(recorder_h recorder)
1895 int ret = RECORDER_ERROR_NONE;
1896 muse_recorder_api_e api = MUSE_RECORDER_API_CANCEL;
1897 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1898 recorder_state_e current_state = RECORDER_STATE_NONE;
1900 if (!pc || !pc->cb_info) {
1901 LOGE("NULL handle");
1902 return RECORDER_ERROR_INVALID_PARAMETER;
1908 ret = recorder_get_state(recorder, ¤t_state);
1909 if (ret != RECORDER_ERROR_NONE) {
1910 LOGE("failed to get current state 0x%x", ret);
1911 return RECORDER_ERROR_INVALID_OPERATION;
1914 if (current_state >= RECORDER_STATE_RECORDING) {
1915 ret = camera_stop_evas_rendering(pc->camera, true);
1916 if (ret != CAMERA_ERROR_NONE) {
1917 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1918 return RECORDER_ERROR_INVALID_OPERATION;
1923 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
1925 if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
1926 camera_start_evas_rendering(pc->camera);
1928 LOGD("ret : 0x%x", ret);
1934 int recorder_set_video_resolution(recorder_h recorder, int width, int height)
1936 int ret = RECORDER_ERROR_NONE;
1938 char *send_msg = NULL;
1939 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION;
1940 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1942 if (!pc || !pc->cb_info) {
1943 LOGE("NULL handle");
1944 return RECORDER_ERROR_INVALID_PARAMETER;
1949 send_msg = muse_core_msg_new(api,
1950 MUSE_TYPE_INT, "width", width,
1951 MUSE_TYPE_INT, "height", height,
1954 if (pc->cb_info->is_server_connected) {
1955 __recorder_update_api_waiting(pc->cb_info, api, 1);
1957 send_ret = muse_core_msg_send(pc->cb_info->fd, send_msg);
1961 LOGE("message send failed");
1962 ret = RECORDER_ERROR_INVALID_OPERATION;
1964 ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT);
1967 __recorder_update_api_waiting(pc->cb_info, api, -1);
1969 muse_core_msg_free(send_msg);
1971 LOGE("failed to create msg");
1972 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1975 LOGD("ret : 0x%x", ret);
1981 int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
1983 int ret = RECORDER_ERROR_NONE;
1984 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_RESOLUTION;
1985 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1987 if (!pc || !pc->cb_info) {
1988 LOGE("NULL handle");
1989 return RECORDER_ERROR_INVALID_PARAMETER;
1992 if (!width || !height) {
1993 LOGE("NULL pointer width = [%p], height = [%p]", width, height);
1994 return RECORDER_ERROR_INVALID_PARAMETER;
1999 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2001 if (ret == RECORDER_ERROR_NONE) {
2002 *width = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] >> 16;
2003 *height = (0x0000ffff & pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION]);
2006 LOGD("ret : 0x%x, %dx%d", ret, *width, *height);
2012 int recorder_foreach_supported_video_resolution(recorder_h recorder,
2013 recorder_supported_video_resolution_cb foreach_cb, void *user_data)
2015 int ret = RECORDER_ERROR_NONE;
2016 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2017 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_RESOLUTION;
2019 if (!pc || !pc->cb_info || foreach_cb == NULL) {
2020 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2021 return RECORDER_ERROR_INVALID_PARAMETER;
2024 LOGD("Enter, handle :%td", pc->remote_handle);
2026 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
2027 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
2029 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2031 LOGD("ret : 0x%x", ret);
2037 int recorder_get_audio_level(recorder_h recorder, double *level)
2039 int ret = RECORDER_ERROR_NONE;
2040 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_LEVEL;
2041 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2043 if (!pc || !pc->cb_info || level == NULL) {
2044 LOGE("NULL pointer %p %p", pc, level);
2045 return RECORDER_ERROR_INVALID_PARAMETER;
2050 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2052 if (ret == RECORDER_ERROR_NONE)
2053 *level = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL];
2055 LOGD("ret : 0x%x, level %lf", ret, *level);
2061 int recorder_set_filename(recorder_h recorder, const char *filename)
2063 int ret = RECORDER_ERROR_NONE;
2065 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
2066 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2067 recorder_msg_param param;
2068 char set_filename[RECORDER_FILENAME_MAX] = {'\0',};
2070 if (!pc || !pc->cb_info) {
2071 LOGE("NULL handle");
2072 return RECORDER_ERROR_INVALID_PARAMETER;
2075 if (filename == NULL) {
2076 LOGE("filename is NULL");
2077 return RECORDER_ERROR_INVALID_PARAMETER;
2080 LOGD("ENTER [%s]", filename);
2082 length = strlen(filename);
2084 if (length >= RECORDER_FILENAME_MAX - 1) {
2085 LOGE("too long file name [%zu]", length);
2086 return RECORDER_ERROR_INVALID_PARAMETER;
2089 if (storage_get_origin_internal_path(filename, RECORDER_FILENAME_MAX, set_filename) < 0) {
2090 /* Cannot convert. Use original path. */
2091 strncpy(set_filename, filename, length + 1);
2092 pc->cb_info->is_filename_converted = FALSE;
2094 /* Converted. Use converted path. */
2095 LOGD("Converted filename : %s -> %s", filename, set_filename);
2096 pc->cb_info->is_filename_converted = TRUE;
2099 RECORDER_MSG_PARAM_SET(param, STRING, set_filename);
2101 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2103 LOGD("ret : 0x%x", ret);
2109 int recorder_get_filename(recorder_h recorder, char **filename)
2111 int ret = RECORDER_ERROR_NONE;
2112 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILENAME;
2113 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2114 char compat_filename[RECORDER_FILENAME_MAX] = {0, };
2116 if (!pc || !pc->cb_info) {
2117 LOGE("NULL handle");
2118 return RECORDER_ERROR_INVALID_PARAMETER;
2121 if (filename == NULL) {
2122 LOGE("filename is NULL");
2123 return RECORDER_ERROR_INVALID_PARAMETER;
2128 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2130 if (ret == RECORDER_ERROR_NONE) {
2131 if (pc->cb_info->is_filename_converted == FALSE ||
2132 storage_get_compat_internal_path(pc->cb_info->get_filename, RECORDER_FILENAME_MAX, compat_filename) < 0) {
2133 /* Use original path. */
2134 *filename = pc->cb_info->get_filename;
2136 /* Converted. Use converted path. */
2137 LOGD("Converted filename : %s -> %s", pc->cb_info->get_filename, compat_filename);
2138 *filename = strdup(compat_filename);
2139 free(pc->cb_info->get_filename);
2142 pc->cb_info->get_filename = NULL;
2145 LOGD("ret : 0x%x, filename : [%s]", ret, (*filename) ? *filename : "NULL");
2151 int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
2153 int ret = RECORDER_ERROR_NONE;
2154 int set_format = (int)format;
2155 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT;
2156 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2157 recorder_msg_param param;
2159 if (!pc || !pc->cb_info) {
2160 LOGE("NULL handle");
2161 return RECORDER_ERROR_INVALID_PARAMETER;
2164 LOGD("ENTER, set_format : %d", set_format);
2166 RECORDER_MSG_PARAM_SET(param, INT, set_format);
2168 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2170 LOGD("ret : 0x%x", ret);
2175 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format)
2177 int ret = RECORDER_ERROR_NONE;
2178 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILE_FORMAT;
2179 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2181 if (!pc || !pc->cb_info) {
2182 LOGE("NULL handle");
2183 return RECORDER_ERROR_INVALID_PARAMETER;
2186 if (format == NULL) {
2187 LOGE("NULL pointer data");
2188 return RECORDER_ERROR_INVALID_PARAMETER;
2193 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2195 if (ret == RECORDER_ERROR_NONE)
2196 *format = (recorder_file_format_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT];
2198 LOGD("ret : 0x%x, format %d", ret, *format);
2204 int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stream_info)
2206 int ret = RECORDER_ERROR_NONE;
2207 muse_recorder_api_e api = MUSE_RECORDER_API_SET_SOUND_STREAM_INFO;
2208 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2209 bool is_available = false;
2210 int stream_index = 0;
2211 char *stream_type = NULL;
2212 char *send_msg = NULL;
2215 if (!pc || !pc->cb_info || stream_info == NULL) {
2216 LOGE("NULL handle");
2217 return RECORDER_ERROR_INVALID_PARAMETER;
2222 ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_RECORDER, &is_available);
2223 if (ret != SOUND_MANAGER_ERROR_NONE) {
2224 LOGE("stream info verification failed");
2225 return RECORDER_ERROR_INVALID_OPERATION;
2228 if (is_available == false) {
2229 LOGE("stream information is not available");
2230 return RECORDER_ERROR_INVALID_OPERATION;
2233 ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
2234 ret |= sound_manager_get_index_from_stream_information(stream_info, &stream_index);
2236 LOGD("sound manager return [0x%x]", ret);
2238 if (ret == SOUND_MANAGER_ERROR_NONE) {
2239 send_msg = muse_core_msg_new(api,
2240 MUSE_TYPE_STRING, "stream_type", stream_type,
2241 MUSE_TYPE_INT, "stream_index", stream_index,
2244 if (pc->cb_info->is_server_connected) {
2245 __recorder_update_api_waiting(pc->cb_info, api, 1);
2247 send_ret = muse_core_msg_send(pc->cb_info->fd, send_msg);
2251 LOGE("message send failed");
2252 ret = RECORDER_ERROR_INVALID_OPERATION;
2254 ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT);
2257 __recorder_update_api_waiting(pc->cb_info, api, -1);
2259 muse_core_msg_free(send_msg);
2261 LOGE("failed to create msg");
2262 ret = RECORDER_ERROR_OUT_OF_MEMORY;
2265 ret = RECORDER_ERROR_INVALID_OPERATION;
2272 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void *user_data)
2274 int ret = RECORDER_ERROR_NONE;
2275 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2276 muse_recorder_api_e api = MUSE_RECORDER_API_SET_STATE_CHANGED_CB;
2278 if (!pc || !pc->cb_info || callback == NULL) {
2279 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2280 return RECORDER_ERROR_INVALID_PARAMETER;
2283 LOGD("Enter, handle :%td", pc->remote_handle);
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] = callback;
2291 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
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_unset_state_changed_cb(recorder_h recorder)
2304 int ret = RECORDER_ERROR_NONE;
2305 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB;
2306 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2308 if (!pc || !pc->cb_info) {
2309 LOGE("NULL handle");
2310 return RECORDER_ERROR_INVALID_PARAMETER;
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_STATE_CHANGE]);
2320 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
2321 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
2323 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
2326 LOGD("ret : 0x%x", ret);
2332 int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data)
2334 int ret = RECORDER_ERROR_NONE;
2335 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2336 muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB;
2338 if (!pc || !pc->cb_info || callback == NULL) {
2339 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2340 return RECORDER_ERROR_INVALID_PARAMETER;
2343 LOGD("Enter, handle :%td", pc->remote_handle);
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] = callback;
2351 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
2353 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
2356 LOGD("ret : 0x%x", ret);
2362 int recorder_unset_interrupted_cb(recorder_h recorder)
2364 int ret = RECORDER_ERROR_NONE;
2365 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB;
2366 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2368 if (!pc || !pc->cb_info) {
2369 LOGE("NULL handle");
2370 return RECORDER_ERROR_INVALID_PARAMETER;
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_INTERRUPTED]);
2380 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
2381 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
2383 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
2386 LOGD("ret : 0x%x", ret);
2392 int recorder_set_interrupt_started_cb(recorder_h recorder, recorder_interrupt_started_cb callback, void *user_data)
2394 int ret = RECORDER_ERROR_NONE;
2395 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2396 muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPT_STARTED_CB;
2398 if (!pc || !pc->cb_info || callback == NULL) {
2399 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2400 return RECORDER_ERROR_INVALID_PARAMETER;
2403 LOGD("Enter, handle :%td", pc->remote_handle);
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] = callback;
2411 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
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_unset_interrupt_started_cb(recorder_h recorder)
2424 int ret = RECORDER_ERROR_NONE;
2425 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPT_STARTED_CB;
2426 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2428 if (!pc || !pc->cb_info) {
2429 LOGE("NULL handle");
2430 return RECORDER_ERROR_INVALID_PARAMETER;
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_INTERRUPT_STARTED]);
2440 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
2441 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
2443 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
2446 LOGD("ret : 0x%x", ret);
2452 int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void *user_data)
2454 int ret = RECORDER_ERROR_NONE;
2455 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2456 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_STREAM_CB;
2458 if (!pc || !pc->cb_info || callback == NULL) {
2459 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2460 return RECORDER_ERROR_INVALID_PARAMETER;
2463 LOGD("Enter, handle :%td", pc->remote_handle);
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] = callback;
2471 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
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_unset_audio_stream_cb(recorder_h recorder)
2484 int ret = RECORDER_ERROR_NONE;
2485 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB;
2486 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2488 if (!pc || !pc->cb_info) {
2489 LOGE("NULL handle");
2490 return RECORDER_ERROR_INVALID_PARAMETER;
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_AUDIO_STREAM]);
2500 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
2501 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
2503 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
2506 LOGD("ret : 0x%x", ret);
2512 int recorder_set_muxed_stream_cb(recorder_h recorder, recorder_muxed_stream_cb callback, void *user_data)
2514 int ret = RECORDER_ERROR_NONE;
2515 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2516 muse_recorder_api_e api = MUSE_RECORDER_API_SET_MUXED_STREAM_CB;
2518 if (!pc || !pc->cb_info || !callback) {
2519 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2520 return RECORDER_ERROR_INVALID_PARAMETER;
2523 LOGD("Enter, handle :%td", pc->remote_handle);
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] = callback;
2531 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = user_data;
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_unset_muxed_stream_cb(recorder_h recorder)
2544 int ret = RECORDER_ERROR_NONE;
2545 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_MUXED_STREAM_CB;
2546 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2548 if (!pc || !pc->cb_info) {
2549 LOGE("NULL handle");
2550 return RECORDER_ERROR_INVALID_PARAMETER;
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_MUXED_STREAM]);
2560 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL;
2561 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL;
2563 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
2566 LOGD("ret : 0x%x", ret);
2572 int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data)
2574 int ret = RECORDER_ERROR_NONE;
2575 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2576 muse_recorder_api_e api = MUSE_RECORDER_API_SET_ERROR_CB;
2578 if (!pc || !pc->cb_info || callback == NULL) {
2579 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2580 return RECORDER_ERROR_INVALID_PARAMETER;
2583 LOGD("Enter, handle :%td", pc->remote_handle);
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] = callback;
2591 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
2593 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
2596 LOGD("ret : 0x%x", ret);
2602 int recorder_unset_error_cb(recorder_h recorder)
2604 int ret = RECORDER_ERROR_NONE;
2605 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_ERROR_CB;
2606 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2608 if (!pc || !pc->cb_info) {
2609 LOGE("NULL handle");
2610 return RECORDER_ERROR_INVALID_PARAMETER;
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_ERROR]);
2620 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL;
2621 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL;
2623 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
2626 LOGD("ret : 0x%x", ret);
2632 int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void *user_data)
2634 int ret = RECORDER_ERROR_NONE;
2635 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2636 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_STATUS_CB;
2638 if (!pc || !pc->cb_info || callback == NULL) {
2639 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2640 return RECORDER_ERROR_INVALID_PARAMETER;
2643 LOGD("Enter, handle :%td", pc->remote_handle);
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] = callback;
2651 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
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_unset_recording_status_cb(recorder_h recorder)
2664 int ret = RECORDER_ERROR_NONE;
2665 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_STATUS_CB;
2666 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2668 if (!pc || !pc->cb_info) {
2669 LOGE("NULL handle");
2670 return RECORDER_ERROR_INVALID_PARAMETER;
2675 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2677 if (ret == RECORDER_ERROR_NONE) {
2678 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
2680 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
2681 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
2683 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
2686 LOGD("ret : 0x%x", ret);
2692 int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void *user_data)
2694 int ret = RECORDER_ERROR_NONE;
2695 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2696 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_LIMIT_REACHED_CB;
2698 if (!pc || !pc->cb_info || callback == NULL) {
2699 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2700 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] = callback;
2709 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
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_unset_recording_limit_reached_cb(recorder_h recorder)
2722 int ret = RECORDER_ERROR_NONE;
2723 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_LIMIT_REACHED_CB;
2724 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2726 if (!pc || !pc->cb_info) {
2727 LOGE("NULL handle");
2728 return RECORDER_ERROR_INVALID_PARAMETER;
2733 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2735 if (ret == RECORDER_ERROR_NONE) {
2736 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
2738 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
2739 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
2741 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
2744 LOGD("ret : 0x%x", ret);
2750 int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb, void *user_data)
2752 int ret = RECORDER_ERROR_NONE;
2753 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2754 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_FILE_FORMAT;
2756 if (!pc || !pc->cb_info || foreach_cb == NULL) {
2757 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2758 return RECORDER_ERROR_INVALID_PARAMETER;
2761 LOGD("Enter, handle :%td", pc->remote_handle);
2763 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = foreach_cb;
2764 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = user_data;
2766 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2768 LOGD("ret : 0x%x", ret);
2774 int recorder_attr_set_size_limit(recorder_h recorder, int kbyte)
2776 int ret = RECORDER_ERROR_NONE;
2777 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_SIZE_LIMIT;
2778 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2779 recorder_msg_param param;
2781 if (!pc || !pc->cb_info) {
2782 LOGE("NULL handle");
2783 return RECORDER_ERROR_INVALID_PARAMETER;
2788 RECORDER_MSG_PARAM_SET(param, INT, kbyte);
2790 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2792 LOGD("ret : 0x%x", ret);
2798 int recorder_attr_set_time_limit(recorder_h recorder, int second)
2800 int ret = RECORDER_ERROR_NONE;
2801 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_TIME_LIMIT;
2802 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2803 recorder_msg_param param;
2805 if (!pc || !pc->cb_info) {
2806 LOGE("NULL handle");
2807 return RECORDER_ERROR_INVALID_PARAMETER;
2812 RECORDER_MSG_PARAM_SET(param, INT, second);
2814 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2816 LOGD("ret : 0x%x", ret);
2822 int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device)
2824 int ret = RECORDER_ERROR_NONE;
2825 int set_device = (int)device;
2826 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_DEVICE;
2827 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2828 recorder_msg_param param;
2830 if (!pc || !pc->cb_info) {
2831 LOGE("NULL handle");
2832 return RECORDER_ERROR_INVALID_PARAMETER;
2837 RECORDER_MSG_PARAM_SET(param, INT, set_device);
2839 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2841 LOGD("ret : 0x%x", ret);
2847 int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec)
2849 int ret = RECORDER_ERROR_NONE;
2850 int set_codec = (int)codec;
2851 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_ENCODER;
2852 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2853 recorder_msg_param param;
2855 if (!pc || !pc->cb_info) {
2856 LOGE("NULL handle");
2857 return RECORDER_ERROR_INVALID_PARAMETER;
2862 RECORDER_MSG_PARAM_SET(param, INT, set_codec);
2864 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2866 LOGD("ret : 0x%x", ret);
2872 int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec)
2874 int ret = RECORDER_ERROR_NONE;
2875 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_ENCODER;
2876 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2878 if (!pc || !pc->cb_info) {
2879 LOGE("NULL handle");
2880 return RECORDER_ERROR_INVALID_PARAMETER;
2883 if (codec == NULL) {
2884 LOGE("codec is NULL");
2885 return RECORDER_ERROR_INVALID_PARAMETER;
2890 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2892 if (ret == RECORDER_ERROR_NONE)
2893 *codec = (recorder_audio_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER];
2895 LOGD("ret : 0x%x, codec %d", ret, *codec);
2901 int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec)
2903 int ret = RECORDER_ERROR_NONE;
2904 int set_codec = (int)codec;
2905 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_ENCODER;
2906 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2907 recorder_msg_param param;
2909 if (!pc || !pc->cb_info) {
2910 LOGE("NULL handle");
2911 return RECORDER_ERROR_INVALID_PARAMETER;
2916 RECORDER_MSG_PARAM_SET(param, INT, set_codec);
2918 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2920 LOGD("ret : 0x%x", ret);
2926 int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec)
2928 int ret = RECORDER_ERROR_NONE;
2929 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_ENCODER;
2930 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2932 if (!pc || !pc->cb_info) {
2933 LOGE("NULL handle");
2934 return RECORDER_ERROR_INVALID_PARAMETER;
2937 if (codec == NULL) {
2938 LOGE("codec is NULL");
2939 return RECORDER_ERROR_INVALID_PARAMETER;
2944 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
2946 if (ret == RECORDER_ERROR_NONE)
2947 *codec = (recorder_video_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER];
2949 LOGD("ret : 0x%x, codec %d", ret, *codec);
2955 int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate)
2957 int ret = RECORDER_ERROR_NONE;
2958 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_SAMPLERATE;
2959 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2960 recorder_msg_param param;
2962 if (!pc || !pc->cb_info) {
2963 LOGE("NULL handle");
2964 return RECORDER_ERROR_INVALID_PARAMETER;
2967 LOGD("ENTER, samplerate : %d", samplerate);
2969 RECORDER_MSG_PARAM_SET(param, INT, samplerate);
2971 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2973 LOGD("ret : 0x%x", ret);
2979 int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate)
2981 int ret = RECORDER_ERROR_NONE;
2982 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_ENCODER_BITRATE;
2983 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2984 recorder_msg_param param;
2986 if (!pc || !pc->cb_info) {
2987 LOGE("NULL handle");
2988 return RECORDER_ERROR_INVALID_PARAMETER;
2993 RECORDER_MSG_PARAM_SET(param, INT, bitrate);
2995 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
2997 LOGD("ret : 0x%x", ret);
3003 int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate)
3005 int ret = RECORDER_ERROR_NONE;
3006 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_VIDEO_ENCODER_BITRATE;
3007 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3008 recorder_msg_param param;
3010 if (!pc || !pc->cb_info) {
3011 LOGE("NULL handle");
3012 return RECORDER_ERROR_INVALID_PARAMETER;
3017 RECORDER_MSG_PARAM_SET(param, INT, bitrate);
3019 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3021 LOGD("ret : 0x%x", ret);
3027 int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte)
3029 int ret = RECORDER_ERROR_NONE;
3030 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT;
3031 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3033 if (!pc || !pc->cb_info) {
3034 LOGE("NULL handle");
3035 return RECORDER_ERROR_INVALID_PARAMETER;
3038 if (kbyte == NULL) {
3039 LOGE("NULL pointer kbyte");
3040 return RECORDER_ERROR_INVALID_PARAMETER;
3045 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3047 if (ret == RECORDER_ERROR_NONE)
3048 *kbyte = pc->cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT];
3050 LOGD("ret : 0x%x, %d kbyte", ret, *kbyte);
3056 int recorder_attr_get_time_limit(recorder_h recorder, int *second)
3058 int ret = RECORDER_ERROR_NONE;
3059 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT;
3060 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3062 if (!pc || !pc->cb_info) {
3063 LOGE("NULL handle");
3064 return RECORDER_ERROR_INVALID_PARAMETER;
3067 if (second == NULL) {
3068 LOGE("NULL pointer second");
3069 return RECORDER_ERROR_INVALID_PARAMETER;
3074 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3076 if (ret == RECORDER_ERROR_NONE)
3077 *second = pc->cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT];
3079 LOGD("ret : 0x%x, %d second", ret, *second);
3085 int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device)
3087 int ret = RECORDER_ERROR_NONE;
3088 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE;
3089 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3091 if (!pc || !pc->cb_info) {
3092 LOGE("NULL handle");
3093 return RECORDER_ERROR_INVALID_PARAMETER;
3096 if (device == NULL) {
3097 LOGE("NULL pointer device");
3098 return RECORDER_ERROR_INVALID_PARAMETER;
3103 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3105 if (ret == RECORDER_ERROR_NONE)
3106 *device = (recorder_audio_device_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE];
3108 LOGD("ret : 0x%x, device %d", ret, *device);
3114 int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate)
3116 int ret = RECORDER_ERROR_NONE;
3117 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE;
3118 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3120 if (!pc || !pc->cb_info) {
3121 LOGE("NULL handle");
3122 return RECORDER_ERROR_INVALID_PARAMETER;
3125 if (samplerate == NULL) {
3126 LOGE("NULL pointer handle");
3127 return RECORDER_ERROR_INVALID_PARAMETER;
3132 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3134 if (ret == RECORDER_ERROR_NONE)
3135 *samplerate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE];
3137 LOGD("ret : 0x%x, samplerate %d", ret, *samplerate);
3143 int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate)
3145 int ret = RECORDER_ERROR_NONE;
3146 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE;
3147 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3149 if (!pc || !pc->cb_info) {
3150 LOGE("NULL handle");
3151 return RECORDER_ERROR_INVALID_PARAMETER;
3154 if (bitrate == NULL) {
3155 LOGE("NULL pointer");
3156 return RECORDER_ERROR_INVALID_PARAMETER;
3161 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3163 if (ret == RECORDER_ERROR_NONE)
3164 *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE];
3166 LOGD("ret : 0x%x, bitrate %d", ret, *bitrate);
3172 int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate)
3174 int ret = RECORDER_ERROR_NONE;
3175 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE;
3176 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3178 if (!pc || !pc->cb_info) {
3179 LOGE("NULL handle");
3180 return RECORDER_ERROR_INVALID_PARAMETER;
3183 if (bitrate == NULL) {
3184 LOGE("NULL pointer");
3185 return RECORDER_ERROR_INVALID_PARAMETER;
3190 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3192 if (ret == RECORDER_ERROR_NONE)
3193 *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE];
3195 LOGD("ret : 0x%x", ret);
3201 int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb, void *user_data)
3203 int ret = RECORDER_ERROR_NONE;
3204 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3205 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_AUDIO_ENCODER;
3207 if (!pc || !pc->cb_info || foreach_cb == NULL) {
3208 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
3209 return RECORDER_ERROR_INVALID_PARAMETER;
3212 LOGD("Enter, handle :%td", pc->remote_handle);
3214 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = foreach_cb;
3215 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = user_data;
3217 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3219 LOGD("ret : 0x%x", ret);
3225 int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb, void *user_data)
3227 int ret = RECORDER_ERROR_NONE;
3228 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3229 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_ENCODER;
3231 if (!pc || !pc->cb_info || foreach_cb == NULL) {
3232 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
3233 return RECORDER_ERROR_INVALID_PARAMETER;
3236 LOGD("Enter, handle :%td", pc->remote_handle);
3238 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = foreach_cb;
3239 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = user_data;
3241 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3243 LOGD("ret : 0x%x", ret);
3249 int recorder_attr_set_mute(recorder_h recorder, bool enable)
3251 int ret = RECORDER_ERROR_NONE;
3252 int set_enable = (int)enable;
3253 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_MUTE;
3254 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3255 recorder_msg_param param;
3257 if (!pc || !pc->cb_info) {
3258 LOGE("NULL handle");
3259 return RECORDER_ERROR_INVALID_PARAMETER;
3264 RECORDER_MSG_PARAM_SET(param, INT, set_enable);
3266 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3268 LOGD("ret : 0x%x", ret);
3274 bool recorder_attr_is_muted(recorder_h recorder)
3277 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_IS_MUTED;
3278 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3280 if (!pc || !pc->cb_info) {
3281 LOGE("NULL handle");
3287 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3289 if (ret == RECORDER_ERROR_SERVICE_DISCONNECTED)
3292 LOGD("ret : %d", ret);
3298 int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate)
3300 int ret = RECORDER_ERROR_NONE;
3301 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_RECORDING_MOTION_RATE;
3302 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3303 recorder_msg_param param;
3305 if (!pc || !pc->cb_info) {
3306 LOGE("NULL handle");
3307 return RECORDER_ERROR_INVALID_PARAMETER;
3310 LOGD("ENTER - %.20lf", rate);
3312 RECORDER_MSG_PARAM_SET(param, DOUBLE, rate);
3314 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3316 LOGD("ret : 0x%x", ret);
3322 int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate)
3324 int ret = RECORDER_ERROR_NONE;
3325 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE;
3326 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3328 if (!pc || !pc->cb_info) {
3329 LOGE("NULL handle");
3330 return RECORDER_ERROR_INVALID_PARAMETER;
3334 LOGE("rate is NULL");
3335 return RECORDER_ERROR_INVALID_PARAMETER;
3340 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3341 if (ret == RECORDER_ERROR_NONE)
3342 *rate = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE];
3344 LOGD("ret : 0x%x - rate %.20lf", ret, *rate);
3350 int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count)
3352 int ret = RECORDER_ERROR_NONE;
3353 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_CHANNEL;
3354 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3355 recorder_msg_param param;
3357 if (!pc || !pc->cb_info) {
3358 LOGE("NULL handle");
3359 return RECORDER_ERROR_INVALID_PARAMETER;
3364 RECORDER_MSG_PARAM_SET(param, INT, channel_count);
3366 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3368 LOGD("ret : 0x%x", ret);
3374 int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count)
3376 int ret = RECORDER_ERROR_NONE;
3377 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL;
3378 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3380 if (!pc || !pc->cb_info) {
3381 LOGE("NULL handle");
3382 return RECORDER_ERROR_INVALID_PARAMETER;
3385 if (channel_count == NULL) {
3386 LOGE("channel_count is NULL");
3387 return RECORDER_ERROR_INVALID_PARAMETER;
3392 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3394 if (ret == RECORDER_ERROR_NONE)
3395 *channel_count = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL];
3397 LOGD("ret : 0x%x, channel count %d", ret, *channel_count);
3403 int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation)
3405 int ret = RECORDER_ERROR_NONE;
3406 int set_orientation = (int)orientation;
3407 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_ORIENTATION_TAG;
3408 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3409 recorder_msg_param param;
3411 if (!pc || !pc->cb_info) {
3412 LOGE("NULL handle");
3413 return RECORDER_ERROR_INVALID_PARAMETER;
3418 RECORDER_MSG_PARAM_SET(param, INT, set_orientation);
3420 _recorder_msg_send_param1(api, pc->cb_info, &ret, ¶m);
3422 LOGD("ret : 0x%x", ret);
3428 int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation)
3430 int ret = RECORDER_ERROR_NONE;
3431 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG;
3432 recorder_cli_s *pc = (recorder_cli_s *)recorder;
3434 if (!pc || !pc->cb_info) {
3435 LOGE("NULL handle");
3436 return RECORDER_ERROR_INVALID_PARAMETER;
3439 if (orientation == NULL) {
3440 LOGE("orientation is NULL");
3441 return RECORDER_ERROR_INVALID_PARAMETER;
3446 _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
3448 if (ret == RECORDER_ERROR_NONE)
3449 *orientation = (recorder_rotation_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG];
3451 LOGD("ret : 0x%x, orientation %d", ret, *orientation);
3457 int recorder_get_device_state(recorder_type_e type, recorder_device_state_e *state)
3459 int ret = RECORDER_ERROR_NONE;
3461 int get_device_state = 0;
3462 char *send_msg = NULL;
3463 char recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH] = {'\0',};
3466 LOGE("NULL pointer");
3467 return RECORDER_ERROR_INVALID_PARAMETER;
3470 LOGD("Enter - type %d", type);
3472 sock_fd = muse_client_new();
3475 LOGE("muse_client_new failed - returned fd %d", sock_fd);
3476 ret = RECORDER_ERROR_INVALID_OPERATION;
3477 goto _GET_DEVICE_STATE_EXIT;
3481 send_msg = muse_core_msg_new(MUSE_RECORDER_API_GET_DEVICE_STATE,
3482 MUSE_TYPE_INT, "module", MUSE_RECORDER,
3483 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, type,
3488 ret = RECORDER_ERROR_OUT_OF_MEMORY;
3489 goto _GET_DEVICE_STATE_EXIT;
3493 LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
3495 ret = muse_core_msg_send(sock_fd, send_msg);
3497 muse_core_msg_free(send_msg);
3502 LOGE("send msg failed %d", errno);
3503 ret = RECORDER_ERROR_INVALID_OPERATION;
3504 goto _GET_DEVICE_STATE_EXIT;
3508 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_RECORDER_MSG_MAX_LENGTH);
3511 LOGE("recv msg failed %d", errno);
3512 ret = RECORDER_ERROR_INVALID_OPERATION;
3513 goto _GET_DEVICE_STATE_EXIT;
3517 if (!muse_recorder_msg_get(ret, recv_msg)) {
3519 LOGE("failed to get return value from msg [%s]", recv_msg);
3520 ret = RECORDER_ERROR_INVALID_OPERATION;
3521 goto _GET_DEVICE_STATE_EXIT;
3525 if (ret == RECORDER_ERROR_NONE) {
3526 if (muse_recorder_msg_get(get_device_state, recv_msg)) {
3527 *state = (recorder_device_state_e)get_device_state;
3528 LOGD("device type %d state %d", type, *state);
3530 LOGE("failed to get device state from msg [%s]", recv_msg);
3531 ret = RECORDER_ERROR_INVALID_OPERATION;
3534 LOGE("failed 0x%x", ret);
3537 _GET_DEVICE_STATE_EXIT:
3539 muse_client_close(sock_fd);
3547 int recorder_add_device_state_changed_cb(recorder_device_state_changed_cb callback, void *user_data, int *cb_id)
3549 int ret = RECORDER_ERROR_NONE;
3550 recorder_device_state_e state = RECORDER_DEVICE_STATE_IDLE;
3551 recorder_cb_info *info = NULL;
3553 if (!callback || !cb_id) {
3554 LOGE("invalid pointer %p %p", callback, cb_id);
3555 return RECORDER_ERROR_INVALID_PARAMETER;
3558 g_mutex_lock(&g_rec_dev_state_changed_cb_lock);
3560 /* check recorder support */
3561 ret = recorder_get_device_state(RECORDER_TYPE_AUDIO, &state);
3562 if (ret != RECORDER_ERROR_NONE) {
3563 LOGE("get device state failed");
3564 g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
3568 info = g_new0(recorder_cb_info, 1);
3570 LOGE("info failed");
3571 ret = RECORDER_ERROR_OUT_OF_MEMORY;
3575 info->id = ++g_rec_dev_state_changed_cb_id;
3576 info->callback = (void *)callback;
3577 info->user_data = user_data;
3581 /* subscribe dbus signal for camera state change */
3582 if (!g_rec_dev_state_changed_cb_conn) {
3583 g_rec_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
3584 if (!g_rec_dev_state_changed_cb_conn) {
3585 LOGE("failed to get gdbus connection");
3586 ret = RECORDER_ERROR_INVALID_OPERATION;
3590 LOGD("subscribe signal %s - %s - %s",
3591 MM_CAMCORDER_DBUS_OBJECT,
3592 MM_CAMCORDER_DBUS_INTERFACE_RECORDER,
3593 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
3595 g_rec_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_rec_dev_state_changed_cb_conn,
3596 NULL, MM_CAMCORDER_DBUS_INTERFACE_RECORDER, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
3597 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__recorder_device_state_changed_cb, NULL, NULL);
3598 if (!g_rec_dev_state_changed_cb_subscribe_id) {
3599 LOGE("failed to get gdbus connection");
3600 ret = RECORDER_ERROR_INVALID_OPERATION;
3604 LOGD("signal subscribe id %u", g_rec_dev_state_changed_cb_subscribe_id);
3607 g_rec_dev_state_changed_cb_list = g_list_prepend(g_rec_dev_state_changed_cb_list, (gpointer)info);
3609 LOGD("callback id %d", info->id);
3612 if (ret != RECORDER_ERROR_NONE) {
3619 if (g_rec_dev_state_changed_cb_conn) {
3620 g_object_unref(g_rec_dev_state_changed_cb_conn);
3621 g_rec_dev_state_changed_cb_conn = NULL;
3626 g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);
3632 int recorder_remove_device_state_changed_cb(int cb_id)
3634 int ret = RECORDER_ERROR_NONE;
3635 recorder_device_state_e state = RECORDER_DEVICE_STATE_IDLE;
3636 GList *tmp_list = NULL;
3637 recorder_cb_info *info = NULL;
3639 /* check recorder support */
3640 ret = recorder_get_device_state(RECORDER_TYPE_AUDIO, &state);
3641 if (ret != RECORDER_ERROR_NONE) {
3642 LOGE("get device state failed");
3646 g_mutex_lock(&g_rec_dev_state_changed_cb_lock);
3648 if (!g_rec_dev_state_changed_cb_list) {
3649 LOGE("there is no callback info");
3650 ret = RECORDER_ERROR_INVALID_OPERATION;
3654 tmp_list = g_rec_dev_state_changed_cb_list;
3657 info = tmp_list->data;
3658 tmp_list = tmp_list->next;
3665 if (info->id == cb_id) {
3666 g_rec_dev_state_changed_cb_list = g_list_remove(g_rec_dev_state_changed_cb_list, info);
3671 if (!g_rec_dev_state_changed_cb_list) {
3672 /* no remained callback */
3673 if (g_rec_dev_state_changed_cb_conn) {
3674 /* unsubscribe signal */
3675 g_dbus_connection_signal_unsubscribe(g_rec_dev_state_changed_cb_conn, g_rec_dev_state_changed_cb_subscribe_id);
3676 g_rec_dev_state_changed_cb_subscribe_id = 0;
3678 /* unref connection */
3679 g_object_unref(g_rec_dev_state_changed_cb_conn);
3680 g_rec_dev_state_changed_cb_conn = NULL;
3684 LOGD("id %d callback removed", cb_id);
3685 ret = RECORDER_ERROR_NONE;
3691 LOGE("id %d callback not found", cb_id);
3692 ret = RECORDER_ERROR_INVALID_PARAMETER;
3695 g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);