#define MA_METHOD_INITIALIZE "ma_method_initialize"
#define MA_METHOD_DEINITIALIZE "ma_method_deinitialize"
#define MA_METHOD_GET_RECORDING_AUDIO_FORMAT "ma_method_get_recording_audio_format"
+#define MA_METHOD_GET_RECORDING_AUDIO_SOURCE_TYPE "ma_method_get_recording_audio_source_type"
#define MA_METHOD_SEND_ASR_RESULT "ma_method_send_asr_result"
#define MA_METHOD_SEND_RESULT "ma_method_send_result"
#define MA_METHOD_SEND_RECOGNITION_RESULT "ma_method_send_recognition_result"
int mas_client_get_audio_format(int pid, int* rate, int* channel, int* audio_type);
+int mas_client_get_audio_source_type(int pid, char** type);
+
int mas_client_request_speech_data(int pid);
int mas_client_send_asr_result(int pid, int event, char* asr_result);
int multi_assistant_service_plugin_get_recording_audio_format(int* rate, int* channel, int* audio_type);
+int multi_assistant_service_plugin_get_recording_audio_source_type(char **type);
+
int multi_assistant_service_plugin_set_callbacks(void);
int multi_assistant_service_plugin_set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data);
typedef int (*wakeup_manager_stop_streaming_follow_up_data)(void);
#define MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT "wakeup_manager_get_audio_format"
typedef int (*wakeup_manager_get_audio_format)(int* rate, int* channel, int* audio_type);
+#define MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE "wakeup_manager_get_audio_source_type"
+typedef int (*wakeup_manager_get_audio_source_type)(char** type);
#define MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK "wakeup_manager_set_wakeup_event_callback"
typedef int (*wakeup_manager_set_wakeup_event_callback)(wakeup_service_wakeup_event_cb callback, void* user_data);
#define MA_WAKEUP_MANAGER_FUNC_SET_UTTERANCE_STREAMING_CALLBACK "wakeup_manager_set_utterance_streaming_callback"
wakeup_manager_start_streaming_follow_up_data start_streaming_follow_up_data;
wakeup_manager_stop_streaming_follow_up_data stop_streaming_follow_up_data;
wakeup_manager_get_audio_format get_audio_format;
+ wakeup_manager_get_audio_source_type get_audio_source_type;
wakeup_manager_set_wakeup_event_callback set_wakeup_event_callback;
wakeup_manager_set_utterance_streaming_callback set_utterance_streaming_callback;
wakeup_manager_set_previous_utterance_streaming_callback set_previous_utterance_streaming_callback;
EXPORT_API int mas_dependency_change_system_volume(void);
EXPORT_API int mas_dependency_recover_system_volume(void);
EXPORT_API int mas_dependency_get_audio_format(int* rate, int* channel, int* audio_type);
+EXPORT_API int mas_dependency_get_audio_source_type(char** type);
#ifdef __cplusplus
}
void dependency_default_audio_recover_system_volume();
void dependency_default_audio_get_audio_format(int* rate, int* channel, int* audio_type);
+void dependency_default_audio_get_audio_source_type(char** type);
+
#endif //_DEPENDENCY_DEFAULT_AUDIO_H_
dependency_default_audio_get_audio_format(rate, channel, audio_type);
return 0;
}
+
+int mas_dependency_get_audio_source_type(char** type)
+{
+ dependency_default_audio_get_audio_source_type(type);
+ return 0;
+}
*rate = 16000;
*channel = 0;
*audio_type = 0;
+}
+
+void dependency_default_audio_get_audio_source_type(char** type)
+{
+ static char source_type[] = "default_audio";
+ if (!type) {
+ return;
+ }
+ *type = source_type;
}
\ No newline at end of file
int dependency_resolver_change_system_volume();
int dependency_resolver_recover_system_volume();
int dependency_resolver_get_audio_format(int* rate, int* channel, int* audio_type);
+int dependency_resolver_get_audio_source_type(char** type);
/**************************************************************************************
*** Definitions for dependencies
typedef int (*mas_dependency_recover_system_volume)(void);
#define MAS_DEPENDENCY_FUNC_GET_AUDIO_FORMAT "mas_dependency_get_audio_format"
typedef int (*mas_dependency_get_audio_format)(int* rate, int* channel, int* audio_type);
+#define MAS_DEPENDENCY_FUNC_GET_AUDIO_SOURCE_TYPE "mas_dependency_get_audio_source_type"
+typedef int (*mas_dependency_get_audio_source_type)(char** type);
typedef struct {
mas_dependency_initialize initialize;
mas_dependency_change_system_volume change_system_volume;
mas_dependency_recover_system_volume recover_system_volume;
mas_dependency_get_audio_format get_audio_format;
+ mas_dependency_get_audio_source_type get_audio_source_type;
} mas_dependency;
#ifdef __cplusplus
bool update_result_state(string appid, int state);
bool process_event(ma_plugin_event_e event, void* data, int len);
bool get_audio_format(int* rate, int* channel, int* audio_type);
+ bool get_audio_source_type(char** type);
bool set_language(string language);
bool get_voice_key_pressed();
EXPORT_API int wakeup_manager_get_audio_format(int *rate, int *channel, int *audio_type);
+EXPORT_API int wakeup_manager_get_audio_source_type(char** type);
+
EXPORT_API int wakeup_manager_set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data);
EXPORT_API int wakeup_manager_set_utterance_streaming_callback(wakeup_service_speech_streaming_cb callback, void* user_data);
g_mas_dependency.get_audio_format =
(mas_dependency_get_audio_format)dlsym(g_handle,
MAS_DEPENDENCY_FUNC_GET_AUDIO_FORMAT);
+ g_mas_dependency.get_audio_source_type =
+ (mas_dependency_get_audio_source_type)dlsym(g_handle,
+ MAS_DEPENDENCY_FUNC_GET_AUDIO_SOURCE_TYPE);
int ret = -1;
int dependency_version = 0;
return ret;
}
+int dependency_resolver_get_audio_source_type(char** type)
+{
+ int ret = -1;
+ if (NULL != g_handle) {
+ mas_dependency_get_audio_source_type func = g_mas_dependency.get_audio_source_type;
+ if (NULL == func) {
+ MAS_LOGE("[ERROR] symbol lookup failed : %s", MAS_DEPENDENCY_FUNC_GET_AUDIO_SOURCE_TYPE);
+ } else {
+ ret = func(type);
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to get audio source type, ret(%d)", ret);
+ }
+ }
+ } else {
+ MAS_LOGE("[ERROR] g_handle is not valid");
+ }
+
+ return ret;
+}
return true;
}
+bool CWakeupManager::get_audio_source_type(char** type)
+{
+ MWR_LOGD("[ENTER]");
+
+ if (!type) {
+ MWR_LOGE("[ERROR] Invalid parameter");
+ return false;
+ }
+
+ dependency_resolver_get_audio_source_type(type);
+
+ MWR_LOGD("[END] type(%s)", *type);
+ return true;
+}
+
CWakeupPolicy* CWakeupManager::get_wakeup_policy()
{
return mWakeupPolicy.get();
return 0;
}
+int wakeup_manager_get_audio_source_type(char** type)
+{
+ MWR_LOGD("[ENTER]");
+
+ if (!type) {
+ MWR_LOGE("[ERROR] Invalid parameter");
+ return -1;
+ }
+
+ g_wakeup_manager.get_audio_source_type(type);
+
+ MWR_LOGD("[END] type(%s)", *type);
+ return 0;
+}
+
int wakeup_manager_set_wakeup_event_callback(wakeup_service_wakeup_event_cb callback, void* user_data)
{
MWR_LOGD("[ENTER]");
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_GET_RECORDING_AUDIO_FORMAT)) {
ma_service_dbus_get_audio_format(g_conn_listener, msg);
+ } else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_GET_RECORDING_AUDIO_SOURCE_TYPE)) {
+ ma_service_dbus_get_audio_source_type(g_conn_listener, msg);
+
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_SEND_ASR_RESULT)) {
ma_service_dbus_send_asr_result(g_conn_listener, msg);
return 0;
}
+int ma_service_dbus_get_audio_source_type(DBusConnection* conn, DBusMessage* msg)
+{
+ DBusError err;
+ dbus_error_init(&err);
+
+ int pid = -1;
+ char *type = NULL;
+ int ret;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &pid,
+ DBUS_TYPE_INVALID);
+
+ MAS_LOGD("[DEBUG] MAS GET AUDIO SOURCE TYPE");
+
+ if (dbus_error_is_set(&err)) {
+ MAS_LOGE("[IN ERROR] mas get audio source type : Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ ret = -1; //MAS_ERROR_OPERATION_FAILED;
+ } else {
+ MAS_LOGD("[IN] mas get default voice");
+ ret = mas_client_get_audio_source_type(pid, &type);
+ }
+
+ DBusMessage* reply;
+ reply = dbus_message_new_method_return(msg);
+
+ char* temp_type = NULL;
+
+ if (type)
+ temp_type = strdup(type);
+ else
+ temp_type = strdup("#NULL");
+
+ if (NULL != reply) {
+ /* Append result and voice */
+ dbus_message_append_args(reply,
+ DBUS_TYPE_INT32, &ret,
+ DBUS_TYPE_STRING, &temp_type,
+ DBUS_TYPE_INVALID);
+ if (0 == ret) {
+ MAS_LOGD("[OUT] mas get audio source type : type(%s)", temp_type);
+ } else {
+ MAS_LOGE("[OUT ERROR] mas get audio source type : result(%d)", ret);
+ }
+
+ if (!dbus_connection_send(conn, reply, NULL)) {
+ MAS_LOGE("[OUT ERROR] mas get audio source type : Out Of Memory!");
+ }
+
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+ } else {
+ MAS_LOGE("[OUT ERROR] mas get audio source type : Fail to create reply message!!");
+ }
+
+ if (temp_type)
+ free(temp_type);
+
+ return 0;
+}
+
int ma_service_dbus_send_asr_result(DBusConnection* conn, DBusMessage* msg)
{
DBusError err;
int ma_service_dbus_get_audio_format(DBusConnection* conn, DBusMessage* msg);
+int ma_service_dbus_get_audio_source_type(DBusConnection* conn, DBusMessage* msg);
+
int ma_service_dbus_send_asr_result(DBusConnection* conn, DBusMessage* msg);
int ma_service_dbus_send_result(DBusConnection* conn, DBusMessage* msg);
return ret;
}
+int mas_client_get_audio_source_type(int pid, char** type)
+{
+ MAS_LOGD("[Enter] pid(%d)", pid);
+
+ int ret = multi_assistant_service_plugin_get_recording_audio_source_type(type);
+ if (0 != ret){
+ MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
+ }
+
+ return ret;
+}
+
int mas_client_activate(int pid)
{
int ret = -1;
_wakeup_manager_interface.get_audio_format =
(wakeup_manager_get_audio_format)dlsym(g_handle,
MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_FORMAT);
+ _wakeup_manager_interface.get_audio_source_type =
+ (wakeup_manager_get_audio_source_type)dlsym(g_handle,
+ MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
_wakeup_manager_interface.set_wakeup_event_callback =
(wakeup_manager_set_wakeup_event_callback)dlsym(g_handle,
MA_WAKEUP_MANAGER_FUNC_SET_WAKEUP_EVENT_CALLBACK);
return ret;
}
+int multi_assistant_service_plugin_get_recording_audio_source_type(char** type)
+{
+ int ret = -1;
+ if (NULL != g_handle) {
+ wakeup_manager_get_audio_source_type func = _wakeup_manager_interface.get_audio_source_type;
+ if (NULL == func) {
+ MAS_LOGE("[ERROR] symbol lookup failed : %s", MA_WAKEUP_MANAGER_FUNC_GET_AUDIO_SOURCE_TYPE);
+ } else {
+ ret = func(type);
+ if (0 != ret) {
+ MAS_LOGE("[ERROR] Fail to get recording audio source type, ret(%d)", ret);
+ }
+ }
+ } else {
+ MAS_LOGE("[ERROR] g_handle is not valid");
+ }
+ return ret;
+}
+
int multi_assistant_service_plugin_set_callbacks(void)
{
int ret = multi_assistant_service_plugin_set_wakeup_event_callback(__wakeup_event_cb, NULL);