1 /* 2 * Copyright (c) 2022 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 MEDIA_DFX_H 17 #define MEDIA_DFX_H 18 19 #include <string> 20 #include <refbase.h> 21 #include "nocopyable.h" 22 #include "hisysevent.h" 23 24 namespace OHOS { 25 namespace Media { 26 class __attribute__((visibility("default"))) MediaEvent : public NoCopyable { 27 public: 28 MediaEvent() = default; 29 ~MediaEvent() = default; 30 bool CreateMsg(const char *format, ...) __attribute__((__format__(printf, 2, 3))); 31 void EventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type, 32 std::string module); 33 void EventWriteWithAppInfo(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type, 34 std::string module, std::string status, int32_t appUid, int32_t appPid); 35 void EventWriteBundleName(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type, 36 std::string module, std::string status, int32_t appUid, int32_t appPid, std::string bundleName); 37 private: 38 std::string msg_; 39 }; 40 41 __attribute__((visibility("default"))) void BehaviorEventWrite(std::string status, std::string module); 42 __attribute__((visibility("default"))) void BehaviorEventWriteForScreenCapture(std::string status, 43 std::string module, int32_t appUid, int32_t appPid); 44 __attribute__((visibility("default"))) void StatisticEventWriteBundleName(std::string status, 45 std::string module); 46 __attribute__((visibility("default"))) void FaultEventWrite(std::string msg, std::string module); 47 48 class __attribute__((visibility("default"))) MediaTrace : public NoCopyable { 49 public: 50 explicit MediaTrace(const std::string &funcName); 51 static void TraceBegin(const std::string &funcName, int32_t taskId); 52 static void TraceEnd(const std::string &funcName, int32_t taskId); 53 static void CounterTrace(const std::string &varName, int32_t val); 54 ~MediaTrace(); 55 private: 56 bool isSync_ = false; 57 }; 58 } // namespace Media 59 } // namespace OHOS 60 #endif // MEDIA_DFX_H