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_AVSESSION_DUMP_HELPER_H
17 #define OHOS_AVSESSION_DUMP_HELPER_H
18 
19 #include <string>
20 
21 #include "avsession_service.h"
22 
23 namespace OHOS::AVSession {
24 class AVSessionDumper {
25     using DumpActionType = void(*)(std::string& result, const AVSessionService& sessionService);
26 public:
27     AVSessionDumper() = default;
28     ~AVSessionDumper() = default;
29     void Dump(const std::vector<std::string>& args, std::string& result, const AVSessionService& sessionService) const;
30     void SetErrorInfo(const std::string& inErrMsg);
31 
32 private:
33     void ShowHelp(std::string& result) const;
34     void ShowIllegalInfo(std::string& result) const;
35     void ProcessParameter(const std::string& arg, std::string& result, const AVSessionService& sessionService) const;
36     static void ShowMetaData(std::string& result, const AVSessionService& sessionService);
37     static void ShowSessionInfo(std::string& result, const AVSessionService& sessionService);
38     static void ShowControllerInfo(std::string& result, const AVSessionService& sessionService);
39     static void ShowErrorInfo(std::string& result, const AVSessionService& sessionService);
40     static void ShowTrustedDevicesInfo(std::string& result, const AVSessionService& sessionService);
41 
42     static std::map<std::string, AVSessionDumper::DumpActionType> funcMap_;
43     static std::map<int32_t, std::string> playBackStates_;
44     static std::map<int32_t, std::string> loopMode_;
45     static std::vector<std::string> errMessage_;
46     static std::map<int32_t, std::string> deviceTypeId_;
47 };
48 } // namespace OHOS::AVSession
49 #endif // OHOS_AVSESSION_DUMP_HELPER_H