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_CAMERA_SINK_HIDUMPER_H
17 #define OHOS_DISTRIBUTED_CAMERA_SINK_HIDUMPER_H
18 
19 #include <map>
20 #include <string>
21 #include <vector>
22 
23 #include "single_instance.h"
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 class DCameraSourceDev;
28 enum class HidumpFlag {
29     UNKNOWN = 0,
30     GET_HELP,
31     GET_CAMERA_INFO,
32     GET_OPENED_INFO,
33     GET_VERSION_INFO,
34     START_DUMP,
35     STOP_DUMP,
36 };
37 
38 struct CameraDumpInfo {
39     std::string version;
40     int32_t camNumber;
41     std::vector<std::string> camIds;
42 };
43 
44 class DcameraSinkHidumper {
45 DECLARE_SINGLE_INSTANCE_BASE(DcameraSinkHidumper);
46 
47 public:
48     bool Dump(const std::vector<std::string>& args, std::string& result);
49 
50 private:
51     explicit DcameraSinkHidumper() = default;
52     ~DcameraSinkHidumper() = default;
53     void ShowHelp(std::string& result);
54     int32_t ShowIllegalInfomation(std::string& result);
55     int32_t ProcessDump(const std::string& args, std::string& result);
56     void SetSinkDumpInfo(CameraDumpInfo& camDumpInfo_);
57 
58     int32_t GetLocalCameraNumber(std::string& result);
59     int32_t GetOpenedCameraInfo(std::string& result);
60     int32_t GetVersionInfo(std::string& result);
61 
62 private:
63     CameraDumpInfo camDumpInfo_;
64     const int32_t DUMP_MAX_SIZE = 10 * 1024;
65 };
66 } // namespace DistributedHardware
67 } // namespace OHOS
68 #endif // OHOS_DISTRIBUTED_CAMERA_SINK_HIDUMPER_H