#include <recorder.h>
#include <recorder_private.h>
#include <dlog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
#ifdef LOG_TAG
#undef LOG_TAG
#define LOG_TAG "TIZEN_N_RECORDER"
#define LOWSET_DECIBEL -300.0
+#define RECORDER_PATH_RECORDER_RESOURCE "/usr/share/sounds/mm-camcorder/recorder_resource"
/*
case CAMERA_ERROR_SECURITY_RESTRICTED:
new_code = RECORDER_ERROR_SECURITY_RESTRICTED;
break;
+ default:
+ break;
}
return new_code;
}
static int __convert_recorder_error_code(const char *func, int code){
int ret = RECORDER_ERROR_INVALID_OPERATION;
- char *errorstr = NULL;
-
+ const char *errorstr = NULL;
+
switch(code)
{
case RECORDER_ERROR_INVALID_PARAMETER:
break;
case MM_ERROR_CAMCORDER_INVALID_ARGUMENT :
case MM_ERROR_COMMON_INVALID_ATTRTYPE :
- case MM_ERROR_COMMON_INVALID_PERMISSION :
case MM_ERROR_COMMON_OUT_OF_ARRAY :
case MM_ERROR_COMMON_OUT_OF_RANGE :
case MM_ERROR_COMMON_ATTR_NOT_EXIST :
ret = RECORDER_ERROR_INVALID_PARAMETER;
errorstr = "INVALID_PARAMETER";
break;
+ case MM_ERROR_COMMON_INVALID_PERMISSION :
+ ret = RECORDER_ERROR_PERMISSION_DENIED;
+ errorstr = "ERROR_PERMISSION_DENIED";
+ break;
case MM_ERROR_CAMCORDER_NOT_INITIALIZED :
case MM_ERROR_CAMCORDER_INVALID_STATE :
ret = RECORDER_ERROR_INVALID_STATE;
((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]);
}
// should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state
- if( policy != RECORDER_POLICY_NONE ){
- if( previous_state != handle->state && handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED] ){
+ if (policy != RECORDER_POLICY_NONE &&
+ (m->state.current == MM_CAMCORDER_STATE_PAUSED || m->state.current == MM_CAMCORDER_STATE_NULL)) {
+ if (handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED]) {
((recorder_interrupted_cb)handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED])(policy, previous_state, handle->state, handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED]);
- }
- if( m->state.previous == MM_CAMCORDER_STATE_PREPARE && m->state.current == MM_CAMCORDER_STATE_PREPARE ){
- mm_camcorder_unrealize(handle->mm_handle);
+ } else {
+ LOGW("_RECORDER_EVENT_TYPE_INTERRUPTED cb is NULL");
}
}
-
+
break;
case MM_MESSAGE_CAMCORDER_MAX_SIZE:
- case MM_MESSAGE_CAMCORDER_NO_FREE_SPACE:
+ case MM_MESSAGE_CAMCORDER_NO_FREE_SPACE:
case MM_MESSAGE_CAMCORDER_TIME_LIMIT:
{
recorder_recording_limit_type_e type ;
case MM_ERROR_OUT_OF_STORAGE:
recorder_error = RECORDER_ERROR_OUT_OF_STORAGE;
break;
+ default:
+ recorder_error = RECORDER_ERROR_INVALID_OPERATION;
+ break;
}
if( recorder_error != 0 && handle->user_cb[_RECORDER_EVENT_TYPE_ERROR] )
((recorder_error_cb)handle->user_cb[_RECORDER_EVENT_TYPE_ERROR])(errorcode, handle->state , handle->user_data[_RECORDER_EVENT_TYPE_ERROR]);
if( handle->last_max_input_level < m->rec_volume_dB )
handle->last_max_input_level = m->rec_volume_dB;
break;
+ default:
+ break;
}
return 1;
}
-int recorder_create_videorecorder( camera_h camera, recorder_h* recorder){
+int recorder_create_videorecorder(camera_h camera, recorder_h* recorder)
+{
+ int resource_fd = -1;
+ recorder_s * handle = NULL;
+ int preview_format = MM_PIXEL_FORMAT_NV12;
+
if( camera == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- recorder_s * handle;
- int preview_format;
-
//Check already used in another recorder
if( _camera_is_used(camera)){
LOGE("[%s] camera is using in another recorder.", __func__);
return RECORDER_ERROR_INVALID_PARAMETER;
}
+ resource_fd = open(RECORDER_PATH_RECORDER_RESOURCE, O_RDONLY);
+ if (resource_fd < 0) {
+ LOGE("failed to open recorder resource : errno [%d]", errno);
+ if (errno == EPERM || errno == EACCES) {
+ LOGE("permission denied");
+ return RECORDER_ERROR_PERMISSION_DENIED;
+ } else {
+ LOGE("invalid operation");
+ return RECORDER_ERROR_INVALID_OPERATION;
+ }
+ }
+
+ close(resource_fd);
+ resource_fd = -1;
+
+ LOGW("permission check done");
+
handle = (recorder_s*)malloc( sizeof(recorder_s) );
if(handle == NULL){
LOGE("[%s] malloc error", __func__);
return RECORDER_ERROR_OUT_OF_MEMORY;
}
- memset(handle, 0 , sizeof(recorder_s));
+ memset(handle, 0 , sizeof(recorder_s));
handle->last_max_input_level = LOWSET_DECIBEL;
handle->changed_preview_format = -1;
- handle->camera = camera;
+ handle->mm_source.camera = camera;
_camera_set_use(camera, true);
_camera_get_mm_handle(camera, &handle->mm_handle);
}
int recorder_create_audiorecorder( recorder_h* recorder){
-
+
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
-
- int ret;
+
+ int ret = MM_ERROR_NONE;
recorder_s * handle;
MMCamPreset info;
info.videodev_type= MM_VIDEO_DEVICE_NONE;
-
+
handle = (recorder_s*)malloc( sizeof(recorder_s) );
if(handle==NULL){
LOGE( "[%s] OUT_OF_MEMORY(0x%08x)", __func__, RECORDER_ERROR_OUT_OF_MEMORY);
return RECORDER_ERROR_OUT_OF_MEMORY;
}
-
+
memset(handle, 0 , sizeof(recorder_s));
handle->last_max_input_level = LOWSET_DECIBEL;
-
+
ret = mm_camcorder_create(&handle->mm_handle, &info);
if( ret != MM_ERROR_NONE){
free(handle);
handle->state = RECORDER_STATE_CREATED;
mm_camcorder_set_message_callback(handle->mm_handle, __mm_recorder_msg_cb, (void*)handle);
- handle->camera = NULL;
+ handle->mm_source.camera = NULL;
handle->type = _RECORDER_TYPE_AUDIO;
*recorder = (recorder_h)handle;
int recorder_get_state(recorder_h recorder, recorder_state_e * state){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
if( state == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
MMCamcorderStateType mmstate ;
recorder_state_e capi_state;
- mm_camcorder_get_state(handle->mm_handle, &mmstate);
+ mm_camcorder_get_state(handle->mm_handle, &mmstate);
capi_state = __recorder_state_convert(mmstate);
*state = capi_state;
- return CAMERA_ERROR_NONE;
-
+ return RECORDER_ERROR_NONE;
}
int recorder_destroy( recorder_h recorder){
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
recorder_s * handle;
- int ret = RECORDER_ERROR_NONE;
+ int ret = MM_ERROR_NONE;
handle = (recorder_s *) recorder;
if( handle->type == _RECORDER_TYPE_VIDEO ){
//set to unsed
- _camera_set_use(handle->camera, false);
+ _camera_set_use(handle->mm_source.camera, false);
int preview_format;
mm_camcorder_get_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
// preview format was changed?
if( preview_format == handle->changed_preview_format ){
mm_camcorder_set_attributes(handle->mm_handle, NULL, MMCAM_CAMERA_FORMAT, handle->origin_preview_format,(void*)NULL);
}
- _camera_set_relay_mm_message_callback(handle->camera , NULL, NULL);
+ _camera_set_relay_mm_message_callback(handle->mm_source.camera , NULL, NULL);
}else{
ret = mm_camcorder_destroy(handle->mm_handle);
}
}
int recorder_prepare( recorder_h recorder){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret = 0;
+ int ret = MM_ERROR_NONE;
recorder_s *handle = (recorder_s*)recorder;
if( handle->type == _RECORDER_TYPE_VIDEO ){
- return __convert_error_code_camera_to_recorder(camera_start_preview(handle->camera));
+ return __convert_error_code_camera_to_recorder(camera_start_preview(handle->mm_source.camera));
}
MMCamcorderStateType mmstate ;
mm_camcorder_get_state(handle->mm_handle, &mmstate);
if( mmstate != MM_CAMCORDER_STATE_READY){
- ret = mm_camcorder_realize(handle->mm_handle);
+ ret = mm_camcorder_realize(handle->mm_handle);
if( ret != MM_ERROR_NONE){
LOGE("[%s] mm_camcorder_realize fail", __func__);
return __convert_recorder_error_code(__func__, ret);
ret = mm_camcorder_start(handle->mm_handle);
if( ret != MM_ERROR_NONE){
- LOGE("[%s] mm_camcorder_start fail", __func__);
+ LOGE("[%s] mm_camcorder_start fail", __func__);
mm_camcorder_unrealize(handle->mm_handle);
return __convert_recorder_error_code(__func__, ret);
- }
+ }
return RECORDER_ERROR_NONE;
}
int recorder_unprepare( recorder_h recorder){
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret = 0;
+ int ret = MM_ERROR_NONE;
recorder_s *handle = (recorder_s*)recorder;
MMCamcorderStateType mmstate ;
- mm_camcorder_get_state(handle->mm_handle, &mmstate);
-
+ mm_camcorder_get_state(handle->mm_handle, &mmstate);
+
if( mmstate == MM_CAMCORDER_STATE_PREPARE){
- ret = mm_camcorder_stop(handle->mm_handle);
+ ret = mm_camcorder_stop(handle->mm_handle);
if( ret != MM_ERROR_NONE){
- LOGE("[%s] mm_camcorder_stop fail", __func__);
+ LOGE("[%s] mm_camcorder_stop fail", __func__);
return __convert_recorder_error_code(__func__, ret);
}
}
}
int recorder_start( recorder_h recorder){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ int ret = MM_ERROR_NONE;
recorder_s *handle = (recorder_s*)recorder;
ret = mm_camcorder_record(handle->mm_handle);
return __convert_recorder_error_code(__func__, ret);
}
int recorder_pause( recorder_h recorder){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ int ret = MM_ERROR_NONE;
recorder_s *handle = (recorder_s*)recorder;
ret = mm_camcorder_pause(handle->mm_handle);
}
int recorder_commit( recorder_h recorder){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ int ret = MM_ERROR_NONE;
recorder_s *handle = (recorder_s*)recorder;
ret = mm_camcorder_commit(handle->mm_handle);
- return __convert_recorder_error_code(__func__, ret);
+ return __convert_recorder_error_code(__func__, ret);
}
int recorder_cancel( recorder_h recorder){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ int ret = MM_ERROR_NONE;
recorder_s *handle = (recorder_s*)recorder;
ret = mm_camcorder_cancel(handle->mm_handle);
- return __convert_recorder_error_code(__func__, ret);
+ return __convert_recorder_error_code(__func__, ret);
+}
+
+
+int recorder_set_video_resolution(recorder_h recorder, int width, int height)
+{
+ int ret = MM_ERROR_NONE;
+ recorder_s *handle = (recorder_s*)recorder;
+ recorder_state_e state;
+
+ if (!handle || !width || !height) {
+ LOGE("NULL pointer %p %p %p", handle, width, height);
+ return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ }
+
+ recorder_get_state(recorder, &state);
+ if (state > RECORDER_STATE_READY) {
+ LOGE("RECORDER_ERROR_INVALID_STATE (state:%d)", state);
+ return RECORDER_ERROR_INVALID_STATE;
+ }
+
+ ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
+ MMCAM_VIDEO_WIDTH, width,
+ MMCAM_VIDEO_HEIGHT, height,
+ NULL);
+
+ return __convert_recorder_error_code(__func__, ret);
}
+
+int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
+{
+ int ret = MM_ERROR_NONE;
+ recorder_s *handle = (recorder_s*)recorder;
+
+ if (!handle || !width || !height) {
+ LOGE("NULL pointer %p %p %p", handle, width, height);
+ return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ }
+
+ ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
+ MMCAM_VIDEO_WIDTH, width,
+ MMCAM_VIDEO_HEIGHT, height,
+ NULL);
+
+ return __convert_recorder_error_code(__func__, ret);
+}
+
+
+int recorder_foreach_supported_video_resolution(recorder_h recorder,
+ recorder_supported_video_resolution_cb foreach_cb, void *user_data)
+{
+ int i = 0;
+ int ret = MM_ERROR_NONE;
+ recorder_s * handle = (recorder_s*)recorder;
+ MMCamAttrsInfo video_width;
+ MMCamAttrsInfo video_height;
+
+ if (!handle || !foreach_cb) {
+ LOGE("NULL pointer %p %p", handle, foreach_cb);
+ return RECORDER_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_WIDTH , &video_width);
+ ret |= mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_HEIGHT , &video_height);
+
+ if (ret != MM_ERROR_NONE ) {
+ return __convert_recorder_error_code(__func__, ret);
+ }
+
+ for (i = 0 ; i < video_width.int_array.count ; i++) {
+ if (!foreach_cb(video_width.int_array.array[i], video_height.int_array.array[i], user_data)) {
+ break;
+ }
+ }
+
+ return RECORDER_ERROR_NONE;
+}
+
+
int recorder_get_audio_level(recorder_h recorder, double *level){
if( recorder == NULL || level == NULL ) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
recorder_s *handle = (recorder_s*)recorder;
}
int recorder_set_filename(recorder_h recorder, const char *filename){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
g_return_val_if_fail(filename != NULL, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_FILENAME , filename , strlen(filename), NULL);
return __convert_recorder_error_code(__func__, ret);
}
int recorder_get_filename(recorder_h recorder, char **filename){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
g_return_val_if_fail(filename != NULL, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
- char *record_filename;
+ char *record_filename = NULL;
int record_filename_size;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_FILENAME , &record_filename, &record_filename_size, NULL);
- if( ret == CAMERA_ERROR_NONE ){
+
+ if( ret == MM_ERROR_NONE && record_filename) {
*filename = strdup(record_filename);
+ } else {
+ LOGE("internal return (0x%08x), get filename p:%p", ret, record_filename);
+ *filename = NULL;
}
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
{
- int ret;
+ int ret = MM_ERROR_NONE;
int format_table[6] = { MM_FILE_FORMAT_3GP, //RECORDER_FILE_FORMAT_3GP
MM_FILE_FORMAT_MP4, //RECORDER_FILE_FORMAT_MP4
MM_FILE_FORMAT_AMR, //RECORDER_FILE_FORMAT_AMR
}
int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- g_return_val_if_fail(format != NULL, RECORDER_ERROR_INVALID_PARAMETER);
-
- int ret;
+ g_return_val_if_fail(format != NULL, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
int mm_format;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_FILE_FORMAT , &mm_format, NULL);
return __convert_recorder_error_code(__func__, ret);
}
-
-
int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
recorder_s *handle = (recorder_s*)recorder;
if( callback == NULL )
return RECORDER_ERROR_INVALID_PARAMETER;
-
handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
return RECORDER_ERROR_NONE;
-
}
int recorder_unset_state_changed_cb(recorder_h recorder){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
recorder_s *handle = (recorder_s*)recorder;
handle->user_cb[_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
handle->user_data[_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
- return RECORDER_ERROR_NONE;
+ return RECORDER_ERROR_NONE;
}
int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data){
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
recorder_s *handle = (recorder_s*)recorder;
if( callback == NULL )
return RECORDER_ERROR_INVALID_PARAMETER;
return RECORDER_ERROR_NONE;
}
int recorder_unset_interrupted_cb(recorder_h recorder){
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
recorder_s *handle = (recorder_s*)recorder;
handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
}
int recorder_foreach_supported_file_format(recorder_h recorder, recorder_supported_file_format_cb foreach_cb , void *user_data){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
recorder_s * handle = (recorder_s*)recorder;
MMCamAttrsInfo info;
ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILE_FORMAT , &info);
- if( ret != RECORDER_ERROR_NONE )
+ if( ret != MM_ERROR_NONE )
return ret;
-
int i;
for( i=0 ; i < info.int_array.count ; i++)
{
int format;
-
+
switch( info.int_array.array[i] ){
case MM_FILE_FORMAT_3GP:
format = RECORDER_FILE_FORMAT_3GP;
break;
}
return RECORDER_ERROR_NONE;
-
+
}
int recorder_attr_set_size_limit(recorder_h recorder, int kbyte){
-
if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, "target-max-size" , kbyte, NULL);
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_attr_set_time_limit(recorder_h recorder, int second){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_TIME_LIMIT , second, NULL);
- return __convert_recorder_error_code(__func__, ret);
+ return __convert_recorder_error_code(__func__, ret);
}
int recorder_attr_set_audio_device(recorder_h recorder , recorder_audio_device_e device){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DEVICE , device, NULL);
- return __convert_recorder_error_code(__func__, ret);
+ return __convert_recorder_error_code(__func__, ret);
}
int recorder_set_audio_encoder(recorder_h recorder, recorder_audio_codec_e codec){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
if( codec != RECORDER_AUDIO_CODEC_DISABLE && ( codec < RECORDER_AUDIO_CODEC_AMR || codec > RECORDER_AUDIO_CODEC_PCM) )
return RECORDER_ERROR_INVALID_PARAMETER;
MM_AUDIO_CODEC_VORBIS, //RECORDER_AUDIO_CODEC_VORBIS
MM_AUDIO_CODEC_WAVE //RECORDER_AUDIO_CODEC_PCM
};
- int ret;
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
if( codec == RECORDER_AUDIO_CODEC_DISABLE )
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DISABLE , 1, NULL);
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER , audio_table[codec], MMCAM_AUDIO_DISABLE, 0, NULL);
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *codec){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- g_return_val_if_fail(codec != NULL, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ g_return_val_if_fail(codec != NULL, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
int mm_codec = 0;
int audio_disable = 0;
-
+
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER , &mm_codec , MMCAM_AUDIO_DISABLE, &audio_disable, NULL);
if( ret == 0 && audio_disable == 0 ){
}else if( ret == 0 && audio_disable ){
*codec = RECORDER_AUDIO_CODEC_DISABLE;
}
-
- return __convert_recorder_error_code(__func__, ret);
+
+ return __convert_recorder_error_code(__func__, ret);
}
int recorder_set_video_encoder(recorder_h recorder, recorder_video_codec_e codec){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
int video_table[4] = { MM_VIDEO_CODEC_H263, //RECORDER_VIDEO_CODEC_H263, /**< H263 codec */
MM_VIDEO_CODEC_H264, //RECORDER_VIDEO_CODEC_H264, /**< H264 codec */
return __convert_recorder_error_code(__func__, ret);
}
-
-
int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *codec){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- if( codec == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( codec == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
int mm_codec = 0;
}
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_attr_set_audio_samplerate(recorder_h recorder, int samplerate){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_SAMPLERATE , samplerate, NULL);
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_attr_set_audio_encoder_bitrate(recorder_h recorder, int bitrate){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER_BITRATE , bitrate, NULL);
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_attr_set_video_encoder_bitrate(recorder_h recorder, int bitrate){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_set_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER_BITRATE , bitrate, NULL);
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, "target-max-size" , kbyte, NULL);
- return __convert_recorder_error_code(__func__, ret);
+ return __convert_recorder_error_code(__func__, ret);
}
int recorder_attr_get_time_limit(recorder_h recorder, int *second){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_TARGET_TIME_LIMIT , second, NULL);
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_attr_get_audio_device(recorder_h recorder , recorder_audio_device_e *device){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_DEVICE , device, NULL);
- return __convert_recorder_error_code(__func__, ret);
+ return __convert_recorder_error_code(__func__, ret);
}
-
-
int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_SAMPLERATE , samplerate, NULL);
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_ENCODER_BITRATE , bitrate, NULL);
return __convert_recorder_error_code(__func__, ret);
}
int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- int ret;
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ int ret = MM_ERROR_NONE;
recorder_s * handle = (recorder_s*)recorder;
ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_VIDEO_ENCODER_BITRATE , bitrate, NULL);
return __convert_recorder_error_code(__func__, ret);
-
}
int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_supported_audio_encoder_cb foreach_cb , void *user_data){
-
- if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
- if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( recorder == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
+ if( foreach_cb == NULL) return __convert_recorder_error_code(__func__, RECORDER_ERROR_INVALID_PARAMETER);
int ret;
recorder_s * handle = (recorder_s*)recorder;
MMCamAttrsInfo info;
ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_AUDIO_ENCODER , &info);
- if( ret != RECORDER_ERROR_NONE )
+ if( ret != MM_ERROR_NONE )
return __convert_recorder_error_code(__func__, ret);
int i;
recorder_s * handle = (recorder_s*)recorder;
MMCamAttrsInfo info;
ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_VIDEO_ENCODER , &info);
- if( ret != RECORDER_ERROR_NONE )
+ if( ret != MM_ERROR_NONE )
return __convert_recorder_error_code(__func__, ret);
int i;
}
recorder_s * handle = (recorder_s*)recorder;
double volume = 1.0;
- mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_VOLUME , &volume , NULL);
+ int ret = mm_camcorder_get_attributes(handle->mm_handle ,NULL, MMCAM_AUDIO_VOLUME , &volume , NULL);
+
+ set_last_result(__convert_recorder_error_code(__func__, ret));
if( volume == 0.0 )
return true;
else