[ACR-1449] Add new api to set audio type
[platform/core/uifw/stt.git] / common / stt_engine.c
index 9dfd996..532381d 100644 (file)
@@ -41,6 +41,8 @@ static bool g_is_from_lib = false;
 static stt_engine_result_cb g_result_cb = NULL;
 static stte_private_data_set_cb g_set_private_data_cb = NULL;
 static stte_private_data_requested_cb g_get_private_data_cb = NULL;
+static stte_audio_type_cb g_set_audio_type_cb = NULL;
+static void* g_set_audio_type_user_data = NULL;
 
 
 static int __stt_set_engine_from(bool is_from_lib)
@@ -149,6 +151,8 @@ int stt_engine_initialize(bool is_from_lib)
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to initialize");
+
        ret = g_engine->callback->initialize();
        if (0 != ret) {
                SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to initialize : %s", __stt_get_engine_error_code(ret));
@@ -174,6 +178,8 @@ int stt_engine_deinitialize()
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to deinitialize");
+
        int ret;
        ret = g_engine->callback->deinitialize();
        if (0 != ret) {
@@ -391,6 +397,8 @@ int stt_engine_support_silence(bool* support)
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to support silence");
+
        if (NULL == g_engine->callback->support_silence) {
                SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine");
                return STTE_ERROR_OPERATION_FAILED;
@@ -420,6 +428,8 @@ int stt_engine_need_app_credential(bool* need)
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to need app credential");
+
        if (NULL == g_engine->callback->need_app_credential) {
                SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine");
                return STTE_ERROR_OPERATION_FAILED;
@@ -454,6 +464,8 @@ int stt_engine_support_recognition_type(const char* type, bool* support)
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to support recognition type, type(%s)", type);
+
        int ret = STTE_ERROR_NONE;
        ret = g_engine->callback->support_recognition_type(type, support);
        if (0 != ret) {
@@ -462,7 +474,7 @@ int stt_engine_support_recognition_type(const char* type, bool* support)
        return ret;
 }
 
-int stt_engine_get_audio_type(stte_audio_type_e* types, int* rate, int* channels)
+int stt_engine_get_audio_format(stte_audio_type_e* types, int* rate, int* channels)
 {
        if (NULL == types || NULL == rate || NULL == channels) {
                SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter");
@@ -484,6 +496,8 @@ int stt_engine_get_audio_type(stte_audio_type_e* types, int* rate, int* channels
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to get audio format");
+
        int ret;
        ret = g_engine->callback->get_audio_format(types, rate, channels);
        if (0 != ret) {
@@ -511,6 +525,8 @@ int stt_engine_set_silence_detection(bool value)
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to set silence detection(%d)", value);
+
        int ret = g_engine->callback->set_silence_detection(value);
        if (STTE_ERROR_NOT_SUPPORTED_FEATURE == ret) {
                SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Not support silence detection");
@@ -543,6 +559,8 @@ int stt_engine_check_app_agreed(const char* appid, bool* is_agreed)
                return 0;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to app agreed, appid(%s), is_agreed(%d)", appid, *is_agreed);
+
        int ret = g_engine->callback->check_app_agreed(appid, is_agreed);
        if (0 != ret) {
                SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get app agreement : %s", __stt_get_engine_error_code(ret));
@@ -575,6 +593,8 @@ int stt_engine_recognize_start(const char* lang, const char* recognition_type, c
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to start, lang(%s), recognition_type(%s), credential(%s)", lang, recognition_type, credential);
+
        int ret = g_engine->callback->start(lang, recognition_type, appid, credential, user_param);
 
        if (0 != ret) {
@@ -632,6 +652,8 @@ int stt_engine_recognize_stop()
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to stop");
+
        int ret = g_engine->callback->stop();
        if (0 != ret) {
                SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to stop : %s", __stt_get_engine_error_code(ret));
@@ -657,6 +679,8 @@ int stt_engine_recognize_cancel()
                return STTE_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to cancel");
+
        int ret = g_engine->callback->cancel();
        if (0 != ret) {
                SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to cancel : %s", __stt_get_engine_error_code(ret));
@@ -822,3 +846,38 @@ int stt_engine_set_private_data_requested_cb(stte_private_data_requested_cb priv
 
        return 0;
 }
+
+int stt_engine_set_audio_type(const char* audio_type)
+{
+       if (NULL == audio_type) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter");
+               return STTE_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_INFO, stt_tag(), "[Engine Info] set audio type (%s)", audio_type);
+
+       int ret = STTE_ERROR_NONE;
+       if (NULL != g_set_audio_type_cb) {
+               ret = g_set_audio_type_cb(audio_type, g_set_audio_type_user_data);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set audio type, ret(%d)", ret);
+               }
+       } else {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] There's no set audio function)");
+       }
+
+       return ret;
+}
+
+int stt_engine_set_audio_type_set_cb(stte_audio_type_cb audio_type_set_cb, void* user_data)
+{
+       if (NULL == audio_type_set_cb) {
+               SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter");
+               return STTE_ERROR_INVALID_PARAMETER;
+       }
+
+       g_set_audio_type_cb = audio_type_set_cb;
+       g_set_audio_type_user_data = user_data;
+
+       return 0;
+}
\ No newline at end of file