• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 AUDIO_RENDERER_FILE_SINK_H
17 #define AUDIO_RENDERER_FILE_SINK_H
18 
19 #include <cstdio>
20 #include <list>
21 #include <iostream>
22 #include <string>
23 
24 #include "i_audio_renderer_sink.h"
25 
26 namespace OHOS {
27 namespace AudioStandard {
28 class AudioRendererFileSink  : public IAudioRendererSink {
29 public:
30     static AudioRendererFileSink *GetInstance(void);
31 
32     int32_t Init(const IAudioSinkAttr &attr) override;
33     bool IsInited(void) override;
34     void DeInit(void) override;
35 
36     int32_t Start(void) override;
37     int32_t Stop(void) override;
38     int32_t Flush(void) override;
39     int32_t Reset(void) override;
40     int32_t Pause(void) override;
41     int32_t Resume(void) override;
42     int32_t SuspendRenderSink(void) override;
43     int32_t RestoreRenderSink(void) override;
44     int32_t RenderFrame(char &data, uint64_t len, uint64_t &writeLen) override;
45     int32_t SetVolume(float left, float right) override;
46     int32_t GetLatency(uint32_t *latency) override;
47     int32_t GetTransactionId(uint64_t *transactionId) override;
48 
49     int32_t GetVolume(float &left, float &right) override;
50     int32_t SetVoiceVolume(float volume) override;
51 
52     int32_t GetAudioScene() override;
53     int32_t SetAudioScene(AudioScene audioScene, std::vector<DeviceType> &activeDevices) override;
54     int32_t SetOutputRoutes(std::vector<DeviceType> &outputDevices) override;
55 
56     void SetAudioParameter(const AudioParamKey key, const std::string &condition, const std::string &value) override;
57     std::string GetAudioParameter(const AudioParamKey key, const std::string &condition) override;
58     void RegisterAudioSinkCallback(IAudioSinkCallback* callback) override;
59 
60     void SetAudioMonoState(bool audioMono) override;
61     void SetAudioBalanceValue(float audioBalance) override;
62     int32_t GetPresentationPosition(uint64_t& frames, int64_t& timeSec, int64_t& timeNanoSec) override;
63 
64     void ResetOutputRouteForDisconnect(DeviceType device) override;
65 
66     float GetMaxAmplitude() override;
67     int32_t SetPaPower(int32_t flag) override;
68     int32_t SetPriPaPower() override;
69 
70     int32_t UpdateAppsUid(const int32_t appsUid[MAX_MIX_CHANNELS], const size_t size) final;
71     int32_t UpdateAppsUid(const std::vector<int32_t> &appsUid) final;
72     int32_t GetRenderId(uint32_t &renderId) const override;
73 private:
74     AudioRendererFileSink();
75     ~AudioRendererFileSink();
76     FILE *filePtr_ = nullptr;
77     std::string filePath_;
78 };
79 }  // namespace AudioStandard
80 }  // namespace OHOS
81 #endif // AUDIO_RENDERER_FILE_SINK_H
82