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");
368 g_list_free(cb_info->idle_event_list);
369 cb_info->idle_event_list = NULL;
372 g_mutex_unlock(&cb_info->idle_event_mutex);
378 static void *_recorder_msg_handler_func(gpointer data)
384 recorder_message_s *rec_msg = NULL;
385 recorder_idle_event_s *rec_idle_event = NULL;
386 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
388 if (cb_info == NULL) {
389 LOGE("cb_info NULL");
395 g_mutex_lock(&cb_info->msg_handler_mutex);
397 while (g_atomic_int_get(&cb_info->msg_handler_running)) {
398 if (g_queue_is_empty(cb_info->msg_queue)) {
399 LOGD("signal wait...");
400 g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
401 LOGD("signal received");
403 if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
404 LOGD("stop event thread");
409 rec_msg = (recorder_message_s *)g_queue_pop_head(cb_info->msg_queue);
411 g_mutex_unlock(&cb_info->msg_handler_mutex);
413 if (rec_msg == NULL) {
414 LOGE("NULL message");
415 g_mutex_lock(&cb_info->msg_handler_mutex);
421 if (api < MUSE_RECORDER_API_MAX) {
422 g_mutex_lock(&cb_info->api_mutex[api]);
424 if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
425 cb_info->api_ret[api] = ret;
426 cb_info->api_activating[api] = 1;
428 LOGD("recorder api %d - return 0x%x", ret);
430 g_cond_signal(&cb_info->api_cond[api]);
432 LOGE("failed to get ret for api %d, msg %s", rec_msg->api, rec_msg->recv_msg);
435 g_mutex_unlock(&cb_info->api_mutex[api]);
436 } else if (api == MUSE_RECORDER_CB_EVENT) {
440 if (!muse_recorder_msg_get(event, rec_msg->recv_msg) ||
441 !muse_recorder_msg_get(event_class, rec_msg->recv_msg)) {
442 LOGE("failed to get recorder event %d, class %d", event, event_class);
447 g_mutex_lock(&cb_info->msg_handler_mutex);
451 switch (event_class) {
452 case MUSE_RECORDER_EVENT_CLASS_THREAD_SUB:
453 _client_user_callback(cb_info, rec_msg->recv_msg, event);
455 case MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN:
456 rec_idle_event = (recorder_idle_event_s *)malloc(sizeof(recorder_idle_event_s));
457 if (rec_idle_event == NULL) {
458 LOGE("rec_idle_event alloc failed");
462 rec_idle_event->event = event;
463 rec_idle_event->cb_info = cb_info;
464 g_mutex_init(&rec_idle_event->event_mutex);
465 memcpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg));
467 LOGD("add recorder event[%d, %p] to IDLE", event, rec_idle_event);
469 g_mutex_lock(&cb_info->idle_event_mutex);
470 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)rec_idle_event);
471 g_mutex_unlock(&cb_info->idle_event_mutex);
473 g_idle_add_full(G_PRIORITY_DEFAULT,
474 (GSourceFunc)_recorder_idle_event_callback,
475 (gpointer)rec_idle_event,
479 LOGE("unknown recorder event class %d", event_class);
483 LOGE("unknown recorder api[%d] message", api);
489 g_mutex_lock(&cb_info->msg_handler_mutex);
492 /* remove remained event */
493 while (!g_queue_is_empty(cb_info->msg_queue)) {
494 rec_msg = (recorder_message_s *)g_queue_pop_head(cb_info->msg_queue);
496 LOGD("remove recorder message %p", rec_msg);
500 LOGW("NULL recorder message");
504 g_mutex_unlock(&cb_info->msg_handler_mutex);
512 static void *_recorder_msg_recv_func(gpointer data)
521 char *recv_msg = NULL;
522 char **parse_str = NULL;
523 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
525 if (cb_info == NULL) {
526 LOGE("cb_info NULL");
532 parse_str = (char **)malloc(sizeof(char *) * RECORDER_PARSE_STRING_SIZE);
533 if (parse_str == NULL) {
534 LOGE("parse_str malloc failed");
538 for (i = 0 ; i < RECORDER_PARSE_STRING_SIZE ; i++) {
539 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
540 if (parse_str[i] == NULL) {
541 LOGE("parse_str[%d] malloc failed", i);
542 goto CB_HANDLER_EXIT;
546 recv_msg = cb_info->recv_msg;
548 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
549 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
552 recv_msg[ret] = '\0';
558 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
560 /* Need to split the combined entering msgs.
561 This module supports up to 200 combined msgs. */
562 for (str_pos = 0; str_pos < ret; str_pos++) {
563 if(recv_msg[str_pos] == '}') {
564 memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
565 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
566 LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);
567 prev_pos = str_pos+1;
572 /*LOGD("num_token : %d", num_token);*/
574 /* Re-construct to the useful single msg. */
575 for (i = 0; i < num_token; i++) {
576 if (i >= RECORDER_PARSE_STRING_SIZE) {
577 LOGE("invalid token index %d", i);
584 if (!muse_recorder_msg_get(api, parse_str[i])) {
585 LOGE("failed to get recorder api");
589 if (muse_recorder_msg_get(api_class, parse_str[i])) {
590 LOGD("recorder api_class[%d]", api_class);
593 if (api_class == MUSE_RECORDER_API_CLASS_IMMEDIATE) {
594 g_mutex_lock(&cb_info->api_mutex[api]);
596 if (!muse_recorder_msg_get(ret, parse_str[i])) {
597 LOGE("failed to get recorder ret");
598 g_mutex_unlock(&cb_info->api_mutex[api]);
602 cb_info->api_ret[api] = ret;
603 cb_info->api_activating[api] = 1;
605 if (api == MUSE_RECORDER_API_CREATE) {
606 if (ret != RECORDER_ERROR_NONE) {
607 g_atomic_int_set(&cb_info->msg_recv_running, 0);
608 LOGE("recorder create error 0x%x. close client cb handler", ret);
610 } else if (api == MUSE_RECORDER_API_DESTROY) {
611 if (ret == RECORDER_ERROR_NONE) {
612 g_atomic_int_set(&cb_info->msg_recv_running, 0);
613 LOGD("recorder destroy done. close client cb handler");
617 g_cond_signal(&cb_info->api_cond[api]);
618 g_mutex_unlock(&cb_info->api_mutex[api]);
619 } else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB ||
620 api == MUSE_RECORDER_CB_EVENT) {
621 recorder_message_s *rec_msg = g_new0(recorder_message_s, 1);
622 if (rec_msg == NULL) {
623 LOGE("failed to alloc rec_msg");
628 memcpy(rec_msg->recv_msg, parse_str[i], sizeof(rec_msg->recv_msg));
630 LOGD("add recorder message to queue : api %d", api);
632 g_mutex_lock(&cb_info->msg_handler_mutex);
633 g_queue_push_tail(cb_info->msg_queue, (gpointer)rec_msg);
634 g_cond_signal(&cb_info->msg_handler_cond);
635 g_mutex_unlock(&cb_info->msg_handler_mutex);
637 LOGW("unknown recorder api %d and api_class %d", api, api_class);
642 LOGD("client cb exit");
646 for (i = 0 ; i < RECORDER_PARSE_STRING_SIZE ; i++) {
660 static recorder_cb_info_s *_client_callback_new(gint sockfd)
662 recorder_cb_info_s *cb_info = NULL;
663 GCond *tmp_cond = NULL;
664 GMutex *tmp_mutex = NULL;
665 gint *tmp_activating = NULL;
666 gint *tmp_ret = NULL;
668 g_return_val_if_fail(sockfd > 0, NULL);
670 cb_info = g_new0(recorder_cb_info_s, 1);
671 if (cb_info == NULL) {
672 LOGE("cb_info failed");
676 g_mutex_init(&cb_info->msg_handler_mutex);
677 g_cond_init(&cb_info->msg_handler_cond);
678 g_mutex_init(&cb_info->idle_event_mutex);
679 g_cond_init(&cb_info->idle_event_cond);
681 tmp_cond = g_new0(GCond, MUSE_RECORDER_API_MAX);
682 if (tmp_cond == NULL) {
683 LOGE("tmp_cond failed");
687 tmp_mutex = g_new0(GMutex, MUSE_RECORDER_API_MAX);
688 if (tmp_mutex == NULL) {
689 LOGE("tmp_mutex failed");
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_cond = tmp_cond;
723 cb_info->api_mutex = tmp_mutex;
724 cb_info->api_activating = tmp_activating;
725 cb_info->api_ret = tmp_ret;
727 g_atomic_int_set(&cb_info->msg_recv_running, 1);
728 cb_info->msg_recv_thread = g_thread_try_new("recorder_msg_recv",
729 _recorder_msg_recv_func,
732 if (cb_info->msg_recv_thread == NULL) {
733 LOGE("message receive thread creation failed");
741 if (cb_info->msg_handler_thread) {
742 g_mutex_lock(&cb_info->msg_handler_mutex);
743 g_atomic_int_set(&cb_info->msg_handler_running, 0);
744 g_cond_signal(&cb_info->msg_handler_cond);
745 g_mutex_unlock(&cb_info->msg_handler_mutex);
747 g_thread_join(cb_info->msg_handler_thread);
748 g_thread_unref(cb_info->msg_handler_thread);
749 cb_info->msg_handler_thread = NULL;
752 g_mutex_clear(&cb_info->msg_handler_mutex);
753 g_cond_clear(&cb_info->msg_handler_cond);
754 g_mutex_clear(&cb_info->idle_event_mutex);
755 g_cond_clear(&cb_info->idle_event_cond);
757 if (cb_info->msg_queue) {
758 g_queue_free(cb_info->msg_queue);
759 cb_info->msg_queue = NULL;
774 if (tmp_activating) {
775 g_free(tmp_activating);
776 tmp_activating = NULL;
786 static int client_wait_for_cb_return(muse_recorder_api_e api, recorder_cb_info_s *cb_info, int time_out)
788 int ret = RECORDER_ERROR_NONE;
791 LOGD("Enter api : %d", api);
793 g_mutex_lock(&(cb_info->api_mutex[api]));
795 if (cb_info->api_activating[api] == 0) {
796 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
797 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
798 ret = cb_info->api_ret[api];
799 cb_info->api_activating[api] = 0;
801 LOGD("return value : 0x%x", ret);
803 ret = RECORDER_ERROR_INVALID_OPERATION;
805 LOGE("api %d was TIMED OUT!", api);
808 ret = cb_info->api_ret[api];
809 cb_info->api_activating[api] = 0;
811 LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);
814 g_mutex_unlock(&(cb_info->api_mutex[api]));
819 static void _client_callback_destroy(recorder_cb_info_s *cb_info)
821 g_return_if_fail(cb_info != NULL);
823 LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
825 g_thread_join(cb_info->msg_recv_thread);
826 g_thread_unref(cb_info->msg_recv_thread);
827 cb_info->msg_recv_thread = NULL;
829 LOGD("msg thread removed");
831 g_mutex_lock(&cb_info->msg_handler_mutex);
832 g_atomic_int_set(&cb_info->msg_handler_running, 0);
833 g_cond_signal(&cb_info->msg_handler_cond);
834 g_mutex_unlock(&cb_info->msg_handler_mutex);
836 g_thread_join(cb_info->msg_handler_thread);
837 g_thread_unref(cb_info->msg_handler_thread);
838 cb_info->msg_handler_thread = NULL;
840 g_queue_free(cb_info->msg_queue);
841 cb_info->msg_queue = NULL;
842 g_mutex_clear(&cb_info->msg_handler_mutex);
843 g_cond_clear(&cb_info->msg_handler_cond);
844 g_mutex_clear(&cb_info->idle_event_mutex);
845 g_cond_clear(&cb_info->idle_event_cond);
847 LOGD("event thread removed");
849 if (cb_info->bufmgr) {
850 tbm_bufmgr_deinit(cb_info->bufmgr);
851 cb_info->bufmgr = NULL;
853 if (cb_info->api_cond) {
854 g_free(cb_info->api_cond);
855 cb_info->api_cond = NULL;
857 if (cb_info->api_mutex) {
858 g_free(cb_info->api_mutex);
859 cb_info->api_mutex = 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_create_common(recorder_h *recorder, muse_recorder_type_e type, camera_h camera)
878 int ret = RECORDER_ERROR_NONE;
879 int destroy_ret = RECORDER_ERROR_NONE;
881 char *send_msg = NULL;
882 char *root_directory = NULL;
883 intptr_t camera_handle = 0;
885 tbm_bufmgr bufmgr = NULL;
886 recorder_cli_s *pc = NULL;
888 LOGD("Enter - type %d", type);
890 if (recorder == NULL) {
891 LOGE("NULL pointer for recorder handle");
892 return RECORDER_ERROR_INVALID_PARAMETER;
895 if (type == MUSE_RECORDER_TYPE_VIDEO && camera == NULL) {
896 LOGE("NULL pointer for camera handle on video recorder mode");
897 return RECORDER_ERROR_INVALID_PARAMETER;
900 bufmgr = tbm_bufmgr_init(-1);
901 if (bufmgr == NULL) {
902 LOGE("get tbm bufmgr failed");
903 return RECORDER_ERROR_INVALID_OPERATION;
906 pc = g_new0(recorder_cli_s, 1);
908 ret = RECORDER_ERROR_OUT_OF_MEMORY;
909 goto _ERR_RECORDER_EXIT;
912 sock_fd = muse_core_client_new();
914 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
915 ret = RECORDER_ERROR_INVALID_OPERATION;
916 goto _ERR_RECORDER_EXIT;
919 if (type == MUSE_RECORDER_TYPE_AUDIO) {
920 send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
921 MUSE_TYPE_INT, "module", MUSE_RECORDER,
922 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_AUDIO,
923 MUSE_TYPE_INT, "pid", getpid(),
926 camera_handle = (intptr_t)((camera_cli_s *)camera)->remote_handle;
927 send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
928 MUSE_TYPE_INT, "module", MUSE_RECORDER,
929 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_VIDEO,
930 MUSE_TYPE_POINTER, "camera_handle", camera_handle,
934 LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
936 muse_core_ipc_send_msg(sock_fd, send_msg);
937 muse_core_msg_json_factory_free(send_msg);
939 pc->cb_info = _client_callback_new(sock_fd);
940 if (pc->cb_info == NULL) {
941 ret = RECORDER_ERROR_OUT_OF_MEMORY;
942 goto _ERR_RECORDER_EXIT;
945 ret = client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, CALLBACK_TIME_OUT);
946 if (ret == RECORDER_ERROR_NONE) {
947 muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
949 LOGE("Receiving Handle Failed!!");
950 goto _ERR_RECORDER_EXIT;
953 if (mm_camcorder_client_get_root_directory(&root_directory) != MM_ERROR_NONE ||
954 root_directory == NULL) {
955 LOGE("failed to get root directory of internal storage");
956 ret = RECORDER_ERROR_INVALID_OPERATION;
957 goto _ERR_RECORDER_AFTER_CREATE;
960 LOGD("set root directory [%s]", root_directory);
962 muse_recorder_msg_send1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY,
963 sock_fd, pc->cb_info, ret, STRING, root_directory);
964 if (ret != RECORDER_ERROR_NONE) {
965 LOGE("failed to set root directory %s", root_directory);
966 ret = RECORDER_ERROR_INVALID_OPERATION;
967 goto _ERR_RECORDER_AFTER_CREATE;
970 free(root_directory);
971 root_directory = NULL;
973 pc->remote_handle = handle;
974 pc->cb_info->bufmgr = bufmgr;
976 LOGD("recorder[type %d] %p create success : remote handle 0x%x",
977 type, pc, pc->remote_handle);
979 *recorder = (recorder_h) pc;
981 goto _ERR_RECORDER_EXIT;
986 return RECORDER_ERROR_NONE;
988 _ERR_RECORDER_AFTER_CREATE:
989 muse_recorder_msg_send(MUSE_RECORDER_API_DESTROY, sock_fd, pc->cb_info, destroy_ret);
990 LOGE("destroy return 0x%x", destroy_ret);
993 tbm_bufmgr_deinit(bufmgr);
996 if (root_directory) {
997 free(root_directory);
998 root_directory = NULL;
1003 _client_callback_destroy(pc->cb_info);
1013 int recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
1015 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_VIDEO, camera);
1019 int recorder_create_audiorecorder(recorder_h *recorder)
1021 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_AUDIO, NULL);
1024 int recorder_get_state(recorder_h recorder, recorder_state_e *state)
1026 if (recorder == NULL) {
1027 LOGE("NULL pointer handle");
1028 return RECORDER_ERROR_INVALID_PARAMETER;
1030 if (state == NULL) {
1031 LOGE("NULL pointer state");
1032 return RECORDER_ERROR_INVALID_PARAMETER;
1035 int ret = RECORDER_ERROR_NONE;
1037 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1038 muse_recorder_api_e api = MUSE_RECORDER_API_GET_STATE;
1040 if (pc->cb_info == NULL) {
1041 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1042 return RECORDER_ERROR_INVALID_PARAMETER;
1044 sock_fd = pc->cb_info->fd;
1047 LOGD("Enter, remote_handle : %x", pc->remote_handle);
1049 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1051 if (ret == RECORDER_ERROR_NONE) {
1052 muse_recorder_msg_get(get_state, pc->cb_info->recv_msg);
1053 *state = (recorder_state_e)get_state;
1056 LOGD("ret : 0x%x, get_state : %d", ret, get_state);
1062 int recorder_destroy(recorder_h recorder)
1064 if (recorder == NULL) {
1065 LOGE("NULL pointer handle");
1066 return RECORDER_ERROR_INVALID_PARAMETER;
1068 int ret = RECORDER_ERROR_NONE;
1069 muse_recorder_api_e api = MUSE_RECORDER_API_DESTROY;
1070 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1072 if (pc->cb_info == NULL) {
1073 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1074 return RECORDER_ERROR_INVALID_PARAMETER;
1076 sock_fd = pc->cb_info->fd;
1081 return RECORDER_ERROR_INVALID_OPERATION;
1082 } else if (pc->cb_info == NULL) {
1083 return RECORDER_ERROR_INVALID_OPERATION;
1086 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1087 if (ret == RECORDER_ERROR_NONE) {
1088 _recorder_remove_idle_event_all(pc->cb_info);
1089 _client_callback_destroy(pc->cb_info);
1094 LOGD("ret : 0x%x", ret);
1100 int recorder_prepare(recorder_h recorder)
1102 if (recorder == NULL) {
1103 LOGE("NULL pointer handle");
1104 return RECORDER_ERROR_INVALID_PARAMETER;
1107 int ret = RECORDER_ERROR_NONE;
1108 muse_recorder_api_e api = MUSE_RECORDER_API_PREPARE;
1109 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1111 if (pc->cb_info == NULL) {
1112 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1113 return RECORDER_ERROR_INVALID_PARAMETER;
1115 sock_fd = pc->cb_info->fd;
1119 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1121 LOGD("ret : 0x%x", ret);
1127 int recorder_unprepare(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_UNPREPARE;
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_start(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_START;
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_pause(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_PAUSE;
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_commit(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_COMMIT;
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_cancel(recorder_h recorder)
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_CANCEL;
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_send(api, sock_fd, pc->cb_info, ret);
1242 LOGD("ret : 0x%x", ret);
1247 int recorder_set_video_resolution(recorder_h recorder, int width, int height)
1249 if (recorder == NULL) {
1250 LOGE("NULL pointer handle");
1251 return RECORDER_ERROR_INVALID_PARAMETER;
1253 int ret = RECORDER_ERROR_NONE;
1254 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION;
1255 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1257 if (pc->cb_info == NULL) {
1258 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1259 return RECORDER_ERROR_INVALID_PARAMETER;
1261 sock_fd = pc->cb_info->fd;
1265 muse_recorder_msg_send2(api,
1271 LOGD("ret : 0x%x", ret);
1276 int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
1278 if (recorder == NULL) {
1279 LOGE("NULL pointer handle");
1280 return RECORDER_ERROR_INVALID_PARAMETER;
1282 if (!width || !height) {
1283 LOGE("NULL pointer width = [%p], height = [%p]", width, height);
1284 return RECORDER_ERROR_INVALID_PARAMETER;
1286 int ret = RECORDER_ERROR_NONE;
1287 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_RESOLUTION;
1288 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1290 if (pc->cb_info == NULL) {
1291 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1292 return RECORDER_ERROR_INVALID_PARAMETER;
1294 sock_fd = pc->cb_info->fd;
1300 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1301 if (ret == RECORDER_ERROR_NONE) {
1302 muse_recorder_msg_get(get_width, pc->cb_info->recv_msg);
1303 muse_recorder_msg_get(get_height, pc->cb_info->recv_msg);
1305 *height = get_height;
1307 LOGD("ret : 0x%x", ret);
1312 int recorder_foreach_supported_video_resolution(recorder_h recorder,
1313 recorder_supported_video_resolution_cb foreach_cb, void *user_data)
1315 if( recorder == NULL || foreach_cb == NULL){
1316 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1317 return RECORDER_ERROR_INVALID_PARAMETER;
1319 int ret = RECORDER_ERROR_NONE;
1321 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1322 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_RESOLUTION;
1324 LOGD("Enter, handle :%x", pc->remote_handle);
1327 if (pc->cb_info == NULL) {
1328 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1329 return RECORDER_ERROR_INVALID_PARAMETER;
1331 sock_fd = pc->cb_info->fd;
1332 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
1333 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
1335 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1336 LOGD("ret : 0x%x", ret);
1341 int recorder_get_audio_level(recorder_h recorder, double *level)
1343 if (recorder == NULL || level == NULL) {
1344 LOGE("NULL pointer %p %p", recorder, level);
1345 return RECORDER_ERROR_INVALID_PARAMETER;
1348 int ret = RECORDER_ERROR_NONE;
1349 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_LEVEL;
1350 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1352 if (pc->cb_info == NULL) {
1353 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1354 return RECORDER_ERROR_INVALID_PARAMETER;
1356 sock_fd = pc->cb_info->fd;
1361 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1362 if (ret == RECORDER_ERROR_NONE) {
1363 muse_recorder_msg_get_double(get_level, pc->cb_info->recv_msg);
1366 LOGD("ret : 0x%x", ret);
1371 int recorder_set_filename(recorder_h recorder, const char *filename)
1373 if (recorder == NULL) {
1374 LOGE("handle is NULL");
1375 return RECORDER_ERROR_INVALID_PARAMETER;
1378 if (filename == NULL) {
1379 LOGE("filename is NULL");
1380 return RECORDER_ERROR_INVALID_PARAMETER;
1382 int ret = RECORDER_ERROR_NONE;
1383 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
1384 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1386 if (pc->cb_info == NULL) {
1387 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1388 return RECORDER_ERROR_INVALID_PARAMETER;
1390 sock_fd = pc->cb_info->fd;
1394 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, filename);
1395 LOGD("ret : 0x%x", ret);
1400 int recorder_get_filename(recorder_h recorder, char **filename)
1402 if (recorder == NULL) {
1403 LOGE("handle is NULL");
1404 return RECORDER_ERROR_INVALID_PARAMETER;
1407 if (filename == NULL) {
1408 LOGE("filename is NULL");
1409 return RECORDER_ERROR_INVALID_PARAMETER;
1411 int ret = RECORDER_ERROR_NONE;
1412 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILENAME;
1413 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1415 if (pc->cb_info == NULL) {
1416 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1417 return RECORDER_ERROR_INVALID_PARAMETER;
1419 sock_fd = pc->cb_info->fd;
1420 char get_filename[MUSE_RECORDER_MSG_MAX_LENGTH] = {0,};
1424 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1426 if (ret == RECORDER_ERROR_NONE) {
1427 muse_recorder_msg_get_string(get_filename, pc->cb_info->recv_msg);
1428 *filename = strdup(get_filename);
1430 LOGD("ret : 0x%x, filename : %s", ret, *filename);
1435 int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
1437 if (recorder == NULL) {
1438 LOGE("NULL pointer handle");
1439 return RECORDER_ERROR_INVALID_PARAMETER;
1441 if (format < RECORDER_FILE_FORMAT_3GP || format > RECORDER_FILE_FORMAT_OGG) {
1442 LOGE("invalid format %d", format);
1443 return RECORDER_ERROR_INVALID_PARAMETER;
1445 int ret = RECORDER_ERROR_NONE;
1446 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT;
1447 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1449 if (pc->cb_info == NULL) {
1450 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1451 return RECORDER_ERROR_INVALID_PARAMETER;
1453 sock_fd = pc->cb_info->fd;
1454 int set_format = (int)format;
1456 LOGD("ENTER, set_format : %d", set_format);
1458 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
1459 LOGD("ret : 0x%x", ret);
1464 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format)
1466 if (recorder == NULL) {
1467 LOGE("NULL pointer handle");
1468 return RECORDER_ERROR_INVALID_PARAMETER;
1470 if (format == NULL) {
1471 LOGE("NULL pointer data");
1472 return RECORDER_ERROR_INVALID_PARAMETER;
1474 int ret = RECORDER_ERROR_NONE;
1475 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILE_FORMAT;
1476 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1478 if (pc->cb_info == NULL) {
1479 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1480 return RECORDER_ERROR_INVALID_PARAMETER;
1482 sock_fd = pc->cb_info->fd;
1487 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1489 if (ret == RECORDER_ERROR_NONE) {
1490 muse_recorder_msg_get(get_format, pc->cb_info->recv_msg);
1491 LOGD("get_fileformat : %d", get_format);
1492 *format = (recorder_file_format_e)get_format;
1494 LOGD("ret : 0x%x", ret);
1499 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data)
1501 if( recorder == NULL || callback == NULL){
1502 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1503 return RECORDER_ERROR_INVALID_PARAMETER;
1505 int ret = RECORDER_ERROR_NONE;
1507 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1508 muse_recorder_api_e api = MUSE_RECORDER_API_SET_STATE_CHANGED_CB;
1510 LOGD("Enter, handle :%x", pc->remote_handle);
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;
1518 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
1519 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
1521 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1522 LOGD("ret : 0x%x", ret);
1527 int recorder_unset_state_changed_cb(recorder_h recorder)
1529 if (recorder == NULL) {
1530 LOGE("NULL pointer handle");
1531 return RECORDER_ERROR_INVALID_PARAMETER;
1533 int ret = RECORDER_ERROR_NONE;
1534 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB;
1535 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1537 if (pc->cb_info == NULL) {
1538 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1539 return RECORDER_ERROR_INVALID_PARAMETER;
1541 sock_fd = pc->cb_info->fd;
1545 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1546 LOGD("ret : 0x%x", ret);
1551 int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data)
1553 if( recorder == NULL || callback == NULL){
1554 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1555 return RECORDER_ERROR_INVALID_PARAMETER;
1557 int ret = RECORDER_ERROR_NONE;
1559 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1560 muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB;
1562 LOGD("Enter, handle :%x", pc->remote_handle);
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;
1570 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
1571 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
1573 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1574 LOGD("ret : 0x%x", ret);
1579 int recorder_unset_interrupted_cb(recorder_h recorder)
1581 if (recorder == NULL) {
1582 LOGE("NULL pointer handle");
1583 return RECORDER_ERROR_INVALID_PARAMETER;
1585 int ret = RECORDER_ERROR_NONE;
1586 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB;
1587 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1589 if (pc->cb_info == NULL) {
1590 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1591 return RECORDER_ERROR_INVALID_PARAMETER;
1593 sock_fd = pc->cb_info->fd;
1597 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1598 LOGD("ret : 0x%x", ret);
1603 int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data)
1605 if( recorder == NULL || callback == NULL){
1606 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1607 return RECORDER_ERROR_INVALID_PARAMETER;
1609 int ret = RECORDER_ERROR_NONE;
1611 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1612 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_STREAM_CB;
1614 LOGD("Enter, handle :%x", pc->remote_handle);
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;
1622 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
1623 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
1625 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1626 LOGD("ret : 0x%x", ret);
1631 int recorder_unset_audio_stream_cb(recorder_h recorder)
1633 if (recorder == NULL) {
1634 LOGE("NULL pointer handle");
1635 return RECORDER_ERROR_INVALID_PARAMETER;
1637 int ret = RECORDER_ERROR_NONE;
1638 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB;
1639 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1641 if (pc->cb_info == NULL) {
1642 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1643 return RECORDER_ERROR_INVALID_PARAMETER;
1645 sock_fd = pc->cb_info->fd;
1649 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1650 LOGD("ret : 0x%x", ret);
1655 int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data)
1657 if( recorder == NULL || callback == NULL){
1658 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1659 return RECORDER_ERROR_INVALID_PARAMETER;
1661 int ret = RECORDER_ERROR_NONE;
1663 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1664 muse_recorder_api_e api = MUSE_RECORDER_API_SET_ERROR_CB;
1666 LOGD("Enter, handle :%x", pc->remote_handle);
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;
1674 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
1675 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
1677 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1678 LOGD("ret : 0x%x", ret);
1683 int recorder_unset_error_cb(recorder_h recorder)
1685 if (recorder == NULL) {
1686 LOGE("NULL pointer handle");
1687 return RECORDER_ERROR_INVALID_PARAMETER;
1689 int ret = RECORDER_ERROR_NONE;
1690 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_ERROR_CB;
1691 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1693 if (pc->cb_info == NULL) {
1694 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1695 return RECORDER_ERROR_INVALID_PARAMETER;
1697 sock_fd = pc->cb_info->fd;
1701 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1702 LOGD("ret : 0x%x", ret);
1707 int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void* user_data)
1709 if( recorder == NULL || callback == NULL){
1710 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1711 return RECORDER_ERROR_INVALID_PARAMETER;
1713 int ret = RECORDER_ERROR_NONE;
1715 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1716 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_STATUS_CB;
1718 LOGD("Enter, handle :%x", pc->remote_handle);
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;
1726 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
1727 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
1729 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1730 LOGD("ret : 0x%x", ret);
1735 int recorder_unset_recording_status_cb(recorder_h recorder)
1737 if (recorder == NULL) {
1738 LOGE("NULL pointer handle");
1739 return RECORDER_ERROR_INVALID_PARAMETER;
1741 int ret = RECORDER_ERROR_NONE;
1742 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_STATUS_CB;
1743 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1745 if (pc->cb_info == NULL) {
1746 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1747 return RECORDER_ERROR_INVALID_PARAMETER;
1749 sock_fd = pc->cb_info->fd;
1753 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1754 LOGD("ret : 0x%x", ret);
1759 int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void* user_data)
1761 if( recorder == NULL || callback == NULL){
1762 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1763 return RECORDER_ERROR_INVALID_PARAMETER;
1765 int ret = RECORDER_ERROR_NONE;
1767 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1768 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_LIMIT_REACHED_CB;
1770 LOGD("Enter, handle :%x", pc->remote_handle);
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;
1778 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
1779 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
1781 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1782 LOGD("ret : 0x%x", ret);
1787 int recorder_unset_recording_limit_reached_cb(recorder_h recorder)
1789 if (recorder == NULL) {
1790 LOGE("NULL pointer handle");
1791 return RECORDER_ERROR_INVALID_PARAMETER;
1793 int ret = RECORDER_ERROR_NONE;
1794 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_LIMIT_REACHED_CB;
1795 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1797 if (pc->cb_info == NULL) {
1798 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1799 return RECORDER_ERROR_INVALID_PARAMETER;
1801 sock_fd = pc->cb_info->fd;
1805 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1806 LOGD("ret : 0x%x", ret);
1811 int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb, void *user_data)
1813 if( recorder == NULL || foreach_cb == NULL){
1814 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1815 return RECORDER_ERROR_INVALID_PARAMETER;
1817 int ret = RECORDER_ERROR_NONE;
1819 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1820 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_FILE_FORMAT;
1822 LOGD("Enter, handle :%x", pc->remote_handle);
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;
1830 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = foreach_cb;
1831 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = user_data;
1833 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1834 LOGD("ret : 0x%x", ret);
1839 int recorder_attr_set_size_limit(recorder_h recorder, int kbyte)
1841 if (recorder == NULL) {
1842 LOGE("NULL pointer handle");
1843 return RECORDER_ERROR_INVALID_PARAMETER;
1845 int ret = RECORDER_ERROR_NONE;
1846 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_SIZE_LIMIT;
1847 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1849 if (pc->cb_info == NULL) {
1850 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1851 return RECORDER_ERROR_INVALID_PARAMETER;
1853 sock_fd = pc->cb_info->fd;
1857 muse_recorder_msg_send1(api,
1862 LOGD("ret : 0x%x", ret);
1867 int recorder_attr_set_time_limit(recorder_h recorder, int second)
1869 if (recorder == NULL) {
1870 LOGE("NULL pointer handle");
1871 return RECORDER_ERROR_INVALID_PARAMETER;
1873 int ret = RECORDER_ERROR_NONE;
1874 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_TIME_LIMIT;
1875 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1877 if (pc->cb_info == NULL) {
1878 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1879 return RECORDER_ERROR_INVALID_PARAMETER;
1881 sock_fd = pc->cb_info->fd;
1885 muse_recorder_msg_send1(api,
1890 LOGD("ret : 0x%x", ret);
1895 int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device)
1897 if (recorder == NULL) {
1898 LOGE("NULL pointer handle");
1899 return RECORDER_ERROR_INVALID_PARAMETER;
1901 int ret = RECORDER_ERROR_NONE;
1902 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_DEVICE;
1903 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1905 if (pc->cb_info == NULL) {
1906 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1907 return RECORDER_ERROR_INVALID_PARAMETER;
1909 sock_fd = pc->cb_info->fd;
1910 int set_device = (int)device;
1914 muse_recorder_msg_send1(api,
1919 LOGD("ret : 0x%x", ret);
1924 int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec)
1926 if (recorder == NULL) {
1927 LOGE("NULL pointer handle");
1928 return RECORDER_ERROR_INVALID_PARAMETER;
1930 if (codec != RECORDER_AUDIO_CODEC_DISABLE &&
1931 (codec < RECORDER_AUDIO_CODEC_AMR || codec > RECORDER_AUDIO_CODEC_PCM)) {
1932 LOGE("invalid parameter : codec %d", codec);
1933 return RECORDER_ERROR_INVALID_PARAMETER;
1935 int ret = RECORDER_ERROR_NONE;
1936 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_ENCODER;
1937 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1939 if (pc->cb_info == NULL) {
1940 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1941 return RECORDER_ERROR_INVALID_PARAMETER;
1943 sock_fd = pc->cb_info->fd;
1944 int set_codec = (int)codec;
1948 muse_recorder_msg_send1(api,
1953 LOGD("ret : 0x%x", ret);
1958 int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec)
1960 if (recorder == NULL) {
1961 LOGE("NULL pointer handle");
1962 return RECORDER_ERROR_INVALID_PARAMETER;
1964 if (codec == NULL) {
1965 LOGE("codec is NULL");
1966 return RECORDER_ERROR_INVALID_PARAMETER;
1968 int ret = RECORDER_ERROR_NONE;
1969 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_ENCODER;
1970 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1972 if (pc->cb_info == NULL) {
1973 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
1974 return RECORDER_ERROR_INVALID_PARAMETER;
1976 sock_fd = pc->cb_info->fd;
1981 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1982 if (ret == RECORDER_ERROR_NONE) {
1983 muse_recorder_msg_get(get_codec, pc->cb_info->recv_msg);
1984 *codec = (recorder_audio_codec_e)get_codec;
1986 LOGD("ret : 0x%x", ret);
1991 int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec)
1993 if (recorder == NULL) {
1994 LOGE("NULL pointer handle");
1995 return RECORDER_ERROR_INVALID_PARAMETER;
1997 if (codec < RECORDER_VIDEO_CODEC_H263 || codec > RECORDER_VIDEO_CODEC_THEORA) {
1998 LOGE("invalid codec %d", codec);
1999 return RECORDER_ERROR_INVALID_PARAMETER;
2001 int ret = RECORDER_ERROR_NONE;
2002 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_ENCODER;
2003 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2005 if (pc->cb_info == NULL) {
2006 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2007 return RECORDER_ERROR_INVALID_PARAMETER;
2009 sock_fd = pc->cb_info->fd;
2010 int set_codec = (int)codec;
2014 muse_recorder_msg_send1(api,
2019 LOGD("ret : 0x%x", ret);
2024 int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec)
2026 if (recorder == NULL) {
2027 LOGE("NULL pointer handle");
2028 return RECORDER_ERROR_INVALID_PARAMETER;
2030 if (codec == NULL) {
2031 LOGE("codec is NULL");
2032 return RECORDER_ERROR_INVALID_PARAMETER;
2034 int ret = RECORDER_ERROR_NONE;
2035 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_ENCODER;
2036 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2038 if (pc->cb_info == NULL) {
2039 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2040 return RECORDER_ERROR_INVALID_PARAMETER;
2042 sock_fd = pc->cb_info->fd;
2047 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2048 if (ret == RECORDER_ERROR_NONE) {
2049 muse_recorder_msg_get(get_codec, pc->cb_info->recv_msg);
2050 *codec = (recorder_audio_codec_e)get_codec;
2052 LOGD("ret : 0x%x", ret);
2057 int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate)
2059 if (recorder == NULL) {
2060 LOGE("NULL pointer handle");
2061 return RECORDER_ERROR_INVALID_PARAMETER;
2063 if (samplerate < 1) {
2064 LOGE("invalid samplerate %d", samplerate);
2065 return RECORDER_ERROR_INVALID_PARAMETER;
2067 int ret = RECORDER_ERROR_NONE;
2068 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_SAMPLERATE;
2069 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2071 if (pc->cb_info == NULL) {
2072 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2073 return RECORDER_ERROR_INVALID_PARAMETER;
2075 sock_fd = pc->cb_info->fd;
2077 LOGD("ENTER, samplerate : %d", samplerate);
2079 muse_recorder_msg_send1(api,
2084 LOGD("ret : 0x%x, samplerate : %d", ret, samplerate);
2089 int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate)
2091 if (recorder == NULL) {
2092 LOGE("NULL pointer handle");
2093 return RECORDER_ERROR_INVALID_PARAMETER;
2096 LOGE("invalid bitrate %d", bitrate);
2097 return RECORDER_ERROR_INVALID_PARAMETER;
2099 int ret = RECORDER_ERROR_NONE;
2100 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_ENCODER_BITRATE;
2101 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2103 if (pc->cb_info == NULL) {
2104 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2105 return RECORDER_ERROR_INVALID_PARAMETER;
2107 sock_fd = pc->cb_info->fd;
2111 muse_recorder_msg_send1(api,
2116 LOGD("ret : 0x%x", ret);
2121 int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate)
2123 if (recorder == NULL) {
2124 LOGE("NULL pointer handle");
2125 return RECORDER_ERROR_INVALID_PARAMETER;
2128 int ret = RECORDER_ERROR_NONE;
2129 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_VIDEO_ENCODER_BITRATE;
2130 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2132 if (pc->cb_info == NULL) {
2133 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2134 return RECORDER_ERROR_INVALID_PARAMETER;
2136 sock_fd = pc->cb_info->fd;
2140 muse_recorder_msg_send1(api,
2145 LOGD("ret : 0x%x", ret);
2150 int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte)
2152 if (recorder == NULL) {
2153 LOGE("NULL pointer handle");
2154 return RECORDER_ERROR_INVALID_PARAMETER;
2156 if (kbyte == NULL) {
2157 LOGE("NULL pointer kbyte");
2158 return RECORDER_ERROR_INVALID_PARAMETER;
2160 int ret = RECORDER_ERROR_NONE;
2161 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT;
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;
2173 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2174 if (ret == RECORDER_ERROR_NONE) {
2175 muse_recorder_msg_get(get_kbyte, pc->cb_info->recv_msg);
2178 LOGD("ret : 0x%x", ret);
2183 int recorder_attr_get_time_limit(recorder_h recorder, int *second)
2185 if (recorder == NULL) {
2186 LOGE("NULL pointer handle");
2187 return RECORDER_ERROR_INVALID_PARAMETER;
2189 if (second == NULL) {
2190 LOGE("NULL pointer second");
2191 return RECORDER_ERROR_INVALID_PARAMETER;
2193 int ret = RECORDER_ERROR_NONE;
2194 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT;
2195 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2197 if (pc->cb_info == NULL) {
2198 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2199 return RECORDER_ERROR_INVALID_PARAMETER;
2201 sock_fd = pc->cb_info->fd;
2206 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2207 if (ret == RECORDER_ERROR_NONE) {
2208 muse_recorder_msg_get(get_second, pc->cb_info->recv_msg);
2209 *second = get_second;
2211 LOGD("ret : 0x%x", ret);
2216 int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device)
2218 if (recorder == NULL) {
2219 LOGE("NULL pointer handle");
2220 return RECORDER_ERROR_INVALID_PARAMETER;
2222 if (device == NULL) {
2223 LOGE("NULL pointer device");
2224 return RECORDER_ERROR_INVALID_PARAMETER;
2226 int ret = RECORDER_ERROR_NONE;
2227 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE;
2228 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2230 if (pc->cb_info == NULL) {
2231 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2232 return RECORDER_ERROR_INVALID_PARAMETER;
2234 sock_fd = pc->cb_info->fd;
2239 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2240 if (ret == RECORDER_ERROR_NONE) {
2241 muse_recorder_msg_get(get_device, pc->cb_info->recv_msg);
2242 *device = (recorder_audio_device_e)get_device;
2245 LOGD("ret : 0x%x", ret);
2250 int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate)
2252 if (recorder == NULL) {
2253 LOGE("NULL pointer handle");
2254 return RECORDER_ERROR_INVALID_PARAMETER;
2256 if (samplerate == NULL) {
2257 LOGE("NULL pointer handle");
2258 return RECORDER_ERROR_INVALID_PARAMETER;
2260 int ret = RECORDER_ERROR_NONE;
2261 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE;
2262 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2264 if (pc->cb_info == NULL) {
2265 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2266 return RECORDER_ERROR_INVALID_PARAMETER;
2268 sock_fd = pc->cb_info->fd;
2273 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2274 if (ret == RECORDER_ERROR_NONE) {
2275 muse_recorder_msg_get(get_samplerate, pc->cb_info->recv_msg);
2276 *samplerate = get_samplerate;
2278 LOGD("ret : 0x%x, get_samplerate : %d", ret, get_samplerate);
2283 int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate)
2285 if (recorder == NULL) {
2286 LOGE("NULL pointer handle");
2287 return RECORDER_ERROR_INVALID_PARAMETER;
2289 if (bitrate == NULL) {
2290 LOGE("NULL pointer");
2291 return RECORDER_ERROR_INVALID_PARAMETER;
2293 int ret = RECORDER_ERROR_NONE;
2294 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE;
2295 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2297 if (pc->cb_info == NULL) {
2298 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2299 return RECORDER_ERROR_INVALID_PARAMETER;
2301 sock_fd = pc->cb_info->fd;
2306 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2307 if (ret == RECORDER_ERROR_NONE) {
2308 muse_recorder_msg_get(get_bitrate, pc->cb_info->recv_msg);
2309 *bitrate = get_bitrate;
2311 LOGD("ret : 0x%x", ret);
2316 int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate)
2318 if (recorder == NULL) {
2319 LOGE("NULL pointer handle");
2320 return RECORDER_ERROR_INVALID_PARAMETER;
2322 if (bitrate == NULL) {
2323 LOGE("NULL pointer");
2324 return RECORDER_ERROR_INVALID_PARAMETER;
2326 int ret = RECORDER_ERROR_NONE;
2327 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE;
2328 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2330 if (pc->cb_info == NULL) {
2331 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2332 return RECORDER_ERROR_INVALID_PARAMETER;
2334 sock_fd = pc->cb_info->fd;
2339 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2340 if (ret == RECORDER_ERROR_NONE) {
2341 muse_recorder_msg_get(get_bitrate, pc->cb_info->recv_msg);
2342 *bitrate = get_bitrate;
2344 LOGD("ret : 0x%x", ret);
2349 int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb, void *user_data)
2351 if( recorder == NULL || foreach_cb == NULL){
2352 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2353 return RECORDER_ERROR_INVALID_PARAMETER;
2355 int ret = RECORDER_ERROR_NONE;
2357 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2358 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_AUDIO_ENCODER;
2360 LOGD("Enter, handle :%x", pc->remote_handle);
2363 if (pc->cb_info == NULL) {
2364 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2365 return RECORDER_ERROR_INVALID_PARAMETER;
2367 sock_fd = pc->cb_info->fd;
2368 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = foreach_cb;
2369 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = user_data;
2371 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2372 LOGD("ret : 0x%x", ret);
2377 int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb, void *user_data)
2379 if( recorder == NULL || foreach_cb == NULL){
2380 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2381 return RECORDER_ERROR_INVALID_PARAMETER;
2383 int ret = RECORDER_ERROR_NONE;
2385 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2386 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_ENCODER;
2388 LOGD("Enter, handle :%x", pc->remote_handle);
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 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = foreach_cb;
2397 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = user_data;
2399 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2400 LOGD("ret : 0x%x", ret);
2405 int recorder_attr_set_mute(recorder_h recorder, bool enable)
2407 if (recorder == NULL) {
2408 LOGE("NULL pointer handle");
2409 return RECORDER_ERROR_INVALID_PARAMETER;
2411 int ret = RECORDER_ERROR_NONE;
2412 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_MUTE;
2413 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2415 if (pc->cb_info == NULL) {
2416 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2417 return RECORDER_ERROR_INVALID_PARAMETER;
2419 sock_fd = pc->cb_info->fd;
2420 int set_enable = (int)enable;
2424 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
2426 LOGD("ret : 0x%x", ret);
2432 bool recorder_attr_is_muted(recorder_h recorder)
2434 if (recorder == NULL) {
2435 LOGE("NULL pointer handle");
2438 int ret = RECORDER_ERROR_NONE;
2439 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_IS_MUTED;
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;
2450 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2451 LOGD("ret : 0x%x", ret);
2456 int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate)
2458 if (recorder == NULL) {
2459 LOGE("NULL pointer handle");
2460 return RECORDER_ERROR_INVALID_PARAMETER;
2462 int ret = RECORDER_ERROR_NONE;
2463 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_RECORDING_MOTION_RATE;
2464 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2466 if (pc->cb_info == NULL) {
2467 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2468 return RECORDER_ERROR_INVALID_PARAMETER;
2470 sock_fd = pc->cb_info->fd;
2472 LOGD("ENTER - %.20lf", rate);
2474 muse_recorder_msg_send1(api,
2480 LOGD("ret : 0x%x", ret);
2486 int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate)
2488 if (recorder == NULL) {
2489 LOGE("NULL pointer handle");
2490 return RECORDER_ERROR_INVALID_PARAMETER;
2493 LOGE("rate is NULL");
2494 return RECORDER_ERROR_INVALID_PARAMETER;
2496 int ret = RECORDER_ERROR_NONE;
2497 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE;
2498 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2500 if (pc->cb_info == NULL) {
2501 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2502 return RECORDER_ERROR_INVALID_PARAMETER;
2504 sock_fd = pc->cb_info->fd;
2509 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2510 if (ret == RECORDER_ERROR_NONE) {
2511 muse_recorder_msg_get_double(get_rate, pc->cb_info->recv_msg);
2514 LOGD("ret : 0x%x - rate %.20lf", ret, *rate);
2519 int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count)
2521 if (recorder == NULL) {
2522 LOGE("NULL pointer handle");
2523 return RECORDER_ERROR_INVALID_PARAMETER;
2525 if (channel_count < 1) {
2526 LOGE("invalid channel %d", channel_count);
2527 return RECORDER_ERROR_INVALID_PARAMETER;
2529 int ret = RECORDER_ERROR_NONE;
2530 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_CHANNEL;
2531 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2533 if (pc->cb_info == NULL) {
2534 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2535 return RECORDER_ERROR_INVALID_PARAMETER;
2537 sock_fd = pc->cb_info->fd;
2541 muse_recorder_msg_send1(api,
2545 INT, channel_count);
2546 LOGD("ret : 0x%x", ret);
2551 int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count)
2553 if (recorder == NULL) {
2554 LOGE("NULL pointer handle");
2555 return RECORDER_ERROR_INVALID_PARAMETER;
2557 if (channel_count == NULL) {
2558 LOGE("channel_count is NULL");
2559 return RECORDER_ERROR_INVALID_PARAMETER;
2561 int ret = RECORDER_ERROR_NONE;
2562 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL;
2563 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2565 if (pc->cb_info == NULL) {
2566 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2567 return RECORDER_ERROR_INVALID_PARAMETER;
2569 sock_fd = pc->cb_info->fd;
2570 int get_channel_count;
2574 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2575 if (ret == RECORDER_ERROR_NONE) {
2576 muse_recorder_msg_get(get_channel_count, pc->cb_info->recv_msg);
2577 *channel_count = get_channel_count;
2579 LOGD("ret : 0x%x", ret);
2584 int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation)
2586 if (recorder == NULL) {
2587 LOGE("NULL pointer handle");
2588 return RECORDER_ERROR_INVALID_PARAMETER;
2590 if (orientation > RECORDER_ROTATION_270) {
2591 LOGE("invalid orientation %d", orientation);
2592 return RECORDER_ERROR_INVALID_PARAMETER;
2594 int ret = RECORDER_ERROR_NONE;
2595 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_ORIENTATION_TAG;
2596 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2598 if (pc->cb_info == NULL) {
2599 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2600 return RECORDER_ERROR_INVALID_PARAMETER;
2602 sock_fd = pc->cb_info->fd;
2603 int set_orientation = (int)orientation;
2607 muse_recorder_msg_send1(api,
2611 INT, set_orientation);
2612 LOGD("ret : 0x%x", ret);
2617 int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation)
2619 if (recorder == NULL) {
2620 LOGE("NULL pointer handle");
2621 return RECORDER_ERROR_INVALID_PARAMETER;
2623 if (orientation == NULL) {
2624 LOGE("orientation is NULL");
2625 return RECORDER_ERROR_INVALID_PARAMETER;
2627 int ret = RECORDER_ERROR_NONE;
2628 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG;
2629 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2631 if (pc->cb_info == NULL) {
2632 LOGE("INVALID_PARAMETER(0x%08x)",RECORDER_ERROR_INVALID_PARAMETER);
2633 return RECORDER_ERROR_INVALID_PARAMETER;
2635 sock_fd = pc->cb_info->fd;
2636 int get_orientation;
2640 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2641 if (ret == RECORDER_ERROR_NONE) {
2642 muse_recorder_msg_get(get_orientation, pc->cb_info->recv_msg);
2643 *orientation = (recorder_rotation_e)get_orientation;
2645 LOGD("ret : 0x%x", ret);