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.
21 #include <sound_manager.h>
22 #include <sound_manager_internal.h>
24 #include <muse_recorder.h>
25 #include <muse_recorder_msg.h>
26 #include <muse_core_ipc.h>
27 #include <muse_core_module.h>
28 #include <recorder_private.h>
35 #define LOG_TAG "TIZEN_N_RECORDER"
38 static int _recorder_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
41 tbm_bo_handle tmp_bo_handle = {NULL, };
43 if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
44 LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
45 bufmgr, bo, bo_handle, tbm_key);
49 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
51 LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
55 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
56 if (tmp_bo_handle.ptr == NULL) {
57 LOGE("bo map failed %p", tmp_bo);
63 /* set bo and bo_handle */
65 *bo_handle = tmp_bo_handle;
70 static void _recorder_release_imported_bo(tbm_bo *bo)
72 if (bo == NULL || *bo == NULL) {
84 static void _client_user_callback(recorder_cb_info_s *cb_info, char *recv_msg, muse_recorder_event_e event)
86 if (recv_msg == NULL || event >= MUSE_RECORDER_EVENT_TYPE_NUM) {
87 LOGE("invalid parameter - recorder msg %p, event %d", recv_msg, event);
91 LOGD("get recorder msg %s, event %d", recv_msg, event);
93 if (cb_info->user_cb[event] == NULL) {
94 LOGW("user callback for event %d is not set", event);
99 case MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE:
105 muse_recorder_msg_get(previous, recv_msg);
106 muse_recorder_msg_get(current, recv_msg);
107 muse_recorder_msg_get(by_policy, recv_msg);
109 ((recorder_state_changed_cb)cb_info->user_cb[event])((recorder_state_e)previous,
110 (recorder_state_e)current,
112 cb_info->user_data[event]);
115 case MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED:
119 muse_recorder_msg_get(type, recv_msg);
121 ((recorder_recording_limit_reached_cb)cb_info->user_cb[event])((recorder_recording_limit_type_e)type,
122 cb_info->user_data[event]);
125 case MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS:
127 int64_t cb_elapsed_time = 0;
128 int64_t cb_file_size = 0;
130 muse_recorder_msg_get(cb_elapsed_time, recv_msg);
131 muse_recorder_msg_get(cb_file_size, recv_msg);
133 ((recorder_recording_status_cb)cb_info->user_cb[event])((unsigned long long)cb_elapsed_time,
134 (unsigned long long)cb_file_size,
135 cb_info->user_data[event]);
138 case MUSE_RECORDER_EVENT_TYPE_INTERRUPTED:
144 muse_recorder_msg_get(policy, recv_msg);
145 muse_recorder_msg_get(previous, recv_msg);
146 muse_recorder_msg_get(current, recv_msg);
148 ((recorder_interrupted_cb)cb_info->user_cb[event])((recorder_policy_e)policy,
149 (recorder_state_e)previous,
150 (recorder_state_e)current,
151 cb_info->user_data[event]);
154 case MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM:
162 tbm_bo_handle bo_handle = {.ptr = NULL};
164 muse_recorder_msg_get(tbm_key, recv_msg);
170 if (!_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
171 LOGE("tbm key %d import failed", tbm_key);
175 muse_recorder_msg_get(size, recv_msg);
176 muse_recorder_msg_get(format, recv_msg);
177 muse_recorder_msg_get(channel, recv_msg);
178 muse_recorder_msg_get(timestamp, recv_msg);
180 ((recorder_audio_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
182 (audio_sample_type_e)format,
184 (unsigned int)timestamp,
185 cb_info->user_data[event]);
187 /* release imported bo */
188 _recorder_release_imported_bo(&bo);
191 muse_recorder_msg_send1_no_return(MUSE_RECORDER_API_RETURN_BUFFER,
192 cb_info->fd, cb_info,
196 case MUSE_RECORDER_EVENT_TYPE_ERROR:
199 int current_state = 0;
201 muse_recorder_msg_get(error, recv_msg);
202 muse_recorder_msg_get(current_state, recv_msg);
204 ((recorder_error_cb)cb_info->user_cb[event])((recorder_error_e)error,
205 (recorder_state_e)current_state,
206 cb_info->user_data[event]);
209 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER:
213 muse_recorder_msg_get(codec, recv_msg);
215 if (((recorder_supported_audio_encoder_cb)cb_info->user_cb[event])((recorder_audio_codec_e)codec, cb_info->user_data[event]) == false) {
216 cb_info->user_cb[event] = NULL;
217 cb_info->user_data[event] = NULL;
218 LOGD("stop foreach callback for SUPPORTED_AUDIO_ENCODER");
222 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT:
226 muse_recorder_msg_get(format, recv_msg);
228 if (((recorder_supported_file_format_cb)cb_info->user_cb[event])((recorder_file_format_e)format, cb_info->user_data[event]) == false) {
229 cb_info->user_cb[event] = NULL;
230 cb_info->user_data[event] = NULL;
231 LOGD("stop foreach callback for SUPPORTED_FILE_FORMAT");
235 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER:
239 muse_recorder_msg_get(codec, recv_msg);
241 if (((recorder_supported_video_encoder_cb)cb_info->user_cb[event])((recorder_video_codec_e)codec, cb_info->user_data[event]) == false) {
242 cb_info->user_cb[event] = NULL;
243 cb_info->user_data[event] = NULL;
244 LOGD("stop foreach callback for SUPPORTED_VIDEO_ENCODER");
248 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION:
253 muse_recorder_msg_get(width, recv_msg);
254 muse_recorder_msg_get(height, recv_msg);
256 if (((recorder_supported_video_resolution_cb)cb_info->user_cb[event])(width, height, cb_info->user_data[event]) == false) {
257 cb_info->user_cb[event] = NULL;
258 cb_info->user_data[event] = NULL;
259 LOGD("stop foreach callback for SUPPORTED_VIDEO_RESOLUTION");
265 LOGE("Unknonw recorder event %d", event);
273 static bool _recorder_idle_event_callback(void *data)
275 recorder_cb_info_s *cb_info = NULL;
276 recorder_idle_event_s *rec_idle_event = (recorder_idle_event_s *)data;
278 if (rec_idle_event == NULL) {
279 LOGE("rec_idle_event is NULL");
284 g_mutex_lock(&rec_idle_event->event_mutex);
286 cb_info = rec_idle_event->cb_info;
287 if (cb_info == NULL) {
288 LOGW("recorder cb_info is NULL. event %d", rec_idle_event->event);
289 goto IDLE_EVENT_CALLBACK_DONE;
292 /* remove event from list */
293 g_mutex_lock(&cb_info->idle_event_mutex);
294 if (cb_info->idle_event_list)
295 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
297 /*LOGD("remove recorder idle event %p, %p", rec_idle_event, cb_info->idle_event_list);*/
298 g_mutex_unlock(&cb_info->idle_event_mutex);
301 _client_user_callback(rec_idle_event->cb_info, rec_idle_event->recv_msg, rec_idle_event->event);
303 /* send signal for waiting thread */
304 g_cond_signal(&cb_info->idle_event_cond);
306 IDLE_EVENT_CALLBACK_DONE:
307 /* unlock and release event */
308 g_mutex_unlock(&rec_idle_event->event_mutex);
309 g_mutex_clear(&rec_idle_event->event_mutex);
311 g_free(rec_idle_event);
312 rec_idle_event = NULL;
318 static void _recorder_remove_idle_event_all(recorder_cb_info_s *cb_info)
320 recorder_idle_event_s *rec_idle_event = NULL;
325 if (cb_info == NULL) {
326 LOGE("cb_info is NULL");
330 g_mutex_lock(&cb_info->idle_event_mutex);
332 if (cb_info->idle_event_list == NULL) {
333 LOGD("No idle event is remained.");
335 list = cb_info->idle_event_list;
338 rec_idle_event = list->data;
339 list = g_list_next(list);
341 if (!rec_idle_event) {
342 LOGW("Fail to remove idle event. The event is NULL");
344 if (g_mutex_trylock(&rec_idle_event->event_mutex)) {
345 ret = g_idle_remove_by_data(rec_idle_event);
347 LOGD("remove idle event [%p], ret[%d]", rec_idle_event, ret);
350 rec_idle_event->cb_info = NULL;
351 LOGW("idle callback for event %p will be called later", rec_idle_event);
354 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
356 g_mutex_unlock(&rec_idle_event->event_mutex);
359 g_mutex_clear(&rec_idle_event->event_mutex);
361 g_free(rec_idle_event);
362 rec_idle_event = NULL;
364 LOGD("remove idle event done");
367 LOGW("event lock failed. it's being called...");
369 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
371 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
372 LOGW("signal received");
379 g_list_free(cb_info->idle_event_list);
380 cb_info->idle_event_list = NULL;
383 g_mutex_unlock(&cb_info->idle_event_mutex);
389 static void *_recorder_msg_handler_func(gpointer data)
395 recorder_message_s *rec_msg = NULL;
396 recorder_idle_event_s *rec_idle_event = NULL;
397 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
399 if (cb_info == NULL) {
400 LOGE("cb_info NULL");
406 g_mutex_lock(&cb_info->msg_handler_mutex);
408 while (g_atomic_int_get(&cb_info->msg_handler_running)) {
409 if (g_queue_is_empty(cb_info->msg_queue)) {
410 LOGD("signal wait...");
411 g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
412 LOGD("signal received");
414 if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
415 LOGD("stop event thread");
420 rec_msg = (recorder_message_s *)g_queue_pop_head(cb_info->msg_queue);
421 g_mutex_unlock(&cb_info->msg_handler_mutex);
422 if (rec_msg == NULL) {
423 LOGE("NULL message");
424 g_mutex_lock(&cb_info->msg_handler_mutex);
428 if (api < MUSE_RECORDER_API_MAX) {
429 g_mutex_lock(&cb_info->api_mutex[api]);
430 if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
431 cb_info->api_ret[api] = ret;
432 cb_info->api_activating[api] = 1;
434 LOGD("recorder api %d - return 0x%x", ret);
436 g_cond_signal(&cb_info->api_cond[api]);
438 LOGE("failed to get ret for api %d, msg %s", rec_msg->api, rec_msg->recv_msg);
441 g_mutex_unlock(&cb_info->api_mutex[api]);
442 } else if (api == MUSE_RECORDER_CB_EVENT) {
446 if (!muse_recorder_msg_get(event, rec_msg->recv_msg) ||
447 !muse_recorder_msg_get(event_class, rec_msg->recv_msg)) {
448 LOGE("failed to get recorder event %d, class %d", event, event_class);
453 g_mutex_lock(&cb_info->msg_handler_mutex);
457 switch (event_class) {
458 case MUSE_RECORDER_EVENT_CLASS_THREAD_SUB:
459 _client_user_callback(cb_info, rec_msg->recv_msg, event);
461 case MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN:
462 rec_idle_event = g_new0(recorder_idle_event_s, 1);
463 if (rec_idle_event == NULL) {
464 LOGE("rec_idle_event alloc failed");
468 rec_idle_event->event = event;
469 rec_idle_event->cb_info = cb_info;
470 g_mutex_init(&rec_idle_event->event_mutex);
471 memcpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg));
473 LOGD("add recorder event[%d, %p] to IDLE", event, rec_idle_event);
475 g_mutex_lock(&cb_info->idle_event_mutex);
476 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)rec_idle_event);
477 g_mutex_unlock(&cb_info->idle_event_mutex);
479 g_idle_add_full(G_PRIORITY_DEFAULT,
480 (GSourceFunc)_recorder_idle_event_callback,
481 (gpointer)rec_idle_event,
485 LOGE("unknown recorder event class %d", event_class);
489 LOGE("unknown recorder api[%d] message", api);
495 g_mutex_lock(&cb_info->msg_handler_mutex);
498 /* remove remained event */
499 while (!g_queue_is_empty(cb_info->msg_queue)) {
500 rec_msg = (recorder_message_s *)g_queue_pop_head(cb_info->msg_queue);
502 LOGD("remove recorder message %p", rec_msg);
506 LOGW("NULL recorder message");
510 g_mutex_unlock(&cb_info->msg_handler_mutex);
518 static void *_recorder_msg_recv_func(gpointer data)
527 char *recv_msg = NULL;
528 char **parse_str = NULL;
529 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
531 if (cb_info == NULL) {
532 LOGE("cb_info NULL");
538 parse_str = (char **)malloc(sizeof(char *) * RECORDER_PARSE_STRING_SIZE);
539 if (parse_str == NULL) {
540 LOGE("parse_str malloc failed");
544 for (i = 0 ; i < RECORDER_PARSE_STRING_SIZE ; i++) {
545 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
546 if (parse_str[i] == NULL) {
547 LOGE("parse_str[%d] malloc failed", i);
548 goto CB_HANDLER_EXIT;
552 recv_msg = cb_info->recv_msg;
554 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
555 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
558 recv_msg[ret] = '\0';
564 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
566 /* Need to split the combined entering msgs.
567 This module supports up to 200 combined msgs. */
568 for (str_pos = 0; str_pos < ret; str_pos++) {
569 if (recv_msg[str_pos] == '}') {
570 memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
571 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
572 LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);
573 prev_pos = str_pos+1;
578 /*LOGD("num_token : %d", num_token);*/
580 /* Re-construct to the useful single msg. */
581 for (i = 0; i < num_token; i++) {
582 if (i >= RECORDER_PARSE_STRING_SIZE) {
583 LOGE("invalid token index %d", i);
590 if (!muse_recorder_msg_get(api, parse_str[i])) {
591 LOGE("failed to get recorder api");
595 if (api != MUSE_RECORDER_CB_EVENT) {
596 LOGD("check api_class");
597 if (muse_recorder_msg_get(api_class, parse_str[i]))
598 LOGD("recorder api_class[%d]", api_class);
601 if (api_class == MUSE_RECORDER_API_CLASS_IMMEDIATE) {
602 g_mutex_lock(&cb_info->api_mutex[api]);
604 if (!muse_recorder_msg_get(ret, parse_str[i])) {
605 LOGE("failed to get recorder ret");
606 g_mutex_unlock(&cb_info->api_mutex[api]);
610 cb_info->api_ret[api] = ret;
611 cb_info->api_activating[api] = 1;
613 if (api == MUSE_RECORDER_API_CREATE) {
614 if (ret != RECORDER_ERROR_NONE) {
615 g_atomic_int_set(&cb_info->msg_recv_running, 0);
616 LOGE("recorder create error 0x%x. close client cb handler", ret);
618 } else if (api == MUSE_RECORDER_API_DESTROY) {
619 if (ret == RECORDER_ERROR_NONE) {
620 g_atomic_int_set(&cb_info->msg_recv_running, 0);
621 LOGD("recorder destroy done. close client cb handler");
625 g_cond_signal(&cb_info->api_cond[api]);
626 g_mutex_unlock(&cb_info->api_mutex[api]);
627 } else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB ||
628 api == MUSE_RECORDER_CB_EVENT) {
629 recorder_message_s *rec_msg = g_new0(recorder_message_s, 1);
630 if (rec_msg == NULL) {
631 LOGE("failed to alloc rec_msg");
636 memcpy(rec_msg->recv_msg, parse_str[i], sizeof(rec_msg->recv_msg));
638 LOGD("add recorder message to queue : api %d", api);
640 g_mutex_lock(&cb_info->msg_handler_mutex);
641 g_queue_push_tail(cb_info->msg_queue, (gpointer)rec_msg);
642 g_cond_signal(&cb_info->msg_handler_cond);
643 g_mutex_unlock(&cb_info->msg_handler_mutex);
645 LOGW("unknown recorder api %d and api_class %d", api, api_class);
650 LOGD("client cb exit");
654 for (i = 0 ; i < RECORDER_PARSE_STRING_SIZE ; i++) {
668 static recorder_cb_info_s *_client_callback_new(gint sockfd)
670 recorder_cb_info_s *cb_info = NULL;
671 gint *tmp_activating = NULL;
672 gint *tmp_ret = NULL;
675 g_return_val_if_fail(sockfd > 0, NULL);
677 cb_info = g_new0(recorder_cb_info_s, 1);
678 if (cb_info == NULL) {
679 LOGE("cb_info failed");
683 g_mutex_init(&cb_info->msg_handler_mutex);
684 g_cond_init(&cb_info->msg_handler_cond);
685 g_mutex_init(&cb_info->idle_event_mutex);
686 g_cond_init(&cb_info->idle_event_cond);
688 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
689 g_mutex_init(&cb_info->api_mutex[i]);
690 g_cond_init(&cb_info->api_cond[i]);
693 tmp_activating = g_new0(gint, MUSE_RECORDER_API_MAX);
694 if (tmp_activating == NULL) {
695 LOGE("tmp_activating failed");
699 tmp_ret = g_new0(gint, MUSE_RECORDER_API_MAX);
700 if (tmp_ret == NULL) {
701 LOGE("tmp_ret failed");
705 cb_info->msg_queue = g_queue_new();
706 if (cb_info->msg_queue == NULL) {
707 LOGE("msg_queue new failed");
711 g_atomic_int_set(&cb_info->msg_handler_running, 1);
712 cb_info->msg_handler_thread = g_thread_try_new("recorder_msg_handler",
713 _recorder_msg_handler_func,
716 if (cb_info->msg_handler_thread == NULL) {
717 LOGE("message handler thread creation failed");
721 cb_info->fd = sockfd;
722 cb_info->api_activating = tmp_activating;
723 cb_info->api_ret = tmp_ret;
725 g_atomic_int_set(&cb_info->msg_recv_running, 1);
726 cb_info->msg_recv_thread = g_thread_try_new("recorder_msg_recv",
727 _recorder_msg_recv_func,
730 if (cb_info->msg_recv_thread == NULL) {
731 LOGE("message receive thread creation failed");
740 if (cb_info->msg_handler_thread) {
741 g_mutex_lock(&cb_info->msg_handler_mutex);
742 g_atomic_int_set(&cb_info->msg_handler_running, 0);
743 g_cond_signal(&cb_info->msg_handler_cond);
744 g_mutex_unlock(&cb_info->msg_handler_mutex);
746 g_thread_join(cb_info->msg_handler_thread);
747 g_thread_unref(cb_info->msg_handler_thread);
748 cb_info->msg_handler_thread = NULL;
751 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
752 g_mutex_clear(&cb_info->api_mutex[i]);
753 g_cond_clear(&cb_info->api_cond[i]);
756 g_mutex_clear(&cb_info->msg_handler_mutex);
757 g_cond_clear(&cb_info->msg_handler_cond);
758 g_mutex_clear(&cb_info->idle_event_mutex);
759 g_cond_clear(&cb_info->idle_event_cond);
761 if (cb_info->msg_queue) {
762 g_queue_free(cb_info->msg_queue);
763 cb_info->msg_queue = NULL;
770 if (tmp_activating) {
771 g_free(tmp_activating);
772 tmp_activating = NULL;
782 static int client_wait_for_cb_return(muse_recorder_api_e api, recorder_cb_info_s *cb_info, int time_out)
784 int ret = RECORDER_ERROR_NONE;
787 LOGD("Enter api : %d", api);
789 g_mutex_lock(&(cb_info->api_mutex[api]));
791 if (cb_info->api_activating[api] == 0) {
792 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
793 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
794 ret = cb_info->api_ret[api];
795 cb_info->api_activating[api] = 0;
797 LOGD("return value : 0x%x", ret);
799 ret = RECORDER_ERROR_INVALID_OPERATION;
801 LOGE("api %d was TIMED OUT!", api);
804 ret = cb_info->api_ret[api];
805 cb_info->api_activating[api] = 0;
807 LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);
810 g_mutex_unlock(&(cb_info->api_mutex[api]));
815 static void _client_callback_destroy(recorder_cb_info_s *cb_info)
819 g_return_if_fail(cb_info != NULL);
821 LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
823 g_thread_join(cb_info->msg_recv_thread);
824 g_thread_unref(cb_info->msg_recv_thread);
825 cb_info->msg_recv_thread = NULL;
827 LOGD("msg thread removed");
829 g_mutex_lock(&cb_info->msg_handler_mutex);
830 g_atomic_int_set(&cb_info->msg_handler_running, 0);
831 g_cond_signal(&cb_info->msg_handler_cond);
832 g_mutex_unlock(&cb_info->msg_handler_mutex);
834 g_thread_join(cb_info->msg_handler_thread);
835 g_thread_unref(cb_info->msg_handler_thread);
836 cb_info->msg_handler_thread = NULL;
838 g_queue_free(cb_info->msg_queue);
839 cb_info->msg_queue = NULL;
840 g_mutex_clear(&cb_info->msg_handler_mutex);
841 g_cond_clear(&cb_info->msg_handler_cond);
842 g_mutex_clear(&cb_info->idle_event_mutex);
843 g_cond_clear(&cb_info->idle_event_cond);
845 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
846 g_mutex_clear(&cb_info->api_mutex[i]);
847 g_cond_clear(&cb_info->api_cond[i]);
850 LOGD("event thread removed");
852 if (cb_info->fd > -1) {
853 muse_core_connection_close(cb_info->fd);
857 if (cb_info->bufmgr) {
858 tbm_bufmgr_deinit(cb_info->bufmgr);
859 cb_info->bufmgr = NULL;
861 if (cb_info->api_activating) {
862 g_free(cb_info->api_activating);
863 cb_info->api_activating = NULL;
865 if (cb_info->api_ret) {
866 g_free(cb_info->api_ret);
867 cb_info->api_ret = NULL;
876 static int _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
878 char **root_directory = (char **)user_data;
880 if (root_directory == NULL) {
881 LOGE("user data is NULL");
885 LOGD("storage id %d, type %d, state %d, path %s",
886 storage_id, type, state, path ? path : "NULL");
888 if (type == STORAGE_TYPE_INTERNAL && path) {
889 if (*root_directory) {
890 free(*root_directory);
891 *root_directory = NULL;
894 *root_directory = strdup(path);
895 if (*root_directory) {
896 LOGD("get root directory %s", *root_directory);
899 LOGE("strdup %s failed");
906 static int _client_get_root_directory(char **root_directory)
908 int ret = STORAGE_ERROR_NONE;
910 if (root_directory == NULL) {
911 LOGE("user data is NULL");
915 ret = storage_foreach_device_supported((storage_device_supported_cb)_recorder_storage_device_supported_cb, root_directory);
916 if (ret != STORAGE_ERROR_NONE) {
917 LOGE("storage_foreach_device_supported failed 0x%x", ret);
924 static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e type, camera_h camera)
926 int ret = RECORDER_ERROR_NONE;
927 int destroy_ret = RECORDER_ERROR_NONE;
929 char *send_msg = NULL;
930 char *root_directory = NULL;
931 intptr_t camera_handle = 0;
933 tbm_bufmgr bufmgr = NULL;
934 recorder_cli_s *pc = NULL;
936 LOGD("Enter - type %d", type);
938 if (recorder == NULL) {
939 LOGE("NULL pointer for recorder handle");
940 return RECORDER_ERROR_INVALID_PARAMETER;
943 if (type == MUSE_RECORDER_TYPE_VIDEO && camera == NULL) {
944 LOGE("NULL pointer for camera handle on video recorder mode");
945 return RECORDER_ERROR_INVALID_PARAMETER;
948 bufmgr = tbm_bufmgr_init(-1);
949 if (bufmgr == NULL) {
950 LOGE("get tbm bufmgr failed");
951 return RECORDER_ERROR_INVALID_OPERATION;
954 pc = g_new0(recorder_cli_s, 1);
956 ret = RECORDER_ERROR_OUT_OF_MEMORY;
957 goto _ERR_RECORDER_EXIT;
960 sock_fd = muse_core_client_new();
962 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
963 ret = RECORDER_ERROR_INVALID_OPERATION;
964 goto _ERR_RECORDER_EXIT;
967 if (type == MUSE_RECORDER_TYPE_AUDIO) {
968 send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
969 MUSE_TYPE_INT, "module", MUSE_RECORDER,
970 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_AUDIO,
971 MUSE_TYPE_INT, "pid", getpid(),
974 camera_handle = (intptr_t)((camera_cli_s *)camera)->remote_handle;
975 send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
976 MUSE_TYPE_INT, "module", MUSE_RECORDER,
977 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_VIDEO,
978 MUSE_TYPE_POINTER, "camera_handle", camera_handle,
982 LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
984 muse_core_ipc_send_msg(sock_fd, send_msg);
985 muse_core_msg_json_factory_free(send_msg);
987 pc->cb_info = _client_callback_new(sock_fd);
988 if (pc->cb_info == NULL) {
989 ret = RECORDER_ERROR_OUT_OF_MEMORY;
990 goto _ERR_RECORDER_EXIT;
993 ret = client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CALLBACK_TIME_OUT);
994 if (ret == RECORDER_ERROR_NONE) {
995 muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
997 LOGE("Receiving Handle Failed!!");
998 goto _ERR_RECORDER_EXIT;
1001 if (!_client_get_root_directory(&root_directory) || root_directory == NULL) {
1002 LOGE("failed to get root directory of internal storage");
1003 ret = RECORDER_ERROR_INVALID_OPERATION;
1004 goto _ERR_RECORDER_AFTER_CREATE;
1007 LOGD("set root directory [%s]", root_directory);
1009 muse_recorder_msg_send1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY,
1010 sock_fd, pc->cb_info, ret, STRING, root_directory);
1011 if (ret != RECORDER_ERROR_NONE) {
1012 LOGE("failed to set root directory %s", root_directory);
1013 ret = RECORDER_ERROR_INVALID_OPERATION;
1014 goto _ERR_RECORDER_AFTER_CREATE;
1017 free(root_directory);
1018 root_directory = NULL;
1020 pc->remote_handle = handle;
1021 pc->cb_info->bufmgr = bufmgr;
1023 LOGD("recorder[type %d] %p create success : remote handle 0x%x",
1024 type, pc, pc->remote_handle);
1026 *recorder = (recorder_h) pc;
1028 goto _ERR_RECORDER_EXIT;
1033 return RECORDER_ERROR_NONE;
1035 _ERR_RECORDER_AFTER_CREATE:
1036 muse_recorder_msg_send(MUSE_RECORDER_API_DESTROY, sock_fd, pc->cb_info, destroy_ret);
1037 LOGE("destroy return 0x%x", destroy_ret);
1040 tbm_bufmgr_deinit(bufmgr);
1043 if (root_directory) {
1044 free(root_directory);
1045 root_directory = NULL;
1050 _client_callback_destroy(pc->cb_info);
1060 int recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
1062 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_VIDEO, camera);
1066 int recorder_create_audiorecorder(recorder_h *recorder)
1068 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_AUDIO, NULL);
1071 int recorder_get_state(recorder_h recorder, recorder_state_e *state)
1073 if (recorder == NULL) {
1074 LOGE("NULL pointer handle");
1075 return RECORDER_ERROR_INVALID_PARAMETER;
1077 if (state == NULL) {
1078 LOGE("NULL pointer state");
1079 return RECORDER_ERROR_INVALID_PARAMETER;
1082 int ret = RECORDER_ERROR_NONE;
1084 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1085 muse_recorder_api_e api = MUSE_RECORDER_API_GET_STATE;
1087 if (pc->cb_info == NULL) {
1088 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1089 return RECORDER_ERROR_INVALID_PARAMETER;
1091 sock_fd = pc->cb_info->fd;
1094 LOGD("Enter, remote_handle : %x", pc->remote_handle);
1096 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1098 if (ret == RECORDER_ERROR_NONE) {
1099 muse_recorder_msg_get(get_state, pc->cb_info->recv_msg);
1100 *state = (recorder_state_e)get_state;
1103 LOGD("ret : 0x%x, get_state : %d", ret, get_state);
1109 int recorder_destroy(recorder_h recorder)
1111 if (recorder == NULL) {
1112 LOGE("NULL pointer handle");
1113 return RECORDER_ERROR_INVALID_PARAMETER;
1115 int ret = RECORDER_ERROR_NONE;
1116 muse_recorder_api_e api = MUSE_RECORDER_API_DESTROY;
1117 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1120 if (pc->cb_info == NULL) {
1121 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1122 return RECORDER_ERROR_INVALID_PARAMETER;
1125 sock_fd = pc->cb_info->fd;
1129 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1130 if (ret == RECORDER_ERROR_NONE) {
1131 _recorder_remove_idle_event_all(pc->cb_info);
1132 _client_callback_destroy(pc->cb_info);
1137 LOGD("ret : 0x%x", ret);
1143 int recorder_prepare(recorder_h recorder)
1145 if (recorder == NULL) {
1146 LOGE("NULL pointer handle");
1147 return RECORDER_ERROR_INVALID_PARAMETER;
1150 int ret = RECORDER_ERROR_NONE;
1151 muse_recorder_api_e api = MUSE_RECORDER_API_PREPARE;
1152 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1154 if (pc->cb_info == NULL) {
1155 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1156 return RECORDER_ERROR_INVALID_PARAMETER;
1158 sock_fd = pc->cb_info->fd;
1162 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1164 LOGD("ret : 0x%x", ret);
1170 int recorder_unprepare(recorder_h recorder)
1172 if (recorder == NULL) {
1173 LOGE("NULL pointer handle");
1174 return RECORDER_ERROR_INVALID_PARAMETER;
1176 int ret = RECORDER_ERROR_NONE;
1177 muse_recorder_api_e api = MUSE_RECORDER_API_UNPREPARE;
1178 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1180 if (pc->cb_info == NULL) {
1181 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1182 return RECORDER_ERROR_INVALID_PARAMETER;
1184 sock_fd = pc->cb_info->fd;
1188 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1189 LOGD("ret : 0x%x", ret);
1194 int recorder_start(recorder_h recorder)
1196 if (recorder == NULL) {
1197 LOGE("NULL pointer handle");
1198 return RECORDER_ERROR_INVALID_PARAMETER;
1200 int ret = RECORDER_ERROR_NONE;
1201 muse_recorder_api_e api = MUSE_RECORDER_API_START;
1202 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1204 if (pc->cb_info == NULL) {
1205 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1206 return RECORDER_ERROR_INVALID_PARAMETER;
1208 sock_fd = pc->cb_info->fd;
1212 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1213 LOGD("ret : 0x%x", ret);
1218 int recorder_pause(recorder_h recorder)
1220 if (recorder == NULL) {
1221 LOGE("NULL pointer handle");
1222 return RECORDER_ERROR_INVALID_PARAMETER;
1224 int ret = RECORDER_ERROR_NONE;
1225 muse_recorder_api_e api = MUSE_RECORDER_API_PAUSE;
1226 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1228 if (pc->cb_info == NULL) {
1229 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1230 return RECORDER_ERROR_INVALID_PARAMETER;
1232 sock_fd = pc->cb_info->fd;
1236 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1237 LOGD("ret : 0x%x", ret);
1242 int recorder_commit(recorder_h recorder)
1244 if (recorder == NULL) {
1245 LOGE("NULL pointer handle");
1246 return RECORDER_ERROR_INVALID_PARAMETER;
1248 int ret = RECORDER_ERROR_NONE;
1249 muse_recorder_api_e api = MUSE_RECORDER_API_COMMIT;
1250 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1252 if (pc->cb_info == NULL) {
1253 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1254 return RECORDER_ERROR_INVALID_PARAMETER;
1256 sock_fd = pc->cb_info->fd;
1260 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1261 LOGD("ret : 0x%x", ret);
1266 int recorder_cancel(recorder_h recorder)
1268 if (recorder == NULL) {
1269 LOGE("NULL pointer handle");
1270 return RECORDER_ERROR_INVALID_PARAMETER;
1272 int ret = RECORDER_ERROR_NONE;
1273 muse_recorder_api_e api = MUSE_RECORDER_API_CANCEL;
1274 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1276 if (pc->cb_info == NULL) {
1277 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1278 return RECORDER_ERROR_INVALID_PARAMETER;
1280 sock_fd = pc->cb_info->fd;
1284 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1285 LOGD("ret : 0x%x", ret);
1290 int recorder_set_video_resolution(recorder_h recorder, int width, int height)
1292 if (recorder == NULL) {
1293 LOGE("NULL pointer handle");
1294 return RECORDER_ERROR_INVALID_PARAMETER;
1296 int ret = RECORDER_ERROR_NONE;
1297 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION;
1298 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1300 if (pc->cb_info == NULL) {
1301 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1302 return RECORDER_ERROR_INVALID_PARAMETER;
1304 sock_fd = pc->cb_info->fd;
1308 muse_recorder_msg_send2(api,
1314 LOGD("ret : 0x%x", ret);
1319 int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
1321 if (recorder == NULL) {
1322 LOGE("NULL pointer handle");
1323 return RECORDER_ERROR_INVALID_PARAMETER;
1325 if (!width || !height) {
1326 LOGE("NULL pointer width = [%p], height = [%p]", width, height);
1327 return RECORDER_ERROR_INVALID_PARAMETER;
1329 int ret = RECORDER_ERROR_NONE;
1330 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_RESOLUTION;
1331 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1333 if (pc->cb_info == NULL) {
1334 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1335 return RECORDER_ERROR_INVALID_PARAMETER;
1337 sock_fd = pc->cb_info->fd;
1343 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1344 if (ret == RECORDER_ERROR_NONE) {
1345 muse_recorder_msg_get(get_width, pc->cb_info->recv_msg);
1346 muse_recorder_msg_get(get_height, pc->cb_info->recv_msg);
1348 *height = get_height;
1350 LOGD("ret : 0x%x", ret);
1355 int recorder_foreach_supported_video_resolution(recorder_h recorder,
1356 recorder_supported_video_resolution_cb foreach_cb, void *user_data)
1358 if (recorder == NULL || foreach_cb == NULL) {
1359 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1360 return RECORDER_ERROR_INVALID_PARAMETER;
1362 int ret = RECORDER_ERROR_NONE;
1364 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1365 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_RESOLUTION;
1367 LOGD("Enter, handle :%x", pc->remote_handle);
1370 if (pc->cb_info == NULL) {
1371 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1372 return RECORDER_ERROR_INVALID_PARAMETER;
1374 sock_fd = pc->cb_info->fd;
1375 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
1376 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
1378 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1379 LOGD("ret : 0x%x", ret);
1384 int recorder_get_audio_level(recorder_h recorder, double *level)
1386 if (recorder == NULL || level == NULL) {
1387 LOGE("NULL pointer %p %p", recorder, level);
1388 return RECORDER_ERROR_INVALID_PARAMETER;
1391 int ret = RECORDER_ERROR_NONE;
1392 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_LEVEL;
1393 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1395 if (pc->cb_info == NULL) {
1396 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1397 return RECORDER_ERROR_INVALID_PARAMETER;
1399 sock_fd = pc->cb_info->fd;
1404 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1405 if (ret == RECORDER_ERROR_NONE) {
1406 muse_recorder_msg_get_double(get_level, pc->cb_info->recv_msg);
1409 LOGD("ret : 0x%x", ret);
1414 int recorder_set_filename(recorder_h recorder, const char *filename)
1416 if (recorder == NULL) {
1417 LOGE("handle is NULL");
1418 return RECORDER_ERROR_INVALID_PARAMETER;
1421 if (filename == NULL) {
1422 LOGE("filename is NULL");
1423 return RECORDER_ERROR_INVALID_PARAMETER;
1425 int ret = RECORDER_ERROR_NONE;
1426 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
1427 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1429 if (pc->cb_info == NULL) {
1430 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1431 return RECORDER_ERROR_INVALID_PARAMETER;
1433 sock_fd = pc->cb_info->fd;
1437 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, filename);
1438 LOGD("ret : 0x%x", ret);
1443 int recorder_get_filename(recorder_h recorder, char **filename)
1445 if (recorder == NULL) {
1446 LOGE("handle is NULL");
1447 return RECORDER_ERROR_INVALID_PARAMETER;
1450 if (filename == NULL) {
1451 LOGE("filename is NULL");
1452 return RECORDER_ERROR_INVALID_PARAMETER;
1454 int ret = RECORDER_ERROR_NONE;
1455 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILENAME;
1456 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1458 if (pc->cb_info == NULL) {
1459 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1460 return RECORDER_ERROR_INVALID_PARAMETER;
1462 sock_fd = pc->cb_info->fd;
1463 char get_filename[MUSE_RECORDER_MSG_MAX_LENGTH] = {0,};
1467 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1469 if (ret == RECORDER_ERROR_NONE) {
1470 muse_recorder_msg_get_string(get_filename, pc->cb_info->recv_msg);
1471 *filename = strdup(get_filename);
1473 LOGD("ret : 0x%x, filename : %s", ret, *filename);
1478 int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
1480 if (recorder == NULL) {
1481 LOGE("NULL pointer handle");
1482 return RECORDER_ERROR_INVALID_PARAMETER;
1484 if (format < RECORDER_FILE_FORMAT_3GP || format > RECORDER_FILE_FORMAT_M2TS) {
1485 LOGE("invalid format %d", format);
1486 return RECORDER_ERROR_INVALID_PARAMETER;
1488 int ret = RECORDER_ERROR_NONE;
1489 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT;
1490 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1492 if (pc->cb_info == NULL) {
1493 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1494 return RECORDER_ERROR_INVALID_PARAMETER;
1496 sock_fd = pc->cb_info->fd;
1497 int set_format = (int)format;
1499 LOGD("ENTER, set_format : %d", set_format);
1501 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
1502 LOGD("ret : 0x%x", ret);
1507 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format)
1509 if (recorder == NULL) {
1510 LOGE("NULL pointer handle");
1511 return RECORDER_ERROR_INVALID_PARAMETER;
1513 if (format == NULL) {
1514 LOGE("NULL pointer data");
1515 return RECORDER_ERROR_INVALID_PARAMETER;
1517 int ret = RECORDER_ERROR_NONE;
1518 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILE_FORMAT;
1519 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1521 if (pc->cb_info == NULL) {
1522 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1523 return RECORDER_ERROR_INVALID_PARAMETER;
1525 sock_fd = pc->cb_info->fd;
1530 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1532 if (ret == RECORDER_ERROR_NONE) {
1533 muse_recorder_msg_get(get_format, pc->cb_info->recv_msg);
1534 LOGD("get_fileformat : %d", get_format);
1535 *format = (recorder_file_format_e)get_format;
1537 LOGD("ret : 0x%x", ret);
1542 int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stream_info)
1544 int ret = RECORDER_ERROR_NONE;
1545 muse_recorder_api_e api = MUSE_RECORDER_API_SET_SOUND_STREAM_INFO;
1546 recorder_cli_s *pc = NULL;
1547 bool is_available = false;
1549 int stream_index = 0;
1550 char *stream_type = NULL;
1552 if (recorder == NULL || stream_info == NULL) {
1553 LOGE("NULL pointer handle");
1554 return RECORDER_ERROR_INVALID_PARAMETER;
1557 pc = (recorder_cli_s *)recorder;
1558 if (pc->cb_info == NULL) {
1559 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1560 return RECORDER_ERROR_INVALID_PARAMETER;
1563 sock_fd = pc->cb_info->fd;
1567 ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_RECORDER, &is_available);
1568 if (ret != SOUND_MANAGER_ERROR_NONE) {
1569 LOGE("stream info verification failed");
1570 return RECORDER_ERROR_INVALID_OPERATION;
1573 if (is_available == false) {
1574 LOGE("stream information is not available");
1575 return RECORDER_ERROR_INVALID_OPERATION;
1578 ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
1579 ret |= sound_manager_get_index_from_stream_information(stream_info, &stream_index);
1581 LOGD("sound manager return [0x%x]", ret);
1583 if (ret == SOUND_MANAGER_ERROR_NONE)
1584 muse_recorder_msg_send2(api, sock_fd, pc->cb_info, ret, STRING, stream_type, INT, stream_index);
1586 ret = RECORDER_ERROR_INVALID_OPERATION;
1592 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data)
1594 if (recorder == NULL || callback == NULL) {
1595 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1596 return RECORDER_ERROR_INVALID_PARAMETER;
1598 int ret = RECORDER_ERROR_NONE;
1600 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1601 muse_recorder_api_e api = MUSE_RECORDER_API_SET_STATE_CHANGED_CB;
1603 LOGD("Enter, handle :%x", pc->remote_handle);
1606 if (pc->cb_info == NULL) {
1607 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1608 return RECORDER_ERROR_INVALID_PARAMETER;
1610 sock_fd = pc->cb_info->fd;
1611 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
1612 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
1614 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1615 LOGD("ret : 0x%x", ret);
1620 int recorder_unset_state_changed_cb(recorder_h recorder)
1622 if (recorder == NULL) {
1623 LOGE("NULL pointer handle");
1624 return RECORDER_ERROR_INVALID_PARAMETER;
1626 int ret = RECORDER_ERROR_NONE;
1627 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB;
1628 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1630 if (pc->cb_info == NULL) {
1631 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1632 return RECORDER_ERROR_INVALID_PARAMETER;
1634 sock_fd = pc->cb_info->fd;
1638 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1639 LOGD("ret : 0x%x", ret);
1644 int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data)
1646 if (recorder == NULL || callback == NULL) {
1647 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1648 return RECORDER_ERROR_INVALID_PARAMETER;
1650 int ret = RECORDER_ERROR_NONE;
1652 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1653 muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB;
1655 LOGD("Enter, handle :%x", pc->remote_handle);
1658 if (pc->cb_info == NULL) {
1659 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1660 return RECORDER_ERROR_INVALID_PARAMETER;
1662 sock_fd = pc->cb_info->fd;
1663 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
1664 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
1666 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1667 LOGD("ret : 0x%x", ret);
1672 int recorder_unset_interrupted_cb(recorder_h recorder)
1674 if (recorder == NULL) {
1675 LOGE("NULL pointer handle");
1676 return RECORDER_ERROR_INVALID_PARAMETER;
1678 int ret = RECORDER_ERROR_NONE;
1679 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB;
1680 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1682 if (pc->cb_info == NULL) {
1683 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1684 return RECORDER_ERROR_INVALID_PARAMETER;
1686 sock_fd = pc->cb_info->fd;
1690 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1691 LOGD("ret : 0x%x", ret);
1696 int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data)
1698 if (recorder == NULL || callback == NULL) {
1699 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1700 return RECORDER_ERROR_INVALID_PARAMETER;
1702 int ret = RECORDER_ERROR_NONE;
1704 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1705 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_STREAM_CB;
1707 LOGD("Enter, handle :%x", pc->remote_handle);
1710 if (pc->cb_info == NULL) {
1711 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1712 return RECORDER_ERROR_INVALID_PARAMETER;
1714 sock_fd = pc->cb_info->fd;
1715 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
1716 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
1718 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1719 LOGD("ret : 0x%x", ret);
1724 int recorder_unset_audio_stream_cb(recorder_h recorder)
1726 if (recorder == NULL) {
1727 LOGE("NULL pointer handle");
1728 return RECORDER_ERROR_INVALID_PARAMETER;
1730 int ret = RECORDER_ERROR_NONE;
1731 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB;
1732 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1734 if (pc->cb_info == NULL) {
1735 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1736 return RECORDER_ERROR_INVALID_PARAMETER;
1738 sock_fd = pc->cb_info->fd;
1742 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1743 LOGD("ret : 0x%x", ret);
1748 int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data)
1750 if (recorder == NULL || callback == NULL) {
1751 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1752 return RECORDER_ERROR_INVALID_PARAMETER;
1754 int ret = RECORDER_ERROR_NONE;
1756 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1757 muse_recorder_api_e api = MUSE_RECORDER_API_SET_ERROR_CB;
1759 LOGD("Enter, handle :%x", pc->remote_handle);
1762 if (pc->cb_info == NULL) {
1763 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1764 return RECORDER_ERROR_INVALID_PARAMETER;
1766 sock_fd = pc->cb_info->fd;
1767 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
1768 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
1770 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1771 LOGD("ret : 0x%x", ret);
1776 int recorder_unset_error_cb(recorder_h recorder)
1778 if (recorder == NULL) {
1779 LOGE("NULL pointer handle");
1780 return RECORDER_ERROR_INVALID_PARAMETER;
1782 int ret = RECORDER_ERROR_NONE;
1783 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_ERROR_CB;
1784 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1786 if (pc->cb_info == NULL) {
1787 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1788 return RECORDER_ERROR_INVALID_PARAMETER;
1790 sock_fd = pc->cb_info->fd;
1794 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1795 LOGD("ret : 0x%x", ret);
1800 int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void* user_data)
1802 if (recorder == NULL || callback == NULL) {
1803 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1804 return RECORDER_ERROR_INVALID_PARAMETER;
1806 int ret = RECORDER_ERROR_NONE;
1808 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1809 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_STATUS_CB;
1811 LOGD("Enter, handle :%x", pc->remote_handle);
1814 if (pc->cb_info == NULL) {
1815 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1816 return RECORDER_ERROR_INVALID_PARAMETER;
1818 sock_fd = pc->cb_info->fd;
1819 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
1820 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
1822 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1823 LOGD("ret : 0x%x", ret);
1828 int recorder_unset_recording_status_cb(recorder_h recorder)
1830 if (recorder == NULL) {
1831 LOGE("NULL pointer handle");
1832 return RECORDER_ERROR_INVALID_PARAMETER;
1834 int ret = RECORDER_ERROR_NONE;
1835 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_STATUS_CB;
1836 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1838 if (pc->cb_info == NULL) {
1839 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1840 return RECORDER_ERROR_INVALID_PARAMETER;
1842 sock_fd = pc->cb_info->fd;
1846 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1847 LOGD("ret : 0x%x", ret);
1852 int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void* user_data)
1854 if (recorder == NULL || callback == NULL) {
1855 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1856 return RECORDER_ERROR_INVALID_PARAMETER;
1858 int ret = RECORDER_ERROR_NONE;
1860 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1861 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_LIMIT_REACHED_CB;
1863 LOGD("Enter, handle :%x", pc->remote_handle);
1866 if (pc->cb_info == NULL) {
1867 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1868 return RECORDER_ERROR_INVALID_PARAMETER;
1870 sock_fd = pc->cb_info->fd;
1871 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
1872 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
1874 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1875 LOGD("ret : 0x%x", ret);
1880 int recorder_unset_recording_limit_reached_cb(recorder_h recorder)
1882 if (recorder == NULL) {
1883 LOGE("NULL pointer handle");
1884 return RECORDER_ERROR_INVALID_PARAMETER;
1886 int ret = RECORDER_ERROR_NONE;
1887 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_LIMIT_REACHED_CB;
1888 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1890 if (pc->cb_info == NULL) {
1891 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1892 return RECORDER_ERROR_INVALID_PARAMETER;
1894 sock_fd = pc->cb_info->fd;
1898 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1899 LOGD("ret : 0x%x", ret);
1904 int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb, void *user_data)
1906 if (recorder == NULL || foreach_cb == NULL) {
1907 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1908 return RECORDER_ERROR_INVALID_PARAMETER;
1910 int ret = RECORDER_ERROR_NONE;
1912 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1913 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_FILE_FORMAT;
1915 LOGD("Enter, handle :%x", pc->remote_handle);
1918 if (pc->cb_info == NULL) {
1919 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1920 return RECORDER_ERROR_INVALID_PARAMETER;
1922 sock_fd = pc->cb_info->fd;
1923 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = foreach_cb;
1924 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = user_data;
1926 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1927 LOGD("ret : 0x%x", ret);
1932 int recorder_attr_set_size_limit(recorder_h recorder, int kbyte)
1934 if (recorder == NULL) {
1935 LOGE("NULL pointer handle");
1936 return RECORDER_ERROR_INVALID_PARAMETER;
1938 int ret = RECORDER_ERROR_NONE;
1939 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_SIZE_LIMIT;
1940 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1942 if (pc->cb_info == NULL) {
1943 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1944 return RECORDER_ERROR_INVALID_PARAMETER;
1946 sock_fd = pc->cb_info->fd;
1950 muse_recorder_msg_send1(api,
1955 LOGD("ret : 0x%x", ret);
1960 int recorder_attr_set_time_limit(recorder_h recorder, int second)
1962 if (recorder == NULL) {
1963 LOGE("NULL pointer handle");
1964 return RECORDER_ERROR_INVALID_PARAMETER;
1966 int ret = RECORDER_ERROR_NONE;
1967 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_TIME_LIMIT;
1968 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1970 if (pc->cb_info == NULL) {
1971 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1972 return RECORDER_ERROR_INVALID_PARAMETER;
1974 sock_fd = pc->cb_info->fd;
1978 muse_recorder_msg_send1(api,
1983 LOGD("ret : 0x%x", ret);
1988 int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device)
1990 if (recorder == NULL) {
1991 LOGE("NULL pointer handle");
1992 return RECORDER_ERROR_INVALID_PARAMETER;
1994 int ret = RECORDER_ERROR_NONE;
1995 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_DEVICE;
1996 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1998 if (pc->cb_info == NULL) {
1999 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2000 return RECORDER_ERROR_INVALID_PARAMETER;
2002 sock_fd = pc->cb_info->fd;
2003 int set_device = (int)device;
2007 muse_recorder_msg_send1(api,
2012 LOGD("ret : 0x%x", ret);
2017 int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec)
2019 if (recorder == NULL) {
2020 LOGE("NULL pointer handle");
2021 return RECORDER_ERROR_INVALID_PARAMETER;
2023 if (codec != RECORDER_AUDIO_CODEC_DISABLE &&
2024 (codec < RECORDER_AUDIO_CODEC_AMR || codec > RECORDER_AUDIO_CODEC_PCM)) {
2025 LOGE("invalid parameter : codec %d", codec);
2026 return RECORDER_ERROR_INVALID_PARAMETER;
2028 int ret = RECORDER_ERROR_NONE;
2029 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_ENCODER;
2030 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2032 if (pc->cb_info == NULL) {
2033 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2034 return RECORDER_ERROR_INVALID_PARAMETER;
2036 sock_fd = pc->cb_info->fd;
2037 int set_codec = (int)codec;
2041 muse_recorder_msg_send1(api,
2046 LOGD("ret : 0x%x", ret);
2051 int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec)
2053 if (recorder == NULL) {
2054 LOGE("NULL pointer handle");
2055 return RECORDER_ERROR_INVALID_PARAMETER;
2057 if (codec == NULL) {
2058 LOGE("codec is NULL");
2059 return RECORDER_ERROR_INVALID_PARAMETER;
2061 int ret = RECORDER_ERROR_NONE;
2062 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_ENCODER;
2063 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2065 if (pc->cb_info == NULL) {
2066 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2067 return RECORDER_ERROR_INVALID_PARAMETER;
2069 sock_fd = pc->cb_info->fd;
2074 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2075 if (ret == RECORDER_ERROR_NONE) {
2076 muse_recorder_msg_get(get_codec, pc->cb_info->recv_msg);
2077 *codec = (recorder_audio_codec_e)get_codec;
2079 LOGD("ret : 0x%x", ret);
2084 int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec)
2086 if (recorder == NULL) {
2087 LOGE("NULL pointer handle");
2088 return RECORDER_ERROR_INVALID_PARAMETER;
2090 if (codec < RECORDER_VIDEO_CODEC_H263 || codec > RECORDER_VIDEO_CODEC_THEORA) {
2091 LOGE("invalid codec %d", codec);
2092 return RECORDER_ERROR_INVALID_PARAMETER;
2094 int ret = RECORDER_ERROR_NONE;
2095 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_ENCODER;
2096 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2098 if (pc->cb_info == NULL) {
2099 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2100 return RECORDER_ERROR_INVALID_PARAMETER;
2102 sock_fd = pc->cb_info->fd;
2103 int set_codec = (int)codec;
2107 muse_recorder_msg_send1(api,
2112 LOGD("ret : 0x%x", ret);
2117 int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec)
2119 if (recorder == NULL) {
2120 LOGE("NULL pointer handle");
2121 return RECORDER_ERROR_INVALID_PARAMETER;
2123 if (codec == NULL) {
2124 LOGE("codec is NULL");
2125 return RECORDER_ERROR_INVALID_PARAMETER;
2127 int ret = RECORDER_ERROR_NONE;
2128 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_ENCODER;
2129 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2131 if (pc->cb_info == NULL) {
2132 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2133 return RECORDER_ERROR_INVALID_PARAMETER;
2135 sock_fd = pc->cb_info->fd;
2140 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2141 if (ret == RECORDER_ERROR_NONE) {
2142 muse_recorder_msg_get(get_codec, pc->cb_info->recv_msg);
2143 *codec = (recorder_audio_codec_e)get_codec;
2145 LOGD("ret : 0x%x", ret);
2150 int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate)
2152 if (recorder == NULL) {
2153 LOGE("NULL pointer handle");
2154 return RECORDER_ERROR_INVALID_PARAMETER;
2156 if (samplerate < 1) {
2157 LOGE("invalid samplerate %d", samplerate);
2158 return RECORDER_ERROR_INVALID_PARAMETER;
2160 int ret = RECORDER_ERROR_NONE;
2161 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_SAMPLERATE;
2162 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2164 if (pc->cb_info == NULL) {
2165 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2166 return RECORDER_ERROR_INVALID_PARAMETER;
2168 sock_fd = pc->cb_info->fd;
2170 LOGD("ENTER, samplerate : %d", samplerate);
2172 muse_recorder_msg_send1(api,
2177 LOGD("ret : 0x%x, samplerate : %d", ret, samplerate);
2182 int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate)
2184 if (recorder == NULL) {
2185 LOGE("NULL pointer handle");
2186 return RECORDER_ERROR_INVALID_PARAMETER;
2189 LOGE("invalid bitrate %d", bitrate);
2190 return RECORDER_ERROR_INVALID_PARAMETER;
2192 int ret = RECORDER_ERROR_NONE;
2193 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_ENCODER_BITRATE;
2194 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2196 if (pc->cb_info == NULL) {
2197 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2198 return RECORDER_ERROR_INVALID_PARAMETER;
2200 sock_fd = pc->cb_info->fd;
2204 muse_recorder_msg_send1(api,
2209 LOGD("ret : 0x%x", ret);
2214 int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate)
2216 if (recorder == NULL) {
2217 LOGE("NULL pointer handle");
2218 return RECORDER_ERROR_INVALID_PARAMETER;
2221 int ret = RECORDER_ERROR_NONE;
2222 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_VIDEO_ENCODER_BITRATE;
2223 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2225 if (pc->cb_info == NULL) {
2226 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2227 return RECORDER_ERROR_INVALID_PARAMETER;
2229 sock_fd = pc->cb_info->fd;
2233 muse_recorder_msg_send1(api,
2238 LOGD("ret : 0x%x", ret);
2243 int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte)
2245 if (recorder == NULL) {
2246 LOGE("NULL pointer handle");
2247 return RECORDER_ERROR_INVALID_PARAMETER;
2249 if (kbyte == NULL) {
2250 LOGE("NULL pointer kbyte");
2251 return RECORDER_ERROR_INVALID_PARAMETER;
2253 int ret = RECORDER_ERROR_NONE;
2254 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT;
2255 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2257 if (pc->cb_info == NULL) {
2258 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2259 return RECORDER_ERROR_INVALID_PARAMETER;
2261 sock_fd = pc->cb_info->fd;
2266 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2267 if (ret == RECORDER_ERROR_NONE) {
2268 muse_recorder_msg_get(get_kbyte, pc->cb_info->recv_msg);
2271 LOGD("ret : 0x%x", ret);
2276 int recorder_attr_get_time_limit(recorder_h recorder, int *second)
2278 if (recorder == NULL) {
2279 LOGE("NULL pointer handle");
2280 return RECORDER_ERROR_INVALID_PARAMETER;
2282 if (second == NULL) {
2283 LOGE("NULL pointer second");
2284 return RECORDER_ERROR_INVALID_PARAMETER;
2286 int ret = RECORDER_ERROR_NONE;
2287 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT;
2288 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2290 if (pc->cb_info == NULL) {
2291 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2292 return RECORDER_ERROR_INVALID_PARAMETER;
2294 sock_fd = pc->cb_info->fd;
2299 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2300 if (ret == RECORDER_ERROR_NONE) {
2301 muse_recorder_msg_get(get_second, pc->cb_info->recv_msg);
2302 *second = get_second;
2304 LOGD("ret : 0x%x", ret);
2309 int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device)
2311 if (recorder == NULL) {
2312 LOGE("NULL pointer handle");
2313 return RECORDER_ERROR_INVALID_PARAMETER;
2315 if (device == NULL) {
2316 LOGE("NULL pointer device");
2317 return RECORDER_ERROR_INVALID_PARAMETER;
2319 int ret = RECORDER_ERROR_NONE;
2320 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE;
2321 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2323 if (pc->cb_info == NULL) {
2324 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2325 return RECORDER_ERROR_INVALID_PARAMETER;
2327 sock_fd = pc->cb_info->fd;
2332 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2333 if (ret == RECORDER_ERROR_NONE) {
2334 muse_recorder_msg_get(get_device, pc->cb_info->recv_msg);
2335 *device = (recorder_audio_device_e)get_device;
2338 LOGD("ret : 0x%x", ret);
2343 int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate)
2345 if (recorder == NULL) {
2346 LOGE("NULL pointer handle");
2347 return RECORDER_ERROR_INVALID_PARAMETER;
2349 if (samplerate == NULL) {
2350 LOGE("NULL pointer handle");
2351 return RECORDER_ERROR_INVALID_PARAMETER;
2353 int ret = RECORDER_ERROR_NONE;
2354 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE;
2355 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2357 if (pc->cb_info == NULL) {
2358 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2359 return RECORDER_ERROR_INVALID_PARAMETER;
2361 sock_fd = pc->cb_info->fd;
2366 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2367 if (ret == RECORDER_ERROR_NONE) {
2368 muse_recorder_msg_get(get_samplerate, pc->cb_info->recv_msg);
2369 *samplerate = get_samplerate;
2371 LOGD("ret : 0x%x, get_samplerate : %d", ret, get_samplerate);
2376 int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate)
2378 if (recorder == NULL) {
2379 LOGE("NULL pointer handle");
2380 return RECORDER_ERROR_INVALID_PARAMETER;
2382 if (bitrate == NULL) {
2383 LOGE("NULL pointer");
2384 return RECORDER_ERROR_INVALID_PARAMETER;
2386 int ret = RECORDER_ERROR_NONE;
2387 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE;
2388 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2390 if (pc->cb_info == NULL) {
2391 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2392 return RECORDER_ERROR_INVALID_PARAMETER;
2394 sock_fd = pc->cb_info->fd;
2399 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2400 if (ret == RECORDER_ERROR_NONE) {
2401 muse_recorder_msg_get(get_bitrate, pc->cb_info->recv_msg);
2402 *bitrate = get_bitrate;
2404 LOGD("ret : 0x%x", ret);
2409 int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate)
2411 if (recorder == NULL) {
2412 LOGE("NULL pointer handle");
2413 return RECORDER_ERROR_INVALID_PARAMETER;
2415 if (bitrate == NULL) {
2416 LOGE("NULL pointer");
2417 return RECORDER_ERROR_INVALID_PARAMETER;
2419 int ret = RECORDER_ERROR_NONE;
2420 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE;
2421 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2423 if (pc->cb_info == NULL) {
2424 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2425 return RECORDER_ERROR_INVALID_PARAMETER;
2427 sock_fd = pc->cb_info->fd;
2432 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2433 if (ret == RECORDER_ERROR_NONE) {
2434 muse_recorder_msg_get(get_bitrate, pc->cb_info->recv_msg);
2435 *bitrate = get_bitrate;
2437 LOGD("ret : 0x%x", ret);
2442 int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb, void *user_data)
2444 if (recorder == NULL || foreach_cb == NULL) {
2445 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2446 return RECORDER_ERROR_INVALID_PARAMETER;
2448 int ret = RECORDER_ERROR_NONE;
2450 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2451 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_AUDIO_ENCODER;
2453 LOGD("Enter, handle :%x", pc->remote_handle);
2456 if (pc->cb_info == NULL) {
2457 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2458 return RECORDER_ERROR_INVALID_PARAMETER;
2460 sock_fd = pc->cb_info->fd;
2461 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = foreach_cb;
2462 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = user_data;
2464 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2465 LOGD("ret : 0x%x", ret);
2470 int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb, void *user_data)
2472 if (recorder == NULL || foreach_cb == NULL) {
2473 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2474 return RECORDER_ERROR_INVALID_PARAMETER;
2476 int ret = RECORDER_ERROR_NONE;
2478 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2479 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_ENCODER;
2481 LOGD("Enter, handle :%x", pc->remote_handle);
2484 if (pc->cb_info == NULL) {
2485 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2486 return RECORDER_ERROR_INVALID_PARAMETER;
2488 sock_fd = pc->cb_info->fd;
2489 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = foreach_cb;
2490 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = user_data;
2492 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2493 LOGD("ret : 0x%x", ret);
2498 int recorder_attr_set_mute(recorder_h recorder, bool enable)
2500 if (recorder == NULL) {
2501 LOGE("NULL pointer handle");
2502 return RECORDER_ERROR_INVALID_PARAMETER;
2504 int ret = RECORDER_ERROR_NONE;
2505 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_MUTE;
2506 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2508 if (pc->cb_info == NULL) {
2509 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2510 return RECORDER_ERROR_INVALID_PARAMETER;
2512 sock_fd = pc->cb_info->fd;
2513 int set_enable = (int)enable;
2517 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
2519 LOGD("ret : 0x%x", ret);
2525 bool recorder_attr_is_muted(recorder_h recorder)
2527 if (recorder == NULL) {
2528 LOGE("NULL pointer handle");
2531 int ret = RECORDER_ERROR_NONE;
2532 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_IS_MUTED;
2533 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2535 if (pc->cb_info == NULL) {
2536 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2537 return RECORDER_ERROR_INVALID_PARAMETER;
2539 sock_fd = pc->cb_info->fd;
2543 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2544 LOGD("ret : 0x%x", ret);
2549 int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate)
2551 if (recorder == NULL) {
2552 LOGE("NULL pointer handle");
2553 return RECORDER_ERROR_INVALID_PARAMETER;
2555 int ret = RECORDER_ERROR_NONE;
2556 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_RECORDING_MOTION_RATE;
2557 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2559 if (pc->cb_info == NULL) {
2560 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2561 return RECORDER_ERROR_INVALID_PARAMETER;
2563 sock_fd = pc->cb_info->fd;
2565 LOGD("ENTER - %.20lf", rate);
2567 muse_recorder_msg_send1(api,
2573 LOGD("ret : 0x%x", ret);
2579 int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate)
2581 if (recorder == NULL) {
2582 LOGE("NULL pointer handle");
2583 return RECORDER_ERROR_INVALID_PARAMETER;
2586 LOGE("rate is NULL");
2587 return RECORDER_ERROR_INVALID_PARAMETER;
2589 int ret = RECORDER_ERROR_NONE;
2590 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE;
2591 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2593 if (pc->cb_info == NULL) {
2594 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2595 return RECORDER_ERROR_INVALID_PARAMETER;
2597 sock_fd = pc->cb_info->fd;
2602 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2603 if (ret == RECORDER_ERROR_NONE) {
2604 muse_recorder_msg_get_double(get_rate, pc->cb_info->recv_msg);
2607 LOGD("ret : 0x%x - rate %.20lf", ret, *rate);
2612 int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count)
2614 if (recorder == NULL) {
2615 LOGE("NULL pointer handle");
2616 return RECORDER_ERROR_INVALID_PARAMETER;
2618 if (channel_count < 1) {
2619 LOGE("invalid channel %d", channel_count);
2620 return RECORDER_ERROR_INVALID_PARAMETER;
2622 int ret = RECORDER_ERROR_NONE;
2623 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_CHANNEL;
2624 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2626 if (pc->cb_info == NULL) {
2627 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2628 return RECORDER_ERROR_INVALID_PARAMETER;
2630 sock_fd = pc->cb_info->fd;
2634 muse_recorder_msg_send1(api,
2638 INT, channel_count);
2639 LOGD("ret : 0x%x", ret);
2644 int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count)
2646 if (recorder == NULL) {
2647 LOGE("NULL pointer handle");
2648 return RECORDER_ERROR_INVALID_PARAMETER;
2650 if (channel_count == NULL) {
2651 LOGE("channel_count is NULL");
2652 return RECORDER_ERROR_INVALID_PARAMETER;
2654 int ret = RECORDER_ERROR_NONE;
2655 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL;
2656 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2658 if (pc->cb_info == NULL) {
2659 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2660 return RECORDER_ERROR_INVALID_PARAMETER;
2662 sock_fd = pc->cb_info->fd;
2663 int get_channel_count;
2667 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2668 if (ret == RECORDER_ERROR_NONE) {
2669 muse_recorder_msg_get(get_channel_count, pc->cb_info->recv_msg);
2670 *channel_count = get_channel_count;
2672 LOGD("ret : 0x%x", ret);
2677 int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation)
2679 if (recorder == NULL) {
2680 LOGE("NULL pointer handle");
2681 return RECORDER_ERROR_INVALID_PARAMETER;
2683 if (orientation > RECORDER_ROTATION_270) {
2684 LOGE("invalid orientation %d", orientation);
2685 return RECORDER_ERROR_INVALID_PARAMETER;
2687 int ret = RECORDER_ERROR_NONE;
2688 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_ORIENTATION_TAG;
2689 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2691 if (pc->cb_info == NULL) {
2692 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2693 return RECORDER_ERROR_INVALID_PARAMETER;
2695 sock_fd = pc->cb_info->fd;
2696 int set_orientation = (int)orientation;
2700 muse_recorder_msg_send1(api,
2704 INT, set_orientation);
2705 LOGD("ret : 0x%x", ret);
2710 int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation)
2712 if (recorder == NULL) {
2713 LOGE("NULL pointer handle");
2714 return RECORDER_ERROR_INVALID_PARAMETER;
2716 if (orientation == NULL) {
2717 LOGE("orientation is NULL");
2718 return RECORDER_ERROR_INVALID_PARAMETER;
2720 int ret = RECORDER_ERROR_NONE;
2721 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG;
2722 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2724 if (pc->cb_info == NULL) {
2725 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2726 return RECORDER_ERROR_INVALID_PARAMETER;
2728 sock_fd = pc->cb_info->fd;
2729 int get_orientation;
2733 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2734 if (ret == RECORDER_ERROR_NONE) {
2735 muse_recorder_msg_get(get_orientation, pc->cb_info->recv_msg);
2736 *orientation = (recorder_rotation_e)get_orientation;
2738 LOGD("ret : 0x%x", ret);