voice.h revision 8edfd66a7b1d033e65e5621d25ef3cbf1f40316e
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 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#ifndef VOICE_H 18#define VOICE_H 19 20#define BASE_SESS_IDX 0 21#define VOICE_SESS_IDX (BASE_SESS_IDX) 22 23#ifdef MULTI_VOICE_SESSION_ENABLED 24#define MAX_VOICE_SESSIONS 5 25#else 26#define MAX_VOICE_SESSIONS 1 27#endif 28 29#define BASE_CALL_STATE 1 30#define CALL_INACTIVE (BASE_CALL_STATE) 31#define CALL_ACTIVE (BASE_CALL_STATE + 1) 32 33#define VOICE_VSID 0x10C01000 34 35#define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled" 36#define AUDIO_PARAMETER_VALUE_TRUE "true" 37 38struct audio_device; 39struct str_parms; 40struct stream_in; 41struct stream_out; 42 43struct call_state { 44 int current; 45 int new; 46}; 47 48struct voice_session { 49 struct pcm *pcm_rx; 50 struct pcm *pcm_tx; 51 struct call_state state; 52 uint32_t vsid; 53}; 54 55struct voice { 56 struct voice_session session[MAX_VOICE_SESSIONS]; 57 int tty_mode; 58 bool hac; 59 bool mic_mute; 60 float volume; 61 bool voice_device_set; 62}; 63 64enum { 65 INCALL_REC_NONE = -1, 66 INCALL_REC_UPLINK, 67 INCALL_REC_DOWNLINK, 68 INCALL_REC_UPLINK_AND_DOWNLINK, 69}; 70 71int voice_start_call(struct audio_device *adev, struct stream_out *out); 72int voice_stop_call(struct audio_device *adev); 73int voice_set_parameters(struct audio_device *adev, struct str_parms *parms); 74void voice_get_parameters(struct audio_device *adev, struct str_parms *query, 75 struct str_parms *reply); 76void voice_init(struct audio_device *adev); 77bool voice_is_in_call(struct audio_device *adev); 78bool voice_is_in_call_rec_stream(struct stream_in *in); 79int voice_set_mic_mute(struct audio_device *dev, bool state); 80bool voice_get_mic_mute(struct audio_device *dev); 81int voice_set_volume(struct audio_device *adev, float volume); 82int voice_check_and_set_incall_rec_usecase(struct audio_device *adev, 83 struct stream_in *in); 84int voice_check_and_set_incall_music_usecase(struct audio_device *adev, 85 struct stream_out *out); 86int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev, 87 struct stream_in *in); 88void voice_update_devices_for_all_voice_usecases(struct audio_device *adev); 89#endif //VOICE_H 90