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_DIALING_STATE, 35 SWITCH_ALERTING_STATE, 36 SWITCH_INCOMING_STATE, 37 SWITCH_HOLDING_STATE, 38 SWITCH_AUDIO_INACTIVE_STATE, 39 NEW_ACTIVE_CS_CALL, 40 NEW_ACTIVE_IMS_CALL, 41 NEW_ACTIVE_OTT_CALL, 42 NEW_DIALING_CALL, 43 NEW_ALERTING_CALL, 44 NEW_INCOMING_CALL, 45 NO_MORE_ACTIVE_CALL, 46 NO_MORE_DIALING_CALL, 47 NO_MORE_ALERTING_CALL, 48 NO_MORE_INCOMING_CALL, 49 CALL_TYPE_CS_CHANGE_IMS, 50 CALL_TYPE_IMS_CHANGE_CS, 51 // audio device event 52 ENABLE_DEVICE_EARPIECE, 53 ENABLE_DEVICE_SPEAKER, 54 ENABLE_DEVICE_WIRED_HEADSET, 55 ENABLE_DEVICE_BLUETOOTH, 56 WIRED_HEADSET_CONNECTED, 57 WIRED_HEADSET_DISCONNECTED, 58 BLUETOOTH_SCO_CONNECTED, 59 BLUETOOTH_SCO_DISCONNECTED, 60 INIT_AUDIO_DEVICE 61 }; 62 63 class AudioBase { 64 public: AudioBase()65 AudioBase() {} ~AudioBase()66 virtual ~AudioBase() {} 67 // handle audio events in current state 68 virtual bool ProcessEvent(int32_t event) = 0; 69 70 protected: 71 std::mutex mutex_; 72 }; 73 } // namespace Telephony 74 } // namespace OHOS 75 #endif // TELEPHONY_AUDIO_BASE_H