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>
28 #include <media/sound_manager.h>
29 #include <mm_sound_private.h>
34 #define VOICE_CALL_SND_RINGTONE_PATH_LEN 256 /**<Max File length for Ringtone */
36 #define VOICE_CALL_SND_RINGTONE_VOL_MAX 15
39 * This enum defines the sound actions with respect to the sound conflict notifications
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;
53 * This enumeration defines names of the on call audio status
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 */
61 } 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_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;
75 * This enumeration defines volume alert type
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;
84 * This enumeration defines volume level to be used
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;
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;
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;
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;
117 typedef enum __voicecall_snd_mm_path_type_t {
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 */
127 } voicecall_snd_mm_path_type_t;
129 typedef enum __voicecall_snd_cm_status {
131 VOICE_CALL_SND_VIDEOCALL,
132 VOICE_CALL_SND_OTHER,
134 } voicecall_snd_cm_status_type_t;
136 typedef void (*voicecall_snd_callback) (gpointer pdata);
139 * This enum defines sound managers components
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*/
147 gboolean bsound_cm_state;
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*/
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;
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 */
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*/
176 voicecall_snd_mm_path_type_t current_path_type;
178 int mmfsoundplay_handle;
179 int mmfalternateplay_handle;
181 int settings_sound_status;
182 int settings_vib_status;
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 */
187 voicecall_snd_status_t effect_tone_status;
188 } voicecall_snd_mgr_t;
191 * This function initializes the sound functionalties required by the Application
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
197 gboolean voicecall_snd_init(void *pcall_core, voicecall_snd_mgr_t **papp_snd);
200 * This function stops the sound alert
203 * @param[in] papp_snd Handle to Sound Manager
205 void voicecall_snd_stop_alert(voicecall_snd_mgr_t *papp_snd);
208 * This function mutes the sound play
210 * @return TRUE - Success, FALSE - Otherwise
211 * @param[in] papp_snd Handle to Sound Manager
213 gboolean voicecall_snd_mute_alert(voicecall_snd_mgr_t *papp_snd);
216 * This function stops the alternate sound play
219 * @param[in] papp_snd Handle to Sound Manager
221 void voicecall_snd_stop_altenate_sound(voicecall_snd_mgr_t *papp_snd);
224 * This function plays call sound
226 * @return Returns TRUE on success or FALSE on failure
227 * @param[in] papp_snd Handle to Sound Manager
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);
234 * This function stops the sound alert
237 * @param[in] papp_snd Handle to Sound Manager
239 void voicecall_snd_stop_signal(voicecall_snd_mgr_t *papp_snd);
242 * This function sets the end signal of the given end cause type
245 * @param[in] papp_snd Handle to Sound Manager
246 * @param[in] end_cause_type Type of the end cause
248 void voicecall_snd_set_signal_type(voicecall_snd_mgr_t *papp_snd, voicecall_snd_signal_type_t signal_type);
251 * This function plays the effect tone accordign to the given effect type
254 * @param[in] papp_snd Handle to Sound Manager
255 * @param[in] effect_type Type of effect tone to be played
257 gboolean voicecall_snd_play_effect_tone(voicecall_snd_mgr_t *papp_snd, int effect_type);
260 * This function stops the effect tone play
263 * @param[in] papp_snd Handle to Sound Manager
265 void voicecall_snd_stop_effect_tone(voicecall_snd_mgr_t *papp_snd);
268 * This function changes the mm sound path according to the current status
271 * @param[in] papp_snd Handle to Sound Manager
273 void voicecall_snd_change_mm_path(voicecall_snd_mgr_t *papp_snd);
276 * This function changes the sound path according to the current status
279 * @param[in] papp_snd Handle to Sound Manager
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);
284 void voicecall_snd_change_modem_path(voicecall_snd_mgr_t *papp_snd);
287 * This function sets the status of the given call audio type
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
294 void voicecall_snd_set_path_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_path_t path);
296 voicecall_snd_path_t voicecall_snd_get_path_status(voicecall_snd_mgr_t *papp_snd);
299 * This function sets the volume level for the given volume alert type
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
306 void voicecall_snd_set_volume(voicecall_snd_mgr_t *papp_snd, voicecall_snd_volume_alert_type_t vol_alert_type, int volume_level);
309 * This function retreives the volume according to the given volume alert type
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
315 int voicecall_snd_get_volume(voicecall_snd_mgr_t *papp_snd, voicecall_snd_volume_alert_type_t vol_alert_type);
318 * This function retreives the volume according to the given volume alert type
320 * @return return TRUE if alternate playing
321 * @param[in] papp_snd Handle to Sound Manager
323 gboolean voicecall_snd_get_alternate_play(voicecall_snd_mgr_t *papp_snd);
326 * This function registers the application with the sound conflict manager
329 * @param[in] papp_snd Handle to Sound Manager
331 void voicecall_snd_register_cm(voicecall_snd_mgr_t *papp_snd);
334 * This function unregisters the application from the sound conflict manager
337 * @param[in] papp_snd Handle to Sound Manager
339 void voicecall_snd_unregister_cm(voicecall_snd_mgr_t *papp_snd);
342 * This function sets the status of the given call audio type
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
349 void voicecall_snd_set_status(voicecall_snd_mgr_t *papp_snd, voicecall_snd_audio_type_t snd_audio_type, gboolean status);
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);
354 void voicecall_snd_set_to_defaults(voicecall_snd_mgr_t *papp_snd);
356 gboolean voicecall_snd_is_effect_playing(voicecall_snd_mgr_t *papp_snd);