[ACR-1449] Add new api to set audio type
[platform/core/uifw/stt.git] / common / stt_engine.c
index 57944a2..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)
@@ -472,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");
@@ -844,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