1 /* 2 * Copyright (C) 2023 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 AVCODEC_SYSEVENT_H 17 #define AVCODEC_SYSEVENT_H 18 19 #include <string> 20 #include "nocopyable.h" 21 #include "hisysevent.h" 22 23 namespace OHOS { 24 namespace MediaAVCodec { 25 enum class FaultType : int32_t { 26 FAULT_TYPE_INVALID = -1, 27 FAULT_TYPE_FREEZE = 0, 28 FAULT_TYPE_CRASH = 1, 29 FAULT_TYPE_INNER_ERROR = 2, 30 }; 31 32 struct SubAbilityCount { 33 uint32_t codecCount = 0; 34 uint32_t muxerCount = 0; 35 uint32_t sourceCount = 0; 36 uint32_t demuxerCount = 0; 37 uint32_t codeclistCount = 0; 38 }; 39 40 struct CodecDfxInfo { 41 int32_t clientPid; 42 int32_t clientUid; 43 int32_t codecInstanceId; 44 std::string codecName; 45 std::string codecIsVendor; 46 std::string codecMode; 47 int64_t encoderBitRate; 48 int32_t videoWidth; 49 int32_t videoHeight; 50 double videoFrameRate; 51 std::string videoPixelFormat; 52 int32_t audioChannelCount; 53 int32_t audioSampleRate; 54 }; 55 56 class __attribute__((visibility("default"))) AVCodecEvent : public NoCopyable { 57 public: 58 AVCodecEvent() = default; 59 ~AVCodecEvent() = default; 60 bool CreateMsg(const char* format, ...) __attribute__((__format__(printf, 2, 3))); 61 void FaultEventWrite(const std::string& eventName, 62 OHOS::HiviewDFX::HiSysEvent::EventType type, 63 FaultType faultType, 64 const std::string& module); 65 66 private: 67 std::string msg_; 68 }; 69 70 __attribute__((visibility("default"))) void FaultEventWrite(FaultType faultType, const std::string& msg, 71 const std::string& module); 72 __attribute__((visibility("default"))) void ServiceStartEventWrite(uint32_t useTime, const std::string& module); 73 __attribute__((visibility("default"))) void CodecStartEventWrite(CodecDfxInfo& codecDfxInfo); 74 __attribute__((visibility("default"))) void CodecStopEventWrite(uint32_t clientPid, uint32_t clientUid, 75 uint32_t codecInstanceId); 76 } // namespace MediaAVCodec 77 } // namespace OHOS 78 #endif // AVCODEC_SYSEVENT_H