Fix dbus delay when requesting hello
[platform/core/uifw/stt.git] / client / stt_client.h
1 /*
2 *  Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *  Licensed under the Apache License, Version 2.0 (the "License");
4 *  you may not use this file except in compliance with the License.
5 *  You may obtain a copy of the License at
6 *  http://www.apache.org/licenses/LICENSE-2.0
7 *  Unless required by applicable law or agreed to in writing, software
8 *  distributed under the License is distributed on an "AS IS" BASIS,
9 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 *  See the License for the specific language governing permissions and
11 *  limitations under the License.
12 */
13
14
15 #ifndef __STT_CLIENT_H_
16 #define __STT_CLIENT_H_
17
18 #include <pthread.h>
19 #include "stt.h"
20 #include "stt_internal.h"
21 #include "stt_main.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 typedef enum {
28         STT_INTERNAL_STATE_NONE         = 0,
29         STT_INTERNAL_STATE_STARTING     = 1,
30         STT_INTERNAL_STATE_STOPPING     = 2,
31         STT_INTERNAL_STATE_CANCELING    = 3
32 } stt_internal_state_e;
33
34 typedef struct {
35         /* base info */
36         stt_h   stt;
37         int     pid;
38         int     uid;    /*<< unique id = pid + handle */
39
40         stt_recognition_result_cb       recognition_result_cb;
41         void*                           recognition_result_user_data;
42         stt_result_time_cb              result_time_cb;
43         void*                           result_time_user_data;
44
45         stt_state_changed_cb            state_changed_cb;
46         void*                           state_changed_user_data;
47         stt_error_cb                    error_cb;
48         void*                           error_user_data;
49         stt_default_language_changed_cb default_lang_changed_cb;
50         void*                           default_lang_changed_user_data;
51         stt_engine_changed_cb           engine_changed_cb;
52         void*                           engine_changed_user_data;
53
54         stt_supported_engine_cb         supported_engine_cb;
55         void*                           supported_engine_user_data;
56         stt_supported_language_cb       supported_lang_cb;
57         void*                           supported_lang_user_data;
58
59         stt_speech_status_cb            speech_status_cb;
60         void*                           speech_status_user_data;
61
62         char*           current_engine_id;
63         char*           credential;
64
65         /* option */
66         bool            silence_supported;
67         stt_option_silence_detection_e  silence;
68         bool            credential_needed;
69
70         /* state */
71         stt_state_e     before_state;
72         stt_state_e     current_state;
73
74         stt_internal_state_e    internal_state;
75
76         /* speech status */
77         int     speech_status;
78
79         /* mutex */
80         int             cb_ref_count;
81
82         /* result data */
83         int     event;
84         char**  data_list;
85         int     data_count;
86         char*   msg;
87
88         /* error data */
89         int     reason;
90         char*   err_msg;
91
92         /* is this internal? */
93         bool    internal;
94 } stt_client_s;
95
96
97 typedef bool (*stt_time_cb)(int index, int event, const char* text, long start_time, long end_time, void *user_data);
98
99 int stt_client_new(stt_h* stt);
100
101 int stt_client_destroy(stt_h stt);
102
103 stt_client_s* stt_client_get(stt_h stt);
104
105 stt_client_s* stt_client_get_by_uid(const int uid);
106
107 int stt_client_get_size();
108
109 int stt_client_use_callback(stt_client_s* client);
110
111 int stt_client_not_use_callback(stt_client_s* client);
112
113 int stt_client_get_use_callback(stt_client_s* client);
114
115 GList* stt_client_get_client_list();
116
117 #ifdef __cplusplus
118 }
119 #endif
120
121 #endif /* __STT_CLIENT_H_ */