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