1 /*
2  * Copyright (c) 2024 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 #ifndef AUDIO_PCM_DUMP_H
16 #define AUDIO_PCM_DUMP_H
17 
18 #include <string>
19 #include <memory>
20 #include <vector>
21 
22 namespace OHOS {
23 namespace AudioStandard {
24 
25 const std::string SET_OPEN_KEY = "OPEN";
26 const std::string SET_CLOSE_KEY = "CLOSE";
27 const std::string SET_UPLOAD_KEY = "UPLOAD";
28 const std::string GET_STATUS_KEY = "STATUS";
29 const std::string GET_TIME_KEY = "TIME";
30 const std::string GET_MEMORY_KEY = "MEMORY";
31 const std::vector<std::string> AUDIO_CACHE_STATE = {"CLOSE", "OPEN", "INIT"};
32 
33 constexpr size_t BYTE_TO_KB_SIZE = 1024;
34 
35 class AudioCacheMgr {
36 public:
37     static AudioCacheMgr &GetInstance();
38     AudioCacheMgr() = default;
39     virtual ~AudioCacheMgr() = default;
40 
41     virtual bool Init();
42     virtual bool DeInit();
43 
44     virtual void CacheData(std::string &dumpFileName, void* dataPointer, size_t dataLength) = 0;
45     virtual int32_t DumpAllMemBlock() = 0;
46     virtual void GetCachedDuration(int64_t &startTime, int64_t &endTime) = 0;
47     virtual void GetCurMemoryCondition(size_t &dataLength, size_t &bufferLength, size_t &structLength) = 0;
48     virtual bool SetDumpParameter(const std::vector<std::pair<std::string, std::string>> &params) = 0;
49     virtual bool GetDumpParameter(const std::vector<std::string> &subKeys,
50         std::vector<std::pair<std::string, std::string>> &result) = 0;
51 };
52 
53 } // namespace AudioStandard
54 } // namespace OHOS
55 #endif // AUDIO_PCM_DUMP_H