Add feature check for recorder_get_device_state 00/177700/1 accepted/tizen/unified/20180504.063319 submit/tizen/20180503.054637
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 3 May 2018 05:08:14 +0000 (14:08 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 3 May 2018 05:08:14 +0000 (14:08 +0900)
[Version] 0.3.12
[Profile] Common
[Issue Type] Update
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20180502.3]

Change-Id: I1896cde0dd451575fcc16e87dfb2965b6698aed4
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
muse/src/muse_recorder_dispatcher.c
packaging/mmsvc-recorder.spec

index d9fea6d..c2e0440 100644 (file)
@@ -567,13 +567,36 @@ static int _recorder_remove_export_data(muse_module_h module, int key, int remov
        return FALSE;
 }
 
+
+bool _recorder_check_supported_feature(int type)
+{
+       bool feature_supported = false;
+       const char *feature_name = NULL;
+
+       if (type != MUSE_RECORDER_TYPE_AUDIO && type != MUSE_RECORDER_TYPE_VIDEO) {
+               LOGE("invalid type %d", type);
+               return false;
+       }
+
+       if (type == MUSE_RECORDER_TYPE_AUDIO)
+               feature_name = AUDIO_RECORDING_FEATURE_NAME;
+       else
+               feature_name = VIDEO_RECORDING_FEATURE_NAME;
+
+       if (muse_server_get_platform_info(feature_name, &feature_supported) != MM_ERROR_NONE)
+               LOGE("failed to get platform info for [%s]", feature_name);
+
+       LOGD("[%s] -> %d", feature_name, feature_supported);
+
+       return feature_supported;
+}
+
+
 int recorder_dispatcher_create(muse_module_h module)
 {
        int ret = RECORDER_ERROR_NONE;
        int recorder_type = MUSE_RECORDER_TYPE_AUDIO;
        int pid = 0;
-       bool feature_supported = false;
-       const char *feature_name = NULL;
        void *gdbus_connection = NULL;
        muse_recorder_api_e api = MUSE_RECORDER_API_CREATE;
        muse_recorder_api_class_e class = MUSE_RECORDER_API_CLASS_IMMEDIATE;
@@ -620,8 +643,6 @@ int recorder_dispatcher_create(muse_module_h module)
                LOGD("video type, camera handle : %p", muse_camera->camera_handle);
 
                ret = legacy_recorder_create_videorecorder(muse_camera->camera_handle, &muse_recorder->recorder_handle);
-
-               feature_name = VIDEO_RECORDING_FEATURE_NAME;
        } else if (recorder_type == MUSE_RECORDER_TYPE_AUDIO) {
                muse_recorder_msg_get(pid, muse_server_module_get_msg(module));
 
@@ -635,19 +656,17 @@ int recorder_dispatcher_create(muse_module_h module)
 
                ret = legacy_recorder_set_client_pid(muse_recorder->recorder_handle, pid);
                ret |= legacy_recorder_set_gdbus_connection(muse_recorder->recorder_handle, gdbus_connection);
-
-               feature_name = AUDIO_RECORDING_FEATURE_NAME;
+       } else {
+               LOGE("unknown type %d", recorder_type);
+               ret = RECORDER_ERROR_INVALID_OPERATION;
        }
 
        if (ret != RECORDER_ERROR_NONE)
                goto _CREATE_ERROR;
 
-       /* microphone feature support check */
-       if (muse_server_get_platform_info(feature_name, &feature_supported) != MM_ERROR_NONE)
-               LOGE("failed to get platform info for [%s]", feature_name);
-
-       if (!feature_supported) {
-               LOGE("feature[%s] NOT SUPPORTED, BUT INI FILE FOR RECORDER IS EXISTED. RECOMMEND TO REMOVE IT.", feature_name);
+       /* recording feature check */
+       if (!_recorder_check_supported_feature(recorder_type)) {
+               LOGE("feature NOT SUPPORTED, BUT INI FILE FOR RECORDER IS EXISTED. RECOMMEND TO REMOVE IT.");
                ret = RECORDER_ERROR_NOT_SUPPORTED;
                goto _CREATE_ERROR;
        }
@@ -2262,9 +2281,6 @@ int recorder_dispatcher_get_device_state(muse_module_h module)
        int device_state = 0;
        int device_recording = 0;
        int device_paused = 0;
-#ifdef _MMSVC_CHECK_SUPPORT_
-       recorder_h recorder = NULL;
-#endif /* _MMSVC_CHECK_SUPPORT_ */
        recorder_type_e recorder_type = RECORDER_TYPE_AUDIO;
        recorder_device_state_e get_device_state = RECORDER_DEVICE_STATE_IDLE;
        muse_recorder_api_e api = MUSE_RECORDER_API_GET_DEVICE_STATE;
@@ -2274,23 +2290,19 @@ int recorder_dispatcher_get_device_state(muse_module_h module)
 
        if (recorder_type > RECORDER_TYPE_VIDEO) {
                LOGE("invalid type %d", recorder_type);
-               ret = CAMERA_ERROR_INVALID_PARAMETER;
+               ret = RECORDER_ERROR_INVALID_PARAMETER;
                muse_recorder_msg_return(api, class, ret, module);
-               return MUSE_CAMERA_ERROR_NONE;
+               return MUSE_RECORDER_ERROR_NONE;
        }
 
-#ifdef _MMSVC_CHECK_SUPPORT_
-       ret = legacy_recorder_create_audiorecorder(&recorder);
-       if (ret != RECORDER_ERROR_NONE) {
-               LOGE("failed to create recorder handle 0x%x", ret);
+       /* recording feature check */
+       if (!_recorder_check_supported_feature(recorder_type)) {
+               LOGE("feature not supported");
+               ret = RECORDER_ERROR_NOT_SUPPORTED;
                muse_recorder_msg_return(api, class, ret, module);
-               return MUSE_CAMERA_ERROR_NONE;
+               return MUSE_RECORDER_ERROR_NONE;
        }
 
-       legacy_recorder_destroy(recorder);
-       recorder = NULL;
-#endif /* _MMSVC_CHECK_SUPPORT_ */
-
        if (recorder_type == RECORDER_TYPE_AUDIO)
                muse_server_module_get_value(module, RECORDER_DEVICE_STATE_KEY_AUDIO, &device_state);
        else
index 88d97e1..ab272f5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-recorder
 Summary:    A Recorder module for muse server
-Version:    0.3.11
+Version:    0.3.12
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0