• 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_SCENE_PROCESSOR_H
17 #define TELEPHONY_AUDIO_SCENE_PROCESSOR_H
18 
19 #include "audio_base.h"
20 
21 #include <map>
22 
23 #include "singleton.h"
24 #include "audio_proxy.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 enum CallStateType {
29     INACTIVE_STATE = 0,
30     ALERTING_STATE,
31     INCOMING_STATE,
32     CS_CALL_STATE,
33     IMS_CALL_STATE,
34     HOLDING_STATE,
35     UNKNOWN_STATE
36 };
37 
38 /**
39  * @class AudioSceneProcessor
40  * describes the available audio scenes of a call.
41  */
42 class AudioSceneProcessor : public std::enable_shared_from_this<AudioSceneProcessor> {
43     DECLARE_DELAYED_SINGLETON(AudioSceneProcessor)
44 public:
45     int32_t Init();
46     bool ProcessEvent(AudioEvent event);
47 
48 private:
49     std::mutex mutex_;
50     bool SwitchState(AudioEvent event);
51     bool SwitchState(CallStateType state);
52     bool SwitchCS();
53     bool SwitchIMS();
54     bool SwitchOTT();
55     bool SwitchAlerting();
56     bool SwitchIncoming();
57     bool SwitchHolding();
58     bool SwitchInactive();
59     bool ActivateAudioInterrupt(const AudioStandard::AudioStreamType &streamType);
60     bool DeactivateAudioInterrupt();
61     AudioStandard::AudioScene currentAudioScene_;
62     std::unique_ptr<AudioBase> currentState_;
63     using AudioSceneProcessorFunc = bool (AudioSceneProcessor::*)();
64     std::map<uint32_t, AudioSceneProcessorFunc> memberFuncMap_;
65 };
66 } // namespace Telephony
67 } // namespace OHOS
68 #endif // TELEPHONY_AUDIO_SCENE_PROCESSOR_H
69