• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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_FFMPEG_FLAC_ENCODER_PLUGIN_H
17 #define AUDIO_FFMPEG_FLAC_ENCODER_PLUGIN_H
18 
19 #include "audio_base_codec.h"
20 #include "audio_ffmpeg_encoder_plugin.h"
21 #include "avcodec_codec_name.h"
22 
23 namespace OHOS {
24 namespace MediaAVCodec {
25 class AudioFFMpegFlacEncoderPlugin : public AudioBaseCodec::CodecRegister<AudioFFMpegFlacEncoderPlugin> {
26 public:
27     AudioFFMpegFlacEncoderPlugin();
28     ~AudioFFMpegFlacEncoderPlugin() override;
29 
30     int32_t Init(const Format &format) override;
31     int32_t ProcessSendData(const std::shared_ptr<AudioBufferInfo> &inputBuffer) override;
32     int32_t ProcessRecieveData(std::shared_ptr<AudioBufferInfo> &outBuffer) override;
33     int32_t Reset() override;
34     int32_t Release() override;
35     int32_t Flush() override;
36     int32_t GetInputBufferSize() const override;
37     int32_t GetOutputBufferSize() const override;
38     Format GetFormat() const noexcept override;
39     std::string_view GetCodecType() const noexcept override;
40 
Identify()41     const static std::string Identify()
42     {
43         return std::string(AVCodecCodecName::AUDIO_ENCODER_FLAC_NAME);
44     }
45 
46 private:
47     int32_t CheckFormat(const Format &format);
48     bool CheckBitRate(const Format &format) const;
49     int32_t SetContext(const Format &format);
50     void SetFormat(const Format &format) noexcept;
51     int32_t channels;
52     std::unique_ptr<AudioFfmpegEncoderPlugin> basePlugin;
53     Format format_;
54 };
55 } // namespace MediaAVCodec
56 } // namespace OHOS
57 #endif