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 FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_IMAGE_DFX_H 17 #define FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_IMAGE_DFX_H 18 19 #include <string> 20 21 namespace OHOS { 22 namespace Media { 23 const uint16_t INNER_INTERFACE = 0; 24 const uint16_t JS_INTERFACE = 1; 25 const uint16_t C_INTERFACE = 2; 26 27 struct DecodeInfoOptions { 28 uint32_t sampleSize; 29 float rotate; 30 bool editable; 31 int32_t sourceWidth; 32 int32_t sourceHeight; 33 int32_t desireSizeWidth; 34 int32_t desireSizeHeight; 35 int32_t desireRegionWidth; 36 int32_t desireRegionHeight; 37 int32_t desireRegionX; 38 int32_t desireRegionY; 39 int32_t desirePixelFormat; 40 int32_t photoDesiredPixelFormat; 41 uint32_t index; 42 int32_t fitDensity; 43 int32_t desireColorSpace; 44 std::string mimeType; 45 uint32_t memorySize; 46 int32_t memoryType; 47 std::string imageSource; 48 uint16_t invokeType; 49 bool isIncrementalDecode = false; 50 bool isHardDecode; 51 std::string hardDecodeError; 52 std::string errorMsg; 53 std::string pluginType; 54 int32_t heifGridWidth; 55 int32_t heifGridHeight; 56 }; 57 58 class ImageEvent { 59 public: 60 ImageEvent(); 61 ~ImageEvent(); 62 std::string getInvokeType(); 63 void SetDecodeInfoOptions(const DecodeInfoOptions &options); 64 void SetDecodeErrorMsg(std::string msg); 65 void ReportDecodeFault(); 66 void ReportDecodeInfo(); SetIncrementalDecode()67 void SetIncrementalDecode() 68 { 69 options_.isIncrementalDecode = true; 70 } SetPluginType(std::string pluginType)71 void SetPluginType(std::string pluginType) 72 { 73 options_.pluginType = pluginType; 74 } SetHeifGridTileSize(int32_t heifGridWidth,int32_t heifGridHeight)75 void SetHeifGridTileSize(int32_t heifGridWidth, int32_t heifGridHeight) 76 { 77 options_.heifGridWidth = heifGridWidth; 78 options_.heifGridHeight = heifGridHeight; 79 } 80 DecodeInfoOptions &GetDecodeInfoOptions(); 81 private: 82 DecodeInfoOptions options_ = {}; 83 uint64_t startTime_; 84 }; 85 86 void ReportCreateImageSourceFault(uint32_t width, uint32_t height, std::string type, std::string message); 87 void ReportEncodeFault(uint32_t width, uint32_t height, std::string mimeType, std::string message); 88 } // namespace Media 89 } // namespace OHOS 90 #endif // FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_IMAGE_DFX_H 91