2 * Copyright (c) 2012, Intel Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
30 #ifndef __SRS_DAEMON_CLIENT_H__
31 #define __SRS_DAEMON_CLIENT_H__
33 typedef struct srs_client_s srs_client_t;
35 #include "srs/daemon/context.h"
36 #include "srs/daemon/resctl.h"
37 #include "srs/daemon/audiobuf.h"
38 #include "srs/daemon/voice.h"
39 #include "srs/daemon/client-api-types.h"
47 SRS_CLIENT_TYPE_NONE = 0,
48 SRS_CLIENT_TYPE_BUILTIN, /* builtin client */
49 SRS_CLIENT_TYPE_EXTERNAL, /* other client */
57 #define SRS_MAX_TOKENS 64
60 char **tokens; /* tokens of this command */
61 int ntoken; /* number of tokens */
66 * dictionary operations
70 SRS_DICT_OP_UNKNOWN = 0,
82 /* recognizer interface */
83 int (*notify_focus)(srs_client_t *c, srs_voice_focus_t focus);
84 int (*notify_command)(srs_client_t *c, int idx, int ntoken,
85 char **tokens, uint32_t *start, uint32_t *end,
86 srs_audiobuf_t *audio);
87 /* voice rendering interface */
88 int (*notify_render)(srs_client_t *c, srs_voice_event_t *event);
93 mrp_list_hook_t hook; /* to list of clients */
94 srs_client_type_t type; /* client type */
95 char *name; /* client name */
96 char *appclass; /* client application class */
97 srs_command_t *commands; /* client command set */
98 int ncommand; /* number of commands */
99 char *id; /* client id */
100 srs_context_t *srs; /* context back pointer */
101 srs_resset_t *rset; /* resource set */
102 srs_voice_focus_t requested; /* requested voice focus */
103 int granted; /* granted resources */
104 int enabled : 1; /* interested in commands */
105 int shared : 1; /* whether voice focus is shared */
106 mrp_list_hook_t voices; /* unfinished voice requests */
107 srs_client_ops_t ops; /* client ops (notifications) */
108 void *user_data; /* opaque client data */
112 /** Create a new client. */
113 srs_client_t *client_create(srs_context_t *srs, srs_client_type_t type,
114 const char *name, const char *appclass,
115 char **commands, int ncommand,
116 const char *id, srs_client_ops_t *ops,
119 /** Destroy a client. */
120 void client_destroy(srs_client_t *c);
122 /** Look up a client by its id. */
123 srs_client_t *client_lookup_by_id(srs_context_t *srs, const char *id);
125 /** Request client focus change. */
126 int client_request_focus(srs_client_t *c, srs_voice_focus_t focus);
128 /** Deliver a command notification event to the client. */
129 void client_notify_command(srs_client_t *c, int idx, int ntoken,
130 const char **tokens, uint32_t *start, uint32_t *end,
131 srs_audiobuf_t *audio);
133 /** Request synthesizing a message. */
134 uint32_t client_render_voice(srs_client_t *c, const char *msg,
135 const char *voice, double rate, double pitch,
136 int timeout, int notify_events);
138 /** Cancel/stop a synthesizing request. */
139 void client_cancel_voice(srs_client_t *c, uint32_t id);
141 /** Create resources for all registered clients. */
142 void client_create_resources(srs_context_t *srs);
144 /** Reset the resource sets of all clients. */
145 void client_reset_resources(srs_context_t *srs);
147 /** Query voice actors. */
148 int client_query_voices(srs_client_t *c, const char *language,
149 srs_voice_actor_t **actorsp);
151 /** Free voice actor query reult. */
152 void client_free_queried_voices(srs_voice_actor_t *actors);
154 #endif /* __SRS_DAEMON_CLIENT_H__ */