Review UIX-TTS API cs files
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.Tts / Interop / Interop.Tts.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 using Tizen.Uix.Tts;
21
22 /// <summary>
23 /// Partial interop class.
24 /// </summary>
25 internal static partial class Interop
26 {
27     /// <summary>
28     /// Tts interop class.
29     /// </summary>
30     internal static class Tts
31     {
32         internal static string LogTag = "Tizen.Uix.Tts";
33
34         private const int ErrorTts = -0x02F10000;
35
36         internal enum TtsError
37         {
38             None = Tizen.Internals.Errors.ErrorCode.None,                           /**< Successful */
39             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,             /**< Out of Memory */
40             IoError = Tizen.Internals.Errors.ErrorCode.IoError,                     /**< I/O error */
41             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,   /**< Invalid parameter */
42             OutOfNetwork = Tizen.Internals.Errors.ErrorCode.Networkdown,            /**< Network is down */
43             TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,                   /**< No answer from the STT service */
44             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,   /**< Permission denied */
45             NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,           /**< STT NOT supported */
46             InvalidState = ErrorTts | 0x01,                                         /**< Invalid state */
47             InvalidVoice = ErrorTts | 0x02,                                         /**< Invalid language */
48             EngineNotFound = ErrorTts | 0x03,                                       /**< No available engine  */
49             OperationFailed = ErrorTts | 0x04,                                      /**< Operation failed  */
50             AudioPolicyBlocked = ErrorTts | 0x05,                                   /**< Audio policy blocked */
51             NotSupportedFeature = ErrorTts | 0x06,                                  /**< Not supported feature of current engine*/
52             ServiceReset = ErrorTts | 0x07                                          /**< Service reset*/
53         };
54
55         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
56         internal delegate void TtsStateChangedCB(IntPtr handle, State previous, State current, IntPtr userData);
57
58         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
59         internal delegate void TtsUtteranceStartedCB(IntPtr handle, int uttId, IntPtr userData);
60
61         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
62         internal delegate void TtsUtteranceCompletedCB(IntPtr handle, int uttId, IntPtr userData);
63
64         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
65         internal delegate void TtsErrorCB(IntPtr handle, int uttId, TtsError reason, IntPtr userData);
66
67         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
68         internal delegate bool TtsSupportedVoiceCB(IntPtr handle, IntPtr language, int voiceType, IntPtr userData);
69
70         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
71         internal delegate void TtsDefaultVoiceChangedCB(IntPtr handle, IntPtr previous_language, int previous_voice_type, IntPtr current_language, int current_voice_type, IntPtr userData);
72
73         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
74         internal delegate void TtsEngineChangedCB(IntPtr handle, IntPtr engine_id, IntPtr language, int voice_type, bool need_credential, IntPtr userData);
75
76         [DllImport(Libraries.Tts, EntryPoint = "tts_create", CallingConvention = CallingConvention.Cdecl)]
77         internal static extern TtsError TtsCreate(out IntPtr handle);
78
79         [DllImport(Libraries.Tts, EntryPoint = "tts_destroy", CallingConvention = CallingConvention.Cdecl)]
80         internal static extern TtsError TtsDestroy(IntPtr handle);
81
82         [DllImport(Libraries.Tts, EntryPoint = "tts_set_mode", CallingConvention = CallingConvention.Cdecl)]
83         internal static extern TtsError TtsSetMode(IntPtr handle, Mode m);
84
85         [DllImport(Libraries.Tts, EntryPoint = "tts_get_mode", CallingConvention = CallingConvention.Cdecl)]
86         internal static extern TtsError TtsGetMode(IntPtr handle, out Mode m);
87
88         [DllImport(Libraries.Tts, EntryPoint = "tts_set_credential", CallingConvention = CallingConvention.Cdecl)]
89         internal static extern TtsError TtsSetCredential(IntPtr handle, string credential);
90
91         [DllImport(Libraries.Tts, EntryPoint = "tts_prepare", CallingConvention = CallingConvention.Cdecl)]
92         internal static extern TtsError TtsPrepare(IntPtr handle);
93
94         [DllImport(Libraries.Tts, EntryPoint = "tts_unprepare", CallingConvention = CallingConvention.Cdecl)]
95         internal static extern TtsError TtsUnprepare(IntPtr handle);
96
97         [DllImport(Libraries.Tts, EntryPoint = "tts_foreach_supported_voices", CallingConvention = CallingConvention.Cdecl)]
98         internal static extern TtsError TtsForeachSupportedVoices(IntPtr handle, TtsSupportedVoiceCB callback, IntPtr userData);
99
100         [DllImport(Libraries.Tts, EntryPoint = "tts_get_default_voice", CallingConvention = CallingConvention.Cdecl)]
101         internal static extern TtsError TtsGetDefaultVoice(IntPtr handle, out string language, out int voice_type);
102
103         [DllImport(Libraries.Tts, EntryPoint = "tts_set_private_data", CallingConvention = CallingConvention.Cdecl)]
104         internal static extern TtsError TtsSetPrivateData(IntPtr handle, string key, string data);
105
106         [DllImport(Libraries.Tts, EntryPoint = "tts_get_private_data", CallingConvention = CallingConvention.Cdecl)]
107         internal static extern TtsError TtsGetPrivateData(IntPtr handle, string key, out string data);
108
109         [DllImport(Libraries.Tts, EntryPoint = "tts_get_max_text_size", CallingConvention = CallingConvention.Cdecl)]
110         internal static extern TtsError TtsGetMaxTextSize(IntPtr handle, out uint size);
111
112         [DllImport(Libraries.Tts, EntryPoint = "tts_get_state", CallingConvention = CallingConvention.Cdecl)]
113         internal static extern TtsError TtsGetState(IntPtr handle, out State state);
114
115         [DllImport(Libraries.Tts, EntryPoint = "tts_get_speed_range", CallingConvention = CallingConvention.Cdecl)]
116         internal static extern TtsError TtsGetSpeedRange(IntPtr handle, out int min, out int normal, out int max);
117
118         [DllImport(Libraries.Tts, EntryPoint = "tts_get_error_message", CallingConvention = CallingConvention.Cdecl)]
119         internal static extern TtsError TtsGetErrorMessage(IntPtr handle, out string err_msg);
120
121         [DllImport(Libraries.Tts, EntryPoint = "tts_is_recognition_type_supported", CallingConvention = CallingConvention.Cdecl)]
122         internal static extern TtsError TtsIsRecognitionTypeSupported(IntPtr handle, string type, out bool support);
123
124         [DllImport(Libraries.Tts, EntryPoint = "tts_add_text", CallingConvention = CallingConvention.Cdecl)]
125         internal static extern TtsError TtsAddText(IntPtr handle, string text, string language, int voice_type, int speed, out int uttId);
126
127         [DllImport(Libraries.Tts, EntryPoint = "tts_play", CallingConvention = CallingConvention.Cdecl)]
128         internal static extern TtsError TtsPlay(IntPtr handle);
129
130         [DllImport(Libraries.Tts, EntryPoint = "tts_stop", CallingConvention = CallingConvention.Cdecl)]
131         internal static extern TtsError TtsStop(IntPtr handle);
132
133         [DllImport(Libraries.Tts, EntryPoint = "tts_pause", CallingConvention = CallingConvention.Cdecl)]
134         internal static extern TtsError TtsPause(IntPtr handle);
135
136         [DllImport(Libraries.Tts, EntryPoint = "tts_set_state_changed_cb", CallingConvention = CallingConvention.Cdecl)]
137         internal static extern TtsError TtsSetStateChangedCB(IntPtr handle, TtsStateChangedCB callback, IntPtr userData);
138
139         [DllImport(Libraries.Tts, EntryPoint = "tts_unset_state_changed_cb", CallingConvention = CallingConvention.Cdecl)]
140         internal static extern TtsError TtsUnsetStateChangedCB(IntPtr handle);
141
142         [DllImport(Libraries.Tts, EntryPoint = "tts_set_utterance_started_cb", CallingConvention = CallingConvention.Cdecl)]
143         internal static extern TtsError TtsSetUtteranceStartedCB(IntPtr handle, TtsUtteranceStartedCB callback, IntPtr userData);
144
145         [DllImport(Libraries.Tts, EntryPoint = "tts_unset_utterance_started_cb", CallingConvention = CallingConvention.Cdecl)]
146         internal static extern TtsError TtsUnsetUtteranceStartedCB(IntPtr handle);
147
148         [DllImport(Libraries.Tts, EntryPoint = "tts_set_utterance_completed_cb", CallingConvention = CallingConvention.Cdecl)]
149         internal static extern TtsError TtsSetUtteranceCompletedCB(IntPtr handle, TtsUtteranceCompletedCB callback, IntPtr userData);
150
151         [DllImport(Libraries.Tts, EntryPoint = "tts_unset_utterance_completed_cb", CallingConvention = CallingConvention.Cdecl)]
152         internal static extern TtsError TtsUnsetUtteranceCompletedCB(IntPtr handle);
153
154         [DllImport(Libraries.Tts, EntryPoint = "tts_set_error_cb", CallingConvention = CallingConvention.Cdecl)]
155         internal static extern TtsError TtsSetErrorCB(IntPtr handle, TtsErrorCB callback, IntPtr userData);
156
157         [DllImport(Libraries.Tts, EntryPoint = "tts_unset_error_cb", CallingConvention = CallingConvention.Cdecl)]
158         internal static extern TtsError TtsUnsetErrorCB(IntPtr handle);
159
160         [DllImport(Libraries.Tts, EntryPoint = "tts_set_default_voice_changed_cb", CallingConvention = CallingConvention.Cdecl)]
161         internal static extern TtsError TtsSetDefaultVoiceChangedCB(IntPtr handle, TtsDefaultVoiceChangedCB callback, IntPtr userData);
162
163         [DllImport(Libraries.Tts, EntryPoint = "tts_unset_default_voice_changed_cb", CallingConvention = CallingConvention.Cdecl)]
164         internal static extern TtsError TtsUnsetDefaultVoiceChangedCB(IntPtr handle);
165
166         [DllImport(Libraries.Tts, EntryPoint = "tts_set_engine_changed_cb", CallingConvention = CallingConvention.Cdecl)]
167         internal static extern TtsError TtsSetEngineChangedCB(IntPtr handle, TtsEngineChangedCB callback, IntPtr userData);
168
169         [DllImport(Libraries.Tts, EntryPoint = "tts_unset_engine_changed_cb", CallingConvention = CallingConvention.Cdecl)]
170         internal static extern TtsError TtsUnsetEngineChangedCB(IntPtr handle);
171     }
172 }