• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DfxRecorderType {
36     DFX_RECORDER_TYPE_ARKTS = 0,
37     DFX_RECORDER_TYPE_NATIVE,
38     DFX_RECORDER_TYPE_OPENSL_ES,
39     DFX_RECORDER_TYPE_AV_RECORDER,
40 };
41 
42 enum DfxAppState {
43     DFX_APP_STATE_UNKNOWN = -1,
44     DFX_APP_STATE_START = 0,
45     DFX_APP_STATE_FOREGROUND = 2,
46     DFX_APP_STATE_BACKGROUND = 4,
47     DFX_APP_STATE_END = 16,
48 };
49 
50 struct DfxStatInt32 {
51     DfxStatInt32() = default;
DfxStatInt32DfxStatInt3252     DfxStatInt32(uint8_t param1, uint8_t param2, uint8_t param3, uint8_t param4)
53         : firstByte(param1), secondByte(param2), thirdByte(param3), fourthByte(param4) {}
54 
55     uint8_t firstByte{};
56     uint8_t secondByte{};
57     uint8_t thirdByte{};
58     uint8_t fourthByte{};
59 };
60 
61 struct DfxStatAction : public DfxStatInt32 {
62     DfxStatAction() = default;
63     DfxStatAction(uint8_t param1, uint8_t param2, uint8_t param3, uint8_t param4);
64 
65     uint64_t timestamp{};
66 };
67 
68 struct InterruptEffect {
69     std::string bundleName{};
70     uint8_t streamUsage{};
71     uint8_t appState{};
72     uint8_t interruptEvent{};
73 };
74 
75 struct RendererStats {
76     uint32_t samplingRate{};
77     uint64_t duration{};
78     uint32_t underrunCnt{};
79     uint16_t originalFlag{};
80     uint16_t zeroDataPercent{};
81     int64_t frameWritten{};
82 };
83 
84 struct CapturerStats {
85     uint32_t samplingRate{};
86     uint64_t duration{};
87 };
88 
89 struct RenderDfxInfo {
90     DfxStatAction rendererAction{};
91     DfxStatInt32 rendererInfo{};
92     RendererStats rendererStat{};
93 };
94 
95 struct CapturerDfxInfo {
96     DfxStatAction capturerAction{};
97     DfxStatInt32 capturerInfo{};
98     CapturerStats capturerStat{};
99 };
100 
101 struct InterruptDfxInfo {
102     DfxStatAction interruptAction;
103     DfxStatInt32 interruptInfo;
104     std::vector<InterruptEffect> interruptEffectVec{};
105 };
106 
107 struct DfxRunningAppInfo {
108     int32_t appUid{-1};
109     std::string appName{};
110     std::string versionName{};
111     std::vector<uint8_t> appStateVec{};
112     std::vector<uint64_t> appStateTimeStampVec{};
113 };
114 
115 } // namespace AudioStandard
116 } // namespace OHOS
117 
118 #endif // ST_DFX_STAT_H