1 /*
2  * Copyright (C) 2024 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 IMAGE_EFFECT_EVENT_REPORT_H
17 #define IMAGE_EFFECT_EVENT_REPORT_H
18 
19 #include <string>
20 #include <unordered_map>
21 #include "image_effect_marco_define.h"
22 
23 namespace OHOS {
24 namespace Media {
25 namespace Effect {
26 constexpr const char* const REGISTER_CUSTOM_FILTER_STATISTIC = "REGISTER_CUSTOM_FILTER";
27 constexpr const char* const ADD_FILTER_STATISTIC = "ADD_FILTER";
28 constexpr const char* const REMOVE_FILTER_STATISTIC = "REMOVE_FILTER";
29 constexpr const char* const INPUT_DATA_TYPE_STATISTIC = "INPUT_DATA_TYPE";
30 constexpr const char* const OUTPUT_DATA_TYPE_STATISTIC = "OUTPUT_DATA_TYPE";
31 constexpr const char* const RENDER_FAILED_FAULT = "RENDER_FAILED";
32 constexpr const char* const SAVE_IMAGE_EFFECT_BEHAVIOR = "SAVE_IMAGE_EFFECT";
33 constexpr const char* const RESTORE_IMAGE_EFFECT_BEHAVIOR = "RESTORE_IMAGE_EFFECT";
34 
35 enum class EventDataType {
36     PIXEL_MAP = 0,
37     URI,
38     SURFACE,
39     SURFACE_BUFFER,
40     PICTURE
41 };
42 
43 struct EventErrorInfo {
44     int32_t errorCode = 0;
45     std::string errorMsg;
46 };
47 
48 struct EventInfo {
49     std::string filterName;
50     uint32_t supportedFormats = 0;
51     int32_t filterNum = 0;
52     EventDataType dataType;
53     EventErrorInfo errorInfo;
54 };
55 
56 class EventReport {
57 public:
58     IMAGE_EFFECT_EXPORT static void ReportHiSysEvent(const std::string &eventName, const EventInfo &eventInfo);
59 
60 private:
61     static void ReportRegisterCustomFilterEvent(const EventInfo &eventInfo);
62     static void ReportAddFilterEvent(const EventInfo &eventInfo);
63     static void ReportRemoveFilterEvent(const EventInfo &eventInfo);
64     static void ReportInputDataTypeEvent(const EventInfo &eventInfo);
65     static void ReportOutputDataTypeEvent(const EventInfo &eventInfo);
66     static void ReportRenderFailedEvent(const EventInfo &eventInfo);
67     static void ReportSaveImageEffectEvent(const EventInfo &eventInfo);
68     static void ReportRestoreImageEffectEvent(const EventInfo &eventInfo);
69 
70     static std::string ConvertDataType(const EventDataType &dataType);
71 
72     static std::unordered_map<std::string, void (*)(const EventInfo &eventInfo)> sysEventFuncMap_;
73     static std::unordered_map<EventDataType, std::string> sysEventDataTypeMap_;
74 };
75 } // namespace Effect
76 } // namespace Media
77 } // namespace OHOS
78 
79 #endif // IMAGE_EFFECT_EVENT_REPORT_H
80