Merge with Tizen 2.3
[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_e;
31
32 typedef struct {
33         /* base info */
34         stt_h   stt;
35         int     pid; 
36         int     uid;    /*<< unique id = pid + handle */
37
38         stt_recognition_result_cb       recognition_result_cb;
39         void*                           recognition_result_user_data;
40         stt_result_time_cb              result_time_cb;
41         void*                           result_time_user_data;
42
43         stt_state_changed_cb            state_changed_cb;
44         void*                           state_changed_user_data;
45         stt_error_cb                    error_cb;
46         void*                           error_user_data;
47         stt_default_language_changed_cb default_lang_changed_cb;
48         void*                           default_lang_changed_user_data;
49
50         stt_supported_engine_cb         supported_engine_cb;
51         void*                           supported_engine_user_data;
52         stt_supported_language_cb       supported_lang_cb;
53         void*                           supported_lang_user_data;
54
55         char*           current_engine_id;
56
57         /* option */
58         bool            silence_supported;
59         stt_option_silence_detection_e  silence;
60
61         /* state */
62         stt_state_e     before_state;
63         stt_state_e     current_state;
64
65         stt_internal_state_e    internal_state;
66
67         /* mutex */
68         int             cb_ref_count;
69
70         /* result data */
71         int     event;
72         char**  data_list;
73         int     data_count;
74         char*   msg;
75         
76         /* error data */
77         int     reason;
78 }stt_client_s;
79
80
81 typedef bool (*stt_time_cb)(int index, int event, const char* text, long start_time, long end_time, void *user_data);
82
83 int stt_client_new(stt_h* stt);
84
85 int stt_client_destroy(stt_h stt);
86
87 stt_client_s* stt_client_get(stt_h stt);
88
89 stt_client_s* stt_client_get_by_uid(const int uid);
90
91 int stt_client_get_size();
92
93 int stt_client_use_callback(stt_client_s* client);
94
95 int stt_client_not_use_callback(stt_client_s* client);
96
97 int stt_client_get_use_callback(stt_client_s* client);
98
99 GList* stt_client_get_client_list();
100
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif /* __STT_CLIENT_H_ */