1/*
2 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
3 * Not a contribution.
4 *
5 * Copyright (C) 2013 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#ifndef VOICE_H
21#define VOICE_H
22
23#define BASE_SESS_IDX       0
24#define VOICE_SESS_IDX     (BASE_SESS_IDX)
25
26#ifdef MULTI_VOICE_SESSION_ENABLED
27#define MAX_VOICE_SESSIONS 5
28#else
29#define MAX_VOICE_SESSIONS 1
30#endif
31
32#define BASE_CALL_STATE     1
33#define CALL_INACTIVE       (BASE_CALL_STATE)
34#define CALL_ACTIVE         (BASE_CALL_STATE + 1)
35
36#define VOICE_VSID  0x10C01000
37
38#define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled"
39#define AUDIO_PARAMETER_VALUE_TRUE "true"
40
41struct audio_device;
42struct str_parms;
43struct stream_in;
44struct stream_out;
45typedef int audio_usecase_t;
46
47struct call_state {
48    int current;
49    int new;
50};
51
52struct voice_session {
53    struct pcm *pcm_rx;
54    struct pcm *pcm_tx;
55    struct call_state state;
56    uint32_t vsid;
57};
58
59struct voice {
60    struct voice_session session[MAX_VOICE_SESSIONS];
61    int tty_mode;
62    bool mic_mute;
63    float volume;
64    bool is_in_call;
65    bool in_call;
66};
67
68enum {
69    INCALL_REC_NONE = -1,
70    INCALL_REC_UPLINK,
71    INCALL_REC_DOWNLINK,
72    INCALL_REC_UPLINK_AND_DOWNLINK,
73};
74
75int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
76int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
77
78int voice_start_call(struct audio_device *adev);
79int voice_stop_call(struct audio_device *adev);
80int voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
81void voice_get_parameters(struct audio_device *adev, struct str_parms *query,
82                          struct str_parms *reply);
83void voice_init(struct audio_device *adev);
84bool voice_is_in_call(struct audio_device *adev);
85bool voice_is_in_call_rec_stream(struct stream_in *in);
86int voice_set_mic_mute(struct audio_device *dev, bool state);
87bool voice_get_mic_mute(struct audio_device *dev);
88int voice_set_volume(struct audio_device *adev, float volume);
89int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
90                                           struct stream_in *in);
91int voice_check_and_set_incall_music_usecase(struct audio_device *adev,
92                                             struct stream_out *out);
93int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
94                                            struct stream_in *in);
95void voice_update_devices_for_all_voice_usecases(struct audio_device *adev);
96#endif //VOICE_H
97