8088969444876df02b7d7b22d806ee89974a9659
[profile/ivi/speech-recognition.git] / src / plugins / client-api / native / native-client.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_CLIENT_H__
31 #define __SRS_NATIVE_CLIENT_H__
32
33 #include <murphy/common/macros.h>
34 #include <glib.h>
35
36 #include "srs/daemon/client-api-types.h"
37 #include "srs/daemon/voice-api-types.h"
38
39 MRP_CDECL_BEGIN
40
41 /** Opaque SRS client context type. */
42 typedef struct srs_s srs_t;
43
44 /** Connection status notification callback type. */
45 typedef void (*srs_connect_notify_t)(srs_t *srs, int status, const char *msg,
46                                      void *user_data);
47
48 /** Command notification callback type. */
49 typedef void (*srs_command_notify_t)(srs_t *srs, int idx, char **tokens,
50                                      int ntoken, void *user_data);
51
52 /** Focus notification callback type. */
53 typedef void (*srs_focus_notify_t)(srs_t *srs, srs_voice_focus_t granted,
54                                    void *user_data);
55
56 /** Voice rendering notification callback type. */
57 typedef void (*srs_render_notify_t)(srs_t *srs, srs_voice_event_t *event,
58                                     void *user_data, void *notify_data);
59
60 /** Voice query notification callback type. */
61 typedef void (*srs_voiceqry_notify_t)(srs_t *srs, srs_voice_actor_t *actors,
62                                       int nactor, void *user_data,
63                                       void *notify_data);
64
65 /** Use the given Murphy mainloop as the underlying mainloop. */
66 void srs_set_mainloop(mrp_mainloop_t *ml);
67
68 /** Use the given GMainLoop as the underlying mainloop. */
69 void srs_set_gmainloop(GMainLoop *gml);
70
71 /** Create an SRS client context with the given class and commands. */
72 srs_t *srs_create(const char *name, const char *appclass, char **commands,
73                   size_t ncommand, srs_connect_notify_t connect_notify,
74                   srs_focus_notify_t focus_notify,
75                   srs_command_notify_t command_notify, void *user_data);
76
77 /** Destroy the given SRS client context. */
78 void srs_destroy(srs_t *srs);
79
80 /** Try to establish a connection to the server at the given address. */
81 int srs_connect(srs_t *srs, const char *server, int reconnect);
82
83 /** Close connection to the server if there is one. */
84 void srs_disconnect(srs_t *srs);
85
86 /** Request the given type of focus. */
87 int srs_request_focus(srs_t *srs, srs_voice_focus_t focus);
88
89 /** Request rendering the given message, subscribing for the given events. */
90 uint32_t srs_render_voice(srs_t *srs, const char *msg, const char *voice,
91                           int timeout, int events, srs_render_notify_t cb,
92                           void *cb_data);
93
94 /** Cancel an ongoing voice render request. */
95 int srs_cancel_voice(srs_t *srs, uint32_t id);
96
97 /** Query the available voices for the given language (or all if omitted). */
98 int srs_query_voices(srs_t *srs, const char *language,
99                      srs_voiceqry_notify_t cb, void *cb_data);
100
101 MRP_CDECL_END
102
103 #endif /* __SRS_NATIVE_CLIENT_H__ */