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 IPC_STREAM_H 17 #define IPC_STREAM_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_info.h" 27 #include "audio_process_config.h" 28 #include "i_stream_listener.h" 29 #include "oh_audio_buffer.h" 30 31 namespace OHOS { 32 namespace AudioStandard { 33 class IpcStream : public IRemoteBroker { 34 public: 35 virtual ~IpcStream() = default; 36 37 virtual int32_t RegisterStreamListener(sptr<IRemoteObject> object) = 0; 38 39 virtual int32_t ResolveBuffer(std::shared_ptr<OHAudioBuffer> &buffer) = 0; 40 41 virtual int32_t UpdatePosition() = 0; 42 43 virtual int32_t GetAudioSessionID(uint32_t &sessionId) = 0; 44 45 virtual int32_t Start() = 0; 46 47 virtual int32_t Pause() = 0; 48 49 virtual int32_t Stop() = 0; 50 51 virtual int32_t Release() = 0; 52 53 virtual int32_t Flush() = 0; 54 55 virtual int32_t Drain() = 0; 56 57 virtual int32_t GetAudioTime(uint64_t &framePos, uint64_t &timeStamp) = 0; 58 59 virtual int32_t GetLatency(uint64_t &latency) = 0; 60 61 virtual int32_t SetRate(int32_t rate) = 0; // SetRenderRate 62 63 virtual int32_t GetRate(int32_t &rate) = 0; // SetRenderRate 64 65 virtual int32_t SetLowPowerVolume(float volume) = 0; // renderer only 66 67 virtual int32_t GetLowPowerVolume(float &volume) = 0; // renderer only 68 69 virtual int32_t SetAudioEffectMode(int32_t effectMode) = 0; // renderer only 70 71 virtual int32_t GetAudioEffectMode(int32_t &effectMode) = 0; // renderer only 72 73 virtual int32_t SetPrivacyType(int32_t privacyType) = 0; // renderer only 74 75 virtual int32_t GetPrivacyType(int32_t &privacyType) = 0; // renderer only 76 77 virtual int32_t SetOffloadMode(int32_t state, bool isAppBack) = 0; // renderer only 78 79 virtual int32_t UnsetOffloadMode() = 0; // renderer only 80 81 virtual int32_t GetOffloadApproximatelyCacheTime(uint64_t &timeStamp, uint64_t &paWriteIndex, 82 uint64_t &cacheTimeDsp, uint64_t &cacheTimePa) = 0; // renderer only 83 84 virtual int32_t OffloadSetVolume(float volume) = 0; // renderer only 85 86 // IPC code. 87 enum IpcStreamMsg : uint32_t { 88 ON_REGISTER_STREAM_LISTENER = 0, 89 ON_RESOLVE_BUFFER, 90 ON_UPDATE_POSITION, 91 ON_GET_AUDIO_SESSIONID, 92 ON_START, 93 ON_PAUSE, 94 ON_STOP, 95 ON_RELEASE, 96 ON_FLUSH, 97 ON_DRAIN, 98 OH_GET_AUDIO_TIME, 99 ON_GET_LATENCY, 100 ON_SET_RATE, 101 ON_GET_RATE, 102 ON_SET_LOWPOWER_VOLUME, 103 ON_GET_LOWPOWER_VOLUME, 104 ON_SET_EFFECT_MODE, 105 ON_GET_EFFECT_MODE, 106 ON_SET_PRIVACY_TYPE, 107 ON_GET_PRIVACY_TYPE, 108 ON_SET_OFFLOAD_MODE, 109 ON_UNSET_OFFLOAD_MODE, 110 ON_GET_OFFLOAD_APPROXIMATELY_CACHE_TIME, 111 ON_SET_OFFLOAD_VOLUME, 112 IPC_STREAM_MAX_MSG 113 }; 114 115 DECLARE_INTERFACE_DESCRIPTOR(u"IpcStream"); 116 }; 117 118 class IpcStreamListener : public IRemoteBroker, public IStreamListener { 119 public: 120 virtual ~IpcStreamListener() = default; 121 122 // IPC code. 123 enum IpcStreamListenerMsg : uint32_t { 124 ON_OPERATION_HANDLED = 0, 125 IPC_STREAM_LISTENER_MAX_MSG 126 }; 127 DECLARE_INTERFACE_DESCRIPTOR(u"IpcStreamListener"); 128 }; 129 } // namespace AudioStandard 130 } // namespace OHOS 131 #endif // IPC_STREAM_H 132