Make TIZEN 2.0
[apps/home/call.git] / call-engine / include / voice-call-sound.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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 #ifndef _VOICE_CALL_SOUND_H_
19 #define _VOICE_CALL_SOUND_H_
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 #include <stdio.h>
26 #include <mm_message.h>
27 #include <mm_player.h>
28 #include <media/sound_manager.h>
29 #include <mm_sound_private.h>
30 #include <mm_types.h>
31 #include <mm_error.h>
32 #include <glib.h>
33
34 #define VOICE_CALL_SND_RINGTONE_PATH_LEN                        256     /**<Max File length for Ringtone */
35
36 #define VOICE_CALL_SND_RINGTONE_VOL_MAX                         15
37
38 /**
39  * This enum defines the sound actions with respect to the sound conflict notifications
40  */
41 typedef enum _voicecall_snd_status_t {
42         VOICE_CALL_SND_STATUS_NONE,             /**<Initial State */
43         VOICE_CALL_AND_STATUS_ALTERNATE_PLAY,   /**<Alternate Play can be done */
44         VOICE_CALL_SND_STATUS_READY,            /**<Sound Player Prepared, ready to play */
45         VOICE_CALL_SND_STATUS_PROCESSED,        /**< Intial Sound Play Started */
46         VOICE_CALL_SND_STATUS_STOP,             /**< The Sound is stopped by the application */
47         VOICE_CALL_SND_STATUS_PLAY,             /**< Specifies that the sound is currently being played */
48         VOICE_CALL_SND_STATUS_PAUSE,            /**< It specifies that the sound is currently paused */
49         VOICE_CALL_SND_STATUS_STOPPED           /**< The sound is stopeed by other application */
50 } voicecall_snd_status_t;
51
52 /**
53 * This enumeration defines names of the on call audio status
54 */
55 typedef enum _voicecall_snd_audio_type_t {
56         VOICE_CALL_AUDIO_NONE,                                  /**< none */
57         VOICE_CALL_AUDIO_SPEAKER,                       /**< System LoudSpeaker Audio */
58         VOICE_CALL_AUDIO_RECEIVER_EARJACK,                      /**< System receiver Audio */
59         VOICE_CALL_AUDIO_HEADSET,                       /**< System Headset Audio */
60         VOICE_CALL_AUDIO_MAX,
61 } voicecall_snd_audio_type_t;
62
63 /**
64 * This enumeration defines names of the on call sound path status
65 */
66 typedef enum _voicecall_snd_path_t {
67         VOICE_CALL_SND_PATH_NONE,                                       /**< none */
68         VOICE_CALL_SND_PATH_SPEAKER,                    /**< System LoudSpeaker path */
69         VOICE_CALL_SND_PATH_RECEIVER_EARJACK,                   /**< System Receiver or Earjack */
70         VOICE_CALL_SND_PATH_BT,                         /**< System BT Headset path */
71         VOICE_CALL_SND_PATH_MAX,
72 } voicecall_snd_path_t;
73
74 /**
75 * This enumeration defines volume alert type
76 */
77 typedef enum __voicecall_snd_volume_alert_type_t {
78         VOICE_CALL_VOL_TYPE_RINGTONE,
79         VOICE_CALL_VOL_TYPE_VOICE,
80         VOICE_CALL_VOL_TYPE_HEADSET
81 } voicecall_snd_volume_alert_type_t;
82
83 /**
84 * This enumeration defines volume level to be used
85 */
86 typedef enum __voicecall_snd_volume_level_t {
87         VOICE_CALL_VOL_LEVEL_1 = 1,
88         VOICE_CALL_VOL_LEVEL_2,
89         VOICE_CALL_VOL_LEVEL_3,
90         VOICE_CALL_VOL_LEVEL_4,
91         VOICE_CALL_VOL_LEVEL_5,
92         VOICE_CALL_VOL_LEVEL_6
93 } voicecall_snd_volume_level_t;
94
95 typedef enum __voicecall_snd_play_type_t {
96         VOICE_CALL_PLAY_TYPE_RINGTONE,
97         VOICE_CALL_PLAY_TYPE_SIGNAL,
98         VOICE_CALL_PLAY_TYPE_MAX
99 } voicecall_snd_play_type_t;
100
101 typedef enum __voicecall_snd_signal_type_t {
102         VOICE_CALL_SIGNAL_NONE,
103         VOICE_CALL_SIGNAL_USER_BUSY_TONE,
104         VOICE_CALL_SIGNAL_WRONG_NUMBER_TONE,
105         VOICE_CALL_SIGNAL_CALL_FAIL_TONE,
106         VOICE_CALL_SIGNAL_NW_CONGESTION_TONE,
107         VOICE_CALL_SIGNAL_MAX,
108 } voicecall_snd_signal_type_t;
109
110 typedef enum _voicecall_snd_effect_type_t {
111         VOICE_CALL_SND_EFFECT_CALL_CONNECT,
112         VOICE_CALL_SND_EFFECT_CALL_DISCONNECT,
113         VOICE_CALL_SND_EFFECT_CALL_MINUTE_MINDER,
114         VOICE_CALL_SND_EFFECT_MAX
115 } voicecall_snd_effect_type_t;
116
117 typedef enum __voicecall_snd_mm_path_type_t {
118         VOICE_CALL_MM_NONE,
119         VOICE_CALL_MM_ALERT_TONE,       /*When playing the in call alert tones like call end tone, call connected tone */
120         VOICE_CALL_MM_RING_TONE,        /*When playing the incoming call ringtone */
121         VOICE_CALL_MM_SECOND_CALL_TONE, /*When playing the second incoming call tone */
122         VOICE_CALL_MM_SIGNAL_TONE,      /*When playing the outgoing call fail signal tone */
123         VOICE_CALL_MM_VOICE,    /*During outgoing call and connected call */
124         VOICE_CALL_MM_RESET,    /*This should be used when app is closed after call */
125         VOICE_CALL_MM_MUTE_PLAY,        /*This should be used when ringtone needs to be played when mute profile is enabled */
126         VOICE_CALL_MM_MAX
127 } voicecall_snd_mm_path_type_t;
128
129 typedef enum __voicecall_snd_cm_status {
130         VOICE_CALL_SND_NONE,
131         VOICE_CALL_SND_VIDEOCALL,
132         VOICE_CALL_SND_OTHER,
133         VOICE_CALL_SND_MAX
134 } voicecall_snd_cm_status_type_t;
135
136 typedef void (*voicecall_snd_callback) (gpointer pdata);
137
138 /**
139  * This enum defines sound managers components
140  */
141 typedef struct __voicecall_snd_mgr_t {
142         MMHandleType pmm_player;                /**< Handle to MM Player */
143         sound_call_session_h psnd_session;
144         system_audio_route_t backup_route_policy;
145         int vibration_handle;                                    /**< Handle to System Vibration Module*/
146
147         gboolean bsound_cm_state;
148
149         voicecall_snd_status_t ringtone_sound_status;           /**< Holds a current sound play status for Ringtone player*/
150         voicecall_snd_path_t old_snd_path;                              /**< Holds a old sound path status*/
151         voicecall_snd_path_t current_snd_path;                          /**< Holds a current sound path status*/
152         void *pcall_core;                                       /**< Holds a pointer to the voicecall core Handle */
153         gboolean bcall_audio_status[VOICE_CALL_AUDIO_MAX];                /**< Holds of status of the #voicecall_snd_audio_type_t*/
154         gboolean bmute_status;                  /**< voice mute*/
155         gboolean bextra_volume_status;  /**< Extra volume*/
156
157         gboolean bincreasingmelody;                             /**<TRUE - Increasing Melody Activated, FALSE - Otherwise*/
158         int increment_melody_value;                             /**<specifies the current level of increasing melody*/
159         int org_ringtone_value;                         /**<specifies the current level of ringtone value*/
160         gboolean bvibration;                                    /**<TRUE - Vibration activated, FALSE -otherwise*/
161         gboolean bvibration_then_melody;                        /**<TRUE - Vibration then meldody is activated, FALSE -otherwise*/
162         gboolean balternate_play;
163         gboolean bmute_play;                                    /**<TRUE - Player created for playing the tone during mute play*/
164         int balternate_play_count;
165
166         char ring_tone[VOICE_CALL_SND_RINGTONE_PATH_LEN];                       /**< Holds the Path of the Ringtone to be played */
167         int current_playing_call_handle;                        /**< Holds the Call Handle of Currently Playing Call */
168         int incoming_call_handle;                       /**< Holds the Call Handle of Incoming Call */
169         int vibalert_onoff;                                     /**< On/Off Counter for periodic Vibration */
170
171         int pmm_signal_player;                                  /**< Handle to MM Signal Player */
172         voicecall_snd_signal_type_t signal_type;                /**< Signal Type */
173         char signal_tone[VOICE_CALL_SND_RINGTONE_PATH_LEN];                     /**< Holds the Path of the Signal tone to be played */
174         voicecall_snd_status_t signal_sound_status;             /**< Holds a current sound play status for Signal player*/
175
176         voicecall_snd_mm_path_type_t current_path_type;
177
178         int mmfsoundplay_handle;
179         int mmfalternateplay_handle;
180
181         int settings_sound_status;
182         int settings_vib_status;
183
184         voicecall_snd_callback psignal_play_end_cb;             /**< Callback called after Sound Play ends */
185         gpointer psignal_play_end_cb_data;                      /**< Sound Play end callback data */
186
187         voicecall_snd_status_t effect_tone_status;
188 } voicecall_snd_mgr_t;
189
190  /**
191  * This function initializes the sound functionalties required by the Application
192  *
193  * @return              Returns TRUE on success or FALSE on failure
194  * @param[in]           pcall_core              Handle to voicecall core
195  * @param[out]  papp_snd                        Handle to the Sound Manager
196  */
197 gboolean voicecall_snd_init(void *pcall_core, voicecall_snd_mgr_t **papp_snd);
198
199 /**
200  * This function stops the sound alert
201  *
202  * @return              void
203  * @param[in]           papp_snd                        Handle to Sound Manager
204  */
205 void voicecall_snd_stop_alert(voicecall_snd_mgr_t *papp_snd);
206
207 /**
208  * This function mutes the sound play
209  *
210  * @return              TRUE - Success, FALSE - Otherwise
211  * @param[in]   papp_snd                        Handle to Sound Manager
212  */
213 gboolean voicecall_snd_mute_alert(voicecall_snd_mgr_t *papp_snd);
214
215 /**
216  * This function stops the alternate sound play
217  *
218  * @return              void
219  * @param[in]   papp_snd                        Handle to Sound Manager
220  */
221 void voicecall_snd_stop_altenate_sound(voicecall_snd_mgr_t *papp_snd);
222
223 /**
224  * This function plays call sound
225  *
226  * @return              Returns TRUE on success or FALSE on failure
227  * @param[in]           papp_snd                        Handle to Sound Manager
228  */
229 gboolean voicecall_snd_play_signal(voicecall_snd_mgr_t *papp_snd, voicecall_snd_callback pplay_end_callback, void *pcallback_data);
230 gboolean voicecall_snd_set_play_end_callback(voicecall_snd_mgr_t *papp_snd, voicecall_snd_callback pplay_end_callback, void *pcallback_data);
231 gboolean voicecall_snd_is_signal_playing(voicecall_snd_mgr_t *papp_snd);
232
233 /**
234  * This function stops the sound alert
235  *
236  * @return              void
237  * @param[in]           papp_snd                        Handle to Sound Manager
238  */
239 void voicecall_snd_stop_signal(voicecall_snd_mgr_t *papp_snd);
240
241 /**
242  * This function sets the end signal of the given end cause type
243  *
244  * @return              void
245  * @param[in]           papp_snd                Handle to Sound Manager
246  * @param[in]           end_cause_type          Type of the end cause
247  */
248 void voicecall_snd_set_signal_type(voicecall_snd_mgr_t *papp_snd, voicecall_snd_signal_type_t signal_type);
249
250 /**
251  * This function plays the effect tone accordign to the given effect type
252  *
253  * @return              void
254  * @param[in]   papp_snd        Handle to Sound Manager
255  * @param[in]   effect_type     Type of effect tone to be played
256  */
257 gboolean voicecall_snd_play_effect_tone(voicecall_snd_mgr_t *papp_snd, int effect_type);
258
259 /**
260  * This function stops the effect tone play
261  *
262  * @return              void
263  * @param[in]   papp_snd        Handle to Sound Manager
264  */
265 void voicecall_snd_stop_effect_tone(voicecall_snd_mgr_t *papp_snd);
266
267 /**
268  * This function changes the mm sound path according to the current status
269  *
270  * @return              void
271  * @param[in]           papp_snd                        Handle to Sound Manager
272  */
273 void voicecall_snd_change_mm_path(voicecall_snd_mgr_t *papp_snd);
274
275 /**
276  * This function changes the sound path according to the current status
277  *
278  * @return              void
279  * @param[in]           papp_snd                        Handle to Sound Manager
280  */
281 void voicecall_snd_change_path(voicecall_snd_mgr_t *papp_snd);
282 void voicecall_snd_change_path_real(voicecall_snd_mgr_t *papp_snd);
283
284 void voicecall_snd_change_modem_path(voicecall_snd_mgr_t *papp_snd);
285
286 /**
287  * This function sets the status of the given call audio type
288  *
289  * @return              void
290  * @param[in]           papp_snd                Handle to Sound Manager
291  * @param[in]           snd_audio_type          Type of the Device to be changed
292  * @param[in]           status                          Status, TRUE - Enable, FALSE -Disable
293  */
294 void voicecall_snd_set_path_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_path_t path);
295
296 voicecall_snd_path_t voicecall_snd_get_path_status(voicecall_snd_mgr_t *papp_snd);
297
298 /**
299 * This function sets the volume level for the given volume alert type
300 *
301 * @return               void
302 * @param[in]    papp_snd                Handle to Sound Manager
303 * @param[in]    vol_alert_type  volume alert type #voicecall_snd_volume_alert_type_t
304 * @param[in]    volume_level    volume level to be set
305 */
306 void voicecall_snd_set_volume(voicecall_snd_mgr_t *papp_snd, voicecall_snd_volume_alert_type_t vol_alert_type, int volume_level);
307
308 /**
309  * This function retreives the volume according to the given volume alert type
310  *
311  * @return              current volume level
312  * @param[in]           papp_snd                Handle to Sound Manager
313  * @param[in]           vol_alert_type          volume alert type #voicecall_snd_volume_alert_type_t
314  */
315 int voicecall_snd_get_volume(voicecall_snd_mgr_t *papp_snd, voicecall_snd_volume_alert_type_t vol_alert_type);
316
317 /**
318  * This function retreives the volume according to the given volume alert type
319  *
320  * @return              return TRUE if alternate playing
321  * @param[in]           papp_snd                Handle to Sound Manager
322  */
323 gboolean voicecall_snd_get_alternate_play(voicecall_snd_mgr_t *papp_snd);
324
325 /**
326 * This function registers the application with the sound conflict manager
327 *
328 * @return                       void
329 * @param[in]            papp_snd                Handle to Sound Manager
330 */
331 void voicecall_snd_register_cm(voicecall_snd_mgr_t *papp_snd);
332
333 /**
334 * This function unregisters the application from the sound conflict manager
335 *
336 * @return                       void
337 * @param[in]            papp_snd                Handle to Sound Manager
338 */
339 void voicecall_snd_unregister_cm(voicecall_snd_mgr_t *papp_snd);
340
341 /**
342  * This function sets the status of the given call audio type
343  *
344  * @return              void
345  * @param[in]           papp_snd                Handle to Sound Manager
346  * @param[in]           snd_audio_type          Type of the Device to be changed
347  * @param[in]           status                          Status, TRUE - Enable, FALSE -Disable
348  */
349 void voicecall_snd_set_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_audio_type_t snd_audio_type, gboolean status);
350
351 void voicecall_snd_prepare_alert(voicecall_snd_mgr_t *papp_snd, int call_handle);
352 void voicecall_snd_play_alert(voicecall_snd_mgr_t *papp_snd);
353
354 void voicecall_snd_set_to_defaults(voicecall_snd_mgr_t *papp_snd);
355
356 gboolean voicecall_snd_is_effect_playing(voicecall_snd_mgr_t *papp_snd);
357
358 #ifdef __cplusplus
359 }
360 #endif
361
362 #endif