• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014-2016 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 7
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 
38 struct audio_device;
39 struct str_parms;
40 struct stream_in;
41 struct stream_out;
42 typedef int audio_usecase_t;
43 typedef int snd_device_t;
44 
45 struct call_state {
46     int current;
47     int new;
48 };
49 
50 struct voice_session {
51     struct pcm *pcm_rx;
52     struct pcm *pcm_tx;
53     struct call_state state;
54     uint32_t vsid;
55 };
56 
57 struct voice {
58     struct voice_session session[MAX_VOICE_SESSIONS];
59     int tty_mode;
60     bool hac;
61     bool mic_mute;
62     float volume;
63     bool in_call;
64 };
65 
66 enum {
67     INCALL_REC_NONE = -1,
68     INCALL_REC_UPLINK,
69     INCALL_REC_DOWNLINK,
70     INCALL_REC_UPLINK_AND_DOWNLINK,
71 };
72 
73 int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
74 int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
75 
76 int voice_start_call(struct audio_device *adev);
77 int voice_stop_call(struct audio_device *adev);
78 int voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
79 void voice_get_parameters(struct audio_device *adev, struct str_parms *query,
80                           struct str_parms *reply);
81 void voice_init(struct audio_device *adev);
82 bool voice_is_in_call(struct audio_device *adev);
83 bool voice_is_in_call_rec_stream(struct stream_in *in);
84 int voice_set_mic_mute(struct audio_device *dev, bool state);
85 bool voice_get_mic_mute(struct audio_device *dev);
86 int voice_set_volume(struct audio_device *adev, float volume);
87 int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
88                                            struct stream_in *in);
89 int voice_check_and_set_incall_music_usecase(struct audio_device *adev,
90                                              struct stream_out *out);
91 int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
92                                             struct stream_in *in);
93 void voice_update_devices_for_all_voice_usecases(struct audio_device *adev);
94 void voice_set_sidetone(struct audio_device *adev,
95                        snd_device_t out_snd_device,
96                        bool enable);
97 bool voice_is_call_state_active(struct audio_device *adev);
98 void voice_set_device_mute_flag (struct audio_device *adev, bool state);
99 
100 #endif //VOICE_H
101