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_PROCESS_CLUSTER_H 17 #define HPAE_PROCESS_CLUSTER_H 18 #include "hpae_mixer_node.h" 19 #include "hpae_audio_format_converter_node.h" 20 #include "hpae_gain_node.h" 21 #include "hpae_render_effect_node.h" 22 #include "hpae_loudness_gain_node.h" 23 24 namespace OHOS { 25 namespace AudioStandard { 26 namespace HPAE { 27 class HpaeProcessCluster : public OutputNode<HpaePcmBuffer*>, public InputNode<HpaePcmBuffer*>, 28 public INodeFormatInfoCallback { 29 public: 30 HpaeProcessCluster(HpaeNodeInfo nodeInfo, HpaeSinkInfo &sinkInfo); 31 virtual ~HpaeProcessCluster(); 32 virtual void DoProcess() override; 33 virtual bool Reset() override; 34 virtual bool ResetAll() override; 35 std::shared_ptr<HpaeNode> GetSharedInstance() override; 36 OutputPort<HpaePcmBuffer *> *GetOutputPort() override; 37 void Connect(const std::shared_ptr<OutputNode<HpaePcmBuffer *>> &preNode) override; 38 void DisConnect(const std::shared_ptr<OutputNode<HpaePcmBuffer *>> &preNode) override; 39 int32_t GetGainNodeCount(); 40 int32_t GetConverterNodeCount(); 41 int32_t GetPreOutNum(); 42 int32_t AudioRendererCreate(HpaeNodeInfo &nodeInfo); 43 int32_t AudioRendererStart(HpaeNodeInfo &nodeInfo); 44 int32_t AudioRendererStop(HpaeNodeInfo &nodeInfo); 45 int32_t AudioRendererRelease(HpaeNodeInfo &nodeInfo); 46 int32_t GetNodeInputFormatInfo(uint32_t sessionId, AudioBasicFormat &basicFormat) override; 47 std::shared_ptr<HpaeGainNode> GetGainNodeById(uint32_t id) const; 48 std::shared_ptr<HpaeAudioFormatConverterNode> GetConverterNodeById(uint32_t id) const; 49 void SetConnectedFlag(bool flag); 50 bool GetConnectedFlag() const; 51 int32_t SetupAudioLimiter(); 52 int32_t SetLoudnessGain(uint32_t sessionId, float loudnessGain); 53 void DisConnectMixerNode(); 54 void InitEffectBuffer(const uint32_t sessionId); 55 private: 56 void ConnectMixerNode(); 57 void CreateGainNode(uint32_t sessionId, const HpaeNodeInfo &preNodeInfo); 58 void CreateConverterNode(uint32_t sessionId, const HpaeNodeInfo &preNodeInfo); 59 void CreateLoudnessGainNode(uint32_t sessionId, const HpaeNodeInfo &preNodeInfo); 60 std::shared_ptr<HpaeMixerNode> mixerNode_; 61 std::shared_ptr<HpaeRenderEffectNode> renderEffectNode_ = nullptr; 62 std::unordered_map<uint32_t, std::shared_ptr<HpaeAudioFormatConverterNode>> idConverterMap_; 63 std::unordered_map<uint32_t, std::shared_ptr<HpaeGainNode>> idGainMap_; 64 std::unordered_map<uint32_t, std::shared_ptr<HpaeLoudnessGainNode>> idLoudnessGainNodeMap_; 65 HpaeSinkInfo sinkInfo_; 66 bool isConnectedToOutputCluster = false; 67 }; 68 } // namespace HPAE 69 } // namespace AudioStandard 70 } // namespace OHOS 71 #endif // HPAE_PROCESS_CLUSTER_H