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_AAC_DECODER_PLUGIN_H
17 #define AUDIO_FFMPEG_AAC_DECODER_PLUGIN_H
18 
19 #include "audio_base_codec.h"
20 #include "audio_ffmpeg_decoder_plugin.h"
21 #include "avcodec_codec_name.h"
22 
23 namespace OHOS {
24 namespace MediaAVCodec {
25 class AudioFFMpegAacDecoderPlugin : public AudioBaseCodec::CodecRegister<AudioFFMpegAacDecoderPlugin> {
26 public:
27     AudioFFMpegAacDecoderPlugin();
28     ~AudioFFMpegAacDecoderPlugin() 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;
Identify()40     const static std::string Identify()
41     {
42         return std::string(AVCodecCodecName::AUDIO_DECODER_AAC_NAME);
43     }
44 
45 private:
46     std::unique_ptr<AudioFfmpegDecoderPlugin> basePlugin;
47     std::string aacName_;
48     int32_t channels_;
49 
50 private:
51     bool CheckAdts(const Format &format);
52     bool CheckSampleFormat(const Format &format);
53     bool CheckFormat(const Format &format);
54     bool CheckChannelCount(const Format &format);
55     bool CheckSampleRate(const Format &format) const;
56 };
57 } // namespace MediaAVCodec
58 } // namespace OHOS
59 #endif