Service Worker: Start coalescing SWVersion's timers.
[chromium-blink-merge.git] / third_party / speech-dispatcher / libspeechd.h
blob66aea959b484b904db84159e950065d49a07df9f
2 /*
3 * libspeechd.h - Shared library for easy acces to Speech Dispatcher functions (header)
5 * Copyright (C) 2001, 2002, 2003, 2004 Brailcom, o.p.s.
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this package; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
22 * $Id: libspeechd.h,v 1.29 2008-07-30 09:47:00 hanke Exp $
25 #ifndef _LIBSPEECHD_H
26 #define _LIBSPEECHD_H
28 #include <stdio.h>
29 #include <stddef.h>
30 #include <pthread.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 /* Arguments for spd_send_data() */
37 #define SPD_WAIT_REPLY 1 /* Wait for reply */
38 #define SPD_NO_REPLY 0 /* No reply requested */
41 /* --------------------- Public data types ------------------------ */
43 typedef enum{
44 SPD_PUNCT_ALL = 0,
45 SPD_PUNCT_NONE = 1,
46 SPD_PUNCT_SOME = 2
47 }SPDPunctuation;
49 typedef enum{
50 SPD_CAP_NONE = 0,
51 SPD_CAP_SPELL = 1,
52 SPD_CAP_ICON = 2
53 }SPDCapitalLetters;
55 typedef enum{
56 SPD_SPELL_OFF = 0,
57 SPD_SPELL_ON = 1
58 }SPDSpelling;
60 typedef enum{
61 SPD_DATA_TEXT = 0,
62 SPD_DATA_SSML = 1
63 }SPDDataMode;
65 typedef enum{
66 SPD_MALE1 = 1,
67 SPD_MALE2 = 2,
68 SPD_MALE3 = 3,
69 SPD_FEMALE1 = 4,
70 SPD_FEMALE2 = 5,
71 SPD_FEMALE3 = 6,
72 SPD_CHILD_MALE = 7,
73 SPD_CHILD_FEMALE = 8
74 }SPDVoiceType;
77 typedef struct{
78 char *name; /* Name of the voice (id) */
79 char *language; /* 2-letter ISO language code */
80 char *variant; /* a not-well defined string describing dialect etc. */
81 }SPDVoice;
83 typedef enum{
84 SPD_BEGIN = 1,
85 SPD_END = 2,
86 SPD_INDEX_MARKS = 4,
87 SPD_CANCEL = 8,
88 SPD_PAUSE = 16,
89 SPD_RESUME = 32
90 }SPDNotification;
92 typedef enum{
93 SPD_IMPORTANT = 1,
94 SPD_MESSAGE = 2,
95 SPD_TEXT = 3,
96 SPD_NOTIFICATION = 4,
97 SPD_PROGRESS = 5
98 }SPDPriority;
100 typedef enum{
101 SPD_EVENT_BEGIN,
102 SPD_EVENT_END,
103 SPD_EVENT_CANCEL,
104 SPD_EVENT_PAUSE,
105 SPD_EVENT_RESUME,
106 SPD_EVENT_INDEX_MARK
107 }SPDNotificationType;
109 typedef enum{
110 SPD_MODE_SINGLE = 0,
111 SPD_MODE_THREADED = 1
112 }SPDConnectionMode;
114 typedef enum{
115 SPD_METHOD_UNIX_SOCKET = 0,
116 SPD_METHOD_INET_SOCKET = 1,
117 }SPDConnectionMethod;
119 typedef struct{
120 SPDConnectionMethod method;
121 char *unix_socket_name;
122 char *inet_socket_host;
123 int inet_socket_port;
124 char *dbus_bus;
125 }SPDConnectionAddress;
127 typedef void (*SPDCallback)(size_t msg_id, size_t client_id, SPDNotificationType state);
128 typedef void (*SPDCallbackIM)(size_t msg_id, size_t client_id, SPDNotificationType state, char *index_mark);
130 typedef struct{
132 /* PUBLIC */
133 SPDCallback callback_begin;
134 SPDCallback callback_end;
135 SPDCallback callback_cancel;
136 SPDCallback callback_pause;
137 SPDCallback callback_resume;
138 SPDCallbackIM callback_im;
140 /* PRIVATE */
141 int socket;
142 FILE *stream;
143 SPDConnectionMode mode;
145 pthread_mutex_t *ssip_mutex;
147 pthread_t *events_thread;
148 pthread_mutex_t *comm_mutex;
149 pthread_cond_t *cond_reply_ready;
150 pthread_mutex_t *mutex_reply_ready;
151 pthread_cond_t *cond_reply_ack;
152 pthread_mutex_t *mutex_reply_ack;
154 char *reply;
156 }SPDConnection;
158 /* -------------- Public functions --------------------------*/
160 /* Openning and closing Speech Dispatcher connection */
161 SPDConnectionAddress* spd_get_default_address(char** error);
162 SPDConnection* spd_open(const char* client_name, const char* connection_name, const char* user_name,
163 SPDConnectionMode mode);
164 SPDConnection* spd_open2(const char* client_name, const char* connection_name, const char* user_name,
165 SPDConnectionMode mode, SPDConnectionAddress *address, int autospawn,
166 char **error_result);
168 void spd_close(SPDConnection* connection);
170 /* Speaking */
171 int spd_say(SPDConnection* connection, SPDPriority priority, const char* text);
172 int spd_sayf(SPDConnection* connection, SPDPriority priority, const char *format, ...);
174 /* Speech flow */
175 int spd_stop(SPDConnection* connection);
176 int spd_stop_all(SPDConnection* connection);
177 int spd_stop_uid(SPDConnection* connection, int target_uid);
179 int spd_cancel(SPDConnection* connection);
180 int spd_cancel_all(SPDConnection* connection);
181 int spd_cancel_uid(SPDConnection* connection, int target_uid);
183 int spd_pause(SPDConnection* connection);
184 int spd_pause_all(SPDConnection* connection);
185 int spd_pause_uid(SPDConnection* connection, int target_uid);
187 int spd_resume(SPDConnection* connection);
188 int spd_resume_all(SPDConnection* connection);
189 int spd_resume_uid(SPDConnection* connection, int target_uid);
191 /* Characters and keys */
192 int spd_key(SPDConnection* connection, SPDPriority priority, const char *key_name);
193 int spd_char(SPDConnection* connection, SPDPriority priority, const char *character);
194 int spd_wchar(SPDConnection* connection, SPDPriority priority, wchar_t wcharacter);
196 /* Sound icons */
197 int spd_sound_icon(SPDConnection* connection, SPDPriority priority, const char *icon_name);
199 /* Setting parameters */
200 int spd_set_voice_type(SPDConnection*, SPDVoiceType type);
201 int spd_set_voice_type_all(SPDConnection*, SPDVoiceType type);
202 int spd_set_voice_type_uid(SPDConnection*, SPDVoiceType type, unsigned int uid);
204 int spd_set_synthesis_voice(SPDConnection*, const char *voice_name);
205 int spd_set_synthesis_voice_all(SPDConnection*, const char *voice_name);
206 int spd_set_synthesis_voice_uid(SPDConnection*, const char *voice_name, unsigned int uid);
208 int spd_set_data_mode(SPDConnection *connection, SPDDataMode mode);
210 int spd_set_notification_on(SPDConnection* connection, SPDNotification notification);
211 int spd_set_notification_off(SPDConnection* connection, SPDNotification notification);
212 int spd_set_notification(SPDConnection* connection, SPDNotification notification, const char* state);
214 int spd_set_voice_rate(SPDConnection* connection, signed int rate);
215 int spd_set_voice_rate_all(SPDConnection* connection, signed int rate);
216 int spd_set_voice_rate_uid(SPDConnection* connection, signed int rate, unsigned int uid);
218 int spd_set_voice_pitch(SPDConnection* connection, signed int pitch);
219 int spd_set_voice_pitch_all(SPDConnection* connection, signed int pitch);
220 int spd_set_voice_pitch_uid(SPDConnection* connection, signed int pitch, unsigned int uid);
222 int spd_set_volume(SPDConnection* connection, signed int volume);
223 int spd_set_volume_all(SPDConnection* connection, signed int volume);
224 int spd_set_volume_uid(SPDConnection* connection, signed int volume, unsigned int uid);
226 int spd_set_punctuation(SPDConnection* connection, SPDPunctuation type);
227 int spd_set_punctuation_all(SPDConnection* connection, SPDPunctuation type);
228 int spd_set_punctuation_uid(SPDConnection* connection, SPDPunctuation type, unsigned int uid);
230 int spd_set_capital_letters(SPDConnection* connection, SPDCapitalLetters type);
231 int spd_set_capital_letters_all(SPDConnection* connection, SPDCapitalLetters type);
232 int spd_set_capital_letters_uid(SPDConnection* connection, SPDCapitalLetters type, unsigned int uid);
234 int spd_set_spelling(SPDConnection* connection, SPDSpelling type);
235 int spd_set_spelling_all(SPDConnection* connection, SPDSpelling type);
236 int spd_set_spelling_uid(SPDConnection* connection, SPDSpelling type, unsigned int uid);
238 int spd_set_language(SPDConnection* connection, const char* language);
239 int spd_set_language_all(SPDConnection* connection, const char* language);
240 int spd_set_language_uid(SPDConnection* connection, const char* language, unsigned int uid);
242 int spd_set_output_module(SPDConnection* connection, const char* output_module);
243 int spd_set_output_module_all(SPDConnection* connection, const char* output_module);
244 int spd_set_output_module_uid(SPDConnection* connection, const char* output_module, unsigned int uid);
246 int spd_get_client_list(SPDConnection *connection, char **client_names, int *client_ids, int* active);
247 int spd_get_message_list_fd(SPDConnection *connection, int target, int *msg_ids, char **client_names);
249 char** spd_list_modules(SPDConnection *connection);
250 char** spd_list_voices(SPDConnection *connection);
251 SPDVoice** spd_list_synthesis_voices(SPDConnection *connection);
252 char** spd_execute_command_with_list_reply(SPDConnection *connection, char* command);
255 /* Direct SSIP communication */
256 int spd_execute_command(SPDConnection* connection, char* command);
257 int spd_execute_command_with_reply(SPDConnection *connection, char* command, char **reply);
258 int spd_execute_command_wo_mutex(SPDConnection *connection, char* command);
259 char* spd_send_data(SPDConnection* connection, const char *message, int wfr);
260 char* spd_send_data_wo_mutex(SPDConnection *connection, const char *message, int wfr);
264 #ifdef __cplusplus
266 #endif /* __cplusplus */
268 #endif /* ifndef _LIBSPEECHD_H */