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.
23 #include <mm_camcorder.h>
28 #include <recorder_private.h>
34 #define LOG_TAG "TIZEN_N_RECORDER"
36 #define LOWSET_DECIBEL -300.0
40 * camera_private function
42 int _camera_get_mm_handle(camera_h camera , MMHandleType *handle);
43 int _camera_set_relay_mm_message_callback(camera_h camera, MMMessageCallback callback, void *user_data);
45 * end of camera_private function
48 static int __mm_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *user_param);
49 static int __mm_recorder_msg_cb(int message, void *param, void *user_data);
52 static int __convert_error_code_camera_to_recorder(int code){
56 case CAMERA_ERROR_INVALID_STATE :
57 new_code = RECORDER_ERROR_INVALID_STATE;
59 case CAMERA_ERROR_DEVICE:
60 new_code = RECORDER_ERROR_DEVICE;
62 case CAMERA_ERROR_SOUND_POLICY:
63 new_code = RECORDER_ERROR_SOUND_POLICY;
65 case CAMERA_ERROR_SECURITY_RESTRICTED:
66 new_code = RECORDER_ERROR_SECURITY_RESTRICTED;
72 static int __convert_recorder_error_code(const char *func, int code){
73 int ret = RECORDER_ERROR_INVALID_OPERATION;
74 char *errorstr = NULL;
78 case RECORDER_ERROR_INVALID_PARAMETER:
79 ret = RECORDER_ERROR_INVALID_PARAMETER;
80 errorstr = "INVALID_PARAMETER";
83 ret = RECORDER_ERROR_NONE;
84 errorstr = "ERROR_NONE";
86 case MM_ERROR_CAMCORDER_INVALID_ARGUMENT :
87 case MM_ERROR_COMMON_INVALID_ATTRTYPE :
88 case MM_ERROR_COMMON_INVALID_PERMISSION :
89 case MM_ERROR_COMMON_OUT_OF_ARRAY :
90 case MM_ERROR_COMMON_OUT_OF_RANGE :
91 case MM_ERROR_COMMON_ATTR_NOT_EXIST :
92 ret = RECORDER_ERROR_INVALID_PARAMETER;
93 errorstr = "INVALID_PARAMETER";
95 case MM_ERROR_CAMCORDER_NOT_INITIALIZED :
96 case MM_ERROR_CAMCORDER_INVALID_STATE :
97 ret = RECORDER_ERROR_INVALID_STATE;
98 errorstr = "INVALID_STATE";
101 case MM_ERROR_CAMCORDER_DEVICE :
102 case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND :
103 case MM_ERROR_CAMCORDER_DEVICE_BUSY :
104 case MM_ERROR_CAMCORDER_DEVICE_OPEN :
105 case MM_ERROR_CAMCORDER_DEVICE_IO :
106 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT :
107 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE :
108 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG :
109 case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER :
110 ret = RECORDER_ERROR_DEVICE;
111 errorstr = "ERROR_DEVICE";
114 case MM_ERROR_CAMCORDER_GST_CORE :
115 case MM_ERROR_CAMCORDER_GST_LIBRARY :
116 case MM_ERROR_CAMCORDER_GST_RESOURCE :
117 case MM_ERROR_CAMCORDER_GST_STREAM :
118 case MM_ERROR_CAMCORDER_GST_STATECHANGE :
119 case MM_ERROR_CAMCORDER_GST_NEGOTIATION :
120 case MM_ERROR_CAMCORDER_GST_LINK :
121 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR :
122 case MM_ERROR_CAMCORDER_ENCODER :
123 case MM_ERROR_CAMCORDER_ENCODER_BUFFER :
124 case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE :
125 case MM_ERROR_CAMCORDER_ENCODER_WORKING :
126 case MM_ERROR_CAMCORDER_INTERNAL :
127 case MM_ERROR_CAMCORDER_NOT_SUPPORTED :
128 case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT :
129 case MM_ERROR_CAMCORDER_CMD_IS_RUNNING :
130 case MM_ERROR_CAMCORDER_DSP_FAIL :
131 case MM_ERROR_CAMCORDER_AUDIO_EMPTY :
132 case MM_ERROR_CAMCORDER_CREATE_CONFIGURE :
133 case MM_ERROR_CAMCORDER_FILE_SIZE_OVER :
134 case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF :
135 case MM_ERROR_CAMCORDER_INVALID_CONDITION :
136 ret = RECORDER_ERROR_INVALID_OPERATION;
137 errorstr = "INVALID_OPERATION";
139 case MM_ERROR_CAMCORDER_RESOURCE_CREATION :
140 case MM_ERROR_COMMON_OUT_OF_MEMORY:
141 ret = RECORDER_ERROR_OUT_OF_MEMORY;
142 errorstr = "OUT_OF_MEMORY";
145 case MM_ERROR_POLICY_BLOCKED:
146 ret = RECORDER_ERROR_SOUND_POLICY;
147 errorstr = "ERROR_SOUND_POLICY";
150 case MM_ERROR_POLICY_RESTRICTED:
151 ret = RECORDER_ERROR_SECURITY_RESTRICTED;
152 errorstr = "ERROR_RESTRICTED";
156 ret = RECORDER_ERROR_INVALID_OPERATION;
157 errorstr = "INVALID_OPERATION";
161 LOGE( "[%s] %s(0x%08x) : core frameworks error code(0x%08x)",func, errorstr, ret, code);
167 static recorder_state_e __recorder_state_convert(MMCamcorderStateType mm_state )
169 recorder_state_e state = RECORDER_STATE_NONE;
171 case MM_CAMCORDER_STATE_NONE:
172 state = RECORDER_STATE_NONE;
174 case MM_CAMCORDER_STATE_NULL:
175 state = RECORDER_STATE_CREATED;
177 case MM_CAMCORDER_STATE_READY:
178 state = RECORDER_STATE_CREATED;
180 case MM_CAMCORDER_STATE_PREPARE:
181 state = RECORDER_STATE_READY;
183 case MM_CAMCORDER_STATE_CAPTURING:
184 state = RECORDER_STATE_READY;
186 case MM_CAMCORDER_STATE_RECORDING:
187 state = RECORDER_STATE_RECORDING;
189 case MM_CAMCORDER_STATE_PAUSED:
190 state = RECORDER_STATE_PAUSED;
193 state = RECORDER_STATE_NONE;
200 static int __mm_recorder_msg_cb(int message, void *param, void *user_data){
201 recorder_s * handle = (recorder_s*)user_data;
202 MMMessageParamType *m = (MMMessageParamType*)param;
203 recorder_state_e previous_state;
206 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
207 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
208 case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
209 previous_state = handle->state;
210 handle->state = __recorder_state_convert(m->state.current);
211 recorder_policy_e policy = RECORDER_POLICY_NONE;
212 if(message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM )
213 policy = RECORDER_POLICY_SOUND;
214 else if( message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY )
215 policy = RECORDER_POLICY_SECURITY;
217 if( previous_state != handle->state && handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE] ){
218 ((recorder_state_changed_cb)handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, policy , handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE]);
220 // should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state
221 if( policy != RECORDER_POLICY_NONE ){
222 if( previous_state != handle->state && handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED] ){
223 ((recorder_interrupted_cb)handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED]);
225 if( m->state.previous == MM_CAMCORDER_STATE_PREPARE && m->state.current == MM_CAMCORDER_STATE_PREPARE ){
226 mm_camcorder_unrealize(handle->mm_handle);
231 case MM_MESSAGE_CAMCORDER_MAX_SIZE:
232 case MM_MESSAGE_CAMCORDER_NO_FREE_SPACE:
233 case MM_MESSAGE_CAMCORDER_TIME_LIMIT:
235 recorder_recording_limit_type_e type ;
236 if( MM_MESSAGE_CAMCORDER_MAX_SIZE == message )
237 type = RECORDER_RECORDING_LIMIT_SIZE;
238 else if( MM_MESSAGE_CAMCORDER_NO_FREE_SPACE == message)
239 type = RECORDER_RECORDING_LIMIT_FREE_SPACE;
241 type = RECORDER_RECORDING_LIMIT_TIME;
242 if( handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] ){
243 ((recorder_recording_limit_reached_cb)handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED])(type, handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
247 case MM_MESSAGE_CAMCORDER_RECORDING_STATUS:
248 if( handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS] ){
249 ((recorder_recording_status_cb)handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS])( m->recording_status.elapsed, m->recording_status.filesize, handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
252 case MM_MESSAGE_CAMCORDER_CAPTURED :
254 if( handle->type == _RECORDER_TYPE_AUDIO ){
255 MMCamRecordingReport *report = (MMCamRecordingReport *)m ->data;
256 if( report != NULL && report->recording_filename ){
257 free(report->recording_filename );
258 report->recording_filename = NULL;
267 case MM_MESSAGE_CAMCORDER_ERROR:
269 int errorcode = m->code;
270 int recorder_error = 0;
272 case MM_ERROR_CAMCORDER_DEVICE :
273 case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT :
274 case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE :
275 case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG :
276 recorder_error = RECORDER_ERROR_DEVICE;
278 case MM_ERROR_CAMCORDER_GST_CORE :
279 case MM_ERROR_CAMCORDER_GST_LIBRARY :
280 case MM_ERROR_CAMCORDER_GST_RESOURCE :
281 case MM_ERROR_CAMCORDER_GST_STREAM :
282 case MM_ERROR_CAMCORDER_GST_NEGOTIATION :
283 case MM_ERROR_CAMCORDER_GST_FLOW_ERROR :
284 case MM_ERROR_CAMCORDER_ENCODER :
285 case MM_ERROR_CAMCORDER_ENCODER_BUFFER :
286 case MM_ERROR_CAMCORDER_ENCODER_WORKING :
287 case MM_ERROR_CAMCORDER_MNOTE_CREATION :
288 case MM_ERROR_CAMCORDER_MNOTE_ADD_ENTRY :
289 case MM_ERROR_CAMCORDER_INTERNAL :
290 recorder_error = RECORDER_ERROR_INVALID_OPERATION;
292 case MM_ERROR_CAMCORDER_LOW_MEMORY :
293 case MM_ERROR_CAMCORDER_MNOTE_MALLOC :
294 recorder_error = RECORDER_ERROR_OUT_OF_MEMORY;
297 if( recorder_error != 0 && handle->user_cb[_RECORDER_EVENT_TYPE_ERROR] )
298 ((recorder_error_cb)handle->user_cb[_RECORDER_EVENT_TYPE_ERROR])(errorcode, handle->state , handle->user_data[_RECORDER_EVENT_TYPE_ERROR]);
301 case MM_MESSAGE_CAMCORDER_CURRENT_VOLUME:
302 if( handle->last_max_input_level < m->rec_volume_dB )
303 handle->last_max_input_level = m->rec_volume_dB;
310 static int __mm_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *user_param){
311 if( user_param == NULL || stream == NULL)
314 recorder_s * handle = (recorder_s*)user_param;
315 audio_sample_type_e format = AUDIO_SAMPLE_TYPE_U8;
316 if( stream->format == MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE)
317 format = AUDIO_SAMPLE_TYPE_S16_LE;
319 if( handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM] ){
320 ((recorder_audio_stream_cb)(handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM]))(stream->data,
325 handle->user_data[_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
331 int recorder_create_videorecorder( camera_h camera, recorder_h* recorder){
333 if( camera == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
334 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
338 camera_state_e camera_state;
341 camera_get_state(camera, &camera_state);
342 //TODO. if allow compatible with video mode / image mode, it should be changed
343 if( camera_state != CAMERA_STATE_CREATED){
344 LOGE("[%s] camera state(%d) is not CAMERA_STATE_CREATED ", __func__, camera_state);
345 return RECORDER_ERROR_INVALID_PARAMETER;
348 handle = (recorder_s*)malloc( sizeof(recorder_s) );
350 LOGE("[%s] malloc error", __func__);
351 return RECORDER_ERROR_OUT_OF_MEMORY;
354 memset(handle, 0 , sizeof(recorder_s));
355 handle->last_max_input_level = LOWSET_DECIBEL;
356 handle->camera = camera;
357 //TODO if allow compatible with video mode / image mode, it should be changed.
358 handle->state = RECORDER_STATE_CREATED;
359 _camera_get_mm_handle(camera, &handle->mm_handle);
360 _camera_set_relay_mm_message_callback(camera, __mm_recorder_msg_cb , (void*)handle);
362 handle->type = _RECORDER_TYPE_VIDEO;
363 *recorder = (recorder_h)handle;
365 preview_format = MM_PIXEL_FORMAT_YUYV;
366 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
367 handle->origin_preview_format = preview_format;
368 preview_format = MM_PIXEL_FORMAT_NV12;
369 ret = mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING, &preview_format, NULL);
371 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
372 MMCAM_MODE , MM_CAMCORDER_MODE_VIDEO,
373 MMCAM_CAMERA_FORMAT, preview_format,
375 return __convert_recorder_error_code(__func__, ret);
379 int recorder_create_audiorecorder( recorder_h* recorder){
381 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
386 info.videodev_type= MM_VIDEO_DEVICE_NONE;
388 handle = (recorder_s*)malloc( sizeof(recorder_s) );
390 LOGE( "[%s] OUT_OF_MEMORY(0x%08x)", __func__, RECORDER_ERROR_OUT_OF_MEMORY);
391 return RECORDER_ERROR_OUT_OF_MEMORY;
394 memset(handle, 0 , sizeof(recorder_s));
395 handle->last_max_input_level = LOWSET_DECIBEL;
397 ret = mm_camcorder_create(&handle->mm_handle, &info);
398 if( ret != MM_ERROR_NONE){
400 LOGE("[%s] mm_camcorder_create fail", __func__);
401 return __convert_recorder_error_code(__func__, ret);
403 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
404 MMCAM_MODE , MM_CAMCORDER_MODE_AUDIO,
407 if( ret != MM_ERROR_NONE){
408 mm_camcorder_destroy(handle->mm_handle);
410 LOGE("[%s] AUDIO mode setting fail", __func__);
411 return __convert_recorder_error_code(__func__, ret);
415 handle->state = RECORDER_STATE_CREATED;
416 mm_camcorder_set_message_callback(handle->mm_handle, __mm_recorder_msg_cb, (void*)handle);
417 handle->camera = NULL;
418 handle->type = _RECORDER_TYPE_AUDIO;
420 *recorder = (recorder_h)handle;
422 return RECORDER_ERROR_NONE;
427 int recorder_get_state(recorder_h recorder, recorder_state_e * state){
429 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
430 if( state == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
432 recorder_s *handle = (recorder_s*)recorder;
434 MMCamcorderStateType mmstate ;
435 recorder_state_e capi_state;
436 mm_camcorder_get_state(handle->mm_handle, &mmstate);
437 capi_state = __recorder_state_convert(mmstate);
440 return CAMERA_ERROR_NONE;
444 int recorder_destroy( recorder_h recorder){
446 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
450 handle = (recorder_s *) recorder;
451 if( handle->type == _RECORDER_TYPE_VIDEO ){
452 //camera object mode change
453 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
454 MMCAM_MODE , MM_CAMCORDER_MODE_IMAGE,
455 MMCAM_CAMERA_FORMAT, handle->origin_preview_format,
456 MMCAM_IMAGE_ENCODER , MM_IMAGE_CODEC_JPEG,
457 MMCAM_CAPTURE_FORMAT, MM_PIXEL_FORMAT_ENCODED,
458 MMCAM_CAPTURE_COUNT, 1,
460 _camera_set_relay_mm_message_callback(handle->camera , NULL, NULL);
462 ret = mm_camcorder_destroy(handle->mm_handle);
465 if(ret == MM_ERROR_NONE)
468 return __convert_recorder_error_code(__func__, ret);
472 int recorder_prepare( recorder_h recorder){
474 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
476 recorder_s *handle = (recorder_s*)recorder;
478 if( handle->type == _RECORDER_TYPE_VIDEO ){
479 return __convert_error_code_camera_to_recorder(camera_start_preview(handle->camera));
482 MMCamcorderStateType mmstate ;
483 mm_camcorder_get_state(handle->mm_handle, &mmstate);
485 if( mmstate != MM_CAMCORDER_STATE_READY){
486 ret = mm_camcorder_realize(handle->mm_handle);
487 if( ret != MM_ERROR_NONE){
488 LOGE("[%s] mm_camcorder_realize fail", __func__);
489 return __convert_recorder_error_code(__func__, ret);
493 ret = mm_camcorder_start(handle->mm_handle);
495 if( ret != MM_ERROR_NONE){
496 LOGE("[%s] mm_camcorder_start fail", __func__);
497 mm_camcorder_unrealize(handle->mm_handle);
498 return __convert_recorder_error_code(__func__, ret);
501 return RECORDER_ERROR_NONE;
504 int recorder_unprepare( recorder_h recorder){
505 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
507 recorder_s *handle = (recorder_s*)recorder;
509 MMCamcorderStateType mmstate ;
510 mm_camcorder_get_state(handle->mm_handle, &mmstate);
512 if( mmstate == MM_CAMCORDER_STATE_PREPARE){
513 ret = mm_camcorder_stop(handle->mm_handle);
514 if( ret != MM_ERROR_NONE){
515 LOGE("[%s] mm_camcorder_stop fail", __func__);
516 return __convert_recorder_error_code(__func__, ret);
519 ret = mm_camcorder_unrealize(handle->mm_handle);
520 return __convert_recorder_error_code(__func__, ret);
523 int recorder_start( recorder_h recorder){
525 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
527 recorder_s *handle = (recorder_s*)recorder;
528 ret = mm_camcorder_record(handle->mm_handle);
529 return __convert_recorder_error_code(__func__, ret);
532 int recorder_pause( recorder_h recorder){
534 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
536 recorder_s *handle = (recorder_s*)recorder;
537 ret = mm_camcorder_pause(handle->mm_handle);
539 return __convert_recorder_error_code(__func__, ret);
542 int recorder_commit( recorder_h recorder){
544 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
546 recorder_s *handle = (recorder_s*)recorder;
547 ret = mm_camcorder_commit(handle->mm_handle);
548 return __convert_recorder_error_code(__func__, ret);
551 int recorder_cancel( recorder_h recorder){
553 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
555 recorder_s *handle = (recorder_s*)recorder;
556 ret = mm_camcorder_cancel(handle->mm_handle);
557 return __convert_recorder_error_code(__func__, ret);
560 int recorder_get_audio_level(recorder_h recorder, double *level){
561 if( recorder == NULL || level == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
562 recorder_s *handle = (recorder_s*)recorder;
564 recorder_state_e state;
565 recorder_get_state(recorder, &state);
566 if( state < RECORDER_STATE_RECORDING ){
567 LOGE("[%s]RECORDER_ERROR_INVALID_STATE(0x%08x) ",__func__, RECORDER_ERROR_INVALID_STATE);
568 return RECORDER_ERROR_INVALID_STATE;
571 *level = handle->last_max_input_level ;
572 handle->last_max_input_level = LOWSET_DECIBEL;
573 return RECORDER_ERROR_NONE;
576 int recorder_set_filename(recorder_h recorder, const char *filename){
578 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
579 g_return_val_if_fail(filename != NULL, RECORDER_ERROR_INVALID_PARAMETER);
581 recorder_s * handle = (recorder_s*)recorder;
582 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_FILENAME , filename , strlen(filename), NULL);
583 return __convert_recorder_error_code(__func__, ret);
587 int recorder_get_filename(recorder_h recorder, char **filename){
589 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
590 g_return_val_if_fail(filename != NULL, RECORDER_ERROR_INVALID_PARAMETER);
592 recorder_s * handle = (recorder_s*)recorder;
594 char *record_filename;
595 int record_filename_size;
596 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_FILENAME , &record_filename, &record_filename_size, NULL);
597 if( ret == CAMERA_ERROR_NONE ){
598 *filename = strdup(record_filename);
601 return __convert_recorder_error_code(__func__, ret);
606 int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format){
608 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
610 int format_table[5] = { MM_FILE_FORMAT_3GP , // RECORDER_FILE_FORMAT_3GP,
611 MM_FILE_FORMAT_MP4 , //RECORDER_FILE_FORMAT_MP4,
612 MM_FILE_FORMAT_AMR, //RECORDER_FILE_FORMAT_AMR,
613 MM_FILE_FORMAT_AAC, //RECORDER_FILE_FORMAT_ADTS
614 MM_FILE_FORMAT_WAV //RECORDER_FILE_FORMAT_WAV
617 if( format < RECORDER_FILE_FORMAT_3GP || format > RECORDER_FILE_FORMAT_WAV )
618 return RECORDER_ERROR_INVALID_PARAMETER;
620 recorder_s * handle = (recorder_s*)recorder;
621 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_FILE_FORMAT , format_table[format], NULL);
622 return __convert_recorder_error_code(__func__, ret);
625 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format){
627 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
628 g_return_val_if_fail(format != NULL, RECORDER_ERROR_INVALID_PARAMETER);
631 recorder_s * handle = (recorder_s*)recorder;
633 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILE_FORMAT , &mm_format, NULL);
637 case MM_FILE_FORMAT_3GP:
638 *format = RECORDER_FILE_FORMAT_3GP;
640 case MM_FILE_FORMAT_MP4 :
641 *format = RECORDER_FILE_FORMAT_MP4;
643 case MM_FILE_FORMAT_AMR :
644 *format = RECORDER_FILE_FORMAT_AMR;
646 case MM_FILE_FORMAT_AAC :
647 *format = RECORDER_FILE_FORMAT_ADTS;
649 case MM_FILE_FORMAT_WAV:
650 *format = RECORDER_FILE_FORMAT_WAV;
653 ret = MM_ERROR_CAMCORDER_INTERNAL;
657 return __convert_recorder_error_code(__func__, ret);
662 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data){
664 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
665 recorder_s *handle = (recorder_s*)recorder;
666 if( callback == NULL )
667 return RECORDER_ERROR_INVALID_PARAMETER;
669 handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
670 handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
672 return RECORDER_ERROR_NONE;
676 int recorder_unset_state_changed_cb(recorder_h recorder){
678 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
679 recorder_s *handle = (recorder_s*)recorder;
681 handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
682 handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
684 return RECORDER_ERROR_NONE;
687 int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data){
688 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
689 recorder_s *handle = (recorder_s*)recorder;
690 if( callback == NULL )
691 return RECORDER_ERROR_INVALID_PARAMETER;
693 handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
694 handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
696 return RECORDER_ERROR_NONE;
698 int recorder_unset_interrupted_cb(recorder_h recorder){
699 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
700 recorder_s *handle = (recorder_s*)recorder;
702 handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
703 handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
705 return RECORDER_ERROR_NONE;
708 int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data){
709 if( recorder == NULL || callback == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
711 recorder_s *handle = (recorder_s*)recorder;
712 ret = mm_camcorder_set_audio_stream_callback( handle->mm_handle, __mm_audio_stream_cb, handle);
714 handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
715 handle->user_data[_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
717 return __convert_recorder_error_code(__func__, ret);
720 int recorder_unset_audio_stream_cb(recorder_h recorder){
721 if( recorder == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
723 recorder_s *handle = (recorder_s*)recorder;
724 handle->user_cb[_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
725 handle->user_data[_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
726 ret = mm_camcorder_set_audio_stream_callback( handle->mm_handle, NULL, NULL);
727 return __convert_recorder_error_code(__func__, ret);
730 int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void *user_data){
731 if( recorder == NULL || callback == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
732 recorder_s *handle = (recorder_s*)recorder;
733 handle->user_cb[_RECORDER_EVENT_TYPE_ERROR] = callback;
734 handle->user_data[_RECORDER_EVENT_TYPE_ERROR] = user_data;
735 return RECORDER_ERROR_NONE;
738 int recorder_unset_error_cb(recorder_h recorder){
739 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
740 recorder_s *handle = (recorder_s*)recorder;
741 handle->user_cb[_RECORDER_EVENT_TYPE_ERROR] = NULL;
742 handle->user_data[_RECORDER_EVENT_TYPE_ERROR] = NULL;
743 return RECORDER_ERROR_NONE;
746 int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void* user_data){
748 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
749 recorder_s *handle = (recorder_s*)recorder;
750 if( callback == NULL )
751 return RECORDER_ERROR_INVALID_PARAMETER;
753 handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
754 handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
756 return RECORDER_ERROR_NONE;
759 int recorder_unset_recording_status_cb(recorder_h recorder){
761 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
762 recorder_s *handle = (recorder_s*)recorder;
763 handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
764 handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
766 return RECORDER_ERROR_NONE;
770 int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void* user_data){
772 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
773 recorder_s *handle = (recorder_s*)recorder;
774 if( callback == NULL )
775 return RECORDER_ERROR_INVALID_PARAMETER;
777 handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
778 handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
780 return RECORDER_ERROR_NONE;
784 int recorder_unset_recording_limit_reached_cb(recorder_h recorder){
786 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
787 recorder_s *handle = (recorder_s*)recorder;
788 handle->user_cb[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
789 handle->user_data[_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
791 return RECORDER_ERROR_NONE;
794 int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb , void *user_data){
796 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
797 if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
799 recorder_s * handle = (recorder_s*)recorder;
801 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILE_FORMAT , &info);
802 if( ret != RECORDER_ERROR_NONE )
806 for( i=0 ; i < info.int_array.count ; i++)
811 switch( info.int_array.array[i] ){
812 case MM_FILE_FORMAT_3GP:
813 format = RECORDER_FILE_FORMAT_3GP;
815 case MM_FILE_FORMAT_MP4 :
816 format = RECORDER_FILE_FORMAT_MP4;
818 case MM_FILE_FORMAT_AMR :
819 format = RECORDER_FILE_FORMAT_AMR;
821 case MM_FILE_FORMAT_AAC:
822 format = RECORDER_FILE_FORMAT_ADTS;
824 case MM_FILE_FORMAT_WAV:
825 format = RECORDER_FILE_FORMAT_WAV;
831 if ( format != -1 && !foreach_cb(format,user_data) )
834 return RECORDER_ERROR_NONE;
840 int recorder_attr_set_size_limit(recorder_h recorder, int kbyte){
842 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
844 recorder_s * handle = (recorder_s*)recorder;
845 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "target-max-size" , kbyte, NULL);
846 return __convert_recorder_error_code(__func__, ret);
850 int recorder_attr_set_time_limit(recorder_h recorder, int second){
852 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
854 recorder_s * handle = (recorder_s*)recorder;
855 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_TIME_LIMIT , second, NULL);
856 return __convert_recorder_error_code(__func__, ret);
859 int recorder_attr_set_audio_device(recorder_h recorder , recorder_audio_device_e device){
861 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
863 recorder_s * handle = (recorder_s*)recorder;
864 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DEVICE , device, NULL);
865 return __convert_recorder_error_code(__func__, ret);
868 int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec){
870 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
872 if( codec != RECORDER_AUDIO_CODEC_DISABLE && ( codec < RECORDER_AUDIO_CODEC_AMR || codec > RECORDER_AUDIO_CODEC_PCM) )
873 return RECORDER_ERROR_INVALID_PARAMETER;
875 int audio_table[4] = { MM_AUDIO_CODEC_AMR, //RECORDER_AUDIO_CODEC_AMR
876 MM_AUDIO_CODEC_AAC, //RECORDER_AUDIO_CODEC_AAC
877 MM_AUDIO_CODEC_VORBIS, //RECORDER_AUDIO_CODEC_VORBIS
878 MM_AUDIO_CODEC_WAVE //RECORDER_AUDIO_CODEC_PCM
881 recorder_s * handle = (recorder_s*)recorder;
882 if( codec == RECORDER_AUDIO_CODEC_DISABLE )
883 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DISABLE , 1, NULL);
885 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER , audio_table[codec], MMCAM_AUDIO_DISABLE, 0, NULL);
887 return __convert_recorder_error_code(__func__, ret);
891 int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec){
893 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
894 g_return_val_if_fail(codec != NULL, RECORDER_ERROR_INVALID_PARAMETER);
897 int audio_disable = 0;
899 recorder_s * handle = (recorder_s*)recorder;
900 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER , &mm_codec , MMCAM_AUDIO_DISABLE, &audio_disable, NULL);
901 if( ret == 0 && audio_disable == 0 ){
903 case MM_AUDIO_CODEC_AMR :
904 *codec = RECORDER_AUDIO_CODEC_AMR;
906 case MM_AUDIO_CODEC_AAC :
907 *codec = RECORDER_AUDIO_CODEC_AAC;
909 case MM_AUDIO_CODEC_VORBIS:
910 *codec = RECORDER_AUDIO_CODEC_VORBIS;
912 case MM_AUDIO_CODEC_WAVE:
913 *codec = RECORDER_AUDIO_CODEC_PCM;
916 ret = MM_ERROR_CAMCORDER_INTERNAL;
919 }else if( ret == 0 && audio_disable ){
920 *codec = RECORDER_AUDIO_CODEC_DISABLE;
923 return __convert_recorder_error_code(__func__, ret);
926 int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec){
928 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
931 int video_table[4] = { MM_VIDEO_CODEC_H263, //RECORDER_VIDEO_CODEC_H263, /**< H263 codec */
932 MM_VIDEO_CODEC_H264, //RECORDER_VIDEO_CODEC_H264, /**< H264 codec */
933 MM_VIDEO_CODEC_MPEG4, //RECORDER_VIDEO_CODEC_MPEG4, /**< MPEG4 codec */
934 MM_VIDEO_CODEC_THEORA //RECORDER_VIDEO_CODEC_THEORA
936 if( codec < RECORDER_VIDEO_CODEC_H263 || codec > RECORDER_VIDEO_CODEC_THEORA )
937 return RECORDER_ERROR_INVALID_PARAMETER;
938 recorder_s * handle = (recorder_s*)recorder;
940 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER , video_table[codec], NULL);
941 return __convert_recorder_error_code(__func__, ret);
946 int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec){
948 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
949 if( codec == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
954 recorder_s * handle = (recorder_s*)recorder;
955 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER , &mm_codec, NULL);
958 case MM_VIDEO_CODEC_H263 :
959 *codec = RECORDER_VIDEO_CODEC_H263;
961 case MM_VIDEO_CODEC_H264 :
962 *codec = RECORDER_VIDEO_CODEC_H264;
964 case MM_VIDEO_CODEC_MPEG4 :
965 *codec = RECORDER_VIDEO_CODEC_MPEG4;
967 case MM_VIDEO_CODEC_THEORA:
968 *codec = RECORDER_VIDEO_CODEC_THEORA;
971 ret = MM_ERROR_CAMCORDER_INTERNAL;
976 return __convert_recorder_error_code(__func__, ret);
980 int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate){
982 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
984 recorder_s * handle = (recorder_s*)recorder;
985 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_SAMPLERATE , samplerate, NULL);
986 return __convert_recorder_error_code(__func__, ret);
990 int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate){
992 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
994 recorder_s * handle = (recorder_s*)recorder;
995 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER_BITRATE , bitrate, NULL);
996 return __convert_recorder_error_code(__func__, ret);
1000 int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate){
1002 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1004 recorder_s * handle = (recorder_s*)recorder;
1005 ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER_BITRATE , bitrate, NULL);
1006 return __convert_recorder_error_code(__func__, ret);
1010 int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte){
1012 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1014 recorder_s * handle = (recorder_s*)recorder;
1015 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, "target-max-size" , kbyte, NULL);
1016 return __convert_recorder_error_code(__func__, ret);
1019 int recorder_attr_get_time_limit(recorder_h recorder, int *second){
1021 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1023 recorder_s * handle = (recorder_s*)recorder;
1024 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_TIME_LIMIT , second, NULL);
1025 return __convert_recorder_error_code(__func__, ret);
1029 int recorder_attr_get_audio_device(recorder_h recorder , recorder_audio_device_e *device){
1031 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1033 recorder_s * handle = (recorder_s*)recorder;
1034 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DEVICE , device, NULL);
1035 return __convert_recorder_error_code(__func__, ret);
1040 int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate){
1042 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1044 recorder_s * handle = (recorder_s*)recorder;
1045 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_SAMPLERATE , samplerate, NULL);
1046 return __convert_recorder_error_code(__func__, ret);
1050 int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate){
1052 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1054 recorder_s * handle = (recorder_s*)recorder;
1055 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER_BITRATE , bitrate, NULL);
1056 return __convert_recorder_error_code(__func__, ret);
1059 int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate){
1061 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1063 recorder_s * handle = (recorder_s*)recorder;
1064 ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER_BITRATE , bitrate, NULL);
1065 return __convert_recorder_error_code(__func__, ret);
1069 int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb , void *user_data){
1071 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1072 if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1074 recorder_s * handle = (recorder_s*)recorder;
1075 MMCamAttrsInfo info;
1076 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_AUDIO_ENCODER , &info);
1077 if( ret != RECORDER_ERROR_NONE )
1078 return __convert_recorder_error_code(__func__, ret);
1081 for( i=0 ; i < info.int_array.count ; i++)
1085 switch( info.int_array.array[i] ){
1086 case MM_AUDIO_CODEC_AMR:
1087 codec = RECORDER_AUDIO_CODEC_AMR;
1089 case MM_AUDIO_CODEC_AAC :
1090 codec = RECORDER_AUDIO_CODEC_AAC;
1092 case MM_AUDIO_CODEC_VORBIS:
1093 codec = RECORDER_AUDIO_CODEC_VORBIS;
1095 case MM_AUDIO_CODEC_WAVE:
1096 codec = RECORDER_AUDIO_CODEC_PCM;
1101 if( codec != -1 && !foreach_cb(codec,user_data) )
1104 return RECORDER_ERROR_NONE;
1106 int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_supported_video_encoder_cb foreach_cb , void *user_data){
1108 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1109 if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1111 recorder_s * handle = (recorder_s*)recorder;
1112 MMCamAttrsInfo info;
1113 ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_ENCODER , &info);
1114 if( ret != RECORDER_ERROR_NONE )
1115 return __convert_recorder_error_code(__func__, ret);
1118 for( i=0 ; i < info.int_array.count ; i++)
1122 switch( info.int_array.array[i] ){
1123 case MM_VIDEO_CODEC_H263 :
1124 codec = RECORDER_VIDEO_CODEC_H263;
1126 case MM_VIDEO_CODEC_H264 :
1127 codec = RECORDER_VIDEO_CODEC_H264;
1129 case MM_VIDEO_CODEC_MPEG4 :
1130 codec = RECORDER_VIDEO_CODEC_MPEG4;
1132 case MM_VIDEO_CODEC_THEORA :
1133 codec = RECORDER_VIDEO_CODEC_THEORA;
1139 if ( codec != -1 && !foreach_cb(codec,user_data) )
1142 return RECORDER_ERROR_NONE;
1147 int recorder_attr_set_mute(recorder_h recorder, bool enable){
1148 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1149 recorder_s * handle = (recorder_s*)recorder;
1150 int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_VOLUME , enable ? 0.0 : 1.0 , NULL);
1151 return __convert_recorder_error_code(__func__, ret);
1154 bool recorder_attr_is_muted(recorder_h recorder){
1155 if( recorder == NULL){
1156 __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1159 recorder_s * handle = (recorder_s*)recorder;
1160 double volume = 1.0;
1161 mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_VOLUME , &volume , NULL);
1168 int recorder_attr_set_recording_motion_rate(recorder_h recorder , double rate){
1169 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1170 recorder_s * handle = (recorder_s*)recorder;
1171 int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "camera-recording-motion-rate" , rate, NULL);
1172 return __convert_recorder_error_code(__func__, ret);
1175 int recorder_attr_get_recording_motion_rate(recorder_h recorder , double *rate){
1176 if( recorder == NULL || rate == NULL )
1177 return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1179 recorder_s * handle = (recorder_s*)recorder;
1180 int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, "camera-recording-motion-rate" , rate , NULL);
1181 return __convert_recorder_error_code(__func__, ret);
1186 int recorder_attr_set_slow_motion_rate(recorder_h recorder , double rate){
1187 return recorder_attr_set_recording_motion_rate(recorder, rate);
1190 int recorder_attr_get_slow_motion_rate(recorder_h recorder , double *rate){
1191 return recorder_attr_get_recording_motion_rate(recorder, rate);
1195 int recorder_attr_set_audio_channel(recorder_h recorder, int channel_count){
1196 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1197 recorder_s * handle = (recorder_s*)recorder;
1198 int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_CHANNEL, channel_count, NULL);
1199 return __convert_recorder_error_code(__func__, ret);
1202 int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count){
1203 if( recorder == NULL || channel_count == NULL )
1204 return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1206 recorder_s * handle = (recorder_s*)recorder;
1207 int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_CHANNEL , channel_count, NULL);
1208 return __convert_recorder_error_code(__func__, ret);
1211 int recorder_attr_set_recording_orientation(recorder_h recorder, recorder_rotation_e orientation){
1212 if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1213 recorder_s * handle = (recorder_s*)recorder;
1214 int ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "camcorder-rotation", orientation, NULL);
1215 return __convert_recorder_error_code(__func__, ret);
1218 int recorder_attr_get_recording_orientation(recorder_h recorder, recorder_rotation_e *orientation){
1219 if( recorder == NULL || orientation == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
1220 recorder_s * handle = (recorder_s*)recorder;
1221 int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, "camcorder-rotation" , orientation, NULL);
1222 return __convert_recorder_error_code(__func__, ret);