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