From 9823c4f35e67df7b027154d33762d28596a0bd2d Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 1 Aug 2022 16:42:25 +0900 Subject: [PATCH] Add new APIs about activated mode information - Requirement: Engine application needs mode information that is currently activated by connected clients. - Solution: This patch adds new APIs about mode informatino that is currently activated by connected clients. These new APIs sends activated mode information through a getter or registered callback function. Change-Id: Ie2a2c4c49be23d05195519c34dbc6d98c61e0bad Signed-off-by: Suyeon Hwang --- include/ttse.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ server/ttse.c | 22 +++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/include/ttse.h b/include/ttse.h index 0c73115e..1cf441fc 100755 --- a/include/ttse.h +++ b/include/ttse.h @@ -71,6 +71,17 @@ typedef enum { TTSE_RESULT_EVENT_FINISH = 3 /**< Event when the sound data is last data or sound data is only one result */ } ttse_result_event_e; +/** +* @brief Enumeration for TTS mode mask. +* @since_tizen 7.0 +*/ +typedef enum { + TTSE_MODE_MASK_DEFAULT = 0x01, /**< Default mode */ + TTSE_MODE_MASK_NOTIFICATION = 0x02, /**< Notification mode */ + TTSE_MODE_MASK_SCREEN_READER = 0x04, /**< Screen reader mode */ + TTSE_MODE_MASK_INTERRUPT = 0x08 /**< Interrupt mode */ +} ttse_mode_mask_e; + /** * @brief Definition for male voice type. @@ -373,6 +384,23 @@ typedef int (*ttse_private_data_set_cb)(const char* key, const char* data); typedef int (*ttse_private_data_requested_cb)(const char* key, char** data); +/** +* @brief Called when activated modes are changed. +* @details When a client connects to TTS engine, the engine activates the TTS mode of the client. +* For example, if two clients, one is default mode and other is screen reader mode, connect to TTS engine, then the +* @a activated_mode has the same bit sequence as '#TTSE_MODE_MASK_DEFAULT | #TTSE_MODE_MASK_SCREEN_READER'. +* The activated TTS modes are decided according to the connected clients, so when a client connects or disconnects to +* the engine, the activated TTS modes may be changed. +* This callback function is called when the activated TTS modes are changed. +* @since_tizen 7.0 +* @remarks This callback function is optional and is registered using ttse_set_activated_mode_changed_cb(). +* @param[in] activated_mode The activated TTS modes by connected clients, values of ttse_mode_mask_e combined with bitwise 'or'. +* @see ttse_set_activated_mode_changed_cb() +* @see ttse_get_activated_mode() +*/ +typedef void (*ttse_activated_mode_changed_cb)(int activated_mode); + + /** * @brief A structure for the TTS engine functions. * @details This structure contains essential callback functions for operating TTS engine. @@ -621,6 +649,42 @@ int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func); int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_func); +/** +* @brief Gets activated modes. +* @details When a client connects to TTS engine, the engine activates the TTS mode of the client. +* For example, if two clients, one is default mode and other is screen reader mode, connect to TTS engine, then the +* @a activated_mode has the same bit sequence as '#TTSE_MODE_MASK_DEFAULT | #TTSE_MODE_MASK_SCREEN_READER'. +* Using this API, the engine can get the activated TTS modes information. +* @since_tizen 7.0 +* @param[out] activated_mode The activated TTS mode by connected clients, values of ttse_mode_mask_e combined with bitwise 'or'. +* @return @c 0 on success, +* otherwise a negative error value +* @retval #TTSE_ERROR_NONE Successful +* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #TTSE_ERROR_INVALID_STATE Not initialized +* @pre The ttse_main() function should be invoked before this function is called. +* @see ttse_set_activated_mode_changed_cb() +*/ +int ttse_get_activated_mode(int* activated_mode); + + +/** +* @brief Sets a callback function to be called when the activated TTS modes are changed. +* @since_tizen 7.0 +* @remarks The ttse_activated_mode_changed_cb() function is called when the activated TTS modes are changed. +* @param[in] callback ttse_activated_mode_changed event callback function +* @return @c 0 on success, +* otherwise a negative error value +* @retval #TTSE_ERROR_NONE Successful +* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #TTSE_ERROR_INVALID_STATE Not initialized +* @pre The ttse_main() function should be invoked before this function is called. +* @see ttse_activated_mode_changed_cb() +* @see ttse_get_activated_mode() +*/ +int ttse_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback); + + #ifdef __cplusplus } #endif diff --git a/server/ttse.c b/server/ttse.c index 89fd48e0..a04fc84e 100755 --- a/server/ttse.c +++ b/server/ttse.c @@ -240,3 +240,25 @@ int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_f return ret; } + +int ttse_get_activated_mode(int* activated_mode) +{ + if (NULL == activated_mode) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter"); + return TTSE_ERROR_INVALID_PARAMETER; + } + + // TODO: Implement function + return TTSE_ERROR_NONE; +} + +int ttse_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback) +{ + if (NULL == callback) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter"); + return TTSE_ERROR_INVALID_PARAMETER; + } + + // TODO: Implement function + return TTSE_ERROR_NONE; +} -- 2.34.1