• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef TELEPHONY_AUDIO_BASE_H
17 #define TELEPHONY_AUDIO_BASE_H
18 
19 #include <cstdint>
20 #include <mutex>
21 
22 namespace OHOS {
23 namespace Telephony {
24 enum AudioEvent {
25     UNKNOWN_EVENT = 0,
26     // audio focus event
27     AUDIO_ACTIVATED,
28     AUDIO_RINGING,
29     AUDIO_DEACTIVATED,
30     // call state event
31     SWITCH_CS_CALL_STATE,
32     SWITCH_IMS_CALL_STATE,
33     SWITCH_OTT_CALL_STATE,
34     SWITCH_ALERTING_STATE,
35     SWITCH_INCOMING_STATE,
36     SWITCH_HOLDING_STATE,
37     SWITCH_AUDIO_INACTIVE_STATE,
38     NEW_ACTIVE_CS_CALL,
39     NEW_ACTIVE_IMS_CALL,
40     NEW_ACTIVE_OTT_CALL,
41     NEW_ALERTING_CALL,
42     NEW_INCOMING_CALL,
43     NO_MORE_ACTIVE_CALL,
44     NO_MORE_ALERTING_CALL,
45     NO_MORE_INCOMING_CALL,
46     CALL_TYPE_CS_CHANGE_IMS,
47     CALL_TYPE_IMS_CHANGE_CS,
48     // audio device event
49     ENABLE_DEVICE_EARPIECE,
50     ENABLE_DEVICE_SPEAKER,
51     ENABLE_DEVICE_WIRED_HEADSET,
52     ENABLE_DEVICE_BLUETOOTH,
53     WIRED_HEADSET_CONNECTED,
54     WIRED_HEADSET_DISCONNECTED,
55     BLUETOOTH_SCO_CONNECTED,
56     BLUETOOTH_SCO_DISCONNECTED,
57     INIT_AUDIO_DEVICE
58 };
59 
60 class AudioBase {
61 public:
AudioBase()62     AudioBase() {}
~AudioBase()63     virtual ~AudioBase() {}
64     // handle audio events in current state
65     virtual bool ProcessEvent(int32_t event) = 0;
66 
67 protected:
68     std::mutex mutex_;
69 };
70 } // namespace Telephony
71 } // namespace OHOS
72 #endif // TELEPHONY_AUDIO_BASE_H