| 1 | /* | 
| 2 |  * libspeechd.h - Shared library for easy acces to Speech Dispatcher functions (header) | 
| 3 |  * | 
| 4 |  * Copyright (C) 2001, 2002, 2003, 2004 Brailcom, o.p.s. | 
| 5 |  * | 
| 6 |  * This is free software; you can redistribute it and/or modify it | 
| 7 |  * under the terms of the GNU Lesser General Public License as published by | 
| 8 |  * the Free Software Foundation; either version 2.1, or (at your option) | 
| 9 |  * any later version. | 
| 10 |  * | 
| 11 |  * This software is distributed in the hope that it will be useful, | 
| 12 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 13 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
| 14 |  * Lesser General Public License for more details. | 
| 15 |  * | 
| 16 |  * You should have received a copy of the GNU Lesser General Public License | 
| 17 |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | 
| 18 |  * | 
| 19 |  * $Id: libspeechd.h,v 1.29 2008-07-30 09:47:00 hanke Exp $ | 
| 20 |  */ | 
| 21 |  | 
| 22 | #ifndef _LIBSPEECHD_H | 
| 23 | #define _LIBSPEECHD_H | 
| 24 |  | 
| 25 | #include <stdio.h> | 
| 26 | #include <stddef.h> | 
| 27 | #include <pthread.h> | 
| 28 |  | 
| 29 | #include "libspeechd_version.h" | 
| 30 | #include "speechd_types.h" | 
| 31 |  | 
| 32 | /* *INDENT-OFF* */ | 
| 33 | #ifdef __cplusplus | 
| 34 | extern "C"  { | 
| 35 | #endif | 
| 36 | /* *INDENT-ON* */ | 
| 37 |     /* Speech Dispatcher's default port for inet communication */ | 
| 38 | #define SPEECHD_DEFAULT_PORT 6560 | 
| 39 |  | 
| 40 |     /* Arguments for spd_send_data() */ | 
| 41 | #define SPD_WAIT_REPLY 1	/* Wait for reply */ | 
| 42 | #define SPD_NO_REPLY 0		/* No reply requested */ | 
| 43 |  | 
| 44 |     /* --------------------- Public data types ------------------------ */ | 
| 45 |  | 
| 46 | #ifdef __GNUC__ | 
| 47 | # define SPD_ATTRIBUTE_FORMAT(type, string, first) __attribute__((format(type, string, first))) | 
| 48 | #else | 
| 49 | # define SPD_ATTRIBUTE_FORMAT(type, string, first) | 
| 50 | #endif | 
| 51 |  | 
| 52 | typedef enum { | 
| 53 | 	SPD_MODE_SINGLE = 0, | 
| 54 | 	SPD_MODE_THREADED = 1 | 
| 55 | } SPDConnectionMode; | 
| 56 |  | 
| 57 | typedef enum { | 
| 58 | 	SPD_METHOD_UNIX_SOCKET = 0, | 
| 59 | 	SPD_METHOD_INET_SOCKET = 1, | 
| 60 | } SPDConnectionMethod; | 
| 61 |  | 
| 62 | typedef struct { | 
| 63 | 	SPDConnectionMethod method; | 
| 64 | 	char *unix_socket_name; | 
| 65 | 	char *inet_socket_host; | 
| 66 | 	int inet_socket_port; | 
| 67 | 	char *dbus_bus; | 
| 68 | } SPDConnectionAddress; | 
| 69 |  | 
| 70 | void SPDConnectionAddress__free(SPDConnectionAddress * address); | 
| 71 |  | 
| 72 | typedef void (*SPDCallback) (size_t msg_id, size_t client_id, | 
| 73 | 			     SPDNotificationType state); | 
| 74 | typedef void (*SPDCallbackIM) (size_t msg_id, size_t client_id, | 
| 75 | 			       SPDNotificationType state, char *index_mark); | 
| 76 |  | 
| 77 | typedef struct { | 
| 78 |  | 
| 79 | 	/* PUBLIC */ | 
| 80 | 	SPDCallback callback_begin; | 
| 81 | 	SPDCallback callback_end; | 
| 82 | 	SPDCallback callback_cancel; | 
| 83 | 	SPDCallback callback_pause; | 
| 84 | 	SPDCallback callback_resume; | 
| 85 | 	SPDCallbackIM callback_im; | 
| 86 |  | 
| 87 | 	/* PRIVATE */ | 
| 88 | 	int socket; | 
| 89 | 	FILE *stream; | 
| 90 | 	SPDConnectionMode mode; | 
| 91 |  | 
| 92 | 	pthread_mutex_t ssip_mutex; | 
| 93 |  | 
| 94 | 	struct SPDConnection_threaddata *td; | 
| 95 |  | 
| 96 | 	char *reply; | 
| 97 |  | 
| 98 | } SPDConnection; | 
| 99 |  | 
| 100 | /* -------------- Public functions --------------------------*/ | 
| 101 |  | 
| 102 | /* Opening and closing Speech Dispatcher connection */ | 
| 103 | SPDConnectionAddress *spd_get_default_address(char **error); | 
| 104 | SPDConnection *spd_open(const char *client_name, const char *connection_name, | 
| 105 | 			const char *user_name, SPDConnectionMode mode); | 
| 106 | SPDConnection *spd_open2(const char *client_name, const char *connection_name, | 
| 107 | 			 const char *user_name, SPDConnectionMode mode, | 
| 108 | 			 const SPDConnectionAddress * address, int autospawn, | 
| 109 | 			 char **error_result); | 
| 110 |  | 
| 111 | int spd_get_client_id(SPDConnection * connection); | 
| 112 |  | 
| 113 | void spd_close(SPDConnection * connection); | 
| 114 |  | 
| 115 | /* Speaking */ | 
| 116 | int spd_say(SPDConnection * connection, SPDPriority priority, const char *text); | 
| 117 | int spd_sayf(SPDConnection * connection, SPDPriority priority, | 
| 118 | 	     const char *format, ...) | 
| 119 | 	     SPD_ATTRIBUTE_FORMAT(printf, 3, 4); | 
| 120 |  | 
| 121 | /* Speech flow */ | 
| 122 | int spd_stop(SPDConnection * connection); | 
| 123 | int spd_stop_all(SPDConnection * connection); | 
| 124 | int spd_stop_uid(SPDConnection * connection, int target_uid); | 
| 125 |  | 
| 126 | int spd_cancel(SPDConnection * connection); | 
| 127 | int spd_cancel_all(SPDConnection * connection); | 
| 128 | int spd_cancel_uid(SPDConnection * connection, int target_uid); | 
| 129 |  | 
| 130 | int spd_pause(SPDConnection * connection); | 
| 131 | int spd_pause_all(SPDConnection * connection); | 
| 132 | int spd_pause_uid(SPDConnection * connection, int target_uid); | 
| 133 |  | 
| 134 | int spd_resume(SPDConnection * connection); | 
| 135 | int spd_resume_all(SPDConnection * connection); | 
| 136 | int spd_resume_uid(SPDConnection * connection, int target_uid); | 
| 137 |  | 
| 138 | /* Characters and keys */ | 
| 139 | int spd_key(SPDConnection * connection, SPDPriority priority, | 
| 140 | 	    const char *key_name); | 
| 141 | int spd_char(SPDConnection * connection, SPDPriority priority, | 
| 142 | 	     const char *character); | 
| 143 | int spd_wchar(SPDConnection * connection, SPDPriority priority, | 
| 144 | 	      wchar_t wcharacter); | 
| 145 |  | 
| 146 | /* Sound icons */ | 
| 147 | int spd_sound_icon(SPDConnection * connection, SPDPriority priority, | 
| 148 | 		   const char *icon_name); | 
| 149 |  | 
| 150 | /* Setting parameters */ | 
| 151 | int spd_set_voice_type(SPDConnection *, SPDVoiceType type); | 
| 152 | int spd_set_voice_type_all(SPDConnection *, SPDVoiceType type); | 
| 153 | int spd_set_voice_type_uid(SPDConnection *, SPDVoiceType type, | 
| 154 | 			   unsigned int uid); | 
| 155 | SPDVoiceType spd_get_voice_type(SPDConnection *); | 
| 156 |  | 
| 157 | int spd_set_synthesis_voice(SPDConnection *, const char *voice_name); | 
| 158 | int spd_set_synthesis_voice_all(SPDConnection *, const char *voice_name); | 
| 159 | int spd_set_synthesis_voice_uid(SPDConnection *, const char *voice_name, | 
| 160 | 				unsigned int uid); | 
| 161 |  | 
| 162 | int spd_set_data_mode(SPDConnection * connection, SPDDataMode mode); | 
| 163 |  | 
| 164 | int spd_set_notification_on(SPDConnection * connection, | 
| 165 | 			    SPDNotification notification); | 
| 166 | int spd_set_notification_off(SPDConnection * connection, | 
| 167 | 			     SPDNotification notification); | 
| 168 | int spd_set_notification(SPDConnection * connection, | 
| 169 | 			 SPDNotification notification, const char *state); | 
| 170 |  | 
| 171 | int spd_set_voice_rate(SPDConnection * connection, signed int rate); | 
| 172 | int spd_set_voice_rate_all(SPDConnection * connection, signed int rate); | 
| 173 | int spd_set_voice_rate_uid(SPDConnection * connection, signed int rate, | 
| 174 | 			   unsigned int uid); | 
| 175 | int spd_get_voice_rate(SPDConnection * connection); | 
| 176 |  | 
| 177 | int spd_set_voice_pitch(SPDConnection * connection, signed int pitch); | 
| 178 | int spd_set_voice_pitch_all(SPDConnection * connection, signed int pitch); | 
| 179 | int spd_set_voice_pitch_uid(SPDConnection * connection, signed int pitch, | 
| 180 | 			    unsigned int uid); | 
| 181 | int spd_get_voice_pitch(SPDConnection * connection); | 
| 182 |  | 
| 183 | int spd_set_voice_pitch_range(SPDConnection * connection, | 
| 184 | 			      signed int pitch_range); | 
| 185 | int spd_set_voice_pitch_range_all(SPDConnection * connection, | 
| 186 | 				  signed int pitch_range); | 
| 187 | int spd_set_voice_pitch_range_uid(SPDConnection * connection, | 
| 188 | 				  signed int pitch_range, unsigned int uid); | 
| 189 |  | 
| 190 | int spd_set_volume(SPDConnection * connection, signed int volume); | 
| 191 | int spd_set_volume_all(SPDConnection * connection, signed int volume); | 
| 192 | int spd_set_volume_uid(SPDConnection * connection, signed int volume, | 
| 193 | 		       unsigned int uid); | 
| 194 | int spd_get_volume(SPDConnection * connection); | 
| 195 |  | 
| 196 | int spd_set_punctuation(SPDConnection * connection, SPDPunctuation type); | 
| 197 | int spd_set_punctuation_all(SPDConnection * connection, SPDPunctuation type); | 
| 198 | int spd_set_punctuation_uid(SPDConnection * connection, SPDPunctuation type, | 
| 199 | 			    unsigned int uid); | 
| 200 |  | 
| 201 | int spd_set_capital_letters(SPDConnection * connection, SPDCapitalLetters type); | 
| 202 | int spd_set_capital_letters_all(SPDConnection * connection, | 
| 203 | 				SPDCapitalLetters type); | 
| 204 | int spd_set_capital_letters_uid(SPDConnection * connection, | 
| 205 | 				SPDCapitalLetters type, unsigned int uid); | 
| 206 |  | 
| 207 | int spd_set_spelling(SPDConnection * connection, SPDSpelling type); | 
| 208 | int spd_set_spelling_all(SPDConnection * connection, SPDSpelling type); | 
| 209 | int spd_set_spelling_uid(SPDConnection * connection, SPDSpelling type, | 
| 210 | 			 unsigned int uid); | 
| 211 |  | 
| 212 | int spd_set_language(SPDConnection * connection, const char *language); | 
| 213 | int spd_set_language_all(SPDConnection * connection, const char *language); | 
| 214 | int spd_set_language_uid(SPDConnection * connection, const char *language, | 
| 215 | 			 unsigned int uid); | 
| 216 | char *spd_get_language(SPDConnection * connection); | 
| 217 |  | 
| 218 | int spd_set_output_module(SPDConnection * connection, | 
| 219 | 			  const char *output_module); | 
| 220 | int spd_set_output_module_all(SPDConnection * connection, | 
| 221 | 			      const char *output_module); | 
| 222 | int spd_set_output_module_uid(SPDConnection * connection, | 
| 223 | 			      const char *output_module, unsigned int uid); | 
| 224 |  | 
| 225 | int spd_get_client_list(SPDConnection * connection, char **client_names, | 
| 226 | 			int *client_ids, int *active); | 
| 227 | int spd_get_message_list_fd(SPDConnection * connection, int target, | 
| 228 | 			    int *msg_ids, char **client_names); | 
| 229 |  | 
| 230 | char **spd_list_modules(SPDConnection * connection); | 
| 231 | void free_spd_modules(char **); | 
| 232 | char *spd_get_output_module(SPDConnection * connection); | 
| 233 |  | 
| 234 | char **spd_list_voices(SPDConnection * connection); | 
| 235 | SPDVoice **spd_list_synthesis_voices(SPDConnection * connection); | 
| 236 | void free_spd_voices(SPDVoice ** voices); | 
| 237 | char **spd_execute_command_with_list_reply(SPDConnection * connection, | 
| 238 | 					   const char *command); | 
| 239 |  | 
| 240 | /* Direct SSIP communication */ | 
| 241 | int spd_execute_command(SPDConnection * connection, const char *command); | 
| 242 | int spd_execute_command_with_reply(SPDConnection * connection, const char *command, | 
| 243 | 				   char **reply); | 
| 244 | int spd_execute_command_wo_mutex(SPDConnection * connection, const char *command); | 
| 245 | char *spd_send_data(SPDConnection * connection, const char *message, int wfr); | 
| 246 | char *spd_send_data_wo_mutex(SPDConnection * connection, const char *message, | 
| 247 | 			     int wfr); | 
| 248 |  | 
| 249 |  | 
| 250 |  | 
| 251 | /* *INDENT-OFF* */ | 
| 252 | #ifdef __cplusplus | 
| 253 | } | 
| 254 | #endif /* __cplusplus */ | 
| 255 | /* *INDENT-ON* */ | 
| 256 |  | 
| 257 | #endif /* ifndef _LIBSPEECHD_H */ | 
| 258 |  |