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 
16 #ifndef OFFLINE_STREAM_IN_SERVER_H
17 #define OFFLINE_STREAM_IN_SERVER_H
18 
19 #include <memory>
20 
21 #include "ipc_offline_stream_stub.h"
22 #include "offline_audio_effect_server_chain.h"
23 #include "audio_info.h"
24 
25 namespace OHOS {
26 namespace AudioStandard {
27 class OfflineStreamInServer : public IpcOfflineStreamStub {
28 public:
29     static sptr<OfflineStreamInServer> GetOfflineStream(int32_t &errCode);
30     static int32_t GetOfflineAudioEffectChains(std::vector<std::string> &effectChains);
31 
32     int32_t CreateOfflineEffectChain(const std::string &chainName) override;
33 
34     int32_t ConfigureOfflineEffectChain(const AudioStreamInfo &inInfo, const AudioStreamInfo &outInfo) override;
35 
36     int32_t PrepareOfflineEffectChain(std::shared_ptr<AudioSharedMemory> &inBuffer,
37         std::shared_ptr<AudioSharedMemory> &outBuffer) override;
38 
39     int32_t ProcessOfflineEffectChain(uint32_t inSize, uint32_t outSize) override;
40 
41     void ReleaseOfflineEffectChain() override;
42 
43     OfflineStreamInServer() = default;
44     ~OfflineStreamInServer() = default;
45 private:
46     int32_t AllocSharedMemory(uint32_t inSize, uint32_t outSize);
47     std::shared_ptr<AudioSharedMemory> serverBufferIn_;
48     std::shared_ptr<AudioSharedMemory> serverBufferOut_;
49     std::shared_ptr<OfflineAudioEffectServerChain> effectChain_;
50 };
51 } // namespace AudioStandard
52 } // namespace OHOS
53 #endif // OFFLINE_STREAM_IN_SERVER_H
54