1 /* 2 * Copyright (c) 2020-2021 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 RECORDER_AUDIO_SOURCE_H 17 #define RECORDER_AUDIO_SOURCE_H 18 19 #include <memory> 20 #include <map> 21 #include <string> 22 #include "format.h" 23 #include "media_errors.h" 24 #include "media_info.h" 25 #include "recorder_source.h" 26 #include "audio_capturer_impl.h" 27 28 namespace OHOS { 29 namespace Media { 30 using namespace OHOS::Audio; 31 32 class RecorderAudioSource : public RecorderSource { 33 public: 34 35 RecorderAudioSource(); 36 virtual ~RecorderAudioSource(); 37 38 int32_t Init(const RecorderAudioSourceConfig &sourceConfig); 39 40 virtual int32_t Start() override; 41 42 virtual int32_t AcquireBuffer(RecorderSourceBuffer &buffer, bool isBlocking) override; 43 44 virtual int32_t ReleaseBuffer(RecorderSourceBuffer &buffer) override; 45 46 virtual int32_t Stop() override; 47 48 virtual int32_t Resume() override; 49 50 virtual int32_t Pause() override; 51 52 virtual int32_t Release() override; 53 54 private: 55 std::unique_ptr<AudioCapturerImpl> audioCap_; 56 uint32_t framesize_; 57 uint8_t *buffer_; 58 uint64_t frameSeq_; 59 }; 60 } // namespace Media 61 } // namespace OHOS 62 #endif // RECORDER_AUDIO_SOURCE_H 63