1 /* 2 * Copyright (c) 2023-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 I_AUDIO_PROCESS_H 17 #define I_AUDIO_PROCESS_H 18 19 #include <memory> 20 21 #include "ipc_types.h" 22 #include "iremote_broker.h" 23 #include "iremote_proxy.h" 24 #include "iremote_stub.h" 25 26 #include "audio_process_config.h" 27 #include "oh_audio_buffer.h" 28 29 namespace OHOS { 30 namespace AudioStandard { 31 class AudioProcess { 32 public: 33 virtual int32_t ResolveBuffer(std::shared_ptr<OHAudioBuffer> &buffer) = 0; 34 35 virtual int32_t GetSessionId(uint32_t &sessionId) = 0; 36 37 virtual int32_t Start() = 0; 38 39 virtual int32_t Pause(bool isFlush) = 0; 40 41 virtual int32_t Resume() = 0; 42 43 virtual int32_t Stop() = 0; 44 45 virtual int32_t RequestHandleInfo(bool isAync = true) = 0; 46 47 virtual int32_t Release(bool isSwitchStream = false) = 0; 48 49 virtual int32_t SetDefaultOutputDevice(const DeviceType defaultOutputDevice) = 0; 50 51 virtual int32_t SetSilentModeAndMixWithOthers(bool on) = 0; 52 53 virtual int32_t SetSourceDuration(int64_t duration) = 0; 54 55 virtual int32_t SetUnderrunCount(uint32_t underrunCnt) = 0; 56 57 virtual ~AudioProcess() = default; 58 }; 59 60 class IProcessCb : public IRemoteBroker { 61 public: 62 virtual ~IProcessCb() = default; 63 64 virtual int32_t OnEndpointChange(int32_t status) = 0; 65 66 // IPC code. 67 enum IProcessCbMsg : uint32_t { 68 ON_ENDPOINT_CHANGE = 0, 69 PROCESS_CB_MAX_MSG 70 }; 71 DECLARE_INTERFACE_DESCRIPTOR(u"IProcessCb"); 72 }; 73 74 class IAudioProcess : public AudioProcess, public IRemoteBroker { 75 public: 76 virtual ~IAudioProcess() = default; 77 78 virtual int32_t RegisterProcessCb(sptr<IRemoteObject> object) = 0; 79 virtual int32_t RegisterThreadPriority(uint32_t tid, const std::string &bundleName) = 0; 80 81 // IPC code. 82 enum IAudioProcessMsg : uint32_t { 83 ON_RESOLVE_BUFFER = 0, 84 OH_GET_SESSIONID, 85 ON_START, 86 ON_PAUSE, 87 ON_RESUME, 88 ON_STOP, 89 ON_REQUEST_HANDLE_INFO, 90 ON_RELEASE, 91 ON_REGISTER_PROCESS_CB, 92 ON_REGISTER_THREAD_PRIORITY, 93 ON_SET_DEFAULT_OUTPUT_DEVICE, 94 ON_SET_SLITNT_MODE_AND_MIX_WITH_OTHERS, 95 ON_SET_SOURCE_DURATION, 96 ON_SET_UNDERRUN_CNT, 97 PROCESS_MAX_MSG 98 }; 99 100 DECLARE_INTERFACE_DESCRIPTOR(u"IAudioProcess"); 101 }; 102 } // namespace AudioStandard 103 } // namespace OHOS 104 #endif // I_AUDIO_PROCESS_H 105