updates codes to sync with the latest 2.4 spin code
[platform/core/uifw/stt.git] / client / stt_client.h
1 /*
2 *  Copyright (c) 2011-2014 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_main.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 typedef enum {
27         STT_INTERNAL_STATE_NONE         = 0,
28         STT_INTERNAL_STATE_STARTING     = 1,
29         STT_INTERNAL_STATE_STOPING      = 2,
30         STT_INTERNAL_STATE_CANCELING    = 3
31 }stt_internal_state_e;
32
33 typedef struct {
34         /* base info */
35         stt_h   stt;
36         int     pid; 
37         int     uid;    /*<< unique id = pid + handle */
38
39         stt_recognition_result_cb       recognition_result_cb;
40         void*                           recognition_result_user_data;
41         stt_result_time_cb              result_time_cb;
42         void*                           result_time_user_data;
43
44         stt_state_changed_cb            state_changed_cb;
45         void*                           state_changed_user_data;
46         stt_error_cb                    error_cb;
47         void*                           error_user_data;
48         stt_default_language_changed_cb default_lang_changed_cb;
49         void*                           default_lang_changed_user_data;
50
51         stt_supported_engine_cb         supported_engine_cb;
52         void*                           supported_engine_user_data;
53         stt_supported_language_cb       supported_lang_cb;
54         void*                           supported_lang_user_data;
55
56         char*           current_engine_id;
57
58         /* option */
59         bool            silence_supported;
60         stt_option_silence_detection_e  silence;
61
62         /* state */
63         stt_state_e     before_state;
64         stt_state_e     current_state;
65
66         stt_internal_state_e    internal_state;
67
68         /* mutex */
69         int             cb_ref_count;
70
71         /* result data */
72         int     event;
73         char**  data_list;
74         int     data_count;
75         char*   msg;
76         
77         /* error data */
78         int     reason;
79 }stt_client_s;
80
81
82 typedef bool (*stt_time_cb)(int index, int event, const char* text, long start_time, long end_time, void *user_data);
83
84 int stt_client_new(stt_h* stt);
85
86 int stt_client_destroy(stt_h stt);
87
88 stt_client_s* stt_client_get(stt_h stt);
89
90 stt_client_s* stt_client_get_by_uid(const int uid);
91
92 int stt_client_get_size();
93
94 int stt_client_use_callback(stt_client_s* client);
95
96 int stt_client_not_use_callback(stt_client_s* client);
97
98 int stt_client_get_use_callback(stt_client_s* client);
99
100 GList* stt_client_get_client_list();
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif /* __STT_CLIENT_H_ */