1 /* 2 * Copyright (c) 2022 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 HDF_I_AUDIO_ADAPTER_H 17 #define HDF_I_AUDIO_ADAPTER_H 18 19 #include <string> 20 #include <vector> 21 22 #include "i_audio_capture.h" 23 #include "i_audio_render.h" 24 #include "i_audio_param_callback.h" 25 #include "types.h" 26 27 namespace OHOS { 28 namespace DistributedHardware { 29 using RenderHandle = uint64_t; 30 using CaptureHandle = uint64_t; 31 using RouteHandle = int32_t; 32 33 class IAudioAdapter { 34 public: 35 virtual int32_t InitAllPorts() = 0; 36 37 virtual int32_t CreateRender(const AudioDeviceDescriptorHAL &desc, const AudioSampleAttributesHAL &attrs, 38 RenderHandle &handle, IAudioRender &render) = 0; 39 40 virtual int32_t DestoryRender(const RenderHandle handle) = 0; 41 42 virtual int32_t CreateCapture(const AudioDeviceDescriptorHAL &desc, const AudioSampleAttributesHAL &attrs, 43 CaptureHandle &handle, IAudioCapture &capture) = 0; 44 45 virtual int32_t DestoryCapture(const CaptureHandle handle) = 0; 46 47 virtual int32_t GetPortCapability(const AudioPortHAL &port, AudioPortCapabilityHAL &capability) = 0; 48 49 virtual int32_t SetPassthroughMode(const AudioPortHAL &port, const AudioPortPassthroughModeHAL mode) = 0; 50 51 virtual int32_t GetPassthroughMode(const AudioPortHAL &port, AudioPortPassthroughModeHAL &mode) = 0; 52 53 virtual int32_t UpdateAudioRoute(const AudioRouteHAL &route, RouteHandle &handle) = 0; 54 55 virtual int32_t ReleaseAudioRoute(const RouteHandle handle) = 0; 56 57 virtual int32_t SetAudioParameters(const std::vector<AudioParameter> ¶m) = 0; 58 59 virtual int32_t GetAudioParameters(std::vector<AudioParameter> ¶m) = 0; 60 61 virtual int32_t RegAudioParamObserver(IAudioParamCallback &cbObj) = 0; 62 }; 63 } // namespace DistributedHardware 64 } // namespace OHOS 65 #endif // HDF_I_AUDIO_ADAPTER_H