• 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 Prepare the offline audio effect chain
39      *
40      * @return The result of the preparation, 0 for success, other for error code
41      * @since 15
42      */
43     virtual int32_t Prepare() = 0;
44 
45     /**
46      * @brief Get the size of the audio effect buffer
47      *
48      * @param inBufferSize Size of the input buffer
49      * @param outBufferSize Size of the output buffer
50      * @return The result of the retrieval, 0 for success, other for error code
51      * @since 15
52      */
53     virtual int32_t GetEffectBufferSize(uint32_t &inBufferSize, uint32_t &outBufferSize) = 0;
54 
55     /**
56      * @brief Process the audio data
57      *
58      * @param inBuffer Input audio data buffer
59      * @param inSize Size of the input audio data
60      * @param outBuffer Output audio data buffer
61      * @param outSize Size of the output audio data
62      * @return The result of processing, 0 for success, other for error code
63      * @since 15
64      */
65     virtual int32_t Process(uint8_t *inBuffer, int32_t inSize, uint8_t *outBuffer, int32_t outSize) = 0;
66 
67     /**
68      * @brief Release the resources of the audio effect chain
69      *
70      * @since 15
71      */
72     virtual void Release() = 0;
73 
74     virtual ~OfflineAudioEffectChain() = default;
75 };
76 
77 class OfflineAudioEffectManager {
78 public:
79     /**
80      * @brief Get all offline audio effect chain names
81      *
82      * @return Returns all offline audio effect chains avalible.
83      * @since 15
84      */
85     std::vector<std::string> GetOfflineAudioEffectChains();
86 
87     /**
88      * @brief Creata an offline audio effect chain
89      *
90      * @return Returns offload audio effect chain with chainName provided, nullptr if failed
91      * @since 15
92      */
93     std::unique_ptr<OfflineAudioEffectChain> CreateOfflineAudioEffectChain(const std::string &chainName);
94 };
95 } // namespace AudioStandard
96 } // namespace OHOS
97 #endif // ST_AUDIO_SPATIALIZATION_MANAGER_H
98