• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 HPAE_RENDER_EFFECT_NODE_H
17 #define HPAE_RENDER_EFFECT_NODE_H
18 
19 #include "hpae_plugin_node.h"
20 #ifdef ENABLE_HOOK_PCM
21 #include "hpae_pcm_dumper.h"
22 #endif
23 namespace OHOS {
24 namespace AudioStandard {
25 namespace HPAE {
26 
27 enum ModifyAudioEffectChainInfoReason {
28     ADD_AUDIO_EFFECT_CHAIN_INFO = 0,
29     REMOVE_AUDIO_EFFECT_CHAIN_INFO = 1,
30 };
31 
32 class HpaeRenderEffectNode : public HpaePluginNode {
33 public:
34     HpaeRenderEffectNode(HpaeNodeInfo &nodeInfo);
35     virtual ~HpaeRenderEffectNode();
36     void DoProcess() override;
37     int32_t AudioRendererCreate(HpaeNodeInfo &nodeInfo);
38     int32_t AudioRendererStart(HpaeNodeInfo &nodeInfo);
39     int32_t AudioRendererStop(HpaeNodeInfo &nodeInfo);
40     int32_t AudioRendererRelease(HpaeNodeInfo &nodeInfo);
41     int32_t GetExpectedInputChannelInfo(AudioBasicFormat &basicFormat);
42     void InitEffectBuffer(const uint32_t sessionId);
43     void InitEffectBufferFromDisConnect();
44 protected:
45     HpaePcmBuffer* SignalProcess(const std::vector<HpaePcmBuffer*> &inputs) override;
46 private:
47     void ReconfigOutputBuffer();
48     int32_t CreateAudioEffectChain(HpaeNodeInfo &nodeInfo);
49     int32_t ReleaseAudioEffectChain(HpaeNodeInfo &nodeInfo);
50     void ModifyAudioEffectChainInfo(HpaeNodeInfo &nodeInfo, ModifyAudioEffectChainInfoReason reason);
51     void UpdateAudioEffectChainInfo(HpaeNodeInfo &nodeInfo);
52     bool IsByPassEffectZeroVolume(HpaePcmBuffer *pcmBuffer);
53     int32_t SplitCollaborativeData();
54     PcmBufferInfo pcmBufferInfo_;
55     HpaePcmBuffer effectOutput_;
56     std::unique_ptr<HpaePcmBuffer> directOutput_ = nullptr;
57     std::unique_ptr<HpaePcmBuffer> collaborativeOutput_ = nullptr;
58     std::string sceneType_ = "EFFECT_NONE";
59     int64_t silenceDataUs_ = 0;
60     bool isByPassEffect_ = false;
61     bool isDisplayEffectZeroVolume_ = false;
62 #ifdef ENABLE_HOOK_PCM
63     std::unique_ptr<HpaePcmDumper> directPcmDumper_;
64     std::unique_ptr<HpaePcmDumper> collaborativePcmDumper_;
65 #endif
66 };
67 
68 } // namespace HPAE
69 } // namespace AudioStandard
70 } // namespace OHOS
71 
72 #endif // HPAE_RENDER_EFFECT_NODE_H