Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.Stt / Interop / Interop.Stt.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 using System;
19 using System.Runtime.InteropServices;
20
21 /// <summary>
22 /// Partial Interop Class
23 /// </summary>
24 internal static partial class Interop
25 {
26     /// <summary>
27     /// Stt Interop Class
28     /// </summary>
29     internal static class Stt
30     {
31         internal static string LogTag = "Tizen.Uix.Stt";
32
33         private const int ErrorStt = -0x02F00000;
34
35         internal enum SttError
36         {
37             None = Tizen.Internals.Errors.ErrorCode.None,                           /**< Successful */
38             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,             /**< Out of Memory */
39             IoError = Tizen.Internals.Errors.ErrorCode.IoError,                     /**< I/O error */
40             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,   /**< Invalid parameter */
41             TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,                   /**< No answer from the STT service */
42             RecorderBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy,           /**< Device or resource busy */
43             OutOfNetwork = Tizen.Internals.Errors.ErrorCode.Networkdown,            /**< Network is down */
44             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,   /**< Permission denied */
45             NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,           /**< STT NOT supported */
46             InvalidState = ErrorStt | 0x01,                                         /**< Invalid state */
47             InvalidLanguage = ErrorStt | 0x02,                                      /**< Invalid language */
48             EngineNotFound = ErrorStt | 0x03,                                       /**< No available engine  */
49             OperationFailed = ErrorStt | 0x04,                                      /**< Operation failed  */
50             NotSupportedFeature = ErrorStt | 0x05,                                  /**< Not supported feature of current engine */
51             RecordingTimedOut = ErrorStt | 0x06,                                    /**< Recording timed out */
52             NoSpeech = ErrorStt | 0x07,                                             /**< No speech while recording*/
53             InProgressToReady = ErrorStt | 0x08,                                    /**< Progress to ready is not finished*/
54             InProgressToRecording = ErrorStt | 0x09,                                /**< Progress to recording is not finished*/
55             InProgressToProcessing = ErrorStt | 0x10,                               /**< Progress to processing is not finished*/
56             ServiceReset = ErrorStt | 0x11                                          /**< Service reset*/
57         };
58
59         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
60         internal delegate bool SupportedEngineCallback(IntPtr handle, IntPtr engineId, IntPtr engineName, IntPtr userData);
61
62         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
63         internal delegate void RecognitionResultCallback(IntPtr handle, Tizen.Uix.Stt.ResultEvent e, IntPtr data, int dataCount, IntPtr msg, IntPtr userData);
64
65         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
66         internal delegate bool ResultTimeCallback(IntPtr handle, int index, Tizen.Uix.Stt.TimeEvent e, IntPtr text, IntPtr startTime, IntPtr endTime, IntPtr userData);
67
68         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
69         internal delegate void StateChangedCallback(IntPtr handle, Tizen.Uix.Stt.State previous, Tizen.Uix.Stt.State current, IntPtr userData);
70
71         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
72         internal delegate void ErrorCallback(IntPtr handle, SttError reason, IntPtr userData);
73
74         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
75         internal delegate bool SupportedLanguageCallback(IntPtr handle, IntPtr language, IntPtr userData);
76
77         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
78         internal delegate void DefaultLanguageChangedCallback(IntPtr handle, IntPtr previousLanguage, IntPtr currentLanguage, IntPtr userData);
79
80         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
81         internal delegate void EngineChangedCallback(IntPtr handle, IntPtr engineId, IntPtr language, bool supportSilence, bool needCredential, IntPtr userData);
82
83         [DllImport(Libraries.Stt, EntryPoint = "stt_create", CallingConvention = CallingConvention.Cdecl)]
84         internal static extern SttError SttCreate(out IntPtr handle);
85
86         [DllImport(Libraries.Stt, EntryPoint = "stt_destroy", CallingConvention = CallingConvention.Cdecl)]
87         internal static extern SttError SttDestroy(IntPtr handle);
88
89         [DllImport(Libraries.Stt, EntryPoint = "stt_foreach_supported_engines", CallingConvention = CallingConvention.Cdecl)]
90         internal static extern SttError SttForeEachSupportedEngines(IntPtr handle, SupportedEngineCallback callback, IntPtr userData);
91
92         [DllImport(Libraries.Stt, EntryPoint = "stt_get_engine", CallingConvention = CallingConvention.Cdecl)]
93         internal static extern SttError SttGetEngine(IntPtr handle, out string engineId);
94
95         [DllImport(Libraries.Stt, EntryPoint = "stt_set_engine", CallingConvention = CallingConvention.Cdecl)]
96         internal static extern SttError SttSetEngine(IntPtr handle, string engineId);
97
98         [DllImport(Libraries.Stt, EntryPoint = "stt_set_credential", CallingConvention = CallingConvention.Cdecl)]
99         internal static extern SttError SttSetcredential(IntPtr handle, string credential);
100
101         [DllImport(Libraries.Stt, EntryPoint = "stt_set_private_data", CallingConvention = CallingConvention.Cdecl)]
102         internal static extern SttError SttSetPrivateData(IntPtr handle, string key, string data);
103
104         [DllImport(Libraries.Stt, EntryPoint = "stt_get_private_data", CallingConvention = CallingConvention.Cdecl)]
105         internal static extern SttError SttGetPrivateData(IntPtr handle, string key, out string data);
106
107         [DllImport(Libraries.Stt, EntryPoint = "stt_prepare", CallingConvention = CallingConvention.Cdecl)]
108         internal static extern SttError SttPrepare(IntPtr handle);
109
110         [DllImport(Libraries.Stt, EntryPoint = "stt_unprepare", CallingConvention = CallingConvention.Cdecl)]
111         internal static extern SttError SttUnprepare(IntPtr handle);
112
113         [DllImport(Libraries.Stt, EntryPoint = "stt_foreach_supported_languages", CallingConvention = CallingConvention.Cdecl)]
114         internal static extern SttError SttForeachSupportedLanguages(IntPtr handle, SupportedLanguageCallback callback, IntPtr userData);
115
116         [DllImport(Libraries.Stt, EntryPoint = "stt_get_default_language", CallingConvention = CallingConvention.Cdecl)]
117         internal static extern SttError SttGetDefaultLanguage(IntPtr handle, out string language);
118
119         [DllImport(Libraries.Stt, EntryPoint = "stt_get_state", CallingConvention = CallingConvention.Cdecl)]
120         internal static extern SttError SttGetState(IntPtr handle, out Tizen.Uix.Stt.State state);
121
122         [DllImport(Libraries.Stt, EntryPoint = "stt_get_error_message", CallingConvention = CallingConvention.Cdecl)]
123         internal static extern SttError SttGetErrorMessage(IntPtr handle, out string err_msg);
124
125         [DllImport(Libraries.Stt, EntryPoint = "stt_is_recognition_type_supported", CallingConvention = CallingConvention.Cdecl)]
126         internal static extern SttError SttIsRecognitionTypeSupported(IntPtr handle, string type, out bool support);
127
128         [DllImport(Libraries.Stt, EntryPoint = "stt_set_silence_detection", CallingConvention = CallingConvention.Cdecl)]
129         internal static extern SttError SttSetSilenceDetection(IntPtr handle, Tizen.Uix.Stt.SilenceDetection type);
130
131         [DllImport(Libraries.Stt, EntryPoint = "stt_set_start_sound", CallingConvention = CallingConvention.Cdecl)]
132         internal static extern SttError SttSetStartSound(IntPtr handle, string filename);
133
134         [DllImport(Libraries.Stt, EntryPoint = "stt_unset_start_sound", CallingConvention = CallingConvention.Cdecl)]
135         internal static extern SttError SttUnsetStartSound(IntPtr handle);
136
137         [DllImport(Libraries.Stt, EntryPoint = "stt_set_stop_sound", CallingConvention = CallingConvention.Cdecl)]
138         internal static extern SttError SttSetStopSound(IntPtr handle, string filename);
139
140         [DllImport(Libraries.Stt, EntryPoint = "stt_unset_stop_sound", CallingConvention = CallingConvention.Cdecl)]
141         internal static extern SttError SttUnsetStopSound(IntPtr handle);
142
143         [DllImport(Libraries.Stt, EntryPoint = "stt_start", CallingConvention = CallingConvention.Cdecl)]
144         internal static extern SttError SttStart(IntPtr handle, string language, string type);
145
146         [DllImport(Libraries.Stt, EntryPoint = "stt_stop", CallingConvention = CallingConvention.Cdecl)]
147         internal static extern SttError SttStop(IntPtr handle);
148
149         [DllImport(Libraries.Stt, EntryPoint = "stt_cancel", CallingConvention = CallingConvention.Cdecl)]
150         internal static extern SttError SttCancel(IntPtr handle);
151
152         [DllImport(Libraries.Stt, EntryPoint = "stt_get_recording_volume", CallingConvention = CallingConvention.Cdecl)]
153         internal static extern SttError SttGetRecordingVolume(IntPtr handle, out float volume);
154
155         [DllImport(Libraries.Stt, EntryPoint = "stt_foreach_detailed_result", CallingConvention = CallingConvention.Cdecl)]
156         internal static extern SttError SttForeachDetailedResult(IntPtr handle, ResultTimeCallback callback, IntPtr userData);
157
158         [DllImport(Libraries.Stt, EntryPoint = "stt_set_recognition_result_cb", CallingConvention = CallingConvention.Cdecl)]
159         internal static extern SttError SttSetRecognitionResultCB(IntPtr handle, RecognitionResultCallback callback, IntPtr userData);
160
161         [DllImport(Libraries.Stt, EntryPoint = "stt_unset_recognition_result_cb", CallingConvention = CallingConvention.Cdecl)]
162         internal static extern SttError SttUnsetRecognitionResultCB(IntPtr handle);
163
164         [DllImport(Libraries.Stt, EntryPoint = "stt_set_state_changed_cb", CallingConvention = CallingConvention.Cdecl)]
165         internal static extern SttError SttSetStateChangedCB(IntPtr handle, StateChangedCallback callback, IntPtr userData);
166
167         [DllImport(Libraries.Stt, EntryPoint = "stt_unset_state_changed_cb", CallingConvention = CallingConvention.Cdecl)]
168         internal static extern SttError SttUnsetStateChangedCB(IntPtr handle);
169
170         [DllImport(Libraries.Stt, EntryPoint = "stt_set_error_cb", CallingConvention = CallingConvention.Cdecl)]
171         internal static extern SttError SttSetErrorCB(IntPtr handle, ErrorCallback callback, IntPtr userData);
172
173         [DllImport(Libraries.Stt, EntryPoint = "stt_unset_error_cb", CallingConvention = CallingConvention.Cdecl)]
174         internal static extern SttError SttUnsetErrorCB(IntPtr handle);
175
176         [DllImport(Libraries.Stt, EntryPoint = "stt_set_default_language_changed_cb", CallingConvention = CallingConvention.Cdecl)]
177         internal static extern SttError SttSetDefaultLanguageChangedCB(IntPtr handle, DefaultLanguageChangedCallback callback, IntPtr userData);
178
179         [DllImport(Libraries.Stt, EntryPoint = "stt_unset_default_language_changed_cb", CallingConvention = CallingConvention.Cdecl)]
180         internal static extern SttError SttUnsetDefaultLanguageChangedCB(IntPtr handle);
181
182         [DllImport(Libraries.Stt, EntryPoint = "stt_set_engine_changed_cb", CallingConvention = CallingConvention.Cdecl)]
183         internal static extern SttError SttSetEngineChangedCB(IntPtr handle, EngineChangedCallback callback, IntPtr userData);
184
185         [DllImport(Libraries.Stt, EntryPoint = "stt_unset_engine_changed_cb", CallingConvention = CallingConvention.Cdecl)]
186         internal static extern SttError SttUnsetEngineChangedCB(IntPtr handle);
187     }
188 }