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
36extern "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
48typedef enum {
49 SPD_MODE_SINGLE = 0,
50 SPD_MODE_THREADED = 1
51} SPDConnectionMode;
52
53typedef enum {
54 SPD_METHOD_UNIX_SOCKET = 0,
55 SPD_METHOD_INET_SOCKET = 1,
56} SPDConnectionMethod;
57
58typedef 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
66void SPDConnectionAddress__free(SPDConnectionAddress * address);
67
68typedef void (*SPDCallback) (size_t msg_id, size_t client_id,
69 SPDNotificationType state);
70typedef void (*SPDCallbackIM) (size_t msg_id, size_t client_id,
71 SPDNotificationType state, char *index_mark);
72
73typedef 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 */
104SPDConnectionAddress *spd_get_default_address(char **error);
105SPDConnection *spd_open(const char *client_name, const char *connection_name,
106 const char *user_name, SPDConnectionMode mode);
107SPDConnection *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
112void spd_close(SPDConnection * connection);
113
114/* Speaking */
115int spd_say(SPDConnection * connection, SPDPriority priority, const char *text);
116int spd_sayf(SPDConnection * connection, SPDPriority priority,
117 const char *format, ...);
118
119/* Speech flow */
120int spd_stop(SPDConnection * connection);
121int spd_stop_all(SPDConnection * connection);
122int spd_stop_uid(SPDConnection * connection, int target_uid);
123
124int spd_cancel(SPDConnection * connection);
125int spd_cancel_all(SPDConnection * connection);
126int spd_cancel_uid(SPDConnection * connection, int target_uid);
127
128int spd_pause(SPDConnection * connection);
129int spd_pause_all(SPDConnection * connection);
130int spd_pause_uid(SPDConnection * connection, int target_uid);
131
132int spd_resume(SPDConnection * connection);
133int spd_resume_all(SPDConnection * connection);
134int spd_resume_uid(SPDConnection * connection, int target_uid);
135
136/* Characters and keys */
137int spd_key(SPDConnection * connection, SPDPriority priority,
138 const char *key_name);
139int spd_char(SPDConnection * connection, SPDPriority priority,
140 const char *character);
141int spd_wchar(SPDConnection * connection, SPDPriority priority,
142 wchar_t wcharacter);
143
144/* Sound icons */
145int spd_sound_icon(SPDConnection * connection, SPDPriority priority,
146 const char *icon_name);
147
148/* Setting parameters */
149int spd_set_voice_type(SPDConnection *, SPDVoiceType type);
150int spd_set_voice_type_all(SPDConnection *, SPDVoiceType type);
151int spd_set_voice_type_uid(SPDConnection *, SPDVoiceType type,
152 unsigned int uid);
153SPDVoiceType spd_get_voice_type(SPDConnection *);
154
155int spd_set_synthesis_voice(SPDConnection *, const char *voice_name);
156int spd_set_synthesis_voice_all(SPDConnection *, const char *voice_name);
157int spd_set_synthesis_voice_uid(SPDConnection *, const char *voice_name,
158 unsigned int uid);
159
160int spd_set_data_mode(SPDConnection * connection, SPDDataMode mode);
161
162int spd_set_notification_on(SPDConnection * connection,
163 SPDNotification notification);
164int spd_set_notification_off(SPDConnection * connection,
165 SPDNotification notification);
166int spd_set_notification(SPDConnection * connection,
167 SPDNotification notification, const char *state);
168
169int spd_set_voice_rate(SPDConnection * connection, signed int rate);
170int spd_set_voice_rate_all(SPDConnection * connection, signed int rate);
171int spd_set_voice_rate_uid(SPDConnection * connection, signed int rate,
172 unsigned int uid);
173int spd_get_voice_rate(SPDConnection * connection);
174
175int spd_set_voice_pitch(SPDConnection * connection, signed int pitch);
176int spd_set_voice_pitch_all(SPDConnection * connection, signed int pitch);
177int spd_set_voice_pitch_uid(SPDConnection * connection, signed int pitch,
178 unsigned int uid);
179int spd_get_voice_pitch(SPDConnection * connection);
180
181int spd_set_volume(SPDConnection * connection, signed int volume);
182int spd_set_volume_all(SPDConnection * connection, signed int volume);
183int spd_set_volume_uid(SPDConnection * connection, signed int volume,
184 unsigned int uid);
185int spd_get_volume(SPDConnection * connection);
186
187int spd_set_punctuation(SPDConnection * connection, SPDPunctuation type);
188int spd_set_punctuation_all(SPDConnection * connection, SPDPunctuation type);
189int spd_set_punctuation_uid(SPDConnection * connection, SPDPunctuation type,
190 unsigned int uid);
191
192int spd_set_capital_letters(SPDConnection * connection, SPDCapitalLetters type);
193int spd_set_capital_letters_all(SPDConnection * connection,
194 SPDCapitalLetters type);
195int spd_set_capital_letters_uid(SPDConnection * connection,
196 SPDCapitalLetters type, unsigned int uid);
197
198int spd_set_spelling(SPDConnection * connection, SPDSpelling type);
199int spd_set_spelling_all(SPDConnection * connection, SPDSpelling type);
200int spd_set_spelling_uid(SPDConnection * connection, SPDSpelling type,
201 unsigned int uid);
202
203int spd_set_language(SPDConnection * connection, const char *language);
204int spd_set_language_all(SPDConnection * connection, const char *language);
205int spd_set_language_uid(SPDConnection * connection, const char *language,
206 unsigned int uid);
207char *spd_get_language(SPDConnection * connection);
208
209int spd_set_output_module(SPDConnection * connection,
210 const char *output_module);
211int spd_set_output_module_all(SPDConnection * connection,
212 const char *output_module);
213int spd_set_output_module_uid(SPDConnection * connection,
214 const char *output_module, unsigned int uid);
215
216int spd_get_client_list(SPDConnection * connection, char **client_names,
217 int *client_ids, int *active);
218int spd_get_message_list_fd(SPDConnection * connection, int target,
219 int *msg_ids, char **client_names);
220
221char **spd_list_modules(SPDConnection * connection);
222void free_spd_modules(char **);
223char *spd_get_output_module(SPDConnection * connection);
224
225char **spd_list_voices(SPDConnection * connection);
226SPDVoice **spd_list_synthesis_voices(SPDConnection * connection);
227void free_spd_voices(SPDVoice ** voices);
228char **spd_execute_command_with_list_reply(SPDConnection * connection,
229 char *command);
230
231/* Direct SSIP communication */
232int spd_execute_command(SPDConnection * connection, char *command);
233int spd_execute_command_with_reply(SPDConnection * connection, char *command,
234 char **reply);
235int spd_execute_command_wo_mutex(SPDConnection * connection, char *command);
236char *spd_send_data(SPDConnection * connection, const char *message, int wfr);
237char *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 */
249