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 uint32_t index; 41 int32_t fitDensity; 42 int32_t desireColorSpace; 43 std::string mimeType; 44 uint32_t memorySize; 45 int32_t memoryType; 46 std::string imageSource; 47 uint16_t invokeType; 48 bool isIncrementalDecode = false; 49 bool isHardDecode; 50 std::string hardDecodeError; 51 std::string errorMsg; 52 }; 53 54 class ImageEvent { 55 public: 56 ImageEvent(); 57 ~ImageEvent(); 58 void SetDecodeInfoOptions(const DecodeInfoOptions &options); 59 void SetDecodeErrorMsg(std::string msg); 60 void ReportDecodeFault(); 61 void ReportDecodeInfo(); SetIncrementalDecode()62 void SetIncrementalDecode() 63 { 64 options_.isIncrementalDecode = true; 65 } 66 DecodeInfoOptions &GetDecodeInfoOptions(); 67 private: 68 DecodeInfoOptions options_ = {}; 69 uint64_t startTime_; 70 }; 71 72 void ReportCreateImageSourceFault(uint32_t width, uint32_t height, std::string type, std::string message); 73 void ReportEncodeFault(uint32_t width, uint32_t height, std::string mimeType, std::string message); 74 } // namespace Media 75 } // namespace OHOS 76 #endif // FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_IMAGE_DFX_H 77