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