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_REMOTE_OUTPUT_CLUSTER_H 17 #define HPAE_REMOTE_OUTPUT_CLUSTER_H 18 #include "i_hpae_output_cluster.h" 19 #include "hpae_remote_sink_output_node.h" 20 #include "hpae_audio_format_converter_node.h" 21 #include "hpae_mixer_node.h" 22 23 namespace OHOS { 24 namespace AudioStandard { 25 namespace HPAE { 26 27 HpaeProcessorType TransStreamUsageToSplitSceneType(StreamUsage streamUsage, const std::string &splitMode); 28 29 class HpaeRemoteOutputCluster : public IHpaeOutputCluster { 30 public: 31 HpaeRemoteOutputCluster(HpaeNodeInfo &nodeInfo, HpaeSinkInfo &sinkInfo); 32 virtual ~HpaeRemoteOutputCluster(); 33 void DoProcess() override; 34 bool Reset() override; 35 bool ResetAll() override; 36 void Connect(const std::shared_ptr<OutputNode<HpaePcmBuffer *>> &preNode) override; 37 void DisConnect(const std::shared_ptr<OutputNode<HpaePcmBuffer *>> &preNode) override; 38 int32_t GetConverterNodeCount() override; 39 int32_t GetPreOutNum() override; 40 int32_t GetInstance(const std::string &deviceClass, const std::string &deviceNetId) override; 41 int32_t Init(IAudioSinkAttr &attr) override; 42 int32_t DeInit() override; 43 int32_t Flush(void) override; 44 int32_t Pause(void) override; 45 int32_t ResetRender(void) override; 46 int32_t Resume(void) override; 47 int32_t Start(void) override; 48 int32_t Stop(void) override; 49 int32_t SetTimeoutStopThd(uint32_t timeoutThdMs) override; 50 const char *GetFrameData(void) override; 51 StreamManagerState GetState(void) override; 52 bool IsProcessClusterConnected(HpaeProcessorType sceneType) override; 53 int32_t UpdateAppsUid(const std::vector<int32_t> &appsUid) override; 54 private: 55 std::shared_ptr<HpaeRemoteSinkOutputNode> hpaeSinkOutputNode_ = nullptr; 56 std::unordered_map<HpaeProcessorType, std::shared_ptr<HpaeAudioFormatConverterNode>> sceneConverterMap_; 57 std::unordered_map<HpaeProcessorType, std::shared_ptr<HpaeMixerNode>> sceneMixerMap_; 58 std::unordered_map<HpaeProcessorType, uint32_t> sceneStopCountMap_; 59 uint32_t timeoutThdFrames_ = TIME_OUT_STOP_THD_DEFAULT_FRAME; 60 uint32_t frameLenMs_ = FRAME_LEN_MS_DEFAULT_MS; 61 std::set<HpaeProcessorType> connectedProcessCluster_; 62 }; 63 } // namespace HPAE 64 } // namespace AudioStandard 65 } // namespace OHOS 66 #endif 67