2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
18 #ifndef _VOICE_CALL_SOUND_H_
19 #define _VOICE_CALL_SOUND_H_
26 #include <mm_message.h>
27 #include <mm_player.h>
29 #include <mm_sound_private.h>
34 #define VOICE_CALL_SND_RINGTONE_PATH_LEN 256 /**<Max File length for Ringtone */
37 * This enum defines the sound actions with respect to the sound conflict notifications
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;
51 * This enumeration defines names of the on call audio status
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 */
60 } voicecall_snd_audio_type_t;
64 * This enumeration defines names of the on call sound path status
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;
77 * This enumeration defines voice recorder status
79 typedef enum __voicecall_snd_record_status_t {
83 } voicecall_snd_record_status_t;
86 * This enumeration defines volume alert type
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;
95 * This enumeration defines volume level to be used
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;
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;
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;
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;
128 typedef enum __voicecall_snd_mm_path_type_t {
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 */
139 } voicecall_snd_mm_path_type_t;
141 typedef enum __voicecall_snd_cm_status {
143 VOICE_CALL_SND_VIDEOCALL,
144 VOICE_CALL_SND_OTHER,
146 } voicecall_snd_cm_status_type_t;
148 typedef void (*voicecall_snd_callback) (gpointer pdata);
151 * This enum defines sound managers components
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*/
158 gboolean bsound_cm_state;
160 voicecall_snd_status_t ringtone_sound_status; /**< Holds a current sound play status for Ringtone player*/
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*/
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*/
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;
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 */
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*/
187 voicecall_snd_mm_path_type_t current_path_type;
189 int mmfsoundplay_handle;
190 int mmfalternateplay_handle;
192 int settings_sound_status;
193 int settings_vib_status;
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 */
198 voicecall_snd_status_t effect_tone_status;
200 #ifdef VOICE_CALL_RINGTONE_ELEVATOR
201 guint ring_elvator_timerid;
203 } voicecall_snd_mgr_t;
206 * This function initializes the sound functionalties required by the Application
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
212 gboolean voicecall_snd_init(void *pcall_core, voicecall_snd_mgr_t **papp_snd);
215 * This function stops the sound alert
218 * @param[in] papp_snd Handle to Sound Manager
220 void voicecall_snd_stop_alert(voicecall_snd_mgr_t *papp_snd);
223 * This function mutes the sound play
225 * @return TRUE - Success, FALSE - Otherwise
226 * @param[in] papp_snd Handle to Sound Manager
228 gboolean voicecall_snd_mute_alert(voicecall_snd_mgr_t *papp_snd);
231 * This function stops the alternate sound play
234 * @param[in] papp_snd Handle to Sound Manager
236 void voicecall_snd_stop_altenate_sound(voicecall_snd_mgr_t *papp_snd);
239 * This function plays call sound
241 * @return Returns TRUE on success or FALSE on failure
242 * @param[in] papp_snd Handle to Sound Manager
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);
249 * This function stops the sound alert
252 * @param[in] papp_snd Handle to Sound Manager
254 void voicecall_snd_stop_signal(voicecall_snd_mgr_t *papp_snd);
257 * This function sets the end signal of the given end cause type
260 * @param[in] papp_snd Handle to Sound Manager
261 * @param[in] end_cause_type Type of the end cause
263 void voicecall_snd_set_signal_type(voicecall_snd_mgr_t *papp_snd, voicecall_snd_signal_type_t signal_type);
266 * This function plays the effect tone accordign to the given effect type
269 * @param[in] papp_snd Handle to Sound Manager
270 * @param[in] effect_type Type of effect tone to be played
272 gboolean voicecall_snd_play_effect_tone(voicecall_snd_mgr_t *papp_snd, int effect_type);
275 * This function stops the effect tone play
278 * @param[in] papp_snd Handle to Sound Manager
280 void voicecall_snd_stop_effect_tone(voicecall_snd_mgr_t *papp_snd);
283 * This function changes the mm sound path according to the current status
286 * @param[in] papp_snd Handle to Sound Manager
288 void voicecall_snd_change_mm_path(voicecall_snd_mgr_t *papp_snd, voicecall_snd_mm_path_type_t mm_path_type);
291 * This function changes the sound path according to the current status
294 * @param[in] papp_snd Handle to Sound Manager
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);
299 void voicecall_snd_change_modem_path(voicecall_snd_mgr_t *papp_snd);
303 * This function sets the status of the given call audio type
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
310 void voicecall_snd_set_path_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_path_t path);
312 voicecall_snd_path_t voicecall_snd_get_path_status(voicecall_snd_mgr_t *papp_snd);
315 * This function sets the status of the given call audio type
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
322 void voicecall_snd_set_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_audio_type_t snd_audio_type, gboolean status);
325 * This function returns the current status of the given call audio type
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
331 gboolean voicecall_snd_get_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_audio_type_t snd_audio_type);
335 * This function sets the volume level for the given volume alert type
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
342 void voicecall_snd_set_volume(voicecall_snd_mgr_t *papp_snd, voicecall_snd_volume_alert_type_t vol_alert_type, int volume_level);
345 * This function retreives the volume according to the given volume alert type
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
351 int voicecall_snd_get_volume(voicecall_snd_mgr_t *papp_snd, voicecall_snd_volume_alert_type_t vol_alert_type);
354 * This function retreives the volume according to the given volume alert type
356 * @return return TRUE if alternate playing
357 * @param[in] papp_snd Handle to Sound Manager
359 gboolean voicecall_snd_get_alternate_play(voicecall_snd_mgr_t *papp_snd);
362 * This function registers the application with the sound conflict manager
365 * @param[in] papp_snd Handle to Sound Manager
367 void voicecall_snd_register_cm(voicecall_snd_mgr_t *papp_snd);
370 * This function unregisters the application from the sound conflict manager
373 * @param[in] papp_snd Handle to Sound Manager
375 void voicecall_snd_unregister_cm(voicecall_snd_mgr_t *papp_snd);
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);
380 void voicecall_snd_set_to_defaults(voicecall_snd_mgr_t *papp_snd);
382 gboolean voicecall_snd_is_effect_playing(voicecall_snd_mgr_t *papp_snd);