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 #include "voice-call-service.h"
19 #include "voice-call-dbus.h"
20 #include "vc-core-util.h"
21 #include "voice-call-core.h"
22 #include "voice-call-sound.h"
23 #include "voice-call-bt.h"
26 * This function on the loud speaker state
29 * @param[in] pcall_core Handle to voicecall core
31 gboolean voicecall_service_loudspeaker_on(call_vc_core_state_t *pcall_core)
33 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_core != NULL);
35 gboolean bloud_speaker = FALSE;
36 voicecall_snd_mgr_t *papp_snd = pcall_core->papp_snd;
38 int total_call_member = -1;
40 CALL_ENG_DEBUG(ENG_DEBUG, "\n");
42 voicecall_core_get_total_call_member(pcall_core->pcall_engine, &total_call_member);
43 if (total_call_member == 0) {
44 CALL_ENG_DEBUG(ENG_DEBUG, "There are not active calls hence it should not work \n");
48 /* Toggle the LoudSpeaker Status */
50 if (voicecall_snd_get_path_status(pcall_core->papp_snd) != VOICE_CALL_SND_PATH_SPEAKER) {
51 if (TRUE == _vc_bt_is_bt_connected(pcall_core) &&
52 (voicecall_snd_get_path_status(pcall_core->papp_snd) == VOICE_CALL_SND_PATH_BT)) {
53 voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_SPEAKER);
54 /* _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SWITCH_TO_PHONE, -1, NULL);*/
55 _vc_bt_request_switch_headset_path(pcall_core, FALSE);
57 voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_SPEAKER);
58 voicecall_snd_change_path(papp_snd);
61 CALL_ENG_DEBUG(ENG_DEBUG, "loudspeacker is already on.\n");
65 bloud_speaker = voicecall_snd_get_status(papp_snd, VOICE_CALL_AUDIO_SPEAKER);
66 if (bloud_speaker == FALSE) {
67 CALL_ENG_DEBUG(ENG_DEBUG, "Change to Speaker On. \n");
69 /*If current Path is Set to BT Headset, Change Path from Headset to Phone */
70 if (TRUE == _vc_bt_is_bt_connected(pcall_core)) {
71 if (TRUE == voicecall_snd_get_status(papp_snd, VOICE_CALL_AUDIO_HEADSET)) {
72 voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_HEADSET, FALSE);
73 /* _vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SWITCH_TO_PHONE, -1, NULL);*/
74 _vc_bt_request_switch_headset_path(pcall_core, FALSE);
75 voicecall_snd_change_path(papp_snd);
79 voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_SPEAKER, TRUE);
81 /* Change Audio Path according to the current status */
82 voicecall_snd_change_path(papp_snd);
85 CALL_ENG_DEBUG(ENG_DEBUG, "loudspeacker is already on.\n");
93 * This function off the loud speaker state
96 * @param[in] pcall_core Handle to voicecall core
98 gboolean voicecall_service_loudspeaker_off(call_vc_core_state_t *pcall_core)
100 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_core != NULL);
102 gboolean bloud_speaker = FALSE;
103 gboolean ret = FALSE;
104 voicecall_snd_mgr_t *papp_snd = pcall_core->papp_snd;
105 int total_call_member = -1;
106 voicecall_core_get_total_call_member(pcall_core->pcall_engine, &total_call_member);
107 if (total_call_member == 0) {
108 CALL_ENG_DEBUG(ENG_DEBUG, "There are not active calls hence it should not work \n");
112 CALL_ENG_DEBUG(ENG_DEBUG, "\n");
115 if (voicecall_snd_get_path_status(pcall_core->papp_snd) == VOICE_CALL_SND_PATH_SPEAKER) {
116 if (TRUE == _vc_bt_is_bt_connected(pcall_core)) {
117 voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_BT);
118 /*_vc_bt_send_response_to_bt(pcall_core, BT_AG_RES_SWITCH_TO_HEADSET, -1, NULL);*/
119 _vc_bt_request_switch_headset_path(pcall_core, TRUE);
121 voicecall_snd_set_path_status(pcall_core->papp_snd, VOICE_CALL_SND_PATH_RECEIVER);
122 voicecall_snd_change_path(papp_snd);
125 CALL_ENG_DEBUG(ENG_DEBUG, "loudspeacker is already on.\n");
130 /* Toggle the LoudSpeaker Status */
131 bloud_speaker = voicecall_snd_get_status(papp_snd, VOICE_CALL_AUDIO_SPEAKER);
132 if (bloud_speaker == TRUE) {
133 CALL_ENG_DEBUG(ENG_DEBUG, "Change to Speaker Off. \n");
135 voicecall_snd_set_status(papp_snd, VOICE_CALL_AUDIO_SPEAKER, FALSE);
137 /* Change Audio Path according to the current status */
138 voicecall_snd_change_path(papp_snd);
142 CALL_ENG_DEBUG(ENG_DEBUG, "loudspeacker is already off.\n");
151 * This function is mute on
154 * @param[in] pcall_core Handle to voicecall core
157 gboolean voicecall_service_mute_status_on(call_vc_core_state_t *pcall_core)
159 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_core != NULL);
161 gboolean bactive_calls = FALSE;
162 gboolean bheld_calls = FALSE;
164 voicecall_snd_mgr_t *papp_snd = pcall_core->papp_snd;
165 voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
167 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
169 voicecall_core_is_call_exists(pcall_engine, &bactive_calls, &bheld_calls);
171 if (FALSE == bactive_calls && TRUE == bheld_calls) {
172 CALL_ENG_DEBUG(ENG_DEBUG, "nothing to do.\n");
173 /*Mute button should not be handled if only held calls exists */
177 if (FALSE == papp_snd->bmute_status) {
178 CALL_ENG_DEBUG(ENG_DEBUG, "Setting Voice Audio Mute Status On. \n");
179 voicecall_core_set_audio_mute_status(pcall_engine, TRUE);
180 papp_snd->bmute_status = TRUE;
183 CALL_ENG_DEBUG(ENG_DEBUG, "mute status is already on.\n");
190 * This function is mute off
193 * @param[in] pcall_core Handle to voicecall core
195 gboolean voicecall_service_mute_status_off(call_vc_core_state_t *pcall_core)
197 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_core != NULL);
199 gboolean bactive_calls = FALSE;
200 gboolean bheld_calls = FALSE;
202 voicecall_snd_mgr_t *papp_snd = pcall_core->papp_snd;
203 voicecall_engine_t *pcall_engine = pcall_core->pcall_engine;
205 CALL_ENG_DEBUG(ENG_DEBUG, "..\n");
207 voicecall_core_is_call_exists(pcall_engine, &bactive_calls, &bheld_calls);
209 if (FALSE == bactive_calls && TRUE == bheld_calls) {
210 CALL_ENG_DEBUG(ENG_DEBUG, "nothing to do.\n");
211 /*Mute button should not be handled if only held calls exists */
215 if (TRUE == papp_snd->bmute_status) {
216 CALL_ENG_DEBUG(ENG_DEBUG, "Setting Voice Audio Mute Status Off. \n");
217 voicecall_core_set_audio_mute_status(pcall_engine, FALSE);
218 papp_snd->bmute_status = FALSE;
221 CALL_ENG_DEBUG(ENG_DEBUG, "mute status is already off.\n");
228 * This function set volume level.
230 * @return Returns TRUE on success or FALSE on failure
231 * @param[in] pcall_core Handle to voicecall core
232 * @param[in] vol_alert_type volume alert type
233 * @param[in] volume_level volume level to be set
235 gboolean voicecall_service_set_volume(call_vc_core_state_t *pcall_core, voicecall_snd_volume_alert_type_t vol_alert_type, int volume_level)
237 VOICECALL_RETURN_FALSE_IF_FAIL(pcall_core != NULL);
239 voicecall_snd_mgr_t *papp_snd = pcall_core->papp_snd;
241 voicecall_snd_set_volume(papp_snd, vol_alert_type, volume_level);