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 #ifndef HPAE_RESAMPLE_NODE_H 16 #define HPAE_RESAMPLE_NODE_H 17 #include "audio_proresampler.h" 18 #include "hpae_plugin_node.h" 19 #ifdef ENABLE_HOOK_PCM 20 #include "hpae_pcm_dumper.h" 21 #endif 22 namespace OHOS { 23 namespace AudioStandard { 24 namespace HPAE { 25 26 enum class ResamplerType { 27 PRORESAMPLER 28 }; 29 30 class HpaeResampleNode : public HpaePluginNode { 31 public: 32 HpaeResampleNode(HpaeNodeInfo& nodeInfo, HpaeNodeInfo& preNodeInfo, ResamplerType type); 33 HpaeResampleNode(HpaeNodeInfo& nodeInfo, HpaeNodeInfo& preNodeInfo); 34 ~HpaeResampleNode() = default; 35 virtual bool Reset() override; 36 void ConnectWithInfo(const std::shared_ptr<OutputNode<HpaePcmBuffer*>> &preNode, HpaeNodeInfo &nodeInfo) override; 37 void DisConnectWithInfo(const std::shared_ptr<OutputNode<HpaePcmBuffer*>> &preNode, 38 HpaeNodeInfo &nodeInfo) override; 39 protected: 40 HpaePcmBuffer* SignalProcess(const std::vector<HpaePcmBuffer*>& inputs) override; 41 private: 42 void ResampleProcess(float *srcData, uint32_t inputFrameLen, float *dstData, uint32_t outputFrameLen); 43 PcmBufferInfo pcmBufferInfo_; 44 HpaePcmBuffer resampleOutput_; 45 HpaeNodeInfo preNodeInfo_; 46 std::vector<float> tempOutput_; 47 #ifdef ENABLE_HOOK_PCM 48 std::unique_ptr<HpaePcmDumper> inputPcmDumper_ = nullptr; 49 std::unique_ptr<HpaePcmDumper> outputPcmDumper_ = nullptr; 50 #endif 51 std::unique_ptr<Resampler> resampler_ = nullptr; 52 }; 53 } // namespace HPAE 54 } // namespace AudioStandard 55 } // namespace OHOS 56 #endif