Revise log related code
[platform/core/multimedia/mmsvc-recorder.git] / legacy / src / legacy_recorder.c
index 9578624..cfa4cb8 100644 (file)
@@ -180,7 +180,7 @@ int __convert_recorder_error_code(const char *func, int code)
 //LCOV_EXCL_STOP
        }
 
-       LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func, errorstr, ret, code);
+       CAM_LOG_ERROR("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func, errorstr, ret, code);
 
        return ret;
 }
@@ -199,10 +199,10 @@ static recorder_state_e __recorder_state_convert(MMCamcorderStateType mm_state,
        case MM_CAMCORDER_STATE_READY:
                if (mm_old_state == MM_CAMCORDER_STATE_PREPARE) {
                        state = RECORDER_STATE_READY;
-                       LOGW("destroying pipeline now");
+                       CAM_LOG_WARNING("destroying pipeline now");
                } else {
                        state = RECORDER_STATE_CREATED;
-                       LOGW("preparing pipeline now");
+                       CAM_LOG_WARNING("preparing pipeline now");
                }
                break;
        case MM_CAMCORDER_STATE_PREPARE:
@@ -236,7 +236,7 @@ static int __mm_recorder_msg_cb(int message, void *param, void *user_data)
 
        switch (message) {
        case MM_MESSAGE_READY_TO_RESUME:
-               LOGW("not supported message");
+               CAM_LOG_WARNING("not supported message");
                break;
        case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
        case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
@@ -250,16 +250,16 @@ static int __mm_recorder_msg_cb(int message, void *param, void *user_data)
 //LCOV_EXCL_START
                if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
                        policy = RECORDER_POLICY_SECURITY;
-                       LOGE("RECORDER_POLICY_SECURITY");
+                       CAM_LOG_ERROR("RECORDER_POLICY_SECURITY");
                } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_RM) {
                        policy = RECORDER_POLICY_RESOURCE_CONFLICT;
-                       LOGW("RECORDER_POLICY_RESOURCE_CONFLICT");
+                       CAM_LOG_WARNING("RECORDER_POLICY_RESOURCE_CONFLICT");
                }
 
                if (message != MM_MESSAGE_CAMCORDER_STATE_CHANGED &&
                        interrupt_state == -1) {
                        interrupt_state = previous_state;
-                       LOGD("interrupt state %d", interrupt_state);
+                       CAM_LOG_INFO("interrupt state %d", interrupt_state);
                }
 //LCOV_EXCL_STOP
 
@@ -271,12 +271,12 @@ static int __mm_recorder_msg_cb(int message, void *param, void *user_data)
                        if (policy == RECORDER_POLICY_SECURITY ||
                                m->state.current == MM_CAMCORDER_STATE_PAUSED ||
                                m->state.current == MM_CAMCORDER_STATE_NULL) {
-                               LOGD("call interrupted callback");
+                               CAM_LOG_INFO("call interrupted callback");
 
                                if (handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED])
                                        ((recorder_interrupted_cb)handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPTED])(policy, interrupt_state, handle->state, handle->user_data[_RECORDER_EVENT_TYPE_INTERRUPTED]);
                                else
-                                       LOGW("_RECORDER_EVENT_TYPE_INTERRUPTED cb is NULL");
+                                       CAM_LOG_WARNING("_RECORDER_EVENT_TYPE_INTERRUPTED cb is NULL");
 
                                /* initialize interrupt state */
                                interrupt_state = -1;
@@ -292,7 +292,7 @@ static int __mm_recorder_msg_cb(int message, void *param, void *user_data)
                        else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGE_STARTED_BY_RM)
                                policy = RECORDER_POLICY_RESOURCE_CONFLICT;
 
-                       LOGW("message 0x%x -> policy %d", message, policy);
+                       CAM_LOG_WARNING("message 0x%x -> policy %d", message, policy);
 
                        if (policy != RECORDER_POLICY_NONE) {
                                ((recorder_interrupt_started_cb)handle->user_cb[_RECORDER_EVENT_TYPE_INTERRUPT_STARTED])(policy,
@@ -327,7 +327,7 @@ static int __mm_recorder_msg_cb(int message, void *param, void *user_data)
                case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
                case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
                        recorder_error = RECORDER_ERROR_DEVICE;
-                       LOGE("ERROR_DEVICE : 0x%x", m->code);
+                       CAM_LOG_ERROR("ERROR_DEVICE : 0x%x", m->code);
                        break;
                case MM_ERROR_CAMCORDER_GST_CORE:
                case MM_ERROR_CAMCORDER_GST_LIBRARY:
@@ -344,31 +344,31 @@ static int __mm_recorder_msg_cb(int message, void *param, void *user_data)
                case MM_ERROR_FILE_NOT_FOUND:
                case MM_ERROR_FILE_READ:
                        recorder_error = RECORDER_ERROR_INVALID_OPERATION;
-                       LOGE("INVALID_OPERATION : 0x%x", m->code);
+                       CAM_LOG_ERROR("INVALID_OPERATION : 0x%x", m->code);
                        break;
                case MM_ERROR_CAMCORDER_LOW_MEMORY:
                case MM_ERROR_CAMCORDER_MNOTE_MALLOC:
                        recorder_error = RECORDER_ERROR_OUT_OF_MEMORY;
-                       LOGE("OUT_OF_MEMORY : 0x%x", m->code);
+                       CAM_LOG_ERROR("OUT_OF_MEMORY : 0x%x", m->code);
                        break;
                case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
                        recorder_error = RECORDER_ERROR_ESD;
-                       LOGE("ESD : 0x%x", m->code);
+                       CAM_LOG_ERROR("ESD : 0x%x", m->code);
                        break;
                case MM_ERROR_OUT_OF_STORAGE:
                        recorder_error = RECORDER_ERROR_OUT_OF_STORAGE;
-                       LOGE("OUT_OF_STORAGE : 0x%x", m->code);
+                       CAM_LOG_ERROR("OUT_OF_STORAGE : 0x%x", m->code);
                        break;
                default:
                        recorder_error = RECORDER_ERROR_INVALID_OPERATION;
-                       LOGE("INVALID_OPERATION : 0x%x", m->code);
+                       CAM_LOG_ERROR("INVALID_OPERATION : 0x%x", m->code);
                        break;
                }
 
                if (handle->user_cb[_RECORDER_EVENT_TYPE_ERROR])
                        ((recorder_error_cb)handle->user_cb[_RECORDER_EVENT_TYPE_ERROR])(recorder_error, handle->state, handle->user_data[_RECORDER_EVENT_TYPE_ERROR]);
                else
-                       LOGW("ERROR cb was not set");
+                       CAM_LOG_WARNING("ERROR cb was not set");
                break;
 //LCOV_EXCL_STOP
        case MM_MESSAGE_CAMCORDER_CURRENT_VOLUME:
@@ -394,11 +394,14 @@ static int __mm_audio_stream_cb(MMCamcorderAudioStreamDataType *stream, void *us
        if (stream->format == MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE)
                format = RECORDER_SAMPLE_TYPE_S16_LE;
 
+       CAM_LOG_DEBUG("fmt[%d], ch[%d], timestamp[%u], size[%d]",
+               format, stream->channel, stream->timestamp, stream->length);
+
        if (handle->user_cb[type]) {
                ((recorder_audio_stream_cb)(handle->user_cb[type]))(stream->data, stream->length, format,
                        stream->channel, stream->timestamp, handle->user_data[type]);
        } else {
-               LOGW("audio_stream_cb is NULL");
+               CAM_LOG_WARNING("audio_stream_cb is NULL");
        }
 
        return 1;
@@ -412,11 +415,13 @@ static int __mm_muxed_stream_cb(MMCamcorderMuxedStreamDataType *stream, void *us
 
        recorder_return_val_if_fail(handle && stream, 0);
 
+       CAM_LOG_DEBUG("size[%d], offset[%llu]", stream->length, stream->offset);
+
        if (handle->user_cb[type]) {
                ((recorder_muxed_stream_cb)(handle->user_cb[type]))(stream->data, stream->length,
                        stream->offset, handle->user_data[type]);
        } else {
-               LOGW("muxed_stream_cb is NULL");
+               CAM_LOG_WARNING("muxed_stream_cb is NULL");
        }
 
        return 1;
@@ -432,13 +437,13 @@ static int __mm_video_encode_decision_cb(MMCamcorderVideoStreamDataType *stream,
        recorder_return_val_if_fail(handle && stream, 0);
 
        if (!handle->user_cb[type]) {
-               LOGW("video_encode_decision_cb is NULL");
+               CAM_LOG_WARNING("video_encode_decision_cb is NULL");
                return true;
        }
 
        do_encode = ((recorder_video_encode_decision_cb)(handle->user_cb[type]))(stream, handle->user_data[type]);
 
-       /*LOGD("%d", do_encode);*/
+       CAM_LOG_DEBUG("do_encode[%d]", do_encode);
 
        return (int)do_encode;
 }
@@ -469,17 +474,17 @@ static int _recorder_check_and_set_attribute(recorder_h recorder, const char *at
                        NULL);
 
                if (current_value != set_value) {
-                       LOGD("try to reset pipeline");
+                       CAM_LOG_INFO("try to reset pipeline");
 
                        ret = mm_camcorder_stop(handle->mm_handle);
                        if (ret != MM_ERROR_NONE) {
-                               LOGE("mm_camcorder_stop failed 0x%x", ret);
+                               CAM_LOG_ERROR("mm_camcorder_stop failed 0x%x", ret);
                                return __convert_recorder_error_code(attribute_name, ret);
                        }
 
                        ret = mm_camcorder_unrealize(handle->mm_handle);
                        if (ret != MM_ERROR_NONE) {
-                               LOGE("mm_camcorder_unrealize failed 0x%x", ret);
+                               CAM_LOG_ERROR("mm_camcorder_unrealize failed 0x%x", ret);
                                mm_camcorder_start(handle->mm_handle);
                                return __convert_recorder_error_code(attribute_name, ret);
                        }
@@ -506,20 +511,20 @@ static int _recorder_check_and_set_attribute(recorder_h recorder, const char *at
        }
 
        if (ret != MM_ERROR_NONE)
-               LOGE("set [%s] failed 0x%x", attribute_name, ret);
+               CAM_LOG_ERROR("set [%s] failed 0x%x", attribute_name, ret);
 
        if (reset_pipeline) {
                ret2 = mm_camcorder_realize(handle->mm_handle);
                if (ret2 == MM_ERROR_NONE) {
                        ret2 = mm_camcorder_start(handle->mm_handle);
                        if (ret2 == MM_ERROR_NONE) {
-                               LOGW("restart pipeline done.");
+                               CAM_LOG_WARNING("restart pipeline done.");
                        } else {
-                               LOGE("mm_camcorder_start failed 0x%x", ret2);
+                               CAM_LOG_ERROR("mm_camcorder_start failed 0x%x", ret2);
                                mm_camcorder_unrealize(handle->mm_handle);
                        }
                } else {
-                       LOGE("mm_camcorder_realize failed 0x%x", ret2);
+                       CAM_LOG_ERROR("mm_camcorder_realize failed 0x%x", ret2);
                }
 
                if (ret2 != MM_ERROR_NONE) {
@@ -536,16 +541,16 @@ static int _recorder_check_and_set_attribute(recorder_h recorder, const char *at
                        MMCAM_AUDIO_DISABLE, current_audio_disable,
                        attribute_name, current_value,
                        NULL);
-               LOGW("restore attribute set : 0x%x", ret2);
+               CAM_LOG_WARNING("restore attribute set : 0x%x", ret2);
 
                ret2 = mm_camcorder_realize(handle->mm_handle);
-               LOGW("restore mm_camcorder_realize : 0x%x", ret2);
+               CAM_LOG_WARNING("restore mm_camcorder_realize : 0x%x", ret2);
 
                ret2 = mm_camcorder_start(handle->mm_handle);
-               LOGW("restore mm_camcorder_realize : 0x%x", ret2);
+               CAM_LOG_WARNING("restore mm_camcorder_realize : 0x%x", ret2);
                if (ret2 != MM_ERROR_NONE) {
                        ret2 = mm_camcorder_unrealize(handle->mm_handle);
-                       LOGW("restore mm_camcorder_unrealize : 0x%x", ret2);
+                       CAM_LOG_WARNING("restore mm_camcorder_unrealize : 0x%x", ret2);
                }
        }
 
@@ -564,7 +569,7 @@ int legacy_recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
 
        /* Check already used in another recorder */
        if (legacy_camera_is_used(camera)) {
-               LOGE("[%s] camera is using in another recorder.", __func__);
+               CAM_LOG_ERROR("[%s] camera is using in another recorder.", __func__);
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
@@ -593,13 +598,13 @@ int legacy_recorder_create_videorecorder(camera_h camera, recorder_h *recorder)
                NULL);
        if (ret != MM_ERROR_NONE) {
                g_free(handle);
-               LOGE("get device count error");
+               CAM_LOG_ERROR("get device count error");
                return __convert_recorder_error_code(__func__, ret);
        }
 
        if (camera_device_count == 0) {
                g_free(handle);
-               LOGE("RECORDER_ERROR_NOT_SUPPORTED");
+               CAM_LOG_ERROR("RECORDER_ERROR_NOT_SUPPORTED");
                return RECORDER_ERROR_NOT_SUPPORTED;
        } else {
                handle->camera_device_count = camera_device_count;
@@ -643,7 +648,7 @@ int legacy_recorder_create_audiorecorder(recorder_h *recorder)
        ret = mm_camcorder_create(&handle->mm_handle, &info);
        if (ret != MM_ERROR_NONE) {
                g_free(handle);
-               LOGE("mm_camcorder_create fail");
+               CAM_LOG_ERROR("mm_camcorder_create fail");
                return __convert_recorder_error_code(__func__, ret);
        }
 
@@ -653,7 +658,7 @@ int legacy_recorder_create_audiorecorder(recorder_h *recorder)
        if (ret != MM_ERROR_NONE) {
                mm_camcorder_destroy(handle->mm_handle);
                g_free(handle);
-               LOGE("AUDIO mode setting fail");
+               CAM_LOG_ERROR("AUDIO mode setting fail");
                return __convert_recorder_error_code(__func__, ret);
        }
 
@@ -663,7 +668,7 @@ int legacy_recorder_create_audiorecorder(recorder_h *recorder)
        if (ret != MM_ERROR_NONE) {
                mm_camcorder_destroy(handle->mm_handle);
                g_free(handle);
-               LOGE("get device count error");
+               CAM_LOG_ERROR("get device count error");
                return __convert_recorder_error_code(__func__, ret);
        } else {
                handle->camera_device_count = camera_device_count;
@@ -713,12 +718,12 @@ int legacy_recorder_destroy(recorder_h recorder)
                /* check state */
                ret = mm_camcorder_get_state(handle->mm_handle, &mm_state);
                if (ret != MM_ERROR_NONE) {
-                       LOGE("get state failed 0x%x", ret);
+                       CAM_LOG_ERROR("get state failed 0x%x", ret);
                        return __convert_recorder_error_code(__func__, ret);
                }
 
                if (mm_state >= MM_CAMCORDER_STATE_RECORDING) {
-                       LOGE("NOW RECORDING[%d], should not destroy", mm_state);
+                       CAM_LOG_ERROR("NOW RECORDING[%d], should not destroy", mm_state);
                        return RECORDER_ERROR_INVALID_STATE;
                }
 
@@ -773,14 +778,14 @@ int legacy_recorder_prepare(recorder_h recorder)
        if (ret == MM_ERROR_NONE && mmstate < MM_CAMCORDER_STATE_READY) {
                ret = mm_camcorder_realize(handle->mm_handle);
                if (ret != MM_ERROR_NONE) {
-                       LOGE("mm_camcorder_realize fail");
+                       CAM_LOG_ERROR("mm_camcorder_realize fail");
                        return __convert_recorder_error_code(__func__, ret);
                }
        }
 
        ret = mm_camcorder_start(handle->mm_handle);
        if (ret != MM_ERROR_NONE) {
-               LOGE("mm_camcorder_start fail");
+               CAM_LOG_ERROR("mm_camcorder_start fail");
                mm_camcorder_unrealize(handle->mm_handle);
                return __convert_recorder_error_code(__func__, ret);
        }
@@ -801,13 +806,13 @@ int legacy_recorder_unprepare(recorder_h recorder)
        if (ret == MM_ERROR_NONE && mmstate == MM_CAMCORDER_STATE_PREPARE) {
                ret = mm_camcorder_stop(handle->mm_handle);
                if (ret != MM_ERROR_NONE)
-                       LOGE("mm_camcorder_stop fail");
+                       CAM_LOG_ERROR("mm_camcorder_stop fail");
        }
 
        if (ret == MM_ERROR_NONE) {
                ret = mm_camcorder_unrealize(handle->mm_handle);
                if (ret != MM_ERROR_NONE) {
-                       LOGE("mm_camcorder_unrealize fail");
+                       CAM_LOG_ERROR("mm_camcorder_unrealize fail");
                        mm_camcorder_start(handle->mm_handle);
                }
        }
@@ -976,7 +981,7 @@ int legacy_recorder_get_filename(recorder_h recorder,  char **filename)
        if (ret == MM_ERROR_NONE && record_filename) {
                *filename = strdup(record_filename);
        } else {
-               LOGE("internal return (0x%08x), get filename p:%p", ret, record_filename);
+               CAM_LOG_ERROR("internal return (0x%08x), get filename p:%p", ret, record_filename);
                *filename = NULL;
        }
 
@@ -1336,7 +1341,7 @@ int legacy_recorder_foreach_supported_file_format(recorder_h recorder,
 
        ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_FILE_FORMAT, &info);
        if (ret != MM_ERROR_NONE) {
-               LOGE("mm_camcorder_get_attribute_info failed 0x%x", ret);
+               CAM_LOG_ERROR("mm_camcorder_get_attribute_info failed 0x%x", ret);
                return __convert_recorder_error_code(__func__, ret);;
        }
 
@@ -1936,7 +1941,7 @@ int legacy_recorder_manage_external_storage_state(recorder_h recorder, int stora
 
        recorder_return_val_if_fail(handle, RECORDER_ERROR_INVALID_PARAMETER);
 
-       LOGW("storage state %d", storage_state);
+       CAM_LOG_WARNING("storage state %d", storage_state);
 
        ret = mm_camcorder_manage_external_storage_state(handle->mm_handle, storage_state);