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_CAPTURER_FILE_SOURCE_H 17 #define AUDIO_CAPTURER_FILE_SOURCE_H 18 19 #include <cstdint> 20 #include <cstdio> 21 #include "i_audio_capturer_source.h" 22 23 namespace OHOS { 24 namespace AudioStandard { 25 class AudioCapturerFileSource : public IAudioCapturerSource { 26 public: 27 AudioCapturerFileSource(); 28 ~AudioCapturerFileSource(); 29 int32_t Init(const IAudioSourceAttr &attr) override; 30 bool IsInited(void) override; 31 void DeInit(void) override; 32 33 int32_t Start(void) override; 34 int32_t Stop(void) override; 35 int32_t Flush(void) override; 36 int32_t Reset(void) override; 37 int32_t Pause(void) override; 38 int32_t Resume(void) override; 39 int32_t CaptureFrame(char *frame, uint64_t requestBytes, uint64_t &replyBytes) override; 40 int32_t CaptureFrameWithEc( 41 FrameDesc *fdesc, uint64_t &replyBytes, 42 FrameDesc *fdescEc, uint64_t &replyBytesEc) override; 43 int32_t SetVolume(float left, float right) override; 44 int32_t GetVolume(float &left, float &right) override; 45 int32_t SetMute(bool isMute) override; 46 int32_t GetMute(bool &isMute) override; 47 int32_t SetAudioScene(AudioScene audioScene, DeviceType activeDevice, const std::string &deviceName = "") override; 48 int32_t SetInputRoute(DeviceType deviceType, const std::string &deviceName = "") override; 49 uint64_t GetTransactionId() override; 50 int32_t GetPresentationPosition(uint64_t& frames, int64_t& timeSec, int64_t& timeNanoSec) override; 51 std::string GetAudioParameter(const AudioParamKey key, const std::string &condition) override; 52 void RegisterWakeupCloseCallback(IAudioSourceCallback *callback) override; 53 void RegisterAudioCapturerSourceCallback(std::unique_ptr<ICapturerStateCallback> callback) override; 54 void RegisterParameterCallback(IAudioSourceCallback *callback) override; 55 float GetMaxAmplitude() override; 56 int32_t GetCaptureId(uint32_t &captureId) const override; 57 58 int32_t UpdateAppsUid(const int32_t appsUid[PA_MAX_OUTPUTS_PER_SOURCE], const size_t size) final; 59 int32_t UpdateAppsUid(const std::vector<int32_t> &appsUid) final; 60 private: 61 bool capturerInited_ = false; 62 FILE *filePtr = nullptr; 63 }; 64 } // namespace AudioStandard 65 } // namespace OHOS 66 #endif // AUDIO_CAPTURER_FILE_SOURCE_H 67