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 I_RENDERER_STREAM_H 17 #define I_RENDERER_STREAM_H 18 19 #include "i_stream.h" 20 #include "audio_info.h" 21 #include "audio_stream_info.h" 22 23 namespace OHOS { 24 namespace AudioStandard { 25 class IWriteCallback { 26 public: 27 virtual int32_t OnWriteData(size_t length) = 0; 28 }; 29 30 class IRendererStream : public IStream { 31 public: 32 virtual ~IRendererStream() = default; 33 virtual int32_t GetStreamFramesWritten(uint64_t &framesWritten) = 0; 34 virtual int32_t GetCurrentTimeStamp(uint64_t ×tamp) = 0; 35 virtual int32_t GetCurrentPosition(uint64_t &framePosition, uint64_t ×tamp, uint64_t &latency); 36 virtual int32_t GetLatency(uint64_t &latency) = 0; 37 virtual int32_t SetRate(int32_t rate) = 0; 38 virtual int32_t SetAudioEffectMode(int32_t effectMode) = 0; 39 virtual int32_t GetAudioEffectMode(int32_t &effectMode) = 0; 40 virtual int32_t SetPrivacyType(int32_t privacyType) = 0; 41 virtual int32_t GetPrivacyType(int32_t &privacyType) = 0; 42 43 virtual void RegisterWriteCallback(const std::weak_ptr<IWriteCallback> &callback) = 0; 44 virtual int32_t GetMinimumBufferSize(size_t &minBufferSize) const = 0; 45 virtual void GetByteSizePerFrame(size_t &byteSizePerFrame) const = 0; 46 virtual void GetSpanSizePerFrame(size_t &spanSizeInFrame) const = 0; 47 virtual void AbortCallback(int32_t abortTimes) = 0; 48 49 virtual int32_t SetOffloadMode(int32_t state, bool isAppBack) = 0; 50 virtual int32_t UnsetOffloadMode() = 0; 51 virtual int32_t GetOffloadApproximatelyCacheTime(uint64_t ×tamp, uint64_t &paWriteIndex, 52 uint64_t &cacheTimeDsp, uint64_t &cacheTimePa) = 0; 53 virtual int32_t OffloadSetVolume(float volume) = 0; 54 virtual size_t GetWritableSize() = 0; 55 virtual int32_t UpdateSpatializationState(bool spatializationEnabled, bool headTrackingEnabled) = 0; 56 virtual int32_t UpdateMaxLength(uint32_t maxLength) = 0; 57 58 virtual int32_t Peek(std::vector<char> *audioBuffer, int32_t &index) = 0; 59 virtual int32_t ReturnIndex(int32_t index) = 0; 60 virtual AudioProcessConfig GetAudioProcessConfig() const noexcept = 0; 61 virtual int32_t SetClientVolume(float clientVolume) = 0; 62 }; 63 } // namespace AudioStandard 64 } // namespace OHOS 65 #endif // I_RENDERER_STREAM_H 66