Debian Codegraph @

thirdparty/linuxbsd_headers/speechd/libspeechd.h

raw symbols SCIP
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 package; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 * $Id: libspeechd.h,v 1.29 2008-07-30 09:47:00 hanke Exp $
22 */
23
24 #ifndef _LIBSPEECHD_H
25 #define _LIBSPEECHD_H
26
27 #include <stdio.h>
28 #include <stddef.h>
29 #include <pthread.h>
30
31 #include "libspeechd_version.h"
32 #include "speechd_types.h"
33
34 /* *INDENT-OFF* */
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 /* *INDENT-ON* */
39 /* Speech Dispatcher's default port for inet communication */
40 #define SPEECHD_DEFAULT_PORT 6560
41
42 /* Arguments for spd_send_data() */
43 #define SPD_WAIT_REPLY 1 /* Wait for reply */
44 #define SPD_NO_REPLY 0 /* No reply requested */
45
46 /* --------------------- Public data types ------------------------ */
47
48 typedef enum {
49 SPD_MODE_SINGLE = 0,
50 SPD_MODE_THREADED = 1
51 } SPDConnectionMode;
52
53 typedef enum {
54 SPD_METHOD_UNIX_SOCKET = 0,
55 SPD_METHOD_INET_SOCKET = 1,
56 } SPDConnectionMethod;
57
58 typedef struct {
59 SPDConnectionMethod method;
60 char *unix_socket_name;
61 char *inet_socket_host;
62 int inet_socket_port;
63 char *dbus_bus;
64 } SPDConnectionAddress;
65
66 void SPDConnectionAddress__free(SPDConnectionAddress * address);
67
68 typedef void (*SPDCallback) (size_t msg_id, size_t client_id,
69 SPDNotificationType state);
70 typedef void (*SPDCallbackIM) (size_t msg_id, size_t client_id,
71 SPDNotificationType state, char *index_mark);
72
73 typedef struct {
74
75 /* PUBLIC */
76 SPDCallback callback_begin;
77 SPDCallback callback_end;
78 SPDCallback callback_cancel;
79 SPDCallback callback_pause;
80 SPDCallback callback_resume;
81 SPDCallbackIM callback_im;
82
83 /* PRIVATE */
84 int socket;
85 FILE *stream;
86 SPDConnectionMode mode;
87
88 pthread_mutex_t *ssip_mutex;
89
90 pthread_t *events_thread;
91 pthread_mutex_t *comm_mutex;
92 pthread_cond_t *cond_reply_ready;
93 pthread_mutex_t *mutex_reply_ready;
94 pthread_cond_t *cond_reply_ack;
95 pthread_mutex_t *mutex_reply_ack;
96
97 char *reply;
98
99 } SPDConnection;
100
101 /* -------------- Public functions --------------------------*/
102
103 /* Opening and closing Speech Dispatcher connection */
104 SPDConnectionAddress *spd_get_default_address(char **error);
105 SPDConnection *spd_open(const char *client_name, const char *connection_name,
106 const char *user_name, SPDConnectionMode mode);
107 SPDConnection *spd_open2(const char *client_name, const char *connection_name,
108 const char *user_name, SPDConnectionMode mode,
109 SPDConnectionAddress * address, int autospawn,
110 char **error_result);
111
112 void spd_close(SPDConnection * connection);
113
114 /* Speaking */
115 int spd_say(SPDConnection * connection, SPDPriority priority, const char *text);
116 int spd_sayf(SPDConnection * connection, SPDPriority priority,
117 const char *format, ...);
118
119 /* Speech flow */
120 int spd_stop(SPDConnection * connection);
121 int spd_stop_all(SPDConnection * connection);
122 int spd_stop_uid(SPDConnection * connection, int target_uid);
123
124 int spd_cancel(SPDConnection * connection);
125 int spd_cancel_all(SPDConnection * connection);
126 int spd_cancel_uid(SPDConnection * connection, int target_uid);
127
128 int spd_pause(SPDConnection * connection);
129 int spd_pause_all(SPDConnection * connection);
130 int spd_pause_uid(SPDConnection * connection, int target_uid);
131
132 int spd_resume(SPDConnection * connection);
133 int spd_resume_all(SPDConnection * connection);
134 int spd_resume_uid(SPDConnection * connection, int target_uid);
135
136 /* Characters and keys */
137 int spd_key(SPDConnection * connection, SPDPriority priority,
138 const char *key_name);
139 int spd_char(SPDConnection * connection, SPDPriority priority,
140 const char *character);
141 int spd_wchar(SPDConnection * connection, SPDPriority priority,
142 wchar_t wcharacter);
143
144 /* Sound icons */
145 int spd_sound_icon(SPDConnection * connection, SPDPriority priority,
146 const char *icon_name);
147
148 /* Setting parameters */
149 int spd_set_voice_type(SPDConnection *, SPDVoiceType type);
150 int spd_set_voice_type_all(SPDConnection *, SPDVoiceType type);
151 int spd_set_voice_type_uid(SPDConnection *, SPDVoiceType type,
152 unsigned int uid);
153 SPDVoiceType spd_get_voice_type(SPDConnection *);
154
155 int spd_set_synthesis_voice(SPDConnection *, const char *voice_name);
156 int spd_set_synthesis_voice_all(SPDConnection *, const char *voice_name);
157 int spd_set_synthesis_voice_uid(SPDConnection *, const char *voice_name,
158 unsigned int uid);
159
160 int spd_set_data_mode(SPDConnection * connection, SPDDataMode mode);
161
162 int spd_set_notification_on(SPDConnection * connection,
163 SPDNotification notification);
164 int spd_set_notification_off(SPDConnection * connection,
165 SPDNotification notification);
166 int spd_set_notification(SPDConnection * connection,
167 SPDNotification notification, const char *state);
168
169 int spd_set_voice_rate(SPDConnection * connection, signed int rate);
170 int spd_set_voice_rate_all(SPDConnection * connection, signed int rate);
171 int spd_set_voice_rate_uid(SPDConnection * connection, signed int rate,
172 unsigned int uid);
173 int spd_get_voice_rate(SPDConnection * connection);
174
175 int spd_set_voice_pitch(SPDConnection * connection, signed int pitch);
176 int spd_set_voice_pitch_all(SPDConnection * connection, signed int pitch);
177 int spd_set_voice_pitch_uid(SPDConnection * connection, signed int pitch,
178 unsigned int uid);
179 int spd_get_voice_pitch(SPDConnection * connection);
180
181 int spd_set_volume(SPDConnection * connection, signed int volume);
182 int spd_set_volume_all(SPDConnection * connection, signed int volume);
183 int spd_set_volume_uid(SPDConnection * connection, signed int volume,
184 unsigned int uid);
185 int spd_get_volume(SPDConnection * connection);
186
187 int spd_set_punctuation(SPDConnection * connection, SPDPunctuation type);
188 int spd_set_punctuation_all(SPDConnection * connection, SPDPunctuation type);
189 int spd_set_punctuation_uid(SPDConnection * connection, SPDPunctuation type,
190 unsigned int uid);
191
192 int spd_set_capital_letters(SPDConnection * connection, SPDCapitalLetters type);
193 int spd_set_capital_letters_all(SPDConnection * connection,
194 SPDCapitalLetters type);
195 int spd_set_capital_letters_uid(SPDConnection * connection,
196 SPDCapitalLetters type, unsigned int uid);
197
198 int spd_set_spelling(SPDConnection * connection, SPDSpelling type);
199 int spd_set_spelling_all(SPDConnection * connection, SPDSpelling type);
200 int spd_set_spelling_uid(SPDConnection * connection, SPDSpelling type,
201 unsigned int uid);
202
203 int spd_set_language(SPDConnection * connection, const char *language);
204 int spd_set_language_all(SPDConnection * connection, const char *language);
205 int spd_set_language_uid(SPDConnection * connection, const char *language,
206 unsigned int uid);
207 char *spd_get_language(SPDConnection * connection);
208
209 int spd_set_output_module(SPDConnection * connection,
210 const char *output_module);
211 int spd_set_output_module_all(SPDConnection * connection,
212 const char *output_module);
213 int spd_set_output_module_uid(SPDConnection * connection,
214 const char *output_module, unsigned int uid);
215
216 int spd_get_client_list(SPDConnection * connection, char **client_names,
217 int *client_ids, int *active);
218 int spd_get_message_list_fd(SPDConnection * connection, int target,
219 int *msg_ids, char **client_names);
220
221 char **spd_list_modules(SPDConnection * connection);
222 void free_spd_modules(char **);
223 char *spd_get_output_module(SPDConnection * connection);
224
225 char **spd_list_voices(SPDConnection * connection);
226 SPDVoice **spd_list_synthesis_voices(SPDConnection * connection);
227 void free_spd_voices(SPDVoice ** voices);
228 char **spd_execute_command_with_list_reply(SPDConnection * connection,
229 char *command);
230
231 /* Direct SSIP communication */
232 int spd_execute_command(SPDConnection * connection, char *command);
233 int spd_execute_command_with_reply(SPDConnection * connection, char *command,
234 char **reply);
235 int spd_execute_command_wo_mutex(SPDConnection * connection, char *command);
236 char *spd_send_data(SPDConnection * connection, const char *message, int wfr);
237 char *spd_send_data_wo_mutex(SPDConnection * connection, const char *message,
238 int wfr);
239
240
241
242 /* *INDENT-OFF* */
243 #ifdef __cplusplus
244 }
245 #endif /* __cplusplus */
246 /* *INDENT-ON* */
247
248 #endif /* ifndef _LIBSPEECHD_H */