1 /* 2 * Copyright (c) 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 FILE_AUDIO_CAPTURE_SOURCE_H 17 #define FILE_AUDIO_CAPTURE_SOURCE_H 18 19 #include "source/i_audio_capture_source.h" 20 #include <iostream> 21 #include <cstring> 22 23 namespace OHOS { 24 namespace AudioStandard { 25 class FileAudioCaptureSource : public IAudioCaptureSource { 26 public: 27 FileAudioCaptureSource() = default; 28 ~FileAudioCaptureSource(); 29 30 int32_t Init(const IAudioSourceAttr &attr) override; 31 void DeInit(void) override; 32 bool IsInited(void) override; 33 34 int32_t Start(void) override; 35 int32_t Stop(void) override; 36 int32_t Resume(void) override; 37 int32_t Pause(void) override; 38 int32_t Flush(void) override; 39 int32_t Reset(void) override; 40 int32_t CaptureFrame(char *frame, uint64_t requestBytes, uint64_t &replyBytes) override; 41 int32_t CaptureFrameWithEc(FrameDesc *fdesc, uint64_t &replyBytes, FrameDesc *fdescEc, 42 uint64_t &replyBytesEc) override; 43 44 std::string GetAudioParameter(const AudioParamKey key, const std::string &condition) override; 45 46 int32_t SetVolume(float left, float right) override; 47 int32_t GetVolume(float &left, float &right) override; 48 int32_t SetMute(bool isMute) override; 49 int32_t GetMute(bool &isMute) override; 50 51 uint64_t GetTransactionId(void) override; 52 int32_t GetPresentationPosition(uint64_t &frames, int64_t &timeSec, int64_t &timeNanoSec) override; 53 float GetMaxAmplitude(void) override; 54 55 int32_t SetAudioScene(AudioScene audioScene, DeviceType activeDevice) override; 56 57 int32_t UpdateActiveDevice(DeviceType inputDevice) override; 58 59 int32_t UpdateAppsUid(const int32_t appsUid[PA_MAX_OUTPUTS_PER_SOURCE], const size_t size) final; 60 int32_t UpdateAppsUid(const std::vector<int32_t> &appsUid) final; 61 62 void DumpInfo(std::string &dumpString) override; 63 64 private: 65 bool sourceInited_ = false; 66 FILE *file_ = nullptr; 67 }; 68 69 } // namespace AudioStandard 70 } // namespace OHOS 71 72 #endif // FILE_AUDIO_CAPTURE_SOURCE_H 73