X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=common%2Fstt_engine.c;h=0311c514a27c2d8fde2b8d7c9637f9ff3adad7fc;hb=9f0d6944789b66589ea71c0a6209eb0bb16fd758;hp=c2a8e165750e5223e69b9355370af4736b6170b1;hpb=9c2cf91ba7b1a93590143a5f243a6dfe89fbc0f4;p=platform%2Fcore%2Fuifw%2Fstt.git diff --git a/common/stt_engine.c b/common/stt_engine.c index c2a8e16..0311c51 100644 --- a/common/stt_engine.c +++ b/common/stt_engine.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -263,10 +263,9 @@ int stt_engine_initialize(int engine_id, sttpe_result_cb result_cb, sttpe_silenc ret = engine->pefuncs->initialize(result_cb, silence_cb); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to initialize : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; + return ret; } int stt_engine_deinitialize(int engine_id) @@ -284,7 +283,7 @@ int stt_engine_deinitialize(int engine_id) SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Fail to deinitialize : %s", __stt_get_engine_error_code(ret)); } - return 0; + return ret; } static bool __supported_language_cb(const char* language, void* user_data) @@ -322,10 +321,9 @@ int stt_engine_get_supported_langs(int engine_id, GSList** lang_list) ret = engine->pefuncs->foreach_langs(__supported_language_cb, (void*)lang_list); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] get language list error : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; + return ret; } int stt_engine_is_valid_language(int engine_id, const char* language, bool *is_valid) @@ -350,6 +348,53 @@ int stt_engine_is_valid_language(int engine_id, const char* language, bool *is_v return 0; } +int stt_engine_set_private_data(int engine_id, const char* key, const char* data) +{ + if (NULL == key || NULL == data) { + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + return STTP_ERROR_INVALID_PARAMETER; + } + + sttengine_s* engine = NULL; + engine = __get_engine(engine_id); + if (NULL == engine) { + SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id); + return STTP_ERROR_INVALID_PARAMETER; + } + + int ret = engine->pefuncs->set_private_data(key, data); + if (0 != ret) { + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set private data(%d)", ret); + } + return ret; +} + +int stt_engine_get_private_data(int engine_id, const char* key, char** data) +{ + if (NULL == key || NULL == data) { + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + return STTP_ERROR_INVALID_PARAMETER; + } + + sttengine_s* engine = NULL; + engine = __get_engine(engine_id); + if (NULL == engine) { + SECURE_SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine id(%d) is invalid", engine_id); + return STTP_ERROR_INVALID_PARAMETER; + } + + char* temp = NULL; + int ret = engine->pefuncs->get_private_data(key, &temp); + if (0 != ret) { + SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get private data(%d)", ret); + return ret; + } + + *data = strdup(temp); + + return STTP_ERROR_NONE; +} + int stt_engine_get_first_language(int engine_id, char** language) { if (NULL == language) { @@ -494,10 +539,9 @@ int stt_engine_get_audio_type(int engine_id, sttp_audio_type_e* types, int* rate ret = engine->pefuncs->get_audio_format(types, rate, channels); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get audio format : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; + return ret; } /* Set option */ @@ -516,10 +560,9 @@ int stt_engine_set_silence_detection(int engine_id, bool value) return STTP_ERROR_NOT_SUPPORTED_FEATURE; } else if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set silence detection : %d", ret); - return ret; } - return 0; + return ret; } int stt_engine_check_app_agreed(int engine_id, const char* appid, bool* value) @@ -541,10 +584,9 @@ int stt_engine_check_app_agreed(int engine_id, const char* appid, bool* value) if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get app agreement : %s", __stt_get_engine_error_code(ret)); *value = false; - return ret; } - return 0; + return ret; } /* Recognition */ @@ -566,10 +608,9 @@ int stt_engine_recognize_start(int engine_id, const char* lang, const char* reco if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start recognition : %s", __stt_get_engine_error_code(ret)); SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start recognition : lang(%s), recognition_type(%s), credential(%s)", lang, recognition_type, credential); - return ret; } - return 0; + return ret; } int stt_engine_set_recording_data(int engine_id, const void* data, unsigned int length) @@ -589,10 +630,9 @@ int stt_engine_set_recording_data(int engine_id, const void* data, unsigned int int ret = engine->pefuncs->set_recording(data, length); if (0 != ret) { SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Fail to set recording : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; + return ret; } int stt_engine_recognize_stop(int engine_id) @@ -607,10 +647,9 @@ int stt_engine_recognize_stop(int engine_id) int ret = engine->pefuncs->stop(); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to stop : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; + return ret; } int stt_engine_recognize_cancel(int engine_id) @@ -625,10 +664,9 @@ int stt_engine_recognize_cancel(int engine_id) int ret = engine->pefuncs->cancel(); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to cancel : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; + return ret; } int stt_engine_foreach_result_time(int engine_id, void* time_info, sttpe_result_time_cb callback, void* user_data) @@ -643,10 +681,9 @@ int stt_engine_foreach_result_time(int engine_id, void* time_info, sttpe_result_ int ret = engine->pefuncs->foreach_result_time(time_info, callback, user_data); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to foreach result time : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; + return ret; } int stt_engine_recognize_start_file(int engine_id, const char* lang, const char* recognition_type, @@ -672,10 +709,9 @@ int stt_engine_recognize_start_file(int engine_id, const char* lang, const char* int ret = engine->pefuncs->start_file(lang, recognition_type, filepath, audio_type, sample_rate, user_param); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start file recognition : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; + return ret; } int stt_engine_recognize_cancel_file(int engine_id) @@ -695,8 +731,7 @@ int stt_engine_recognize_cancel_file(int engine_id) int ret = engine->pefuncs->cancel_file(); if (0 != ret) { SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start file recognition : %s", __stt_get_engine_error_code(ret)); - return ret; } - return 0; -} \ No newline at end of file + return ret; +}