voice, festival, client, native-client, dbus-client: add API support for rate and...
[profile/ivi/speech-recognition.git] / src / plugins / client-api / native / native-messages.h
1 /*
2  * Copyright (c) 2012, 2013, Intel Corporation
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *   * Redistributions of source code must retain the above copyright notice,
9  *     this list of conditions and the following disclaimer.
10  *   * Redistributions in binary form must reproduce the above copyright
11  *     notice, this list of conditions and the following disclaimer in the
12  *     documentation and/or other materials provided with the distribution.
13  *   * Neither the name of Intel Corporation nor the names of its contributors
14  *     may be used to endorse or promote products derived from this software
15  *     without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #ifndef __SRS_NATIVE_MESSAGES_H__
31 #define __SRS_NATIVE_MESSAGES_H__
32
33 #include <stdint.h>
34 #include <murphy/common/native-types.h>
35 #include <murphy/common/transport.h>
36
37 #include "srs/daemon/voice-api-types.h"
38
39
40 /*
41  * message types
42  */
43
44 typedef enum {
45     SRS_MSG_UNKNOWN = 0,
46
47     SRS_REQUEST_REGISTER,
48     SRS_REQUEST_UNREGISTER,
49     SRS_REQUEST_FOCUS,
50     SRS_REQUEST_RENDERVOICE,
51     SRS_REQUEST_CANCELVOICE,
52     SRS_REQUEST_QUERYVOICES,
53
54     SRS_REPLY_STATUS,
55     SRS_REPLY_RENDERVOICE,
56     SRS_VOICE_ACTOR,
57     SRS_REPLY_QUERYVOICES,
58
59     SRS_EVENT_FOCUS,
60     SRS_EVENT_COMMAND,
61     SRS_EVENT_VOICE,
62
63     SRS_MSG_MAX
64 } srs_msg_type_t;
65
66
67 /*
68  * registration request
69  */
70
71 typedef struct {
72     uint32_t   type;                     /* SRS_REQUEST_REGISTER */
73     uint32_t   reqno;                    /* request number */
74     char      *name;                     /* application name */
75     char      *appclass;                 /* application class */
76     char     **commands;                 /* speech commands */
77     uint32_t   ncommand;                 /* number of speech commands */
78 } srs_req_register_t;
79
80
81 /*
82  * unregistration request
83  */
84
85 typedef struct {
86     uint32_t type;                       /* SRS_REQUEST_UNREGISTER */
87     uint32_t reqno;                      /* request number */
88 } srs_req_unregister_t;
89
90
91 /*
92  * error codes
93  */
94
95 enum {
96     SRS_STATUS_OK = 0,                   /* success */
97     SRS_STATUS_FAILED,                   /* request failed */
98 };
99
100
101 /*
102  * a status reply
103  */
104
105 typedef struct {
106     uint32_t  type;                      /* message type */
107     uint32_t  reqno;                     /* request number */
108     uint32_t  status;                    /* an error code, or 0 */
109     char     *msg;                       /* error message, if any */
110 } srs_rpl_status_t;
111
112
113 /*
114  * voice focus request
115  */
116
117 typedef struct {
118     uint32_t type;                       /* SRS_REQUEST_FOCUS */
119     uint32_t reqno;                      /* request number */
120     uint32_t focus;                      /* current voice focus */
121 } srs_req_focus_t;
122
123
124 /*
125  * voice focus notification
126  */
127
128 typedef struct {
129     uint32_t type;                       /* SRS_EVENT_FOCUS */
130     uint32_t focus;                      /* granted focus */
131 } srs_evt_focus_t;
132
133
134 /*
135  * voice render request
136  */
137
138 typedef struct {
139     uint32_t  type;                      /* SRS_REQUEST_VOICERENDER */
140     uint32_t  reqno;                     /* request number */
141     char     *msg;                       /* message to render */
142     char     *voice;                     /* voice to use */
143     double    rate;                      /* voice pitch (0 or 1 = default) */
144     double    pitch;                     /* voice pitch (0 or 1 = default) */
145     uint32_t  timeout;                   /* message timeout */
146     uint32_t  events;                    /* mask of events to notify about */
147 } srs_req_voice_t;
148
149
150 /*
151  * reply to voice render request
152  */
153
154 typedef struct {
155     uint32_t  type;                      /* SRS_REPLY_RENDERVOICE */
156     uint32_t  reqno;                     /* request number */
157     uint32_t  id;                        /* client-side id */
158 } srs_rpl_voice_t;
159
160
161 /*
162  * voice cancel request
163  */
164
165 typedef struct {
166     uint32_t  type;                      /* SRS_REQUEST_VOICECANCEL */
167     uint32_t  reqno;                     /* request number */
168     uint32_t  id;                        /* voice render id */
169 } srs_ccl_voice_t;
170
171
172 /*
173  * voice progress notification event
174  */
175
176 typedef struct {
177     uint32_t type;                       /* SRS_EVENT_VOICE */
178     uint32_t event;                      /* SRS_VOICE_EVENT_* */
179     uint32_t id;                         /* voice render id */
180     double   pcnt;                       /* progress in percentages */
181     uint32_t msec;                       /* progress in milliseconds */
182 } srs_evt_voice_t;
183
184
185 /*
186  * voice query request
187  */
188
189 typedef struct {
190     uint32_t  type;                      /* SRS_REQUEST_QUERYVOICES */
191     uint32_t  reqno;                     /* request number */
192     char     *lang;                      /* language to request voices for */
193 } srs_req_voiceqry_t;
194
195
196 /*
197  * voice query reply
198  */
199
200 typedef struct {
201     uint32_t           type;             /* SRS_REPLY_QUERYVOICES */
202     uint32_t           reqno;            /* request number */
203     srs_voice_actor_t *actors;           /* queried actors */
204     uint32_t           nactor;           /* number of actors */
205 } srs_rpl_voiceqry_t;
206
207
208 /*
209  * command notification event
210  */
211
212 typedef struct {
213     uint32_t   type;                     /* SRS_EVENT_COMMAND */
214     uint32_t   idx;                      /* client command index */
215     char     **tokens;                   /* command tokens */
216     uint32_t   ntoken;                   /* number of tokens */
217 } srs_evt_command_t;
218
219
220 /*
221  * a generic request or reply
222  */
223
224 typedef struct {
225     uint32_t type;                       /* message type */
226     uint32_t reqno;                      /* request number */
227 } srs_req_any_t;
228
229 typedef srs_req_any_t srs_rpl_any_t;
230
231 /*
232  * message
233  */
234
235 typedef union {
236     uint32_t               type;
237     srs_req_any_t          any_req;
238     srs_rpl_any_t          any_rpl;
239     srs_req_register_t     reg_req;
240     srs_req_unregister_t   bye_req;
241     srs_rpl_status_t       status_rpl;
242     srs_req_focus_t        focus_req;
243     srs_evt_focus_t        focus_evt;
244     srs_req_voice_t        voice_req;
245     srs_rpl_voice_t        voice_rpl;
246     srs_ccl_voice_t        voice_ccl;
247     srs_evt_voice_t        voice_evt;
248     srs_req_voiceqry_t     voice_qry;
249     srs_rpl_voiceqry_t     voice_lst;
250     srs_evt_command_t      command_evt;
251 } srs_msg_t;
252
253
254 mrp_typemap_t *register_message_types(void);
255 int send_message(mrp_transport_t *t, srs_msg_t *msg);
256 uint32_t message_typeid(uint32_t type);
257 uint32_t message_type(uint32_t type_id);
258
259 #endif /* __SRS_NATIVE_MESSAGES_H__ */