• 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_AUDIO_RENDERER_DFX_COLLECTOR_H
17 #define ST_AUDIO_RENDERER_DFX_COLLECTOR_H
18 
19 #include <map>
20 
21 #include "dfx_collector.h"
22 #include "audio_info.h"
23 
24 namespace OHOS {
25 namespace AudioStandard {
26 
27 struct PlayStat {
28     int64_t frameCnt{};
29     int64_t muteFrameCnt{};
30     int64_t playDuration{};
31     uint32_t underFlowCnt{};
32 };
33 
34 class AudioRenderDfxCollector : public DfxCollector<RenderDfxInfo> {
35 public:
36     void FlushDfxMsg(uint32_t index, int32_t appUid) override;
37 };
38 
39 class RenderDfxBuilder {
40 public:
41     RenderDfxBuilder& WriteActionMsg(uint32_t dfxIndex, RendererStage stage);
42     RenderDfxBuilder& WriteInfoMsg(int64_t sourceDuration, const AudioRendererInfo &rendererInfo);
43     RenderDfxBuilder& WriteStatMsg(const AudioProcessConfig &processConfig, const PlayStat &playStat);
44     RenderDfxInfo GetResult();
45 private:
46     RenderDfxInfo dfxInfo_{};
47 };
48 
49 } // namespace AudioStandard
50 } // namespace OHOS
51 
52 #endif // ST_AUDIO_RENDERER_DFX_COLLECTOR_H