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(bool stopFlag = false) = 0; 56 57 virtual int32_t UpdatePlaybackCaptureConfig(const AudioPlaybackCaptureConfig &config) = 0; 58 59 virtual int32_t GetAudioTime(uint64_t &framePos, uint64_t ×tamp) = 0; 60 61 virtual int32_t GetAudioPosition(uint64_t &framePos, uint64_t ×tamp, uint64_t &latency) = 0; 62 63 virtual int32_t GetLatency(uint64_t &latency) = 0; 64 65 virtual int32_t SetRate(int32_t rate) = 0; // SetRenderRate 66 67 virtual int32_t GetRate(int32_t &rate) = 0; // SetRenderRate 68 69 virtual int32_t SetLowPowerVolume(float volume) = 0; // renderer only 70 71 virtual int32_t GetLowPowerVolume(float &volume) = 0; // renderer only 72 73 virtual int32_t SetAudioEffectMode(int32_t effectMode) = 0; // renderer only 74 75 virtual int32_t GetAudioEffectMode(int32_t &effectMode) = 0; // renderer only 76 77 virtual int32_t SetPrivacyType(int32_t privacyType) = 0; // renderer only 78 79 virtual int32_t GetPrivacyType(int32_t &privacyType) = 0; // renderer only 80 81 virtual int32_t SetOffloadMode(int32_t state, bool isAppBack) = 0; // renderer only 82 83 virtual int32_t UnsetOffloadMode() = 0; // renderer only 84 85 virtual int32_t GetOffloadApproximatelyCacheTime(uint64_t ×tamp, uint64_t &paWriteIndex, 86 uint64_t &cacheTimeDsp, uint64_t &cacheTimePa) = 0; // renderer only 87 88 virtual int32_t UpdateSpatializationState(bool spatializationEnabled, bool headTrackingEnabled) = 0; // rendererOnly 89 90 virtual int32_t GetStreamManagerType() = 0; 91 92 virtual int32_t SetSilentModeAndMixWithOthers(bool on) = 0; 93 94 virtual int32_t SetClientVolume() = 0; 95 96 virtual int32_t SetMute(bool isMute) = 0; 97 98 virtual int32_t SetDuckFactor(float duckFactor) = 0; 99 100 virtual int32_t RegisterThreadPriority(uint32_t tid, const std::string &bundleName) = 0; 101 // IPC code. 102 enum IpcStreamMsg : uint32_t { 103 ON_REGISTER_STREAM_LISTENER = 0, 104 ON_RESOLVE_BUFFER, 105 ON_UPDATE_POSITION, 106 ON_GET_AUDIO_SESSIONID, 107 ON_START, 108 ON_PAUSE, 109 ON_STOP, 110 ON_RELEASE, 111 ON_FLUSH, 112 ON_DRAIN, 113 ON_UPDATA_PLAYBACK_CAPTURER_CONFIG, 114 OH_GET_AUDIO_TIME, 115 OH_GET_AUDIO_POSITION, 116 ON_GET_LATENCY, 117 ON_SET_RATE, 118 ON_GET_RATE, 119 ON_SET_LOWPOWER_VOLUME, 120 ON_GET_LOWPOWER_VOLUME, 121 ON_SET_EFFECT_MODE, 122 ON_GET_EFFECT_MODE, 123 ON_SET_PRIVACY_TYPE, 124 ON_GET_PRIVACY_TYPE, 125 ON_SET_OFFLOAD_MODE, 126 ON_UNSET_OFFLOAD_MODE, 127 ON_GET_OFFLOAD_APPROXIMATELY_CACHE_TIME, 128 ON_UPDATE_SPATIALIZATION_STATE, 129 ON_GET_STREAM_MANAGER_TYPE, 130 ON_SET_SILENT_MODE_AND_MIX_WITH_OTHERS, 131 ON_SET_CLIENT_VOLUME, 132 ON_SET_MUTE, 133 ON_SET_DUCK_FACTOR, 134 ON_REGISTER_THREAD_PRIORITY, 135 IPC_STREAM_MAX_MSG 136 }; 137 138 DECLARE_INTERFACE_DESCRIPTOR(u"IpcStream"); 139 }; 140 141 class IpcStreamListener : public IRemoteBroker, public IStreamListener { 142 public: 143 virtual ~IpcStreamListener() = default; 144 145 // IPC code. 146 enum IpcStreamListenerMsg : uint32_t { 147 ON_OPERATION_HANDLED = 0, 148 IPC_STREAM_LISTENER_MAX_MSG 149 }; 150 DECLARE_INTERFACE_DESCRIPTOR(u"IpcStreamListener"); 151 }; 152 } // namespace AudioStandard 153 } // namespace OHOS 154 #endif // IPC_STREAM_H 155