typedef struct srs_client_s srs_client_t;
-#include "src/daemon/context.h"
-#include "src/daemon/resourceif.h"
+#include "srs/daemon/context.h"
+#include "srs/daemon/resctl.h"
+#include "srs/daemon/audiobuf.h"
+#include "srs/daemon/voice.h"
+#include "srs/daemon/client-api-types.h"
/*
*/
typedef enum {
- SRS_CLIENT_TYPE_UNKNOWN = 0,
- SRS_CLIENT_TYPE_DBUS, /* external D-BUS client */
+ SRS_CLIENT_TYPE_NONE = 0,
SRS_CLIENT_TYPE_BUILTIN, /* builtin client */
+ SRS_CLIENT_TYPE_EXTERNAL, /* other client */
} srs_client_type_t;
/*
- * voice focus types
- */
-
-typedef enum {
- SRS_VOICE_FOCUS_NONE = 0, /* focus released */
- SRS_VOICE_FOCUS_SHARED, /* normal shared voice focus */
- SRS_VOICE_FOCUS_EXCLUSIVE, /* exclusive voice focus */
-} srs_voice_focus_t;
-
-
-/*
* client commands
*/
+#define SRS_MAX_TOKENS 64
+
typedef struct {
char **tokens; /* tokens of this command */
int ntoken; /* number of tokens */
/*
+ * dictionary operations
+ */
+
+typedef enum {
+ SRS_DICT_OP_UNKNOWN = 0,
+ SRS_DICT_OP_SWITCH,
+ SRS_DICT_OP_PUSH,
+ SRS_DICT_OP_POP
+} srs_dict_op_t;
+
+
+/*
* connected clients
*/
typedef struct {
+ /* recognizer interface */
int (*notify_focus)(srs_client_t *c, srs_voice_focus_t focus);
- int (*notify_command)(srs_client_t *c, int ntoken, char **tokens);
+ int (*notify_command)(srs_client_t *c, int idx, int ntoken,
+ char **tokens, uint32_t *start, uint32_t *end,
+ srs_audiobuf_t *audio);
+ /* voice rendering interface */
+ int (*notify_render)(srs_client_t *c, srs_voice_event_t *event);
} srs_client_ops_t;
int ncommand; /* number of commands */
char *id; /* client id */
srs_context_t *srs; /* context back pointer */
- mrp_res_resource_set_t *rset; /* resource set */
+ srs_resset_t *rset; /* resource set */
srs_voice_focus_t requested; /* requested voice focus */
- srs_voice_focus_t granted; /* granted voice focus */
- srs_voice_focus_t focus; /* requested voice focus */
+ int granted; /* granted resources */
int enabled : 1; /* interested in commands */
- int allowed : 1; /* has resource granted */
- srs_client_ops_t *ops; /* client ops (notifications) */
+ int shared : 1; /* whether voice focus is shared */
+ mrp_list_hook_t voices; /* unfinished voice requests */
+ srs_client_ops_t ops; /* client ops (notifications) */
+ void *user_data; /* opaque client data */
};
srs_client_t *client_create(srs_context_t *srs, srs_client_type_t type,
const char *name, const char *appclass,
char **commands, int ncommand,
- const char *id, srs_client_ops_t *ops);
+ const char *id, srs_client_ops_t *ops,
+ void *user_data);
/** Destroy a client. */
void client_destroy(srs_client_t *c);
/** Request client focus change. */
int client_request_focus(srs_client_t *c, srs_voice_focus_t focus);
+/** Deliver a command notification event to the client. */
+void client_notify_command(srs_client_t *c, int idx, int ntoken,
+ const char **tokens, uint32_t *start, uint32_t *end,
+ srs_audiobuf_t *audio);
+
+/** Request synthesizing a message. */
+uint32_t client_render_voice(srs_client_t *c, const char *msg,
+ const char *voice, double rate, double pitch,
+ int timeout, int notify_events);
+
+/** Cancel/stop a synthesizing request. */
+void client_cancel_voice(srs_client_t *c, uint32_t id);
+
/** Create resources for all registered clients. */
void client_create_resources(srs_context_t *srs);
/** Reset the resource sets of all clients. */
void client_reset_resources(srs_context_t *srs);
-/** Deliver a resource notification event to the client. */
-void client_resource_event(srs_client_t *c, srs_resset_event_t event);
+/** Query voice actors. */
+int client_query_voices(srs_client_t *c, const char *language,
+ srs_voice_actor_t **actorsp);
+
+/** Free voice actor query reult. */
+void client_free_queried_voices(srs_voice_actor_t *actors);
#endif /* __SRS_DAEMON_CLIENT_H__ */