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 <sys/types.h> 21 #include "nocopyable.h" 22 #include "hisysevent.h" 23 24 namespace OHOS { 25 namespace MediaAVCodec { 26 enum class FaultType : int32_t { 27 FAULT_TYPE_INVALID = -1, 28 FAULT_TYPE_FREEZE = 0, 29 FAULT_TYPE_CRASH, 30 FAULT_TYPE_INNER_ERROR, 31 FAULT_TYPE_END, 32 }; 33 34 struct CodecDfxInfo { 35 pid_t clientPid; 36 uid_t clientUid; 37 int32_t codecInstanceId; 38 std::string codecName; 39 std::string codecIsVendor; 40 std::string codecMode; 41 int64_t encoderBitRate; 42 int32_t videoWidth; 43 int32_t videoHeight; 44 double videoFrameRate; 45 std::string videoPixelFormat; 46 int32_t audioChannelCount; 47 int32_t audioSampleRate; 48 }; 49 50 struct DemuxerFaultInfo { 51 std::string appName; 52 std::string instanceId; 53 std::string callerType; 54 int8_t sourceType; 55 std::string containerFormat; 56 std::string streamType; 57 std::string errMsg; 58 }; 59 60 struct MuxerFaultInfo { 61 std::string appName; 62 std::string instanceId; 63 std::string callerType; 64 std::string videoCodec; 65 std::string audioCodec; 66 std::string metaCodec; 67 std::string containerFormat; 68 std::string errMsg; 69 }; 70 71 struct AudioCodecFaultInfo { 72 std::string appName; 73 std::string instanceId; 74 std::string callerType; 75 std::string audioCodec; 76 std::string errMsg; 77 }; 78 79 struct VideoCodecFaultInfo { 80 std::string appName; 81 std::string instanceId; 82 std::string callerType; 83 std::string videoCodec; 84 std::string errMsg; 85 }; 86 87 struct AudioSourceFaultInfo { 88 std::string appName; 89 std::string instanceId; 90 int32_t audioSourceType; 91 std::string errMsg; 92 }; 93 94 __attribute__((visibility("default"))) void FaultEventWrite(FaultType faultType, const std::string& msg, 95 const std::string& module); 96 __attribute__((visibility("default"))) void ServiceStartEventWrite(uint32_t useTime, const std::string& module); 97 __attribute__((visibility("default"))) void CodecStartEventWrite(CodecDfxInfo& codecDfxInfo); 98 __attribute__((visibility("default"))) void CodecStopEventWrite(pid_t clientPid, uid_t clientUid, 99 int32_t codecInstanceId); 100 __attribute__((visibility("default"))) void DemuxerInitEventWrite(uint32_t downloadSize, std::string sourceType); 101 __attribute__((visibility("default"))) void FaultDemuxerEventWrite(DemuxerFaultInfo& demuxerFaultInfo); 102 __attribute__((visibility("default"))) void FaultAudioCodecEventWrite(AudioCodecFaultInfo& audioCodecFaultInfo); 103 __attribute__((visibility("default"))) void FaultVideoCodecEventWrite(VideoCodecFaultInfo& videoCodecFaultInfo); 104 __attribute__((visibility("default"))) void FaultMuxerEventWrite(MuxerFaultInfo& muxerFaultInfo); 105 __attribute__((visibility("default"))) void FaultRecordAudioEventWrite(AudioSourceFaultInfo& audioSourceFaultInfo); 106 } // namespace MediaAVCodec 107 } // namespace OHOS 108 #endif // AVCODEC_SYSEVENT_H