• 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 LOG_TAG
17 #define LOG_TAG "IHpaeRendererManager"
18 #endif
19 #include "i_hpae_renderer_manager.h"
20 #include "hpae_renderer_manager.h"
21 #include "hpae_offload_renderer_manager.h"
22 #include "hpae_inner_capturer_manager.h"
23 #include "audio_engine_log.h"
24 
25 namespace OHOS {
26 namespace AudioStandard {
27 namespace HPAE {
28 static const std::string DEVICE_CLASS_OFFLOAD = "offload";
29 static const std::string DEVICE_CLASS_REMOTE_OFFLOAD = "remote_offload";
30 static const std::string DEVICE_NAME_INNER_CAP = "InnerCapturerSink";
31 static const std::string DEVICE_NAME_CAST_INNER_CAP = "RemoteCastInnerCapturer";
CreateRendererManager(HpaeSinkInfo & sinkInfo)32 std::shared_ptr<IHpaeRendererManager> IHpaeRendererManager::CreateRendererManager(HpaeSinkInfo &sinkInfo)
33 {
34     if (sinkInfo.deviceClass == DEVICE_CLASS_OFFLOAD || sinkInfo.deviceClass == DEVICE_CLASS_REMOTE_OFFLOAD) {
35         return std::make_shared<HpaeOffloadRendererManager>(sinkInfo);
36     } else if ((sinkInfo.deviceName.compare(0, DEVICE_NAME_INNER_CAP.length(), DEVICE_NAME_INNER_CAP) == 0)
37         || sinkInfo.deviceName == DEVICE_NAME_CAST_INNER_CAP) {
38         return std::make_shared<HpaeInnerCapturerManager>(sinkInfo);
39     }
40     return std::make_shared<HpaeRendererManager>(sinkInfo);
41 }
42 
UploadDumpSinkInfo(std::string & deviceName)43 void IHpaeRendererManager::UploadDumpSinkInfo(std::string& deviceName)
44 {
45 #ifdef ENABLE_HIDUMP_DFX
46         std::string dumpStr;
47         dfxTree_.PrintTree(dumpStr);
48         TriggerCallback(DUMP_SINK_INFO, deviceName, dumpStr);
49 #endif
50 };
51 
OnNotifyDfxNodeInfo(bool isConnect,uint32_t preNodeId,HpaeDfxNodeInfo & nodeInfo)52 void IHpaeRendererManager::OnNotifyDfxNodeInfo(bool isConnect, uint32_t preNodeId, HpaeDfxNodeInfo &nodeInfo)
53 {
54 #ifdef ENABLE_HIDUMP_DFX
55     AUDIO_INFO_LOG("%{public}s preNodeId %{public}u nodeName:%{public}s, NodeId: %{public}u",
56         isConnect ? "connect" : "disconnect",
57         preNodeId,
58         nodeInfo.nodeName.c_str(),
59         nodeInfo.nodeId);
60     if (isConnect) {
61         dfxTree_.Insert(preNodeId, nodeInfo);
62     } else {
63         dfxTree_.Remove(nodeInfo.nodeId);
64     }
65 #endif
66 };
67 }  // namespace HPAE
68 }  // namespace AudioStandard
69 }  // namespace OHOS
70