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