1 /*
2  * Copyright (c) 2023 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 POLICY_PROVIDER_STUB_H
17 #define POLICY_PROVIDER_STUB_H
18 
19 #include "i_policy_provider_ipc.h"
20 
21 namespace OHOS {
22 namespace AudioStandard {
23 class PolicyProviderStub : public IRemoteStub<IPolicyProviderIpc> {
24 public:
25     virtual ~PolicyProviderStub() = default;
26     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
27 private:
28     static bool CheckInterfaceToken(MessageParcel &data);
29 
30     int32_t HandleGetProcessDeviceInfo(MessageParcel &data, MessageParcel &reply);
31     int32_t HandleInitSharedVolume(MessageParcel &data, MessageParcel &reply);
32     int32_t HandleSetWakeupCapturer(MessageParcel &data, MessageParcel &reply);
33     int32_t HandleSetCapturer(MessageParcel &data, MessageParcel &reply);
34     int32_t HandleWakeupCapturerRemoved(MessageParcel &data, MessageParcel &reply);
35     int32_t HandleIsAbsVolumeSupported(MessageParcel &data, MessageParcel &reply);
36     int32_t HandleOffloadGetRenderPosition(MessageParcel &data, MessageParcel &reply);
37     int32_t HandleGetAndSaveClientType(MessageParcel &data, MessageParcel &reply);
38     int32_t HandleGetMaxRendererInstances(MessageParcel &data, MessageParcel &reply);
39     int32_t HandleConcurrencyFromServer(MessageParcel &data, MessageParcel &reply);
40 };
41 
42 class PolicyProviderWrapper : public PolicyProviderStub {
43 public:
44     ~PolicyProviderWrapper();
45     PolicyProviderWrapper(IPolicyProvider *policyWorker);
46 
47     int32_t GetProcessDeviceInfo(const AudioProcessConfig &config, bool lockFlag, DeviceInfo &deviceInfo) override;
48     int32_t InitSharedVolume(std::shared_ptr<AudioSharedMemory> &buffer) override;
49     int32_t SetWakeUpAudioCapturerFromAudioServer(const AudioProcessConfig &config) override;
50     int32_t NotifyCapturerAdded(AudioCapturerInfo capturerInfo, AudioStreamInfo streamInfo,
51         uint32_t sessionId) override;
52     int32_t NotifyWakeUpCapturerRemoved() override;
53     bool IsAbsVolumeSupported() override;
54     int32_t OffloadGetRenderPosition(uint32_t &delayValue, uint64_t &sendDataSize, uint32_t &timeStamp) override;
55     int32_t GetAndSaveClientType(uint32_t uid, const std::string &bundleName) override;
56     int32_t GetMaxRendererInstances() override;
57     int32_t ActivateConcurrencyFromServer(AudioPipeType incomingPipe) override;
58 private:
59     IPolicyProvider *policyWorker_;
60 };
61 } // namespace AudioStandard
62 } // namespace OHOS
63 #endif // POLICY_PROVIDER_STUB_H
64