1 /* 2 * Copyright (c) 2022 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 OHOS_DISTRIBUTED_AUDIO_HIDUMPER_H 17 #define OHOS_DISTRIBUTED_AUDIO_HIDUMPER_H 18 19 #include <string> 20 #include <vector> 21 #include "sys/stat.h" 22 23 #include <v1_0/iaudio_manager.h> 24 #include <v1_0/audio_types.h> 25 #include "daudio_handler.h" 26 #include "single_instance.h" 27 28 using OHOS::HDI::DistributedAudio::Audio::V1_0::IAudioManager; 29 using OHOS::HDI::DistributedAudio::Audio::V1_0::AudioAdapterDescriptor; 30 31 namespace OHOS { 32 namespace DistributedHardware { 33 enum class HidumpFlag { 34 UNKNOWN = 0, 35 GET_HELP, 36 GET_SOURCE_DEVID, 37 GET_SINK_INFO, 38 GET_ABILITY, 39 DUMP_AUDIO_DATA_START, 40 DUMP_AUDIO_DATA_STOP, 41 }; 42 class DaudioHidumper { 43 DECLARE_SINGLE_INSTANCE_BASE(DaudioHidumper); 44 45 public: 46 bool Dump(const std::vector<std::string> &args, std::string &result); 47 bool QueryDumpDataFlag(); 48 DaudioHidumper(); 49 ~DaudioHidumper(); 50 51 private: 52 void ShowHelp(std::string &result); 53 int32_t ShowIllegalInfomation(std::string &result); 54 int32_t ProcessDump(const std::string &args, std::string &result); 55 56 int32_t GetSourceDevId(std::string &result); 57 int32_t GetSinkInfo(std::string &result); 58 int32_t GetAbilityInfo(std::string &result); 59 int32_t StartDumpData(std::string &result); 60 int32_t StopDumpData(std::string &result); 61 62 private: 63 sptr<IAudioManager> audioManager_ = nullptr; 64 std::vector<AudioAdapterDescriptor> adapterdesc_; 65 bool dumpAudioDataFlag_ = false; 66 const std::string DEFAULT_SPK_DHID = "1"; 67 const std::string DEFAULT_MIC_DHID = "134217729"; 68 }; 69 } // namespace DistributedHardware 70 } // namespace OHOS 71 #endif // OHOS_DISTRIBUTED_AUDIO_HIDUMPER_H