1 /* 2 * Copyright (c) 2021-2022 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 "audio_info.h" 25 #include "i_audio_renderer_sink.h" 26 27 namespace OHOS { 28 namespace AudioStandard { 29 class AudioRendererFileSink : public IAudioRendererSink { 30 public: 31 static AudioRendererFileSink *GetInstance(void); 32 33 int32_t Init(const IAudioSinkAttr &attr) override; 34 bool IsInited(void) override; 35 void DeInit(void) override; 36 37 int32_t Start(void) override; 38 int32_t Stop(void) override; 39 int32_t Flush(void) override; 40 int32_t Reset(void) override; 41 int32_t Pause(void) override; 42 int32_t Resume(void) override; 43 int32_t SuspendRenderSink(void) override; 44 int32_t RestoreRenderSink(void) override; 45 int32_t RenderFrame(char &data, uint64_t len, uint64_t &writeLen) override; 46 int32_t SetVolume(float left, float right) override; 47 int32_t GetLatency(uint32_t *latency) override; 48 int32_t GetTransactionId(uint64_t *transactionId) override; 49 50 int32_t GetVolume(float &left, float &right) override; 51 int32_t SetVoiceVolume(float volume) override; 52 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 RegisterParameterCallback(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 private: 73 AudioRendererFileSink(); 74 ~AudioRendererFileSink(); 75 FILE *filePtr_ = nullptr; 76 std::string filePath_; 77 }; 78 } // namespace AudioStandard 79 } // namespace OHOS 80 #endif // AUDIO_RENDERER_FILE_SINK_H 81