packaging: bumped version, updated changelog.
[profile/ivi/speech-recognition.git] / src / daemon / client.h
index c0e460d..3de0043 100644 (file)
 
 typedef struct srs_client_s srs_client_t;
 
-#include "src/daemon/context.h"
-#include "src/daemon/resourceif.h"
-#include "src/daemon/audiobuf.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"
 
 
 /*
@@ -42,24 +44,13 @@ typedef struct srs_client_s srs_client_t;
  */
 
 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
  */
 
@@ -72,40 +63,9 @@ typedef struct {
 
 
 /*
- * special command tokens
- */
-
-#define SRS_TOKEN_SWITCHDICT "__switch_dict__"
-#define SRS_TOKEN_PUSHDICT   "__push_dict__"
-#define SRS_TOKEN_POPDICT    "__pop_dict__"
-#define SRS_TOKEN_WILDCARD   "*"
-
-
-/* dictionary pseudo-commands */
-#define SRS_DICTCMD_SWITCH    "__switch_dict__"
-#define SRS_DICTCMD_PUSH      "__push_dict__"
-#define SRS_DICTCMD_POP       "__pop_dict__"
-
-#define SRS_DICT_SWITCH(dict) SRS_DICTCMD_SWITCH"("dict")"
-#define SRS_DICT_PUSH(dict)   SRS_DICTCMD_PUSH"("dict")"
-#define SRS_DICT_POP()        SRS_DICTCMD_POP
-
-
-/*
- * special tokens
- */
-
-#define SRS_TOKEN_SWITCHDICT "__switch_dict__"
-#define SRS_TOKEN_PUSHDICT   "__push_dict__"
-#define SRS_TOKEN_POPDICT    "__pop_dict__"
-
-#define SRS_TOKEN_WILDCARD "*"           /* match till end of utterance */
-
-/*
  * dictionary operations
  */
 
-/* dictionary operations */
 typedef enum {
     SRS_DICT_OP_UNKNOWN = 0,
     SRS_DICT_OP_SWITCH,
@@ -119,16 +79,13 @@ typedef enum {
  */
 
 typedef struct {
+    /* recognizer interface */
     int (*notify_focus)(srs_client_t *c, srs_voice_focus_t focus);
-#if 1
     int (*notify_command)(srs_client_t *c, int idx, int ntoken,
                           char **tokens, uint32_t *start, uint32_t *end,
                           srs_audiobuf_t *audio);
-#else
-    int (*notify_command)(srs_client_t *c, int idx, int ntoken,
-                          char **tokens, void *samplebuf, size_t samplelen,
-                          uint32_t *start, uint32_t *end);
-#endif
+    /* voice rendering interface */
+    int (*notify_render)(srs_client_t *c, srs_voice_event_t *event);
 } srs_client_ops_t;
 
 
@@ -141,12 +98,12 @@ struct srs_client_s {
     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 */
+    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 */
 };
@@ -168,18 +125,30 @@ srs_client_t *client_lookup_by_id(srs_context_t *srs, const char *id);
 /** 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);
 
-/** 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);
+/** Free voice actor query reult. */
+void client_free_queried_voices(srs_voice_actor_t *actors);
 
 #endif /* __SRS_DAEMON_CLIENT_H__ */