• 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 OHOS_DISTRIBUTED_AUDIO_COMMON_DFX_UTILS_INCLUDE_DAUDIO_RADAR_H
17 #define OHOS_DISTRIBUTED_AUDIO_COMMON_DFX_UTILS_INCLUDE_DAUDIO_RADAR_H
18 
19 #include <cstdint>
20 #include <chrono>
21 #include <string>
22 #include <vector>
23 
24 #include "single_instance.h"
25 
26 namespace OHOS {
27 namespace DistributedHardware {
28 const std::string ORG_PKG_NAME = "ohos.dhardware.daudio";
29 const std::string ORG_PKG = "ORG_PKG";
30 const std::string FUNC = "FUNC";
31 const std::string BIZ_SCENE = "BIZ_SCENE";
32 const std::string BIZ_STAGE = "BIZ_STAGE";
33 const std::string STAGE_RES = "STAGE_RES";
34 const std::string BIZ_STATE = "BIZ_STATE";
35 const std::string TO_CALL_PKG = "TO_CALL_PKG";
36 const std::string HOST_PKG = "HOST_PKG";
37 const std::string ERROR_CODE = "ERROR_CODE";
38 const std::string DISTRIBUTED_AUDIO_BEHAVIOR = "DISTRIBUTED_AUDIO_BEHAVIOR";
39 constexpr char DISTRIBUTED_AUDIO[] = "DISTAUDIO";
40 
41 enum class BizScene : int32_t {
42     AUDIO_INIT = 1,
43     SPEAKER_OPEN = 2,
44     MIC_OPEN = 3,
45     SPEAKER_CLOSE = 4,
46     MIC_CLOSE = 5,
47     AUDIO_UNINIT = 6,
48 };
49 
50 enum class StageRes : int32_t {
51     STAGE_IDLE = 0,
52     STAGE_SUCC = 1,
53     STAGE_FAIL = 2,
54     STAGE_CANCEL = 3,
55     STAGE_UNKNOW = 4,
56 };
57 
58 enum class BizState : int32_t {
59     BIZ_STATE_START = 1,
60     BIZ_STATE_END = 2,
61 };
62 
63 enum class AudioInit : int32_t {
64     SERVICE_INIT = 1,
65     SOURCE_AUDIO_INIT = 2,
66     LOAD_HDF_DRIVER = 3,
67 };
68 
69 enum class SpeakerOpen : int32_t {
70     CREATE_STREAM = 1,
71     INIT_ENGINE = 2,
72     TRANS_CONTROL = 3,
73     TRANS_START = 4,
74     NOTIFY_HDF = 5,
75 };
76 
77 enum class MicOpen : int32_t {
78     CREATE_STREAM = 1,
79     INIT_ENGINE = 2,
80     TRANS_CONTROL = 3,
81     TRANS_START = 4,
82     NOTIFY_HDF = 5,
83 };
84 
85 enum class SpeakerClose : int32_t {
86     DESTROY_STREAM = 1,
87     STOP_TRANS = 2,
88     RELEASE_TRANS = 3,
89     NOTIFY_HDF = 4,
90 };
91 
92 enum class MicClose : int32_t {
93     DESTROY_STREAM = 1,
94     STOP_TRANS = 2,
95     RELEASE_TRANS = 3,
96     NOTIFY_HDF = 4,
97 };
98 
99 enum class AudioUnInit : int32_t {
100     UNREGISTER = 1,
101     UNLOAD_HDF_DRIVER = 2,
102     DISABLED = 3,
103 };
104 
105 class DaudioRadar {
106     DECLARE_SINGLE_INSTANCE(DaudioRadar);
107 public:
108     bool ReportDaudioInit(const std::string& func, AudioInit bizStage, BizState bizState, int32_t errCode);
109     bool ReportDaudioInitProgress(const std::string& func, AudioInit bizStage, int32_t errCode);
110     bool ReportSpeakerOpen(const std::string& func, SpeakerOpen bizStage, BizState bizState, int32_t errCode);
111     bool ReportSpeakerOpenProgress(const std::string& func, SpeakerOpen bizStage, int32_t errCode);
112     bool ReportSpeakerClose(const std::string& func, SpeakerClose bizStage, BizState bizState, int32_t errCode);
113     bool ReportSpeakerCloseProgress(const std::string& func, SpeakerClose bizStage, int32_t errCode);
114     bool ReportMicOpen(const std::string& func, MicOpen bizStage, BizState bizState, int32_t errCode);
115     bool ReportMicOpenProgress(const std::string& func, MicOpen bizStage, int32_t errCode);
116     bool ReportMicClose(const std::string& func, MicClose bizStage, BizState bizState, int32_t errCode);
117     bool ReportMicCloseProgress(const std::string& func, MicClose bizStage, int32_t errCode);
118     bool ReportDaudioUnInit(const std::string& func, AudioUnInit bizStage, BizState bizState, int32_t errCode);
119     bool ReportDaudioUnInitProgress(const std::string& func, AudioUnInit bizStage, int32_t errCode);
120 };
121 } // namespace DistributedHardware
122 } // namespace OHOS
123 #endif // OHOS_DISTRIBUTED_AUDIO_COMMON_DFX_UTILS_INCLUDE_DAUDIO_RADAR_H