• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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_OFFLINE_AUDIO_EFFECT_MANAGER_H
17 #define ST_OFFLINE_AUDIO_EFFECT_MANAGER_H
18 
19 #include <vector>
20 
21 #include "audio_info.h"
22 
23 namespace OHOS {
24 namespace AudioStandard {
25 class OfflineAudioEffectChain {
26 public:
27     /**
28      * @brief Configure the audio stream information
29      *
30      * @param inInfo Input audio stream information
31      * @param outInfo Output audio stream information
32      * @return The result of the config, 0 for success, other for error code
33      * @since 15
34      */
35     virtual int32_t Configure(const AudioStreamInfo &inInfo, const AudioStreamInfo &outInfo) = 0;
36 
37     /**
38      * @brief Set parameter for the offline audio effect chain
39      *
40      * @param param Input offline audio effect parameter
41      * @return The result of the setparam, 0 for success, other for error code
42      * @since 15
43      */
44     virtual int32_t SetParam(const std::vector<uint8_t> &param) = 0;
45 
46     /**
47      * @brief Prepare the offline audio effect chain
48      *
49      * @return The result of the preparation, 0 for success, other for error code
50      * @since 15
51      */
52     virtual int32_t Prepare() = 0;
53 
54     /**
55      * @brief Get the size of the audio effect buffer
56      *
57      * @param inBufferSize Size of the input buffer
58      * @param outBufferSize Size of the output buffer
59      * @return The result of the retrieval, 0 for success, other for error code
60      * @since 15
61      */
62     virtual int32_t GetEffectBufferSize(uint32_t &inBufferSize, uint32_t &outBufferSize) = 0;
63 
64     /**
65      * @brief Process the audio data
66      *
67      * @param inBuffer Input audio data buffer
68      * @param inSize Size of the input audio data
69      * @param outBuffer Output audio data buffer
70      * @param outSize Size of the output audio data
71      * @return The result of processing, 0 for success, other for error code
72      * @since 15
73      */
74     virtual int32_t Process(uint8_t *inBuffer, int32_t inSize, uint8_t *outBuffer, int32_t outSize) = 0;
75 
76     /**
77      * @brief Release the resources of the audio effect chain
78      *
79      * @since 15
80      */
81     virtual void Release() = 0;
82 
83     virtual ~OfflineAudioEffectChain() = default;
84 };
85 
86 class OfflineAudioEffectManager {
87 public:
88     /**
89      * @brief Get all offline audio effect chain names
90      *
91      * @return Returns all offline audio effect chains avalible.
92      * @since 15
93      */
94     std::vector<std::string> GetOfflineAudioEffectChains();
95 
96     /**
97      * @brief Creata an offline audio effect chain
98      *
99      * @return Returns offload audio effect chain with chainName provided, nullptr if failed
100      * @since 15
101      */
102     std::unique_ptr<OfflineAudioEffectChain> CreateOfflineAudioEffectChain(const std::string &chainName);
103 };
104 } // namespace AudioStandard
105 } // namespace OHOS
106 #endif // ST_AUDIO_SPATIALIZATION_MANAGER_H
107