return 0;
}
+int __ma_cb_preprocessing_information_changed(const char* app_id)
+{
+ ma_preprocessing_information_changed_cb callback = NULL;
+ void* user_data;
+
+ ma_client_get_preprocessing_information_changed_cb(g_ma, &callback, &user_data);
+
+ if (NULL != callback) {
+ ma_client_use_callback(g_ma);
+ callback(app_id, user_data);
+ ma_client_not_use_callback(g_ma);
+ SLOG(LOG_DEBUG, TAG_MAC, "[DEBUG] Preprocessing information changed callback is called, (%s)", app_id);
+ } else {
+ SLOG(LOG_DEBUG, TAG_MAC, "[WARNING] Preprocessing information changed callback is NULL");
+ }
+
+ return 0;
+}
+
int ma_get_state(ma_state_e* state)
{
if (0 != __ma_get_feature_enabled()) {
}
return ret;
}
+
+int ma_set_preprocessing_information_changed_cb(ma_preprocessing_information_changed_cb callback, void* user_data)
+{
+ if (0 != __ma_get_feature_enabled()) {
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_MAC, "[Client DEBUG] Set Multi-assistant preprocessing information changed cb");
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Invalid parameter"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_PARAMETER;
+ }
+
+ ma_state_e state;
+
+ if (0 != ma_client_get_client_state(g_ma, &state)) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] A handle is not available"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != MA_STATE_INITIALIZED) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Invalid State: Current state is not 'Initialized' (%d)", state); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ ma_client_set_preprocessing_information_changed_cb(g_ma, callback, user_data);
+
+ return MA_ERROR_NONE;
+}
+
+int ma_unset_preprocessing_information_changed_cb(void)
+{
+ if (0 != __ma_get_feature_enabled()) {
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_MAC, "[Client DEBUG] Unset Multi-assistant preprocessing information changed cb");
+
+ ma_state_e state;
+
+ if (0 != ma_client_get_client_state(g_ma, &state)) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] A handle is not available"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != MA_STATE_INITIALIZED) {
+ SLOG(LOG_ERROR, TAG_MAC, "[ERROR] Invalid State: Current state is not 'Initialized'"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ ma_client_set_preprocessing_information_changed_cb(g_ma, NULL, NULL);
+
+ return MA_ERROR_NONE;
+}
\ No newline at end of file
void* active_state_changed_user_data;
ma_wakeup_engine_command_cb wakeup_engine_command_cb;
void* wakeup_engine_command_user_data;
+ ma_preprocessing_information_changed_cb preprocessing_information_changed_cb;
+ void* preprocessing_information_changed_user_data;
/* state */
ma_state_e previous_state;
*user_data = client->wakeup_engine_command_user_data;
return MA_ERROR_NONE;
-}
\ No newline at end of file
+}
+
+int ma_client_set_preprocessing_information_changed_cb(ma_h ma, ma_preprocessing_information_changed_cb callback, void* user_data)
+{
+ ma_client_s* client = __client_get(ma);
+
+ if (NULL == client)
+ return MA_ERROR_INVALID_PARAMETER;
+
+ client->preprocessing_information_changed_cb = callback;
+ client->preprocessing_information_changed_user_data = user_data;
+
+ return MA_ERROR_NONE;
+}
+
+int ma_client_get_preprocessing_information_changed_cb(ma_h ma, ma_preprocessing_information_changed_cb* callback, void** user_data)
+{
+ ma_client_s* client = __client_get(ma);
+
+ if (NULL == client)
+ return MA_ERROR_INVALID_PARAMETER;
+
+ *callback = client->preprocessing_information_changed_cb;
+ *user_data = client->preprocessing_information_changed_user_data;
+
+ return MA_ERROR_NONE;
+}
int ma_client_get_wakeup_engine_command_cb(ma_h ma, ma_wakeup_engine_command_cb* callback, void** user_data);
+int ma_client_set_preprocessing_information_changed_cb(ma_h ma, ma_preprocessing_information_changed_cb callback, void* user_data);
+
+int ma_client_get_preprocessing_information_changed_cb(ma_h ma, ma_preprocessing_information_changed_cb* callback, void** user_data);
+
#ifdef __cplusplus
}
#endif
extern int __ma_cb_audio_streaming(int event, char* buffer, int len);
extern int __ma_cb_active_state_changed(int state);
extern int __ma_cb_wakeup_engine_command(const char *command);
+extern int __ma_cb_preprocessing_information_changed(const char* app_id);
static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler* fd_handler)
{
SLOG(LOG_INFO, TAG_MAC, "@@@");
} /* MAS_METHOD_WAKEUP_ENGINE_COMMAND */
+ else if (dbus_message_is_method_call(msg, if_name, MAS_METHOD_SEND_PREPROCESSING_INFORMATION)) {
+ SLOG(LOG_INFO, TAG_MAC, "@@@ Activate");
+ char* app_id = NULL;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_STRING, &app_id,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_MAC, "@@ Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ } else {
+ char* temp_app_id = NULL;
+ if (NULL != app_id && strcmp("#NULL", app_id)) {
+ temp_app_id = strdup(app_id);
+ }
+ __ma_cb_preprocessing_information_changed(temp_app_id);
+ if (NULL != temp_app_id)
+ free(temp_app_id);
+ }
+
+ SLOG(LOG_INFO, TAG_MAC, "@@@");
+ } /* MAS_METHOD_SEND_PREPROCESSING_INFORMATION */
+
else if (dbus_message_is_signal(msg, if_name, MAS_METHOD_ERROR)) {
SLOG(LOG_DEBUG, TAG_MAC, "[DEBUG] Get Error");
int reason;
#define MAS_METHOD_STREAMING_AUDIO_DATA "mas_method_streaming_audio_data"
#define MAS_METHOD_WAKEUP_ENGINE_COMMAND "mas_method_wakeup_engine_command"
#define MAS_METHOD_ERROR "mas_method_error"
+#define MAS_METHOD_SEND_PREPROCESSING_INFORMATION "mas_method_send_preprocessing_information"
#define MAS_UI_METHOD_HELLO "mas_ui_method_hello"
#define MAS_UI_METHOD_SEND_ASR_RESULT "mas_ui_method_send_asr_result"
*/
int ma_set_preprocessing_allow_mode(ma_preprocessing_allow_mode_e mode, const char* app_id);
+/**
+ * @brief Sets the preprocessing information changed callback.
+ * @since_tizen 5.5
+ *
+ * @param[in] callback The callback
+ * @param[in] user_data The user data passed to the callback function
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MA_ERROR_INVALID_STATE Invalid state
+ * @retval #MA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre The state should be #MA_STATE_INITIALIZED.
+ * @see ma_preprocessing_information_changed_cb()
+ * @see ma_unset_preprocessing_information_changed_cb()
+ */
+int ma_set_preprocessing_information_changed_cb(ma_preprocessing_information_changed_cb callback, void* user_data);
+
+/**
+ * @brief Unsets the preprocessing information changed callback.
+ * @since_tizen 5.5
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MA_ERROR_NONE Successful
+ * @retval #MA_ERROR_NOT_SUPPORTED Not supported
+ * @retval #MA_ERROR_INVALID_STATE Invalid state
+ *
+ * @pre The state should be #MA_STATE_INITIALIZED.
+ * @see ma_preprocessing_information_changed_cb()
+ * @see ma_set_preprocessing_information_changed_cb()
+ */
+int ma_unset_preprocessing_information_changed_cb(void);
+
#ifdef __cplusplus
}
#endif
* @param[in] user_data The user data passed from the callback registration function
*/
typedef int (*ma_assistant_info_list_cb)(ma_assistant_info_h handle, void* user_data);
+
+/**
+ * @brief Called when the preprocessing information is changed.
+ * @since_tizen 5.5
+ *
+ * @remarks The @a app_id should not be released and can be used only in the callback. To use outside, make a copy.
+ * @remarks If the @a app_id is NULL, it means there is no preprocessing voice assistant available.
+ * @param[in] app_id The application id of current preprocessing voice assistant
+ */
+typedef void (*ma_preprocessing_information_changed_cb)(const char* app_id, void* user_data);
+
#ifdef __cplusplus
}
#endif