#define MA_METADATA_LANGUAGE "http://tizen.org/metadata/multi-assistant/language"
#define MA_METADATA_ASSISTANT_WAKEUP_ENGINE_APPID "http://tizen.org/metadata/multi-assistant/wakeup_engine_appid"
#define MA_METADATA_ASSISTANT_CUSTOM_UI "http://tizen.org/metadata/multi-assistant/custom_ui"
+#define MA_METADATA_ASSISTANT_VOICE_KEY_SUPPORT_MODE "http://tizen.org/metadata/multi-assistant/voice_key_support_mode"
+#define MA_METADATA_ASSISTANT_VOICE_KEY_TAP_DURATION "http://tizen.org/metadata/multi-assistant/voice_key_tap_duration"
/* Define Macro */
cur = xmlNewNode(NULL, (const xmlChar*)MA_TAG_ASSISTANT_CUSTOM_UI);
xmlNodeSetContent(cur, (const xmlChar*)md->value);
xmlAddChild(root, cur);
+ } else if (!strncmp(md->key, MA_METADATA_ASSISTANT_VOICE_KEY_SUPPORT_MODE, strlen(MA_METADATA_ASSISTANT_VOICE_KEY_SUPPORT_MODE))) {
+ cur = xmlNewNode(NULL, (const xmlChar*)MA_TAG_ASSISTANT_VOICE_KEY_SUPPORT_MODE);
+ xmlNodeSetContent(cur, (const xmlChar*)md->value);
+ xmlAddChild(root, cur);
+ } else if (!strncmp(md->key, MA_METADATA_ASSISTANT_VOICE_KEY_TAP_DURATION, strlen(MA_METADATA_ASSISTANT_VOICE_KEY_TAP_DURATION))) {
+ cur = xmlNewNode(NULL, (const xmlChar*)MA_TAG_ASSISTANT_VOICE_KEY_TAP_DURATION);
+ xmlNodeSetContent(cur, (const xmlChar*)md->value);
+ xmlAddChild(root, cur);
} else {
LOGW("[WARNING] Unknown metadata type");
}
return 0;
}
+
+int __ma_cb_voice_key_status_changed(int status)
+{
+ ma_voice_key_status_changed_cb callback = NULL;
+ void* user_data;
+
+ ma_client_get_voice_key_status_changed_cb(g_ma, &callback, &user_data);
+ if (NULL != callback) {
+ ma_client_use_callback(g_ma);
+ callback(status, user_data);
+ ma_client_not_use_callback(g_ma);
+ MA_SLOGD("[DEBUG] voice key status changed callback is called %d", status);
+ } else {
+ MA_SLOGD("[WARNING] voice key status changed callback is NULL");
+ }
+
+ MA_SLOGD("[INFO] status : changed %d", status);
+
+ return 0;
+}
//LCOV_EXCL_STOP
int ma_get_state(ma_state_e* state)
return MA_ERROR_NONE;
}
+int ma_set_voice_key_status_changed_cb(ma_voice_key_status_changed_cb callback, void* user_data)
+{
+ if (0 != __ma_get_feature_enabled()) {
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ MA_SLOGD("[Client DEBUG] Set Multi-assistant voice key status changed cb");
+
+ if (NULL == callback) {
+ MA_SLOGE("[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)) {
+ MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != MA_STATE_INITIALIZED) {
+ MA_SLOGE("[ERROR] Invalid State: Current state is not 'Initialized' (%d)", state); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ ma_client_set_voice_key_status_changed_cb(g_ma, callback, user_data);
+
+ return MA_ERROR_NONE;
+}
+
+int ma_unset_voice_key_status_changed_cb(void)
+{
+ if (0 != __ma_get_feature_enabled()) {
+ return MA_ERROR_NOT_SUPPORTED;
+ }
+
+ MA_SLOGD("[Client DEBUG] Unset Multi-assistant voice key status changed cb");
+
+ ma_state_e state;
+
+ if (0 != ma_client_get_client_state(g_ma, &state)) {
+ MA_SLOGE("[ERROR] A handle is not available"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ /* check state */
+ if (state != MA_STATE_INITIALIZED) {
+ MA_SLOGE("[ERROR] Invalid State: Current state is not 'Initialized'"); //LCOV_EXCL_LINE
+ return MA_ERROR_INVALID_STATE;
+ }
+
+ ma_client_set_voice_key_status_changed_cb(g_ma, NULL, NULL);
+
+ return MA_ERROR_NONE;
+}
+
//LCOV_EXCL_STOP
void* preprocessing_result_received_user_data;
ma_service_state_changed_cb service_state_changed_cb;
void* service_state_changed_user_data;
+ ma_voice_key_status_changed_cb voice_key_status_changed_cb;
+ void* voice_key_status_changed_user_data;
/* state */
ma_state_e previous_state;
client->audio_streaming_data_section_changed_user_data = NULL;
client->preprocessing_result_received_cb = NULL;
client->preprocessing_result_received_user_data = NULL;
+ client->voice_key_status_changed_cb = NULL;
+ client->voice_key_status_changed_user_data = NULL;
client->previous_state = MA_STATE_INITIALIZED;
client->current_state = MA_STATE_INITIALIZED;
}
//LCOV_EXCL_STOP
-#endif
\ No newline at end of file
+int ma_client_set_voice_key_status_changed_cb(ma_h ma, ma_voice_key_status_changed_cb callback, void* user_data)
+{
+ ma_client_s* client = __client_get(ma);
+
+ if (NULL == client)
+ return MA_ERROR_INVALID_PARAMETER;
+
+ client->voice_key_status_changed_cb = callback;
+ client->voice_key_status_changed_user_data = user_data;
+
+ return MA_ERROR_NONE;
+}
+
+//LCOV_EXCL_START
+int ma_client_get_voice_key_status_changed_cb(ma_h ma, ma_voice_key_status_changed_cb* callback, void** user_data)
+{
+ ma_client_s* client = __client_get(ma);
+
+ if (NULL == client)
+ return MA_ERROR_INVALID_PARAMETER;
+
+ *callback = client->voice_key_status_changed_cb;
+ *user_data = client->voice_key_status_changed_user_data;
+
+ return MA_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
+
+#endif
int ma_client_get_service_state_changed_cb(ma_h ma, ma_service_state_changed_cb* callback, void** user_data);
+int ma_client_set_voice_key_status_changed_cb(ma_h ma, ma_voice_key_status_changed_cb callback, void* user_data);
+
+int ma_client_get_voice_key_status_changed_cb(ma_h ma, ma_voice_key_status_changed_cb* callback, void** user_data);
+
#endif
#ifdef __cplusplus
extern int __ma_cb_preprocessing_information_changed(const char* app_id);
extern int __ma_cb_audio_streaming_data_section_changed(ma_audio_streaming_data_section_e section);
extern int __ma_cb_preprocessing_result_received(bool result);
+extern int __ma_cb_voice_key_status_changed(int status);
#define STREAMING_BUFFER_SIZE 4096
MA_SLOGI("@@@");
} /* MAS_METHOD_SEND_WAKEUP_ENGINE_COMMAND */
+ else if (dbus_message_is_method_call(msg, if_name, MAS_METHOD_VOICE_KEY_STATUS_CHANGE)) {
+ MA_SLOGI("@@@ Activate");
+ int status = 0;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &status,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ MA_SLOGE("@@ Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ } else {
+ __ma_cb_voice_key_status_changed(status);
+ }
+
+ MA_SLOGI("@@@");
+ } /* MAS_METHOD_VOICE_KEY_STATUS_CHANGE */
+
else if (dbus_message_is_signal(msg, if_name, MAS_METHOD_ERROR)) {
int reason;
char* err_msg;
#define MAS_METHOD_SEND_PREPROCESSING_RESULT "mas_method_send_preprocessing_result"
#define MAS_METHOD_SEND_WAKEUP_ENGINE_COMMAND "mas_method_send_wakeup_engine_command"
#define MAS_METHOD_SERVICE_STATE_CHANGE "mas_method_service_state_change"
+#define MAS_METHOD_VOICE_KEY_STATUS_CHANGE "mas_method_voice_key_status_change"
#define MAS_UI_METHOD_HELLO "mas_ui_method_hello"
#define MAS_UI_METHOD_SEND_ASR_RESULT "mas_ui_method_send_asr_result"
#define MA_TAG_ASSISTANT_WAKEUP_WORD "wakeup-word"
#define MA_TAG_ASSISTANT_WAKEUP_ENGINE_APPID "wakeup-engine-appid"
#define MA_TAG_ASSISTANT_CUSTOM_UI "custom-ui"
+#define MA_TAG_ASSISTANT_VOICE_KEY_SUPPORT_MODE "voice-key-support-mode"
+#define MA_TAG_ASSISTANT_VOICE_KEY_TAP_DURATION "voice-key-tap-duration"
+
/**************************************************************************************
*** Definitions for ETC
*/
int ma_unset_service_state_changed_cb(void);
+/**
+ * @brief Sets a voice key status changed callback.
+ * @since_tizen 6.0
+ *
+ * @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_PARAMETER Invalid parameter
+ * @retval #MA_ERROR_INVALID_STATE Invalid state
+ *
+ * @pre The state should be #MA_STATE_INITIALIZED.
+ * @see ma_voice_key_status_changed_cb()
+ * @see ma_unset_voice_key_status_changed_cb()
+ */
+int ma_set_voice_key_status_changed_cb(ma_voice_key_status_changed_cb callback, void* user_data);
+
+/**
+ * @brief Unsets a voice key status changed callback.
+ * @since_tizen 6.0
+ *
+ * @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_set_voice_key_status_changed_cb()
+ * @see ma_voice_key_status_changed_cb()
+ */
+int ma_unset_voice_key_status_changed_cb(void);
+
#ifdef __cplusplus
}
#endif
MA_SERVICE_STATE_VOICE_FEEDBACK = 4, /**< 'VoiceFeedback' state */
} ma_service_state_e;
+/**
+ * @brief Enumerations for voice key's status.
+ * @details If the voice key gets released within the timeout value for tap events,
+ * the voice key's status value will be "released after tap".
+ * Otherwise, "released after push" will be chosen.
+ * @since_tizen 6.0
+ */
+typedef enum {
+ MA_VOICE_KEY_STATUS_PRESSED = 0, /**< 'Pressed' state */
+ MA_VOICE_KEY_STATUS_RELEASED_AFTER_PUSH = 1, /**< 'Released' state after push */
+ MA_VOICE_KEY_STATUS_RELEASED_AFTER_TAP = 2, /**< 'Released' state after tap*/
+} ma_voice_key_status_e;
+
/**
* @brief Called when the client state is changed.
* @since_tizen 5.0
*/
typedef void (*ma_service_state_changed_cb)(ma_service_state_e previous, ma_service_state_e current, void* user_data);
+/**
+ * @brief Called when the multi-assistant service sends voice key status change event.
+ * @since_tizen 6.0
+ *
+ * @param[in] status The current value for voice key's status
+ * @param[in] user_data The user data passed from the callback registration function
+ *
+ * @see ma_set_voice_key_status_changed_cb()
+ * @see ma_unset_voice_key_status_changed_cb()
+ */
+typedef void (*ma_voice_key_status_changed_cb)(ma_voice_key_status_e status, void* user_data);
+
#ifdef __cplusplus
}
#endif