Add g_steal_pointer to avoid double-free
[platform/core/uifw/tts.git] / server / ttsd_main.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 __TTSD_MAIN_H_
16 #define __TTSD_MAIN_H_
17
18 #include <stdio.h>
19 #include <stdbool.h>
20 #include <stdlib.h>
21 #include <tizen.h>
22 #include <unistd.h>
23 #include <string.h>
24 #include <glib.h>
25 #include <dlog.h>
26 #include <errno.h>
27
28 #include "ttse.h"
29 #include "tts_defs.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /* for debug message */
36 #define ENGINE_AGENT_DEBUG
37
38 typedef enum {
39         TTSD_ERROR_NONE                         = TIZEN_ERROR_NONE,             /**< Successful */
40         TTSD_ERROR_OUT_OF_MEMORY                = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
41         TTSD_ERROR_IO_ERROR                     = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
42         TTSD_ERROR_INVALID_PARAMETER            = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
43         TTSD_ERROR_OUT_OF_NETWORK               = TIZEN_ERROR_NETWORK_DOWN,     /**< Out of network */
44         TTSD_ERROR_TIMED_OUT                    = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
45         TTSD_ERROR_PERMISSION_DENIED            = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
46         TTSD_ERROR_NOT_SUPPORTED                = TIZEN_ERROR_NOT_SUPPORTED,    /**< TTS NOT supported */
47         TTSD_ERROR_INVALID_STATE                = TIZEN_ERROR_TTS | 0x01,       /**< Invalid state */
48         TTSD_ERROR_INVALID_VOICE                = TIZEN_ERROR_TTS | 0x02,       /**< Invalid voice */
49         TTSD_ERROR_ENGINE_NOT_FOUND             = TIZEN_ERROR_TTS | 0x03,       /**< No available engine */
50         TTSD_ERROR_OPERATION_FAILED             = TIZEN_ERROR_TTS | 0x04,       /**< Operation failed */
51         TTSD_ERROR_AUDIO_POLICY_BLOCKED         = TIZEN_ERROR_TTS | 0x05,       /**< Audio policy blocked */
52         TTSD_ERROR_NOT_SUPPORTED_FEATURE        = TIZEN_ERROR_TTS | 0x06,       /**< Not supported feature of current engine*/
53         TTSD_ERROR_SERVICE_RESET                = TIZEN_ERROR_TTS | 0x07        /**< Service reset */
54 } ttsd_error_e;
55
56 typedef enum {
57         TTSD_MODE_DEFAULT = 0,          /**< Default mode for normal application */
58         TTSD_MODE_NOTIFICATION,         /**< Notification mode */
59         TTSD_MODE_SCREEN_READER,                /**< Screen reader mode */
60         TTSD_MODE_INTERRUPT                     /**< Interrupt mode */
61 } ttsd_mode_e;
62
63 typedef enum {
64         TTSD_PLAYING_MODE_BY_SERVICE = 0, /**< Mode for TTS playing on TTS service */
65         TTSD_PLAYING_MODE_BY_CLIENT = 1, /**< Mode for TTS playing on TTS client */
66 } ttsd_playing_mode_e;
67
68 typedef enum {
69         TTSD_INTERRUPTED_PAUSED = 0,    /**< Current state change 'Pause' */
70         TTSD_INTERRUPTED_STOPPED        /**< Current state change 'Ready' */
71 } ttsd_interrupted_code_e;
72
73 typedef enum {
74         TTSD_STATE_INVALID = -1,
75         TTSD_STATE_READY = 0, /**< 'Idle' state */
76         TTSD_STATE_SYNTHESIZING = 1, /**< 'Synthesizing' state */
77         TTSD_STATE_PLAYING = 2 /**< 'Playing' state */
78 } ttsd_state_e;
79
80 typedef struct {
81         char* engine_id;
82         char* engine_name;
83         char* ug_name;
84 } engine_s;
85
86 typedef struct {
87         char* language;
88         char* ptts_id;
89         int type;
90 } voice_s;
91
92 typedef struct {
93         int version;
94
95         ttse_get_info_cb                        get_info;
96
97         ttse_initialize_cb                      initialize;
98         ttse_deinitialize_cb                    deinitialize;
99
100         ttse_foreach_supported_voices_cb        foreach_voices;
101         ttse_is_valid_voice_cb                  is_valid_voice;
102         ttse_set_pitch_cb                       set_pitch;
103         ttse_set_personal_tts_id                set_personal_tts_id;
104
105         ttse_load_voice_cb                      load_voice;
106         ttse_unload_voice_cb                    unload_voice;
107
108         ttse_start_synthesis_cb                 start_synth;
109         ttse_cancel_synthesis_cb                cancel_synth;
110
111         ttse_check_app_agreed_cb                check_app_agreed;
112         ttse_need_app_credential_cb             need_app_credential;
113         ttse_private_data_set_cb                private_data_set;
114         ttse_private_data_requested_cb          private_data_requested;
115         ttse_activated_mode_changed_cb          activated_mode_changed;
116 } tts_engine_callback_s;
117
118
119 /* Get log tag : default, notification, screen reader */
120 //const char* get_tag();
121 const char* tts_tag();
122
123 #ifdef __cplusplus
124 }
125 #endif
126
127 #endif  /* __TTSD_MAIN_H_ */