Add new functions for getting audio format from engine 32/293732/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 2 Jun 2023 04:35:45 +0000 (13:35 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 2 Jun 2023 07:08:06 +0000 (16:08 +0900)
- Requirements:
The app needs to know the audio format information that engine can
handle.

- Contents:
This patch adds new function to get audio format information from the
engine. Through this patch, the engine library can ready to send the
audio format information to the clients.

Change-Id: I84b96d93de651740587b3630c84086beeb29ba58
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/sttd_engine_agent.c
server/sttd_engine_agent.h
server/sttd_server.c
server/sttd_server.h

index 790602dca9940b19e9a6dc083888d160aa8d1711..880a24b274893bd63d6cc4e5f5a4cf352460106b 100644 (file)
@@ -562,6 +562,22 @@ int sttd_engine_agent_is_recognition_type_supported(const char* type, bool* supp
        return 0;
 }
 
+int sttd_engine_agent_get_audio_format(stte_audio_type_e* type, int* rate, int* num_of_channels)
+{
+       RETVM_IF(NULL == type || NULL == rate || NULL == num_of_channels, STTD_ERROR_INVALID_PARAMETER,  "[Engine Agent ERROR] Input parameter");
+       int tmp = __sttd_engine_agent_check_precondition();
+       if (STTD_ERROR_NONE != tmp)
+               return tmp;
+
+       int ret = stt_engine_get_audio_format(type, rate, num_of_channels);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to get to audio format : %d", ret);
+               return ret;
+       }
+
+       return STTD_ERROR_NONE;
+}
+
 /*
 * STT Engine Interfaces for client
 */
index d5992a0b0369387a44de7819c36e2b550206c578..0458295bd3db7cf700a6c2bbbf8850ae9b0ad81b 100644 (file)
@@ -84,6 +84,8 @@ int sttd_engine_agent_is_credential_needed(unsigned int uid, bool* credential);
 
 int sttd_engine_agent_is_recognition_type_supported(const char* type, bool* support);
 
+int sttd_engine_agent_get_audio_format(stte_audio_type_e* type, int* rate, int* num_of_channels);
+
 int sttd_engine_agent_set_default_engine(const char* engine_uuid);
 
 int sttd_engine_agent_set_default_language(const char* language);
index 361dff510bb27806af03ad20fa80a86e14efc7ab..95d80a85d7b1b310c516df2656c0e259f6f5b824 100644 (file)
@@ -943,6 +943,30 @@ int sttd_server_is_recognition_type_supported(unsigned int uid, const char* type
        return STTD_ERROR_NONE;
 }
 
+int sttd_server_get_audio_format(unsigned int uid, stte_audio_type_e *type, int *rate, int *num_of_channels)
+{
+       /* check if uid is valid */
+       app_state_e state = APP_STATE_CREATED;
+       if (0 != sttd_client_get_state(uid, &state)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == type || NULL == rate || NULL == num_of_channels) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL");
+               return STTD_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = sttd_engine_agent_get_audio_format(type, rate, num_of_channels);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get recognition type supported : result(%d)", ret);
+               return ret;
+       }
+
+       SLOG(LOG_INFO, TAG_STTD, "[Server SUCCESS] Audio format: type(%d), rate(%d), number of channels(%d)", *type, *rate, *num_of_channels);
+       return STTD_ERROR_NONE;
+}
+
 int sttd_server_set_start_sound(unsigned int uid, const char* file)
 {
        /* check if uid is valid */
index 5ac8f509127efcf6ff3977e4e0c5dd586752c6a6..b24abc793d9290b23a41f7e77c3125cfca1435cc 100644 (file)
@@ -63,6 +63,8 @@ int sttd_server_set_engine_data(unsigned int uid, const char* key, const char* v
 
 int sttd_server_is_recognition_type_supported(unsigned int uid, const char* type, int* support);
 
+int sttd_server_get_audio_format(unsigned int uid, stte_audio_type_e *type, int *rate, int *num_of_channels);
+
 int sttd_server_set_start_sound(unsigned int uid, const char* file);
 
 int sttd_server_set_stop_sound(unsigned int uid, const char* file);