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 OFFLINE_STREAM_IN_CLIENT_H
16 #define OFFLINE_STREAM_IN_CLIENT_H
17 
18 #include <cstdint>
19 #include <string>
20 #include <vector>
21 
22 #include "audio_info.h"
23 #include "audio_shared_memory.h"
24 #include "ipc_offline_stream.h"
25 
26 namespace OHOS {
27 namespace AudioStandard {
28 class OfflineStreamInClient {
29 public:
30     static int32_t GetOfflineAudioEffectChains(std::vector<std::string> &effectChains);
31     static std::shared_ptr<OfflineStreamInClient> Create();
32 
33     OfflineStreamInClient(const sptr<IpcOfflineStream> &ipcProxy);
34     ~OfflineStreamInClient() = default;
35 
36     /**
37      * @brief Create the offline audio effect chain
38      *
39      * @param chainName Audio effect chain name
40      * @return The result of construction, 0 for success, other for error code
41      * @since 15
42      */
43     int32_t CreateOfflineEffectChain(const std::string &chainName);
44 
45     /**
46      * @brief Configure the offline audio effect chain
47      *
48      * @param inInfo Input audio stream information
49      * @param outInfo Output audio stream information
50      * @return The result of configuration, 0 for success, other for error code
51      * @since 15
52      */
53     int32_t ConfigureOfflineEffectChain(const AudioStreamInfo &inInfo, const AudioStreamInfo &outInfo);
54 
55     /**
56      * @brief Prepare the offline audio effect chain
57      *
58      * @param bufIn Input audio sharedmemory buffer
59      * @param bufOut Output audio sharedmemory buffer
60      * @return The result of preparation, 0 for success, other for error code
61      * @since 15
62      */
63     int32_t PrepareOfflineEffectChain(std::shared_ptr<AudioSharedMemory> &bufIn,
64         std::shared_ptr<AudioSharedMemory> &bufOut);
65 
66     /**
67      * @brief Process the offline audio effect chain
68      *
69      * @param inSize Size of input audio data in sharedmemory
70      * @param outSize Size of output audio data in sharedmemory
71      * @return The result of processing, 0 for success, other for error code
72      * @since 15
73      */
74     int32_t ProcessOfflineEffectChain(uint32_t inSize, uint32_t outSize);
75 
76     /**
77      * @brief Release the offline audio effect chain
78      *
79      * @since 15
80      */
81     void ReleaseOfflineEffectChain();
82 private:
83     sptr<IpcOfflineStream> streamProxy_ = nullptr;
84 };
85 } // namespace AudioStandard
86 } // namespace OHOS
87 #endif // OFFLINE_STREAM_IN_CLIENT_H
88