2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <camera_internal.h>
22 #include <sound_manager.h>
23 #include <sound_manager_internal.h>
25 #include <muse_recorder.h>
26 #include <muse_recorder_msg.h>
27 #include <muse_core_ipc.h>
28 #include <muse_core_module.h>
29 #include <recorder_private.h>
36 #define LOG_TAG "TIZEN_N_RECORDER"
39 static int _recorder_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
42 tbm_bo_handle tmp_bo_handle = {NULL, };
44 if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
45 LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
46 bufmgr, bo, bo_handle, tbm_key);
50 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
52 LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
56 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
57 if (tmp_bo_handle.ptr == NULL) {
58 LOGE("bo map failed %p", tmp_bo);
64 /* set bo and bo_handle */
66 *bo_handle = tmp_bo_handle;
71 static void _recorder_release_imported_bo(tbm_bo *bo)
73 if (bo == NULL || *bo == NULL) {
85 static void _client_user_callback(recorder_cb_info_s *cb_info, char *recv_msg, muse_recorder_event_e event)
87 if (recv_msg == NULL || event >= MUSE_RECORDER_EVENT_TYPE_NUM) {
88 LOGE("invalid parameter - recorder msg %p, event %d", recv_msg, event);
92 LOGD("get recorder msg %s, event %d", recv_msg, event);
94 if (cb_info->user_cb[event] == NULL) {
95 LOGW("user callback for event %d is not set", event);
100 case MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE:
106 muse_recorder_msg_get(previous, recv_msg);
107 muse_recorder_msg_get(current, recv_msg);
108 muse_recorder_msg_get(by_policy, recv_msg);
110 ((recorder_state_changed_cb)cb_info->user_cb[event])((recorder_state_e)previous,
111 (recorder_state_e)current,
113 cb_info->user_data[event]);
116 case MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED:
120 muse_recorder_msg_get(type, recv_msg);
122 ((recorder_recording_limit_reached_cb)cb_info->user_cb[event])((recorder_recording_limit_type_e)type,
123 cb_info->user_data[event]);
126 case MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS:
128 int64_t cb_elapsed_time = 0;
129 int64_t cb_file_size = 0;
131 muse_recorder_msg_get(cb_elapsed_time, recv_msg);
132 muse_recorder_msg_get(cb_file_size, recv_msg);
134 ((recorder_recording_status_cb)cb_info->user_cb[event])((unsigned long long)cb_elapsed_time,
135 (unsigned long long)cb_file_size,
136 cb_info->user_data[event]);
139 case MUSE_RECORDER_EVENT_TYPE_INTERRUPTED:
145 muse_recorder_msg_get(policy, recv_msg);
146 muse_recorder_msg_get(previous, recv_msg);
147 muse_recorder_msg_get(current, recv_msg);
149 ((recorder_interrupted_cb)cb_info->user_cb[event])((recorder_policy_e)policy,
150 (recorder_state_e)previous,
151 (recorder_state_e)current,
152 cb_info->user_data[event]);
155 case MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM:
163 tbm_bo_handle bo_handle = {.ptr = NULL};
165 muse_recorder_msg_get(tbm_key, recv_msg);
171 if (!_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
172 LOGE("tbm key %d import failed", tbm_key);
176 muse_recorder_msg_get(size, recv_msg);
177 muse_recorder_msg_get(format, recv_msg);
178 muse_recorder_msg_get(channel, recv_msg);
179 muse_recorder_msg_get(timestamp, recv_msg);
181 ((recorder_audio_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
183 (audio_sample_type_e)format,
185 (unsigned int)timestamp,
186 cb_info->user_data[event]);
188 /* release imported bo */
189 _recorder_release_imported_bo(&bo);
192 muse_recorder_msg_send1_no_return(MUSE_RECORDER_API_RETURN_BUFFER,
193 cb_info->fd, cb_info,
197 case MUSE_RECORDER_EVENT_TYPE_ERROR:
200 int current_state = 0;
202 muse_recorder_msg_get(error, recv_msg);
203 muse_recorder_msg_get(current_state, recv_msg);
205 ((recorder_error_cb)cb_info->user_cb[event])((recorder_error_e)error,
206 (recorder_state_e)current_state,
207 cb_info->user_data[event]);
210 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER:
214 muse_recorder_msg_get(codec, recv_msg);
216 if (((recorder_supported_audio_encoder_cb)cb_info->user_cb[event])((recorder_audio_codec_e)codec, cb_info->user_data[event]) == false) {
217 cb_info->user_cb[event] = NULL;
218 cb_info->user_data[event] = NULL;
219 LOGD("stop foreach callback for SUPPORTED_AUDIO_ENCODER");
223 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT:
227 muse_recorder_msg_get(format, recv_msg);
229 if (((recorder_supported_file_format_cb)cb_info->user_cb[event])((recorder_file_format_e)format, cb_info->user_data[event]) == false) {
230 cb_info->user_cb[event] = NULL;
231 cb_info->user_data[event] = NULL;
232 LOGD("stop foreach callback for SUPPORTED_FILE_FORMAT");
236 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER:
240 muse_recorder_msg_get(codec, recv_msg);
242 if (((recorder_supported_video_encoder_cb)cb_info->user_cb[event])((recorder_video_codec_e)codec, cb_info->user_data[event]) == false) {
243 cb_info->user_cb[event] = NULL;
244 cb_info->user_data[event] = NULL;
245 LOGD("stop foreach callback for SUPPORTED_VIDEO_ENCODER");
249 case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION:
254 muse_recorder_msg_get(width, recv_msg);
255 muse_recorder_msg_get(height, recv_msg);
257 if (((recorder_supported_video_resolution_cb)cb_info->user_cb[event])(width, height, cb_info->user_data[event]) == false) {
258 cb_info->user_cb[event] = NULL;
259 cb_info->user_data[event] = NULL;
260 LOGD("stop foreach callback for SUPPORTED_VIDEO_RESOLUTION");
266 LOGE("Unknonw recorder event %d", event);
274 static bool _recorder_idle_event_callback(void *data)
276 recorder_cb_info_s *cb_info = NULL;
277 recorder_idle_event_s *rec_idle_event = (recorder_idle_event_s *)data;
279 if (rec_idle_event == NULL) {
280 LOGE("rec_idle_event is NULL");
285 g_mutex_lock(&rec_idle_event->event_mutex);
287 cb_info = rec_idle_event->cb_info;
288 if (cb_info == NULL) {
289 LOGW("recorder cb_info is NULL. event %d", rec_idle_event->event);
290 goto IDLE_EVENT_CALLBACK_DONE;
293 /* remove event from list */
294 g_mutex_lock(&cb_info->idle_event_mutex);
295 if (cb_info->idle_event_list)
296 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
298 /*LOGD("remove recorder idle event %p, %p", rec_idle_event, cb_info->idle_event_list);*/
299 g_mutex_unlock(&cb_info->idle_event_mutex);
302 _client_user_callback(rec_idle_event->cb_info, rec_idle_event->recv_msg, rec_idle_event->event);
304 /* send signal for waiting thread */
305 g_cond_signal(&cb_info->idle_event_cond);
307 IDLE_EVENT_CALLBACK_DONE:
308 /* unlock and release event */
309 g_mutex_unlock(&rec_idle_event->event_mutex);
310 g_mutex_clear(&rec_idle_event->event_mutex);
312 g_free(rec_idle_event);
313 rec_idle_event = NULL;
319 static void _recorder_remove_idle_event_all(recorder_cb_info_s *cb_info)
321 recorder_idle_event_s *rec_idle_event = NULL;
326 if (cb_info == NULL) {
327 LOGE("cb_info is NULL");
331 g_mutex_lock(&cb_info->idle_event_mutex);
333 if (cb_info->idle_event_list == NULL) {
334 LOGD("No idle event is remained.");
336 list = cb_info->idle_event_list;
339 rec_idle_event = list->data;
340 list = g_list_next(list);
342 if (!rec_idle_event) {
343 LOGW("Fail to remove idle event. The event is NULL");
345 if (g_mutex_trylock(&rec_idle_event->event_mutex)) {
346 ret = g_idle_remove_by_data(rec_idle_event);
348 LOGD("remove idle event [%p], ret[%d]", rec_idle_event, ret);
351 rec_idle_event->cb_info = NULL;
352 LOGW("idle callback for event %p will be called later", rec_idle_event);
355 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
357 g_mutex_unlock(&rec_idle_event->event_mutex);
360 g_mutex_clear(&rec_idle_event->event_mutex);
362 g_free(rec_idle_event);
363 rec_idle_event = NULL;
365 LOGD("remove idle event done");
368 LOGW("event lock failed. it's being called...");
370 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
372 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
373 LOGW("signal received");
380 g_list_free(cb_info->idle_event_list);
381 cb_info->idle_event_list = NULL;
384 g_mutex_unlock(&cb_info->idle_event_mutex);
390 static void *_recorder_msg_handler_func(gpointer data)
396 recorder_message_s *rec_msg = NULL;
397 recorder_idle_event_s *rec_idle_event = NULL;
398 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
400 if (cb_info == NULL) {
401 LOGE("cb_info NULL");
407 g_mutex_lock(&cb_info->msg_handler_mutex);
409 while (g_atomic_int_get(&cb_info->msg_handler_running)) {
410 if (g_queue_is_empty(cb_info->msg_queue)) {
411 /*LOGD("signal wait...");*/
412 g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
413 /*LOGD("signal received");*/
415 if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
416 LOGD("stop event thread");
421 rec_msg = (recorder_message_s *)g_queue_pop_head(cb_info->msg_queue);
422 g_mutex_unlock(&cb_info->msg_handler_mutex);
423 if (rec_msg == NULL) {
424 LOGE("NULL message");
425 g_mutex_lock(&cb_info->msg_handler_mutex);
429 if (api < MUSE_RECORDER_API_MAX) {
430 g_mutex_lock(&cb_info->api_mutex[api]);
431 if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
432 cb_info->api_ret[api] = ret;
433 cb_info->api_activating[api] = 1;
435 /*LOGD("recorder api %d - return 0x%x", ret);*/
437 g_cond_signal(&cb_info->api_cond[api]);
439 LOGE("failed to get ret for api %d, msg %s", rec_msg->api, rec_msg->recv_msg);
442 g_mutex_unlock(&cb_info->api_mutex[api]);
443 } else if (api == MUSE_RECORDER_CB_EVENT) {
447 if (!muse_recorder_msg_get(event, rec_msg->recv_msg) ||
448 !muse_recorder_msg_get(event_class, rec_msg->recv_msg)) {
449 LOGE("failed to get recorder event %d, class %d", event, event_class);
454 g_mutex_lock(&cb_info->msg_handler_mutex);
458 switch (event_class) {
459 case MUSE_RECORDER_EVENT_CLASS_THREAD_SUB:
460 _client_user_callback(cb_info, rec_msg->recv_msg, event);
462 case MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN:
463 rec_idle_event = g_new0(recorder_idle_event_s, 1);
464 if (rec_idle_event == NULL) {
465 LOGE("rec_idle_event alloc failed");
469 rec_idle_event->event = event;
470 rec_idle_event->cb_info = cb_info;
471 g_mutex_init(&rec_idle_event->event_mutex);
472 memcpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg));
474 /*LOGD("add recorder event[%d, %p] to IDLE", event, rec_idle_event);*/
476 g_mutex_lock(&cb_info->idle_event_mutex);
477 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)rec_idle_event);
478 g_mutex_unlock(&cb_info->idle_event_mutex);
480 g_idle_add_full(G_PRIORITY_DEFAULT,
481 (GSourceFunc)_recorder_idle_event_callback,
482 (gpointer)rec_idle_event,
486 LOGE("unknown recorder event class %d", event_class);
490 LOGE("unknown recorder api[%d] message", api);
496 g_mutex_lock(&cb_info->msg_handler_mutex);
499 /* remove remained event */
500 while (!g_queue_is_empty(cb_info->msg_queue)) {
501 rec_msg = (recorder_message_s *)g_queue_pop_head(cb_info->msg_queue);
503 LOGD("remove recorder message %p", rec_msg);
507 LOGW("NULL recorder message");
511 g_mutex_unlock(&cb_info->msg_handler_mutex);
519 static void *_recorder_msg_recv_func(gpointer data)
528 char *recv_msg = NULL;
529 char **parse_str = NULL;
530 recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
532 if (cb_info == NULL) {
533 LOGE("cb_info NULL");
539 parse_str = (char **)malloc(sizeof(char *) * RECORDER_PARSE_STRING_SIZE);
540 if (parse_str == NULL) {
541 LOGE("parse_str malloc failed");
545 for (i = 0 ; i < RECORDER_PARSE_STRING_SIZE ; i++) {
546 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
547 if (parse_str[i] == NULL) {
548 LOGE("parse_str[%d] malloc failed", i);
549 goto CB_HANDLER_EXIT;
553 recv_msg = cb_info->recv_msg;
555 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
556 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
559 recv_msg[ret] = '\0';
565 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
567 /* Need to split the combined entering msgs.
568 This module supports up to 200 combined msgs. */
569 for (str_pos = 0; str_pos < ret; str_pos++) {
570 if (recv_msg[str_pos] == '}') {
571 memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
572 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
573 /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/
574 prev_pos = str_pos+1;
579 /*LOGD("num_token : %d", num_token);*/
581 /* Re-construct to the useful single msg. */
582 for (i = 0; i < num_token; i++) {
583 if (i >= RECORDER_PARSE_STRING_SIZE) {
584 LOGE("invalid token index %d", i);
591 if (!muse_recorder_msg_get(api, parse_str[i])) {
592 LOGE("failed to get recorder api");
596 if (api != MUSE_RECORDER_CB_EVENT) {
597 if (!muse_recorder_msg_get(api_class, parse_str[i])) {
598 LOGE("failed to get recorder api_class");
603 if (api_class == MUSE_RECORDER_API_CLASS_IMMEDIATE) {
604 if (api >= MUSE_RECORDER_API_MAX) {
605 LOGE("invalid api %d", api);
609 g_mutex_lock(&cb_info->api_mutex[api]);
611 if (!muse_recorder_msg_get(ret, parse_str[i])) {
612 LOGE("failed to get recorder ret");
613 g_mutex_unlock(&cb_info->api_mutex[api]);
617 cb_info->api_ret[api] = ret;
618 cb_info->api_activating[api] = 1;
621 case MUSE_RECORDER_API_CREATE:
622 if (ret != RECORDER_ERROR_NONE) {
623 g_atomic_int_set(&cb_info->msg_recv_running, 0);
624 LOGE("recorder create error 0x%x. close client cb handler", ret);
627 case MUSE_RECORDER_API_DESTROY:
628 if (ret == RECORDER_ERROR_NONE) {
629 g_atomic_int_set(&cb_info->msg_recv_running, 0);
630 LOGD("recorder destroy done. close client cb handler");
633 case MUSE_RECORDER_API_GET_STATE:
636 muse_recorder_msg_get(get_state, parse_str[i]);
637 cb_info->get_int_value[_RECORDER_GET_INT_STATE] = get_state;
640 case MUSE_RECORDER_API_GET_VIDEO_RESOLUTION:
644 muse_recorder_msg_get(get_width, parse_str[i]);
645 muse_recorder_msg_get(get_height, parse_str[i]);
646 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] = get_width << 16;
647 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] |= get_height;
650 case MUSE_RECORDER_API_GET_FILE_FORMAT:
653 muse_recorder_msg_get(get_format, parse_str[i]);
654 cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT] = get_format;
657 case MUSE_RECORDER_API_GET_AUDIO_ENCODER:
660 muse_recorder_msg_get(get_codec, parse_str[i]);
661 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER] = get_codec;
664 case MUSE_RECORDER_API_GET_VIDEO_ENCODER:
667 muse_recorder_msg_get(get_codec, parse_str[i]);
668 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER] = get_codec;
671 case MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT:
674 muse_recorder_msg_get(get_kbyte, parse_str[i]);
675 cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT] = get_kbyte;
678 case MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT:
681 muse_recorder_msg_get(get_second, parse_str[i]);
682 cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT] = get_second;
685 case MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE:
688 muse_recorder_msg_get(get_device, parse_str[i]);
689 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE] = get_device;
692 case MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE:
694 int get_samplerate = 0;
695 muse_recorder_msg_get(get_samplerate, parse_str[i]);
696 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE] = get_samplerate;
699 case MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE:
702 muse_recorder_msg_get(get_bitrate, parse_str[i]);
703 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE] = get_bitrate;
706 case MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE:
709 muse_recorder_msg_get(get_bitrate, parse_str[i]);
710 cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE] = get_bitrate;
713 case MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE:
716 muse_recorder_msg_get_double(get_rate, parse_str[i]);
717 cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE] = get_rate;
720 case MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL:
722 int get_channel_count = 0;
723 muse_recorder_msg_get(get_channel_count, parse_str[i]);
724 cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL] = get_channel_count;
727 case MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG:
729 int get_orientation = 0;
730 muse_recorder_msg_get(get_orientation, parse_str[i]);
731 cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG] = get_orientation;
734 case MUSE_RECORDER_API_GET_AUDIO_LEVEL:
736 double get_level = 0.0;
737 muse_recorder_msg_get_double(get_level, parse_str[i]);
738 cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL] = get_level;
741 case MUSE_RECORDER_API_GET_FILENAME:
743 char get_filename[MUSE_RECORDER_MSG_MAX_LENGTH] = {'\0',};
744 muse_recorder_msg_get_string(get_filename, parse_str[i]);
745 if (cb_info->get_filename) {
746 free(cb_info->get_filename);
747 cb_info->get_filename = NULL;
749 cb_info->get_filename = strdup(get_filename);
756 g_cond_signal(&cb_info->api_cond[api]);
757 g_mutex_unlock(&cb_info->api_mutex[api]);
758 } else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB ||
759 api == MUSE_RECORDER_CB_EVENT) {
760 recorder_message_s *rec_msg = g_new0(recorder_message_s, 1);
761 if (rec_msg == NULL) {
762 LOGE("failed to alloc rec_msg");
767 memcpy(rec_msg->recv_msg, parse_str[i], sizeof(rec_msg->recv_msg));
769 /*LOGD("add recorder message to queue : api %d", api);*/
771 g_mutex_lock(&cb_info->msg_handler_mutex);
772 g_queue_push_tail(cb_info->msg_queue, (gpointer)rec_msg);
773 g_cond_signal(&cb_info->msg_handler_cond);
774 g_mutex_unlock(&cb_info->msg_handler_mutex);
776 LOGW("unknown recorder api %d and api_class %d", api, api_class);
781 LOGD("client cb exit");
785 for (i = 0 ; i < RECORDER_PARSE_STRING_SIZE ; i++) {
799 static recorder_cb_info_s *_client_callback_new(gint sockfd)
801 recorder_cb_info_s *cb_info = NULL;
802 gint *tmp_activating = NULL;
803 gint *tmp_ret = NULL;
806 g_return_val_if_fail(sockfd > 0, NULL);
808 cb_info = g_new0(recorder_cb_info_s, 1);
809 if (cb_info == NULL) {
810 LOGE("cb_info failed");
814 g_mutex_init(&cb_info->msg_handler_mutex);
815 g_cond_init(&cb_info->msg_handler_cond);
816 g_mutex_init(&cb_info->idle_event_mutex);
817 g_cond_init(&cb_info->idle_event_cond);
819 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
820 g_mutex_init(&cb_info->api_mutex[i]);
821 g_cond_init(&cb_info->api_cond[i]);
824 tmp_activating = g_new0(gint, MUSE_RECORDER_API_MAX);
825 if (tmp_activating == NULL) {
826 LOGE("tmp_activating failed");
830 tmp_ret = g_new0(gint, MUSE_RECORDER_API_MAX);
831 if (tmp_ret == NULL) {
832 LOGE("tmp_ret failed");
836 cb_info->msg_queue = g_queue_new();
837 if (cb_info->msg_queue == NULL) {
838 LOGE("msg_queue new failed");
842 g_atomic_int_set(&cb_info->msg_handler_running, 1);
843 cb_info->msg_handler_thread = g_thread_try_new("recorder_msg_handler",
844 _recorder_msg_handler_func,
847 if (cb_info->msg_handler_thread == NULL) {
848 LOGE("message handler thread creation failed");
852 cb_info->fd = sockfd;
853 cb_info->api_activating = tmp_activating;
854 cb_info->api_ret = tmp_ret;
856 g_atomic_int_set(&cb_info->msg_recv_running, 1);
857 cb_info->msg_recv_thread = g_thread_try_new("recorder_msg_recv",
858 _recorder_msg_recv_func,
861 if (cb_info->msg_recv_thread == NULL) {
862 LOGE("message receive thread creation failed");
871 if (cb_info->msg_handler_thread) {
872 g_mutex_lock(&cb_info->msg_handler_mutex);
873 g_atomic_int_set(&cb_info->msg_handler_running, 0);
874 g_cond_signal(&cb_info->msg_handler_cond);
875 g_mutex_unlock(&cb_info->msg_handler_mutex);
877 g_thread_join(cb_info->msg_handler_thread);
878 g_thread_unref(cb_info->msg_handler_thread);
879 cb_info->msg_handler_thread = NULL;
882 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
883 g_mutex_clear(&cb_info->api_mutex[i]);
884 g_cond_clear(&cb_info->api_cond[i]);
887 g_mutex_clear(&cb_info->msg_handler_mutex);
888 g_cond_clear(&cb_info->msg_handler_cond);
889 g_mutex_clear(&cb_info->idle_event_mutex);
890 g_cond_clear(&cb_info->idle_event_cond);
892 if (cb_info->msg_queue) {
893 g_queue_free(cb_info->msg_queue);
894 cb_info->msg_queue = NULL;
901 if (tmp_activating) {
902 g_free(tmp_activating);
903 tmp_activating = NULL;
913 static int client_wait_for_cb_return(muse_recorder_api_e api, recorder_cb_info_s *cb_info, int time_out)
915 int ret = RECORDER_ERROR_NONE;
918 /*LOGD("Enter api : %d", api);*/
920 g_mutex_lock(&(cb_info->api_mutex[api]));
922 if (cb_info->api_activating[api] == 0) {
923 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
924 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
925 ret = cb_info->api_ret[api];
926 cb_info->api_activating[api] = 0;
928 /*LOGD("return value : 0x%x", ret);*/
930 ret = RECORDER_ERROR_INVALID_OPERATION;
932 LOGE("api %d was TIMED OUT!", api);
935 ret = cb_info->api_ret[api];
936 cb_info->api_activating[api] = 0;
938 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
941 g_mutex_unlock(&(cb_info->api_mutex[api]));
946 static void _client_callback_destroy(recorder_cb_info_s *cb_info)
950 g_return_if_fail(cb_info != NULL);
952 LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
954 g_thread_join(cb_info->msg_recv_thread);
955 g_thread_unref(cb_info->msg_recv_thread);
956 cb_info->msg_recv_thread = NULL;
958 LOGD("msg thread removed");
960 g_mutex_lock(&cb_info->msg_handler_mutex);
961 g_atomic_int_set(&cb_info->msg_handler_running, 0);
962 g_cond_signal(&cb_info->msg_handler_cond);
963 g_mutex_unlock(&cb_info->msg_handler_mutex);
965 g_thread_join(cb_info->msg_handler_thread);
966 g_thread_unref(cb_info->msg_handler_thread);
967 cb_info->msg_handler_thread = NULL;
969 g_queue_free(cb_info->msg_queue);
970 cb_info->msg_queue = NULL;
971 g_mutex_clear(&cb_info->msg_handler_mutex);
972 g_cond_clear(&cb_info->msg_handler_cond);
973 g_mutex_clear(&cb_info->idle_event_mutex);
974 g_cond_clear(&cb_info->idle_event_cond);
976 for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
977 g_mutex_clear(&cb_info->api_mutex[i]);
978 g_cond_clear(&cb_info->api_cond[i]);
981 LOGD("event thread removed");
983 if (cb_info->fd > -1) {
984 muse_core_connection_close(cb_info->fd);
988 if (cb_info->bufmgr) {
989 tbm_bufmgr_deinit(cb_info->bufmgr);
990 cb_info->bufmgr = NULL;
992 if (cb_info->api_activating) {
993 g_free(cb_info->api_activating);
994 cb_info->api_activating = NULL;
996 if (cb_info->api_ret) {
997 g_free(cb_info->api_ret);
998 cb_info->api_ret = NULL;
1000 if (cb_info->get_filename) {
1001 free(cb_info->get_filename);
1002 cb_info->get_filename = NULL;
1011 static int _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
1013 char **root_directory = (char **)user_data;
1015 if (root_directory == NULL) {
1016 LOGE("user data is NULL");
1020 LOGD("storage id %d, type %d, state %d, path %s",
1021 storage_id, type, state, path ? path : "NULL");
1023 if (type == STORAGE_TYPE_INTERNAL && path) {
1024 if (*root_directory) {
1025 free(*root_directory);
1026 *root_directory = NULL;
1029 *root_directory = strdup(path);
1030 if (*root_directory) {
1031 LOGD("get root directory %s", *root_directory);
1034 LOGE("strdup %s failed");
1041 static int _client_get_root_directory(char **root_directory)
1043 int ret = STORAGE_ERROR_NONE;
1045 if (root_directory == NULL) {
1046 LOGE("user data is NULL");
1050 ret = storage_foreach_device_supported((storage_device_supported_cb)_recorder_storage_device_supported_cb, root_directory);
1051 if (ret != STORAGE_ERROR_NONE) {
1052 LOGE("storage_foreach_device_supported failed 0x%x", ret);
1059 static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e type, camera_h camera)
1061 int ret = RECORDER_ERROR_NONE;
1062 int destroy_ret = RECORDER_ERROR_NONE;
1064 char *send_msg = NULL;
1065 char *root_directory = NULL;
1066 intptr_t camera_handle = 0;
1067 intptr_t handle = 0;
1068 tbm_bufmgr bufmgr = NULL;
1069 recorder_cli_s *pc = NULL;
1071 LOGD("Enter - type %d", type);
1073 if (recorder == NULL) {
1074 LOGE("NULL pointer for recorder handle");
1075 return RECORDER_ERROR_INVALID_PARAMETER;
1078 if (type == MUSE_RECORDER_TYPE_VIDEO && camera == NULL) {
1079 LOGE("NULL pointer for camera handle on video recorder mode");
1080 return RECORDER_ERROR_INVALID_PARAMETER;
1083 bufmgr = tbm_bufmgr_init(-1);
1084 if (bufmgr == NULL) {
1085 LOGE("get tbm bufmgr failed");
1086 return RECORDER_ERROR_INVALID_OPERATION;
1089 pc = g_new0(recorder_cli_s, 1);
1091 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1092 goto _ERR_RECORDER_EXIT;
1095 sock_fd = muse_core_client_new();
1097 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
1098 ret = RECORDER_ERROR_INVALID_OPERATION;
1099 goto _ERR_RECORDER_EXIT;
1102 if (type == MUSE_RECORDER_TYPE_AUDIO) {
1103 send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
1104 MUSE_TYPE_INT, "module", MUSE_RECORDER,
1105 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_AUDIO,
1106 MUSE_TYPE_INT, "pid", getpid(),
1109 pc->camera = camera;
1110 camera_handle = (intptr_t)((camera_cli_s *)camera)->remote_handle;
1111 send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
1112 MUSE_TYPE_INT, "module", MUSE_RECORDER,
1113 MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_VIDEO,
1114 MUSE_TYPE_POINTER, "camera_handle", camera_handle,
1118 LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
1120 muse_core_ipc_send_msg(sock_fd, send_msg);
1121 muse_core_msg_json_factory_free(send_msg);
1123 pc->cb_info = _client_callback_new(sock_fd);
1124 if (pc->cb_info == NULL) {
1125 ret = RECORDER_ERROR_OUT_OF_MEMORY;
1126 goto _ERR_RECORDER_EXIT;
1129 ret = client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CALLBACK_TIME_OUT);
1130 if (ret == RECORDER_ERROR_NONE) {
1131 muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
1133 LOGE("Receiving Handle Failed!!");
1134 goto _ERR_RECORDER_EXIT;
1137 if (!_client_get_root_directory(&root_directory) || root_directory == NULL) {
1138 LOGE("failed to get root directory of internal storage");
1139 ret = RECORDER_ERROR_INVALID_OPERATION;
1140 goto _ERR_RECORDER_AFTER_CREATE;
1143 LOGD("set root directory [%s]", root_directory);
1145 muse_recorder_msg_send1(MUSE_RECORDER_API_ATTR_SET_ROOT_DIRECTORY,
1146 sock_fd, pc->cb_info, ret, STRING, root_directory);
1147 if (ret != RECORDER_ERROR_NONE) {
1148 LOGE("failed to set root directory %s", root_directory);
1149 ret = RECORDER_ERROR_INVALID_OPERATION;
1150 goto _ERR_RECORDER_AFTER_CREATE;
1153 free(root_directory);
1154 root_directory = NULL;
1156 pc->remote_handle = handle;
1157 pc->cb_info->bufmgr = bufmgr;
1159 LOGD("recorder[type %d] %p create success : remote handle 0x%x",
1160 type, pc, pc->remote_handle);
1162 *recorder = (recorder_h) pc;
1164 goto _ERR_RECORDER_EXIT;
1169 return RECORDER_ERROR_NONE;
1171 _ERR_RECORDER_AFTER_CREATE:
1172 muse_recorder_msg_send(MUSE_RECORDER_API_DESTROY, sock_fd, pc->cb_info, destroy_ret);
1173 LOGE("destroy return 0x%x", destroy_ret);
1176 tbm_bufmgr_deinit(bufmgr);
1179 if (root_directory) {
1180 free(root_directory);
1181 root_directory = NULL;
1186 _client_callback_destroy(pc->cb_info);
1196 int recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
1198 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_VIDEO, camera);
1202 int recorder_create_audiorecorder(recorder_h *recorder)
1204 return _recorder_create_common(recorder, MUSE_RECORDER_TYPE_AUDIO, NULL);
1207 int recorder_get_state(recorder_h recorder, recorder_state_e *state)
1209 int ret = RECORDER_ERROR_NONE;
1211 recorder_cli_s *pc = NULL;
1212 muse_recorder_api_e api = MUSE_RECORDER_API_GET_STATE;
1214 if (recorder == NULL) {
1215 LOGE("NULL pointer handle");
1216 return RECORDER_ERROR_INVALID_PARAMETER;
1219 if (state == NULL) {
1220 LOGE("NULL pointer state");
1221 return RECORDER_ERROR_INVALID_PARAMETER;
1224 pc = (recorder_cli_s *)recorder;
1225 if (pc->cb_info == NULL) {
1226 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1227 return RECORDER_ERROR_INVALID_PARAMETER;
1230 sock_fd = pc->cb_info->fd;
1232 LOGD("Enter, remote_handle : %x", pc->remote_handle);
1234 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1236 if (ret == RECORDER_ERROR_NONE)
1237 *state = (recorder_state_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_STATE];
1239 LOGD("ret : 0x%x, state : %d", ret, *state);
1245 int recorder_destroy(recorder_h recorder)
1247 if (recorder == NULL) {
1248 LOGE("NULL pointer handle");
1249 return RECORDER_ERROR_INVALID_PARAMETER;
1251 int ret = RECORDER_ERROR_NONE;
1252 muse_recorder_api_e api = MUSE_RECORDER_API_DESTROY;
1253 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1256 if (pc->cb_info == NULL) {
1257 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1258 return RECORDER_ERROR_INVALID_PARAMETER;
1261 sock_fd = pc->cb_info->fd;
1265 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1266 if (ret == RECORDER_ERROR_NONE) {
1267 _recorder_remove_idle_event_all(pc->cb_info);
1268 _client_callback_destroy(pc->cb_info);
1273 LOGD("ret : 0x%x", ret);
1279 int recorder_prepare(recorder_h recorder)
1281 if (recorder == NULL) {
1282 LOGE("NULL pointer handle");
1283 return RECORDER_ERROR_INVALID_PARAMETER;
1286 int ret = RECORDER_ERROR_NONE;
1287 muse_recorder_api_e api = MUSE_RECORDER_API_PREPARE;
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;
1298 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1300 LOGD("ret : 0x%x", ret);
1302 if (ret == RECORDER_ERROR_NONE && pc->camera)
1303 camera_start_evas_rendering(pc->camera);
1309 int recorder_unprepare(recorder_h recorder)
1311 int ret = RECORDER_ERROR_NONE;
1312 muse_recorder_api_e api = MUSE_RECORDER_API_UNPREPARE;
1313 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1315 camera_state_e camera_state = CAMERA_STATE_NONE;
1317 if (recorder == NULL) {
1318 LOGE("NULL pointer handle");
1319 return RECORDER_ERROR_INVALID_PARAMETER;
1322 if (pc->cb_info == NULL) {
1323 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1324 return RECORDER_ERROR_INVALID_PARAMETER;
1327 sock_fd = pc->cb_info->fd;
1332 ret = camera_get_state(pc->camera, &camera_state);
1333 if (ret != CAMERA_ERROR_NONE) {
1334 LOGE("failed to get camera state 0x%x", ret);
1335 return RECORDER_ERROR_INVALID_OPERATION;
1338 if (camera_state == CAMERA_STATE_PREVIEW) {
1339 ret = camera_stop_evas_rendering(pc->camera, false);
1340 if (ret != CAMERA_ERROR_NONE) {
1341 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1342 return RECORDER_ERROR_INVALID_OPERATION;
1347 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1349 LOGD("ret : 0x%x", ret);
1355 int recorder_start(recorder_h recorder)
1357 int ret = RECORDER_ERROR_NONE;
1358 muse_recorder_api_e api = MUSE_RECORDER_API_START;
1359 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1361 recorder_state_e current_state = RECORDER_STATE_NONE;
1363 if (recorder == NULL) {
1364 LOGE("NULL pointer handle");
1365 return RECORDER_ERROR_INVALID_PARAMETER;
1368 if (pc->cb_info == NULL) {
1369 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1370 return RECORDER_ERROR_INVALID_PARAMETER;
1372 sock_fd = pc->cb_info->fd;
1377 ret = recorder_get_state(recorder, ¤t_state);
1378 if (ret != RECORDER_ERROR_NONE) {
1379 LOGE("failed to get current state 0x%x", ret);
1380 return RECORDER_ERROR_INVALID_OPERATION;
1383 if (current_state == RECORDER_STATE_READY) {
1384 ret = camera_stop_evas_rendering(pc->camera, true);
1385 if (ret != CAMERA_ERROR_NONE) {
1386 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1387 return RECORDER_ERROR_INVALID_OPERATION;
1392 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1394 if (pc->camera && current_state == RECORDER_STATE_READY)
1395 camera_start_evas_rendering(pc->camera);
1397 LOGD("ret : 0x%x", ret);
1403 int recorder_pause(recorder_h recorder)
1405 if (recorder == NULL) {
1406 LOGE("NULL pointer handle");
1407 return RECORDER_ERROR_INVALID_PARAMETER;
1409 int ret = RECORDER_ERROR_NONE;
1410 muse_recorder_api_e api = MUSE_RECORDER_API_PAUSE;
1411 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1413 if (pc->cb_info == NULL) {
1414 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1415 return RECORDER_ERROR_INVALID_PARAMETER;
1417 sock_fd = pc->cb_info->fd;
1421 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1422 LOGD("ret : 0x%x", ret);
1427 int recorder_commit(recorder_h recorder)
1429 int ret = RECORDER_ERROR_NONE;
1430 muse_recorder_api_e api = MUSE_RECORDER_API_COMMIT;
1431 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1433 recorder_state_e current_state = RECORDER_STATE_NONE;
1435 if (recorder == NULL) {
1436 LOGE("NULL pointer handle");
1437 return RECORDER_ERROR_INVALID_PARAMETER;
1440 if (pc->cb_info == NULL) {
1441 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1442 return RECORDER_ERROR_INVALID_PARAMETER;
1444 sock_fd = pc->cb_info->fd;
1449 ret = recorder_get_state(recorder, ¤t_state);
1450 if (ret != RECORDER_ERROR_NONE) {
1451 LOGE("failed to get current state 0x%x", ret);
1452 return RECORDER_ERROR_INVALID_OPERATION;
1455 if (current_state >= RECORDER_STATE_RECORDING) {
1456 ret = camera_stop_evas_rendering(pc->camera, true);
1457 if (ret != CAMERA_ERROR_NONE) {
1458 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1459 return RECORDER_ERROR_INVALID_OPERATION;
1464 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1466 if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
1467 camera_start_evas_rendering(pc->camera);
1469 LOGD("ret : 0x%x", ret);
1475 int recorder_cancel(recorder_h recorder)
1477 int ret = RECORDER_ERROR_NONE;
1478 muse_recorder_api_e api = MUSE_RECORDER_API_CANCEL;
1479 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1481 recorder_state_e current_state = RECORDER_STATE_NONE;
1483 if (recorder == NULL) {
1484 LOGE("NULL pointer handle");
1485 return RECORDER_ERROR_INVALID_PARAMETER;
1488 if (pc->cb_info == NULL) {
1489 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1490 return RECORDER_ERROR_INVALID_PARAMETER;
1493 sock_fd = pc->cb_info->fd;
1498 ret = recorder_get_state(recorder, ¤t_state);
1499 if (ret != RECORDER_ERROR_NONE) {
1500 LOGE("failed to get current state 0x%x", ret);
1501 return RECORDER_ERROR_INVALID_OPERATION;
1504 if (current_state >= RECORDER_STATE_RECORDING) {
1505 ret = camera_stop_evas_rendering(pc->camera, true);
1506 if (ret != CAMERA_ERROR_NONE) {
1507 LOGE("camera_stop_evas_rendering failed 0x%x", ret);
1508 return RECORDER_ERROR_INVALID_OPERATION;
1513 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1515 if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
1516 camera_start_evas_rendering(pc->camera);
1518 LOGD("ret : 0x%x", ret);
1524 int recorder_set_video_resolution(recorder_h recorder, int width, int height)
1526 if (recorder == NULL) {
1527 LOGE("NULL pointer handle");
1528 return RECORDER_ERROR_INVALID_PARAMETER;
1530 int ret = RECORDER_ERROR_NONE;
1531 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_RESOLUTION;
1532 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1534 if (pc->cb_info == NULL) {
1535 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1536 return RECORDER_ERROR_INVALID_PARAMETER;
1538 sock_fd = pc->cb_info->fd;
1542 muse_recorder_msg_send2(api,
1548 LOGD("ret : 0x%x", ret);
1553 int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
1555 int ret = RECORDER_ERROR_NONE;
1557 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_RESOLUTION;
1558 recorder_cli_s *pc = NULL;
1560 if (recorder == NULL) {
1561 LOGE("NULL pointer handle");
1562 return RECORDER_ERROR_INVALID_PARAMETER;
1565 if (!width || !height) {
1566 LOGE("NULL pointer width = [%p], height = [%p]", width, height);
1567 return RECORDER_ERROR_INVALID_PARAMETER;
1570 pc = (recorder_cli_s *)recorder;
1571 if (pc->cb_info == NULL) {
1572 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1573 return RECORDER_ERROR_INVALID_PARAMETER;
1576 sock_fd = pc->cb_info->fd;
1580 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1582 if (ret == RECORDER_ERROR_NONE) {
1583 *width = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] >> 16;
1584 *height = (0x0000ffff & pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION]);
1587 LOGD("ret : 0x%x, %dx%d", ret, *width, *height);
1593 int recorder_foreach_supported_video_resolution(recorder_h recorder,
1594 recorder_supported_video_resolution_cb foreach_cb, void *user_data)
1596 if (recorder == NULL || foreach_cb == NULL) {
1597 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1598 return RECORDER_ERROR_INVALID_PARAMETER;
1600 int ret = RECORDER_ERROR_NONE;
1602 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1603 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_RESOLUTION;
1605 LOGD("Enter, handle :%x", pc->remote_handle);
1608 if (pc->cb_info == NULL) {
1609 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1610 return RECORDER_ERROR_INVALID_PARAMETER;
1612 sock_fd = pc->cb_info->fd;
1613 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
1614 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
1616 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1617 LOGD("ret : 0x%x", ret);
1622 int recorder_get_audio_level(recorder_h recorder, double *level)
1624 int ret = RECORDER_ERROR_NONE;
1626 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_LEVEL;
1627 recorder_cli_s *pc = NULL;
1629 if (recorder == NULL || level == NULL) {
1630 LOGE("NULL pointer %p %p", recorder, level);
1631 return RECORDER_ERROR_INVALID_PARAMETER;
1634 pc = (recorder_cli_s *)recorder;
1635 if (pc->cb_info == NULL) {
1636 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1637 return RECORDER_ERROR_INVALID_PARAMETER;
1640 sock_fd = pc->cb_info->fd;
1644 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1646 if (ret == RECORDER_ERROR_NONE)
1647 *level = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL];
1649 LOGD("ret : 0x%x, level %lf", ret, *level);
1655 int recorder_set_filename(recorder_h recorder, const char *filename)
1657 if (recorder == NULL) {
1658 LOGE("handle is NULL");
1659 return RECORDER_ERROR_INVALID_PARAMETER;
1662 if (filename == NULL) {
1663 LOGE("filename is NULL");
1664 return RECORDER_ERROR_INVALID_PARAMETER;
1666 int ret = RECORDER_ERROR_NONE;
1667 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
1668 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1670 if (pc->cb_info == NULL) {
1671 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1672 return RECORDER_ERROR_INVALID_PARAMETER;
1674 sock_fd = pc->cb_info->fd;
1678 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, filename);
1679 LOGD("ret : 0x%x", ret);
1684 int recorder_get_filename(recorder_h recorder, char **filename)
1686 int ret = RECORDER_ERROR_NONE;
1688 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILENAME;
1689 recorder_cli_s *pc = NULL;
1691 if (recorder == NULL) {
1692 LOGE("handle is NULL");
1693 return RECORDER_ERROR_INVALID_PARAMETER;
1696 if (filename == NULL) {
1697 LOGE("filename is NULL");
1698 return RECORDER_ERROR_INVALID_PARAMETER;
1701 pc = (recorder_cli_s *)recorder;
1702 if (pc->cb_info == NULL) {
1703 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1704 return RECORDER_ERROR_INVALID_PARAMETER;
1707 sock_fd = pc->cb_info->fd;
1711 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1713 if (ret == RECORDER_ERROR_NONE) {
1714 *filename = pc->cb_info->get_filename;
1715 pc->cb_info->get_filename = NULL;
1718 LOGD("ret : 0x%x, filename : [%s]", ret, (*filename) ? *filename : "NULL");
1724 int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
1726 if (recorder == NULL) {
1727 LOGE("NULL pointer handle");
1728 return RECORDER_ERROR_INVALID_PARAMETER;
1730 if (format < RECORDER_FILE_FORMAT_3GP || format > RECORDER_FILE_FORMAT_M2TS) {
1731 LOGE("invalid format %d", format);
1732 return RECORDER_ERROR_INVALID_PARAMETER;
1734 int ret = RECORDER_ERROR_NONE;
1735 muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILE_FORMAT;
1736 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1738 if (pc->cb_info == NULL) {
1739 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1740 return RECORDER_ERROR_INVALID_PARAMETER;
1742 sock_fd = pc->cb_info->fd;
1743 int set_format = (int)format;
1745 LOGD("ENTER, set_format : %d", set_format);
1747 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
1748 LOGD("ret : 0x%x", ret);
1753 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format)
1755 int ret = RECORDER_ERROR_NONE;
1757 muse_recorder_api_e api = MUSE_RECORDER_API_GET_FILE_FORMAT;
1758 recorder_cli_s *pc = NULL;
1760 if (recorder == NULL) {
1761 LOGE("NULL pointer handle");
1762 return RECORDER_ERROR_INVALID_PARAMETER;
1765 if (format == NULL) {
1766 LOGE("NULL pointer data");
1767 return RECORDER_ERROR_INVALID_PARAMETER;
1770 pc = (recorder_cli_s *)recorder;
1771 if (pc->cb_info == NULL) {
1772 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1773 return RECORDER_ERROR_INVALID_PARAMETER;
1776 sock_fd = pc->cb_info->fd;
1780 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1782 if (ret == RECORDER_ERROR_NONE)
1783 *format = (recorder_file_format_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT];
1785 LOGD("ret : 0x%x, format %d", ret, *format);
1791 int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stream_info)
1793 int ret = RECORDER_ERROR_NONE;
1794 muse_recorder_api_e api = MUSE_RECORDER_API_SET_SOUND_STREAM_INFO;
1795 recorder_cli_s *pc = NULL;
1796 bool is_available = false;
1798 int stream_index = 0;
1799 char *stream_type = NULL;
1801 if (recorder == NULL || stream_info == NULL) {
1802 LOGE("NULL pointer handle");
1803 return RECORDER_ERROR_INVALID_PARAMETER;
1806 pc = (recorder_cli_s *)recorder;
1807 if (pc->cb_info == NULL) {
1808 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1809 return RECORDER_ERROR_INVALID_PARAMETER;
1812 sock_fd = pc->cb_info->fd;
1816 ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_RECORDER, &is_available);
1817 if (ret != SOUND_MANAGER_ERROR_NONE) {
1818 LOGE("stream info verification failed");
1819 return RECORDER_ERROR_INVALID_OPERATION;
1822 if (is_available == false) {
1823 LOGE("stream information is not available");
1824 return RECORDER_ERROR_INVALID_OPERATION;
1827 ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
1828 ret |= sound_manager_get_index_from_stream_information(stream_info, &stream_index);
1830 LOGD("sound manager return [0x%x]", ret);
1832 if (ret == SOUND_MANAGER_ERROR_NONE)
1833 muse_recorder_msg_send2(api, sock_fd, pc->cb_info, ret, STRING, stream_type, INT, stream_index);
1835 ret = RECORDER_ERROR_INVALID_OPERATION;
1841 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data)
1843 if (recorder == NULL || callback == NULL) {
1844 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1845 return RECORDER_ERROR_INVALID_PARAMETER;
1847 int ret = RECORDER_ERROR_NONE;
1849 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1850 muse_recorder_api_e api = MUSE_RECORDER_API_SET_STATE_CHANGED_CB;
1852 LOGD("Enter, handle :%x", pc->remote_handle);
1855 if (pc->cb_info == NULL) {
1856 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1857 return RECORDER_ERROR_INVALID_PARAMETER;
1859 sock_fd = pc->cb_info->fd;
1860 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
1861 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
1863 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1864 LOGD("ret : 0x%x", ret);
1869 int recorder_unset_state_changed_cb(recorder_h recorder)
1871 if (recorder == NULL) {
1872 LOGE("NULL pointer handle");
1873 return RECORDER_ERROR_INVALID_PARAMETER;
1875 int ret = RECORDER_ERROR_NONE;
1876 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_STATE_CHANGED_CB;
1877 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1879 if (pc->cb_info == NULL) {
1880 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1881 return RECORDER_ERROR_INVALID_PARAMETER;
1883 sock_fd = pc->cb_info->fd;
1887 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1888 LOGD("ret : 0x%x", ret);
1893 int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data)
1895 if (recorder == NULL || callback == NULL) {
1896 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1897 return RECORDER_ERROR_INVALID_PARAMETER;
1899 int ret = RECORDER_ERROR_NONE;
1901 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1902 muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPTED_CB;
1904 LOGD("Enter, handle :%x", pc->remote_handle);
1907 if (pc->cb_info == NULL) {
1908 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1909 return RECORDER_ERROR_INVALID_PARAMETER;
1911 sock_fd = pc->cb_info->fd;
1912 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
1913 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
1915 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1916 LOGD("ret : 0x%x", ret);
1921 int recorder_unset_interrupted_cb(recorder_h recorder)
1923 if (recorder == NULL) {
1924 LOGE("NULL pointer handle");
1925 return RECORDER_ERROR_INVALID_PARAMETER;
1927 int ret = RECORDER_ERROR_NONE;
1928 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPTED_CB;
1929 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1931 if (pc->cb_info == NULL) {
1932 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1933 return RECORDER_ERROR_INVALID_PARAMETER;
1935 sock_fd = pc->cb_info->fd;
1939 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1940 LOGD("ret : 0x%x", ret);
1945 int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data)
1947 if (recorder == NULL || callback == NULL) {
1948 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1949 return RECORDER_ERROR_INVALID_PARAMETER;
1951 int ret = RECORDER_ERROR_NONE;
1953 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1954 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_STREAM_CB;
1956 LOGD("Enter, handle :%x", pc->remote_handle);
1959 if (pc->cb_info == NULL) {
1960 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1961 return RECORDER_ERROR_INVALID_PARAMETER;
1963 sock_fd = pc->cb_info->fd;
1964 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
1965 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
1967 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1968 LOGD("ret : 0x%x", ret);
1973 int recorder_unset_audio_stream_cb(recorder_h recorder)
1975 if (recorder == NULL) {
1976 LOGE("NULL pointer handle");
1977 return RECORDER_ERROR_INVALID_PARAMETER;
1979 int ret = RECORDER_ERROR_NONE;
1980 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_AUDIO_STREAM_CB;
1981 recorder_cli_s *pc = (recorder_cli_s *)recorder;
1983 if (pc->cb_info == NULL) {
1984 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
1985 return RECORDER_ERROR_INVALID_PARAMETER;
1987 sock_fd = pc->cb_info->fd;
1991 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
1992 LOGD("ret : 0x%x", ret);
1997 int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data)
1999 if (recorder == NULL || callback == NULL) {
2000 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2001 return RECORDER_ERROR_INVALID_PARAMETER;
2003 int ret = RECORDER_ERROR_NONE;
2005 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2006 muse_recorder_api_e api = MUSE_RECORDER_API_SET_ERROR_CB;
2008 LOGD("Enter, handle :%x", pc->remote_handle);
2011 if (pc->cb_info == NULL) {
2012 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2013 return RECORDER_ERROR_INVALID_PARAMETER;
2015 sock_fd = pc->cb_info->fd;
2016 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
2017 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
2019 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2020 LOGD("ret : 0x%x", ret);
2025 int recorder_unset_error_cb(recorder_h recorder)
2027 if (recorder == NULL) {
2028 LOGE("NULL pointer handle");
2029 return RECORDER_ERROR_INVALID_PARAMETER;
2031 int ret = RECORDER_ERROR_NONE;
2032 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_ERROR_CB;
2033 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2035 if (pc->cb_info == NULL) {
2036 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2037 return RECORDER_ERROR_INVALID_PARAMETER;
2039 sock_fd = pc->cb_info->fd;
2043 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2044 LOGD("ret : 0x%x", ret);
2049 int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void* user_data)
2051 if (recorder == NULL || callback == NULL) {
2052 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2053 return RECORDER_ERROR_INVALID_PARAMETER;
2055 int ret = RECORDER_ERROR_NONE;
2057 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2058 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_STATUS_CB;
2060 LOGD("Enter, handle :%x", pc->remote_handle);
2063 if (pc->cb_info == NULL) {
2064 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2065 return RECORDER_ERROR_INVALID_PARAMETER;
2067 sock_fd = pc->cb_info->fd;
2068 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
2069 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
2071 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2072 LOGD("ret : 0x%x", ret);
2077 int recorder_unset_recording_status_cb(recorder_h recorder)
2079 if (recorder == NULL) {
2080 LOGE("NULL pointer handle");
2081 return RECORDER_ERROR_INVALID_PARAMETER;
2083 int ret = RECORDER_ERROR_NONE;
2084 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_STATUS_CB;
2085 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2087 if (pc->cb_info == NULL) {
2088 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2089 return RECORDER_ERROR_INVALID_PARAMETER;
2091 sock_fd = pc->cb_info->fd;
2095 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2096 LOGD("ret : 0x%x", ret);
2101 int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void* user_data)
2103 if (recorder == NULL || callback == NULL) {
2104 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2105 return RECORDER_ERROR_INVALID_PARAMETER;
2107 int ret = RECORDER_ERROR_NONE;
2109 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2110 muse_recorder_api_e api = MUSE_RECORDER_API_SET_RECORDING_LIMIT_REACHED_CB;
2112 LOGD("Enter, handle :%x", pc->remote_handle);
2115 if (pc->cb_info == NULL) {
2116 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2117 return RECORDER_ERROR_INVALID_PARAMETER;
2119 sock_fd = pc->cb_info->fd;
2120 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
2121 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
2123 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2124 LOGD("ret : 0x%x", ret);
2129 int recorder_unset_recording_limit_reached_cb(recorder_h recorder)
2131 if (recorder == NULL) {
2132 LOGE("NULL pointer handle");
2133 return RECORDER_ERROR_INVALID_PARAMETER;
2135 int ret = RECORDER_ERROR_NONE;
2136 muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_RECORDING_LIMIT_REACHED_CB;
2137 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2139 if (pc->cb_info == NULL) {
2140 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2141 return RECORDER_ERROR_INVALID_PARAMETER;
2143 sock_fd = pc->cb_info->fd;
2147 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2148 LOGD("ret : 0x%x", ret);
2153 int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb, void *user_data)
2155 if (recorder == NULL || foreach_cb == NULL) {
2156 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2157 return RECORDER_ERROR_INVALID_PARAMETER;
2159 int ret = RECORDER_ERROR_NONE;
2161 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2162 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_FILE_FORMAT;
2164 LOGD("Enter, handle :%x", pc->remote_handle);
2167 if (pc->cb_info == NULL) {
2168 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2169 return RECORDER_ERROR_INVALID_PARAMETER;
2171 sock_fd = pc->cb_info->fd;
2172 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = foreach_cb;
2173 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = user_data;
2175 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2176 LOGD("ret : 0x%x", ret);
2181 int recorder_attr_set_size_limit(recorder_h recorder, int kbyte)
2183 if (recorder == NULL) {
2184 LOGE("NULL pointer handle");
2185 return RECORDER_ERROR_INVALID_PARAMETER;
2187 int ret = RECORDER_ERROR_NONE;
2188 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_SIZE_LIMIT;
2189 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2191 if (pc->cb_info == NULL) {
2192 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2193 return RECORDER_ERROR_INVALID_PARAMETER;
2195 sock_fd = pc->cb_info->fd;
2199 muse_recorder_msg_send1(api,
2204 LOGD("ret : 0x%x", ret);
2209 int recorder_attr_set_time_limit(recorder_h recorder, int second)
2211 if (recorder == NULL) {
2212 LOGE("NULL pointer handle");
2213 return RECORDER_ERROR_INVALID_PARAMETER;
2215 int ret = RECORDER_ERROR_NONE;
2216 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_TIME_LIMIT;
2217 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2219 if (pc->cb_info == NULL) {
2220 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2221 return RECORDER_ERROR_INVALID_PARAMETER;
2223 sock_fd = pc->cb_info->fd;
2227 muse_recorder_msg_send1(api,
2232 LOGD("ret : 0x%x", ret);
2237 int recorder_attr_set_audio_device(recorder_h recorder, recorder_audio_device_e device)
2239 if (recorder == NULL) {
2240 LOGE("NULL pointer handle");
2241 return RECORDER_ERROR_INVALID_PARAMETER;
2243 int ret = RECORDER_ERROR_NONE;
2244 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_DEVICE;
2245 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2247 if (pc->cb_info == NULL) {
2248 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2249 return RECORDER_ERROR_INVALID_PARAMETER;
2251 sock_fd = pc->cb_info->fd;
2252 int set_device = (int)device;
2256 muse_recorder_msg_send1(api,
2261 LOGD("ret : 0x%x", ret);
2266 int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec)
2268 int ret = RECORDER_ERROR_NONE;
2269 muse_recorder_api_e api = MUSE_RECORDER_API_SET_AUDIO_ENCODER;
2270 recorder_cli_s *pc = NULL;
2272 int set_codec = (int)codec;
2274 if (recorder == NULL) {
2275 LOGE("NULL pointer handle");
2276 return RECORDER_ERROR_INVALID_PARAMETER;
2279 pc = (recorder_cli_s *)recorder;
2280 if (pc->cb_info == NULL) {
2281 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2282 return RECORDER_ERROR_INVALID_PARAMETER;
2287 sock_fd = pc->cb_info->fd;
2288 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_codec);
2290 LOGD("ret : 0x%x", ret);
2296 int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec)
2298 int ret = RECORDER_ERROR_NONE;
2300 muse_recorder_api_e api = MUSE_RECORDER_API_GET_AUDIO_ENCODER;
2301 recorder_cli_s *pc = NULL;
2303 if (recorder == NULL) {
2304 LOGE("NULL pointer handle");
2305 return RECORDER_ERROR_INVALID_PARAMETER;
2308 if (codec == NULL) {
2309 LOGE("codec is NULL");
2310 return RECORDER_ERROR_INVALID_PARAMETER;
2313 pc = (recorder_cli_s *)recorder;
2314 if (pc->cb_info == NULL) {
2315 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2316 return RECORDER_ERROR_INVALID_PARAMETER;
2319 sock_fd = pc->cb_info->fd;
2323 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2325 if (ret == RECORDER_ERROR_NONE)
2326 *codec = (recorder_audio_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER];
2328 LOGD("ret : 0x%x, codec %d", ret, *codec);
2334 int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec)
2336 if (recorder == NULL) {
2337 LOGE("NULL pointer handle");
2338 return RECORDER_ERROR_INVALID_PARAMETER;
2340 if (codec < RECORDER_VIDEO_CODEC_H263 || codec > RECORDER_VIDEO_CODEC_THEORA) {
2341 LOGE("invalid codec %d", codec);
2342 return RECORDER_ERROR_INVALID_PARAMETER;
2344 int ret = RECORDER_ERROR_NONE;
2345 muse_recorder_api_e api = MUSE_RECORDER_API_SET_VIDEO_ENCODER;
2346 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2348 if (pc->cb_info == NULL) {
2349 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2350 return RECORDER_ERROR_INVALID_PARAMETER;
2352 sock_fd = pc->cb_info->fd;
2353 int set_codec = (int)codec;
2357 muse_recorder_msg_send1(api,
2362 LOGD("ret : 0x%x", ret);
2367 int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec)
2369 int ret = RECORDER_ERROR_NONE;
2371 muse_recorder_api_e api = MUSE_RECORDER_API_GET_VIDEO_ENCODER;
2372 recorder_cli_s *pc = NULL;
2374 if (recorder == NULL) {
2375 LOGE("NULL pointer handle");
2376 return RECORDER_ERROR_INVALID_PARAMETER;
2379 if (codec == NULL) {
2380 LOGE("codec is NULL");
2381 return RECORDER_ERROR_INVALID_PARAMETER;
2384 pc = (recorder_cli_s *)recorder;
2385 if (pc->cb_info == NULL) {
2386 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2387 return RECORDER_ERROR_INVALID_PARAMETER;
2390 sock_fd = pc->cb_info->fd;
2394 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2396 if (ret == RECORDER_ERROR_NONE)
2397 *codec = (recorder_audio_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER];
2399 LOGD("ret : 0x%x, codec %d", ret, *codec);
2405 int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate)
2407 if (recorder == NULL) {
2408 LOGE("NULL pointer handle");
2409 return RECORDER_ERROR_INVALID_PARAMETER;
2411 if (samplerate < 1) {
2412 LOGE("invalid samplerate %d", samplerate);
2413 return RECORDER_ERROR_INVALID_PARAMETER;
2415 int ret = RECORDER_ERROR_NONE;
2416 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_SAMPLERATE;
2417 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2419 if (pc->cb_info == NULL) {
2420 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2421 return RECORDER_ERROR_INVALID_PARAMETER;
2423 sock_fd = pc->cb_info->fd;
2425 LOGD("ENTER, samplerate : %d", samplerate);
2427 muse_recorder_msg_send1(api,
2432 LOGD("ret : 0x%x, samplerate : %d", ret, samplerate);
2437 int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate)
2439 if (recorder == NULL) {
2440 LOGE("NULL pointer handle");
2441 return RECORDER_ERROR_INVALID_PARAMETER;
2444 LOGE("invalid bitrate %d", bitrate);
2445 return RECORDER_ERROR_INVALID_PARAMETER;
2447 int ret = RECORDER_ERROR_NONE;
2448 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_ENCODER_BITRATE;
2449 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2451 if (pc->cb_info == NULL) {
2452 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2453 return RECORDER_ERROR_INVALID_PARAMETER;
2455 sock_fd = pc->cb_info->fd;
2459 muse_recorder_msg_send1(api,
2464 LOGD("ret : 0x%x", ret);
2469 int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate)
2471 if (recorder == NULL) {
2472 LOGE("NULL pointer handle");
2473 return RECORDER_ERROR_INVALID_PARAMETER;
2476 int ret = RECORDER_ERROR_NONE;
2477 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_VIDEO_ENCODER_BITRATE;
2478 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2480 if (pc->cb_info == NULL) {
2481 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2482 return RECORDER_ERROR_INVALID_PARAMETER;
2484 sock_fd = pc->cb_info->fd;
2488 muse_recorder_msg_send1(api,
2493 LOGD("ret : 0x%x", ret);
2498 int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte)
2500 int ret = RECORDER_ERROR_NONE;
2502 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_SIZE_LIMIT;
2503 recorder_cli_s *pc = NULL;
2505 if (recorder == NULL) {
2506 LOGE("NULL pointer handle");
2507 return RECORDER_ERROR_INVALID_PARAMETER;
2510 if (kbyte == NULL) {
2511 LOGE("NULL pointer kbyte");
2512 return RECORDER_ERROR_INVALID_PARAMETER;
2515 pc = (recorder_cli_s *)recorder;
2516 if (pc->cb_info == NULL) {
2517 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2518 return RECORDER_ERROR_INVALID_PARAMETER;
2521 sock_fd = pc->cb_info->fd;
2525 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2527 if (ret == RECORDER_ERROR_NONE)
2528 *kbyte = pc->cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT];
2530 LOGD("ret : 0x%x, %d kbyte", ret, *kbyte);
2536 int recorder_attr_get_time_limit(recorder_h recorder, int *second)
2538 int ret = RECORDER_ERROR_NONE;
2540 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_TIME_LIMIT;
2541 recorder_cli_s *pc = NULL;
2543 if (recorder == NULL) {
2544 LOGE("NULL pointer handle");
2545 return RECORDER_ERROR_INVALID_PARAMETER;
2548 if (second == NULL) {
2549 LOGE("NULL pointer second");
2550 return RECORDER_ERROR_INVALID_PARAMETER;
2553 pc = (recorder_cli_s *)recorder;
2554 if (pc->cb_info == NULL) {
2555 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2556 return RECORDER_ERROR_INVALID_PARAMETER;
2559 sock_fd = pc->cb_info->fd;
2563 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2565 if (ret == RECORDER_ERROR_NONE)
2566 *second = pc->cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT];
2568 LOGD("ret : 0x%x, %d second", ret, *second);
2574 int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e *device)
2576 int ret = RECORDER_ERROR_NONE;
2578 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_DEVICE;
2579 recorder_cli_s *pc = NULL;
2581 if (recorder == NULL) {
2582 LOGE("NULL pointer handle");
2583 return RECORDER_ERROR_INVALID_PARAMETER;
2586 if (device == NULL) {
2587 LOGE("NULL pointer device");
2588 return RECORDER_ERROR_INVALID_PARAMETER;
2591 pc = (recorder_cli_s *)recorder;
2592 if (pc->cb_info == NULL) {
2593 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2594 return RECORDER_ERROR_INVALID_PARAMETER;
2597 sock_fd = pc->cb_info->fd;
2601 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2603 if (ret == RECORDER_ERROR_NONE)
2604 *device = (recorder_audio_device_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE];
2606 LOGD("ret : 0x%x, device %d", ret, *device);
2612 int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate)
2614 int ret = RECORDER_ERROR_NONE;
2616 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_SAMPLERATE;
2617 recorder_cli_s *pc = NULL;
2619 if (recorder == NULL) {
2620 LOGE("NULL pointer handle");
2621 return RECORDER_ERROR_INVALID_PARAMETER;
2624 if (samplerate == NULL) {
2625 LOGE("NULL pointer handle");
2626 return RECORDER_ERROR_INVALID_PARAMETER;
2629 pc = (recorder_cli_s *)recorder;
2630 if (pc->cb_info == NULL) {
2631 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2632 return RECORDER_ERROR_INVALID_PARAMETER;
2635 sock_fd = pc->cb_info->fd;
2639 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2641 if (ret == RECORDER_ERROR_NONE)
2642 *samplerate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE];
2644 LOGD("ret : 0x%x, samplerate %d", ret, *samplerate);
2650 int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate)
2652 int ret = RECORDER_ERROR_NONE;
2654 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_ENCODER_BITRATE;
2655 recorder_cli_s *pc = NULL;
2657 if (recorder == NULL) {
2658 LOGE("NULL pointer handle");
2659 return RECORDER_ERROR_INVALID_PARAMETER;
2662 if (bitrate == NULL) {
2663 LOGE("NULL pointer");
2664 return RECORDER_ERROR_INVALID_PARAMETER;
2667 pc = (recorder_cli_s *)recorder;
2668 if (pc->cb_info == NULL) {
2669 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2670 return RECORDER_ERROR_INVALID_PARAMETER;
2673 sock_fd = pc->cb_info->fd;
2677 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2679 if (ret == RECORDER_ERROR_NONE)
2680 *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE];
2682 LOGD("ret : 0x%x, bitrate %d", ret, *bitrate);
2688 int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate)
2690 int ret = RECORDER_ERROR_NONE;
2692 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_VIDEO_ENCODER_BITRATE;
2693 recorder_cli_s *pc = NULL;
2695 if (recorder == NULL) {
2696 LOGE("NULL pointer handle");
2697 return RECORDER_ERROR_INVALID_PARAMETER;
2700 if (bitrate == NULL) {
2701 LOGE("NULL pointer");
2702 return RECORDER_ERROR_INVALID_PARAMETER;
2705 pc = (recorder_cli_s *)recorder;
2706 if (pc->cb_info == NULL) {
2707 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2708 return RECORDER_ERROR_INVALID_PARAMETER;
2711 sock_fd = pc->cb_info->fd;
2715 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2717 if (ret == RECORDER_ERROR_NONE)
2718 *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE];
2720 LOGD("ret : 0x%x", ret);
2726 int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb, void *user_data)
2728 if (recorder == NULL || foreach_cb == NULL) {
2729 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2730 return RECORDER_ERROR_INVALID_PARAMETER;
2732 int ret = RECORDER_ERROR_NONE;
2734 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2735 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_AUDIO_ENCODER;
2737 LOGD("Enter, handle :%x", pc->remote_handle);
2740 if (pc->cb_info == NULL) {
2741 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2742 return RECORDER_ERROR_INVALID_PARAMETER;
2744 sock_fd = pc->cb_info->fd;
2745 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = foreach_cb;
2746 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = user_data;
2748 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2749 LOGD("ret : 0x%x", ret);
2754 int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb, void *user_data)
2756 if (recorder == NULL || foreach_cb == NULL) {
2757 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2758 return RECORDER_ERROR_INVALID_PARAMETER;
2760 int ret = RECORDER_ERROR_NONE;
2762 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2763 muse_recorder_api_e api = MUSE_RECORDER_API_FOREACH_SUPPORTED_VIDEO_ENCODER;
2765 LOGD("Enter, handle :%x", pc->remote_handle);
2768 if (pc->cb_info == NULL) {
2769 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2770 return RECORDER_ERROR_INVALID_PARAMETER;
2772 sock_fd = pc->cb_info->fd;
2773 pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = foreach_cb;
2774 pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = user_data;
2776 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2777 LOGD("ret : 0x%x", ret);
2782 int recorder_attr_set_mute(recorder_h recorder, bool enable)
2784 if (recorder == NULL) {
2785 LOGE("NULL pointer handle");
2786 return RECORDER_ERROR_INVALID_PARAMETER;
2788 int ret = RECORDER_ERROR_NONE;
2789 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_MUTE;
2790 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2792 if (pc->cb_info == NULL) {
2793 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2794 return RECORDER_ERROR_INVALID_PARAMETER;
2796 sock_fd = pc->cb_info->fd;
2797 int set_enable = (int)enable;
2801 muse_recorder_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
2803 LOGD("ret : 0x%x", ret);
2809 bool recorder_attr_is_muted(recorder_h recorder)
2811 if (recorder == NULL) {
2812 LOGE("NULL pointer handle");
2815 int ret = RECORDER_ERROR_NONE;
2816 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_IS_MUTED;
2817 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2819 if (pc->cb_info == NULL) {
2820 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2821 return RECORDER_ERROR_INVALID_PARAMETER;
2823 sock_fd = pc->cb_info->fd;
2827 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2828 LOGD("ret : 0x%x", ret);
2833 int recorder_attr_set_recording_motion_rate(recorder_h recorder, double rate)
2835 if (recorder == NULL) {
2836 LOGE("NULL pointer handle");
2837 return RECORDER_ERROR_INVALID_PARAMETER;
2839 int ret = RECORDER_ERROR_NONE;
2840 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_RECORDING_MOTION_RATE;
2841 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2843 if (pc->cb_info == NULL) {
2844 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2845 return RECORDER_ERROR_INVALID_PARAMETER;
2847 sock_fd = pc->cb_info->fd;
2849 LOGD("ENTER - %.20lf", rate);
2851 muse_recorder_msg_send1(api,
2857 LOGD("ret : 0x%x", ret);
2863 int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate)
2865 int ret = RECORDER_ERROR_NONE;
2867 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_RECORDING_MOTION_RATE;
2868 recorder_cli_s *pc = NULL;
2870 if (recorder == NULL) {
2871 LOGE("NULL pointer handle");
2872 return RECORDER_ERROR_INVALID_PARAMETER;
2876 LOGE("rate is NULL");
2877 return RECORDER_ERROR_INVALID_PARAMETER;
2880 pc = (recorder_cli_s *)recorder;
2881 if (pc->cb_info == NULL) {
2882 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2883 return RECORDER_ERROR_INVALID_PARAMETER;
2886 sock_fd = pc->cb_info->fd;
2890 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2891 if (ret == RECORDER_ERROR_NONE)
2892 *rate = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE];
2894 LOGD("ret : 0x%x - rate %lf", ret, *rate);
2900 int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count)
2902 if (recorder == NULL) {
2903 LOGE("NULL pointer handle");
2904 return RECORDER_ERROR_INVALID_PARAMETER;
2906 int ret = RECORDER_ERROR_NONE;
2907 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_AUDIO_CHANNEL;
2908 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2910 if (pc->cb_info == NULL) {
2911 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2912 return RECORDER_ERROR_INVALID_PARAMETER;
2914 sock_fd = pc->cb_info->fd;
2918 muse_recorder_msg_send1(api,
2922 INT, channel_count);
2923 LOGD("ret : 0x%x", ret);
2928 int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count)
2930 int ret = RECORDER_ERROR_NONE;
2932 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_AUDIO_CHANNEL;
2933 recorder_cli_s *pc = NULL;
2935 if (recorder == NULL) {
2936 LOGE("NULL pointer handle");
2937 return RECORDER_ERROR_INVALID_PARAMETER;
2940 if (channel_count == NULL) {
2941 LOGE("channel_count is NULL");
2942 return RECORDER_ERROR_INVALID_PARAMETER;
2945 pc = (recorder_cli_s *)recorder;
2946 if (pc->cb_info == NULL) {
2947 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2948 return RECORDER_ERROR_INVALID_PARAMETER;
2951 sock_fd = pc->cb_info->fd;
2955 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
2957 if (ret == RECORDER_ERROR_NONE)
2958 *channel_count = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL];
2960 LOGD("ret : 0x%x, channel count %d", ret, *channel_count);
2966 int recorder_attr_set_orientation_tag(recorder_h recorder, recorder_rotation_e orientation)
2968 if (recorder == NULL) {
2969 LOGE("NULL pointer handle");
2970 return RECORDER_ERROR_INVALID_PARAMETER;
2972 if (orientation > RECORDER_ROTATION_270) {
2973 LOGE("invalid orientation %d", orientation);
2974 return RECORDER_ERROR_INVALID_PARAMETER;
2976 int ret = RECORDER_ERROR_NONE;
2977 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_SET_ORIENTATION_TAG;
2978 recorder_cli_s *pc = (recorder_cli_s *)recorder;
2980 if (pc->cb_info == NULL) {
2981 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
2982 return RECORDER_ERROR_INVALID_PARAMETER;
2984 sock_fd = pc->cb_info->fd;
2985 int set_orientation = (int)orientation;
2989 muse_recorder_msg_send1(api,
2993 INT, set_orientation);
2994 LOGD("ret : 0x%x", ret);
2999 int recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e *orientation)
3001 int ret = RECORDER_ERROR_NONE;
3003 muse_recorder_api_e api = MUSE_RECORDER_API_ATTR_GET_ORIENTATION_TAG;
3004 recorder_cli_s *pc = NULL;
3006 if (recorder == NULL) {
3007 LOGE("NULL pointer handle");
3008 return RECORDER_ERROR_INVALID_PARAMETER;
3011 if (orientation == NULL) {
3012 LOGE("orientation is NULL");
3013 return RECORDER_ERROR_INVALID_PARAMETER;
3016 pc = (recorder_cli_s *)recorder;
3017 if (pc->cb_info == NULL) {
3018 LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
3019 return RECORDER_ERROR_INVALID_PARAMETER;
3022 sock_fd = pc->cb_info->fd;
3026 muse_recorder_msg_send(api, sock_fd, pc->cb_info, ret);
3028 if (ret == RECORDER_ERROR_NONE)
3029 *orientation = (recorder_rotation_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG];
3031 LOGD("ret : 0x%x, orientation %d", ret, *orientation);