1 /* 2 * Copyright (c) 2025 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 ST_DFX_STAT_H 17 #define ST_DFX_STAT_H 18 19 #include <string> 20 #include <vector> 21 #include <chrono> 22 23 namespace OHOS { 24 namespace AudioStandard { 25 26 enum DfxPlayerType { 27 DFX_PLAYER_TYPE_TS_RENDER = 0, 28 DFX_PLAYER_TYPE_NATIVE_RENDER, 29 DFX_PLAYER_TYPE_OPENSL_ES, 30 DFX_PLAYER_TYPE_AVPLAYER, 31 DFX_PLAYER_TYPE_SOUNDPOOL, 32 DFX_PLAYER_TYPE_TONEPLAYER, 33 }; 34 35 enum DfxAppState { 36 DFX_APP_STATE_UNKNOWN = -1, 37 DFX_APP_STATE_START = 0, 38 DFX_APP_STATE_FOREGROUND = 2, 39 DFX_APP_STATE_BACKGROUND = 4, 40 DFX_APP_STATE_END = 16, 41 }; 42 43 struct DfxStatInt32 { 44 DfxStatInt32() = default; DfxStatInt32DfxStatInt3245 DfxStatInt32(uint8_t param1, uint8_t param2, uint8_t param3, uint8_t param4) 46 : firstByte(param1), secondByte(param2), thirdByte(param3), fourthByte(param4) {} 47 48 uint8_t firstByte{}; 49 uint8_t secondByte{}; 50 uint8_t thirdByte{}; 51 uint8_t fourthByte{}; 52 }; 53 54 struct DfxStatAction : public DfxStatInt32 { 55 DfxStatAction() = default; 56 DfxStatAction(uint8_t param1, uint8_t param2, uint8_t param3, uint8_t param4); 57 58 time_t timestamp{}; 59 }; 60 61 struct InterruptEffect { 62 std::string bundleName{}; 63 uint8_t streamUsage{}; 64 uint8_t appState{}; 65 uint8_t interruptEvent{}; 66 }; 67 68 struct RendererStats { 69 uint16_t samplingRate{}; 70 uint64_t duration{}; 71 uint16_t underrunCnt{}; 72 uint16_t originalFlag{}; 73 uint16_t zeroDataPercent{}; 74 }; 75 76 struct CapturerStats { 77 uint16_t samplingRate{}; 78 uint64_t duration{}; 79 }; 80 81 struct RenderDfxInfo { 82 DfxStatAction rendererAction{}; 83 DfxStatInt32 rendererInfo{}; 84 RendererStats rendererStat{}; 85 }; 86 87 struct CapturerDfxInfo { 88 DfxStatAction capturerAction{}; 89 DfxStatInt32 capturerInfo{}; 90 CapturerStats capturerStat{}; 91 }; 92 93 struct InterruptDfxInfo { 94 DfxStatAction interruptAction; 95 DfxStatInt32 interruptInfo; 96 std::vector<InterruptEffect> interruptEffectVec{}; 97 }; 98 99 struct DfxRunningAppInfo { 100 int32_t appUid{-1}; 101 std::string appName{}; 102 std::string versionName{}; 103 std::vector<uint8_t> appStateVec{}; 104 std::vector<uint64_t> appStateTimeStampVec{}; 105 }; 106 107 } // namespace AudioStandard 108 } // namespace OHOS 109 110 #endif // ST_DFX_STAT_H