• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     TEX,
42 };
43 
44 struct EventErrorInfo {
45     int32_t errorCode = 0;
46     std::string errorMsg;
47 };
48 
49 struct EventInfo {
50     std::string filterName;
51     uint32_t supportedFormats = 0;
52     int32_t filterNum = 0;
53     EventDataType dataType;
54     EventErrorInfo errorInfo;
55 };
56 
57 class EventReport {
58 public:
59     IMAGE_EFFECT_EXPORT static void ReportHiSysEvent(const std::string &eventName, const EventInfo &eventInfo);
60 
61 private:
62     static void ReportRegisterCustomFilterEvent(const EventInfo &eventInfo);
63     static void ReportAddFilterEvent(const EventInfo &eventInfo);
64     static void ReportRemoveFilterEvent(const EventInfo &eventInfo);
65     static void ReportInputDataTypeEvent(const EventInfo &eventInfo);
66     static void ReportOutputDataTypeEvent(const EventInfo &eventInfo);
67     static void ReportRenderFailedEvent(const EventInfo &eventInfo);
68     static void ReportSaveImageEffectEvent(const EventInfo &eventInfo);
69     static void ReportRestoreImageEffectEvent(const EventInfo &eventInfo);
70 
71     static std::string ConvertDataType(const EventDataType &dataType);
72 
73     static std::unordered_map<std::string, void (*)(const EventInfo &eventInfo)> sysEventFuncMap_;
74     static std::unordered_map<EventDataType, std::string> sysEventDataTypeMap_;
75 };
76 } // namespace Effect
77 } // namespace Media
78 } // namespace OHOS
79 
80 #endif // IMAGE_EFFECT_EVENT_REPORT_H
81