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_SOURCE_INPUT_CLUSTER_H 17 #define HPAE_SOURCE_INPUT_CLUSTER_H 18 19 #include "hpae_source_input_node.h" 20 #include "hpae_audio_format_converter_node.h" 21 namespace OHOS { 22 namespace AudioStandard { 23 namespace HPAE { 24 class HpaeSourceInputCluster : public OutputNode<HpaePcmBuffer *> { 25 public: 26 HpaeSourceInputCluster(HpaeNodeInfo &nodeInfo); 27 HpaeSourceInputCluster(std::vector<HpaeNodeInfo> &nodeInfos); 28 virtual ~HpaeSourceInputCluster(); 29 virtual void DoProcess() final; 30 virtual bool Reset() final; 31 virtual bool ResetAll() final; 32 std::shared_ptr<HpaeNode> GetSharedInstance() final; 33 std::shared_ptr<HpaeNode> GetSharedInstance(HpaeNodeInfo &nodeInfo) final; 34 OutputPort<HpaePcmBuffer*> *GetOutputPort() final; 35 OutputPort<HpaePcmBuffer*> *GetOutputPort(HpaeNodeInfo &nodeInfo, bool isDisConnect = false) final; 36 int32_t GetCapturerSourceInstance(const std::string &deviceClass, const std::string &deviceNetId, 37 const SourceType &sourceType, const std::string &sourceName); 38 int32_t CapturerSourceInit(IAudioSourceAttr &attr); 39 int32_t CapturerSourceDeInit(); 40 int32_t CapturerSourceFlush(void); 41 int32_t CapturerSourcePause(void); 42 int32_t CapturerSourceReset(void); 43 int32_t CapturerSourceResume(void); 44 int32_t CapturerSourceStart(void); 45 int32_t CapturerSourceStop(void); 46 StreamManagerState GetSourceState(void); 47 size_t GetOutputPortNum(); 48 size_t GetOutputPortNum(HpaeNodeInfo &nodeInfo); 49 HpaeSourceInputNodeType GetSourceInputNodeType(); 50 void SetSourceInputNodeType(HpaeSourceInputNodeType type); 51 void UpdateAppsUidAndSessionId(std::vector<int32_t> &appsUid, std::vector<int32_t> &sessionsId); 52 uint32_t GetCaptureId(); 53 54 // for test 55 uint32_t GetConverterNodeCount(); 56 uint32_t GetSourceInputNodeUseCount(); 57 int32_t WriteCapturerData(char *data, int32_t dataSize); 58 private: 59 HpaeNodeInfo &GetNodeInfoWithInfo(HpaeSourceBufferType &type); 60 61 std::shared_ptr<HpaeSourceInputNode> sourceInputNode_; 62 std::unordered_map<std::string, std::shared_ptr<HpaeAudioFormatConverterNode>> fmtConverterNodeMap_; 63 }; 64 } // namespace HPAE 65 } // namespace AudioStandard 66 } // namespace OHOS 67 #endif