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.
22 #include <muse_recorder.h>
23 #include <muse_recorder_msg.h>
24 #include <muse_core_ipc.h>
25 #include <recorder_private.h>
27 #include <muse_core.h>
28 #include <muse_core_msg_json.h>
29 #include <mm_camcorder_client.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 ((recorder_supported_audio_encoder_cb)cb_info->user_cb[event])((recorder_audio_codec_e)codec,
216 cb_info->user_data[event]);
219 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT:
223 muse_recorder_msg_get(format, recv_msg);
225 ((recorder_supported_file_format_cb)cb_info->user_cb[event])((recorder_file_format_e)format,
226 cb_info->user_data[event]);
229 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER:
233 muse_recorder_msg_get(codec, recv_msg);
235 ((recorder_supported_video_encoder_cb)cb_info->user_cb[event])((recorder_video_codec_e)codec,
236 cb_info->user_data[event]);
239 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION:
244 muse_recorder_msg_get(width, recv_msg);
245 muse_recorder_msg_get(height, recv_msg);
247 ((recorder_supported_video_resolution_cb)cb_info->user_cb[event])(width, height,
248 cb_info->user_data[event]);
253 LOGE("Unknonw recorder event %d", event);
261 static bool _recorder_idle_event_callback(void *data)
263 recorder_cb_info_s *cb_info = NULL;
264 recorder_idle_event_s *rec_idle_event = (recorder_idle_event_s *)data;
266 if (rec_idle_event == NULL) {
267 LOGE("rec_idle_event is NULL");
272 g_mutex_lock(&rec_idle_event->event_mutex);
274 cb_info = rec_idle_event->cb_info;
275 if (cb_info == NULL) {
276 LOGW("recorder cb_info is NULL. event %d", rec_idle_event->event);
277 goto IDLE_EVENT_CALLBACK_DONE;
280 /* remove event from list */
281 g_mutex_lock(&cb_info->idle_event_mutex);
282 if (cb_info->idle_event_list)
283 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
285 /*LOGD("remove recorder idle event %p, %p", rec_idle_event, cb_info->idle_event_list);*/
286 g_mutex_unlock(&cb_info->idle_event_mutex);
289 _client_user_callback(rec_idle_event->cb_info, rec_idle_event->recv_msg, rec_idle_event->event);
291 /* send signal for waiting thread */
292 g_cond_signal(&cb_info->idle_event_cond);
294 IDLE_EVENT_CALLBACK_DONE:
295 /* unlock and release event */
296 g_mutex_unlock(&rec_idle_event->event_mutex);
297 g_mutex_clear(&rec_idle_event->event_mutex);
299 free(rec_idle_event);
300 rec_idle_event = NULL;
306 static void _recorder_remove_idle_event_all(recorder_cb_info_s *cb_info)
308 recorder_idle_event_s *rec_idle_event = NULL;
313 if (cb_info == NULL) {
314 LOGE("cb_info is NULL");
318 g_mutex_lock(&cb_info->idle_event_mutex);
320 if (cb_info->idle_event_list == NULL) {
321 LOGD("No idle event is remained.");
323 list = cb_info->idle_event_list;
326 rec_idle_event = list->data;
327 list = g_list_next(list);
329 if (!rec_idle_event) {
330 LOGW("Fail to remove idle event. The event is NULL");
332 if (g_mutex_trylock(&rec_idle_event->event_mutex)) {
333 ret = g_idle_remove_by_data(rec_idle_event);
335 LOGD("remove idle event [%p], ret[%d]", rec_idle_event, ret);
338 rec_idle_event->cb_info = NULL;
339 LOGW("idle callback for event %p will be called later", rec_idle_event);
342 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
344 g_mutex_unlock(&rec_idle_event->event_mutex);
347 g_mutex_clear(&rec_idle_event->event_mutex);
349 free(rec_idle_event);
350 rec_idle_event = NULL;
352 LOGD("remove idle event done");
355 LOGW("event lock failed. it's being called...");
357 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
359 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
360 LOGW("signal received");
367 g_list_free(cb_info->idle_event_list);
368 cb_info->idle_event_list = NULL;
371 g_mutex_unlock(&cb_info->idle_event_mutex);
377 static void *_recorder_msg_handler_func(gpointer data)
383 recorder_message_s *rec_msg = NULL;
384 recorder_idle_event_s *rec_idle_event = NULL;
385 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
387 if (cb_info == NULL) {
388 LOGE("cb_info NULL");
394 g_mutex_lock(&cb_info->msg_handler_mutex);
396 while (g_atomic_int_get(&cb_info->msg_handler_running)) {
397 if (g_queue_is_empty(cb_info->msg_queue)) {
398 LOGD("signal wait...");
399 g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
400 LOGD("signal received");
402 if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
403 LOGD("stop event thread");
408 rec_msg = (recorder_message_s *)g_queue_pop_head(cb_info->msg_queue);
409 g_mutex_unlock(&cb_info->msg_handler_mutex);
410 if (rec_msg == NULL) {
411 LOGE("NULL message");
412 g_mutex_lock(&cb_info->msg_handler_mutex);
416 if (api < MUSE_RECORDER_API_MAX) {
417 g_mutex_lock(&cb_info->api_mutex[api]);
418 if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
419 cb_info->api_ret[api] = ret;
420 cb_info->api_activating[api] = 1;
422 LOGD("recorder api %d - return 0x%x", ret);
424 g_cond_signal(&cb_info->api_cond[api]);
426 LOGE("failed to get ret for api %d, msg %s", rec_msg->api, rec_msg->recv_msg);
429 g_mutex_unlock(&cb_info->api_mutex[api]);
430 } else if (api == MUSE_RECORDER_CB_EVENT) {
434 if (!muse_recorder_msg_get(event, rec_msg->recv_msg) ||
435 !muse_recorder_msg_get(event_class, rec_msg->recv_msg)) {
436 LOGE("failed to get recorder event %d, class %d", event, event_class);
441 g_mutex_lock(&cb_info->msg_handler_mutex);
445 switch (event_class) {
446 case MUSE_RECORDER_EVENT_CLASS_THREAD_SUB:
447 _client_user_callback(cb_info, rec_msg->recv_msg, event);
449 case MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN:
450 rec_idle_event = (recorder_idle_event_s *)malloc(sizeof(recorder_idle_event_s));
451 if (rec_idle_event == NULL) {
452 LOGE("rec_idle_event alloc failed");
456 rec_idle_event->event = event;
457 rec_idle_event->cb_info = cb_info;
458 g_mutex_init(&rec_idle_event->event_mutex);
459 memcpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg));
461 LOGD("add recorder event[%d, %p] to IDLE", event, rec_idle_event);
463 g_mutex_lock(&cb_info->idle_event_mutex);
464 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)rec_idle_event);
465 g_mutex_unlock(&cb_info->idle_event_mutex);
467 g_idle_add_full(G_PRIORITY_DEFAULT,
468 (GSourceFunc)_recorder_idle_event_callback,
469 (gpointer)rec_idle_event,
473 LOGE("unknown recorder event class %d", event_class);
477 LOGE("unknown recorder api[%d] message", api);
483 g_mutex_lock(&cb_info->msg_handler_mutex);
486 /* remove remained event */
487 while (!g_queue_is_empty(cb_info->msg_queue)) {
488 rec_msg = (recorder_message_s *)g_queue_pop_head(cb_info->msg_queue);
490 LOGD("remove recorder message %p", rec_msg);
494 LOGW("NULL recorder message");
498 g_mutex_unlock(&cb_info->msg_handler_mutex);
506 static void *_recorder_msg_recv_func(gpointer data)
515 char *recv_msg = NULL;
516 char **parse_str = NULL;
517 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
519 if (cb_info == NULL) {
520 LOGE("cb_info NULL");
526 parse_str = (char **)malloc(sizeof(char *) * RECORDER_PARSE_STRING_SIZE);
527 if (parse_str == NULL) {
528 LOGE("parse_str malloc failed");
532 for (i = 0 ; i < RECORDER_PARSE_STRING_SIZE ; i++) {
533 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
534 if (parse_str[i] == NULL) {
535 LOGE("parse_str[%d] malloc failed", i);
536 goto CB_HANDLER_EXIT;
540 recv_msg = cb_info->recv_msg;
542 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
543 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
546 recv_msg[ret] = '\0';
552 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
554 /* Need to split the combined entering msgs.
555 This module supports up to 200 combined msgs. */
556 for (str_pos = 0; str_pos < ret; str_pos++) {
557 if (recv_msg[str_pos] == '}') {
558 memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
559 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
560 LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);
561 prev_pos = str_pos+1;
566 /*LOGD("num_token : %d", num_token);*/
568 /* Re-construct to the useful single msg. */
569 for (i = 0; i < num_token; i++) {
570 if (i >= RECORDER_PARSE_STRING_SIZE) {
571 LOGE("invalid token index %d", i);
578 if (!muse_recorder_msg_get(api, parse_str[i])) {
579 LOGE("failed to get recorder api");
583 if (muse_recorder_msg_get(api_class, parse_str[i]))
584 LOGD("recorder api_class[%d]", api_class);
586 if (api_class == MUSE_RECORDER_API_CLASS_IMMEDIATE) {
587 g_mutex_lock(&cb_info->api_mutex[api]);
589 if (!muse_recorder_msg_get(ret, parse_str[i])) {
590 LOGE("failed to get recorder ret");
591 g_mutex_unlock(&cb_info->api_mutex[api]);
595 cb_info->api_ret[api] = ret;
596 cb_info->api_activating[api] = 1;
598 if (api == MUSE_RECORDER_API_CREATE) {
599 if (ret != RECORDER_ERROR_NONE) {
600 g_atomic_int_set(&cb_info->msg_recv_running, 0);
601 LOGE("recorder create error 0x%x. close client cb handler", ret);
603 } else if (api == MUSE_RECORDER_API_DESTROY) {
604 if (ret == RECORDER_ERROR_NONE) {
605 g_atomic_int_set(&cb_info->msg_recv_running, 0);
606 LOGD("recorder destroy done. close client cb handler");
610 g_cond_signal(&cb_info->api_cond[api]);
611 g_mutex_unlock(&cb_info->api_mutex[api]);
612 } else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB ||
613 api == MUSE_RECORDER_CB_EVENT) {
614 recorder_message_s *rec_msg = g_new0(recorder_message_s, 1);
615 if (rec_msg == NULL) {
616 LOGE("failed to alloc rec_msg");
621 memcpy(rec_msg->recv_msg, parse_str[i], sizeof(rec_msg->recv_msg));
623 LOGD("add recorder message to queue : api %d", api);
625 g_mutex_lock(&cb_info->msg_handler_mutex);
626 g_queue_push_tail(cb_info->msg_queue, (gpointer)rec_msg);
627 g_cond_signal(&cb_info->msg_handler_cond);
628 g_mutex_unlock(&cb_info->msg_handler_mutex);
630 LOGW("unknown recorder api %d and api_class %d", api, api_class);
635 LOGD("client cb exit");
639 for (i = 0 ; i < RECORDER_PARSE_STRING_SIZE ; i++) {
653 static recorder_cb_info_s *_client_callback_new(gint sockfd)
655 recorder_cb_info_s *cb_info = NULL;
656 gint *tmp_activating = NULL;
657 gint *tmp_ret = NULL;
660 g_return_val_if_fail(sockfd > 0, NULL);
662 cb_info = g_new0(recorder_cb_info_s, 1);
663 if (cb_info == NULL) {
664 LOGE("cb_info failed");
668 g_mutex_init(&cb_info->msg_handler_mutex);
669 g_cond_init(&cb_info->msg_handler_cond);
670 g_mutex_init(&cb_info->idle_event_mutex);
671 g_cond_init(&cb_info->idle_event_cond);
673 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
674 g_mutex_init(&cb_info->api_mutex[i]);
675 g_cond_init(&cb_info->api_cond[i]);
678 tmp_activating = g_new0(gint, MUSE_RECORDER_API_MAX);
679 if (tmp_activating == NULL) {
680 LOGE("tmp_activating failed");
684 tmp_ret = g_new0(gint, MUSE_RECORDER_API_MAX);
685 if (tmp_ret == NULL) {
686 LOGE("tmp_ret failed");
690 cb_info->msg_queue = g_queue_new();
691 if (cb_info->msg_queue == NULL) {
692 LOGE("msg_queue new failed");
696 g_atomic_int_set(&cb_info->msg_handler_running, 1);
697 cb_info->msg_handler_thread = g_thread_try_new("recorder_msg_handler",
698 _recorder_msg_handler_func,
701 if (cb_info->msg_handler_thread == NULL) {
702 LOGE("message handler thread creation failed");
706 cb_info->fd = sockfd;
707 cb_info->api_activating = tmp_activating;
708 cb_info->api_ret = tmp_ret;
710 g_atomic_int_set(&cb_info->msg_recv_running, 1);
711 cb_info->msg_recv_thread = g_thread_try_new("recorder_msg_recv",
712 _recorder_msg_recv_func,
715 if (cb_info->msg_recv_thread == NULL) {
716 LOGE("message receive thread creation failed");
725 if (cb_info->msg_handler_thread) {
726 g_mutex_lock(&cb_info->msg_handler_mutex);
727 g_atomic_int_set(&cb_info->msg_handler_running, 0);
728 g_cond_signal(&cb_info->msg_handler_cond);
729 g_mutex_unlock(&cb_info->msg_handler_mutex);
731 g_thread_join(cb_info->msg_handler_thread);
732 g_thread_unref(cb_info->msg_handler_thread);
733 cb_info->msg_handler_thread = NULL;
736 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
737 g_mutex_clear(&cb_info->api_mutex[i]);
738 g_cond_clear(&cb_info->api_cond[i]);
741 g_mutex_clear(&cb_info->msg_handler_mutex);
742 g_cond_clear(&cb_info->msg_handler_cond);
743 g_mutex_clear(&cb_info->idle_event_mutex);
744 g_cond_clear(&cb_info->idle_event_cond);
746 if (cb_info->msg_queue) {
747 g_queue_free(cb_info->msg_queue);
748 cb_info->msg_queue = NULL;
755 if (tmp_activating) {
756 g_free(tmp_activating);
757 tmp_activating = NULL;
767 static int client_wait_for_cb_return(muse_recorder_api_e api, recorder_cb_info_s *cb_info, int time_out)
769 int ret = RECORDER_ERROR_NONE;
772 LOGD("Enter api : %d", api);
774 g_mutex_lock(&(cb_info->api_mutex[api]));
776 if (cb_info->api_activating[api] == 0) {
777 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
778 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
779 ret = cb_info->api_ret[api];
780 cb_info->api_activating[api] = 0;
782 LOGD("return value : 0x%x", ret);
784 ret = RECORDER_ERROR_INVALID_OPERATION;
786 LOGE("api %d was TIMED OUT!", api);
789 ret = cb_info->api_ret[api];
790 cb_info->api_activating[api] = 0;
792 LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);
795 g_mutex_unlock(&(cb_info->api_mutex[api]));
800 static void _client_callback_destroy(recorder_cb_info_s *cb_info)
804 g_return_if_fail(cb_info != NULL);
806 LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
808 g_thread_join(cb_info->msg_recv_thread);
809 g_thread_unref(cb_info->msg_recv_thread);
810 cb_info->msg_recv_thread = NULL;
812 LOGD("msg thread removed");
814 g_mutex_lock(&cb_info->msg_handler_mutex);
815 g_atomic_int_set(&cb_info->msg_handler_running, 0);
816 g_cond_signal(&cb_info->msg_handler_cond);
817 g_mutex_unlock(&cb_info->msg_handler_mutex);
819 g_thread_join(cb_info->msg_handler_thread);
820 g_thread_unref(cb_info->msg_handler_thread);
821 cb_info->msg_handler_thread = NULL;
823 g_queue_free(cb_info->msg_queue);
824 cb_info->msg_queue = NULL;
825 g_mutex_clear(&cb_info->msg_handler_mutex);
826 g_cond_clear(&cb_info->msg_handler_cond);
827 g_mutex_clear(&cb_info->idle_event_mutex);
828 g_cond_clear(&cb_info->idle_event_cond);
830 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
831 g_mutex_clear(&cb_info->api_mutex[i]);
832 g_cond_clear(&cb_info->api_cond[i]);
835 LOGD("event thread removed");
837 if (cb_info->bufmgr) {
838 tbm_bufmgr_deinit(cb_info->bufmgr);
839 cb_info->bufmgr = NULL;
841 if (cb_info->api_activating) {
842 g_free(cb_info->api_activating);
843 cb_info->api_activating = NULL;
845 if (cb_info->api_ret) {
846 g_free(cb_info->api_ret);
847 cb_info->api_ret = NULL;
856 static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e type, camera_h camera)
858 int ret = RECORDER_ERROR_NONE;
859 int destroy_ret = RECORDER_ERROR_NONE;
861 char *send_msg = NULL;
862 char *root_directory = NULL;
863 intptr_t camera_handle = 0;
865 tbm_bufmgr bufmgr = NULL;
866 recorder_cli_s *pc = NULL;
868 LOGD("Enter - type %d", type);
870 if (recorder == NULL) {
871 LOGE("NULL pointer for recorder handle");
872 return RECORDER_ERROR_INVALID_PARAMETER;
875 if (type == MUSE_RECORDER_TYPE_VIDEO && camera == NULL) {
876 LOGE("NULL pointer for camera handle on video recorder mode");
877 return RECORDER_ERROR_INVALID_PARAMETER;
880 bufmgr = tbm_bufmgr_init(-1);
881 if (bufmgr == NULL) {
882 LOGE("get tbm bufmgr failed");
883 return RECORDER_ERROR_INVALID_OPERATION;
886 pc = g_new0(recorder_cli_s, 1);
888 ret = RECORDER_ERROR_OUT_OF_MEMORY;
889 goto _ERR_RECORDER_EXIT;
892 sock_fd = muse_core_client_new();
894 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
895 ret = RECORDER_ERROR_INVALID_OPERATION;
896 goto _ERR_RECORDER_EXIT;
899 if (type == MUSE_RECORDER_TYPE_AUDIO) {
900 send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
901 MUSE_TYPE_INT, "module", MUSE_RECORDER,
902 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_AUDIO,
903 MUSE_TYPE_INT, "pid", getpid(),
906 camera_handle = (intptr_t)((camera_cli_s *)camera)->remote_handle;
907 send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
908 MUSE_TYPE_INT, "module", MUSE_RECORDER,
909 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_VIDEO,
910 MUSE_TYPE_POINTER, "camera_handle", camera_handle,
914 LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
916 muse_core_ipc_send_msg(sock_fd, send_msg);
917 muse_core_msg_json_factory_free(send_msg);
919 pc->cb_info = _client_callback_new(sock_fd);
920 if (pc->cb_info == NULL) {
921 ret = RECORDER_ERROR_OUT_OF_MEMORY;
922 goto _ERR_RECORDER_EXIT;
925 ret = client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, CALLBACK_TIME_OUT);
926 if (ret == RECORDER_ERROR_NONE) {
927 muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
929 LOGE("Receiving Handle Failed!!");
930 goto _ERR_RECORDER_EXIT;
933 if (mm_camcorder_client_get_root_directory(&root_directory) != MM_ERROR_NONE ||
934 root_directory == NULL) {
935 LOGE("failed to get root directory of internal storage");
936 ret = RECORDER_ERROR_INVALID_OPERATION;
937 goto _ERR_RECORDER_AFTER_CREATE;
940 LOGD("set root directory [%s]", root_directory);
942 muse_recorder_msg_send1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY,
943 sock_fd, pc->cb_info, ret, STRING, root_directory);
944 if (ret != RECORDER_ERROR_NONE) {
945 LOGE("failed to set root directory %s", root_directory);
946 ret = RECORDER_ERROR_INVALID_OPERATION;
947 goto _ERR_RECORDER_AFTER_CREATE;
950 free(root_directory);
951 root_directory = NULL;
953 pc->remote_handle = handle;
954 pc->cb_info->bufmgr = bufmgr;
956 LOGD("recorder[type %d] %p create success : remote handle 0x%x",
957 type, pc, pc->remote_handle);
959 *recorder = (recorder_h) pc;
961 goto _ERR_RECORDER_EXIT;
966 return RECORDER_ERROR_NONE;
968 _ERR_RECORDER_AFTER_CREATE:
969 muse_recorder_msg_send(MUSE_RECORDER_API_DESTROY, sock_fd, pc->cb_info, destroy_ret);
970 LOGE("destroy return 0x%x", destroy_ret);
973 tbm_bufmgr_deinit(bufmgr);
976 if (root_directory) {
977 free(root_directory);
978 root_directory = NULL;
983 _client_callback_destroy(pc->cb_info);
993 int recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
995 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_VIDEO, camera);
999 int recorder_create_audiorecorder(recorder_h *recorder)
1001 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_AUDIO, NULL);
1004 int recorder_get_state(recorder_h recorder, recorder_state_e *state)
1006 if (recorder == NULL) {
1007 LOGE("NULL pointer handle");
1008 return RECORDER_ERROR_INVALID_PARAMETER;
1010 if (state == NULL) {
1011 LOGE("NULL pointer state");
1012 return RECORDER_ERROR_INVALID_PARAMETER;
1015 int ret = RECORDER_ERROR_NONE;
1017 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1018 muse_recorder_api_e api = MUSE_RECORDER_API_GET_STATE;
1020 if (pc->cb_info == NULL) {
1021 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1022 return RECORDER_ERROR_INVALID_PARAMETER;
1024 sock_fd = pc->cb_info->fd;
1027 LOGD("Enter, remote_handle : %x", pc->remote_handle);
1029 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1031 if (ret == RECORDER_ERROR_NONE) {
1032 muse_recorder_msg_get(get_state, pc->cb_info->recv_msg);
1033 *state = (recorder_state_e)get_state;
1036 LOGD("ret : 0x%x, get_state : %d", ret, get_state);
1042 int recorder_destroy(recorder_h recorder)
1044 if (recorder == NULL) {
1045 LOGE("NULL pointer handle");
1046 return RECORDER_ERROR_INVALID_PARAMETER;
1048 int ret = RECORDER_ERROR_NONE;
1049 muse_recorder_api_e api = MUSE_RECORDER_API_DESTROY;
1050 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1053 if (pc->cb_info == NULL) {
1054 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1055 return RECORDER_ERROR_INVALID_PARAMETER;
1058 sock_fd = pc->cb_info->fd;
1062 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1063 if (ret == RECORDER_ERROR_NONE) {
1064 _recorder_remove_idle_event_all(pc->cb_info);
1065 _client_callback_destroy(pc->cb_info);
1070 LOGD("ret : 0x%x", ret);
1076 int recorder_prepare(recorder_h recorder)
1078 if (recorder == NULL) {
1079 LOGE("NULL pointer handle");
1080 return RECORDER_ERROR_INVALID_PARAMETER;
1083 int ret = RECORDER_ERROR_NONE;
1084 muse_recorder_api_e api = MUSE_RECORDER_API_PREPARE;
1085 recorder_cli_s *pc = (recorder_cli_s *)recorder;
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;
1095 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1097 LOGD("ret : 0x%x", ret);
1103 int recorder_unprepare(recorder_h recorder)
1105 if (recorder == NULL) {
1106 LOGE("NULL pointer handle");
1107 return RECORDER_ERROR_INVALID_PARAMETER;
1109 int ret = RECORDER_ERROR_NONE;
1110 muse_recorder_api_e api = MUSE_RECORDER_API_UNPREPARE;
1111 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1113 if (pc->cb_info == NULL) {
1114 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1115 return RECORDER_ERROR_INVALID_PARAMETER;
1117 sock_fd = pc->cb_info->fd;
1121 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1122 LOGD("ret : 0x%x", ret);
1127 int recorder_start(recorder_h recorder)
1129 if (recorder == NULL) {
1130 LOGE("NULL pointer handle");
1131 return RECORDER_ERROR_INVALID_PARAMETER;
1133 int ret = RECORDER_ERROR_NONE;
1134 muse_recorder_api_e api = MUSE_RECORDER_API_START;
1135 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1137 if (pc->cb_info == NULL) {
1138 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1139 return RECORDER_ERROR_INVALID_PARAMETER;
1141 sock_fd = pc->cb_info->fd;
1145 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1146 LOGD("ret : 0x%x", ret);
1151 int recorder_pause(recorder_h recorder)
1153 if (recorder == NULL) {
1154 LOGE("NULL pointer handle");
1155 return RECORDER_ERROR_INVALID_PARAMETER;
1157 int ret = RECORDER_ERROR_NONE;
1158 muse_recorder_api_e api = MUSE_RECORDER_API_PAUSE;
1159 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1161 if (pc->cb_info == NULL) {
1162 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1163 return RECORDER_ERROR_INVALID_PARAMETER;
1165 sock_fd = pc->cb_info->fd;
1169 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1170 LOGD("ret : 0x%x", ret);
1175 int recorder_commit(recorder_h recorder)
1177 if (recorder == NULL) {
1178 LOGE("NULL pointer handle");
1179 return RECORDER_ERROR_INVALID_PARAMETER;
1181 int ret = RECORDER_ERROR_NONE;
1182 muse_recorder_api_e api = MUSE_RECORDER_API_COMMIT;
1183 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1185 if (pc->cb_info == NULL) {
1186 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1187 return RECORDER_ERROR_INVALID_PARAMETER;
1189 sock_fd = pc->cb_info->fd;
1193 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1194 LOGD("ret : 0x%x", ret);
1199 int recorder_cancel(recorder_h recorder)
1201 if (recorder == NULL) {
1202 LOGE("NULL pointer handle");
1203 return RECORDER_ERROR_INVALID_PARAMETER;
1205 int ret = RECORDER_ERROR_NONE;
1206 muse_recorder_api_e api = MUSE_RECORDER_API_CANCEL;
1207 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1209 if (pc->cb_info == NULL) {
1210 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1211 return RECORDER_ERROR_INVALID_PARAMETER;
1213 sock_fd = pc->cb_info->fd;
1217 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1218 LOGD("ret : 0x%x", ret);
1223 int recorder_set_video_resolution(recorder_h recorder, int width, int height)
1225 if (recorder == NULL) {
1226 LOGE("NULL pointer handle");
1227 return RECORDER_ERROR_INVALID_PARAMETER;
1229 int ret = RECORDER_ERROR_NONE;
1230 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION;
1231 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1233 if (pc->cb_info == NULL) {
1234 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1235 return RECORDER_ERROR_INVALID_PARAMETER;
1237 sock_fd = pc->cb_info->fd;
1241 muse_recorder_msg_send2(api,
1247 LOGD("ret : 0x%x", ret);
1252 int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
1254 if (recorder == NULL) {
1255 LOGE("NULL pointer handle");
1256 return RECORDER_ERROR_INVALID_PARAMETER;
1258 if (!width || !height) {
1259 LOGE("NULL pointer width = [%p], height = [%p]", width, height);
1260 return RECORDER_ERROR_INVALID_PARAMETER;
1262 int ret = RECORDER_ERROR_NONE;
1263 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_RESOLUTION;
1264 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1266 if (pc->cb_info == NULL) {
1267 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1268 return RECORDER_ERROR_INVALID_PARAMETER;
1270 sock_fd = pc->cb_info->fd;
1276 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1277 if (ret == RECORDER_ERROR_NONE) {
1278 muse_recorder_msg_get(get_width, pc->cb_info->recv_msg);
1279 muse_recorder_msg_get(get_height, pc->cb_info->recv_msg);
1281 *height = get_height;
1283 LOGD("ret : 0x%x", ret);
1288 int recorder_foreach_supported_video_resolution(recorder_h recorder,
1289 recorder_supported_video_resolution_cb foreach_cb, void *user_data)
1291 if (recorder == NULL || foreach_cb == NULL) {
1292 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1293 return RECORDER_ERROR_INVALID_PARAMETER;
1295 int ret = RECORDER_ERROR_NONE;
1297 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1298 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_RESOLUTION;
1300 LOGD("Enter, handle :%x", pc->remote_handle);
1303 if (pc->cb_info == NULL) {
1304 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1305 return RECORDER_ERROR_INVALID_PARAMETER;
1307 sock_fd = pc->cb_info->fd;
1308 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
1309 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
1311 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1312 LOGD("ret : 0x%x", ret);
1317 int recorder_get_audio_level(recorder_h recorder, double *level)
1319 if (recorder == NULL || level == NULL) {
1320 LOGE("NULL pointer %p %p", recorder, level);
1321 return RECORDER_ERROR_INVALID_PARAMETER;
1324 int ret = RECORDER_ERROR_NONE;
1325 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_LEVEL;
1326 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1328 if (pc->cb_info == NULL) {
1329 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1330 return RECORDER_ERROR_INVALID_PARAMETER;
1332 sock_fd = pc->cb_info->fd;
1337 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1338 if (ret == RECORDER_ERROR_NONE) {
1339 muse_recorder_msg_get_double(get_level, pc->cb_info->recv_msg);
1342 LOGD("ret : 0x%x", ret);
1347 int recorder_set_filename(recorder_h recorder, const char *filename)
1349 if (recorder == NULL) {
1350 LOGE("handle is NULL");
1351 return RECORDER_ERROR_INVALID_PARAMETER;
1354 if (filename == NULL) {
1355 LOGE("filename is NULL");
1356 return RECORDER_ERROR_INVALID_PARAMETER;
1358 int ret = RECORDER_ERROR_NONE;
1359 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
1360 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1362 if (pc->cb_info == NULL) {
1363 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1364 return RECORDER_ERROR_INVALID_PARAMETER;
1366 sock_fd = pc->cb_info->fd;
1370 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, filename);
1371 LOGD("ret : 0x%x", ret);
1376 int recorder_get_filename(recorder_h recorder, char **filename)
1378 if (recorder == NULL) {
1379 LOGE("handle is NULL");
1380 return RECORDER_ERROR_INVALID_PARAMETER;
1383 if (filename == NULL) {
1384 LOGE("filename is NULL");
1385 return RECORDER_ERROR_INVALID_PARAMETER;
1387 int ret = RECORDER_ERROR_NONE;
1388 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILENAME;
1389 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1391 if (pc->cb_info == NULL) {
1392 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1393 return RECORDER_ERROR_INVALID_PARAMETER;
1395 sock_fd = pc->cb_info->fd;
1396 char get_filename[MUSE_RECORDER_MSG_MAX_LENGTH] = {0,};
1400 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1402 if (ret == RECORDER_ERROR_NONE) {
1403 muse_recorder_msg_get_string(get_filename, pc->cb_info->recv_msg);
1404 *filename = strdup(get_filename);
1406 LOGD("ret : 0x%x, filename : %s", ret, *filename);
1411 int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
1413 if (recorder == NULL) {
1414 LOGE("NULL pointer handle");
1415 return RECORDER_ERROR_INVALID_PARAMETER;
1417 if (format < RECORDER_FILE_FORMAT_3GP || format > RECORDER_FILE_FORMAT_OGG) {
1418 LOGE("invalid format %d", format);
1419 return RECORDER_ERROR_INVALID_PARAMETER;
1421 int ret = RECORDER_ERROR_NONE;
1422 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT;
1423 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1425 if (pc->cb_info == NULL) {
1426 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1427 return RECORDER_ERROR_INVALID_PARAMETER;
1429 sock_fd = pc->cb_info->fd;
1430 int set_format = (int)format;
1432 LOGD("ENTER, set_format : %d", set_format);
1434 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
1435 LOGD("ret : 0x%x", ret);
1440 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format)
1442 if (recorder == NULL) {
1443 LOGE("NULL pointer handle");
1444 return RECORDER_ERROR_INVALID_PARAMETER;
1446 if (format == NULL) {
1447 LOGE("NULL pointer data");
1448 return RECORDER_ERROR_INVALID_PARAMETER;
1450 int ret = RECORDER_ERROR_NONE;
1451 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILE_FORMAT;
1452 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1454 if (pc->cb_info == NULL) {
1455 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1456 return RECORDER_ERROR_INVALID_PARAMETER;
1458 sock_fd = pc->cb_info->fd;
1463 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1465 if (ret == RECORDER_ERROR_NONE) {
1466 muse_recorder_msg_get(get_format, pc->cb_info->recv_msg);
1467 LOGD("get_fileformat : %d", get_format);
1468 *format = (recorder_file_format_e)get_format;
1470 LOGD("ret : 0x%x", ret);
1475 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data)
1477 if (recorder == NULL || callback == NULL) {
1478 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1479 return RECORDER_ERROR_INVALID_PARAMETER;
1481 int ret = RECORDER_ERROR_NONE;
1483 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1484 muse_recorder_api_e api = MUSE_RECORDER_API_SET_STATE_CHANGED_CB;
1486 LOGD("Enter, handle :%x", pc->remote_handle);
1489 if (pc->cb_info == NULL) {
1490 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1491 return RECORDER_ERROR_INVALID_PARAMETER;
1493 sock_fd = pc->cb_info->fd;
1494 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
1495 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
1497 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1498 LOGD("ret : 0x%x", ret);
1503 int recorder_unset_state_changed_cb(recorder_h recorder)
1505 if (recorder == NULL) {
1506 LOGE("NULL pointer handle");
1507 return RECORDER_ERROR_INVALID_PARAMETER;
1509 int ret = RECORDER_ERROR_NONE;
1510 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB;
1511 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1513 if (pc->cb_info == NULL) {
1514 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1515 return RECORDER_ERROR_INVALID_PARAMETER;
1517 sock_fd = pc->cb_info->fd;
1521 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1522 LOGD("ret : 0x%x", ret);
1527 int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data)
1529 if (recorder == NULL || callback == NULL) {
1530 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1531 return RECORDER_ERROR_INVALID_PARAMETER;
1533 int ret = RECORDER_ERROR_NONE;
1535 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1536 muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB;
1538 LOGD("Enter, handle :%x", pc->remote_handle);
1541 if (pc->cb_info == NULL) {
1542 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1543 return RECORDER_ERROR_INVALID_PARAMETER;
1545 sock_fd = pc->cb_info->fd;
1546 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
1547 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
1549 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1550 LOGD("ret : 0x%x", ret);
1555 int recorder_unset_interrupted_cb(recorder_h recorder)
1557 if (recorder == NULL) {
1558 LOGE("NULL pointer handle");
1559 return RECORDER_ERROR_INVALID_PARAMETER;
1561 int ret = RECORDER_ERROR_NONE;
1562 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB;
1563 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1565 if (pc->cb_info == NULL) {
1566 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1567 return RECORDER_ERROR_INVALID_PARAMETER;
1569 sock_fd = pc->cb_info->fd;
1573 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1574 LOGD("ret : 0x%x", ret);
1579 int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data)
1581 if (recorder == NULL || callback == NULL) {
1582 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1583 return RECORDER_ERROR_INVALID_PARAMETER;
1585 int ret = RECORDER_ERROR_NONE;
1587 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1588 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_STREAM_CB;
1590 LOGD("Enter, handle :%x", pc->remote_handle);
1593 if (pc->cb_info == NULL) {
1594 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1595 return RECORDER_ERROR_INVALID_PARAMETER;
1597 sock_fd = pc->cb_info->fd;
1598 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
1599 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
1601 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1602 LOGD("ret : 0x%x", ret);
1607 int recorder_unset_audio_stream_cb(recorder_h recorder)
1609 if (recorder == NULL) {
1610 LOGE("NULL pointer handle");
1611 return RECORDER_ERROR_INVALID_PARAMETER;
1613 int ret = RECORDER_ERROR_NONE;
1614 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB;
1615 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1617 if (pc->cb_info == NULL) {
1618 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1619 return RECORDER_ERROR_INVALID_PARAMETER;
1621 sock_fd = pc->cb_info->fd;
1625 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1626 LOGD("ret : 0x%x", ret);
1631 int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data)
1633 if (recorder == NULL || callback == NULL) {
1634 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1635 return RECORDER_ERROR_INVALID_PARAMETER;
1637 int ret = RECORDER_ERROR_NONE;
1639 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1640 muse_recorder_api_e api = MUSE_RECORDER_API_SET_ERROR_CB;
1642 LOGD("Enter, handle :%x", pc->remote_handle);
1645 if (pc->cb_info == NULL) {
1646 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1647 return RECORDER_ERROR_INVALID_PARAMETER;
1649 sock_fd = pc->cb_info->fd;
1650 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
1651 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
1653 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1654 LOGD("ret : 0x%x", ret);
1659 int recorder_unset_error_cb(recorder_h recorder)
1661 if (recorder == NULL) {
1662 LOGE("NULL pointer handle");
1663 return RECORDER_ERROR_INVALID_PARAMETER;
1665 int ret = RECORDER_ERROR_NONE;
1666 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_ERROR_CB;
1667 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1669 if (pc->cb_info == NULL) {
1670 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1671 return RECORDER_ERROR_INVALID_PARAMETER;
1673 sock_fd = pc->cb_info->fd;
1677 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1678 LOGD("ret : 0x%x", ret);
1683 int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void* user_data)
1685 if (recorder == NULL || callback == NULL) {
1686 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1687 return RECORDER_ERROR_INVALID_PARAMETER;
1689 int ret = RECORDER_ERROR_NONE;
1691 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1692 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_STATUS_CB;
1694 LOGD("Enter, handle :%x", pc->remote_handle);
1697 if (pc->cb_info == NULL) {
1698 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1699 return RECORDER_ERROR_INVALID_PARAMETER;
1701 sock_fd = pc->cb_info->fd;
1702 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
1703 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
1705 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1706 LOGD("ret : 0x%x", ret);
1711 int recorder_unset_recording_status_cb(recorder_h recorder)
1713 if (recorder == NULL) {
1714 LOGE("NULL pointer handle");
1715 return RECORDER_ERROR_INVALID_PARAMETER;
1717 int ret = RECORDER_ERROR_NONE;
1718 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_STATUS_CB;
1719 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1721 if (pc->cb_info == NULL) {
1722 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1723 return RECORDER_ERROR_INVALID_PARAMETER;
1725 sock_fd = pc->cb_info->fd;
1729 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1730 LOGD("ret : 0x%x", ret);
1735 int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void* user_data)
1737 if (recorder == NULL || callback == NULL) {
1738 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1739 return RECORDER_ERROR_INVALID_PARAMETER;
1741 int ret = RECORDER_ERROR_NONE;
1743 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1744 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_LIMIT_REACHED_CB;
1746 LOGD("Enter, handle :%x", pc->remote_handle);
1749 if (pc->cb_info == NULL) {
1750 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1751 return RECORDER_ERROR_INVALID_PARAMETER;
1753 sock_fd = pc->cb_info->fd;
1754 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
1755 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
1757 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1758 LOGD("ret : 0x%x", ret);
1763 int recorder_unset_recording_limit_reached_cb(recorder_h recorder)
1765 if (recorder == NULL) {
1766 LOGE("NULL pointer handle");
1767 return RECORDER_ERROR_INVALID_PARAMETER;
1769 int ret = RECORDER_ERROR_NONE;
1770 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_LIMIT_REACHED_CB;
1771 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1773 if (pc->cb_info == NULL) {
1774 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1775 return RECORDER_ERROR_INVALID_PARAMETER;
1777 sock_fd = pc->cb_info->fd;
1781 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1782 LOGD("ret : 0x%x", ret);
1787 int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb, void *user_data)
1789 if (recorder == NULL || foreach_cb == NULL) {
1790 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1791 return RECORDER_ERROR_INVALID_PARAMETER;
1793 int ret = RECORDER_ERROR_NONE;
1795 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1796 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_FILE_FORMAT;
1798 LOGD("Enter, handle :%x", pc->remote_handle);
1801 if (pc->cb_info == NULL) {
1802 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1803 return RECORDER_ERROR_INVALID_PARAMETER;
1805 sock_fd = pc->cb_info->fd;
1806 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = foreach_cb;
1807 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = user_data;
1809 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1810 LOGD("ret : 0x%x", ret);
1815 int recorder_attr_set_size_limit(recorder_h recorder, int kbyte)
1817 if (recorder == NULL) {
1818 LOGE("NULL pointer handle");
1819 return RECORDER_ERROR_INVALID_PARAMETER;
1821 int ret = RECORDER_ERROR_NONE;
1822 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_SIZE_LIMIT;
1823 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1825 if (pc->cb_info == NULL) {
1826 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1827 return RECORDER_ERROR_INVALID_PARAMETER;
1829 sock_fd = pc->cb_info->fd;
1833 muse_recorder_msg_send1(api,
1838 LOGD("ret : 0x%x", ret);
1843 int recorder_attr_set_time_limit(recorder_h recorder, int second)
1845 if (recorder == NULL) {
1846 LOGE("NULL pointer handle");
1847 return RECORDER_ERROR_INVALID_PARAMETER;
1849 int ret = RECORDER_ERROR_NONE;
1850 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_TIME_LIMIT;
1851 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1853 if (pc->cb_info == NULL) {
1854 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1855 return RECORDER_ERROR_INVALID_PARAMETER;
1857 sock_fd = pc->cb_info->fd;
1861 muse_recorder_msg_send1(api,
1866 LOGD("ret : 0x%x", ret);
1871 int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device)
1873 if (recorder == NULL) {
1874 LOGE("NULL pointer handle");
1875 return RECORDER_ERROR_INVALID_PARAMETER;
1877 int ret = RECORDER_ERROR_NONE;
1878 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_DEVICE;
1879 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1881 if (pc->cb_info == NULL) {
1882 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1883 return RECORDER_ERROR_INVALID_PARAMETER;
1885 sock_fd = pc->cb_info->fd;
1886 int set_device = (int)device;
1890 muse_recorder_msg_send1(api,
1895 LOGD("ret : 0x%x", ret);
1900 int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec)
1902 if (recorder == NULL) {
1903 LOGE("NULL pointer handle");
1904 return RECORDER_ERROR_INVALID_PARAMETER;
1906 if (codec != RECORDER_AUDIO_CODEC_DISABLE &&
1907 (codec < RECORDER_AUDIO_CODEC_AMR || codec > RECORDER_AUDIO_CODEC_PCM)) {
1908 LOGE("invalid parameter : codec %d", codec);
1909 return RECORDER_ERROR_INVALID_PARAMETER;
1911 int ret = RECORDER_ERROR_NONE;
1912 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_ENCODER;
1913 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1915 if (pc->cb_info == NULL) {
1916 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1917 return RECORDER_ERROR_INVALID_PARAMETER;
1919 sock_fd = pc->cb_info->fd;
1920 int set_codec = (int)codec;
1924 muse_recorder_msg_send1(api,
1929 LOGD("ret : 0x%x", ret);
1934 int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec)
1936 if (recorder == NULL) {
1937 LOGE("NULL pointer handle");
1938 return RECORDER_ERROR_INVALID_PARAMETER;
1940 if (codec == NULL) {
1941 LOGE("codec is NULL");
1942 return RECORDER_ERROR_INVALID_PARAMETER;
1944 int ret = RECORDER_ERROR_NONE;
1945 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_ENCODER;
1946 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1948 if (pc->cb_info == NULL) {
1949 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1950 return RECORDER_ERROR_INVALID_PARAMETER;
1952 sock_fd = pc->cb_info->fd;
1957 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1958 if (ret == RECORDER_ERROR_NONE) {
1959 muse_recorder_msg_get(get_codec, pc->cb_info->recv_msg);
1960 *codec = (recorder_audio_codec_e)get_codec;
1962 LOGD("ret : 0x%x", ret);
1967 int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec)
1969 if (recorder == NULL) {
1970 LOGE("NULL pointer handle");
1971 return RECORDER_ERROR_INVALID_PARAMETER;
1973 if (codec < RECORDER_VIDEO_CODEC_H263 || codec > RECORDER_VIDEO_CODEC_THEORA) {
1974 LOGE("invalid codec %d", codec);
1975 return RECORDER_ERROR_INVALID_PARAMETER;
1977 int ret = RECORDER_ERROR_NONE;
1978 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_ENCODER;
1979 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1981 if (pc->cb_info == NULL) {
1982 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1983 return RECORDER_ERROR_INVALID_PARAMETER;
1985 sock_fd = pc->cb_info->fd;
1986 int set_codec = (int)codec;
1990 muse_recorder_msg_send1(api,
1995 LOGD("ret : 0x%x", ret);
2000 int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec)
2002 if (recorder == NULL) {
2003 LOGE("NULL pointer handle");
2004 return RECORDER_ERROR_INVALID_PARAMETER;
2006 if (codec == NULL) {
2007 LOGE("codec is NULL");
2008 return RECORDER_ERROR_INVALID_PARAMETER;
2010 int ret = RECORDER_ERROR_NONE;
2011 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_ENCODER;
2012 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2014 if (pc->cb_info == NULL) {
2015 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2016 return RECORDER_ERROR_INVALID_PARAMETER;
2018 sock_fd = pc->cb_info->fd;
2023 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2024 if (ret == RECORDER_ERROR_NONE) {
2025 muse_recorder_msg_get(get_codec, pc->cb_info->recv_msg);
2026 *codec = (recorder_audio_codec_e)get_codec;
2028 LOGD("ret : 0x%x", ret);
2033 int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate)
2035 if (recorder == NULL) {
2036 LOGE("NULL pointer handle");
2037 return RECORDER_ERROR_INVALID_PARAMETER;
2039 if (samplerate < 1) {
2040 LOGE("invalid samplerate %d", samplerate);
2041 return RECORDER_ERROR_INVALID_PARAMETER;
2043 int ret = RECORDER_ERROR_NONE;
2044 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_SAMPLERATE;
2045 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2047 if (pc->cb_info == NULL) {
2048 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2049 return RECORDER_ERROR_INVALID_PARAMETER;
2051 sock_fd = pc->cb_info->fd;
2053 LOGD("ENTER, samplerate : %d", samplerate);
2055 muse_recorder_msg_send1(api,
2060 LOGD("ret : 0x%x, samplerate : %d", ret, samplerate);
2065 int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate)
2067 if (recorder == NULL) {
2068 LOGE("NULL pointer handle");
2069 return RECORDER_ERROR_INVALID_PARAMETER;
2072 LOGE("invalid bitrate %d", bitrate);
2073 return RECORDER_ERROR_INVALID_PARAMETER;
2075 int ret = RECORDER_ERROR_NONE;
2076 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_ENCODER_BITRATE;
2077 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2079 if (pc->cb_info == NULL) {
2080 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2081 return RECORDER_ERROR_INVALID_PARAMETER;
2083 sock_fd = pc->cb_info->fd;
2087 muse_recorder_msg_send1(api,
2092 LOGD("ret : 0x%x", ret);
2097 int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate)
2099 if (recorder == NULL) {
2100 LOGE("NULL pointer handle");
2101 return RECORDER_ERROR_INVALID_PARAMETER;
2104 int ret = RECORDER_ERROR_NONE;
2105 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_VIDEO_ENCODER_BITRATE;
2106 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2108 if (pc->cb_info == NULL) {
2109 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2110 return RECORDER_ERROR_INVALID_PARAMETER;
2112 sock_fd = pc->cb_info->fd;
2116 muse_recorder_msg_send1(api,
2121 LOGD("ret : 0x%x", ret);
2126 int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte)
2128 if (recorder == NULL) {
2129 LOGE("NULL pointer handle");
2130 return RECORDER_ERROR_INVALID_PARAMETER;
2132 if (kbyte == NULL) {
2133 LOGE("NULL pointer kbyte");
2134 return RECORDER_ERROR_INVALID_PARAMETER;
2136 int ret = RECORDER_ERROR_NONE;
2137 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT;
2138 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2140 if (pc->cb_info == NULL) {
2141 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2142 return RECORDER_ERROR_INVALID_PARAMETER;
2144 sock_fd = pc->cb_info->fd;
2149 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2150 if (ret == RECORDER_ERROR_NONE) {
2151 muse_recorder_msg_get(get_kbyte, pc->cb_info->recv_msg);
2154 LOGD("ret : 0x%x", ret);
2159 int recorder_attr_get_time_limit(recorder_h recorder, int *second)
2161 if (recorder == NULL) {
2162 LOGE("NULL pointer handle");
2163 return RECORDER_ERROR_INVALID_PARAMETER;
2165 if (second == NULL) {
2166 LOGE("NULL pointer second");
2167 return RECORDER_ERROR_INVALID_PARAMETER;
2169 int ret = RECORDER_ERROR_NONE;
2170 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT;
2171 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2173 if (pc->cb_info == NULL) {
2174 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2175 return RECORDER_ERROR_INVALID_PARAMETER;
2177 sock_fd = pc->cb_info->fd;
2182 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2183 if (ret == RECORDER_ERROR_NONE) {
2184 muse_recorder_msg_get(get_second, pc->cb_info->recv_msg);
2185 *second = get_second;
2187 LOGD("ret : 0x%x", ret);
2192 int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device)
2194 if (recorder == NULL) {
2195 LOGE("NULL pointer handle");
2196 return RECORDER_ERROR_INVALID_PARAMETER;
2198 if (device == NULL) {
2199 LOGE("NULL pointer device");
2200 return RECORDER_ERROR_INVALID_PARAMETER;
2202 int ret = RECORDER_ERROR_NONE;
2203 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE;
2204 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2206 if (pc->cb_info == NULL) {
2207 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2208 return RECORDER_ERROR_INVALID_PARAMETER;
2210 sock_fd = pc->cb_info->fd;
2215 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2216 if (ret == RECORDER_ERROR_NONE) {
2217 muse_recorder_msg_get(get_device, pc->cb_info->recv_msg);
2218 *device = (recorder_audio_device_e)get_device;
2221 LOGD("ret : 0x%x", ret);
2226 int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate)
2228 if (recorder == NULL) {
2229 LOGE("NULL pointer handle");
2230 return RECORDER_ERROR_INVALID_PARAMETER;
2232 if (samplerate == NULL) {
2233 LOGE("NULL pointer handle");
2234 return RECORDER_ERROR_INVALID_PARAMETER;
2236 int ret = RECORDER_ERROR_NONE;
2237 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE;
2238 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2240 if (pc->cb_info == NULL) {
2241 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2242 return RECORDER_ERROR_INVALID_PARAMETER;
2244 sock_fd = pc->cb_info->fd;
2249 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2250 if (ret == RECORDER_ERROR_NONE) {
2251 muse_recorder_msg_get(get_samplerate, pc->cb_info->recv_msg);
2252 *samplerate = get_samplerate;
2254 LOGD("ret : 0x%x, get_samplerate : %d", ret, get_samplerate);
2259 int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate)
2261 if (recorder == NULL) {
2262 LOGE("NULL pointer handle");
2263 return RECORDER_ERROR_INVALID_PARAMETER;
2265 if (bitrate == NULL) {
2266 LOGE("NULL pointer");
2267 return RECORDER_ERROR_INVALID_PARAMETER;
2269 int ret = RECORDER_ERROR_NONE;
2270 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE;
2271 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2273 if (pc->cb_info == NULL) {
2274 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2275 return RECORDER_ERROR_INVALID_PARAMETER;
2277 sock_fd = pc->cb_info->fd;
2282 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2283 if (ret == RECORDER_ERROR_NONE) {
2284 muse_recorder_msg_get(get_bitrate, pc->cb_info->recv_msg);
2285 *bitrate = get_bitrate;
2287 LOGD("ret : 0x%x", ret);
2292 int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate)
2294 if (recorder == NULL) {
2295 LOGE("NULL pointer handle");
2296 return RECORDER_ERROR_INVALID_PARAMETER;
2298 if (bitrate == NULL) {
2299 LOGE("NULL pointer");
2300 return RECORDER_ERROR_INVALID_PARAMETER;
2302 int ret = RECORDER_ERROR_NONE;
2303 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE;
2304 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2306 if (pc->cb_info == NULL) {
2307 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2308 return RECORDER_ERROR_INVALID_PARAMETER;
2310 sock_fd = pc->cb_info->fd;
2315 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2316 if (ret == RECORDER_ERROR_NONE) {
2317 muse_recorder_msg_get(get_bitrate, pc->cb_info->recv_msg);
2318 *bitrate = get_bitrate;
2320 LOGD("ret : 0x%x", ret);
2325 int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb, void *user_data)
2327 if (recorder == NULL || foreach_cb == NULL) {
2328 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2329 return RECORDER_ERROR_INVALID_PARAMETER;
2331 int ret = RECORDER_ERROR_NONE;
2333 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2334 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_AUDIO_ENCODER;
2336 LOGD("Enter, handle :%x", pc->remote_handle);
2339 if (pc->cb_info == NULL) {
2340 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2341 return RECORDER_ERROR_INVALID_PARAMETER;
2343 sock_fd = pc->cb_info->fd;
2344 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = foreach_cb;
2345 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = user_data;
2347 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2348 LOGD("ret : 0x%x", ret);
2353 int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb, void *user_data)
2355 if (recorder == NULL || foreach_cb == NULL) {
2356 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2357 return RECORDER_ERROR_INVALID_PARAMETER;
2359 int ret = RECORDER_ERROR_NONE;
2361 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2362 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_ENCODER;
2364 LOGD("Enter, handle :%x", pc->remote_handle);
2367 if (pc->cb_info == NULL) {
2368 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2369 return RECORDER_ERROR_INVALID_PARAMETER;
2371 sock_fd = pc->cb_info->fd;
2372 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = foreach_cb;
2373 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = user_data;
2375 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2376 LOGD("ret : 0x%x", ret);
2381 int recorder_attr_set_mute(recorder_h recorder, bool enable)
2383 if (recorder == NULL) {
2384 LOGE("NULL pointer handle");
2385 return RECORDER_ERROR_INVALID_PARAMETER;
2387 int ret = RECORDER_ERROR_NONE;
2388 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_MUTE;
2389 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2391 if (pc->cb_info == NULL) {
2392 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2393 return RECORDER_ERROR_INVALID_PARAMETER;
2395 sock_fd = pc->cb_info->fd;
2396 int set_enable = (int)enable;
2400 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
2402 LOGD("ret : 0x%x", ret);
2408 bool recorder_attr_is_muted(recorder_h recorder)
2410 if (recorder == NULL) {
2411 LOGE("NULL pointer handle");
2414 int ret = RECORDER_ERROR_NONE;
2415 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_IS_MUTED;
2416 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2418 if (pc->cb_info == NULL) {
2419 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2420 return RECORDER_ERROR_INVALID_PARAMETER;
2422 sock_fd = pc->cb_info->fd;
2426 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2427 LOGD("ret : 0x%x", ret);
2432 int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate)
2434 if (recorder == NULL) {
2435 LOGE("NULL pointer handle");
2436 return RECORDER_ERROR_INVALID_PARAMETER;
2438 int ret = RECORDER_ERROR_NONE;
2439 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_RECORDING_MOTION_RATE;
2440 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2442 if (pc->cb_info == NULL) {
2443 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2444 return RECORDER_ERROR_INVALID_PARAMETER;
2446 sock_fd = pc->cb_info->fd;
2448 LOGD("ENTER - %.20lf", rate);
2450 muse_recorder_msg_send1(api,
2456 LOGD("ret : 0x%x", ret);
2462 int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate)
2464 if (recorder == NULL) {
2465 LOGE("NULL pointer handle");
2466 return RECORDER_ERROR_INVALID_PARAMETER;
2469 LOGE("rate is NULL");
2470 return RECORDER_ERROR_INVALID_PARAMETER;
2472 int ret = RECORDER_ERROR_NONE;
2473 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE;
2474 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2476 if (pc->cb_info == NULL) {
2477 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2478 return RECORDER_ERROR_INVALID_PARAMETER;
2480 sock_fd = pc->cb_info->fd;
2485 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2486 if (ret == RECORDER_ERROR_NONE) {
2487 muse_recorder_msg_get_double(get_rate, pc->cb_info->recv_msg);
2490 LOGD("ret : 0x%x - rate %.20lf", ret, *rate);
2495 int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count)
2497 if (recorder == NULL) {
2498 LOGE("NULL pointer handle");
2499 return RECORDER_ERROR_INVALID_PARAMETER;
2501 if (channel_count < 1) {
2502 LOGE("invalid channel %d", channel_count);
2503 return RECORDER_ERROR_INVALID_PARAMETER;
2505 int ret = RECORDER_ERROR_NONE;
2506 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_CHANNEL;
2507 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2509 if (pc->cb_info == NULL) {
2510 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2511 return RECORDER_ERROR_INVALID_PARAMETER;
2513 sock_fd = pc->cb_info->fd;
2517 muse_recorder_msg_send1(api,
2521 INT, channel_count);
2522 LOGD("ret : 0x%x", ret);
2527 int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count)
2529 if (recorder == NULL) {
2530 LOGE("NULL pointer handle");
2531 return RECORDER_ERROR_INVALID_PARAMETER;
2533 if (channel_count == NULL) {
2534 LOGE("channel_count is NULL");
2535 return RECORDER_ERROR_INVALID_PARAMETER;
2537 int ret = RECORDER_ERROR_NONE;
2538 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL;
2539 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2541 if (pc->cb_info == NULL) {
2542 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2543 return RECORDER_ERROR_INVALID_PARAMETER;
2545 sock_fd = pc->cb_info->fd;
2546 int get_channel_count;
2550 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2551 if (ret == RECORDER_ERROR_NONE) {
2552 muse_recorder_msg_get(get_channel_count, pc->cb_info->recv_msg);
2553 *channel_count = get_channel_count;
2555 LOGD("ret : 0x%x", ret);
2560 int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation)
2562 if (recorder == NULL) {
2563 LOGE("NULL pointer handle");
2564 return RECORDER_ERROR_INVALID_PARAMETER;
2566 if (orientation > RECORDER_ROTATION_270) {
2567 LOGE("invalid orientation %d", orientation);
2568 return RECORDER_ERROR_INVALID_PARAMETER;
2570 int ret = RECORDER_ERROR_NONE;
2571 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_ORIENTATION_TAG;
2572 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2574 if (pc->cb_info == NULL) {
2575 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2576 return RECORDER_ERROR_INVALID_PARAMETER;
2578 sock_fd = pc->cb_info->fd;
2579 int set_orientation = (int)orientation;
2583 muse_recorder_msg_send1(api,
2587 INT, set_orientation);
2588 LOGD("ret : 0x%x", ret);
2593 int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation)
2595 if (recorder == NULL) {
2596 LOGE("NULL pointer handle");
2597 return RECORDER_ERROR_INVALID_PARAMETER;
2599 if (orientation == NULL) {
2600 LOGE("orientation is NULL");
2601 return RECORDER_ERROR_INVALID_PARAMETER;
2603 int ret = RECORDER_ERROR_NONE;
2604 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG;
2605 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2607 if (pc->cb_info == NULL) {
2608 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2609 return RECORDER_ERROR_INVALID_PARAMETER;
2611 sock_fd = pc->cb_info->fd;
2612 int get_orientation;
2616 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2617 if (ret == RECORDER_ERROR_NONE) {
2618 muse_recorder_msg_get(get_orientation, pc->cb_info->recv_msg);
2619 *orientation = (recorder_rotation_e)get_orientation;
2621 LOGD("ret : 0x%x", ret);