• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SOURCE_HIDUMPER_H
17 #define OHOS_DISTRIBUTED_CAMERA_SOURCE_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_REGISTERED_INFO,
32     GET_CURRENTSTATE_INFO,
33     GET_VERSION_INFO,
34 };
35 
36 typedef enum {
37     DCAMERA_STATE_INIT_DUMP = 0,
38     DCAMERA_STATE_REGIST_DUMP = 1,
39     DCAMERA_STATE_OPENED_DUMP = 2,
40     DCAMERA_STATE_CONFIG_STREAM_DUMP = 3,
41     DCAMERA_STATE_CAPTURE_DUMP = 4,
42 } DCameraState;
43 
44 struct CameraDumpInfo {
45     std::string version;
46     int32_t regNumber;
47     std::map<std::string, int32_t> curState;
48 };
49 
50 class DcameraSourceHidumper {
51 DECLARE_SINGLE_INSTANCE_BASE(DcameraSourceHidumper);
52 
53 public:
54     bool Dump(const std::vector<std::string>& args, std::string& result);
55 
56 private:
57     explicit DcameraSourceHidumper() = default;
58     ~DcameraSourceHidumper() = default;
59     void ShowHelp(std::string& result);
60     int32_t ShowIllegalInfomation(std::string& result);
61     int32_t ProcessDump(const std::string& args, std::string& result);
62     void SetSourceDumpInfo(CameraDumpInfo& camDumpInfo_);
63 
64     int32_t GetRegisteredInfo(std::string& result);
65     int32_t GetCurrentStateInfo(std::string& result);
66     int32_t GetVersionInfo(std::string& result);
67 
68 private:
69     CameraDumpInfo camDumpInfo_;
70 };
71 } // namespace DistributedHardware
72 } // namespace OHOS
73 #endif // OHOS_DISTRIBUTED_CAMERA_SOURCE_HIDUMPER_H